
Javoblar:
0001
print(sum(map(int, input().split())))
0002
a,b=map(int, input().split())
if a==b:
print("=")
elif a<b:
print("<")
else :
print(">")
0003
a=int(input())
b=int(input())
s=a+b
print(s)

4-7

8-11

12-15

16-19

20 - 23

24-27

28 - 31
034
python 3.12
a,b=map(int,input().split())
k=pow(2,a)
p=pow(2,k,b)
print(p)
036
python 3.12
def jadval(satr, ustun):
if satr==1 and ustun==1: return 0
start=1
while start<=satr:
start*=2
start//=2
r=start-ustun
if r>=0:
nat=ustun * start * (start-1)//2
else:
nat=start * start*(start-1)//2
nat+=-r * (start * (start-1)//2+start*start)
if start==satr: return nat
n=ustun
m=satr-start
if n>start:
nat+=start*m*start
nat+=jadval(start,m)
n-=start;
if n<m:
nat+=jadval(m,n)
else:
nat+=jadval(n,m)
else:
nat+=start*n*m;
if n<m:
nat+=jadval(m,n)
else:
nat+=jadval(n,m)
return nat;
n,m=eval(','.join(input().split()))
if n<m:
nat=jadval(m+1, n+1)
else:
nat=jadval(n+1, m+1)
print(nat)
38
python 3.12
from decimal import*
WH_butun_S = Decimal(0)
WH_B_romp_S = Decimal(0)
j_t_romp_S = Decimal(0)
S = Decimal(0)
w,h,d=map(float,input().split())
def b_romps_S(w,h,d):
romp_B_S = d * (d / 2)
WH_B_romp_S = ( (w // d) * (h // d) ) * romp_B_S
return WH_B_romp_S;
def q_rompsW_orH_S(w,h,d):
q_romp_x = w - ( d * ( w // d ) )
if q_romp_x <= (d / 2):
q_bitta_rS = ( ( q_romp_x * 2 ) * q_romp_x ) / 2
else:
q_bitta_rS = ( d * ( d / 2 ) ) / 2
q_bitta_rS += q_bitta_rS - ( ( ( ( d - q_romp_x ) * 2 ) * ( d - q_romp_x ) ) / 2 )
j_t_romp_S = ( h // d ) * q_bitta_rS
return j_t_romp_S;
def noqulay_sh(w,h,d):
S=Decimal(0)
q_sh_w = w - ( ( w // d ) * d )
q_sh_h = h - ( ( h // d ) * d )
if ( d / 2 ) < q_sh_h and ( d / 2 ) < q_sh_w:
if ( q_sh_w - ( d / 2 ) ) + ( q_sh_h - ( d / 2 ) ) >= ( d / 2):
S1 = ( ( ( d - q_sh_h ) * 2 ) * ( d - q_sh_h ) ) / 2
S2 = ( ( ( d - q_sh_w ) * 2 ) * ( d - q_sh_w ) ) / 2
S = ( d * ( d / 2) ) - S1 -S2
else:
S1 = ( (q_sh_h - ( d / 2 ) ) * ( q_sh_w ) ) - ( ( (q_sh_h - ( d / 2 )) * (q_sh_h - ( d / 2 ) ) ) / 2 )
S2 = ( ( q_sh_w - ( d / 2) ) ) * ( d / 2 ) - ( ( ( q_sh_w - ( d / 2) ) * ( q_sh_w - ( d / 2) ) ) / 2 )
S3 = ( ( d / 2 ) * ( d / 2 ) ) / 2
S = S1 + S2 + S3
elif ( q_sh_w < ( d / 2 ) ) and ( q_sh_h < ( d / 2 ) ):
if ( ( d / 2 ) - q_sh_w ) + ( (d / 2 ) - q_sh_h) >= ( d / 2 ):
S = 0
else:
S_l = q_sh_w - ( ( d / 2 ) - q_sh_h )
S = ( S_l * S_l ) / 2
elif ( q_sh_w > ( d / 2 ) ) and ( q_sh_h < ( d / 2) ):
if ( q_sh_w - ( d / 2 ) ) + ((d / 2 ) - q_sh_h ) > ( d / 2 ):
S = ( ( q_sh_h * 2 ) * q_sh_h ) / 2
else:
S1 = ( ( q_sh_w - ( d / 2 ) ) * q_sh_h ) - ( ( (q_sh_w - ( d / 2 ) ) * ( q_sh_w - ( d / 2 ) ) ) / 2 )
S2 = ( q_sh_h * q_sh_h ) / 2
S = S1 + S2
elif ( q_sh_w < ( d / 2 ) ) and ( q_sh_h > ( d / 2 ) ):
if ( ( q_sh_h - ( d / 2 ) ) + ( (d / 2 ) - q_sh_w ) ) > ( d / 2 ):
S = ( ( q_sh_w * 2 ) * q_sh_w ) / 2
else:
S1 = ( ( q_sh_h - ( d / 2 ) ) * ( q_sh_w ) ) - ( ( ( q_sh_h - ( d / 2 ) ) * ( q_sh_h - ( d / 2 ) ) ) / 2 )
S2 = ( q_sh_w * q_sh_w ) / 2
S = S1 + S2
elif q_sh_w == ( d / 2 ) and q_sh_h == ( d / 2 ):
S = ( q_sh_w * q_sh_w ) / 2
return S;
if w % d == 0 and h % d == 0:
print("%.4f" % (b_romps_S(w,h,d)))
elif w % d != 0 and h % d == 0:
print("%.4f" % ( b_romps_S(w, h, d) + q_rompsW_orH_S(w, h, d ) ) )
elif w % d == 0 and h % d != 0:
print("%.4f" % ( b_romps_S(w, h, d) + q_rompsW_orH_S(h, w, d ) ) )
else:
print("%.4f" % ( b_romps_S(w, h, d) + q_rompsW_orH_S(h, w, d ) + q_rompsW_orH_S(w, h, d ) + noqulay_sh(w,h,d) ))
39
python 3.12
n = int(input())
s = ""
for x in range(10,n+1):
if x < 100:
if n == x + int(str(x)[:]):
s += str(x)+" "
else:
if n == x + int(str(x)[1:]):
s+=str(x)+" "
print(s)
40
python 3.12
n,k=map(int,input().split())
s=1
for j in range(n):
s*=n
if n==2:
s+=4
n-=1
print(s-k*n)
42
python 3.12
def sarvar_tpy(s):
p={"+":1, "-": 1, "*": 2, "/": 2, "^": 3, "(": -1, ")": 0}
a={"^"}
l=[]
ops = ["+", "-", "*", "/", "(", ")", "^"]
res=""
for i in s:
if i in ops:
if i == "(":
l.append(i)
else:
while l and (p[l[-1]]>p[i] or p[l[-1]]==p[i] and i not in a
):
res+= l.pop()
if i == ')':
l.pop()
else:
l.append(i)
else:
res+= i
while l:
res+= l.pop()
return res
s=str(input())
print(sarvar_tpy(s))
43
python 3.12
a,b=map(int, input().split())
print(b, a)
44
python 3.12
a=int(input())
if a%4==0 and a%100!=0:
print("Kabisa yili")
elif a%400==0:
print("Kabisa yili")
else :
print("Kabisa yili emas")
45
python 3.12
n=int(input())
print(n*(n+1)//2)
47
pyton 3.12
n=int(input())
for i in range(n):
print(bin(int(input())).count("1"))
48
python 3.12
n=int(input())
a=0
b=0
d=[]
while a!=n:
a=a+1
for i in range(a):
b+=1
d.append(b)
print(*d,sep=' ')
d=[]
51
python 3.12
for i in range(int(input())):
print(bin(int(input()))[2:].count('1'))
53
python 3.12
a=int(input())
s=a*(a-3)//2
if a>3:
print(s)
else:
print("0")
54
python 3.12
a=int(input())
if a%2==1:
print("Hasan")
else:
print("Husan")
55
python 3.12
n = int(input())
for i in range(n):
d = int(input())
print((d**3)+d)
56
python 3.12
l = [0]
for i in range(39):
for j in range(59):
for k in range(64):
l.append(3**j*5**i*2**k)
l.sort()
a="int(input())"
t=eval(a)
while t:
print(l[eval(a)])
t-=1
57
python 3.12
N,M=map(int,input().split())
b=N*M
a=b*b-b
if N >= 1 and M >= 2:
a -= 4 * (N - 1) * (M - 2)
if N >= 2 and M >= 1:
a -= 4 * (N - 2) * (M - 1)
print(a)
58
python 3.12
a=int(input())
print(abs(7-a))
59
python 3.12
a=int(input())
print(a**2)
60
python 3.12
N=int(input())
print(int((3*N*N-N)//2))
61
python 3.12
n=int(input())
a=1
if n>=1:
s=round((2*a+(n-1)*4)*n//2)
print(s)
62
python 3.12
n=int(input())
print((n*n+n+2)//2)
65
python 3.12
a,b=map(str, input().split())
print(int(a,2)*int(b,2))
67
python 3.12
print((bin(int(input())+2**32)[-32:]))
68
python 3.12
m = input()
n = list((map(int,input().split())))
ind = int(input())
n.sort()
print(n[ind-1])
71
python 3.12
a=int(input())
print(a//2+1)
72
python 3.12
x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
x3,y3=map(int,input().split())
a=((y1-y2)**2+(x1-x2)**2)**0.5
b=((y2-y3)**2+(x2-x3)**2)**0.5
c=((y1-y3)**2+(x1-x3)**2)**0.5
if(a+b)>c and (a+c)>b and (b+c)>a:
print("uchburchak")
else:
print("uchburchak emas")
76
python 3.12
a=sum(map(int,input().split()))
b = int(input())
if a<b:
x=b-a
else:
x=0
print(x)
77
python 3.12
x,y=map(int,input().split())
n=1
n=n+(100-x)/(x-3*y)
if (100-x)%(x-3*y)!=0:
n=n+1
print(int(n))
82
python 3.12
n = int(input())
if n % 2 ==0:
n ="Second player"
else:
n ="First player"
print(n)
89
c++ (cpp)
#include <bits/stdc++.h>
#define ll long int
using namespace std;
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int n,k;
cin >> n;
cin >> k;
ll a[n];
ll s[n+1] = {0};
for(int i = 0; i < n; i++) cin >> a[i];
sort(a,a+n);
s[0] = 0;
for(int i = 1; i <= n; i++) s[i] = s[i-1]+a[i-1];
ll t = 0;
for(int i = 0; i < k; i++) t += s[k]-s[i]-(k-i)*a[i];
ll m = t;
for(int i = 0; i < n-k; i++){
t += (k-1)*(a[i]+a[k+i])-2*(s[k+i]-s[i+1]);
m = min(m,t);
}
cout << m;
}
90
c++ (cpp)
#include <stdio.h>
#include <stdlib.h>
int main()
{
long n;
scanf("%li", &n);
long m;
scanf("%lli", &m);
m -= 1;
int i;
long *a = (long *)malloc(n * sizeof(long));
long *b = (long *)malloc(n * sizeof(long));
long *t;
for(i=0; i<n; i++)
{
scanf("%li", a+i);
}
long ans = 1;
while (m > 0)
{
if (m & 1)
{
for(i=0; i<n; i++)
{
if (i+ans < n)
{
b[i] = a[i] ^ a[i+ans];
}
else
{
b[i] = a[i] ^ a[i+ans-n];
}
}
t = a;
a = b;
b = t;
}
ans <<= 1;
if (ans >= n)
{
ans-= n;
}
m >>= 1;
}
printf("%li", a[0]);
for(i=1; i<n; i++)
{
printf(" %li", a[i]);
}
printf("\n");
}
91
c++ (cpp)
#include <bits/stdc++.h>
using namespace std ;
#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()
#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define sc1(x) scanf("%d",&x)
#define sc2(x,y) scanf("%d%d",&x,&y)
#define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scll1(x) scanf("%lld",&x)
#define scll2(x,y) scanf("%lld%lld",&x,&y)
#define scll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define pr1(x) printf("%d\n",x)
#define pr2(x,y) printf("%d %d\n",x,y)
#define pr3(x,y,z) printf("%d %d %d\n",x,y,z)
#define prll1(x) printf("%lld\n",x)
#define prll2(x,y) printf("%lld %lld\n",x,y)
#define prll3(x,y,z) printf("%lld %lld %lld\n",x,y,z)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;
#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)
#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
const int mod = 1e9 + 7;
int ADD(int a, int b, int m = mod) {
int s = a;
s += b;
if( s >= m )
s -= m;
return s;
}
int MUL(int a, int b, int m = mod) {
return (1LL * a * b % m);
}
int power(int a, int b, int m = mod) {
int res = 1;
while( b ) {
if( b & 1 ) {
res = 1LL * res * a % m;
}
a = 1LL * a * a % m;
b /= 2;
}
return res;
}
ll nC2(ll x) {
return ( x * ( x - 1 ) / 2 );
}
const int maxn = 1e6 + 5;
char s1[ maxn ], s2[ maxn ], s[ maxn ];
int p1[ maxn ], p2[ maxn ];
int n, m, len, num, suff, fd[ maxn ], bd[ maxn ]; // node 1 - root with len -1, node 2 - root with len 0 , max suffix palindrome
char txt[ maxn ];
int iSA[maxn], SA[maxn]; //output
int cnt[maxn], next_gen[maxn], lcp[maxn], LCP[maxn][22], sa1[ maxn ], sa2[ maxn ]; //internal
bool bh[maxn], b2h[maxn];
void reset( int len ) {
int i; fr(i, 0, len) {
iSA[i] = 0;
SA[i] = 0;
cnt[i] = 0;
next_gen[i] = 0;
lcp[i] = 0;
bh[i] = 0;
b2h[i] = 0;
int j;
fr(j, 0, 20)
LCP[i][j] = 0;
}
}
bool smaller_first_char(int a, int b){
return txt[a] < txt[b];
}
void SuffixSort(int n) {
for (int i=0; i<n; ++i){
SA[i] = i;
}
sort(SA, SA + n, smaller_first_char);
for (int i=0; i<n; ++i){
bh[i] = i == 0 || txt[SA[i]] != txt[SA[i-1]];
b2h[i] = false;
}
for (int h = 1; h < n; h <<= 1){
int buckets = 0;
for (int i=0, j; i < n; i = j){
j = i + 1;
while (j < n && !bh[j]) j++;
next_gen[i] = j;
buckets++;
}
if (buckets == n) break;
for (int i = 0; i < n; i = next_gen[i]){
cnt[i] = 0;
for (int j = i; j < next_gen[i]; ++j){
iSA[SA[j]] = i;
}
}
cnt[iSA[n - h]]++;
b2h[iSA[n - h]] = true;
for (int i = 0; i < n; i = next_gen[i]){
for (int j = i; j < next_gen[i]; ++j){
int s = SA[j] - h;
if (s >= 0){
int head = iSA[s];
iSA[s] = head + cnt[head]++;
b2h[iSA[s]] = true;
}
}
for (int j = i; j < next_gen[i]; ++j){
int s = SA[j] - h;
if (s >= 0 && b2h[iSA[s]]){
for (int k = iSA[s]+1; !bh[k] && b2h[k]; k++) b2h[k] = false;
}
}
}
for (int i=0; i<n; ++i){
SA[iSA[i]] = i;
bh[i] |= b2h[i];
}
}
for (int i=0; i<n; ++i){
iSA[SA[i]] = i;
}
}
void InitLCP(int n) {
for (int i=0; i<n; ++i)
iSA[SA[i]] = i;
lcp[0] = 0;
for (int i=0, h=0; i<n; ++i)
{
if (iSA[i] > 0)
{
int j = SA[iSA[i]-1];
while (i + h < n && j + h < n && txt[i+h] == txt[j+h])
h++;
lcp[iSA[i]] = h;
if (h > 0)
h--;
}
}
}
void ConstructLCP() {
InitLCP( len );
for(int i = 0;i<len;++i)
LCP[i][0] = lcp[i];
for(int j = 1;(1<<j)<=len;++j){
for(int i = 0;i+(1<<j)-1<len;++i){
if(LCP[i][j-1]<=LCP[i+ ( 1<<(j-1) )][j-1])
LCP[i][j] = LCP[i][j-1];
else
LCP[i][j] = LCP[i+(1<<(j-1))][j-1];
}
}
}
int GetLCP(int x, int y) {
if(x == y) return len-SA[x];
if(x > y) swap(x,y);
int log = 0;
while((1<<log)<=(y-x)) ++log;
--log;
return min(LCP[x+1][log],LCP[y-(1<<log)+1][log]);
}
struct node {
int next[26];
int len;
int sufflink;
};
node tree[maxn];
bool addLetter(int pos) {
int cur = suff, curlen = 0;
int let = s[pos] - 'a';
while (true) {
curlen = tree[cur].len;
if (pos - 1 - curlen >= 0 && s[pos - 1 - curlen] == s[pos])
break;
cur = tree[cur].sufflink;
}
if (tree[cur].next[let]) {
suff = tree[cur].next[let];
return false;
}
num++;
suff = num;
tree[num].len = tree[cur].len + 2;
tree[cur].next[let] = num;
if (tree[num].len == 1) {
tree[num].sufflink = 2;
return true;
}
while (true) {
cur = tree[cur].sufflink;
curlen = tree[cur].len;
if (pos - 1 - curlen >= 0 && s[pos - 1 - curlen] == s[pos]) {
tree[num].sufflink = tree[cur].next[let];
break;
}
}
return true;
}
void initTree() {
num = 2; suff = 2;
tree[1].len = -1; tree[1].sufflink = 1;
tree[2].len = 0; tree[2].sufflink = 1;
}
void solve() {
scanf("%s", s1);
scanf("%s", s2);
n = strlen( s1 );
m = strlen( s2 );
int i;
len = n;
reset( len );
fr(i, 0, n-1) txt[i] = s1[i];
SuffixSort( len );
fr(i, 0, n-1) sa1[i] = iSA[i];
len = m;
reset( len );
fr(i, 0, m-1) txt[i] = s2[m-1-i];
SuffixSort( len );
fr(i, 0, m-1) sa2[m-1-i] = iSA[i];
fr(i, 0, n-1)
s[i] = s1[n-1-i];
initTree();
fr(i, 0, n-1) {
addLetter( i );
p1[n-1-i] = tree[suff].len;
}
p1[ n ] = 0;
fr(i, 1, num) {
tree[i].len = 0;
tree[i].sufflink = 0;
ms(tree[i].next, 0);
}
fr(i, 0, m-1)
s[i] = s2[i];
initTree();
fr(i, 0, m-1) {
addLetter( i );
p2[i] = tree[suff].len;
}
fr(i, 1, num) {
tree[i].len = 0;
tree[i].sufflink = 0;
ms(tree[i].next, 0);
}
len = n + m + 1;
reset( len );
fr(i, 0, n-1) txt[i] = s1[n-1-i];
txt[n] = '$';
fr(i, n+1, n+m) txt[i] = s2[i-n-1];
SuffixSort( len );
ConstructLCP();
int pos1, pos2;
pos1 = pos2 = -1;
fr(i, 0, len - 1) {
if( SA[i] > n ) {
bd[SA[i]] = pos1;
pos2 = SA[i];
} else if( SA[i] < n ){
bd[SA[i]] = pos2;
pos1 = SA[i];
}
}
pos1 = pos2 = -1;
fb(i, len - 1, 0) {
if( SA[i] > n ) {
fd[SA[i]] = pos1;
pos2 = SA[i];
} else if( SA[i] < n ) {
fd[SA[i]] = pos2;
pos1 = SA[i];
}
}
int l, r, currlen = 0;
l = r = -1;
currlen = 0;
fr(i, 0, n-1) {
int temp = 0;
if( fd[n-1-i] != -1 ) temp = max( temp, GetLCP(iSA[n-1-i], iSA[fd[n-1-i]]) );
if( bd[n-1-i] != -1 ) temp = max( temp, GetLCP(iSA[n-1-i], iSA[bd[n-1-i]]) );
if( temp && currlen < temp * 2 + p1[i+1] ) {
l = i - temp + 1;
r = i + p1[i+1];
currlen = temp * 2 + p1[i+1];
} else if( temp && currlen == temp * 2 + p1[i+1] ) {
if(sa1[i-temp+1] < sa1[l]) {
l = i - temp + 1;
r = i + p1[i+1];
}
}
}
if( currlen == 0 ) {
cout << -1 << "\n";
return;
}
string f1, f2;
f1.resize(currlen);
int j;
i = 0; j = currlen - 1;
while( l <= r ) {
f1[i] = f1[j] = s1[l];
l ++;
i ++; j --;
}
l = r = -1;
currlen = 0;
fr(i, 0, m-1) {
int temp = 0, p = 0;
p = (i ? p2[i-1]: 0);
if( fd[n+i+1] != -1 ) temp = max( temp, GetLCP(iSA[n+i+1], iSA[fd[n+i+1]]) );
if( bd[n+i+1] != -1 ) temp = max( temp, GetLCP(iSA[n+i+1], iSA[bd[n+i+1]]) );
if( temp && currlen < temp * 2 + p ) {
r = i+temp-1;
l = i-p;
currlen = temp * 2 + p;
} else if( temp && currlen == temp * 2 + p ) {
if(sa2[i+temp-1] < sa2[r]) {
r = i+temp-1;
l = i-p;
}
}
}
f2.resize( currlen );
i = 0; j = currlen - 1;
while( l <= r ) {
f2[i] = f2[j] = s2[r];
r --; i ++; j --;
}
if( f1.length() != f2.length() ) {
if( f1.length() < f2.length() ) cout << f2 << "\n";
else cout << f1 << "\n";
} else {
if( f1 < f2 ) cout << f1 << "\n";
else cout << f2 << "\n";
}
}
int main() {
int t; sc1( t );
while( t-- ) solve();
}
92
c++ (cpp)
#include <bits/stdc++.h>
using namespace std;
int main(){
int t,n,d;
cin>>t;
while(t--){
int ans=0;
cin>>n;
vector<int>a;
for(int i=0;i<n;i++){
cin>>d;
a.push_back(d);
}
sort(a.begin(),a.end());
for(int o = 0; o < n; o++){
if( a[o] == a[o + 1]){
ans = ans + 1;
if(a[o] == a[o+2]){
o = o + 1;
}
}
}
cout<<ans*2<<endl;
}
return 0;
}
93
python 3.12
a=int(input())
for k in range(a):
str1 = str(input())
u=set(str1)
c=len(u)
print(len(str1)-c)
94
c++ {cpp)
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int a[n][n];
long long sum = 0;
long long max=0;
for(int i = 0;i<n;i++){
long long s = 0;
for(int j=0;j<n;j++){
cin>>a[i][j];
sum+=a[i][j];
s+=a[i][j];
}
if(s>max)max=s;
}
for(int j=0;j<n;j++){
long long s = 0;
for(int i =0;i<n;i++){
s+=a[i][j];
}
if(s>max)max=s;
}
cout<<max*n-sum;
return 0;
}
95
c++ {cpp}
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int V = ((1 << 10) - 1);
void P(vector<string> v, map<int,
int>& freq)
{
for (int i = 0; i < v.size(); i++) {
int mask = 0;
unordered_set<int> T;
for (int j = 0; j < v[i].size(); j++)
T.insert(v[i][j] - '0');
for (auto it = T.begin(); it != T.end(); it++) {
int digit = (*it);
mask += (1 << digit);
}
freq[mask]++;
}
}
int S(map<int, int> freq)
{
int ans = 0;
for (int i = 1; i <= 1023; i++) {
for (int j = 1; j <= 1023; j++) {
if ((i | j) == V) {
if (i == j)
ans += (freq[i] * (freq[i] - 1));
else
ans += (freq[i] * freq[j]);
}
}
}
return ans/2;
}
int C(vector<string> v)
{
map<int, int> freq;
P(v, freq);
return S(freq);
}
main()
{
int n;
string str;
cin>>n;
vector<string> v;
for(int i=0;i<n;i++){
cin>>str;
v.push_back(str);
}
cout << C(v) << endl;
return 0;
}
96
c++ (cpp)
#include <iostream>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#define INF 1120000000
#define MOD 1000000007
#define long long long
template<typename T>
class BIT
{
private:
vector<T> bit;
int n;
public:
BIT(int _n) : n(_n)
{
bit = vector<T>(n+1, 0);
}
void add(int v, T a)
{
for(int x=v+1; x<=n; x += x&(-x)) bit[x] += a;
}
T sum(int v)
{
T ret=0;
for(int x=v+1; x>0; x -= x&(-x)) ret += bit[x];
return ret;
}
};
int a[300005];
bool appear[300005];
long fact[300005];
int main()
{
int n;
scanf("%d", &n);
rep(i,n) scanf("%d", a+i);
fill(appear, appear+n+1, false);
rep(i,n) appear[a[i]] = true;
vector<int> b;
rep(i,1,n+1) if(!appear[i]) b.pb(i);
fact[0] = 1;
rep(i,n) fact[i+1] = (i+1)*fact[i] %MOD;
long m = b.size();
long sumb = 0;
for(auto x : b) sumb += x-1;
sumb %= MOD;
BIT<int> bit(n+1);
long ans = fact[m];
long k = 0;
long pre = 0;
rep(i,n)
{
if(a[i]==0)
{
long tmp = sumb * fact[m-1] %MOD
- pre * fact[m-1] %MOD
- ((m>=2) ? (m*(m-1)/2 %MOD * fact[m-2] %MOD * k %MOD) : (0));
ans = (ans + tmp*fact[n-i-1]) %MOD;
k++;
}
else
{
long tmp = (a[i]-1) * fact[m] %MOD
- bit.sum(a[i]) * fact[m] %MOD
- ((m>=1) ? ((long)(lower_bound(all(b), a[i]) - b.begin()) * k %MOD * fact[m-1] %MOD) : (0));
ans = (ans + tmp*fact[n-i-1]) %MOD;
bit.add(a[i], 1);
pre = (pre + b.end() - lower_bound(all(b), a[i])) %MOD;
}
}
ans %= MOD;
if(ans < 0) ans += MOD;
cout << ans << '\n';
return 0;
}//boshqattan jo‘nating
97
python 3.12
a=int(input())
b=int(input())
i=1
while a&i != b&i:
i=i*2
print(i)
98
c++ (cpp)
#include <iostream>
using namespace std;
int main()
{
long long n,count=0;
cin>>n;
while(n>1){
if(n%3==0)
{
n=n/3;count++;
}
else if(n%3==1)
{
n=2*n+1;count++;
}
else if(n%3==2)
{
n=2*n-1;count++;
}
}
cout<<count;
}
99
python 3.12
n = int(input())
c = 0
if n == 2 or n == 3:
print(2)
elif n == 1:
print(1)
else:
i = 1
while i <= (n+1)**(1/2):
if (n+1)%i == 0:
c += 1
i += 1
if c >= 2:
print(0)
else:
print(n)
100
c++ (cpp)
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long t;
cin>>t;
while(t--){
long long x1,x2,x3,x4,y1,y2,y3,y4;
cin>>x1>>x2>>x3>>x4;
cin>>y1>>y2>>y3>>y4;
if(sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))==sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3)) && sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))==sqrt((x1-x4)*(x1-x4)+(y1-y4)*(y1-y4)))cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
113
PYTHON 3.12
n = int(input())
if n < 38:
s = n
else:
if n % 5 > 2 :
s = ((n//5)*5) +5
else:
s = n
print(s)
119
python 3.12
def sanash(x):
if x%4!=0:
print('-1')
else:
print(x//2)
a=int(input())
sanash(a)
138
python 3.12
a=int(input())
print(a**5+8*a**4-5*a**3+3*a**2+a-12)
139
pthon 3.12
a=input()
x=input()
y=0
d=0
s=0
ch=0
p=0
j=0
for i in x:
if i!=" ":
i=int(i)
if i==1:
y+=1
elif i==2:
d+=1
elif i==3:
s+=1
elif i==4:
ch+=1
else:
p+=1
if y>=d and y>=s and y>=ch and y>=p:
j=1
elif d>=y and d>=s and d>=ch and d>=p:
j=2
elif s>=y and s>=d and s>=ch and s>=p:
j=3
elif ch>=y and ch>=d and ch>=s and ch>=p:
j=4
elif p>=y and p>=d and p>=s and p>=ch:
j=5
print(j)
149
python 3.12
a=int(input())
print(len(bin(a)[2::]))