akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
typedef long long ll;
using namespace std;
class UnionFind{
public:
    vector<ll> p;
    vector<ll> s;
    UnionFind(ll sz_):p(sz_),s(sz_,1LL){
        for(ll i=0;i<sz_;i++)p[i] = i;
    }
    void init(ll sz_){
        p.resize(sz_);
        s.assign(sz_,1LL);
        for(ll i=0;i<sz_;i++)p[i] = i;
    }

    ll root(ll x){
        while(p[x] != x){
            x = p[x] = p[p[x]];
        }
        return x;
    }

    bool merge(ll x,ll y){
        x = root(x);
        y =root(y);
        if(x ==y)return false;
        if(s[x] < s[y])swap(x,y);
        s[x] += s[y];
        p[y] = x;
        return true;
    }

    bool same(ll x,ll y){
        return root(x) == root(y);
    }

    ll size(ll x){
        return s[root(x)];
    }
};

int main(){
    ll n,m;cin >> n >> m;
    ll a[m],b[m];
    for(int i=0;i<m;i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    ll ans[m];
    UnionFind tree(n);
    ans[m-1] = (n*(n-1))/2;
    for(int i=m-1;i>0;i--){
        if(tree.same(a[i],b[i])){
            ans[i-1] = ans[i];
        }
        else if(ans[i] - tree.size(a[i])*tree.size(b[i]) <= 0){
            ans[i-1] = 0;
        }
        else{
            ans[i-1] = ans[i] - tree.size(a[i])*tree.size(b[i]);
        }
        tree.merge(a[i],b[i]);
    }

    for(int i=0;i<m;i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5248
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        
        if(B + C <= A){
            System.out.println(0);
        }else{
            System.out.println(C - (A - B));
        }
    }
}

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

using namespace std;
typedef long long ll;
typedef pair <int, int> pp;
#define MAXN 1000005
#define MAXC 205
#define MAXP 25
#define A first
#define B second
#define MP make_pair
#define PB push_back
const ll INF = 2e9+13;
const ll MOD = 1e9+7;

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int P[MAXN], Q[MAXN];
	int N;
	cin >> N;
	for(int i=0; i<N; i++) cin >> P[i];
	for(int i=0; i<N; i++) cin >> Q[i];
	
	ll inc = 0;
	for(int i=0; i<N; i++) if(P[i] > Q[i]) { inc += 2LL*(P[i]-Q[i]); Q[i] = P[i]; }
	//cout << inc << endl;
	for(int i=0; i<N; i++) {
		if(P[i] < Q[i]) {
			inc -= (ll)((Q[i]-P[i])/2LL) * 2LL;
			P[i] = Q[i];
		}
	}
	//cout << inc << endl;
	if(inc <= 0) { cout << "Yes" << endl; }
	else cout << "No" << endl;
		
	
}

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



int main() {
int N;
  cin>>N;
  string S,T;
  cin>>S>>T;
  
  for(int i=0;i<N;i++){
    cout<<S[i]<<T[i];
  }
  cout<<endl;
  
  
  
}


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

using namespace std;

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

const int K = 15000;
const int N = 80;

int h, w;
int a[N][N], b[N][N];
bool dp[N][N][2*K];

int put(int x) {
  return x + K;
}

int get(int x) {
  return x - K;
}

int main() {
  scanf("%d%d", &h, &w);
  FOR(i, h) FOR(j, w) scanf("%d", &a[i][j]);
  FOR(i, h) FOR(j, w) scanf("%d", &b[i][j]);
  
  dp[0][0][put(a[0][0] - b[0][0])] = dp[0][0][put(b[0][0] - a[0][0])] = true;
  FOR(i, h) FOR(j, w) {
    if (!i && !j) continue;
    int raz = a[i][j] - b[i][j];
    FOR(di, 2) FOR(dj, 2) {
      if (di == dj) continue;
      if (i - di < 0 || j - dj < 0) continue;
      FOR(u, (2 * K)) {
         if (!dp[i-di][j-dj][u]) continue;
         dp[i][j][u + raz] = dp[i][j][u - raz] = true;
      }
    }
  }

  int mini = 1e9;

  FOR(u, (2*K)) {
    if (!dp[h-1][w-1][u]) continue;
    mini = min(mini, abs(get(u)));
  }

  printf("%d\n", mini);

  return 0;
}


Measured memory_bytes: 186240
#include<bits/stdc++.h> 
using namespace std;
char a[200010];
int main()
{
	int n,rz=0,r=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]=='R')
		rz++;
	}
	for(int i=1;i<=rz;i++)	
	if(a[i]=='R')
	r++;
	cout<<rz-r;
	return 0;
}

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

typedef long long ll;

int main(int argc, char const *argv[])
{
    int n,x;scanf("%d %d",&n,&x);
    if(x == 1 or x == 2*n - 1){
        printf("No\n");return 0;
    }else{
        printf("Yes\n");
        if(n==2){
            cout << "1 2 3" << endl;
            return 0;
        }
        queue<int> q;
        vector<int> ans(2*n-1,-1);
        if(x == 2){
            ans[n-2] = x+1,ans[n-1] = x,ans[n] = x-1,ans[n+1] = x+2;
            for(int i = 1;i <= 2*n-1;i++){
                if(i < x-1 or i > x+2)q.push(i);
            }
            for(int i = 0;i < 2*n-1;i++)if(ans[i] == -1)ans[i] = q.front(),q.pop();
            for(int i = 0;i < 2*n-1;i++){
                if(!i)printf("%d",ans[i]);
                else printf(" %d",ans[i]);
            }
            printf("\n");
        }else{
            ans[n-2] = x-1,ans[n-1] = x,ans[n] = x+1,ans[n+1] = x-2;
            for(int i = 1;i <= 2*n-1;i++){
                if(i < x-2 or i > x+1)q.push(i);
            }
            for(int i = 0;i < 2*n-1;i++)if(ans[i] == -1)ans[i] = q.front(),q.pop();
            for(int i = 0;i < 2*n-1;i++){
                if(!i)printf("%d",ans[i]);
                else printf(" %d",ans[i]);
            }
            printf("\n");
        }
    }
    return 0;
}

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

int main(){
	string S; cin>>S;
	string T = "ACGT";

	int maxi = 0, count = 0;
	rp(s,S.size()){
		rp(e,S.size()){
			bool exist = true;
			for(int k=s; k<=e; ++k){
				char s = S[k];
				if(T.find(s)>=T.size()){
					exist = false;
					break;
				}
			}
			maxi = max(maxi, (e-s+1)*exist);
		}
	}
	cout<< maxi <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979323846

typedef struct{
  double x;
  double y;
}zahyou;
void kock(int,zahyou,zahyou);

int main(){
  int n;
  zahyou a,b;
  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  scanf("%d",&n);
  printf("%f %f\n",a.x,a.y);
kock(n,a,b);
printf("%f %f\n",b.x,b.y);
  return 0;
}
 
void kock(int n,zahyou p1,zahyou p2){
  zahyou s,t,u;
  if (n == 0)
    return;
  s.x=(2*p1.x+p2.x)/3;    
        s.y=(2*p1.y+p2.y)/3;    
    t.x=(p1.x+2*p2.x)/3;   
    t.y=(p1.y+2*p2.y)/3;    
    u.x=(t.x-s.x)*cos(60* PI / 180.0)-(t.y-s.y)*sin(60* PI / 180.0)+s.x;    
      u.y=(t.x-s.x)*sin(60* PI / 180.0)+(t.y-s.y)*cos(60* PI / 180.0)+s.y;
   
  kock(n-1, p1, s);
  printf("%f %f\n",s.x,s.y);
      kock(n-1, s, u);
      printf("%f %f\n ",u.x,u.y);
      kock(n-1, u, t);
      printf("%f %f\n",t.x,t.y);
      kock(n-1, t, p2);


}

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

int main(){
  
  int N;
  cin >> N;
  int length[N];
  for(int i=0;i<N;i++){
    cin >> length[i];
  }
  int Total=0;
  sort(length,length+N);
  for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N-1;j++){
      Total += (lower_bound(length, length+N, length[i]+length[j])-length)-j-1;
    }
  }
  cout << Total << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(register int i=(a);i<(b);i++)
#define per(i,a,b) for(register int i=(b);i>=(a);i--)
#define For(i,a,b) for(register int i=(a);i<=(b);i++)
#define Forenska(it,c) for(register __typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
using namespace std;
typedef long long LL;
typedef pair<int,int> Pair;
typedef vector<int> vec;
const long double PI=3.14159265358979323846264338327950288;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const int N=1005;
int c[N],t[N];
int main()
{
    int n,T;
    cin>>n>>T;
    rep(i,0,n)
    {
    	cin>>c[i]>>t[i];
	}
	int ans=INF;
	rep(i,0,n)
	{
		if(t[i]<=T)
		{
			ans=min(ans,c[i]);
		}
	}
	if(ans<INF)cout<<ans<<endl;
	else puts("TLE");
	return 0;
}


Measured memory_bytes: 256
N,W = map(int,input().split())
L = list(list(map(int,input().split())) for i in range(N))
dp = [[0 for j in range(W+1)] for i in range(N+1)] #dp[i][j] : i番目までのitemを認めたとき、weight = j のときの最大の価値

for item in range(N) :
    weight_i,value_i = L[item]
    for weight in range(W+1) :
        if weight - weight_i >= 0 :
            dp[item+1][weight] = max(dp[item][weight], dp[item][weight - weight_i] + value_i)
        else :
            dp[item+1][weight] = dp[item][weight]

ans = dp[N][W]

print(ans)


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

#define    ll     long long int

int grid[4][4];
int a[4];
int b[4];

int main( )
{
    int i, j, k;
    int p, q, r;
    int x, y, z;
    for (i = 0; i < 3; i++) {
        for (j = 0; j < 3; j++) {
            cin >> grid[i][j];
        }
    }
    for (i = 0; i <= 100; i++) {
        for (j = 0; j <= 100; j++) {
            for (k = 0; k <= 100; k++) {
                b[0] = grid[0][0] - i;
                b[1] = grid[1][1] - j;
                b[2] = grid[2][2] - k;
                a[0] = i;
                a[1] = j;
                a[2] = k;
                int fl = 1;
                for (x = 0; fl && x < 3; x++) {
                    for (y = 0; fl && y < 3; y++) {
                        if (a[x] + b[y] != grid[x][y]) {
                            fl = 0;
                            break;
                        }
                    }
                }
                if (fl) {
                    cout << "Yes\n";
                    return 0;
                }
            }
        }
    }
    cout << "No\n";
    return 0;
}



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

using namespace std;

#define sz(x) (int)((x).size())
#define forn(i,n) for (int i=0; i < n; i++)
#define forse(i,s,e) for (int i=s; i < e; i++)
#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define time() ((double)clock() / CLOCKS_PER_SEC)

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//Debug
string to_string(const string& s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A, typename B>
string to_string(pair<A, B> p) {return "("+to_string(p.fi)+", "+to_string(p.se)+")";}
template <typename A>
string to_string(A v) {
	if(v.begin()==v.end()) return "";
	return accumulate(++v.begin(), v.end(), "{"+to_string(*v.begin()),
			[](const string& a, auto b){ return a + ", " + to_string(b);})+"}";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) false
#endif


double PI=3.141592653589793;

void solve(){
	int x,n;
	cin >> x >> n;
	vector<bool> in(102,0);
	forn(i,n){
		int k;cin >> k;
		in[k]=1;
	}
	int ans=-2,mn=INT_MAX;
	for(int i=-1;i<102;i++){
		if(i>=0&&in[i]) continue;
		if(mn>abs(x-i)){
			mn=abs(x-i);
			ans=i;
		}
	}
	cout << ans;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); 
	int T=1;
//	cin >> T;
	forse(c,1,T+1){
		//	cout << "Case #" << cid << ": ";
		solve();
	}
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;
 
#define Pr(f,...) //printf(f,##__VA_ARGS__),fflush(stdout)
 
typedef long long ll;
 
const int N=3e5+50;

int n,len,x[N],len2,l[N],r[N];
ll ans;
int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	scanf("%d%d",&n,&len);
	rep(i,1,n)scanf("%d",x+i);
	len2=len*2;
	for(int i=1,t;i<=n;++i){
		scanf("%d",&t);
		if(t%len2==0)ans+=t/len2*len2;
		else{
			ans+=(t/len2+1)*len2;
			t%=len2;
			if(t<=x[i]*2)l[i]=1;
			if(t<=(len-x[i])*2)r[i]=1;
		}
		Pr("%d:%d,%d\n",i,l[i],r[i]); 
	}
	int lb=0,lq=0;
	rep(i,1,n-1){
		if(!l[i]&&!r[i])continue;
		else if(l[i]&&r[i]){
			if(lb)--lb,++lq,ans-=len2;
			else ++lb;
		}
		else if(r[i]){
			if(lb)--lb,ans-=len2;
			else if(lq)--lq,++lb;
		}else if(l[i])++lb;
		Pr("%d,%lld\n",i,ans); 
	}
	if(!r[n])ans+=len2;
	printf("%lld\n",ans);
}

Measured memory_bytes: 3712
#undef NDEBUG
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll C2(ll n) {
	return n * (n - 1) / 2;
}

ll n = 1;
int eID(int i, int j) {
	if(i > j)
		swap(i, j);
	static map<pair<int, int>, int> mp;
	if(mp.count({i, j})) return mp.at({i, j});
	int sz = mp.size();
	return mp[{i, j}] = sz + 1;
}

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

	ll m;
	cin >> m;

	while (C2(n) < m)
		++n;

	assert(C2(n) >= m);
	if (C2(n) > m) {
		cout << "No\n";
		return 0;
	}

	cout << "Yes\n" << n << '\n';
	for(ll i = 1; i <= n; ++i) {
		cout << n - 1;
		for(int j = 1; j <= n; ++j)
			if(i != j)
				cout << ' ' << eID(i, j);
		cout << '\n';
	}
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N,K;
    cin>>N>>K;
    vector<int> x(N);
    REP(i,N) cin>>x[i];
    ll ans = 0;
    REP(i,N) {
        ans += min(x[i],K-x[i]) * 2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, s: "List[int]"):
    x = [i for i in s if i%10 != 0]
    x.sort()
    if(sum(s)%10 != 0):
        print(sum(s))
    else:
        if(x != []):
            print(sum(s)-x[0])
        else:
            print(0)

    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


int main()
{
    
    int N;
    cin >> N;
    int max=0,sec=0;
    int n1=-1,n2=-1;
    int tmp;
    for(int i=0;i<N;i++)
    {
        cin >> tmp;
        if(max < tmp)
        {
            sec = max;
            max = tmp;
            n2 = n1;
            n1 = i;
        }
        else if(sec < tmp)
        {
            sec = tmp;
            n2  = i;
        }
    }
    
    for(int i=0;i<N;i++)
    {
        if(i != n1)
        {
            cout << max << endl;
        }
        else
        {
            cout << sec << endl;
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 1664
N, K = map(int, input().split())
H = list(map(int, input().split()))
 
# N<=Kの場合、全てのモンスターを必殺技で倒して終了
# N>Kの場合、N体のモンスターのうち、体力が高い順に、K体を必殺技で倒す
# 残ったモンスターは、攻撃によって倒す
# 攻撃の回数を求める（必殺技は数えない）ことに注意する

# 計算量はO(NlogN)で間に合う
H = sorted(H, reverse=True)
ans = 0
if N > K: ans = sum(H[K:])
  
print(ans)

Measured memory_bytes: 31296
#include <stdio.h>
#include <stdlib.h>
#pragma warning (disable:4996)
int main() {
	int n, i;
	scanf("%d", &n);
	int *c;
	c = malloc(sizeof(int)*n);
	int min = 1000001, max = -1000001;
	long long int sum = 0;
	for (i = 0; i < n; i++) {
		scanf("%d", &c[i]);
		if (c[i] < min) min = c[i];
		if (c[i] > max) max = c[i];
		sum += c[i];
	}
	printf("%d %d %lld\n", min, max, sum);
	free(c);
	return 0;
}

Measured memory_bytes: 636
INF=10**18
N,M=map(int,input().split())

a,c=[],[]
for i in range(M):
    A,B=map(int,input().split())  
    C=list(map(int,input().split()))
    tmp=0
    for j in range(B):
      tmp+=1<<(C[j]-1)
    a.append(A)
    c.append(tmp)
    
dp=[[INF]*(1<<N) for i in range(M+1)]
dp[0][0]=0
for i in range(M):
    for j in range(1<<N):
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        o=(j | c[i])
        dp[i+1][o]=min(dp[i+1][o],dp[i][j]+a[i])
ans=dp[M][2**N-1]
print(ans if ans!=INF else -1)

Measured memory_bytes: 99044
#include<stdio.h>

int main(){
  long long x,k,d;
  scanf("%lld %lld %lld",&x,&k,&d);
  
  if(x<0){x=-x;}
  
  long long a=x-(d*(x/d));
  
  long long l=k-(x/d);
  
  if(l<=0){printf("%lld",x-k*d);return 0;}
  
  if(l%2==0){printf("%lld",a); return 0;}
  
  printf("%lld",d-a);
  return 0;
}


Measured memory_bytes: 2144
// Problem : C - : (Colon)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
const ld pii=3.14159265359;
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    //int T; cin >> T;
    //while(T--) 
 	//{
  //    
  //  }
	ld A,B,H,M;
	cin>>A>>B>>H>>M;
	if(H>12)H-=12;
	ld posm=(M/60)*360.0;
	ld posh=((H+M/60)/12)*360.0;
	ld angle=abs(posm-posh);
	if(angle>=180)angle=360-angle;
	ld ans=A*A+B*B-2*A*B*cos(angle*pii/180);
	cout<<setprecision(30)<<sqrt(ans)<<endl;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343
 



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


int main(){
	char matrix[101][101];
	int charCount[26];
	for(int i=0;i<101;i++){
		for(int j=0;j<101;j++){
			matrix[i][j] = 'A';
		}
	}
	for(int i=0;i<26;i++){
		charCount[i] = 0;
	}
	int H,W;
	cin >> H >> W;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin >> matrix[i][j];
			charCount[matrix[i][j]-'a']++;
		}
	}
	bool ikkodake=false;
	if(H%2 == 1 || W%2 == 1){
		ikkodake = true;
	}
	for(int i=0;i<26;i++){//奇数のがあったらダメ
		if(charCount[i]%2==1){
			if(ikkodake){
				ikkodake = false;
				charCount[i]--;
			}else{
				cout << "No" << endl;
				return 0;
			}
		}
	}
	
	int nikoarupea = 0;
	
	nikoarupea = (H/2)*(W%2) + (W/2)*(H%2);
	
	for(int i=0;i<26;i++){
		if((charCount[i]%4)!=0){//二の倍数で四の倍数じゃない数が選別される。
			if(nikoarupea < 0){
				cout << "No" << endl;
				return 0;
			}
			charCount[i] -= 2;
			nikoarupea--;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N = int(input())
C = [0] * N
D = [0] * N
for i in range(N):
    x, y = map(int, input().split())
    C[i] = (x + y, x, y)
    D[i] = (x - y, x, y)
C = sorted(C)
D = sorted(D)
# a1, x1, y2 = C[-1]
# print(C)
ans = -INF
now = abs(C[-1][1] - C[0][1]) + abs(C[-1][2] - C[0][2])
ans = max(ans, now)
now = abs(D[-1][0] - D[0][0])
ans = max(ans, now)
print(ans)

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main()
{
    int minv, maxv = -2000000000;
    int tmp, N, i;
    cin >> N;
    cin >> minv;

    FOR(i, 1, N)
    {
        cin >> tmp;
        maxv = max(maxv, tmp - minv);
        minv = min(tmp, minv);
    }

    cout << maxv << endl;
}

Measured memory_bytes: 3104
#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include <array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
//AtCoderC++.cpp

using namespace std;


int main() {
	auto Ss = vector<string>(3);
	for (size_t i = 0; i < 3; i++) {
		cin >> Ss[i];
	}
	int turn = 0;
	int next;
	while (true) {
		next = Ss[turn][0] - 'a';
		if (Ss[turn].length() == 0)break;
		Ss[turn] = Ss[turn].substr(1, Ss[turn].length() - 1);
		turn = next;
	}
	cout << char('A' + turn) << endl;
}


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

using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  int x = 0, y = 0, z = 0;
  for (int i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    if (i == 0) {
      x = a, y = b, z = c;
    } else {
      int nx = max(y + a, z + a);
      int ny = max(x + b, z + b);
      int nz = max(x + c, y + c);
      x = nx;
      y = ny;
      z = nz;
    }
  }
  cout << max(x, max(y, z)) << endl;
}


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

int main() {
	string s;cin>>s;
  	long long int count=0,ans=0;
  	for(int i=0;i<s.size();i++){
    	if(s.at(i)=='B') count++;
      	if(s.at(i)=='W') ans+=count;
    }
  cout<<ans<<endl;
}
  

Measured memory_bytes: 640
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  998244353;

     signed main(){
      
      int n,x;
      cin>>n>>x;
      if(x==1||x==2*n-1){
           cout<<"No"<<endl;
           return 0;
      }
      cout<<"Yes"<<endl;
      int ans[2*n-1];
     for(int i=0;i<2*n-1;i++)ans[i]=1+(2*n-1+i+x-n)%(2*n-1);
     swap(ans[n],ans[n-2]);
     for(int i=0;i<2*n-1;i++)cout<<ans[i]<<endl;





      }

        


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int r;
  cin >> r;
  double ans = acos(-1)*r*2;
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 3764
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = ReadInts();

            var tap_count = 0;
            var outlet_count = 1;

            while (outlet_count<ab[1])
            {
                outlet_count--;
                outlet_count += ab[0];
                tap_count++;
            }
            WriteLine(tap_count);
        }
    

    private static string Read() { return ReadLine(); }
    private static string[] Reads() { return (Read().Split()); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }


    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false;

        double sqrtNum = Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                return false;
            }
        }
        return true;
    }

    //最大公約数
    public static int Gcd(int a, int b)
    {
        if (a < b)
        {
            return Gcd(b, a);
        }
        while (b != 0)
        {
            var reminder = a % b;
            a = b;
            b = reminder;
        }
        return a;
    }

    //最小公倍数
    public static int Lcm(int a, int b)
    {
        return a * b / Gcd(a, b);
    }

    //文字数を数える
    public static int CountChar(string s, char c)
    {
        return s.Length - s.Replace(c.ToString(), "").Length;
    }
    public static void debuglist(List<int> x)
    {
        foreach (var item in x)
        {
            WriteLine(item);
        }
    }
    public static void debuglist(List<string> x)
    {
        foreach (var item in x)
        {
            WriteLine(item);
        }
    }
    public static void debugarray(int[] x)
    {
        foreach (var item in x)
        {
            WriteLine(item);
        }
    }
    public static void debugarray(string[] x)
    {
        foreach (var item in x)
        {
            WriteLine(item);
        }
    }
}
}


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

int main()
{
  int n,m;
  cin >> n >> m;
  
  int food[m] = {0};
  int k,a;
  rep(i,n){
    cin >> k;
    rep(j,k){
      cin >> a;
      food[a-1]++;
    }
  }
  
  int ans = 0;
  rep(i,m){
    if(food[i] == n){
      ans++;
    }
  }
  
  cout << ans << endl;
      
}

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

using namespace std;

int N, K;
vector<int> adj[100001];
int A[100001];
bool seen[100001];

int main()
{
    scanf("%d", &N);
    for(int i=0; i<N-1; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    memset(A, -1, sizeof A);
    scanf("%d", &K);
    for(int i=0; i<K; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        A[a]=b;
    }
    priority_queue<pair<int, int>> Q;
    for(int i=1; i<=N; i++) if(A[i]!=-1)
        Q.push({A[i], i}), seen[i]=true;
    while(!Q.empty())
    {
        int u=Q.top().second;
        Q.pop();
        for(auto& v: adj[u])
        {
            if(A[v]!=-1 && abs(A[v]-A[u])!=1)
                return printf("No\n"), 0;
            if(!seen[v])
            {
                if(A[v]==-1)
                    A[v]=A[u]-1;
                Q.push({A[v], v});
                seen[v]=true;
            }
        }
    }
    printf("Yes\n");
    for(int i=1; i<=N; i++)
        printf("%d\n", A[i]);
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int a,b,t;
    cin >> a >> b >> t;
    cout << (t/a) * b << endl;
    return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;
 
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = sc.nextInt();
 
    if ((x - a) >= 0 && (x - a) <= b) {
      System.out.println("YES");
    }
    else {
      System.out.println("NO");
    }
  }
}


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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    string s;
    cin >> s;
    vi num;
    for (auto ch : s) {
        num.push_back(ch - '0');
    }

    // 処理
    int sum = 0;
    rep(i, num.size()) { sum += num[i]; }

    // 出力
    cout << (stoi(s) % sum == 0 ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2508

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

string eki = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main()
{
	int N;
	while(cin >> N && N)
	{
		vector<int> keys(N);
		rep(nth,N){
			cin >> keys[nth];
		}
		string S;
		cin >> S;
		
		string ans;
		int pos=0;
		rep( i, S.size() )
		{
			int num;
			if('a'<= S[i] && S[i] <= 'z'){
				num = S[i] - 'a';
			}
			else if('A' <= S[i] && S[i] <= 'Z'){
				num = S[i] - 39;
			}
			char res = eki[ ( num - keys[pos] + 52 ) % 52 ];
			pos = (pos+1)%N;
			ans += res;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;
    int ans=0,id;
    int N,M;
    ll A,B,C,W;
    char a[1000][1000];
    ll sum=0;

int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>M;
    REP(i,N)REP(j,M)cin>>a[i][j];
    REP(i,N+2){
        REP(j,M+2){
            if(i==0||i==N+1||j==0||j==M+1){
                cout<<"#";
            }else{
                cout<<a[i-1][j-1];
            }
        }
        cout<<endl;
    }


    //cout<<ans;

    return 0;
}


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

int main(){
    string s;
    cin>>s;
    int a,b;
    a=stoi(s.substr(0,2));
    b=stoi(s.substr(2,2));
    if(1<=a&&a<=12&&1<=b&&b<=12) cout<<"AMBIGUOUS"<<endl;
    else if(1<=a&&a<=12&&0<=b&&b<=99) cout<<"MMYY"<<endl;
    else if(0<=a&&a<=99&&1<=b&&b<=12) cout<<"YYMM"<<endl;
    else cout<<"NA"<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()

using namespace std;

typedef vector<int> vi;
typedef long long  ll;

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

int main()
{
    ll x , y;
    cin>>x>>y;
    ll ans = 0;
    for(ll j=x;j<=y;j*=2){
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
const LL M = 1e9 + 7;
typedef pair<int, int> pii;
LL P(int n, int p) {
    if (p == 0) return 1;
    LL k = P(n, p / 2);
    if (p % 2)
        return k * k % M * n % M;
    else
        return k * k % M;
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k; cin >> k >> n;
    vector<LL> C(n + 1, 0);
    for (int i = n ; i >= 1 ; i--) {
        LL c = n / i;
        C[i] = P(c, k);
        for (int j = i * 2 ; j <= n ; j += i)
            C[i] -= C[j];
        C[i] %= M;
        C[i] += M;
        C[i] %= M;
    }
    LL ans = 0;
    for (int i = 1 ; i <= n ; i++) {
        ans += C[i] * i % M;
        ans %= M;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3988
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      auto S = new string[3];
      foreach (i; 0 .. 3) {
        S[i] = readToken();
      }
      auto L = new int[3];
      foreach (i; 0 .. 3) {
        L[i] = cast(int)(S[i].length);
      }
      
      auto oks = new bool[][][](3, 3);
      foreach (i; 0 .. 3) foreach (j; i + 1 .. 3) {
        // [-L[j], L[i]]
        oks[i][j] = new bool[L[j] + L[i] + 1];
        foreach (k; -L[j] .. L[i] + 1) {
          bool ok = true;
          foreach (x; 0 .. L[i]) {
            if (0 <= x - k && x - k < L[j]) {
              ok = ok && (S[i][x] == '?' || S[j][x - k] == '?' || S[i][x] == S[j][x - k]);
            }
          }
          oks[i][j][L[j] + k] = ok;
        }
      }
      
      int ans = L[0] + L[1] + L[2];
      foreach (k1; -L[2] - L[1] .. L[0] + L[2] + 1) {
        const l = min(0, k1);
        const r = max(L[0], k1 + L[1]);
        foreach (k2; l - L[2] .. r + 1) {
          bool ok = true;
          if (-L[1] <= k1 && k1 <= L[0]) {
            ok = ok && oks[0][1][L[1] + k1];
          }
          if (-L[2] <= k2 && k2 <= L[0]) {
            ok = ok && oks[0][2][L[2] + k2];
          }
          if (-L[2] <= k2 - k1 && k2 - k1 <= L[1]) {
            ok = ok && oks[1][2][L[2] + k2 - k1];
          }
          if (ok) {
            const ll = min(l, k2);
            const rr = max(r, k2 + L[2]);
            chmin(ans, rr - ll);
          }
        }
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 2300
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace AtCoder.Abc
{
    class QuestionC
    {
        public struct sc
        {
            public int s;
            public int c;
        }
 
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
 
            var nm = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
 
            var scArray = new sc[nm[1]];
 
            for (int i = 0; i < nm[1]; i++) {
                // 整数配列の入力
                var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
 
                scArray[i] = new sc() { s = input[0], c = input[1] };
            }
            var min = (int)Math.Pow(10, nm[0] - 1);
            if(min == 1) {
                min = 0;
            }
 
            var max = (int)Math.Pow(10, nm[0]);
 
            for (int i = min; i < max; i++) {
                var flag = true;
 
                foreach(var sc in scArray) {
                    var str = i.ToString();
                    var a = str[sc.s - 1];
                    if(a != sc.c.ToString()[0]) {
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    Console.WriteLine(i);
                    Console.Out.Flush();
 
                    return;
                }
            }
 
            Console.WriteLine(-1);
 
            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 28612
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    N=int(input())

    A=[int(input()) for i in range(N)]
    num=0
    cnt=0

    for i in range(N):
        if A[num]==2:
            print(cnt+1)
            break
        num=A[num]-1
        cnt+=1

        if i==N-1:
            print(-1)

resolve()

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

int main(){
  int n;
  cin >> n;
  vector<tuple<string,int,int>>sp(n);
  rep(i,n){
    string s;
    int p;
    cin >> s >> p;
    p = -p;
    sp.at(i) = make_tuple(s,p,i+1);
  }
  sort(sp.begin(),sp.end());
  rep(i,n){
    int ans;
    tie(ignore,ignore,ans) = sp.at(i);
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
n = int(input())
a = [0 for _ in range(n)]
xy = [[] for _ in range(n)]
for i in range(n):
  a[i] = int(input())
  for j in range(a[i]):
    xy[i].append(list(map(int, input().split())))
#print(xy)

for i in range(2**n-1, -1, -1):
  #print('0%db' % n)
  num = format(i, '0%db' % n)
  #print(num)
  flag = False
  for j in range(n):
    #print(num[j])
    if int(num[j]) == 1:
      for k in range(a[j]):
        #print(xy[j][k])
        if int(num[xy[j][k][0]-1]) != xy[j][k][1]:
          flag = True
          break
      if flag:
        break
  if not flag:
    cnt = 0
    for l in range(n):
      if int(num[l]):
        cnt += 1
    break
print(cnt)
          
      
  
  

Measured memory_bytes: 3064
/*input
1
44033055505550666011011111090666077705550301110
*/
/*
44033055505550666011011111090666077705550301110
000555555550000330000444000080000200004440000
*/
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_.pop();
    return_
}

fn main() {
    let phone = [
        vec!['.', ',', '!', '?', ' '],
        vec!['a', 'b', 'c'],
        vec!['d', 'e', 'f'],
        vec!['g', 'h', 'i'],
        vec!['j', 'k', 'l'],
        vec!['m', 'n', 'o'],
        vec!['p', 'q', 'r', 's'],
        vec!['t', 'u', 'v'],
        vec!['w', 'x', 'y', 'z'],
    ];
    let mut pos;
    let mut num;
    let mut s;
    let mut chars;
    for _ in 0..read_line().parse().unwrap() {
        chars = read_line()
            .replace("00", "0")
            .replace("00", "0")
            .chars()
            .collect::<Vec<char>>();
        pos = 0;
        num = chars[0];
        s = format!("");
        for i in 1..chars.len() {
            if chars[i] == num {
                pos = pos + 1;
            } else {
                if num == '0' {
                    pos = 0;
                    num = chars[i];
                } else {
                    s.push(
                        phone[(num.to_digit(10).unwrap() - 1) as usize][(pos
                            % phone[(num.to_digit(10).unwrap() - 1) as usize].len())
                            as usize],
                    );
                    pos = 0;
                    num = chars[i];
                }
            }
        }
        println!("{}", s);
    }
}



Measured memory_bytes: 5028
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll x(n);
    REP(i,n) cin >> x[i];
    mint ans = 0;
    mint p = 0;
    for(ll i=0;i<n-1;++i){
        mint t = mint(1)/mint(i+1);
        p += t;
        ans += p*mint(x[i+1]-x[i]);
    }
    for(ll i=1;i<=n-1;++i){
        ans *= mint(i);
    }
    cout << ans.x << endl;

    return 0;
}

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

/*............................*/

#define uint uint64_t
#define mx 100001
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<long long int, long long int>
#define mp make_pair
#define pb push_back
#define inf INT_MAX
#define pi acos(-1)
#define eps 1e-8
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / __gcd(a, b)
#define input(ara, n)          \
   for (int i = 0; i < n; i++) \
   scanf("%d", &ara[i])
#define inputl(ara, n)                   \
   for (long long int i = 0; i < n; i++) \
   scanf("%lld", &ara[i])
#define pf(a) printf("%d\n", a);
#define pfl(a) printf("%lld\n", a);
#define pfi(a) printf("%d ", a);
#define pfll(a) printf("%lld ", a);
#define sc(a) scanf("%d", &a)
#define scc(a, b) scanf("%d %d", &a, &b)
#define sccdbl(a, b) scanf("%lf %lf", &a, &b)
#define sccc(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scccdbl(a, b, c) scanf("%lf %lf %lf", &a, &b, &c)
#define scl(a) scanf("%lld", &a)
#define sccl(a, b) scanf("%lld %lld", &a, &b)
#define scccl(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
using namespace std;
int main()
{
   // int t;
   // sc(t);
   // while (t--)
   // {

   // }
   ll n, sum = 0;
   scl(n);
   ll ara[n + 1], ar[n];
   inputl(ara, n + 1);
   inputl(ar, n);
   for (ll i = 0; i < n; i++)
   {
      if (ar[i] >= ara[i])
      {
         sum += ara[i];
         ar[i] -= ara[i];
         if (i + 1 <= n && ar[i] >= ara[i + 1])
         {
            sum += ara[i + 1];
            ara[i + 1] = 0;
         }
         else if (i + 1 <= n && ar[i] < ara[i + 1])
         {
            sum += ar[i];
            ara[i + 1] -= ar[i];
         }
      }
      else
      {
         sum += ar[i];
      }
   }
   pfl(sum);

   return 0;
}


Measured memory_bytes: 5348
#include <stdio.h>
  
int main(){
  
int W,H,x,y,r;
  
scanf("%d",&W);
scanf("%d",&H);
scanf("%d",&x);
scanf("%d",&y);
scanf("%d",&r);


if(W<=x || H<=y){
    printf("No\n");
}
else if(x<r || y<r){
    printf("No\n");
}
       else{
    printf("Yes\n");
}
}

Measured memory_bytes: 2692
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Math.abs;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final long x = abs(scanner.nextLong());
        final long k = abs(scanner.nextLong());
        final long d = abs(scanner.nextLong());

        if (x / d >= k) {
            System.out.println(x - d * k);
            return;
        }

        final long k1 = x / d;
        if (k1 % 2 == k % 2) {
            System.out.println(x - d * k1);
        } else {
            System.out.println(-(x - d * (k1 + 1)));
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}
    

Measured memory_bytes: 32856
import java.util.*;
import java.text.DecimalFormat;

public class Main{
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        DecimalFormat df = new DecimalFormat("#0.000000");
        double r = input.nextDouble();
        double p = Math.PI;
        double s = r*r*p;
        double c = 2*r*p;
        String ss = df.format(s);
        String cc = df.format(c);
        System.out.println(ss + " " + cc);
    }
}


Measured memory_bytes: 28024
use std::io;
use std::str::FromStr;

fn read() -> i32 {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let x: i32 = s.trim().parse().unwrap();
    x
}

fn main() {

    let mut x = read();
    let mut i = 1;
    while x != 0{
        println!("Case {}: {}",i,x);
        x = read();
        i = i + 1;
    }
    

}


Measured memory_bytes: 5048
#include<stdio.h>
int main(){
int A,B,C,X;
scanf("%d",&A);
scanf("%d",&B);
scanf("%d",&C);
scanf("%d",&X);
int i,j,k;
int count = 0;
for(i=0;i<=A;i++)
    for(j=0;j<=B;j++)
    for(k=0;k<=C;k++)
    {
        if(500*i+100*j+50*k == X) count++;
    }

printf("%d",count);
return 0;}


Measured memory_bytes: 128