akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = (a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (a); i <= (long long)(n); i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

struct Edge {
    ll cost, to;
    Edge(int to_, ll cost_) : 
        to(to_), cost(cost_) { } 
};
using Graph = vector<vector<Edge> >;

void dijkstra(Graph& g, int s, v_ll &dist, v_int &prev)
{
    int n = g.size();
    dist.assign(n, LINF);
    prev.assign(n, -1);
    priority_queue<pii, vector<pii>, greater<pii> > que;

    dist[s] = 0;
    que.push(pii(0, s));
    
    while(!que.empty()) {
        pii p = que.top(); que.pop();
        int node = p.second;
        //if(dist[node] < p.second) continue;

        for(int i = 0; i < g[node].size(); i++) {
            Edge e = g[node][i];
            if (dist[e.to] > dist[node] + e.cost) {
                dist[e.to] = dist[node] + e.cost;
                que.push(pii(dist[e.to], e.to));
                prev[e.to] = node;
            }
        }
    }
}

int main(void)
{
    int n;
    cin >> n;
    Graph node(n);

    irep(i, n-1) {
        int a, b, c;
        cin >> a >> b >> c;
        node[a-1].push_back(Edge(b-1, c));
        node[b-1].push_back(Edge(a-1, c));
    }

    int q, k;
    cin >> q >> k;

    v_ll dist(n);
    v_int prev(n);

    dijkstra(node, k-1, dist, prev);

    ll ans(q);
    irep(i, q) {
        int x, y;
        cin >> x >> y;
        cout << dist[x-1] + dist[y-1] << endl;
    }

    //irep(i, n) { cout << dist[i] << endl; }
    return 0;
}
/** atcoder **/


Measured memory_bytes: 12160
import java.util.Scanner;

public class Main {
    private static Scanner sc;

    public Main() {
    }

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        new Main().solve();

    }

    private void solve() {
        String N = sc.next();
        String ans = "No";
        for (int i = 0; i < 2; i++) {
            if (N.charAt(i) == '9') {
                ans = "Yes";
            }
        }
        
        System.out.println(ans);
    }
}


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

int main()
{
        int A,B,C;
        cin >> A >> B >> C;

        if(A>B){
                int tmp = B;
                B = A;
                A = tmp;
        }
        if(B>C){
                int tmp = C;
                C = B;
                B = tmp;
        }
        if(A>B){
                int tmp = B;
                B = A;
                A = tmp;
        }

        int ans = 0;
        ans += (C-A)/2;
        ans += (C-B)/2;
        if(A%2!=C%2 && B%2!=C%2){
                ans += 1;
        }else if(A%2!=C%2 || B%2!=C%2){
                ans += 2;
        }
        cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    long long N, K;
    while(cin >> N >> K){
        long long res = 0;
        for(int b=K+1;b<=N;b++){
            if(K==0){
                res += N;
            } else {
                long long blk = N/b;
                res += blk * (b-K);
                res += max(0LL, N - blk*b - K + 1);
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
ll dp[2][10005][105];  /* dp[id][i+1][j] : 先頭からi桁目(iは0-index)までで各桁の数字の総和をdで割った余りがjとなる0以上の数の個数
                                           ただし、id = 0 のとき現時点でsと等しい。
                                           id = 1 のとき現時点でsより小さいことが確定。 */
int main() {
    string s;
    ll d;
    cin >> s >> d;
    ll n = s.size();
 
    dp[0][0][0] = 1;
    rep(id, 2) {
        rep(i, n) {
            rep(j, d) {
                ll lim = s[i] - '0';  //  先頭からi桁目にはlim以下の数を置ける
                if(id) {
                    lim = 9;
                }
                exrep(x, 0, lim) {  // 先頭からi桁目にxを置くとする
                    dp[id || x < lim][i+1][(j + x)%d] += dp[id][i][j];
                    dp[id || x < lim][i+1][(j + x)%d] %= mod;
                }
            }
        }
    }
 
    dp[1][n][0] = (dp[1][n][0] + mod -1)%mod;  // 0を余計にカウントしているので除く
    
    ll ans = 0;
    rep(id, 2) {
        ans += dp[id][n][0];
        ans %= mod;
    }
    
    out(ans);
    re0;
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

void Check(vi a,vi b){
	sort(ALL(a));
	sort(ALL(b));
	if(a!=b){
		cout<<-1<<endl;
		exit(0);
	}
}

struct UnionFind{
	vi rank,par;
	void Init(int n){
		rank.assign(n,0);
		par.assign(n,-1);
	}
	int Find(int i){
		return par[i]==-1?i:(par[i]=Find(par[i]));
	}
	bool Same(int a,int b){
		return Find(a)==Find(b);
	}
	bool Unite(int a,int b){
		a=Find(a);
		b=Find(b);
		if(a==b)
			return false;
		if(rank[a]<rank[b])
			swap(a,b);
		par[b]=a;
		if(rank[a]==rank[b])
			rank[a]++;
		return true;
	}
} uf;

void Solve(int n,vi a,vi b){
	vi v=a;sort(ALL(v));
	v.erase(unique(ALL(v)),v.end());
	uf.Init(v.size()+1);
	auto idx=[&](int x){
		return lower_bound(ALL(v),x)-v.begin();
	};
	int dif=0;
	REP(i,n)if(a[i]!=b[i]){
		uf.Unite(idx(a[i]),idx(b[i]));
		dif++;
	}
	int con=0;
	REP(i,n)if(a[i]!=b[i])
		if(!uf.Same(v.size(),idx(a[i]))){
			if(uf.Same(idx(a[n-1]),idx(a[i])))
				;
			else uf.Unite(idx(a[n-1]),idx(a[i]))
				,con++;
			uf.Unite(v.size(),idx(a[i]));
		}
	if(a[n-1]!=b[n-1])con--;
	cout<<dif+con<<endl;
}

signed main(){
	int n=read();
	vi a(n+1,0);REP(i,n)a[n]^=a[i]=read();
	vi b(n+1,0);REP(i,n)b[n]^=b[i]=read();
	Check(a,b);
	Solve(n+1,a,b);
}


Measured memory_bytes: 5736
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;
void solve(){
  int h, w; cin >> h >> w;
  vector<string> v;
  for(int i = 0; i < h; i++){
    string s; cin >> s;
    v.push_back(s);
    v.push_back(s);
  }
  for(int i = 0; i < 2 * h; i++){
    cout << v[i] << endl;
  }
  return;
}

int main(){
  solve();
  return 0;
}


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

int main(){
  int n; string s; cin>>n>>s;
  if(n%2==1)cout<<"No"<<endl;
  else{
    int m=n/2;
    if(s.substr(0, m)==s.substr(m))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

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

char table[6][5] = {
    {'a', 'b', 'c', 'd', 'e'},
    {'f', 'g', 'h', 'i', 'j'},
    {'k', 'l', 'm', 'n', 'o'},
    {'p', 'q', 'r', 's', 't'},
    {'u', 'v', 'w', 'x', 'y'},
    {'z', '.', '?', '!', ' '},
};



int main(){
    string str;
    bool na;
    string result;

    while(cin >> str){
        result = "";
        na = false;
        if(str.size() % 2){
            na = true;
        }else{
            for(int i=0; i<str.size(); i+=2){
                int col = str.at(i) - '0' - 1;
                int row = str.at(i+1) - '0' - 1;
                if(col < 0 || col >= 6 || row < 0 || row >= 5){
                    na = true;
                }else{
                    result += table[col][row];
                }
            }
        }
        if(na == true){
            cout << "NA" <<endl;
        }else{
            cout << result << endl;
        }
    }


    return 0;
}

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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

using ll = long long;
using pii = pair<int, int>;

int n;

int findP(vt<int>& a) {
    vt<int> t(sz(a));
    iota(all(t), 1);

    int cnt = 0;
    for (; t != a; cnt++, next_permutation(all(t)));
    return cnt;
}

void solve() {
    int n;
    cin >> n;
    vt<int> a(n), b(n);
    for (int &i : a) cin >> i;
    for (int &i : b) cin >> i;

    cout << abs(findP(a) - findP(b));
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


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

int main() {
  long n;
  cin >> n;
  
  vector<long> arr(n);
  for(int i = 0; i < n; ++i) cin >> arr[i];
  
  for (int i = 0;i < n; ++i) 
    if (arr[i] == 0) {cout << 0; return 0;}
  
  long prod = 1;
  for (int i = 0; i < n; ++i) {
    if (arr[i] <= 1000000000000000000 / prod) prod *= arr[i];
    else {cout << -1; return 0;}
  }
  cout << prod;
  return 0;
}
      

Measured memory_bytes: 4056
X, Y, Z, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
C = [int(_) for _ in input().split()]

A = sorted(A)
B = sorted(B)
C = sorted(C)

maxn = A[0] * B[0] * C[0]

from heapq import *

h = []


heappush(h, (-A[-1] - B[-1] - C[-1], len(A) - 1, len(B) - 1, len(C) - 1))

used = {}

for i in range(min(K, X * Y * Z)):
    v, ix, iy, iz = heappop(h)
    print(-v)
    def push(x, y, z):
        if x >= 0 and y >= 0 and z >= 0 and (x, y, z) not in used:
            heappush(h, (-A[x] - B[y] - C[z], x, y, z))
            used[x, y, z] = 1
    push(ix - 1, iy, iz)
    push(ix, iy - 1, iz)
    push(ix, iy, iz - 1)



Measured memory_bytes: 5000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int b;
  cin >> a >> b;
  
  if ((a*b)%2 != 0 ) {
      cout << "Odd" << endl;
  }else {
  	  cout << "Even" << endl;
  }
  
}

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
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;}

int main(){
	string s,s2;
	s2 = "CODEFESTIVAL2016";
	int rst = 0;
	cin >> s;
	REP(i, s2.size()) if(s[i] != s2[i]) rst++;
	cout << rst << endl;
}


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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  if((B != A && B == C) ||
     (C != B && C == A) ||
     (A != C && A == B)) cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int cnt[1000005];
#define ll long long
struct node
{
    int l,r;
    int id;
}ask[1000005];
ll q[1000005];
ll Ans[1000005];
int block;
bool cmp(node a,node b){
    if(a.l/block==b.l/block){
        return a.r<b.r;
    }
    return a.l/block<b.l/block;
}
#define il inline
inline ll read() {
    char c=getchar();ll x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0',c=getchar();}
    return x*f;
}
inline void out(ll x) {   
    if(x>9) out(x/10);   
    putchar(x%10+'0'); 
}
ll ans=0;
il void add(int pos){
    if(cnt[q[pos]]==0)ans++;
    cnt[q[pos]]++;
}
il void del(int pos){
    cnt[q[pos]]--;
    if(cnt[q[pos]]==0)ans--;
}
int main(){
    int n,t;
    int m;
    n=read(),m=read();
    for(int i=1;i<=n;++i){
        q[i]=read();
    }
    block=sqrt(n);
    for(int i=1;i<=m;++i){
        ask[i].l=read();
        ask[i].r=read();
       //cin>>ask[i].l>>ask[i].r;
        ask[i].id=i;
    }
    sort(ask+1,ask+1+m,cmp);
    int l=1;
    int r=0;
    for(int i=1;i<=m;++i){
        int L=ask[i].l;
        int R=ask[i].r;
        int id=ask[i].id;
        while(l<L)del(l++);
        while(l>L)add(--l);
        while(r<R)add(++r);
        while(r>R)del(r--);
        Ans[id]=ans;
    }
    for(int i=1;i<=m;++i){
        out(Ans[i]);
        puts("");
    }
    return 0;
}

Measured memory_bytes: 19328
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long i,j,k,n,m,s,t;
    cin>>n;
    long long c[n+3],v[n+3];
    for(i=0;i<n;i++){
        cin>>v[i];
    } s=0;
    for(i=0;i<n;i++){
        cin>>k;
        if(k<v[i]) s+=v[i]-k;
    }cout<<s;
}


Measured memory_bytes: 3504
e1,e2,e3,e4=(int(x) for x in input().split())

if 1<=e1<=100 and 1<=e2<=100 and 1<=e3<=100 and 1<=e4<=100:
    if e1==e2 and e3==e4 or e1==e3 and e2==e4 or e1==e4 and e2==e3:
        print("yes")
        
    else:
        print("no")
        


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
#define N 100010
int main(){
  int n,m,h[N],ma[N];
  cin >> n >> m;
  for(int i=1;i<=n;i++){
    cin >> h[i];
    ma[i]=0;
  }
  for(int i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    ma[a]=max(ma[a],h[b]);
    ma[b]=max(ma[b],h[a]);
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    ans+=h[i]>ma[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4416
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
signed main(){
  int n;cin>>n;
  vector<int> t(n);
  vector<int> a(n);
  rep(i,n)cin>>t[i]>>a[i];
  int res_t=t[0];int res_a=a[0];
  int buf_t=0;int buf_a=0;
  rep1(i,n-1){
    if(t[i]>=res_t&&a[i]>=res_a){
      res_t=t[i];res_a=a[i];
    }
    else{
      int k=max(res_t/t[i],res_a/a[i])-1;
      while(t[i]*k<res_t||a[i]*k<res_a){
        k++;
      }
      res_t=t[i]*k;res_a=a[i]*k;
    }
  }
  cout<<res_t+res_a<<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;
typedef long long ll;
int main() {
    ll N, P;
    cin >> N >> P;
    vector<ll> a(N);
    REP(i,N) cin >> a[i];
    REP(i,N){
        if(a[i]%2 != 0){
            cout << ll(pow(2, N-1));
            return 0;
        }
    }
    if(P == 0){
        cout << ll(pow(2, N));
    }else{
        cout << 0;
    }

    return 0;
}

Measured memory_bytes: 384
from scipy.misc import comb
from decimal import *
import math
import copy

def nClr(n,l,r):
	ans = 0
	pat = 1
	if l == 0:
		ans += 1
		l += 1

	for i in range(l-1):
		pat *= ((n-i)/(i+1))

	for i in range(l-1,r):
		pat *= ((n-i)/(i+1))
		ans +=  pat

	return int(ans)

N,A,B =  map(int,input().split(" "))
v =  list(map(int,input().split(" ")))

v.sort(reverse=True)

mean =float(sum(v[0:A]))/float(A)
whole = {}

for i in range(A):
	if v[i] in whole:
		whole[v[i]] += 1
	else:
		whole[v[i]] = 1

ran_A = copy.deepcopy(whole)

for i in range(A,N):
	if v[i] in whole:
		whole[v[i]] += 1
	else:
		whole[v[i]] = 1


if len(ran_A) == 1:
	n = min(B,whole[v[0]])
	num = nClr(whole[v[0]],A,n)
	print(mean)
	print(num)
	exit(0)


num = 1
for key,val in ran_A.items():
	if ran_A[key] != whole[key]:
		num *= comb(whole[key],ran_A[key])


print(mean)
print(int(round(num,0)))



Measured memory_bytes: 14100
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

struct edge{

long long f,s;

};

int n,m;
int s,t;
int i,j;
vector<pair<int,long long> > v[100001];

long long vis[100001],dp1[100001], dp2[100001];
long long cnt1[100001],cnt2[100001];


void dijk( int src,long long cnt[], long long dist[])
{
    int i;
    set<pair<long long,int> > s;
    set<pair<long long,int> >::iterator it;
    s.insert(make_pair(0,src));
     while(!s.empty())
    {   it=s. begin();
        long long a=it->first;
        int b=it->second; 
        dist[b]=a;
        s.erase(s.begin());
        vis[b]=1;
        for(i=0;i<v[b].size();i++)
        {
            if(vis[v[b][i].first]==0&&(dist[b]+v[b][i].second<=dist[v[b][i].first]))
            {
                if(dist[v[b][i].first]!=1e18)
                s.erase(make_pair(dist[v[b][i].first],v[b][i].first));
                
                if(dist[b]+v[b][i].second==dist[v[b][i].first])
                {
                    cnt[v[b][i].first]+= cnt[b]; 
                    if(cnt[v[b][i].first]>=mod)cnt[v[b][i].first]-=mod;
                    s.insert(make_pair(dist[v[b][i].first],v[b][i].first));
                    continue;
                }
                dist[v[b][i].first]=dist[b]+v[b][i].second;
                cnt[v[b][i].first]= cnt[b];
                if(cnt[v[b][i].first]>=mod)cnt[v[b][i].first]-=mod;
                
                s.insert(make_pair(dist[v[b][i].first],v[b][i].first));
            }
        }
    }
}
int main()
{
    cin>>n>>m;
    cin>>s>>t;
    for(i=0;i<m;i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        
        v[a].push_back({b,c});
        v[b].push_back({a,c});
    }
    
    fill(dp1,dp1+n+1, 1e18);
    fill(dp2,dp2+n+1, 1e18);
    
    
    cnt1[s]=1, cnt2[t]=1;
    dp1[s]=0;
    dijk(s,cnt1,dp1);
    fill(vis,vis+n+1, 0);
    
    dp2[t]=0;
    dijk(t,cnt2,dp2);
    
    long long total= (cnt1[t]*cnt1[t])%mod;
    
    for(i=1;i<=n;i++)
    {   
        if(2*dp1[i]==dp1[t] && 2*dp2[i]== dp1[t])
        {
            long long temp = (cnt1[i]*cnt2[i])%mod;
            temp = (temp*temp)%mod;
            total = (total - temp + mod)%mod;
        }
        
    }
    
    
    for(i=1;i<=n;i++)
    {
        for(int j=0;j<v[i].size();j++)
        {
            long long t1= dp1[i];
            long long t2= dp2[v[i][j].first];
            long long c= v[i][j].second;
            if( 2*t1<dp1[t] && 2*t2<dp1[t] && t1+t2+c== dp1[t])
            {
                long long temp = (cnt1[i]*cnt2[v[i][j].first])%mod;
                temp = (temp*temp)%mod;
                total = (total - temp + mod)%mod;
            }
            
        }
    }
    assert(total>=0);
    cout<<total;
    return 0;
}


Measured memory_bytes: 22000
#include<bits/stdc++.h>
using namespace std;
char s[205];
int main(){
	scanf("%s",s+1);
	int len=strlen(s+1);
	int ans=0;
	for(int l=1;l<=(len-1)/2;l++){
		int flag=1;
		for(int i=1,j=l+1;i<=l;i++,j++){
//printf("%c %c\n",s[i],s[j]);
				if(s[i]!=s[j])flag=0;
			}
		if(flag){
			ans=max(ans,l*2);
		}
	}
	printf("%d\n",ans);
}


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

using namespace std;
typedef long long LL;

const int N=1e5+10;
const LL Inf=1e10+10;

LL s[N],cube[N];
int n,prime[N],cntprime;
bool notprime[N];
map<LL,int>app;
map<LL,LL>r;

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

void Euler()
{
	int n=2200;
	notprime[1]=1; cntprime=0;
	for (int i=2;i<=n;++i)
	{
		if (!notprime[i]) prime[++cntprime]=i,cube[cntprime]=1ll*i*i*i;
		for (int j=1;j<=cntprime && 1ll*i*prime[j]<=n;++j)
		{
			notprime[i*prime[j]]=1;
			if (!(i%prime[j])) break;	
		}
	}
}

void Solve()
{
	Euler();
	for (int i=1;i<=n;++i)
	{
		LL rev=1,d=s[i];
		for (int j=1;j<=cntprime && prime[j]<=s[i];++j)
		{
			while (!(s[i]%cube[j])) s[i]/=cube[j],d/=cube[j];
			if (!(s[i]%prime[j]))
			{
				s[i]/=prime[j];
				if (!(s[i]%prime[j])) s[i]/=prime[j],rev*=prime[j],rev=min(rev,Inf);
				else rev*=prime[j],rev=min(rev,Inf),rev*=prime[j],rev=min(rev,Inf);
			}
		}
		LL v=sqrt(s[i]);
		if (1ll*v*v==s[i]) rev=rev*v,rev=min(rev,Inf);
		else if (rev!=Inf) {
			rev=rev*s[i],rev=min(rev,Inf); if (rev<s[i]) rev=Inf;
			if (rev!=Inf) rev=rev*s[i],rev=min(rev,Inf); if (rev<s[i]) rev=Inf;
		}
		app[d]++; r[d]=rev;
		if (d>rev) swap(d,rev);
	}
	int ans=0;
	for (auto a:app)
	{
		LL v=a.first; int ap=a.second;
		if (v==1) { ans++; continue; }
		if (v<=100000) 
		{
			LL rev=r[v];
			ans+=max(app[rev],ap);
			app[rev]=0; app[v]=0;
		}else ans+=ap;
	}
	printf("%d\n",ans);
}

int main()
{
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 16512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 1e5+10;
LL a[MAXN];
LL n,x;

int main()
{
    cin >> n >> x;
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    LL res = 0;
    LL temp;
    for(int i = 1; i < n; ++i)
    {
        if(a[i]+a[i-1] > x)
        {
            temp = a[i] + a[i-1] - x;
            res += temp;
            if(a[i] >= temp) a[i] -= temp;
            else a[i-1] -= (temp-a[i]), a[i] = 0;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=200010;
int f[N],n,m;
int dis[N],vis[N],front[N],cnt;
struct node{int to,nxt,w;}e[N<<1];
set<int>se[N];
queue<int>Q;
void Add(int u,int v,int w){e[++cnt]=(node){v,front[u],w};front[u]=cnt;}
int find(int x){if(f[x]!=x)f[x]=find(f[x]);return f[x];}
void SPFA(){
	Q.push(1);memset(dis,63,sizeof(dis));dis[1]=0;
	while(!Q.empty()){
		int u=Q.front();Q.pop();vis[u]=0;
		for(int i=front[u];i;i=e[i].nxt){
			int v=e[i].to,W;
			if(se[u].find(e[i].w)!=se[u].end())W=0;
			else W=1;
			if(dis[v]>dis[u]+W){
				dis[v]=dis[u]+W;se[v].clear();se[v].insert(e[i].w);
				if(!vis[v]){vis[v]=1;Q.push(v);}
			}
			else if(dis[v]==dis[u]+W){if(se[v].find(e[i].w)==se[v].end()){if(!vis[v]){vis[v]=1;Q.push(v);}}se[v].insert(e[i].w);}
		}
	}
}
int main(){
	n=gi();m=gi();
	for(int i=1;i<=n;i++)f[i]=i;
	for(int i=1;i<=m;i++){
		int u=gi(),v=gi(),w=gi();
		f[find(u)]=find(v);Add(u,v,w);Add(v,u,w);
	}
	if(find(1)!=find(n))return puts("-1"),0;
	SPFA();printf("%d\n",dis[n]==dis[n+1]?-1:dis[n]);
	return 0;
}


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


void solve(long long N, long long K, std::vector<long long> h){
    sort(h.begin(), h.end());
    cout <<  N-(lower_bound(h.begin(), h.end(), K)-h.begin()) << endl;
}

// 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)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&h[i]);
    }
    solve(N, K, std::move(h));
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;


int main() {
	int n;
	cin >> n;
	map<int, int> a;

	for (int i = 0;i < n;i++) {
		int j;
		cin >> j;
		a[j]++;
		if (a[j] == 2) {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
	return 0;
}
//BBBBBBBBBBBB
//int main(){
//	string s;
//	cin >> s;
//
//	for (int i = 0;i < s.length();i++) {
//		printf("x");
//	}
//
//	return 0;
//}

//AAAAAAAAAAAA
//int main() {
//	string s, t, u;
//	int a, b;
//	cin >> s >> t >> a >> b >> u;
//
//	if (s == u)a--;
//	else b--;
//
//	cout << a << " " << b << endl;
//	return 0;
//}

Measured memory_bytes: 13016
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main(){

  long long int s , t ,a[100010] ,b[100010], c[100010];
  
  cin >> s >> t ;
  
  for(int i=0;i<s;i++)
    cin >> a[i];
  
  
  for(int i=0;i<t;i++){
    
    cin >> b[i] >> c[i];
    
  }
  
  vector<pair<long long int , long long int >> p;
  
  for(int i=0;i<s;i++){
    p.push_back({a[i],1});
  }
  
  for(int i=0;i<t;i++){
  p.push_back({c[i],b[i]});
  }
  
  
  sort(p.begin(),p.end(),greater<pair<long long int,long long int>>());
  
 long long int ans = 0, res = 0;
  for(auto i : p){
    
    if(ans+i.second <= s){
      res += i.first*i.second;
      
      ans += i.second;
      
    }
    else{
      res += i.first*(s-ans);
      ans = s;
      break;
      
    }
    
  }
  
  cout << res << endl;
}
  
  


Measured memory_bytes: 8816
#include <bits/stdc++.h>
using namespace std;
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
    char suit;
    int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right){
    int i,j,k;
    int n1 = mid - left;
    int n2 = right - mid;
    for(i = 0; i < n1; i++) L[i] = A[left + i];
    for(i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1].value = R[n2].value = SENTINEL;
    i = j = 0;
    for ( k = left; k < right; k++ ){
        if( L[i].value <= R[j].value){
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(struct Card A[], int n, int left, int right){
    int mid;
    if ( left + 1 < right ){
        mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int partition(struct Card A[], int n, int p, int r){
    int i,j;
    struct Card t, x;
    x = A[r];
    i = p - 1;
    for( j = p; j < r; j++){
        if( A[j].value <= x.value ){
            i++;
            swap(A[j], A[i]);
        }
    }
    swap(A[i+1], A[r]);
    return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r){
    int q;
    if ( p < r ){
        q = partition(A, n, p, r);
        quickSort(A, n, p, q - 1);
        quickSort(A, n, q + 1, r);
    }
}

int main(){
    int n,i,v;
    struct Card A[MAX], B[MAX];
    char S[10];
    int stable = 1;

    scanf("%d", &n);

    for( i = 0; i < n; i++ ){
        scanf("%s %d", S, &v);
        A[i].suit = B[i].suit = S[0];
        A[i].value = B[i].value = v;
    }

    mergeSort(A, n, 0, n);
    quickSort(B, n, 0, n - 1);

    for( i = 0; i < n; i++){
        if ( A[i].suit != B[i].suit ) stable = 0;
    }

    if ( stable == 1 ) printf("Stable\n");
    else printf("Not stable\n");
    for( i = 0; i < n; i++){
        printf("%c %d\n", B[i].suit, B[i].value);
    }

    return 0;
}


Measured memory_bytes: 5492
#include <iostream>
using namespace std ;
int main()
{
	int i;
	char s[100001];
	cin >> s;

	int app[26] = {}; //zenbu0
	
	for (i=0; s[i] != '\0'; i++){
		app[s[i] - 'a'] = 1;
	}
	for (int i = 0; i < 26; ++i) {
		if (!app[i]) {
			printf("%c\n", (char)(i + 'a'));
			return 0;
		}
	}
	cout << "None";
	return 0;
}


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

using namespace std;

int main(void) {
    int l, r, d;
    cin >> l >> r >> d;
    if(l % d == 0){
        cout << r / d - l / d + 1 << endl;
    }
    else{
        cout << r / d - l / d << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int>a(1000000);
    vector<int>b(1000000);
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[a[i]-1]=i+1;
    }
    for(int i=0;i<n-1;i++){
        cout<<b[i]<<" "<<flush;
    }
    cout<<b[n-1]<<endl;

   return 0;
}

Measured memory_bytes: 8576
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define lint long long
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = 1e-9;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	if (!b)return T(1);
	if (b & 1)return mypow(a, b - 1) * a;
	T memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int n,a[200010],b[200010];
int main(){
	std::cin>>n;
	rep(i,n)std::cin>>a[i]>>b[i];
	std::sort(a,a+n);
	std::sort(b,b+n);
	if(n%2){
		std::cout<<b[n/2]-a[n/2]+1<<std::endl;
	}
	else{
		std::cout<<(b[n/2]+b[n/2-1])-(a[n/2]+a[n/2-1])+1<<std::endl;
	}
	return 0;
}


Measured memory_bytes: 5156
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int ans = 0;

int check(long long int n, int a, bool x3, bool x5, bool x7) {
	if (n > a)
		return 0;
	if (x3&&x5&&x7)
		ans++;
	check(n*10 + 3, a, true, x5, x7);
	check(n*10 + 5, a, x3, true, x7);
	check(n*10 + 7, a, x3, x5, true);
}

int main() {
	int n;
	cin >> n;
	check(0, n, false, false, false);

	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,d=parseMap(split(readline()))
    ans=0
    for i in 1:n
        x,y=parseMap(split(readline()))
        if x^2+y^2<=d^2
            ans+=1
        end
    end
    println(ans)
end
main()

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

int main(){
    int n, t;
    scanf("%d %d", &n, &t);
    vector<pair<int, int>> dish(n);
    for (int i = 0; i < n; i++) scanf("%d %d", &dish[i].first, &dish[i].second);
    sort(dish.begin(), dish.end());
    vector<int> dp(t, 0);
    vector<int> max_b(n, 0);
    for (int i = n - 1; i >= 0; i--){
        max_b[i] = max(max_b[i], dish[i].second);
        if (i != 0) max_b[i - 1] = max_b[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        vector<int> n_dp = dp;
        if (dish[i].first < t) n_dp[dish[i].first] = max(n_dp[dish[i].first], dish[i].second);
        for (int j = 0; j < t; j++){
            n_dp[j] = max(n_dp[j], dp[j]);
            if (j + dish[i].first < t) n_dp[j + dish[i].first] = max(n_dp[j + dish[i].first], dp[j] + dish[i].second);
            if (j != t - 1) n_dp[j + 1] = max(n_dp[j], n_dp[j + 1]);
        }
        dp = n_dp;
        if (i != n - 1) ans = max(ans, dp[t - 1] + max_b[i + 1]);
        else ans = max(ans, dp[t - 1]);
    }
    printf("%d", ans);
}

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

using namespace std;

int a[2][110];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[0][i];
  }
  for (int i = 0; i < n; i++) {
    cin >> a[1][i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = 0; j <= i; j++) {
      sum += a[0][j];
    }
    for (int j = i; j <= n - 1; j++) {
      sum += a[1][j];
    }
    if (ans < sum) {
      ans = sum;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    int a[m],b[m];
    vector<int> one,enu;
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        if(a[i]==1 || b[i]==1){
            one.push_back(max(a[i],b[i]));
        }
        if(a[i]==n || b[i]==n){
            enu.push_back(min(a[i],b[i]));
        }
    }

    sort(one.begin(),one.end());
    sort(enu.begin(),enu.end());

    bool ans=false;

    for(auto i:one){
        if(binary_search(enu.begin(),enu.end(),i)){
            ans=true;
            break;
        }
    }

    if(ans) cout<<"POSSIBLE";
    else cout<<"IMPOSSIBLE";


}

Measured memory_bytes: 2804
#include <stdio.h>
main(){
  int a,b,c,m=0,n=0;
  while(scanf("%d,%d,%d",&a,&b,&c) !=EOF){
    if(a!=b&&(a<c||b<c)&&(a+b)>c&&(a*a+b*b)==c*c) n++;
    else if(a==b&&(a+b)>c) m++;
  }
  printf("%d\n%d\n",n,m);

  return 0; 
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n;
    ll ans = 1;
    ll cnt[1010];
    cin>>n;
    m0(cnt);
    cnt[1]=1;
    
    for(int i = 2; i <= n; i++)
    {
        int tmp=i;
        int div = 2;
        while(tmp>1){
            if(tmp%div==0)
            {
                tmp/=div;
                cnt[div]++;
            }
            else
            {
                div++;
            }
        }
    }
    
    for(int i = 2; i <= n; i++)
    {
        ans*=(cnt[i]+1);
        ans%=(ll)(1e9+7);
    }
    

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
read = lambda: map(int, input().split())
n = int(input())
p = list(read())
ans = 0
for i in range(n):
    if p[i] == i + 1:
        if i < n - 1:
            p[i], p[i + 1] = p[i + 1], p[i]
        ans += 1
print(ans)

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF 1e18

#define MAX_N 1000

ll n,x;
ll a[2222];
ll mina[2222];

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>x;
	rep(i,n)cin>>a[i];
	rep(i,n)mina[i]=INF;
	ll res=INF;
	rep(k,n){
		ll sum=0;
		rep(i,n){
			minch(mina[i],a[i-k+(i-k<0?n:0)]);
			sum+=mina[i];
		}
		minch(res,k*x+sum);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
count = [0] * (N + 1)

for i in range(N):
    num = A[i]
    count[num] += 1

total = 0
for i in range(1,N+1):
    if count[i] > 1:
        total += count[i] * (count[i] - 1) / 2

for i in range(N):
    num = A[i]
    if count[num] > 2:
        result = total - (count[num] * (count[num] - 1) / 2) + ((count[num] - 1) * (count[num] - 2) / 2)
    elif count[num] == 2:
        result = total - 1
    else:
        result = total
    print(int(result))


Measured memory_bytes: 26140
#pragma warning(disable:4996)
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
using namespace std;

const int maxn1 = 60;
int fac[maxn1 + 10], cnt[maxn1 + 10];
long long getFac(long long n)
{
	long long num = 0, sum = 0, m = sqrt(n + 0.5);
	for (long long k = 2; k <= m; k++)
	{
		sum = 0;
		while (n % k == 0)
		{
			n /= k;
			sum++;
		}
		if (sum != 0)
		{
			fac[num] = k;
			cnt[num++] = sum;
		}
		m = sqrt(n + 0.5);
	}
	if (n != 1)
	{
		fac[num] = n;
		cnt[num++] = 1;
	}
	return num;
}

long long gcd(long long a, long long b)
{
	return b ? gcd(b, a % b) : a;
}


int main()
{
	long long x, y;
	scanf("%lld%lld", &x, &y);
	printf("%lld\n", getFac(gcd(x, y)) + 1);
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
//let's do it
 #include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define inf 1000000
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S second
#define F first
#define boost1 ios::sync_with_stdio(false);
#define boost2 cin.tie(0);
#define mem(a,val) memset(a,val,sizeof a)
#define endl "\n"
#define maxn 100001

int cnt[100][100];
int main()
{
	boost1;boost2;
	int i,j,n,mini;
	string s;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>s;
		for(j=0;j<s.length();j++)
		cnt[i][s[j]-'a']++;
	}
	for(i=0;i<26;i++)
	{
		mini=inf;
		for(j=1;j<=n;j++)
		mini=min(mini,cnt[j][i]);
		for(j=1;j<=mini;j++)
		cout<<char(97+i);
	}
	return 0;
}


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

int main() {
  cout << fixed << setprecision(15);
  double a, b, x;
  cin >> a >> b >> x;

  double theta = atan(2 * x / (a * b * b));
  if (b * tan(theta) > a) {
    theta = atan(2 * (a * a * b - x) / (a * a * a));
    cout << (theta * 180 / M_PI) << endl;
  } else {
    cout << 90 - (theta * 180 / M_PI) << endl;
  }
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

bool isPrime[100001];
vector<ll> p, nonPrimeOdd;
void init(){
    for(int i = 2; i <= 10000; i++) isPrime[i] = true;
    for(int i = 2; i <= 10000; i++){
        if(isPrime[i]){
            if(i != 2) p.push_back(i);
            for(int j = 2; i*j <= 10000; j++) isPrime[i*j] = false;
        }
    }
    for(int i = 2; i <= 10000; i++){
        if(i%2 == 1 && !isPrime[i]) nonPrimeOdd.push_back(i);
    }
}

ll ans[500][500];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N;
    cin >> N;
    init();
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if((i-j)%2 == 0){
                int k = (i+j)/2;
                int m = (i-j)/2+N/2;
                ans[i][j] = p[m]*p[N+k];
            }else{
                int k = (i+j)/2;
                int m = (i-j-1)/2+N/2;
                // cout << i << ' ' << j << ' ' << k << ' ' << m << endl;
                ans[i][j] = p[m]*p[m+1]*p[N+k]*p[N+k+1]+1;
            }
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            cout << ans[i][j] << ' ';
        }
        cout << endl;
    }
}

Measured memory_bytes: 5248
#include<stdio.h>
int main(void){

	int a,b,sum,c;

	while(scanf("%d %d",&a,&b)!=EOF){
		sum=a+b;
		c=0;
		while(sum>0){
			sum/=10;
			c++;
		}
		printf("%d\n",c);
	}
	return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define fst first
string s;
int id;

bool left(){
  return id < (int)s.size()-1;
}
char peek(){
  return s[id];
}
char pop(){
  return s[id++];
}
void eat(char c){
  assert(s[id] == c);
  id++;
}
int expr();
int number(){
  int res = 0;
  while (left() && isdigit(peek())) {
    res = res * 10 + pop() - '0';
  }
  return res;
}
int fact(){
  int res;
  if (isdigit(peek())) {
    return res = number();
  } else {
    eat('(');
    res = expr();
    eat(')');
    return res;
  }
}
int term(){
  int res = fact();
  while (left() && (peek() == '*' || peek() == '/')) {
    if (peek() == '*') {
      eat('*');
      res *= fact();
    } else {
      eat('/');
      res /= fact();
    }
  }
  return res;
}
int expr(){
  int res = term();
  while (left() && (peek() == '+' || peek() == '-')) {
    if (peek() == '+') {
      eat('+');
      res += term();
    } else {
      eat('-');
      res -= term();
    }
  }
  return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  REP(i,n){
    id = 0;
    cin >> s;
    cout << expr() << endl;
  }
  return 0;
}


Measured memory_bytes: 3164
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	scanner := makeWordScanner()
	n := eGetInt(scanner)
	m := eGetInt(scanner)
	sum := 0
	as := []int{}
	for i := 0; i < n; i++ {
		a := eGetInt(scanner)
		sum += a
		as = append(as, a)
	}
	sort.Ints(as)
	if ((4 * m) * as[len(as)-1-(m-1)]) < sum {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
const (
	TooLarge = math.MaxInt64
	TooSmall = math.MinInt64
)

func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func pow(a, n int) int {
	if n == 0 {
		return 1
	}
	if n == 1 {
		return a
	}
	if n%2 == 1 {
		return pow((a*a), n/2) * a
	}
	return pow((a * a), n/2)
}
func powMod(a, n, mod int) int {
	if n == 0 {
		return 1 % mod
	}
	if n == 1 {
		return a % mod
	}
	if n%2 == 1 {
		return powMod((a*a)%mod, n/2, mod) * a % mod
	}
	return powMod((a*a)%mod, n/2, mod)
}

func factoricalMod(n, count, mod int) int {
	if count == 1 {
		return n % mod
	}
	return (n % mod) * (factoricalMod(n-1, count-1, mod)) % mod
}

func combinationMod(n, a, mod int) int {
	x := factoricalMod(n, a, mod)
	y := factoricalMod(a, a, mod)
	y = powMod(y, mod-2, mod)
	return ((x % mod) * (y % mod)) % mod
}
func countBitOfOn(i, numbits int) int {
	count := 0
	var bit uint64
	for bit = 0; bit < uint64(numbits); bit++ {
		t := 1 << bit
		if i&t > 0 {
			count++
		}
	}
	return count
}

type ints []int

func ToString(slice []int) string {
	format := fmt.Sprint(slice)
	return fmt.Sprint(format[1 : len(format)-1])
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main () {
    set<int> p;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (p.find(a) != p.end()) {
            p.erase(a);
        }
        else {
            p.insert(a);
        }
    }
    cout << p.size() << endl;
}

Measured memory_bytes: 4864
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        Array.Sort(a);
        var k = int.Parse(Console.ReadLine().Trim());
        a[2] <<= k;
        Console.WriteLine(a.Sum());
    }
}


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

string a,b;
int A[1002][1002];

int lcs () {
    int ath = a.length(), bth = b.length();
    int i, j;
    for ( i = 0; i < ath; i++ ) A[i][0] = 0;
    for ( j = 0; j < bth; j++ ) A[0][j] = 0;

    for ( i = 1; i <= ath; i++ ) {
        for ( j = 1; j <= bth; j++ ) {
            if ( a[i - 1] == b[j - 1] ) A[i][j] = A[i-1][j-1] + 1;
            else if ( A[i][j-1] > A[i-1][j] ) A[i][j] = A[i][j-1];
            else A[i][j] = A[i-1][j];
        }
    }

    return A[i-1][j-1];
}

int main()
{
    int n;
    cin >> n;
    while ( n-- ) {
        cin >> a >> b;
        cout << lcs() << endl;
    }

    return 0;
}



Measured memory_bytes: 7112