akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
bool is(string str)
{
    string res=str;
    reverse(res.begin(),res.end());
    if(res==str)
    {
        return 1;
    }
    return false;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
    cin>>arr[i];
map<int,int> mp;
for(int i=0;i<n;i++)
{
    mp[arr[i]]+=1;
}
map<int,int>::iterator it=mp.begin();
int t=0;
for(;it!=mp.end();it++)
{
    int x=it->second;
    x-=1;
    t+=(x*(x+1))/2;
}
for(int i=0;i<n;i++)
{
    int val=mp[arr[i]];
    t-=(val*(val-1))/2;
int    ans=t+((val-1)*(val-2))/2;
    cout<<ans<<endl;
    t+=(val*(val-1))/2;
}
    return 0;
}


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

struct dice{
	vector<int>d,init;
	bool operator==(const dice&oth){
		vector<string>v={"-"s,"N"s,"W"s,"WW"s,"E"s,"N"s};
		vector<int>tmp=d; d=init;
		int&nwtop=d.at(0),&nwdow=d.at(1),&nwrig=d.at(2)
		,&nwlef=d.at(3),&nwupp=d.at(4);
		auto rotate=[&](){
			swap(nwdow,nwrig),swap(nwdow,nwupp),swap(nwdow,nwlef);
		};
		for(auto&&i:v){
			for(auto&&j:i){
				roll(j);
			}
			for(int j=0;j<4;++j){
				if(d==oth.d){
					d=tmp;
					return true;
				}
				rotate();
			}
		}
		return false;
	}
	void insert(){
		for(int i=0;i<6;++i){
			int n; cin>>n;
			d.emplace_back(n);
			init.emplace_back(n);
		}
	}
	void roll(char c){
		int&top=d.at(0),&dow=d.at(1),&rig=d.at(2)
		,&lef=d.at(3),&upp=d.at(4),&btm=d.at(5);
		if(c=='N')swap(top,upp),swap(top,btm),swap(top,dow);
		else if(c=='E')swap(top,rig),swap(top,btm),swap(top,lef);
		else if(c=='S')swap(top,dow),swap(top,btm),swap(top,upp);
		else if(c=='W')swap(top,lef),swap(top,btm),swap(top,rig);
	}
	void prtop(){
		cout<<d.at(0)<<"\n"s;
	}
	void prrig(int top,int dow){
		vector<string>v={"-"s,"N"s,"W"s,"WW"s,"E"s,"N"s};
		vector<int>tmp=d; d=init;
		int&nwtop=d.at(0),&nwdow=d.at(1),&nwrig=d.at(2)
		,&nwlef=d.at(3),&nwupp=d.at(4);
		auto rotate=[&](){
			swap(nwdow,nwrig),swap(nwdow,nwupp),swap(nwdow,nwlef);
		};
		for(auto&&i:v){
			for(auto&&j:i){
				roll(j);
			}
			for(int j=0;j<4;++j){
				if(top==nwtop&&dow==nwdow){
					cout<<nwrig<<"\n"s;
					d=tmp;
					return;
				}
				rotate();
			}
		}
	}
};

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	dice a,b; a.insert(); b.insert();
	cout<<(a==b?"Yes"s:"No"s)<<"\n"s;
}


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

int main() {
    std::cout<<std::fixed<<std::setprecision(10);
    
    int N; cin >> N;
    vector<vector<int>> rel(N);
    vector<vector<int>> weight(N);
    rep(i, N-1) {
        int a, b, w;
        cin >> a >> b >> w;
        --a;
        --b;
        rel[a].push_back(b); 
        weight[a].push_back(w);
        rel[b].push_back(a); 
        weight[b].push_back(w);
    }
    queue<int> que;
    que.push(0);
    vector<int> clr(N, -1);
    clr[0] = 0;
    while(!que.empty()) {
        int n = que.front();
        que.pop();
        rep(i, rel[n].size()) {
            int u = rel[n][i];
            int w = weight[n][i];
            if (clr[u] != -1) continue;
            clr[u] = (clr[n]+w) % 2;
            que.push(u);
        }
    }
    rep(i, N) cout << clr[i] << endl;
    return 0;
}

Measured memory_bytes: 11904
#include <cstring>
#include <iostream>
#include <cmath>
using namespace std;

int main() {
    char s[11];
    scanf("%s",s);
    int len = (int)strlen(s);
    long long result=0, sum=0;
    for (int cut1=0; cut1 < len; cut1++) {
        sum = 0;
        for (int cut2=cut1+1; cut2 <= len; cut2++) {
            sum = 10*sum + (s[cut2-1]-'0');
            result += sum * pow(2,max(len-1-cut2,0)+max(cut1-1,0));
        }
    }
    printf("%lld\n",result);
    return 0;
}

Measured memory_bytes: 256
S = list(input())
S.reverse()
N = len(S)
mod = 10**9+7
dp = [[0 for r in range(13)] for n in range(N+1)]
dp[0][0] = 1
lookup = [[0 for d in range(10)] for n in range(N)]
for n in range(N):
    for d in range(10):
        lookup[n][d] = d*pow(10, n, 13) % 13
for n in range(1, N+1):
    if S[n-1] == '?':
        for d in range(10):
            for r in range(13):
                dp[n][(r+lookup[n-1][d]) % 13] += dp[n-1][r] % mod
    else:
        for r in range(13):
            dp[n][(r+lookup[n-1][int(S[n-1])]) % 13] += dp[n-1][r] % mod
print(dp[-1][5] % mod)


Measured memory_bytes: 96008
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#define INF 100000000
 
using namespace std;
typedef long long ll;

int main(){
	stack<int> st;
	while(1){
		int n;
		if(!(cin>>n))break;
		if(n==0){
			
			cout<<st.top()<<endl;
			st.pop();
		}
		else{
			st.push(n);
		}
	}
	return 0;
}

Measured memory_bytes: 1200
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include<fstream>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define f(n) for(int i=0;i<n;++i)
#define REP(i,n) for(long long i = 0;i < n;++i)
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
int main(){
	int n,k;
	cin >> n >> k;
	vector<long long> hoge;
	int geko = 0;
	REP(i, n) {
		long long a;
		cin >> a;
		hoge.push_back(a);
		if (a == k) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
		if (a >= k) geko = 1;
	}
	if (geko == 0) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	long long nya = hoge[0];
	for (int i = 1;i < n;++i) {
		nya = gcd(nya, hoge[i]);
	}
	if (nya == gcd(nya, k)) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>

void reverse_sequence(char [20], int);
int string_length(char [20]);

int main(){
	int i, N;
	char str[20];
	scanf("%s", str);

	N = string_length(str);
	reverse_sequence(str, N);
	for(i=0;i<N;++i){
		printf("%c", str[i]);
	}
	printf("\n");

	return 0;
}

void reverse_sequence(char a[20],int N){
	int i;
	char tmp;
	for(i=0; i<N/2; ++i){
		tmp = a[i];
		a[i] = a[(N-1)-i];
		a[(N-1)-i] = tmp;	
	}
}

int string_length(char a[20]){
	int i, count = 0;
	for(i=0; i<20; ++i){
		if(a[i] == '\0')	break;
		count++;
	}
	return count;
}

Measured memory_bytes: 520
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n, tx, ty, th;
    cin >> n;
    
    vector<int> x, y, h;
    for (int i = 0; i < n; ++i) {
        cin >> tx >> ty >> th;
        x.eb(tx), y.eb(ty), h.eb(th);
    }
    
    for (int px = 0; px <= 100; ++px) {
        for (int py = 0; py <= 100; ++py) {
            int height = 1;
            for (int i = 0; i < n; ++i) {
                if (h[i]) height = h[i] + abs(x[i] - px) + abs(y[i] - py);
            }
            
            bool fl = 1;
            for (int i = 0; i < n and fl; ++i) {
                if (h[i] != max(0LL, height - abs(x[i] - px) - abs(y[i] - py))) fl = 0;
            }
            
            if (fl) return cout << px << " " << py << " " << height << "\n", 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
c = 0
while True:
   try:
      s = input()
      cc = 0
      for i in range(len(s)):
         if s[i] == s[len(s) - 1 - i]:
            cc += 1
      if cc == len(s):
         #print("@", s)
         c += 1
   except EOFError:
      break
   
print(c)


Measured memory_bytes: 5560
n, m = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(m)]

ans = [1] * (n)
ans[0] = 1
ball = [False] * (n)
ball[0] = True
for i in range(m):
    x, y = xy[i]
    ans[y-1] += 1
    ans[x-1] -= 1
    if ball[x-1]:
      ball[y-1] = True
    if ans[x-1] == 0:
      ball[x-1] = False
      
cnt = 0
for i in ball:
  if i:
    cnt += 1

print(cnt)

Measured memory_bytes: 28964
#include <iostream>
using namespace std;

int main(){
     int A,B;
     cin >> A >> B;
     int x,y,z;
     x=A-B;y=A+B;z=A*B;

     if(x >= y and x >= z){
          cout << x <<endl;
     }else{
           if(y >= x and y >= z){
                cout << y <<endl;
           }else{
                     if(z >= x and z >= y)cout << z <<endl;
           }
     }

}


Measured memory_bytes: 256
#include "stdio.h"
#define lnth(a,l) for(l=0;a[l];l++)


int main(){
	char a[100];
	scanf("%s",a);
	int l,C=0;
	lnth(a,l);
	if(a[0]!='A'||a[1]=='C'||a[l-1]=='C') {printf("WA");return 0;}
	for(int i = 2;i<l-1;i++){
		if(a[i]=='C')C++;
	}
	if(C!=1){printf("WA");return 0;}
	C=0;
	for(int i=1;i<l;i++){
		if('A'<=a[i]&&a[i]<='Z')C++;
	}
	if(C!=1){printf("WA");return 0;}
	printf("AC");
}


Measured memory_bytes: 128
program sample
	integer ::A,B,C,D,e,f
    
    read(*,*) A
    read(*,*) B    
    read(*,*) C    
    read(*,*) D    
    
    if (A>B) then
    	e=B
    else if(A<=B) then
    	e=A
    end if
    if(C>D) then
    	f=D
    else if(C<=D) then
    	f=C
    end if
    write(*,*) e+f
    stop
end program sample



Measured memory_bytes: 2756
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ft first
#define sc second
#define sz size()
#define ll long long int
int main()
{
   int n;
   cin>>n;
   map<string,int>mp;
   string s;
   while(n--)
   {
       cin>>s;
       mp[s]++;
   }
   printf("AC x %d\n",mp["AC"]);
   printf("WA x %d\n",mp["WA"]);
   printf("TLE x %d\n",mp["TLE"]);
   printf("RE x %d\n",mp["RE"]);


}



Measured memory_bytes: 3724
# -*- coding: utf 8 -*-
# Bubble Sort
# 2019. 4/22

def bubbleSort(A, N):
    sw = 0
    flag = 1
    i = 0
    while flag:
        flag = 0
        for j in range(int(N) - 1, i, -1):
            if A[j - 1] > A[j]:
                A[j], A[j - 1] = A[j - 1], A[j]
                flag = 1
                sw = sw + 1
        i = i + 1
    return A, sw

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    A_sorted, num_sw = bubbleSort(A, N)

    for i in range(N-1):
        print(A[i], end=" ")
    print(A[N-1])
    print(num_sw)



Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 10000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n;
	cin>>n;
	vector<int> a;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.pb(x);
	}
	int ans = 0;
	multiset<int> s;
	for(int i=0;i<n;i++){
		multiset<int>::iterator it = s.upper_bound( -a[i] );
		if( it != s.end() ){
			s.erase(it);
			s.insert(-a[i]);
		}
		else{
			ans++;
			s.insert(-a[i]);
		}
	}
	cout<<ans<<endl;	
	return 0;
}

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





int main(){
    int N, A[100];
    cin >> N;
    rep(i,N) cin >>A[i];
    rep(i,N){
        if (A[i] % 2 == 0){
            if (A[i] %3 ==0 || A[i] %5 ==0){
            }
            else{
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" <<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class T> inline int sod_L(T n){
  int res = 0;
  while(n){
    res += n%10;
    n /= 10;
  }
  return res;
}
int K;
int sz;
long long ans[1000000];
int main(){
  long long i;
  long long j;
  long long k=1;
  long long si;
  long long sj;
  for(i=1;i<=1000000000000000LL;i+=k){
    if(i >= 100*k && i%(10*k)==10*k-1){
      k *= 10;
    }
    while(sz){
      j = ans[sz-1];
      si =sod_L(i);
      sj =sod_L(j);
      if(i*sj >= j*si){
        break;
      }
      sz--;
    }
    ans[sz++] = i;
  }
  rd(K);
  {
    int cTE1_r3A;
    for(cTE1_r3A=(0);cTE1_r3A<(K);cTE1_r3A++){
      wt_L(ans[cTE1_r3A]);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20191110-1

// --- original code ---
// int K;
// int sz; ll ans[1d6];
// {
//   ll i, j, k=1, si, sj;
//   for(i=1;i<=1d15;i+=k){
//     if(i >= 100*k && i%(10k)==10k-1) k *= 10;
//     while(sz){
//       j = ans[sz-1];
//       si = sod(i);
//       sj = sod(j);
//       if(i*sj >= j*si) break;
//       sz--;
//     }
//     ans[sz++] = i;
//   }
//   rd(K);
//   wtLn(ans(K));
// }


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
}

	
int main(){
	init();
	ll a,b;
	cin>>a>>b;
	cout<<(a+b)%24<<endl;
}


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

int main() {
  int x=0;
  cin >> x;
  bool ck = false;
  do{
    ck = true;
    for(int i=2;i<x;i++){
      if(x % i == 0){ 
        ck = false;
        break;
      }      
    }
    if(ck) cout << x << endl;
    else x++;
  }while(!(ck));
    
}


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

using namespace std;

int main()
{

    string s, a;
    int n ;

    cin >> s >> n;

    int l = s.size();
    for(int i = 0; i < l; i += n)
    {
        cout << s[i];
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W,dh,dw,ans;
  cin >>H>>W;
  cin >>dh>>dw;

  ans=H*W-dh*W-dw*H+dh*dw;
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define MOD 1000000007
using namespace std;
typedef long long ll;

ll f[1<<20];
ll sp[1<<20];
int n;

int main(){
	scanf("%d",&n);
	int w=(1LL*(n-1)*(n-1))%MOD;
	f[0]=1;f[1]=n;
	sp[1]=1;sp[2]=n+1;
	fore(k,2,n+1){
		f[k]=f[k-1];
		if(k==2){
			f[k]+=(1LL*(n-1)*(n))%MOD;
			f[k]%=MOD;
			//assert(f[k]==9);
		}
		else {
			f[k]+=w;f[k]%=MOD;
			f[k]+=sp[k-2];
			f[k]%=MOD;
			f[k]+=(1LL*(n+1-k)*1)%MOD;
			f[k]%=MOD;
		}
		sp[k+1]=(sp[k]+f[k])%MOD;
	}
	printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int x, y;
	cin >> x >> y;
	cout << x+y/2 << endl;
	return 0;
}

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

int main(){
  int s,put = 0;
  cin >> s;
  put = s%10+put;
  s = s/10;
  put = s%10+put;
  s = s/10;
  put = s%10+put;
  cout << put << 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()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	set<string> record; record.clear();
	vector<string> words(N);
	bool ok = true;
	rep (i, N){
		string w; cin >> w;
		if (record.count(w) || (i > 0 && words[i-1][(int)words[i-1].length() - 1] != w[0])){
			ok = false;
		} // end if
		words[i] = w;
		record.insert(words[i]);
	} // end rep

	cout << (ok == true ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
var dd,xx,nn,n,d,x,ans:extended;
    i:longint;
begin
  readln(n,d,x);
  nn:=n*2;
  for i:=trunc(n) downto 1 do
  begin
    ans:=ans+d+(nn-1)/2*x;
    dd:=d+(2*d+5*x)/nn;
    xx:=x+4*x/nn;
    x:=xx;d:=dd;
    nn:=nn-2;
  end;
  writeln(ans:0:10);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const long double EPS = 1e-6, PI = acos((long double)-1);

//ここから編集
template<typename T = int> struct BIT{
  vector<T> node;

  int N;
  BIT(int n){
    N = n;
    node.resize(N+1);
  }

  void add(int i, T x){
    i++;
    while(i <= N){
      node[i] += x;
      i += (i & -i);
    }
  }

  T sum(int i){
    T res = 0;
    while(i > 0){
      res += node[i];
      i -= (i & -i);
    }
    return res;
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(4);

  int N, Q; cin >> N >> Q;
  BIT<ll> bit(N+1);
  REP(i,N){
    ll a; cin >> a;
    bit.add(i, a);
  }

  REP(i,Q){
    int t; cin >> t;
    if(t == 0){
      int p, x; cin >> p >> x;
      bit.add(p, x);
    }else{
      int l, r; cin >> l >> r;
      cout << bit.sum(r) - bit.sum(l) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 8240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

ll gcd(ll a, ll b);
ll lcm(ll a, ll b);

int main()
{
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << (B - A + 1) - ((B / C + B / D - B / lcm(C, D)) - ((A - 1) / C + (A - 1) / D - (A - 1) / lcm(C, D))) << endl;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    else
    {
        return gcd(b, a % b);
    }
}

ll lcm(ll a, ll b)
{
    return (a * b) / gcd(a, b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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 mod= 1e9 + 7;

ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M)%M;
}

ll ncr(ll n,ll a){
  ll ax=1, ay=1;
  for(ll i=n;i>=n-a+1;i--){
    ax=(ax*i)%mod;
  }
  for(ll i=a;i>1;i--){
    ay=(ay*i)%mod;
  }
  ay=RepeatSquaring(ay,mod-2,mod); // フェルマーの小定理
  return (ax*ay)%mod;
}

int main() {
  ll x,y;
  cin >> x >> y;
  ll q=x+y+3;    
  ll p=(x+y)/3;
  ll up=x-p,left=y-p;
  if(q%3!=0 || up<0 || left<0){cout << 0 << endl; return 0;}


  cout << ncr(p,up) << endl;
}

Measured memory_bytes: 3604
import java.io.IOException;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine()); //数列Sの長さ
        String[] s = sc.nextLine().split(" "); //数列S

        int q = Integer.parseInt(sc.nextLine()); //数列Tの長さ
        String[] t = sc.nextLine().split(" "); //数列T

        int count = 0; //出力結果（個数）
        for(int j=0; j<q; j++) {
            for(int i=0; i<n; i++) {
                if(s[i].equals(t[j])){
                    count++;
                    break; 
                }
            }
        }
        System.out.println(count);
    }
}



Measured memory_bytes: 29864
#include<bits/stdc++.h>
using namespace std;
#define fl(n)             for(long long int i=0;i<n;i++)
#define sz(a)             int((a).size())
#define tr(c,i)           for(auto i = (c).begin(); i != (c).end(); i++)
#define trr(c,i)          for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define present(c,x)      ((c).find(x) != (c).end())
#define cpresent(c,x)     (find(all(c),x) != (c).end())
#define vi                vector <int>
#define vvi               vector < vi >
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define ll                long long
#define fr                first
#define sc                second
#define vc                vector
#define pii               pair<int,int>
#define msi               map<string,int> 
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define M                 1000000007LL


int solve()
{
	int n;
	cin>>n;
	ll a[n];
	ll sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	ll offset=0,ans=0;
	for(int i=0;i<n;i++)
	{
		offset+=a[i];
		ans+=((a[i]%M)*((sum-offset+M)%M))%M;
		ans=ans%M;
	}
	cout<<ans<<"\n";


  return 0;
}


int main() {
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
  
  int t=1;
  //cin>>t;
  while(t--)
  {
    solve();
  }
  return 0;
}

 

Measured memory_bytes: 5180
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

n,k = map(int,input().split())
twices = [1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072]

base = 0
for i in range(len(twices)):
    if k <= twices[i]:
        base = i
        break


head = 0
for i in range(1,n+1):
    temp = 0
    if k%i == 0:
        temp = k//i
    else:
        temp = k//i+1
    #print(temp)
    for j in range(len(twices)):
        if temp <= twices[j]:
            head += 2**(base-j)
            #print(i,j,2**(base-j))
            break
#print(2**base)
print(head/((2**base)*n))
"{:.2f}".format(3.141592)







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

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> x(N);
    ll ans = 10000000000000001;

    for (ll i = 0; i < N; i++) cin >> x[i];

    for (ll l = 0; l < N-K+1; l++) {
        ll r = l+K-1;
        ll cost1, cost2;
        cost1 = abs(x[l]) + abs(x[r]-x[l]);
        cost2 = abs(x[r]) + abs(x[r]-x[l]);
        ans = min(ans, min(cost1, cost2));
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 1024
fn func(input_str: &str) -> u64 {
    let mut iter = input_str.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: u64 = iter.next().unwrap().parse().unwrap();
    let mut ab_s = vec![(0, 0); n];
    for i in 0..n {
        let a: u64 = iter.next().unwrap().parse().unwrap();
        let b: u64 = iter.next().unwrap().parse().unwrap();
        ab_s[i] = (a, b);
    }
    ab_s.sort_by_key(|x| x.0);
    let mut ans = 0;
    let mut m_remain = m;
    for i in 0..n {
        let (a, b) = ab_s[i];
        if m_remain >= b {
            m_remain -= b;
            ans += a * b;
        } else {
            ans += a * m_remain;
            return ans;
        }
    }
    ans
}

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    println!("{}", func(&buf[..]));
}

Measured memory_bytes: 8444
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 200010;

int dp[210][(1<<15)+1][5];

int main(){
    int x[200];
    For(i, 1, 201) x[i-1] = i*i;
    int n;
    while(scanf("%d", &n) && n){
        int m = upper_bound(x, x+200, n) - x;
        rep(i, m+1)rep(j, n+1)rep(k, 5) dp[i][j][k] = 0;
        dp[0][0][0] = 1;
        rep(i, m)rep(j, n+1)rep(k, 5)if(dp[i][j][k]){
            dp[i+1][j][k] += dp[i][j][k];
            if(k < 4 && j + x[i] <= n) dp[i][j+x[i]][k+1] += dp[i][j][k];
        }
        lint ans = 0;
        rep(k, 5) ans += dp[m][n][k];
        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 119688
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  string s;
  cin >> s;
  string ans;
  if (s == "ARC") ans = "ABC";
  else ans = "ARC";
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
char s[104][104];
int h,w,i,j,a[104][104];
int main() {
    for(scanf("%d%d",&h,&w); i++<h; scanf("%s",s[i]+1));
    for(j=w; --j; a[h][j]=a[h][j+1]+(s[h][j+1]!=s[h][j]));
    for(i=h; --i; a[i][w]=a[i+1][w]+(s[i+1][w]!=s[i][w]));
    for(i=h; --i;)
        for(j=w; --j; a[i][j]=min(a[i][j+1]+(s[i][j+1]!=s[i][j]),
                                  a[i+1][j]+(s[i+1][j]!=s[i][j])));
    printf("%d\n",(s[h][w]=='#')+(a[1][1]+(s[1][1]=='#')>>1)),exit(0);
}

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

#define MOD 1000000007

int h,w,a,b;
int cnt[70];
long long base[70],fac[200200];

long long inverse_md(long long num)
{
    long long val=1;
    int nw=0,po=1;
    base[0]=1;
    cnt[0]=0;
    base[1]=num;
    cnt[1]=1;
    while(nw+cnt[po]<=MOD-2)
    {
        val*=base[po];
        val%=MOD;
        nw+=cnt[po];
        base[po+1]=base[po]*base[po];
        base[po+1]%=MOD;
        cnt[po+1]=cnt[po]*2;
        po++;
    }
    for(int i=po;i>=0;i--)
    {
        if(nw+cnt[i]<=MOD-2)
        {
            val*=base[i];
            val%=MOD;
            nw+=cnt[i];
        }
    }
    //printf("%lld\n",(num*val)%MOD);
    return int(val);
}

long long sr(int dx,int dy)
{
    long long nw=fac[dx+dy];
    nw*=inverse_md(fac[dx]);
    nw%=MOD;
    nw*=inverse_md(fac[dy]);
    nw%=MOD;
    return nw;
}

main()
{
    fac[0]=fac[1]=1;
    for(int i=2;i<200020;i++)
    {
        fac[i]=fac[i-1]*i;
        fac[i]%=MOD;
    }
    scanf("%d %d %d %d",&h,&w,&a,&b);
    long long ans=0;
    for(int i=0;i<h-a;i++)
    {
        ans+=sr(i,b-1)*sr(h-1-i,w-1-(b));
        ans%=MOD;
        //printf("%lld %lld %lld\n",sr(i,b-1),sr(h-1-i,w-1-(b)),ans);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int a[3];
int main(void){
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    int ans=3;
    if(a[0]==a[1]&&a[1]==a[2]){
        ans=1;
    }else if(a[0]==a[1]){
        ans=2;
    }else if(a[1]==a[2]){
        ans=2;
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

enum Which{
	Hanako,
	Jiro,
};

int N,A,B;
int table[NUM];

int calc_xor(int mod){

	int ret = 0;

	for(int i = 0; i < N; i++){
		ret ^= (table[i]%mod);
	}

	return ret;
}

int main(){

	scanf("%d %d %d",&N,&A,&B);

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

	Which winner;
	bool FLG;

	if(A == B){

		//普通のNim
		if(calc_xor(A+1) != 0){
			/*
			 * 初期状態でニム和が非0であれば、先手はニム和0(mod(A+1)下)の状態にもっていくことができ、
			 * 「勝ち状態」を作れるから勝つ
			 * */
			winner = Hanako;

		}else{
			winner = Jiro;
		}
	}else if(A > B){

		FLG = false;

		//少なくとも1つB+1以上の山があれば、mod(B+1)で0の状態を後手に送り付けられるのでHanako必勝
		for(int i = 0; i < N; i++){
			if(table[i] >= B+1){
				FLG = true;
				break;
			}
		}

		if(FLG){

			winner = Hanako;

		}else{

			if(calc_xor(B+1) != 0){ //★判定α★
				winner = Hanako;
			}else{
				/*
				 * ★B+1個以上の山がない→お互いの上限がBであり、かつ判定αが偽、つまり初期状態でmod(B+1)でニム和が0なので、
				 * 後手は必ずmod(B+1)でニム和0の状態を先手に送り付けられる。終了状態は、石が0個、つまりmod(B+1)の下でニム和が0である。
				 * よって、先手は必ずニム和0の状態で石を取らねばならず、その結果はmod(B+1)下でのニム和を0にできない
				 * (★B+1個取れれば良いが、B個までしか取れないから★)。よって、後手必勝。★
				 * */
				winner = Jiro;
			}
		}

	}else{ //A < B

		int tmp_count = 0; //(A+1)個以上の石が積んである山の個数を数える
		int tmp_index,other_xor;

		for(int i = 0; i < N; i++){
			if(table[i] >= A+1){
				tmp_count++;
				tmp_index = i;
			}
		}

		if(tmp_count >= 2){
			//後手は先手に、(A < B)の状態でmod(A+1)でのニム和0の状態を回せるので、後手必勝
			winner = Jiro;

		}else{

			if(tmp_count == 0){ //A+1個以上の山がなければ、お互いの上限がAであるのと結果は同じ

				if(calc_xor(A+1) != 0){

					winner = Hanako;

				}else{

					winner = Jiro;
				}
			}else{ //tmp_count == 1

				FLG = false;

				//他の山のxorを計算
				other_xor = 0;

				for(int i = 0; i < N; i++){
					if(i == tmp_index)continue;
					other_xor ^= (table[i]%(A+1));
				}

				//mod(A+1)下でのニム和0を作れれば先手必勝
				for(int i = 1; i <= A; i++){

					if(table[tmp_index]-i >= A+1)continue; //A+1個残っていたら不可(★次に、後手にmod(A+1)下でのニム和0を作られるから★)

					if((other_xor^(table[tmp_index]-i)%(A+1)) == 0){

						FLG = true;
						break;
					}
				}

				if(FLG){

					winner = Hanako;

				}else{

					winner = Jiro;
				}
			}
		}
	}

	if(winner == Hanako){

		printf("Hanako\n");

	}else{

		printf("Jiro\n");
	}

	return 0;
}



Measured memory_bytes: 3536
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
 int n;
  cin >> n;
  
  n%=10;
  
  if(n==2||n==4||n==5||n==7||n==9) cout << "hon" << endl;
  else if(n==3) cout << "bon" << endl;
  else cout << "pon" << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}  

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    if(t.length()!=s.length()+1){
        cout<<"No";
        return 0;
    }
    for(int i=0;i<s.length();i++){
        if(s[i]!=t[i]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 3652
n, k, s = map(int, input().split())

res = []
if s < 10 ** 9:
    for i in range(n):
        if i + 1 <= k:
            res.append(s)
        else:
            res.append(s + 1)
else:
    for i in range(n):
        if i + 1 <= k:
            res.append(s)
        else:
            res.append(1)
            
print(*res)


Measured memory_bytes: 9584
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int tmp = 0;

        if(N % 2 == 0) {
            tmp = N / 2;
        } else tmp = N / 2 + 1;

        System.out.println((double)tmp / N);       
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;int a[5],pd1,pd2;string s;int main() {cin >> s;for (int i = 0; i < 4; i++) a[i] = s[i] - '0';if (a[2]*10+a[3]<=12&&a[2]+a[3]!=0) pd1=1;if (a[0]*10+a[1]<=12&&a[0]+a[1]!=0) pd2=1;if (pd1&&!pd2) cout << "YYMM\n";else if (!pd1&&pd2) cout << "MMYY\n";else if (pd1&&pd2) cout << "AMBIGUOUS\n";else if (!pd1&&!pd2) cout << "NA\n";return 0;}

Measured memory_bytes: 3612
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, C, D = il()
    T = min(B, D) - max(A,C)
    print(0 if T <= 0 else T)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10072
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define mod 1000000007

int main(){
  ll n,k; cin>>n>>k;
  ll ans=0,sum=0;
  while(1){
      ll need=(sum+k-1)/k;
      if(need==0)need=1;
      if(n<need)break;
      n-=need;
      sum+=need;
      ans++;
  }
  cout<<ans<<endl;
  return 0;
}



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

using Pi = pair<int, int>;
using ll = long long;
constexpr ll mod = 1000000007;

int H, W;
bitset <25601> dp[88][88];
constexpr int offset = 12800;

inline bitset <25601> left_shift(bitset <25601> b, int num) {
    if (num > 0) return (b << num);
    else return (b >> -num);
}

int main() {
    int A[88][88];
    int B[88][88];
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> B[i][j];
        }
    }
    
    dp[0][0][A[0][0] - B[0][0] + offset] = true;
    dp[0][0][B[0][0] - A[0][0] + offset] = true;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (i > 0) {
                dp[i][j] |= left_shift(dp[i - 1][j], B[i][j] - A[i][j]);
                dp[i][j] |= left_shift(dp[i - 1][j], A[i][j] - B[i][j]);
            }
            if (j > 0) {
                dp[i][j] |= left_shift(dp[i][j - 1], B[i][j] - A[i][j]);
                dp[i][j] |= left_shift(dp[i][j - 1], A[i][j] - B[i][j]);
            }
        }
    }
    int minv = 50000;
    for (int i = 0; i <= 25600; i++) {
        if (dp[H - 1][W - 1][i]) minv = min(minv, abs(offset - i));
    }
    cout << minv << endl;
    return (0);
}


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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;
const int T = 1e4 + 3;
const int N = 1e3 + 2;
const int OK = 1e6 + 10;

bitset<N> crivo;
int maxDiv[OK];
vector<int> primes;
ll v[T];

void init() {
    for(int i = 2; i < N; i++) {
        if(!crivo[i]) {
            primes.pb(i);
            for(int j = i+i; j < N; j += i) crivo[j] = 1;
        }
    }
}

ll expo(ll base, ll e) {
    ll ans = 1;
    while(e) {
        if(e&1) ans = (ans * base) % MOD;
        base = (base * base) % MOD;
        e >>= 1;
    }
    return ans;
}

void decop(int x) {
    for(int i = 0; i < primes.size() and primes[i]*primes[i] <= x; i++) {
        int d = 0;
        while(x % primes[i] == 0) d++, x /= primes[i];
        maxDiv[primes[i]] = max(maxDiv[primes[i]], d);
    }
    if(x > 1) maxDiv[x] = max(maxDiv[x],1);
}

int main() {
    ios_base::sync_with_stdio(false);
    init();
    int n; cin >> n;
    ll tira = 0;

    for(int i = 0; i < n; i++) {
        cin >> v[i];
        decop(v[i]);
    }

    ll acum = 1;
    for(ll i = 0; i < OK; i++) {
        ll ok = 1;
        while(maxDiv[i]) ok = (ok * i) % MOD, maxDiv[i]--;
        if(ok > 1) acum = (acum * ok)%MOD;
    }

    ll ans = 0;
    for(int i = 0; i < n; i++) {
        ll ok = (acum*expo(v[i],MOD-2))%MOD;
        ans = (ans + ok) % MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <math.h>

using namespace std;
int n;
double Minkowski_dist (int x[], int y[], int p)
{
    double result = 0;
    for (int i = 0; i < n; i++)
        result += pow(abs(x[i] - y[i]), p);
    result = pow(result, 1.0 / p);
    return result;
}
double Minkowski_dist_inftly(int x[], int y[])
{
    double result = 0;
    double temp;
    for (int i = 0; i < n; i++)
    {
        temp = abs(x[i] - y[i]);
        if(temp > result)
            result = temp;
    }
    return result;
}
int main()
{
    cin >> n;
    int x[n], y[n];
    for (int i = 0; i < n; i++)
        cin >> x[i];
    for (int i = 0; i < n; i++)
        cin >> y[i];

    for (int i = 1; i <= 3; i++)
        printf("%.6f\n", Minkowski_dist(x, y, i));
    printf("%.6f\n", Minkowski_dist_inftly(x, y));
    return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, j, a, b;
	ll ans = 0;
	cin >> num;
	vector<ll> d(100, 0);
	for (i = 1; i <= num; i++) {
		a = i;
		while (a >= 10)
			a /= 10;
		b = i % 10;
		d[a * 10 + b]++;
	}
	rep(i, 10) {
		rep(j, 10) {
			ans += d[10 * i + j] * d[10 * j + i];
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
rat = [list(map(int, input().split(' '))) for _ in range(n)]
a = 1
b = 1
for i in range(n):
    x = max(-(-a//rat[i][0]), -(-b//rat[i][1]))
    a = x*rat[i][0]
    b = x*rat[i][1]
print(a+b)



Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define pb push_back
#define int long long
using namespace std;

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

char ch[10001];

int n,m,ans,sum[10001][4];

signed main()
{
	n=read();
	scanf("%s",ch+1);
	for ( int i=1;i<=n;i++ ) 
	{
		for ( int j=0;j<=2;j++ ) sum[i][j]=sum[i-1][j];
		if(ch[i]=='B') sum[i][2]++;
		if(ch[i]=='G') sum[i][1]++;
		if(ch[i]=='R') sum[i][0]++;
	}
	for ( int i=1;i<=n;i++ ) 
		for ( int j=i+1;j<=n;j++ ) 
		{
			int pos=j-i+j;
			if(ch[i]=='R'&&ch[j]=='G') ans+=sum[n][2]-sum[j][2]-(ch[pos]=='B');
			if(ch[i]=='R'&&ch[j]=='B') ans+=sum[n][1]-sum[j][1]-(ch[pos]=='G');
			if(ch[i]=='G'&&ch[j]=='B') ans+=sum[n][0]-sum[j][0]-(ch[pos]=='R');
			if(ch[i]=='G'&&ch[j]=='R') ans+=sum[n][2]-sum[j][2]-(ch[pos]=='B');
			if(ch[i]=='B'&&ch[j]=='G') ans+=sum[n][0]-sum[j][0]-(ch[pos]=='R');
			if(ch[i]=='B'&&ch[j]=='R') ans+=sum[n][1]-sum[j][1]-(ch[pos]=='G');
		}
	printf("%lld\n",ans);
	return 0;
}
		

Measured memory_bytes: 3852
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#define endl '\n'
//#define ll long long
#define mod 1000000007
#define NCONS 100001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
#define int long long
//#define double long double
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
typedef long long ll;

int gcd(int a, int b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }

#define YYYY cout << "YES" << endl
#define NNNN cout << "NO" << endl
#define yyyy cout << "Yes" << endl
#define nnnn cout << "No" << endl

int32_t main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    priority_queue<double, vector<double>, greater<double>> pq;
    while(N--)
    {
        double v; cin >> v; pq.push(v);
    }
    
    auto cur = pq.top(); pq.pop();
    
    while(!pq.empty())
    {
        auto temp = pq.top(); pq.pop();
        cur += temp;
        cur /= 2;
    }
    
    
    cout << cur << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string S;
  cin>>S;
  sort(ALL(S));
  if(S=="abc")
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
const ll mod = 1000000007;

int n,m,a[100005];
vector<int>edge[100005];
int x[200005],y[200005];
vector<P>vec;
map<int,vector<int>>M;
int dist[100005];
vector<int>G[100005];
int col[100005];

int main(){
	scanf("%d%d",&n,&m);
	repn(i,n){
		scanf("%d",&a[i]);
		M[a[i]].pb(i);
	}
	repn(i,m){
		scanf("%d%d",&x[i],&y[i]);
		edge[x[i]].pb(y[i]);
		edge[y[i]].pb(x[i]);
	}
	repn(i,n){
		rep(j,edge[i].size()){
			int to = edge[i][j];
			if(a[i] >= a[to]) goto nxt;
		}
		puts("-1"); return 0; nxt:;
	}
	bool f = 0;
	
	for(auto aa:M){
		int val = aa.fi;
		vector<int>&vi = aa.sc;
		queue<int>que;
		set<int>S;
		rep(i,vi.size()) S.insert(vi[i]);
		
		rep(i,vi.size()){
			int x = vi[i];
			rep(j,edge[x].size()){
				int to = edge[x][j];
				if(a[to] < val){
					col[x] = -1*col[to];
					que.push(x);
					S.erase(S.find(x));
					break;
				}
			}
		}
		
		while(1){
			f = 1;
			while(!que.empty()){
				int v = que.front();
				que.pop();
				rep(i,edge[v].size()){
					int to = edge[v][i];
					if(a[to] == val && col[to] == 0){
						col[to] = -1*col[v];
						S.erase(S.find(to));
						que.push(to);
					}
				}
			}
			if(S.empty()) break;
			int x = *S.begin();
			S.erase(S.begin());
			
			{
				col[x] = 1;
				rep(i,edge[x].size()){
					int to = edge[x][i];
					if(a[to] == val){
						col[to] = -1;
						que.push(to);
						S.erase(S.find(to));
					}
				}
			}
		}
	}
	repn(i,n) printf(col[i]==1?"B":"W"); puts("");
	repn(i,m) printf("%d\n",max(a[x[i]],a[y[i]]));
}

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

#define  int        long long int
 #define    sp(x)                 setprecision(x)
#define    bp(x)           __builtin_popcount(x)
 #define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

int32_t main()
{
    fast
    int n,x=1000,y=0;
    cin>>n;
    int a[n+2];
    f(i,1,n)    cin>>a[i];
    a[n+1]=-1;
    f(i,1,n)
    {
        if(a[i]<a[i+1])
        {
            int z=x/a[i];
            x-= z*a[i];
            y+=z;
        }
        else
        {
            x+= y*a[i];
            y=0;
        }
    }
    cout<<x;
}


Measured memory_bytes: 3652
#include <stdio.h>

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    int par = 0, impar = 0;
    for (int i = 1; i < n; ++i)
        par += i;
    for (int i = 1; i < m; ++i)
        impar += i;
        
    printf("%d\n", par+impar);
    return 0;
}


Measured memory_bytes: 128