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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 300111

typedef long long ll;
typedef long double ld;

vector<int> ans;

int main(){
	int k, n;
	scanf("%d%d", &k, &n);
	if(k % 2 == 0){
		ans.pb(k / 2);
		for(int i = 0; i < n - 1; i++)
			ans.pb(k);
	}
	if(k % 2 == 1){
		for(int i = 0; i < n; i++)
			ans.pb(k / 2 + 1);

		for(int cnt = 0; cnt < n / 2; cnt++){
			if(ans.back() == 1)
				ans.pop_back();

			else{
				ans.back()--;
				while(ans.size() < n)
					ans.pb(k);
			}
		}
	}
	for(int i : ans)
		printf("%d ", i);

	return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>=b)
        for(int i=1;i<=a;i++)
            cout<<b;
    else
        for(int i=1;i<=b;i++)
            cout<<a;
}

Measured memory_bytes: 256
fun solve(S: String) {
    var ans = ""
    if (S == "A") {
        ans = "T"
    } else if (S == "T") {
        ans = "A"
    } else if (S == "C") {
        ans = "G"
    } else if (S == "G") {
        ans = "C"
    }
    println(ans)
}

fun main() {
    val S = readLine()!!
//    val N = readLine()!!.toInt()
//    val (N, M) = readLine()!!.split(" ").map { it.toInt() }
//    val A = readLine()!!.split(" ").map { it.toInt() }
    solve(S)
}


Measured memory_bytes: 34564
K, N = map(int,input().split())
Alist = ["_"]
Alist += list(map(int,input().split()))
maxway = 0
for i in range(1,N+1):
    if i == N:
        temp = (K-Alist[N]) + Alist[1]
    else:
        temp = Alist[i+1] - Alist[i]
    
    maxway = max(maxway,temp)

print(K-maxway)

Measured memory_bytes: 32292
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>
#include<math.h>

typedef int32_t i32;
typedef int64_t i64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))
#define SORT(a,num,cmp) qsort((a),(num),sizeof(*(a)),cmp)

int cmp_int (const void *a, const void *b) {
  i32 d = *(i32 *)a - *(i32 *)b;
  return d == 0 ? 0 : d < 0 ? -1 : 1;
}

#define POS(i, j) ((i) * len + (j))

void run (void) {
  i32 n, k;
  scanf ("%" SCNi32 "%" SCNi32, &n, &k);
  i32 len = 1;
  i32 *f = ALLOC (100000, i32);
  i32 i = 1;
  for (; i * i < n; ++i) {
    f[len++] = i;
    f[len++] = n / i;
  }
  if (i * i == n) {
    f[len++] = i;
  }
  SORT (f, len, cmp_int);
  const i32 mod = 1000000007;
  i32 *dp = ALLOC ((k + 1) * len, i32);
  i32 *imos = ALLOC (len, i32);
  dp[POS(0, 1)] = 1;
  for (i32 i = 1; i <= k; ++i) {
    memset (imos, 0, sizeof (i32) * len);
    for (i32 j = 1; j < len; ++j) {
      imos[len - j] = dp[POS(i - 1, j)];
    }
    for (i32 j = len - 2; j >= 1; --j) {
      imos[j] = (imos[j] + imos[j + 1]) % mod;
    }
    for (i32 j = 1; j < len; ++j) {
      dp[POS(i, j)] = (i64) imos[j] * (f[j] - f[j - 1]) % mod;
    }
  }
  i64 ans = 0;
  for (i32 i = 1; i < len; ++i) {
    ans += dp[POS(k, i)];
  }
  printf ("%" PRIi64 "\n", ans % mod);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 25476
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;

	cout << s1[0] << s2[0] << s3[0] << endl;
}


Measured memory_bytes: 3636
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   : combinatorics NCR
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define rw freopen("graphs_as_a_service.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define rep(i,a) lp(i,0,a-1)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 3e2 + 3, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
int h, w, e[N][N] = { }, cntb;
bool vis[N][N] = { };
char grid[N][N] = { };
inline bool check(int x, int y) {
	return (x >= 1 && x <= h && y >= 1 && y <= w && grid[x][y] == '.'
			&& !vis[x][y]);
}
inline void BFS(pii node) {
	queue<pii> q;
	q.push(node);
	vis[node.F][node.S] = true;
	e[node.F][node.S] = 1;
	while (!q.empty()) {
		pii a = q.front();
		q.pop();
		lp(i,0,3)
		{
			int x = dx[i] + a.F;
			int y = dy[i] + a.S;
			if (check(x, y)) {
				q.push( { x, y });
				vis[x][y] = true;
				e[x][y] = e[a.F][a.S] + 1;
			}
		}
	}
	if (!vis[h][w])
		cout << -1 << "\n";
	else
		cout << (h * w - cntb - e[h][w]) << "\n";
}
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	cin >> h >> w;
	lp(i,1,h)
	{
		lp(j,1,w)
		{
			cin >> grid[i][j];
			cntb += (grid[i][j] == '#');
		}
	}
	BFS( { 1, 1 });
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll a[5]={};
ll f=0;
for(ll i=0; i<5; i++){
cin>>a[i];}
for(ll i=0; i<5; i++){
if(a[i]==0){
cout<<i+1<<endl;
break;}}}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 0x7ffffff;
const int mod = 1000000007;

ll n, x;
ll p[51];
ll h[51];

ll dfs(ll now_level = n, ll tmp = x) {
	ll ans = 0;
	if (now_level == 0) ans++;
	if (tmp >= 1) tmp--;
	if (tmp >= 1) {
		if (tmp >= h[now_level - 1]) {
			tmp -= h[now_level - 1];
			ans += p[now_level - 1];
		}
		else {
			ans += dfs(now_level - 1, tmp);
			tmp = 0;
		}
	}
	if (tmp >= 1) {
		tmp--;
		ans++;
	}
	if (tmp >= 1) {
		if (tmp >= h[now_level - 1]) {
			tmp -= h[now_level - 1];
			ans += p[now_level - 1];
		}
		else {
			ans += dfs(now_level - 1, tmp);
			tmp = 0;
		}
	}
	if (tmp >= 1) tmp--;
	return ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> x;
	p[0] = 1;
	for (int i = 1; i <= n; ++i) p[i] = 2 * p[i - 1] + 1;
	h[0] = 1;
	for (int i = 1; i <= n; ++i) h[i] = 2 * h[i - 1] + 3;
	ll j_ans = dfs();
	cout << j_ans << endl;
	return 0;
}


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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pint;
typedef tuple<int, int, int> tint;

const int N = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

struct SegTree {
	static const int M = N * 4;
	int mn[M], mx[M], d[M], lazy[M];

	void Tag(int o, int L, int R, int val) {
		mn[o] = mx[o] = val;
		d[o] = val - R;
		lazy[o] = val;
	}
	void Pushdown(int o, int L, int R) {
		if (lazy[o] == 0) return;
		int M = (L + R) / 2;
		Tag(lch, L, M, lazy[o]);
		Tag(rch, M + 1, R, lazy[o]);
		lazy[o] = 0;
	}
	void Maintain(int o) {
		mx[o] = max(mx[lch], mx[rch]);
		mn[o] = min(mn[lch], mn[rch]);
		d[o] = min(d[lch], d[rch]);
	}
	void Build(int o, int L, int R) {
		if (L == R) {
			mx[o] = mn[o] = L;
			return;
		}
		int M = (L + R) / 2;
		Build(lch, L, M);
		Build(rch, M + 1, R);
		Maintain(o);
	}
	void Modify(int o, int L, int R, int qL, int qR, int val) {
		if (qL <= mn[o] && mx[o] <= qR) {
			Tag(o, L, R, val);
			return;
		}
		if (mx[o] < qL || qR < mn[o]) return;
		Pushdown(o, L, R);
		int M = (L + R) / 2;
		if (qL <= mx[lch]) Modify(lch, L, M, qL, qR, val);
		if (mn[rch] <= qR) Modify(rch, M + 1, R, qL, qR, val);
		Maintain(o);
	}
	int Query() {
		return d[1];
	}
};
SegTree seg;

int a[N], b[N];

int main() {
	ios::sync_with_stdio(0);

	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> a[i] >> b[i];
	seg.Build(1, 1, m);

	for (int i = 1; i <= n; i++) {
		int r = b[i] == m ? INF : b[i] + 1;
		seg.Modify(1, 1, m, a[i], b[i], r);
		int ans = seg.Query();
		if (ans >= m)
			cout << -1 << endl;
		else
			cout << ans + i << endl;
	}

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int yellow = 0;
  
  string color;
  
  for (int i = 0; i < N; i++) {
    cin >> color;
    if (color == "Y") {
      yellow++;
    }
  }
  
  if (yellow == 0) {
    cout << "Three" << endl;
  }
  else
    cout << "Four" << endl;
  
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_119A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            if (0 < s.CompareTo("2019/04/30")) Console.WriteLine("TBD");
            else Console.WriteLine("Heisei");
        }
    }
}


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

int main()
{
  int n;
  cin >> n;
  int i, j;
  vector<int> p(n+1, 0);
  for(i = 1; i <= n; i++)
  {
    int k = i;
    for(j = 2; j <= sqrt(i); j++)
    {
      while(k % j == 0)
      {
        p.at(j)++;
        k /= j;
      }
    }
    if(k != 1) p.at(k)++;
  }
  long long ans = 1;
  for(i = 2; i <= n; i++)
  {
    ans *= (p.at(i)+1);
    ans %= 1000000007;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,m;
    cin >> n >> m;
    vector<ll> a(n),b(n+1,0);
    map<ll,ll> mp;
    rep(i,n){
        cin >> a[i];
        b[i+1] = b[i] + a[i];
    }

    rep(i,n+1){
        ll tmp = b[i] % m;
        mp[tmp]++;
    }
    
    ll ans = 0;
    for (auto e : mp){
        ans += (e.second * (e.second-1))/2;
    }

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

Measured memory_bytes: 5760
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int main() {

	int c[26] = { 0 };
	int cnt[26] = { 0 };
	int n;
	cin >> n;

	rep(i,n){
		string s;
		cin >> s;
		rep(j, s.length()) {
			if (i == 0) c[s[j] - 'a']++;
			else cnt[s[j] - 'a']++;	
		}
		if (i != 0) {
			rep(j, 26)chmin(c[j], cnt[j]);
			rep(j, 26)cnt[j] = 0;
		}
	}

	rep(i, 26) {
		rep(j, c[i]) {
			char a = 'a' + i;
			cout << a;
		}
	}
	cout << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
S = [input() for _ in range(n)]

ans = [0, 0, 0, 0]

for _s in S:
    if _s == 'AC':
        ans[0] += 1
    elif _s == 'WA':
        ans[1] += 1
    elif _s == 'TLE':
        ans[2] += 1
    elif _s == 'RE':
        ans[3] += 1

print('AC x',ans[0])
print('WA x',ans[1])
print('TLE x',ans[2])
print('RE x',ans[3])


Measured memory_bytes: 79236
# D - Dice in Line
from itertools import accumulate


def main():
    N, K, *P = map(int, open(0).read().split())
    # cumsum[i] = cumulative sum of expected values in [0, i]
    cumsum = tuple(accumulate(i * (1 + i) / (2 * i) for i in P))
    if N == K:
        print(cumsum[-1])
        return
    ans = 0
    for i in range(N - K):
        ans = max(ans, cumsum[i + K] - cumsum[i])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 25420
typedef struct{double x,y,k;}w;double k,t;w p[101],b;m,v[100],n,j;z(w*c,w*d){return c->k>d->k?-1:1;}double o(q,r,s){return p[q].x*(p[r].y-p[s].y)+p[r].x*(p[s].y-p[q].y)+p[s].x*(p[q].y-p[r].y);}main(i){for(;j=scanf("%d",&n)+~n;){for(m=i=0;i<n;i++)scanf("%lf,%lf",&p[i].x,&p[i].y),p[m].y>p[i].y?m=i:0;b=p[m];p[m]=*p;*p=b;p[100].x=b.x;p[100].y=b.y+1;for(i=1;i<n;i++)p[i].k=o(0,i,100)/hypot(p[i].x-b.x,p[i].y-b.y);qsort(p+1,n-1,24,z);*v=0;v[1]=1;v[2]=j=2;for(i=3;i<n;i++){for(;o(v[j-1],v[j],i)<=0;j--);v[++j]=i;}printf("%d\n",n+~j);}}

Measured memory_bytes: 0
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define p pair <int,int>
typedef long long ll;
using namespace std;
int dx[]={1,0};
int dy[]={0,1};
bool stop=true;
bool clear=true;
int main(int argc,char const* argv[])
{
  int h,w,x,y;;
  cin >> h >> w;
  char board[h][w];
  for(int i=0;i<h;i++)
    {
      for(int j=0;j<w;j++)
	{
	  cin >> board[i][j];
	}
    }
  x=0;y=0;
  board[0][0]='.';
  while(0<=x && x<w && 0<=y && y<h)
    {
      stop=true;
      for(int k=0;k<2;k++)
	{
	  if(x+dx[k]>w-1 || y+dy[k]>h-1) continue;
	  if(board[y+dy[k]][x+dx[k]]=='#')
	    {
	      stop=false;
	      board[y+dy[k]][x+dx[k]]='.';
	      x+=dx[k];y+=dy[k];
	      //cout << "now" << ' ' << y << ' ' << x << endl;
	    }
	}
      if(stop == true) break;
      if(x==w-1 && y== h-1) break;
    }
  for(int i=0;i<h;i++)
    {
      for(int j=0;j<w;j++)
	{
	  if(board[i][j] != '.') clear=false;
	}
    }
  if(clear==false || stop==true)
    {
      cout << "Impossible" <<endl;
    }
  else if(clear==true && stop==false)
    {
      cout <<  "Possible" << endl;
    }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <list>
#include <algorithm>
using namespace std;

int main()
{
    int n, x;
    char com[20];
    list<int> v;
    scanf("%d", &n);
    for (int i; i < n; i++)
    {
        scanf("%s", com);
        if (com[0] == 'i')
        {
            scanf("%d", &x);
            v.push_front(x);
        }
        else if (com[6] == 'F')
        {
            v.pop_front();
        }
        else if (com[6] == 'L')
        {
            v.pop_back();
        }
        else if (com[0] == 'd')
        {
            scanf("%d", &x);
            for (list<int>::iterator itr = v.begin(); itr != v.end(); itr++)
            {
                if (*itr == x)
                {
                    v.erase(itr);
                    break;
                }
            }
        }
    }
    int i = 0;
    for (list<int>::iterator itr = v.begin(); itr != v.end(); itr++)
    {
        if (i++)
            printf(" ");
        printf("%d", *itr);
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 33976
#include<bits/stdc++.h>
using namespace std;
#define rep(i,num) for(i=0;i<num;i++)
int main(){
  int numBall;
  int numColor;
  int i;
  int numAns;
  
  cin >> numBall >>numColor;
  
  numAns = numColor;
  
  rep(i,numBall-1) numAns *= (numColor-1);
  /*
  for(i=0;i<numBall-1;i++){
    numAns *= (numColor-1);
  }
  */
  cout << numAns;
  
  return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<list>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
using namespace std;
#define REP(i,m,n) for(int i = (m); i < (n);i++)
#define rep(i,n) REP(i,0,n)

int main() {
	int n,m;
	cin >> n >> m;
	vector<char> a,b;
	rep(i,n)rep(j,n) {
		char c;
		cin >> c;
		a.push_back(c);
	}
	rep(i,m)rep(j,m) {
		char c;
		cin >> c;
		b.push_back(c);
	}
	rep(i,n-m+1) rep(j,n-m+1) {
		bool match = true;
		rep(di,m)rep(dj,m) {
			if(a.at((i+di)*n+(j+dj)) != b.at(di*m+dj)) {
				match = false;
				goto InnerBreak;
			}
		}
		InnerBreak:
		if(match) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
N, P = map(int, input().split())
A = list(map(int, input().split()))

dp = [[None for remainder in range(2)] for i in range(N + 1)]
dp[0][0] = 1
dp[0][1] = 0

for i in range(N):
    for r in range(2):
        dp[i + 1][r] = dp[i][r] + dp[i][(r + A[i]) % 2]

print(dp[N][P])

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

int main()
{
  int n, t, a;
  cin >> n >> t >> a;
  t -= a;
  int ans;
  double now = 9999;

for (int i = 1; i <= n; i++) {
    double h;
    cin >> h;
    h *= 0.006;
    h = abs(t - h); //理想気温との差
    if (h < now) {
      now = h; //今最も近い温度の差
      ans = i;
    }
  }

  cout << ans << endl;
}


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

int main() {
    int n, a; cin >> n >> a;
    rep (i, a+1) {
        if ((n-i) % 500 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;


int32_t main() {

    fast
    int n;
    cin>> n;
    cout<<(1-n);    



    return 0;
}



Measured memory_bytes: 3644
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		var input = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		int n = input[0];
		int m = input[1];
		int[][] pyn = new int[m][];
        for(var i = 0; i < m; i++)
		{
			pyn[i] = new int[4];//4...id in same p
			var pyin = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
			pyn[i][0] = i + 1;//number
			pyn[i][1] = pyin[0];//p
			pyn[i][2] = pyin[1];//y
		}
		Array.Sort(pyn, (a, b) => a[2] - b[2]);

		int[] cnt = new int[n];
        for(var i = 0; i < m; i++)
		{
			cnt[pyn[i][1] - 1]++;
			pyn[i][3] = cnt[pyn[i][1] - 1];
		}
		Array.Sort(pyn, (a, b) => a[0] - b[0]);
        for(var i = 0; i < m; i++)
		{
			Console.WriteLine(String.Format("{0:D6}", pyn[i][1]) + String.Format("{0:D6}", pyn[i][3]));
           
		}

		
        
	}
}


Measured memory_bytes: 24444
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<stack>
#include<queue>
#include<cstdlib>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#define fi first
#define se second
#define pb push_back
#define me(a,b) memset(a,b,sizeof(a))
#define INIT() std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
const int MAX_N=1000+5;
const int INF=0x7fffffff;
const int inf=100000;
const double EPS=1e-6;
const ull base=123;
const ll mod=1e9+7;
const double pi=4*atan(1.0);
int a[MAX_N];
int main()
{
    int n,k;
    cin>>n>>k;
    int i;
    for(i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+1+n);
    int sum=0;
    for(i=1;i<=k;i++)
        sum+=a[i];
    cout<<sum<<endl;
}

Measured memory_bytes: 3636
def lstToInt(l,x=0):
  if len(l) == 0:
    return x
  else:
    return lstToInt(l[1:], x*10 + l[0])

n,m = map(int,input().split())
c = [-1]*n

for i in range(m):
  s, num = map(int,input().split())
  if c[s-1] != -1 and c[s-1] != num:
    print(-1)
    exit()
  elif s == 1 and num == 0 and n != 1:
    print(-1)
    exit()
  else:
    c[s-1] = num

if c[0] == -1 and n != 1:
  c[0] = 1

ans = lstToInt(list(0 if c[i] == -1 else c[i] for i in range(n)))
print(ans)

Measured memory_bytes: 9204
var
	T,i:Longint;
	A,B,C,D,G,x:int64;
begin
	read(T);
	for i:=1 to T do begin
		read(A,B,C,D);
		if(B>A)or(B>D)then writeln('No')
		else begin
			G:=B;
			while D<>0 do begin
				x:=G;
				G:=D;
				D:=x mod D;
			end;
			A:=(-A-1)mod G;
			if A<0 then inc(A,G);
			if B>A+C+1 then writeln('No')else writeln('Yes');
		end;
	end;
end.

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

const int N = 100;

int main(){
	int a[N], n, cost = 1e9 + 7;
	cin >> n;
	for(int i = 0;i < n;++i){
		cin >> a[i];
	}
	for(int i = -N;i <= N;++i){
		int c = 0;
		for(int j = 0;j < n;++j){
			c += (i - a[j]) * (i - a[j]);
		}
		if(c < cost){
			cost = c;
		}
	}
	cout << cost << endl;
}


Measured memory_bytes: 256
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
cur = sum(p[:X]) + sum(q[:Y])

eat = p[:X] + q[:Y]
eat.sort()
for i in range(min(C,X+Y)):
    if r[i] > eat[i]:
        eat[i] = r[i]

ans = sum(eat)
print(ans)




Measured memory_bytes: 105836
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int b=0;
  vector<int>a(3);
  cin>>a[0]>>a[1]>>a[2];
  while(1){
      sort(a.begin(), a.end());
    if(a[0]==a[2])break;
    if(a[0]!=a[1])a[0]+=2;
    else {
      a[0]++;
      a[1]++;
    }
          b++;
  }
  cout<<b;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
    int a[3][3];
    map<int, int>u, d1, d2;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin>>a[i][j];
            if(i==j)d1[a[i][j]]++;
            if(i+j==2)d2[a[i][j]]++;
        }
    }
    int n;
    cin>>n;
    vi v(n);
    int ans1 = 0, ans2 = 0;
    for(int i = 0; i < n; i++){
        cin>>v[i];
        u[v[i]]++;
        if(d1[v[i]])ans1++;
        if(d2[v[i]])ans2++;
    }
    if(ans1==3||ans2==3){
        cout<<"Yes\n";
        return;
    }
    for(int i = 0; i < 3; i++){
        int cnt = 0;
        for(int j = 0; j < 3; j++){
            if(u[a[i][j]])cnt++;
        }
        if(cnt==3){
            cout<<"Yes\n";
            return;
        }
        cnt=0;
        for(int j = 0; j < 3; j++){
            if(u[a[j][i]])cnt++;
        }
        if(cnt==3){
            cout<<"Yes\n";
            return;
        }
    }
    cout<<"No\n";
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

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

// int ary[32] = {} ;
int N;
int x[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

void input() {
    cin >> N;
}

int main() {
    input();

    cout << x[N-1] << endl;
    return 0;
}

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

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

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

	int n,m; cin >> n >> m;

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

	for (int k = 1;k <= m;k++){
		int now = 0;
		while(now != n-1){
			if(b[now]%k > b[now+1]%k){
				swap(b[now],b[now+1]);
				now++;
			}else now++;
		}
	}

	for (int i = 0;i < n;i++){
		cout << b[i] << endl;
	}

	return 0;

}



Measured memory_bytes: 3224
var
	a,b,i:Longint;
	cnt:array[1..4]of Longint;
	cnt2:array[0..4]of Longint;
begin
	for i:=1 to 6 do begin
		read(a);inc(cnt[a]);
	end;
	for i:=1 to 4 do begin
		inc(cnt2[cnt[i]]);
	end;
	if(cnt2[1]=2)and(cnt2[2]=2)then writeln('YES')else writeln('NO');
end.


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

#define int long long

using namespace std;

signed main(){
    string S;
    cin >> S;
    
    int len = S.size();
    
    int ans = 0;
    int time = 1;
    for(int i = 0; i < len - 1; ++i){
        time *= 2;
    }
    
    
    for(int i = 0; i < time; ++i){
        string s = string() + S[0];
        for(int j = 0; j < len - 1; ++j){
            if((i >> j) & 1){
                s += S[j + 1];
            } else {
                ans += stoll(s);
                s = string() + S[j + 1];
            }
        }
        ans += stoll(s);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
 
#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0)
#define mod                     1000000007
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define foreach(itr, c)         for( __typeof__( (c).begin()) itr = (c).begin();  itr != (c).end(); ++itr)
#define foreachr(itr, c)        for( __typeof__( (c).rbegin()) itr = (c).rbegin();  itr != (c).rend(); ++itr)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define in(a,b)                 ( (b).find(a) != (b).end())
#define pb                      push_back
#define fill(a,v)               memset(a, v, sizeof a)
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define mp                      make_pair
#define minin(a)                *min_element (all(a))
#define maxin(a)                *max_element(all(a))
#define asort(c)                sort(all(c))
#define dsort(c)                sort(all(c), greater<int>()) 
typedef  long long                   ll;
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  set<int>                    si;
typedef  unordered_map<int, int>    mii;

const int N=1e5+4;
vi adj[N];
bool vis[N];
int comp[N],cr;
vi p;

void dfs(int v)
{
  vis[v]=true;
  comp[v]=cr;
  for(auto e: adj[v])
  {
    if(!vis[e])
      dfs(e);
  }
}

int main()
{
  FIO;
 /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout);
  #endif */
 
 int n,m,x,y;
 cin>>n>>m;
 p.resize(n+1);

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

 fill(vis,false);

 forn(i,m)
 {
  cin>>x>>y;
  adj[x].pb(y);
  adj[y].pb(x);
 }
 cr=1;
 rep(i,1,n)
 {
   if(!vis[i])
   {
    dfs(i);
    cr++;
   }
 }
 int ans=0;
 rep(i,1,n)
 {
  if(comp[i]==comp[p[i]])
   ans++;
 }
 cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <string>
#include <vector>

using namespace std;


int main() {

    int n;
    cin >> n;

    vector<int> buttons(n);
    vector<bool> isPressed(n);

    for(int i = 0; i < n && cin >> buttons[i]; ++i);


    int pressCount {};
    int currentButton {};
    while(true) {
        if(isPressed[currentButton]) {
            cout << -1 << endl;
            break;
        }
        else if(currentButton == 1){
            cout << pressCount << endl;
            break;
        }
        else {
            isPressed[currentButton] = true;
            currentButton = buttons[currentButton] - 1;
        }

        ++pressCount;
    }

    return 0;
}

Measured memory_bytes: 640
//Date: 17 - 02 - 18	//Author : Rishabh Paul

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<float.h>
#include<math.h>
#include<inttypes.h>
#include<assert.h>
#include<ctype.h>
#include<limits.h>
#include<time.h>
#define ll long long
#define For(i,n)	for(int i=0;i<n;i++)
#define rep(i ,a ,b)	for(int i=(a);i<=(b);i++)
#define mset(a ,value)	memset(a ,value ,sizeof(a))
#define s(a)	scanf("%d" ,&a);
#define ls(a)	scanf("%ld" ,&a)
#define reg(i)	register int i
#define infinite INT_MAX
#define MAX 100005
#define NIL -1
ll min(ll a,ll b){	return (a<b?a:b);	}
ll max(ll a,ll b){	return (a>b?a:b);	}
int main(){
	int n ,a;
	s(n);	s(a);
	int r = n % 500;
	puts(r > a ? "No" : "Yes");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vll fact(0);
  if(N == 1){
    cout << 0 << endl;
    return 0;
  }
  for(ll i = 2; i*i <= N; i++){
    if(N % i == 0){
      ll count = 0LL;
      while(N%i == 0){
        N /= i;
        count++;
      }
      fact.push_back(count);
    }
  }
  if(N != 1) fact.push_back(1);
  sort(ALL(fact));
  vector<P> num(0);
  for(int i = 0; i < sz(fact); i++){
    if(i == 0) num.push_back(P(fact.at(i), 1));
    else{
      int siz = num.size() - 1;
      if(num.at(siz).first == fact.at(i)) num.at(siz).second++;
      else num.push_back(P(fact.at(i), 1));
    }
  }
  //for(auto x: mp) cout << x.first << ' ' << x.second << endl;
  vll box(0);
  ll sum = 0LL;
  for(int i = 1; i < 1000; i++){
    sum += i;
    box.push_back(sum);
  }
  ll ans = 0LL;
  for(int i = 0; i < sz(num); i++){
    ll n = num.at(i).first;
    ll c = num.at(i).second;
    ll x = upper_bound(ALL(box), n) - box.begin();
    ans += x * c;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3668
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int h,w,n;
char C[55][55],c[55][55];

int f(){
	while(1){
		rep(j,w)for(int i=h-1;i>=0;i--)if(c[i][j]!='.'){
			int y=i;
			while(y<h-1 && c[y+1][j]=='.')y++;
			swap(c[i][j],c[y][j]);
		}
		
		int del[55][55]={};
		rep(i,h){
			int same=0;
			rep(j,w){
				if(j>0 && c[i][j]!='.' && c[i][j]==c[i][j-1]){
					same++;
					if(same>=n)del[i][j]=1;
					if(same==n){
						rep2(jj,j-n+1,j)del[i][jj]=1;
					}
				}else same=1;
			}
		}
		rep(j,w){
			int same=0;
			rep(i,h){
				if(i>0 && c[i][j]!='.' && c[i-1][j]==c[i][j]){
					same++;
					if(same>=n)del[i][j]=1;
					if(same==n){
						rep2(ii,i-n+1,i)del[ii][j]=1;
					}
				}else same=1;
			}
		}
		int flag=0;
		rep(i,h)rep(j,w)if(del[i][j])c[i][j]='.',flag=1;
		if(!flag)break;
	}
	rep(i,h)rep(j,w)if(c[i][j]!='.')return 0;
	return 1;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>h>>w>>n;
	rep(i,h)cin>>C[i];
	rep(i,h)rep(j,w-1){
		rep(ii,h)rep(jj,w)c[ii][jj]=C[ii][jj];
		swap(c[i][j],c[i][j+1]);
		if(f()){cout<<"YES"<<endl;return 0;}
	}
	cout<<"NO"<<endl;
}

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

int main(){
	int n;
	while(1){
		map<int, long long> mp;
		bool isNA = false;
		cin >> n;
		if(n==0)break;
		while(n){
			int id,price,number;
			cin >> id >> price >> number;
			//cout << number;
			if(mp[id]<1000000 && mp[id]+(long long)price*number>=1000000){
				cout << id << endl;
				isNA =true;
			}
			mp[id]+=(long long)price*number;
			n--;
		}
		if(!isNA) cout << "NA" <<endl;
	}
	return 0;	
}

Measured memory_bytes: 3112
#include <stdlib.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(int *)a>*(int *)b)return 1;
    return -1;
}
int main()
{   int n;
    scanf("%d",&n);
    int a[n];
    int set[3]={-1,-1,-1};
    
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(set[0]==-1||set[0]==a[i]){
            set[0]=a[i];
            }else if(set[1]==-1||set[1]==a[i]){
            set[1]=a[i];
           }else if(set[2]==-1||set[2]==a[i]){
            set[2]=a[i];
            }else{
            printf("No");
            return 0;
        }
    }
    if(set[0]==0&&set[1]==-1){
        printf("Yes");
        return 0;
    }
    if(n%3>0){
        printf("No");
        return 0;
    }
    qsort(set,3,sizeof(int),compare);
    qsort(a,n,sizeof(int),compare);
    
    if(set[0]==-1){
        if((set[1]==0)){
            int zc=0;
            for(int i=0;i<n;i++){
                if(a[i]==0)zc++;else{
                    break;
                }
            }
            if(zc==n/3){
            printf("Yes");
                }else{
                printf("No");
            } 
        }else{
            printf("No");
        }
        return 0;
    }int chk=set[0]^set[1];
    chk=chk^set[2];
    if(chk==0){
        int x=0,y=0,z=0;
        for(int i=0;i<n;i++){
            if(a[i]==set[0])x++;
            if(a[i]==set[1])y++;
            if(a[i]==set[2])z++;
        }
        if(x==y&&y==z&&z==n/3)
        printf("Yes");else printf("No");
    }else{
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 892
using System;

class Program
{
  public static void Main(string[] args)
  {
    string[] tmp = Console.ReadLine().Split(' ');
    int[] numbers = new int[2];
    for(int i = 0;i < 2;i++)
    {
      numbers[i] = int.Parse(tmp[i]);
    }
    if(numbers[0] > numbers[1]){
      Console.WriteLine("a > b");
    }
    else if(numbers[0] < numbers[1]){
      Console.WriteLine("a < b");
    } else {
      Console.WriteLine("a == b");
    }
  }
}

Measured memory_bytes: 8908
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n, m;
signed main() {
	cin >> n >> m;
	string s, t; cin >> s >> t;
	int lc1 = lcm(n, m);
	int lc = lcm(lc1 / n, lc1 / m);
	for (int i = 0; i < lc1; i += lc) {
		if (s[i / (lc1 / n)] != t[i / (lc1 / m)]) {
			cout << -1 << endl; return 0;
		}
	}
	cout << lcm(n, m) << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define loopf(i,a,b) for(int i = a;i < b;i++)
#define loopb(i,a,b) for(int i = a;i >= b;i--)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;


int32_t main()
{
    fast

   int test=1;
   //cin>>test;


  while(test--)
  {
  int n;
  cin>>n;

  vvi dp(n,vi (3,0));
  cin>>dp[0][0]>>dp[0][1]>>dp[0][2];
  for(int i=1;i<n;i++)
  {
    int c[3];
    cin>>c[0]>>c[1]>>c[2];
    for(int j=0;j<3;j++)
      for(int k=0;k<3;k++)
      {
        if(j!=k)dp[i][j]=max(dp[i][j],dp[i-1][k]+c[j]);
      }
  }

  cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
 


  //while loop ending 
  }

return 0;
}

Measured memory_bytes: 5760
def solve(num):
  n = int(num)
  for i in range(int(n**0.5)+1, 0, -1):
    if n%i:
      continue
    else:
      j = n/i
      sum = i+j-2
      return(int(sum))
      
      
if __name__ == "__main__":
  print(solve(input()))

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

int main()
{
    int N;
    cin >> N;
    vector<int> D(N, 0);
    for (int i = 0; i < N; ++i){
        cin >> D[i];
    }
    sort(D.begin(), D.end());

    int ans = 0;
    for (int i = 1; i < N; ++i)
    {
        if(D[i-1]!= D[i]){
            ans++;
        }
    }

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

Measured memory_bytes: 256
import java.util.Scanner;
     
class Main{
    public static void main(String arg[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine();
        String S = sc.nextLine();
        sc.close();
        String[] s = S.split(" ");
        int[] n = new int[N];
        
        for(int i = 0; i < N; i++) {
        	String tmp = s[i];
        	n[i] = Integer.parseInt(tmp);
        }
        
        System.out.println(calc(n));
        
    }
    
    public static int calc(int n[]) {
    	int count = 0;
    	while(true) {
        	for(int j = 0; j < n.length; j++) {
        		if(n[j]%2 == 0) {
        			n[j] /= 2; 
        		}else {
        			return count;
                }
            }
            count++;
        }
    }
}

Measured memory_bytes: 23380
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int,int> Pi;
const ll inf = 1e18 + 1;
const ll limit = 1e9;

int main() {
    int n; cin >> n;
    map<string,int> mp;
    int max_val = 0;
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        mp[s]++;
        if (max_val < mp[s])  max_val = mp[s];
    }
    vector<pair<int,string>> v;
    for (const auto& p : mp) v.emplace_back(make_pair(p.second,p.first));
    sort(v.begin(),v.end());
    for (auto s : v) if (s.first == max_val) cout << s.second << "\n";
}

Measured memory_bytes: 29684
#include "bits/stdc++.h"
using namespace std;

#define say(obj) (cout << (obj) << endl)
#define endline (cout << endl)
#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to, cost;
	edge_(ll to, ll cost) : to(to), cost(cost) {}
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr int		INF = (int)1e7;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template <typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template <typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template <typename T>
ostream& operator << (ostream& os, const vector<vector<T>>& mat) {
	for (const vector<T>& m : mat) os << m << endl;
	return os;
}

template <typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

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

template <typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	int N;
	cin >> N;
	vll T(N), A(N);
	for (int i = 0; i < N; i++) cin >> T[i] >> A[i];

	ll t = T[0], a = A[0];
	for (int i = 1; i < N; i++) {
		ll n = max((t + T[i] - 1) / T[i], (a + A[i] - 1) / A[i]);
		t = n * T[i];
		a = n * A[i];
	}

	say(t + a);

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,k,x,y,sum = 0;
  scanf("%d",&n);
  scanf("%d",&k);
  scanf("%d",&x);  
  scanf("%d",&y);
  if(n > k) sum = k * x + (n - k) * y;
  else sum = n *x;
  printf("%d",sum);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 1;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int main()
{
	int		a,b,c,i,j,k,n,m,x,y,ans = 0;
	char	str[10001];
	
	scanf("%d", &n);
	scanf("%s", str);
	m = strlen(str);
	
	for(i=0;i<m;i++) {
		str[i] -= 'A';
		str[i] += n;
		str[i] %= 26;
		str[i] += 'A';
	}
	printf("%s\n", str);


	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
char arr[310][310];
bool valid[310][310];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n; cin>>n;
	for (int i = 0; i < n; ++i)
	{
		for(int j = 0; j < n; j++){
			cin>>arr[i][j];
			valid[i][j] = true;
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			// cout<<"outer "<<i<<" "<<j<<endl;
			for(int k = 0; k < n; k++){
				int a = i + k, b = j;
				int p = i, q = j + k;
				a = a%n; b = b%n;
				p = p%n; q = q%n;
				// cout<<"-> "<<a<<" "<<b<<endl;
				if(arr[a][b] != arr[p][q]){
					valid[i][j] = false;
					int counter = 0;
					for(int y = i , z = j ; counter < n ;y--,z--, counter++){
						if(y == -1) y = n - 1;
						if(z == -1) z = n - 1;
						valid[y][z] = false;
					}
					break;
				}
			}
		}
	}
	int answer = 0;
	for (int i = 0; i < n; ++i)
	{
		for(int j = 0; j < n; j++){
			if(valid[i][j]){
				// cout<<i<<" "<<j<<endl;
				answer++;
			}
		}
	}
	cout<<answer<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define min(a,b) a<b?a:b

using namespace std;

ll llabs(ll a){
	if (a < 0) return -a;
	return a;
}

int main(){

	ll n;

	cin >> n;

	vector < ll > adj(n+1);
	vector < ll > dp(n+1);

	for (ll i = 1; i <= n; i++){
		ll a;
		cin >> a;
		adj[i] = a;
	}

	dp[1] = 0;
	dp[2] = llabs(adj[1] - adj[2]);

	for (ll i = 3; i <= n; i++){
		dp[i] = min(dp[i-1] + llabs(adj[i-1] - adj[i]), dp[i-2] + llabs(adj[i-2] - adj[i]));
	}

	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 1792
N=int(input())
s=str(input())
t=str(input())
c=0
tmp=0
S=list(s)
T=list(t)
for i in range(N):
    if s[N-i-1:N]==t[0:i+1]:
        c=i+1
    #print(s[N-i-1:N],t[0:i+1])
#print(c)
print(2*N-c)
        


Measured memory_bytes: 2940
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        if(n==1){
            System.out.println(scanner.nextInt());
            return;
        }
        char[] chars = scanner.nextLine().toCharArray();
        int[] a = new int[n-1];
        for (int i = 1; i < n; i++) {
            a[i-1] = Math.abs(chars[i]-chars[i-1]);
        }
        if(n==2){
            System.out.println(a[0]);
            return;
        };
        System.out.println(solution(a));
    }

    public static int solution(int[] a){
        int n = a.length;
        if(!findParity(a)) return 1;
        for (int i = 0; i < n; i++) {
            if(a[i]==1) return 0;
            a[i]/=2;
        }
        if(findParity(a)) return 0;
        else return 2;
    }

    //true - четнео, афдыу - нечетно
    private static boolean findParity(int[] a){
        int n = a.length;
        int ans = a[0]^a[n-1];
        int pow = 0;
        for (int i = 1; i < n-1; i++) {
            if((i&1)==0){
                int c = 0;
                int t = i;
                while ((t&1)==0){
                    t>>=1;
                    c++;
                }
                pow-=c;
            }
            if(((n-i)&1)==0){
                int c = 0;
                int t = n-i;
                while ((t&1)==0){
                    t>>=1;
                    c++;
                }
                pow+=c;
            }
            if(pow==0){
                ans = ans ^ a[i];
            }
        }
        return (ans&1)==0;
    }
}


Measured memory_bytes: 46716