akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    from fractions import Fraction
    return float(Fraction(1, sum(Fraction(1, a) for a in A)))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, A))

if __name__ == '__main__':
    main()


Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
 
int main(){
unsigned long int n,i = 0;
unsigned long int sum = 0;
cin >> n;
 
while(n != 0){
  i++;
  if(i % 3 != 0 && i % 5 != 0)
    sum += i;
  n--;  
}
 
cout << sum;
}


Measured memory_bytes: 3620
import fractions

T = int(input())

for i in range(T):

    a,b,c,d = map(int,input().split())

    if a < b or d < b:
        print ("No")
        continue

    elif b-c < 2:
        print ("Yes")
        continue

    elif (((a-b) % fractions.gcd(b,d-b)) + b - fractions.gcd(b,d-b) > c and ((a-b) % fractions.gcd(b,d-b)) + b - fractions.gcd(b,d-b) < b):
        print ("No")

    else:
        print ("Yes")


Measured memory_bytes: 5048
n = int(input())
ls = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(ls[n-1])

Measured memory_bytes: 3060
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0

for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if X == 500 * i + 100 * j + 50 * k:
        ans += 1

print(ans)

Measured memory_bytes: 3060
n = int(input())
a = list(map(int,input().split()))


# 次の日の方が安いなら全て売る
# 次の日の方が高いなら全て買う
#　同じなら何もしない
money = 1000
stock=0
for i in range(n-1):
    if a[i] < a[i+1]:
        tmp = money//a[i]
        stock += tmp
        money -= tmp * a[i]
    elif a[i]== a[i+1]:
        pass
    else:
        money += stock *a[i]
        stock =0

if stock >0:
    money+=stock*a[-1]
    stock=0
print(money)

Measured memory_bytes: 61932
import sys
input=sys.stdin.readline
n,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
res=[0 for _ in range(w+1)]
for i in range(n):
    for j in range(w,a[i][0]-1,-1):
        res[j]=max(res[j],res[j-a[i][0]]+a[i][1])
print(res[w])

Measured memory_bytes: 45040
n = gets.chomp.to_i
arr = gets.chomp.split(" ").map(&:to_i)

A = 10 ** 9 + 7
result = 0
base = 0
(n-2).downto(0) do |i|
  base += arr[i+1]
  tmp = (base * arr[i]) % A
  result += tmp
  result %= A
end

puts result


Measured memory_bytes: 36052
#include <iostream>
#include <algorithm>

using namespace std;

// dp[i][j]: i番目までの品物から重さjを超えないように選んだときの最大の価値
long long dp[101][100001];

int main()
{
    int N, W;
    cin >> N >> W;

    int weight[101], value[101];
    for (int i = 1; i <= N; i++) {
        cin >> weight[i] >> value[i];
    }

    // ループごとにdp[i][j]を更新
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= W; j++) {
            if (j - weight[i] < 0) {
                // i番目の品物の重さががjより大きいので選べない
                dp[i][j] = dp[i - 1][j];
            } else {
                // max(選んだ場合の最大の価値, 選ばなかった場合の最大の価値)
                dp[i][j] = max(dp[i - 1][j - weight[i]] + value[i], dp[i - 1][j]);
            }
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}

Measured memory_bytes: 78336
#include <stdio.h>
#include <math.h>

double avg(int num[], int n) {
    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += num[i];
    }
    return (double)sum / n;
}

double dev(int num[], double avg, int n) {
    double sum = 0;
    for (int i = 0; i < n; i++) {
        sum += pow(num[i] - avg, 2);
    }
    return sqrt(sum / n);
}

int main(void){
    int n;
    int s[1000];

    while(scanf("%d\n", &n) && n != 0) {
        double m;
        double a;

        for (int i = 0; i < n; i++) {
            scanf("%d", &s[i]);
        }

        m = avg(s, n);
        a = dev(s, m, n);
        printf("%.8lf\n", a);
    }

    return 0;
}


Measured memory_bytes: 2148
from queue import Queue


def distances(tree: list, treeSize: int, root: int)->list:
    dists = [0] * treeSize

    q = Queue()
    q.put((root, -1, 0))

    while not q.empty():
        v, prev, d2v = q.get()

        dists[v] = d2v
        for u, dv2u in tree[v]:
            if prev == u:
                continue
            q.put((u, v, d2v + dv2u))

    return dists


def transit_tree_path(
        N: int, edges: list, Q: int, K: int, queries: list)->list:
    tree = [[] for _ in range(N)]
    for u, v, c in edges:
        tree[u-1].append((v-1, c))
        tree[v-1].append((u-1, c))

    d = distances(tree, N, K-1)

    return [d[x-1]+d[y-1] for x, y in queries]


if __name__ == "__main__":
    N = int(input())
    edges = [tuple(map(int, input().split())) for _ in range(N-1)]
    Q = 0
    Q, K = map(int, input().split())
    queries = [tuple(map(int, input().split())) for _ in range(Q)]

    ans = transit_tree_path(N, edges, Q, K, queries)
    for a in ans:
        print(a)


Measured memory_bytes: 76088
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

LL nC2(LL n){
    return n*(n-1)/2;
}

int main() {
    LL n;
    vector<LL> a;
    LL tmp_a;
    vector<LL> multi_bin_n;
    vector<LL> multi_bin_v;
    LL tmp_ans;
    LL ans;
 
    cin >> n;
    vector<int> bin(n+1, 0);
    for(int i=0; i<n; i++){
        cin >> tmp_a;
        tmp_a--;
        a.push_back(tmp_a);
        bin[tmp_a]++;
    }
 
    tmp_ans=0;
    for(int i=0; i<n; i++){
        tmp_ans+=nC2(bin[i]);
    }
    //cout << tmp_ans << endl;
 
    for(int i=0; i<n; i++){
        ans=tmp_ans;
        ans-=bin[a[i]]*(bin[a[i]]-1)/2;
        bin[a[i]]--;
        //cout << bin[a[i]] << " " << ans << endl;
        ans+=bin[a[i]]*(bin[a[i]]-1)/2;
        bin[a[i]]++;
        cout << ans << endl;
    }
 
    return 0;
}

Measured memory_bytes: 5104
N = int(input())
ans = [0 for _ in range(N + 1)]

for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      v = x * x + y * y + z * z  + x * y + y * z + z * x
      if v > N:
        continue
      ans[v - 1] += 1

for i in range(N):
  print(ans[i])

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
int N,cnt;
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin>>N;
    while(N--){
        int x;
        cin>>x;
        while(x%2==0){
            x/=2;
            cnt++;
        }
    }
    cout<<cnt;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int x,y;
    int w,h,r;
    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
    if(x>=0+r&&x<=w-r&&y>=0+r&&y<=h-r)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int a[2][105];
int sum_i[2][105];
int main() {
    int n;
    cin >> n;

    rep(i, n) {
        cin >> a[0][i];
    }

    rep(i, n) {
        cin >> a[1][i];
    }

    for(int i=1; i<=n; ++i) {
        sum_i[0][i] = a[0][i-1] + sum_i[0][i-1];
        sum_i[1][i] = a[1][n-i] + sum_i[1][i-1];
    }

    int ans = -1;

    for(int i=1; i<=n; ++i) {
        ans = max(ans, sum_i[0][i]+sum_i[1][n-i+1]);
    }

    cout << ans << endl;

}



Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()


def customCount(idx):
    target = A[idx]
    cnt = 1
    idx += 1
    while True:
        if idx == N or A[idx] != target:
            return cnt
        else:
            idx += 1
            cnt += 1


index = 0
result = 0
while True:
    num = customCount(index)
    index += num
    if (num % 2) == 1:
        result += 1
    if N <= index:
        break
print(result)

Measured memory_bytes: 7388
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int sx,sy,tx,ty;

int dx,dy;

char right_;
char left_;
char up_;
char down_;

int main()
{
	cin >> sx >> sy >> tx >> ty;

	if(sx <= tx)
	{
		right_ = 'R';
		left_ = 'L';
	}
	else
	{
		right_ = 'L';
		left_ = 'R';
	}

	if(sy <= ty)
	{
		up_ = 'U';
		down_ = 'D';
	}
	else
	{
		up_ = 'D';
		down_ = 'U';
	}

	dx = abs(sx - tx);
	dy = abs(sy - ty);

	for(int i = 0;i < dx;i++)
	{
		cout << right_;
	}
	for(int i = 0;i < dy;i++)
	{
		cout << up_;
	}
	for(int i = 0;i < dx;i++)
	{
		cout << left_;
	}
	for(int i = 0;i < dy;i++)
	{
		cout << down_;
	}
	cout << down_;
	for(int i = 0;i < dx + 1;i++)
	{
		cout << right_;
	}
	for(int i = 0;i < dy + 1;i++)
	{
		cout << up_;	
	}
	cout << left_;
	cout << up_;
	for(int i = 0;i < dx + 1;i++)
	{
		cout << left_;
	}
	for(int i = 0;i < dy + 1;i++)
	{
		cout << down_;
	}
	cout << right_;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  string s;
  cin >> s;

  string ans = "";
  for (int i = 0; i < s.length(); i += 2) {
    ans += s.at(i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a, c[200005] = {};
    cin >> n;
    for (int i = 2; i <= n; i++) cin >> a, c[a]++;
    for (int i = 1; i <= n; i++) cout << c[i] << '\n';
}


Measured memory_bytes: 4428
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<string> s;
	for (auto i = 0; i < N; ++i)
	{
		string temp;
		cin >> temp;
		sort(temp.begin(), temp.end());
		s.push_back(temp);
	}

	sort(s.begin(), s.end());

	auto num = 0ll;
	for (auto left = 0; left < s.size();)
	{
		auto right = left;
		while (right < s.size() && s[left].compare(s[right]) == 0)
		{
			++right;
		}

		long long temp = right - left;
		if (temp > 1)
		{
			num += temp * (temp - 1) / 2;
		}
		left = right;
	}

	cout << num << endl;

	return 0;
}

Measured memory_bytes: 5748
#include<stdio.h>
int main(){
  int d[100000][2];
  int n,i,j,c;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d %d",&d[i][0],&d[i][1]);
  for(j=n;j>-1;j--){
    for(i=c=0;i<n;i++){
      if(d[i][0]<=j+1&&j+1<=d[i][1])c++;
    }
    if(c>=j)break;
  }
  printf("%d\n",j);
  return 0;
}

Measured memory_bytes: 1376
#include<bits/stdc++.h>
using namespace std;

const int maxn = 1e5 + 10;
typedef long long int ll;
ll sum[maxn][4]; 

int main(){
		ll n;cin>>n;
	char s[5000];scanf("%s",s + 1);
	ll r = 0, b = 0,g = 0;
	for(int i = 1; i <= n; i++){
		if(s[i] == 'R'){
			r++;
			sum[i][1] = sum[i - 1][1] + 1;
			sum[i][2] = sum[i - 1][2];
			sum[i][3] = sum[i - 1][3];
		}else if(s[i] == 'G'){
			g++;
			sum[i][1] = sum[i - 1][1];
			sum[i][2] = sum[i - 1][2] + 1;
			sum[i][3] = sum[i - 1][3];
		}else if(s[i] == 'B'){
			b++;
			sum[i][1] = sum[i - 1][1];
			sum[i][2] = sum[i - 1][2];
			sum[i][3] = sum[i - 1][3] + 1;
		}
	}
	//cout<<"r :"<<r<<"  G:"<<g<<"  B:"<<b<<endl;
	//cout<<"R:  "<<sum[n][1]<<"  G:"<<sum[n][2]<<"   B:"<<sum[n][3]<<endl;
	ll ans = 0;
	for(int i = 1; i <= n; i++)
	for(int k = i + 1; k <= n; k++){
		if(s[i] == 'R' && s[k] == 'B' ){
			if((k - i + 1) & 1 && s[(i + k) /2] == 'G')ans --;
			ans += sum[k - 1][2] - sum[i][2];
		}
		if(s[i] == 'B' && s[k] == 'R'){
			if((k - i + 1) & 1 && s[(i + k) /2] == 'G')ans --;
			ans += sum[k - 1][2] - sum[i][2];
		}
		if(s[i] == 'G' && s[k] == 'B'){
			if((k - i + 1) & 1 && s[(i + k) /2] == 'R')ans --;
			ans += sum[k - 1][1] - sum[i][1];
		}
		if(s[i] == 'B' && s[k] == 'G'){
			if((k - i + 1) & 1 && s[(i + k) /2] == 'R')ans --;
			ans += sum[k - 1][1] - sum[i][1];
		}
		if(s[i] == 'R' && s[k] == 'G'){
			if((k - i + 1) & 1 && s[(i + k) /2] == 'B')ans --;
			ans += sum[k - 1][3] - sum[i][3];
		}
		if(s[i] == 'G' && s[k] == 'R'){
			if((k - i + 1) & 1 && s[(i + k) /2] == 'B')ans --;
			ans += sum[k - 1][3] - sum[i][3];
		}
	}
	cout<<ans<<endl;
	return 0;
} 


Measured memory_bytes: 3896
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n=0,count=0,max=0;
	string s;
	cin>>n>>s;
	for(int j=0;j<n;j++){
	   if(s[j]=='I')                                 
	      count++;                                                  
	    else
			count--;
        if(max<count)
        
           max=count;
                 
}


cout<<max;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

#define W 50
#define H 50

using namespace std;
void dfs(int w, int h);
int map[H][W];
int dy[8] = {1,1,0,-1,-1,-1,0,1}, dx[8] = {0,-1,-1,-1,0,1,1,1};
int w,h;

int main(){
  int i = 0,j = 0,is=0;
  cin >> w >> h;

  while(w != 0 && h != 0){
    for(i = 0;i < h;i++){
      for(j = 0;j<w;j++){
	cin>>map[i][j];
      }
    }
    i = j = 0;
    is = 0;
    while(i <= h-1  && j <= w-1){
      if(map[i][j] == 1){
	dfs(i,j);
	is++;
      }
      i++;
      if(i == h){
	i = 0;
	j++;
      }
    }
    cout << is << endl;
    cin >> w >> h;
  }
  return 0;
}

void dfs(int x,int y){
  int i = 0;
  map[x][y] = 0;
  for(i = 0;i < 8; i++){
    if(x + dx[i] > -1 && y + dy[i] > -1 && x + dx[i] < h && y + dy[i] < w){
      if(map[x + dx[i]][y + dy[i]] == 1){
	dfs(x + dx[i],y + dy[i]);
      }
    }
  }
}

Measured memory_bytes: 1240
# ABC113C
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


from collections import defaultdict
n,m = map(int, input().split())
p = defaultdict(list)
ps = [None] * m
ys = [None] * m
for i in range(m):
    pp,yy = map(int, input().split())
    p[pp].append((i,yy))
    ps[i] = pp
    ys[i] = yy
d = {}
for k,v in p.items():
    tmp = sorted(v, key=lambda x: x[1])
    d[k] = {j:i+1 for i,(j,y) in enumerate(tmp)}

for i in range(m):
    print(str(ps[i]).rjust(6,"0")+str(d[ps[i]][i]).rjust(6, "0"))

Measured memory_bytes: 110684
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000001

using namespace std;
#define ll long long
#define dbg if(0)

void build(ll a[],ll b[],int n,vector<ll> &v){
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            v.push_back(a[i]+b[j]);
        }
    }
}



int main(){
    int n;
    ll v;
    cin >> n>>v;
    ll a[n],b[n],c[n],d[n];
    vector<ll> X,Y;
    ll cnt=0;

    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    for(int i=0;i<n;i++){
        cin >> c[i];
    }
    for(int i=0;i<n;i++){
        cin >> d[i];
    }

    build(a,b,n,X);
    build(c,d,n,Y);
    sort(Y.begin(),Y.end());

    for(auto xi: X){
        ll lo=lower_bound(Y.begin(),Y.end(),v-xi) - Y.begin();
        ll hi=upper_bound(Y.begin(),Y.end(),v-xi) - Y.begin();
        cnt+=hi-lo;
    }
    cout <<cnt<<endl;
    return 0;
}


Measured memory_bytes: 23128
def LI(): return list(map(int, input().split()))
def LS(): return input().split()
def I(): return int(input())
def S(): return input()

n = I()
a = []
a.append([0,0,0])
for i in range(n):
    a.append(LI())
# 距離 + 2nが可能
flag = 0
for i in range(n):
    t = a[i + 1][0] - a[i][0]
    l = abs(a[i][1] - a[i+1][1]) + abs(a[i][2] - a[i+1][2])
    if t >= l and (t-l)%2 == 0:
        continue
    flag = 1

if flag == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 27380
/*
                                Bismillahi-r-Rahmani-r-Rahim
                                        RhIeyAaD
                                    IIT-7th Batch,JU
*/
#include<bits/stdc++.h>
using namespace std;

#define ll              long long int
#define MAX             2134567891
#define fr(i,n)         for(i=0;i<n;i++)
#define rep(i,n)        for(i=1;i<=n;i++)
#define rev(i,a,n)      for(i=n;i>=a;i--)
#define FOR(i,a,n)      for(i=a;i<=n;i++)
#define ALL(n)          n.begin(),n.end()
#define mem(x,n)        memset(x,n,sizeof(x))
#define TC(t)           printf("Case %lld: ",t)
#define ans(t,c)        printf("Case %lld: %lld\n",t,c)
#define SETP(n)         cout<<setprecision(n)<<fixed
#define READ            freopen("F:\\Project\\Test_Case.txt","r",stdin)
#define WRITE           freopen("F:\\Project\\Output_Test.txt","w",stdout)
#define IO              ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define PAIR            pair<ll,ll>
#define MP              make_pair
#define pb(a)           push_back(a)
#define ff              first
#define ss              second
#define NL              printf("\n");
#define debug(a)        cout<<a<<" ";
#define hlw             printf("hlw\n");
#define NN              111
#define MOD             1000000007///10^9
#define N               1000007 ///10^6->6 zero after 1 **

ll x[N],y[N],z[N],n;
string s,S;
vector<ll>v;
//map <ll,ll> mp;

int main()
{
    //IO;
    //while(1)
    //READ;WRITE;
{
    ll a=0,b=0,c=0,d,e,f,g,i,j,k,l,m,p,q,r,u,w,t,tc,in,mod,loc,diff,val,sz,lo,hi,mid,mn=MAX,mx=0,sum=0,ans=0;
    cin>>n;
    rep(i,n)
    {
        if(i%3==0 || i%5==0)continue;
        a+=i;
    }
    cout<<a<<endl;
}
    return 0;
}

/*

*/
/// Check for constraint 0 or 1?
/// long long or double? sqrt or division will work fine??


Measured memory_bytes: 3624
S = input()
S = list(S)
#print(S)
counts0 = 0
counts1 = 0
counts2 = 0
if S[0] == S[1]:
    counts0 = counts0 + 1
if S[0] == S[2]:
    counts0 = counts0 + 1
if S[0] == S[3]:
    counts0 = counts0 + 1
if S[1] == S[2]:
    counts1 = counts1 + 1
if S[1] == S[3]:
    counts1 = counts1 + 1
if S[2] == S[3]:
    counts2 = counts2 + 1

if counts0 == 1 and ((counts1 == 1 and counts2 ==0) or (counts1 == 0 and counts2 == 1)):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) throws Exception {
		int n = sc.nextInt();
		long arr[] = new long[n], xor = 0;
		
		for(int i = 0; i < n; i++) {
			arr[i] = sc.nextLong();
			xor ^= i < 2 ? 0 : arr[i];
		}
		
		long sum = arr[0] + arr[1];
		long and = (sum - xor) >> 1;
		long a = 0, b = 0;
		
		for(int i = 60; i >= 0; i--) {
			boolean xi = (xor & (1L << i)) > 0;
			boolean ai = (and & (1L << i)) > 0;
			
			if(!xi && ai) {
				a |= 1L << i;
				b |= 1L << i;
			}
		}
		
		
		for(int i = 60; i >= 0; i--) {
			boolean xi = (xor & (1L << i)) > 0;
			boolean ai = (and & (1L << i)) > 0;
			
			if(xi && !ai) {
				if((a | 1L << i) <= arr[0]) {
					a |= 1L << i;
				}else {
					b |= 1L << i;
				}
			}
		}
		
		boolean flag = (a + b) == sum && (a ^ b) == xor;
		flag &= a >= 1 && a <= arr[0] && b >= arr[1];
		
		out.println(flag ? arr[0] - a : -1);
		out.close();
	}

}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public Scanner(String file) throws Exception {
		br = new BufferedReader(new FileReader(file));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}


Measured memory_bytes: 25912
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  int cnt[10][10]={};
  reps(i,n){
    string s=to_string(i);
    int head=s[0]-'0';
    int tail=i%10;
    if(tail==0) continue;
    cnt[head][tail]++;
  }
  int ans=0;
  reps(i,9){
    reps(j,9){
      ans+=cnt[i][j]*cnt[j][i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << "-->" << x << endl;
#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        cout << it << " ";        \
    }                             \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
    #define mod 998244353
 
#define fi first
#define se second
int32_t main() 
{
   int n;
   cin >> n;
   int n1 = n;
   map<string, int> m;
   while(n--)
   {
       string s;
       cin>>s;
       m[s]++;
   }
   int ans = 0;
   for(auto it:m){
       ans = max(ans, it.se);
   }
   vector<string> ans1;
   for(auto it:m){
       if(it.se==ans)
           ans1.pb(it.fi);
   }
   for(auto it:ans1)
       cout << it << endl;
} 


Measured memory_bytes: 26868
n = int(input())
a = [int(i) for i in input().split()]

kouho = [0] * (n + 1 )

ans = 0

for i in range(n):
    if a[i] < n + 1:
        kouho[a[i]] += 1
    else:
        ans += 1

for i in range(n+1):
    if kouho[i] != 0:
        #print(kouho[i],i)
        if kouho[i] >= i:
            ans += kouho[i] - i
        else:
            ans += kouho[i]
        
print(ans)


Measured memory_bytes: 14268
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<limits.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int IINF=INT32_MAX;
static const ll LINF=INT64_MAX;
static const ll mod=1e9+7;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

int N,K;
string s;

int main(){
    cin>>N>>K;
    cin>>s;
    int ans=0;
    for(int i=0;i<N;++i){
        if(i!=0){
            if(s[i]=='L'&&s[i-1]=='L')ans++;
        }
        if(i!=N-1){
            if(s[i]=='R'&&s[i+1]=='R')ans++;
        }
    }
    ans=min(ans+2*K,N-1);
    cout<<min(ans,N-1)<<endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#define NIL -1

typedef struct node{
  int left;
  int right;
  int parent;
}node;

int getSibling(int);
int getDegree(int);
int getDepth(int);
int getHeight(int);
void printTree(void);

node *tree;
int n;

int main(){
  int id,left,right,i;
  
  scanf("%d",&n);
  
  tree = (node *)malloc(sizeof(node)*n);
  for(i=0;i<n;i++){
    tree[i].parent = NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&left,&right);
    tree[id].left = left;
    tree[id].right = right;
    tree[tree[id].left].parent = id;
    tree[tree[id].right].parent = id;
  }

  printTree();

  return 0;
}

int getSibling(int c){
  int left,right;
  if(tree[c].parent!=-1){
    left = tree[tree[c].parent].left;
    right = tree[tree[c].parent].right;

    if(left!=-1&&c!=left) return left;
    else if(right!=-1&&c!=right) return right;
  }
  return -1;
}

int getDegree(int c){
  int d=0;
  if(tree[c].left!=-1) d++;
  if(tree[c].right!=-1) d++;
 
  return d;
}

int getDepth(int c){
  int d=0;
  while(tree[c].parent!=-1){
    c=tree[c].parent;
    d++;
  }
  return d;
}

int getHeight(int c){
  int d=0;
  if(tree[c].left==-1&&tree[c].right==-1) return 0;
  if(tree[c].left==-1) return getHeight(tree[c].right)+1;
  if(tree[c].right==-1) return getHeight(tree[c].left)+1;
  if(getHeight(tree[c].left)<getHeight(tree[c].right))
    return getHeight(tree[c].right)+1;
  else return getHeight(tree[c].left)+1;
  return d;
}

void printTree(){
  int i,dep,h;
  for(i=0;i<n;i++){
    dep=getDepth(i);
    h=getHeight(i);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,tree[i].parent,getSibling(i),getDegree(i),dep,h);
    if(dep==0) printf("root\n");
    else if(h==0) printf("leaf\n");
    else printf("internal node\n");
  }

  return;
}

Measured memory_bytes: 612
# include<iostream>

using namespace std;
int main() {
	int a = 0;
	int b = 0;
	int c = 0;
	int k = 0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++) {
		if (c%i == 0) {
			k++;
		}
	}
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    cin.tie(0)->sync_with_stdio(false);

	string s, t;
	cin >> s >> t;
	int n = s.size();

	int cnt = 0;
	REP(i, n)
		if (s[i] != t[i])
			cnt++;

	cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 3816
#include <stdio.h>

int main(void){
    int game,pa=0,pb=0,i;
    char line[101];
    for(game=1;fgets(line,101,stdin),line[0]!= '0';game++){
        if(game!= 1){
            line[0]=='A'?pa++:pb++;
            printf("%d %d\n",pa,pb);
            pa=pb=0;
        }
        i=0;
        while(line[++i]!= '\n'){
            if(line[i] == 'A')
                pa++;
            else
                pb++;
        }
        if(game == 3){
            if(pa+pb <=20){
                pa==10?pa++:pb++;
                printf("%d %d\n",pa,pb);
            }
            else{
                pa>pb?pa++:pb++;
                printf("%d %d\n",pa,pb);
            }
            pa=pb=0;
            game=0;
        }
    }
    return 0;
}

Measured memory_bytes: 524
#include <iostream>
using namespace std;
int n, l[9], r[9]; long long dp[14][14][4104]; bool vis[14][14][4104];
long long solve(int digit, int last, int bit) {
	if (vis[digit][last][bit]) return dp[digit][last][bit];
	long long ret = 0;
	if (bit & 2) ret = 1;
	else if ((bit & 1) && l[0] <= last && last <= r[0]) ret = 1;
	for (int i = 0; i <= 9; i++) {
		int nbit = 0;
		for (int j = 0; j < n; j++) {
			if (j != 0 && ((bit >> (2 * j)) & 1) && l[j] <= last && last <= r[j]) nbit |= 1 << (2 * j - 2);
			if (j != 0 && ((bit >> (2 * j + 1)) & 1)) nbit |= 1 << (2 * j - 2);
			if (i != 0 && ((bit >> (2 * j)) & 1) && l[j] <= i * 10 + last && i * 10 + last <= r[j]) nbit |= 1 << (2 * j + 1);
		}
		if (nbit != 0) ret += solve(digit + 1, i, nbit);
	}
	vis[digit][last][bit] = true;
	dp[digit][last][bit] = ret;
	return ret;
}
int main() {
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) cin >> l[i] >> r[i];
		for (int i = 0; i <= 2 * n; i++) {
			for (int j = 0; j <= 9; j++) {
				for (int k = 0; k < 1 << (2 * n); k++) {
					vis[i][j][k] = false;
				}
			}
		}
		long long ret = 0;
		for (int i = 0; i <= 9; i++) ret += solve(1, i, 1 << (2 * n - 2));
		cout << ret << endl;
	}
	return 0;
}


Measured memory_bytes: 4432
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long long mod=1e9+7; //10^9+7

int main() {
    int n;
    ll a[200000];
    ll x[200000];
   cin >> n;
   ll sum = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        sum += a[i] * pow(-1,i+1);
    }
    sum = abs(sum);
    x[0] = sum/2;

    for(int i=1; i<n; i++){
        x[i] = a[i-1] - x[i-1];
    }

    for(int i=0; i<n; i++){
        cout << x[i]*2 << " ";
    }
    cout << endl;

  return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define pf push_front
#define ssort(e) sort(e.begin(), e.end())
#define ll long long int
#define ull unsigned long long

typedef vector<int> VII;
typedef vector<string> VSS;
typedef vector<char> VCC;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef map<int, int> MII;
typedef stack<int> STI;
typedef queue<int> QUI;
typedef set<int> SII;
typedef set<char> SCC;

string to_String(double num)
{
    ostringstream ss;
    ss << num;
    return ss.str();
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a, b;
    cin >> a >> b;

    cout << (a + b + 1) / 2 << endl;

    return 0;
}



Measured memory_bytes: 384
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
import math
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math as M
MOD=10**9+7
import sys
#####################################

n,k=INPUT()
A=INPUT()

for i in range(n-k):
    if A[i+k]>A[i]:
        print("Yes")
    else:
        print("No")
    


Measured memory_bytes: 102260
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

const int MAXN = 60;
int n;
int l[MAXN], t[MAXN], r[MAXN], b[MAXN];
int x[MAXN * 2], w;
int y[MAXN * 2], h;
bool c[MAXN * 4][MAXN * 4];
int ans;
const int dx[] = {0, -1, 0, 1};
const int dy[] = {-1, 0, 1, 0};

void init()
{
	w = h = 0;
	for (int i = 0; i < n; ++i) {
		scanf("%d%d%d%d", &l[i], &t[i], &r[i], &b[i]);
		x[w++] = l[i];
		x[w++] = r[i];
		y[h++] = t[i];
		y[h++] = b[i];
	}
	sort(x, x + w);
	w = unique(x, x + w) - x;
	sort(y, y + h);
	h = unique(y, y + h) - y;
}

void build()
{
	memset(c, 0, sizeof(c));
	for (int i = 0; i < n; ++i) {
		int x1 = (lower_bound(x, x + w, l[i]) - x) * 2 + 1;
		int x2 = (lower_bound(x, x + w, r[i]) - x) * 2 + 1;
		int y1 = (lower_bound(y, y + h, b[i]) - y) * 2 + 1;
		int y2 = (lower_bound(y, y + h, t[i]) - y) * 2 + 1;
		for (int x = x1; x <= x2; ++x) c[x][y1] = c[x][y2] = true;
		for (int y = y1; y <= y2; ++y) c[x1][y] = c[x2][y] = true;
	}
}

bool inrange(int x, int y)
{
	return x >= 0 && x <= w && y >= 0 && y <= h;
}

void dfs(int x, int y)
{
	c[x][y] = true;
	for (int i = 0; i < 4; ++i) {
		int nx = x + dx[i], ny = y + dy[i];
		if (inrange(nx, ny) && !c[nx][ny]) dfs(nx, ny);
	}
}

void solve()
{
	ans = 0;
	w *= 2, h *= 2;
	// for (int j = h; j >= 0; --j) {
	// 	for (int i = 0; i <= w; ++i) {
	// 		putchar(c[i][j] ? '*' : ' ');
	// 	}
	// 	puts("");
	// }
	for (int i = 0; i <= w; ++i) {
		for (int j = 0; j <= h; ++j) {
			if (!c[i][j]) dfs(i, j), ++ans;
		}
	}
}

int main()
{
	while (scanf("%d", &n) != EOF && n) {
		init();
		build();
		solve();
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 2196
N,K =map(int,input().split())
l =[int(input())for _ in range(N)]
l =sorted(l)
ans = 10**9
for i in range(N+1-K):
    if l[i+K-1]-l[i] < ans:
        ans =l[i+K-1] -l[i]
print(ans)

Measured memory_bytes: 8280
from collections import Counter
import sys
sys.setrecursionlimit(10000000)

class UnionFind:
    def __init__(self, N: int) -> None:
        #自身が親なら、その集合に属する頂点数に-1をかけたもの
        #自身が親でないなら、自身の親
        self.par = [-1 for i in range(N)]
    
    def root(self, x: int) -> bool:
        if self.par[x] < 0: #親が自分自身なら頂点
            return x
        else:
            #経路圧縮してから返す
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def unite(self, x: int, y: int) -> None:
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return
        else:
            if rx > ry:
                rx, ry = ry, rx
            self.par[rx] += self.par[ry]
            self.par[ry] = rx
    
    def same(self, x: int, y: int) -> bool:
        return self.root(x) == self.root(y)
    
    def size(self, x: int) -> int:
        root = self.root(x)
        return -self.par[root]


def main():
    N, M = map(int, input().split())
    uf = UnionFind(N)
    for _ in range(M):
        a, b = map(int, input().split())
        uf.unite(a-1, b-1)
    
    ans = 0
    for i in range(N):
        ans = max(ans, uf.size(i))
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 86764
#include <bits/stdc++.h>
using namespace std;
const int fish=1e9+7;
int st;
int Bits[(1<<21)+20];
int dp[(1<<21)+20];
int N,a[1005][1005];
int main()
{
	scanf("%d",&N);
	for (int i=1;i<=N;i++)
	  for (int j=1;j<=N;j++)
	    scanf("%d",&a[i][j]);
	st=(1<<N)-1;
	for (int i=0;i<=21;i++)
	  Bits[1<<i]=i;
     dp[0]=1;
	for (int i=1;i<=st;i++)
	  {
	  	int K=i,cnt=0;
	  	while (K!=0)
	    {
	      cnt++;
	      K-=(K&(-K));
		}
		K=i;
		for (int j=1;j<=N;j++)
		  {
		  	if (i&(1<<(j-1)))
		  	  if (a[cnt][j])
		  	    dp[i]=(dp[i]+dp[i^(1<<(j-1))])%fish;
		  }
	  }
	printf("%d",dp[st]);
	return 0;
}

Measured memory_bytes: 14848
from numba import njit, i8
import numpy as np


@njit(i8[:](i8))
def solve(N):
    # 4 * h * n * w == N * (h * n + n * w + w * h)
    for i in range(3501):
        for j in range(3501):
            num = N * i * j
            den = 4 * i * j - N * (i + j)
            if den <= 0:
                continue
            if num % den == 0:
                return np.array((i, j, num // den), dtype=np.int64)
    return np.zeros(3, dtype=np.int64)


print(*solve(int(input())))


Measured memory_bytes: 110296
#include<bits/stdc++.h>
using namespace std;
#define pb			push_back
#define vi  		vector<int>
#define all(a)		(a).begin(),(a).end()
#define F 			first
#define S 			second
#define endl		"\n"
#define fast 		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int 		long long int
#define mod			1000000007
#define test		int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)

int32_t main(){
	string str1,str;
	cin>>str1>>str;


	int flag=0;
	for(int i=0;str1[i];i++){
		if(str[i]!=str1[i]){
			flag=1;
			break;
		}
	}
	if(flag==0){
		if(str1.length()+1 == str.length())
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
	else
		cout<<"No"<<endl;

	return 0;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
  cin >> N;
  int COUNT=0;
  
  vector<int> p(N);
   for (int i = 0; i < N; i++) {
   cin >> p.at(i);
  }  
  for (int i = 0; i < N; i++) {
    if ( i+1 != p.at(i) )
    COUNT++;
  } 
  
  if  ( COUNT > 2 )
  cout << "NO" << endl;
  else 
  cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

// bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
//     return arg1.first > arg2.first;
// }

class UnionFind {
public:
    vector<ll> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int find(int x) {
        if (par[x] < 0) return x;
        else return par[x] = find(par[x]);
    }
    
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    ll size(int x) {
        return -par[find(x)];
    }

    bool issame(int x, int y) {
        return find(x) == find(y);
    }
};

int main(void) {
    ll n, m;
    cin >> n >> m;

    vector<int> a(m);
    vector<int> b(m);
    for(int im=0;im<m;im++) {
        cin >> a.at(im) >> b.at(im); a.at(im)--; b.at(im)--;
    }

    UnionFind uf = UnionFind(n);

    vector<ll> ans(m);
    ll n1, n2, tmp;
    tmp = n*(n-1)/2;
    int atmp, btmp;
    for(int im=0;im<m;im++) {
        ans.at(m-1-im) = tmp;
        atmp = a.at(m-1-im);
        btmp = b.at(m-1-im);
        if(uf.issame(atmp, btmp)) continue;
        n1 = uf.size(atmp);
        n2 = uf.size(btmp);
        tmp -= n1 * n2;
        uf.unite(atmp, btmp);
    }

    for(int im=0;im<m;im++) {
        cout << ans.at(im) << endl;
    }

    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> s(n+1, false);

  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      s[a] = true;
    }
  }

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!s[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VI prime;
    prime.push_back(2);
    FOR(i, 3, 100) {
        for(auto p : prime) {
            if(i % p == 0) break;
            if(p == prime.back()) prime.push_back(i);
        }
    }

    VI prime_cnt(prime.size(), 0);
    FOR(i, 1, n) {
        int tmp = i;
        REP(j, prime.size()) {
            while(tmp % prime[j] == 0) {
                tmp /= prime[j];
                prime_cnt[j]++;
            }
        }
    }

    int over2 = 0;
    int over4 = 0;
    int over14 = 0;
    int over24 = 0;
    int over74 = 0;
    REP(i, prime_cnt.size()) {
        if(prime_cnt[i] >= 2) over2++;
        if(prime_cnt[i] >= 4) over4++;
        if(prime_cnt[i] >= 14) over14++;
        if(prime_cnt[i] >= 24) over24++;
        if(prime_cnt[i] >= 74) over74++;
    }

    int ans = over4 * (over4 - 1) / 2 * max(over2 - 2, 0);
    ans += over14 * max(over4 - 1, 0);
    ans += over24 * max(over2 - 1, 0);
    ans += over74;
    cout << ans << ln;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdint.h>

bool map[6][6];

int main()
{
	int H, W, K;
	scanf("%d%d%d", &H, &W, &K);
	for (int y = 0; y < H; y++) {
		char str[8];
		scanf("%s", str);
		for (int x = 0; x < W; x++) {
			map[x][y] = (str[x] == '#');
		}
	}

	int ans = 0;
	for (uint32_t hpat = 0; hpat < (1 << H); hpat++) {
		for (uint32_t wpat = 0; wpat < (1 << W); wpat++) {
			int count = 0;
			for (int x = 0; x < W; x++) {
				for (int y = 0; y < H; y++) {
					uint32_t usex = wpat & (1 << x);
					uint32_t usey = hpat & (1 << y);
					if (usex && usey && map[x][y]) {
						count++;
					}
				}
			}
			if (count == K) {
				ans++;
			}
		}
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);ios::sync_with_stdio(false);

signed main()
{
    ll n, ans = 0;
    cin >> n;
    priority_queue<ll> q;
    queue<ll> q2;
    rep(i, n)
    {
        ll x;
        cin >> x;
        q.push(x);
    }

    while (q.top() > n - 1)
    {
        ll now = q.top(), p;
        q.pop();

        if (now >= 2 * n - 1)
        {
            ans += (now - n + 1) / n;
            p = (now - n + 1) / n;
            while (!q.empty())
            {
                ll next = q.top() + p;
                q.pop();
                q2.push(next);
            }

            q.push(now- p*n);

            while (!q2.empty())
            {
                q.push(q2.front());
                q2.pop();
            }
        }
        else
        {
            ans++;
            p = 1;

            while (!q.empty())
            {
                ll next = q.top() + p;
                q.pop();
                q2.push(next);
            }

            q.push(now - n);

            while (!q2.empty())
            {
                q.push(q2.front());
                q2.pop();
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int a, b;
    cin >> a >> b;

    if(a == b) {
        cout << "Draw" << endl;
        return 0;
    }
    if(a == 1) {
        cout << "Alice" << endl;
        return 0;
    }
    if(b == 1) {
        cout << "Bob" << endl;
        return 0;
    }

    cout << (a > b ? "Alice" : "Bob") << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

int main() {
    int64_t a, b, c;
    cin >> a >> b >> c;
    cout << ((c - a - b > 0 && a*a + b*b + c*c - 2*a*b - 2*b*c - 2*c*a > 0) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,m;
	string s; cin>>n>>m>>s;

	vector<int> cost(n+1,-1);
	cost[n]=0;
	for(int x=n;x>0;) if(s[x]=='0') {
		int next=-1;
		for(int d=1;d<=m;d++) if(x-d>=0 && s[x-d]=='0') {
			cost[x-d]=cost[x]+1;
			next=x-d;
		}
		x=next;
	}

	if(cost[0]==-1) return puts("-1"),0;

	for(int x=0;x<n;){
		int pre=x;
		for(;cost[x]+1!=cost[pre];x++);
		printf("%d ",x-pre);
	}

	return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3

import itertools
import math

n = int(input())

ab = [list(map(int, input().split())) for i in range(n)]


sum_dis = 0
for i, j in itertools.permutations(range(n), 2):
    x1, y1 = ab[i]
    x2, y2 = ab[j]
    sum_dis += ((x1-x2)**2+(y1-y2)**2)**0.5

sum_dis /= n*(n-1)/2

print(sum_dis*(n-1)/2)


Measured memory_bytes: 3188
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    int x=0;
    string s;
    cin>>s;
 
        for(int i=0;i<s.size();i++){
            if((int)s[i]==44) s[i]=' ';
        }
        for(int i=0;i<s.size();i++){
           cout<<s[i];
        }
   
return 0;
}

Measured memory_bytes: 256
import fileinput
from collections import defaultdict

def longest_path(node_count, edges):
    graph = defaultdict(list)
    for v_a, v_b in edges:
        graph[v_a].append(v_b)
    
    visited_nodes = [False] * (node_count + 1)
    sorted_nodes = []

    node_stack = []
    for node in graph:
        if visited_nodes[node]:
            continue

        node_stack.append([node, 0])
        visited_nodes[node] = True
        while node_stack:
            top_node, last_child = node_stack[-1]
            if top_node in graph and last_child < len(graph[top_node]):
                node_stack[-1][1] += 1
                current_child = graph[top_node][last_child]
                if not visited_nodes[current_child]:
                    node_stack.append([current_child, 0])
                    visited_nodes[current_child] = True
            else:
                node_stack.pop()
                sorted_nodes.append(top_node)
    
    path_table = {}
    longest_path = 0
    for node in sorted_nodes:
        if node in graph:
            path_table[node] = max(
                path_table[n] for n in graph[node]
            ) + 1
        else:
            path_table[node] = 0
        longest_path = max(path_table[node], longest_path)        

    return longest_path

inp = fileinput.FileInput()

split = inp.readline().split(" ")
node_count = int(split[0])
edge_count = int(split[1])
edges = []

for _ in range(edge_count):
    split = inp.readline().split(" ")
    edges.append(
        (int(split[0]), int(split[1]))
    )

print(longest_path(node_count, edges))

Measured memory_bytes: 84568
# -*- coding: utf-8 -*-
# 整数の入力
from decimal import Decimal


def main():
    n = int(input())

    if n == 1:
        print(0)
        return

    # print(int(n ** 2 - n))
    # print((n ** 2 - n) / 2)
    # print(n * (n - 1))
    # print(n * (n - 1) / 2)
    ans = int(Decimal(n * (n - 1)) / 2)
    print(ans)
    # print(ans * 2)


if __name__ == "__main__":
    main()


Measured memory_bytes: 5204