akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
long long int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sumxor,sum;
ll ans;
ll a,b,c,d,e,f,g,h,w,v;
char s[500005];
ll x[800005],y[800005],z[900005];
bool animal[500005];

int main(){	
	cin>>n;
	cin>>s;
	while(b<10){
		b++;
		//deba(b);
		animal[0]=b%2;
		animal[1]=(b/2)%2;
		for(i=1;i<n;i++){
			if(animal[i] && s[i]=='o'){
				animal[i+1] = animal[i-1];
			}else if(animal[i] && s[i]=='x'){
				animal[i+1] = !animal[i-1];
			}else if(!animal[i] && s[i]=='o'){
				animal[i+1] = !animal[i-1];
			}else{
				animal[i+1] = animal[i-1];
			}
		}
		//for(i=0;i<=n;i++){
		//	if(animal[i])pu('S');
		//	if(!animal[i])pu('W');
		//}
		//el;
		a=0;
		if(animal[0] == animal[n])a++;
		if(s[0]=='o' && animal[1]==animal[n-1] && animal[0])a++;
		if(s[0]=='x' && animal[1]!=animal[n-1] && animal[0])a++;
		if(s[0]=='o' && animal[1]!=animal[n-1] && !animal[0])a++;
		if(s[0]=='x' && animal[1]==animal[n-1] && !animal[0])a++;
		//deba(a);
		if(a<=1){
			continue;
		}else{
			for(i=0;i<n;i++){
				if(animal[i]){
					pu("S");
				}else{
					pu("W");
				}
			}
		}
		el;
		return 0;
	}
	p(-1);
	
	//p(ans);
	return 0;
}

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

int main(){
  int x, y, r=1;

  cin >> x >> y;

  while(r>0){
  if (x > y){
    r = x % y;
  } else {
    r = y % x;
    y=x;
  }

  // cout << x << " " << y << " " << r << endl;

  x=y; y=r;

  }

  cout << x << endl;

  return 0;
}

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

#define PrintLn(X) cout << X << endl
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)

int main(void)
{
	int N;
	cin >> N;
	int count = 0;
	Rep(i, N){
		int a;
		cin >> a;
		if(a % 2 == 1){
			count++;
		}
	}
	if(count % 2 == 0){
		PrintLn("YES");
	}else{
		PrintLn("NO");
	}
	return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class ABC178B
    {
        // https://atcoder.jp/contests/abc178/tasks/abc178_b
        static void Main(string[] args)
        {
            var items = Console.ReadLine().Split();
            Int64 a = Int64.Parse(items[0]);
            Int64 b = Int64.Parse(items[1]);
            Int64 c = Int64.Parse(items[2]);
            Int64 d = Int64.Parse(items[3]);

            Int64 max = Math.Max(a * c, a * d);
            max = Math.Max(max, b * c);
            max = Math.Max(max, b * d);

            Console.WriteLine(max);
        }
    }
}


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

struct UnionFind {
  vector<int> par;

  UnionFind(int n) : par(n, -1) { }

  int root(int x) {
    if (par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }

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

  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;

    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;

    return true;
  }

  int size(int x) {
    return -par[root(x)];
  }
};

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

  int N,M;
  cin >> N >> M;

  UnionFind uf(N+1);
  
  vector<int> P(N);
  rep(i, N) cin >> P[i];

  rep(i, M) {
    int x,y; cin >> x >> y;
    uf.merge(x, y);
  }

  int ans = 0;
  rep(i, N) {
    if(uf.same(P[i], i + 1)) {
      ans++;
    }
  }

  cout << ans << endl;
}


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

#define FOR( i, m, n )   for( int i = m; i < n; i++ )
#define REP( i, n )      FOR( i, 0, n )
#define ALL( a )         (a).begin(), (a).end()

typedef long long ll;

int main(){
  string o, e;

  cin >> o >> e;

  REP( i, o.size() + e.size() ){
    if( ( i + 1 ) % 2 == 1 ) cout << o[i / 2];
    else cout << e[i / 2];
  }
  cout << endl;
}


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

int main(){
    //入力
    int N, L, T; cin >> N >> L >> T;
    int X[100100], W[100100];
    for(int i=0; i<N; i++){
        cin >> X[i] >> W[i];
    }
    //
    //最終的な位置を計算
    int fin[100100];
    int pos;
    for(int i=0; i<N; i++){
        if(W[i]==1){
            fin[i] = (T+X[i]) % L;
        }
        if(W[i]==2){
            fin[i]= (X[i]-T) %L;
            if(fin[i]<0) fin[i] +=L;
        }
    }
    pos=fin[0];
    sort(fin,fin+N);
    //0が他のものと何回ぶつかるか
    int num=0;
    for(int i=1; i<N; i++){
        if(W[i]==W[0]) continue;
        int dis;
        if(W[0]==1) dis=X[i]-X[0];
        else dis=L-(X[i]-X[0]);
        if(dis > 2*T) continue;
        num += (2*T-dis)/L +1;
    }
    num %=N;
//    cout << num << endl;
    //
    int ans[100100];
    if(W[0]==1){
        int x = upper_bound(fin,fin+N,pos)-fin-1;
        for(int i=0; i<N; i++){
            if(x+i < N){
                ans[(num+i)%N] = fin[x+i];
            }
            else{
                ans[(num+i)%N] = fin[x+i-N];
            }
        }
    }
    else{
        int x =lower_bound(fin,fin+N,pos)-fin;
        for(int i=0; i<N; i++){
            if(x+i<N){
                ans[(N-num+i)%N]=fin[x+i];
            }
            else{
                ans[(N-num+i)%N]=fin[x+i-N];
            }
        }
    }
    for(int i=0; i<N; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 2816
#include "bits/stdc++.h"
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define bisea binary_search
#define unsort(vec) sort(vec); rever(vec);
#define cend cout<<endl;
#define gcd __gcd
using namespace std;

int n,k,dp[100010],vec[100010];
signed main() {
	cin>>n>>k;
	for(int i=1;i<=n;i++) {
		cin>>vec[i];
		dp[i]=inf;
	}
	dp[1]=0;
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=k;j++) {
			dp[i+j]=min(dp[i+j],dp[i]+abs(vec[i]-vec[i+j]));
		}
	}
	cout<<dp[n]<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define pb(s) push_back(s)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
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(b<a)a=b;}
long long fac(ll a) {
 long long ans=1;
 while(a>1){
 ans*=a;
 ans%=1000000007;
     a--;
    }
    return ans;
     }
int main() {
  
  string S;
  cin >>S;
  
  ll x=S.size();
  ll count=0;
  ll a=0;
  ll b=0;
  rep(i,x) {
    if(S.at(i)=='B') {
      count++;
    }
  }
  
  
  rep(i,x) {
    if(S.at(i)=='B') {
	a +=(x-1)-i-b;
      b++;
    }
  }
  cout<<a<<endl;
}
    
    


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

pll LRcon(pll LR0, pll LR1) {
	pll ans;
	ans.first = -1;
	ans.second = pow(10, 18);
	ans.first = max(ans.first, LR0.first);
	ans.first = max(ans.first, LR1.first);
	ans.second = min(ans.second, LR0.second);
	ans.second = min(ans.second, LR1.second);
	if (ans.first > ans.second)
		ans.first = ans.second + 1;
	return ans;
}

ll lentmp(pll LR) {
	ll lentmp = LR.second - LR.first + 1;
	lentmp = max(lentmp, (ll)0);
	return lentmp;
}

int main() {
	int N;
	cin >> N;
	vector<pll> len(N);
	vector<pll> LR(N);
	rep(i, N) {
		ll l, r;
		cin >> l >> r;
		LR[i].first = l;
		LR[i].second = r;
		len[i].first = r;
		len[i].second = i;
	}
	sort(len.begin(), len.end(), less<pll>());
	int j;
	j = len[0].second;
	pll LR0 = LR[j];
	j = len[1].second;
	pll LR1 = LR[j];
	ll ansmax;
	for (int i = 2; i < N; i++) {
		pll LR0_nxt;
		pll LR1_nxt;
		ansmax = 0;
		ll anstmp;
		j = len[i].second;
		pll LRtmp = LR[j];
		pll LRnew;

		anstmp = 0;
		LRnew = LRcon(LR0, LR1);
		anstmp += lentmp(LRnew);
		anstmp += lentmp(LRtmp);
		if (ansmax <= anstmp) {
			ansmax = anstmp;
			LR0_nxt = LRnew;
			LR1_nxt = LRtmp;
		}

		anstmp = 0;
		LRnew = LRcon(LR0, LRtmp);
		anstmp += lentmp(LRnew);
		anstmp += lentmp(LR1);
		if (ansmax <= anstmp) {
			ansmax = anstmp;
			LR0_nxt = LRnew;
			LR1_nxt = LR1;
		}

		anstmp = 0;
		LRnew = LRcon(LR1, LRtmp);
		anstmp += lentmp(LRnew);
		anstmp += lentmp(LR0);
		if (ansmax <= anstmp) {
			ansmax = anstmp;
			LR0_nxt = LRnew;
			LR1_nxt = LR0;
		}

		LR0 = LR0_nxt;
		LR1 = LR1_nxt;
	}
	ansmax = 0;
	ansmax += lentmp(LR0);
	ansmax += lentmp(LR1);
	cout << ansmax << endl;
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

 int gcd(int a,int b){

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

 long long numbers[500005];

 int main(){

  ll n,d=0,mind;
  cin>>n;

  vector<ll>v(n);

  for(int i=0;i<n;i++){
    cin>>v.at(i);
    d += v.at(i);
  }

 d -= v.at(0)*2;
 mind = abs(d);

 for(int i=1;i<n-1;i++){

  d -= v.at(i)*2;
  mind = min(mind,abs(d));
 }

  cout<<mind<<endl;

 return 0;
 }

Measured memory_bytes: 4716
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>

using ll = long long;

using namespace std;

int main() {
    set<char> s;
    for (int i=0; i<3; i++) {
        char c; cin >> c;
        s.insert(c);
    }
    cout << (s.size() > 1 ? "Yes" : "No") << '\n';
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s=="A")
        cout << "T" << endl;
    if(s=="T")
        cout << "A" << endl;
    if(s=="C")
        cout << "G" << endl;
    if(s=="G")
        cout << "C" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    while (true) {
        int n; cin >> n;
        if(!n) break;

        vector<int> seconds(24*60*60, 0);
        rep(i, n) {
            string s, t; cin >> s >> t;
            int sh = (s[0]-'0') * 10 + (s[1]-'0');
            int sm = (s[3]-'0') * 10 + (s[4]-'0');
            int ss = (s[6]-'0') * 10 + (s[7]-'0');
            int th = (t[0]-'0') * 10 + (t[1]-'0');
            int tm = (t[3]-'0') * 10 + (t[4]-'0');
            int ts = (t[6]-'0') * 10 + (t[7]-'0');
            seconds[sh*60*60+sm*60+ss] += 1;
            seconds[th*60*60+tm*60+ts] -= 1;
        }

        vector<int> imos(24*60*60+1, 0);
        rep(i, imos.size()) imos[i+1] = imos[i]+seconds[i];
        int ans = 0;
        for(const auto& ss: imos) ans = max(ans, ss);
        cout << ans << endl;
    }
}


Measured memory_bytes: 3768
import java.util.Scanner;




public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);
    	int N=sc.nextInt();

    	String[] S=sc.next().split("");

    	int sum=0;
    	int max=-1;
    	for(int i=0;i<S.length;i++) {

    		if(S[i].equals("I")) {
    			sum++;
    		}else {
    			sum--;
    		}

    		if(max<sum) {
    			max=sum;
    		}

    	}
    	
    	if(max==-1) {
    		max=0;
    	}

    	System.out.println(max);
    }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    cin >> S;
    int ans = 0,count = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'A' || S[i] == 'T' || S[i] == 'C' || S[i] == 'G') count++;
        else{
            ans = max(ans,count);
            count = 0;
        }
    }
    ans = max(ans,count);
    cout << ans << endl;
}


Measured memory_bytes: 256
n,x=map(int,input().split())
l=list(map(int,input().split()))
c=0
t=l[0]
for a in l[1:]:
    d=t+a-x
    if d>0:
        if a<d:
            a=0
        else:
            a-=d
        c+=d
    t=a
print(c)

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

// #define multitest 1
// #define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

void solve()
{
	int l, r;
	cin >> l >> r;
	int diff = r - l + 1;
	if (diff >= 2019)
	{
		cout << 0;
		return;
	}
	l %= 2019;
	r %= 2019;
	int maxi = 2020;
	for (int i = l; i < r; ++i)
		for (int j = i + 1; j <= r; ++j)
			maxi = min(maxi, i * j % 2019);
	cout << maxi;
}

int main()
{
#ifndef Debug
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

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

// 区間交差判定
int main() {
	int N, M;
	cin >> N >> M;
	int L = 1, R = N;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		// ここ大事
		L = max(L, a);
		R = min(R, b);
	}
	// L <= RならR - L + 1, L > Rなら0
	cout << max(R - L + 1, 0) << endl;
}

Measured memory_bytes: 256
import math
import sys

x, y, r = 0, 0, 90
for i in sys.stdin.readlines():
    d, a = [int(z) for z in i.split(',')]
    if d == a == 0:
        break
    x += d * math.cos(math.radians(r))
    y += d * math.sin(math.radians(r))
    r -= a

print(int(x))
print(int(y))

Measured memory_bytes: 7976
#include <bits/stdc++.h>
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
using namespace std;
 
ll n, k;
ll a[200000];

ll Count(ll x) {
	ll ok,ng,mid,ret=0,i;
	rep(i,n) {
		if (a[i]>=0) {
			ok=-1;
			ng=n;
			while (ng-ok>=2) {
				mid=(ok+ng)/2;
				if (a[i]*a[mid]<=x) ok=mid;
				else ng=mid;
			}
			if (ok>=i) ret+=ok;
			else ret+=ok+1;
		}
		else {
			ng=-1;
			ok=n;
			while (ok-ng>=2) {
				mid=(ok+ng)/2;
				if (a[i]*a[mid]<=x) ok=mid;
				else ng = mid;
			}
			if (ok<=i) ret+=n-1-ok;
			else ret+=n-ok;
		}
	}
	return ret/2;
}

int main() {
	ll i,j;
	cin >>n >>k;
	rep(i,n) cin >>a[i];
	sort(a,a+n);	
	ll INF=(1e18);
	ll st=-INF,ed=INF,mid;
	while (ed-st>=2) {
		mid=(st+ed)/2;
		if (Count(mid)<k) st=mid;
		else ed=mid;
	}
	cout <<ed <<endl;
	return 0;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ans = 'snake'
h, w = map(int, input().split())

for i in range(h):
  i += 1
  s = [x for x in input().split()]
  if 'snuke' in s:
    ans = alphabet[s.index('snuke')] + str(i)
    break

print(ans)


Measured memory_bytes: 3060
import java.nio.charset.IllegalCharsetNameException;
import java.util.*;
import java.lang.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int lt = sc.nextInt();
		int[] t = new int[n];
		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
		}
		int count = 0;
		for (int i = 1; i < n; i++) {
			if (t[i - 1] + lt <= t[i]) {
				count += lt;
			} else {
				count += t[i] - t[i - 1];
			}
		}
		count += lt;
		System.out.println(count);
	}
}

Measured memory_bytes: 89956
// https://atcoder.jp/contests/dp/tasks/dp_d
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

#define ll long long
#define rep(i, s, n) for (ll i = s; i < n; ++i)
#define dump(x) cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define MOD 1000000007

using namespace std;

ll solve(int n, int lim, ll* w, ll* v) {
    ll dp[n + 1][lim + 1];
    rep(i, 0, n + 1) {
        rep(j, 0, lim + 1) { dp[i][j] = 0; }
    }

    rep(i, 0, n) {
        rep(j, 0, lim + 1) {
            if (w[i] <= j) {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
            } else {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }

    return dp[n][lim];
}

int main() {
    int n, lim;

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> lim;
    ll w[n], v[n];
    rep(i, 0, n) { cin >> w[i] >> v[i]; }

    ll ans = solve(n, lim, w, v);
    cout << ans << endl;
}


Measured memory_bytes: 82508
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  vector<vector<int>> info(3, vector<int> (3));
  rep(i,3) rep(j,3) cin >> info[i][j];

  vector<int> a(3);
  vector<int> b(3);

  a[0] = 0;
  rep(i,3) b[i] = info[0][i];
  rep(i,2) a[i+1] = info[i+1][0] - b[0];

  rep(i,3) {
    rep(j,3) {
      if(info[i][j] != a[i]+b[j]) { cout << "No" << endl; return 0; }
    }
  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
# 偶数桁がある場合、それより前の値は N の値に関係なく一定
# 2桁なら 9、 4桁なら 909、 なので、偶数桁の数だけ '09'をつなげて int にする
# N の桁数が奇数の時は最大の桁の奇数桁の数を足す(N = 12500 なら 12500 - 10000 + 1)    
N = input()

digit = len(N)
ans = 0

if digit != 1:
  ans = '09' * (digit // 2)
  ans = int(ans)

if digit % 2 == 1:
  ans += int(N) - 10**(digit - 1) + 1

print(ans)

Measured memory_bytes: 3316
S = input()


temp1 = int(S[:2])
temp2 = int(S[2:])

flag1 = 0
flag2 = 0

if temp1 >= 13 or temp1 == 0:
    flag1 = 1
if temp2 >= 13 or temp2 == 0:
    flag2 = 1

if flag1 == 1 and flag2 == 0:
    ans = 'YYMM'
elif flag1 == 0 and flag2 == 1:
    ans = 'MMYY'
elif flag1 == 0 and flag2 == 0:
    ans = 'AMBIGUOUS'
else:
    ans = 'NA'
print(ans)

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

int main() {
  int n,m;
  cin >> n >> m;
  long long ans = 0;
  vector<pair<long long,int>>data(n);
  for(int i = 0;i < n;i++){
    cin >> data[i].first;
    data[i].second = 1;
  }
  for(int i = 0;i < m;i++){
    int b,c;
    cin >> b >> c;
    data.push_back(make_pair(c,b));
  }
  sort(data.begin(),data.end(), greater<pair<long long,int> >());
  int cnt = 0,c = 0;
  while(cnt < n){
    if(cnt+data[c].second >= n) data[c].second = n-cnt;
    ans += data[c].first*data[c].second;
    cnt += data[c].second;
    c++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 7392
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

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

        Set<Integer> set = new HashSet<>();
        set.add(sc.nextInt());
        set.add(sc.nextInt());
        set.add(sc.nextInt());
        if (set.size() == 1) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}


Measured memory_bytes: 21844
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>

using namespace std;

#define ABS(a) ((a>0)?a:-(a))
#define MIN(a,b) ((a<b)?(a):(b))
#define MAX(a,b) ((a<b)?(b):(a))
#define FOR(i,a,n) for (int i=(a);i<(n);++i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define pnt pair <int, int>
#define mp make_pair
#define PI 3.1415926535897
#define MEMS(a,b) memset(a,b,sizeof(a))
#define LL long long
#define U unsigned

vector<vector<int>> g;
int dp[3010];
int a[3010];

int dfs(int v, int par) {
	FOR(i,0,g[v].size()) {
		int to = g[v][i];
		if (to == par) {
			continue;
		}
		if ((a[to] < a[v]) && (dfs(to, v) == 0)) {
			return 1;
		}
	}
	return 0;
}

int main()
{
#ifdef Fcdkbear
	freopen("in.txt", "r", stdin);
	double beg = clock();
	//freopen("out.txt", "w", stdout);
#endif

	int n;
	scanf("%d",&n);
	FOR(i,0,n) {
		scanf("%d",&a[i]);
	}
	g.resize(n);
	FOR(i,0,n-1) {
		int v1,v2;
		scanf("%d%d",&v1,&v2);
		v1--;
		v2--;
		g[v1].push_back(v2);
		g[v2].push_back(v1);
	}
	int was = 0;
	FOR(i,0,n) {
		int v = dfs(i, -1);
		if (v) {
			if (was) {
				printf(" ");
			}
			printf("%d", i + 1);
			was = 1;
		}
	}
	printf("\n");

#ifdef Fcdkbear
	double end = clock();
	fprintf(stderr, "*** Total time = %.3lf ***\n", (end - beg) / CLOCKS_PER_SEC);
#endif
	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <string>
#include <tuple>

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

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

  vector<vector<int>> v;
  for (int i = 0; i < m; ++i)
  {
    int k;
    cin >> k;
    vector<int> t(k);
    for (auto &e : t)
      cin >> e;
    v.emplace_back(t);
  }
  vector<int> p(m);
  for (auto &e : p)
    cin >> e;

  int cnt = 0;
  for (int bit = 0; bit < (1 << n); ++bit)
  {
    bool flag = true;
    for (int i = 0; i < m; ++i)
    {
      int sum = 0;
      for (int j = 0; j < v[i].size(); ++j)
      {
        if (bit & (1 << (v[i][j] - 1)))
          sum++;
      }
      if (sum % 2 != p[i])
        flag = false;
    }
    if (flag)
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#define MOD 100000007LL
#define INF 100000000LL
#define MAX 100001
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
struct edge{ll to,cost;};
vector<edge> G[MAX];
ll dis[MAX];
void dfs(int v,int p,ll d){
    dis[v]=d;
    for(int i=0;i<G[v].size();i++){
        if(G[v][i].to==p){
            continue;
        }
        dfs(G[v][i].to,v,d+G[v][i].cost);
    }
}
int main() {    
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        G[a].push_back({b,c});
        G[b].push_back({a,c});
    }
    int q,k;
    cin>>q>>k;
    k--;
    dfs(k,-1,0);
    for(int i=0;i<q;i++){
        int x,y;
        cin>>x>>y;
        x--;y--;
        cout<<dis[x]+dis[y]<<endl;
    }
}

                           


Measured memory_bytes: 15872
#include<stdio.h>
int main(){
	int a,b,c,tmp,i;
	scanf("%d %d %d",&a,&b,&c);
	
	for(i=1;i<=3;i++){
		if(a>b){
			tmp=b;
			b=a;
			a=tmp;		
		}else if(b>c){
			tmp=c;
			c=b;
			b=tmp;
		}
	}

	printf("%d %d %d\n",a,b,c);

	return 0;
}

Measured memory_bytes: 596
use std::io;


fn main() {
    let s = read_one::<usize>();
    let h = s / 3600;
    let m = (s - h * 3600) / 60;
    let s = s - h * 3600 - m * 60;
    println!("{}:{}:{}", h, m, s);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}


Measured memory_bytes: 5036
//Simultaneous Equation

#include <iostream>
#include <utility>
#include <cstdio>
#include <cassert>

namespace {

template <class T>
T GreatestCommonDivisor(T a, T b)
{
  // a must be less than b
  if (a > b) std::swap(a, b);

  while (a != 0) {
    T tmp = b % a;
    b = a;
    a = tmp;
  }

  return b;
}

template <class T>
T LeastCommonMultiple(T a, T b)
{
  // a must be less than b
  if (a > b) std::swap(a, b);

  T lcm = b;
  while (lcm % a != 0) {
    lcm += b;
  }

  return lcm;
}

} // unnamed namespace

int main()
{
  while (1) {
    long a, b;
    std::cin >> a >> b;
    if (std::cin.fail()) break;

    std::cout
      << GreatestCommonDivisor(a, b) << " "
      << LeastCommonMultiple(a, b) << std::endl;
  }

  return 0;
}

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

char b;
int main()
{
	cin >> b;
	if(b == 'A')
		cout << 'T' << endl;
	else if(b == 'T')
		cout << 'A' << endl;
	if(b == 'C')
		cout << 'G' << endl;
	else if(b == 'G')
		cout << 'C' << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int h[10];
    int a;
    int i;
    for (i=0; i<10; i++) {
        scanf("%d",&h[i]);
    }
    int j;
    for (j=0; j<3; j++) {
        int k;
        for (k=j+1; k<10; k++) {
            if (h[j]<h[k]) {
                a=h[k];
                h[k]=h[j];
                h[j]=a;
            }
        }
    }
    int l;
    for(l=0; l<3; l++){
        printf("%d\n",h[l]);
    }
    
    return 0;
}

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

int main(){
    
    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    
    // 2. 点数の合計が, 丁度 N となるようにするには？
    // k * k - k - 2 * N = 0 を 解いてみる.
    // k = (-1 + √(1 + 8 * N)) / 2
    int ans = (-1 + sqrt(1.0 + 8.0 * N)) / 2;
    if(ans * ans + ans < 2 * N) ans++;
    
    // 3. 出力.
    while(N){
        if(N - ans >= ans){
            printf("%d\n", ans);
            N -= ans;
            ans--;
        }else{
            printf("%d\n", ans);
            if(N - ans) printf("%d\n", N - ans);
            N = 0;
        }
    }
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
const lint MOD = 1e9+7;

signed main(){
  lint N, K; cin >> N >> K;
  lint ans = 0;
  for(lint i = N - K + 2; i <= N + 1; i++){
    ans += i;
    ans %= MOD;
  }
  lint ans1 = 0;
  for(lint i = 1; i <= K; i++){
    ans1 += i; ans1 %= MOD;
  }
  lint ans2 = 0;
  ans2 += (ans - ans1 + 1) % MOD;
  if(ans2 < 0) ans2 += MOD;
  
  for(lint i = 1; i <= N - K + 1; i++){
    ans1 += K + i;
    ans += (N - K - i + 2);
    ans1 %= MOD; ans %= MOD;
    ans2 += (ans - ans1 + 1);
    ans2 %= MOD;
    if(ans2 < 0) ans2 += MOD;
  }
  cout << ans2 << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int H, W, M; cin >> H >> W >> M;
    set<pair<int, int>> S;
    vector<pair<int, int>> hp(H), wp(W);
    for (int i = 0; i < H; i++) {
        hp[i] = make_pair(0, i);
    }
    for (int i = 0; i < W; i++) {
        wp[i] = make_pair(0, i);
    }
    for (int i = 0; i < M; i++) {
        int h, w; cin >> h >> w; h--, w--;
        S.emplace(h, w);
        hp[h].first++;
        wp[w].first++;
    }
    sort(rbegin(hp), rend(hp));
    sort(rbegin(wp), rend(wp));
    int hmax = hp[0].first;
    int wmax = wp[0].first;
    int both = 1;
    for (int i = 0; i < H && hp[i].first == hmax; i++) {
        for (int j = 0; j < W && wp[j].first == wmax; j++) {
            if (!S.count(make_pair(hp[i].second, wp[j].second))) {
                both = 0;
                goto END;
            }
        }
    }
    END:;
    cout << hmax + wmax - both << endl;
    return 0;
}


Measured memory_bytes: 21952
import Control.Applicative
import Control.Monad
 

main :: IO ()
main = do
    [a, b, c] <- map read . words <$> getLine
    putStrLn $ show (solve a b c)

solve :: Int -> Int -> Int -> Int 
solve a b c = if diff >= 0 then diff else 0
      where diff = c - (a - b)

Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>

void a(std::istream& in)
{
    int N;
    in >> N;

    std::cout << (N + 1) / 2;
}

int main(int, char* [])
{
    a(std::cin);
    return 0;
}


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

#define int long long 

int n;
int k;
int a[100010];
int b[100010];
typedef pair<int,int> P;
vector<P> vec;
signed main()
{
    cin>>n>>k;
    for(int i  = 0;i < n;i++)cin >> a[i] >> b[i];
    for(int i = 0;i  < n;i++) vec.push_back({a[i],b[i]});
    int cou = 0;
    sort(vec.begin(),vec.end());
    for(int i = 0;i < n;i++)
    {
        cou += vec[i].second;
        if(cou >= k)
        {
            cout << vec[i].first << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 4084
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;

T[][] permulate(T)(T[] items) {
  T[][] res;
  if (items.length == 1) return [items];
  foreach(uint i, T item; items) {
    res ~= remove(items.dup, i).permulate.map!((x) => item ~ x).array;
  }
  return res;
}

void solve(int[] items) {
  auto ops =
    [
     '+':(int x, int y) => x + y,
     '-':(int x, int y) => x - y,
     '*':(int x, int y) => x * y];
  
  foreach(i; permulate!(int)(items).sort) {
    foreach(char a_ch, a; ops) {
      foreach(char b_ch, b; ops) {
        foreach(char c_ch, c; ops) {
          auto num1 = a(b(c(i[0], i[1]), i[2]), i[3]);
          auto num2 = a(b(i[0], i[1]), c(i[2], i[3]));
          if (num1 == 10) {
            writeln("((( ", i[0], " ", c_ch, " ", i[1], " ) ", b_ch, " ", i[2], " ) ", a_ch, " ", i[3], " )");
            goto end;
          }
          else if (num2 == 10) {
            writeln("(( ", i[0], " ", b_ch, " ", i[1], " ) ", a_ch, " ( ", i[2], " ", c_ch, " ", i[3], " ))");
            goto end;
          }
        }
      }
    }
  }
  writeln(0);
 end:;
}

void main() {
  while(true) {
    int[] list = readln().chomp.split(" ").map!(to!(int)).array;
    if (list.filter!(x => x != 0).array == null) break;
    solve(list);
  }
}

Measured memory_bytes: 1244
N = int(input())

for i in range(N + 1):
    if i * (i + 1) // 2 == N:
        M = i
        print('Yes')
        print(M + 1)
        res = [[] for _ in range(M + 1)]
        for i in range(M + 1):
            res[i].append(M)
        cnt = 1
        for k in range(M):
            for i in range(M - k):
                res[k].append(cnt + i)
            for i in range(M - k):
                res[k + i + 1].append(cnt)
                cnt += 1
        for r in res:
            print(*r)
        break
else:
    print('No')

Measured memory_bytes: 16948
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,m,x;
  cin >> n >> m >> x;
  vec a(n,0);
  for(ll i=0;i<m;i++) {
    ll tmp;
    cin >> tmp;
    tmp--;
    a[tmp]++;
  }
  ll ans=0;
  for(ll i=0;i<x;i++) {
    ans+=a[i];
  }
  ll ans2=0;
  for(ll i=x;i<n;i++) {
    ans2+=a[i];
  }
  cout << min(ans,ans2) << endl;
}

Measured memory_bytes: 256
N = int(input())
S = list(map(int, input().split(" ")))
Exchange_Number_of_times = 0
flag = True
while flag:
    flag = False
    for j in range(N - 1, 0, -1):
        f = j - 1
        if S[j] < S[f]:
            S[j], S[f] = S[f], S[j]
            flag = True
            Exchange_Number_of_times += 1
print(' '.join(map(str,S)))
print(Exchange_Number_of_times)


Measured memory_bytes: 5600
//vec[i]の範囲外エラー表示
#define _GLIBCXX_DEBUG
//includeとusing
#include <bits/stdc++.h>
using namespace std;
//型名省略
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
using ll = long long;
using st = string;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using pll = pair<ll, ll>;
using pcc = pair<char, char>;
//定数
const ll INF = 1e9;
const ll MOD = 1e9+7;
const vl dx = {1,0,-1,0,1,0,-1,0};
const vl dy = {0,1,0,-1,0,1,0,-1};
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rrep(i,n) for(ll i = (ll) n - 1; i >= 0;i--)
#define REP(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define RREP(i,x,n) for(ll i = (ll) n - 1; i >= x; i--)
#define each(i,A) for(ll i: (vl) A)
#define all(A) A.begin(), A.end()
#define Size(A) ll(A.size())
//入力
template<typename T> T input() {T x; cin >> x; return x;}
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}
//余り切り上げ
ll ceil(ll a,ll b) {return (a + b - 1) / b;}
//最大値・最小値
template <typename T> bool chmax(T &a, const T& b) {if(a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, const T& b) {if(a > b) {a = b; return true;} return false;}
//最大公約数
ll gcd(ll a,ll b){if(a<b)swap(a,b); if(a%b==0)return b; return gcd(b,a%b);}
//最小公倍数
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//n乗の余り
ll modpow(ll x,ll n,ll mod){ll res=1;for(ll i=0;i<n;i++){res=res*x%mod;}return res;}
ll MODpow(ll x,ll n){ll res=1;for(ll i=0;i<n;i++){res=res*x%MOD;}return res;}


/*--------------------------------------------------------------------------*/

vb seen;
void dfs(const vvl &G, ll v) {
    seen[v] = true;

    for(auto next_v: G[v]){
        if(seen[next_v]) continue;
        dfs(G, next_v);
    }
}

int main() {
    ll N, M; cin >> N >> M;

    vvl G(N);
    rep(i,M){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    seen.assign(N, false);

    ll count = 0;
    rep(v,N){
        if(seen[v]) continue;
        dfs(G, v);
        count++;
    }

    cout << count - 1 << endl;
}


Measured memory_bytes: 18532
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=10000000;

bool t[26][26];

int main(){
    string a,b;
    cin >> a >> b;
    for(int i=0;i<a.length();i++){
        t[a[i]-'a'][b[i]-'a']=true;
    }
    for(int i=0;i<26;i++){
        int sum=0,tsum=0;
        for(int j=0;j<26;j++){
            sum+=t[i][j];
            tsum+=t[j][i];
        }
        if(sum>=2||tsum>=2){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
ll divisor(ll a,ll b){
  if(a % b == 0)return b;
  ll acopy = 0;
  acopy = a;
  a = b;
  b = acopy % b;
  divisor(a,b);
}
int main(){
  ll n = 0;
  cin >> n;
  ll res = 0;
  ll one,two;
  cin >> one >> two;
  res = divisor(one,two);
  for(int i = 2;i < n;i++){
    ll num = 0;
    cin >> num;
    res = divisor(res,num);
  }
  cout << res << endl;
  return 0;
}

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

int main()
{
    int n;
    string s;
    cin>>n>>s;
    int len = s.size();
    for(int i=0; i<len; i++) {
        s[i] += n;
    }
    for(int i=0; i<len; i++) {
        if(s[i] > 90) s[i] = (s[i]%90)+64;
    }
    cout<<s<<endl;
    return 0;
}

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

namespace AtCoderTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var dir = Enumerable.Range(0, int.Parse(Console.ReadLine()))
                .Select(x=> Console.ReadLine())
                .GroupBy(x => x)
                .ToDictionary(x => x.Key, x => x.Count());
            Console.WriteLine($"AC x {(dir.TryGetValue("AC", out int c1) ? c1 : 0)}");
            Console.WriteLine($"WA x {(dir.TryGetValue("WA", out int c2) ? c2 : 0)}");
            Console.WriteLine($"TLE x {(dir.TryGetValue("TLE", out int c3) ? c3 : 0)}");
            Console.WriteLine($"RE x {(dir.TryGetValue("RE", out int c4) ? c4 : 0)}");
        }
    }
}


Measured memory_bytes: 33368
using System;
// using System.Collections.Generic;
// using System.Linq;

class Program
{
    static void Main()
    {
        String[] arr = Console.ReadLine().Split();
        int S, W;
        S = int.Parse(arr[0]);
        W = int.Parse(arr[1]);
        Console.WriteLine(S <= W ? "unsafe" : "safe");
        return;
    }
}

Measured memory_bytes: 27344
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	V a(n),sum(n+1,0LL);
	int cnt=0;
	rep(i,n){
		cin>>a[i];
	}
	sort(all(a));
	rep(i,n){
		sum[i+1]=a[i];
		sum[i+1]+=sum[i];
	//	clog<<sum[i+1]<<" ";
	}
	//clog<<endl;

	rep(i,n-1){
		if(sum[i+1]*2>= sum[i+2]- sum[i+1]){
			cnt++;
		}else{
			cnt=0;
		}
	}
	cout<<cnt+1<<endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;
const double pi=2*acos(0.0);

//abc169

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,Q;
ll V[101010];
map<ll,ll> M;
ll RR[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>Q;
	V[0]=N;
	FOR(i,Q) cin>>V[i+1];
	
	ll prev=V[Q];
	M[-prev]=1;
	for(i=Q-1;i>=0;i--) if(prev>V[i]) {
		prev = V[i];
		for(auto it=M.begin(); it!=M.end() && -it->first > prev; it=M.erase(it)) {
			M[-prev] += (-it->first)/prev * it->second;
			M[-((-it->first)%prev)] += it->second;
		}
	}
	FORR(r,M) RR[-r.first] += r.second;
	
	for(i=N+1;i>=1;i--) RR[i]+=RR[i+1];
	for(i=1;i<=N;i++) _P("%lld\n",RR[i]);
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> L(N);
    for (int i = 0; i < N; ++i) scanf("%d", &L[i]);
    sort(L.begin(), L.end());

    int ans = 0;
    int endIdx = L.size() - 1 - K;
    for (int i = L.size() - 1; i > endIdx; --i) {
        ans += L[i];
    }

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

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

using lint = long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

constexpr lint INF = 1'010'000'000'000'000'017LL;
constexpr lint MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(lint i = (start); i < end; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }

lint mod(lint val, lint m){ lint res = val % m; if(res < 0) res += m; return res;}
lint modinv(lint a, lint m) { lint b = m, u = 1, v = 0; while (b) { lint t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u;}
lint modpow(lint a, lint n, lint mod) { lint res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
lint gcd(lint a, lint b){ if(a < b) swap(a, b); if(b == 0) return a; return gcd(b, a%b);}
lint lcm(lint a, lint b){ return a * b / gcd(a, b);}


//---------------------------------------------------------------

void Main()
{
    lint N, ans;
    cin >> N;
    vector<lint> d(N);
    REP(i, N)
    {
        cin >> d[i];
    }

    ans = 0;
    REP(i, N){
        FOR(j, i+1, N){
            ans += d[i] * d[j];
        }
    }

    cout << ans << endl;
}

//---------------------------------------------------------------
int main()
{
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define min(x,y) ((x)<(y)?(x):(y))
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
int main(void){
    while(1){
        int e; scanf("%d",&e);
        if(e==0) break;
        int min=e;
        for(int z=0;z*z*z<=e;z++){
            for(int y=0;y*y+z*z*z<=e;y++){
                int x=e-z*z*z-y*y;
                if(min>x+y+z) min=x+y+z;
            }
        }
        printf("%d\n",min);
    }
}



Measured memory_bytes: 2044
import os
import sys
from functools import lru_cache

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

sys.setrecursionlimit(2147483647)
INF = float("inf")

X, Y = list(map(int, sys.stdin.readline().split()))


# @debug
@lru_cache(maxsize=None)
def grundy(x, y):
    if (x, y) in [(0, 1), (1, 0), (1, 1)]:
        return 0

    gs = set()
    for i in range(2, x + 1, 2):
        gs.add(grundy(x - i, y + i // 2))
    for i in range(2, y + 1, 2):
        gs.add(grundy(x + i // 2, y - i))
    ret = 0
    while ret in gs:
        ret += 1
    return ret


# for i in range(100):
#     for j in range(100):
#         print(i, j, grundy(i, j))

# if grundy(X, Y):
#     print('Alice')
# else:
#     print('Brown')

if abs(X - Y) <= 1:
    print('Brown')
else:
    print('Alice')


Measured memory_bytes: 3572
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<set>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll


signed main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N;
    cin>>N;
    if(N%2==1){
        cout<<0<<endl;
    }else{
        ll x=N/2;
        ll ans=0;
        while(x!=0){
            ans+=x/5;
            x/=5;
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256