akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int n, m, k, i, j, kk, x1, y1, x2, y2, x, y, xx, yy, ans, INF = 10000000;

	cin >> n >> m >> kk >> x1 >> y1 >> x2 >> y2;
	vector<string> s(n);
	for (i = 0; i < n; i++) cin >> s[i];

	vector<vector<int>> dp(n + 1, vector<int>(m + 1, INF));
	dp[x1][y1] = 0;
	queue<pair<int, int>> q;
	q.push({ x1, y1 });

	int v[4][2] = { 1, 0, 0, 1, -1, 0, 0, -1 };

	while (!q.empty()) {
		x = q.front().first;
		y = q.front().second;
		q.pop();

		for (k = 0; k < 4; k++) {
			for (i = 1; i <= kk; i++) {
				xx = x + i * v[k][0];
				yy = y + i * v[k][1];
				if ((xx <= 0) || (xx > n) || (yy <= 0) || (yy > m)) break;
				if (s[xx - 1][yy - 1] == '@') break;
				if (dp[xx][yy] == dp[x][y]) break;
				if (dp[xx][yy] == INF) {
					dp[xx][yy] = dp[x][y] + 1;
					q.push({ xx, yy });
				}
			}
		}
	}

	if (dp[x2][y2] == INF) ans = -1;
	else ans = dp[x2][y2];

	cout << ans << "\n";

	return 0;
}


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

int main(){
    int a,N;
    long long max,min,vol;
    cin >> N;
    max = -10000000;
    min = 10000000;
    vol = 0;
    
    
    for(int i =0;i<N;i++){
        cin >> a;
        if(a>max) max = a;
        if(a<min) min = a;
        vol += a;
    }
    cout << min << " " << max << " " << vol << endl;


}


Measured memory_bytes: 3080
#include<stdio.h>
int main(void)
{
  int N, M;
  char A[51][51];
  char B[51][51];

  scanf("%d %d", &N, &M);
  for(int i = 0; i < N; i++){
    scanf("%s", A[i]);
  }
  for(int i = 0; i < M; i++){
    scanf("%s", B[i]);
  }
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      int isOK = 1;
      for(int k = 0; k < M; k++){
        for (int l = 0; l < M; l++) {
          if (i + k >= N) {
            isOK = 0;
            break;
          }
          if (j + l >= N) {
            isOK = 0;
            break;
          }
          if (A[i + k][j + l] != B[k][l]) {
            isOK = 0;
          }
        }
      }
      if (isOK) {
        printf("Yes\n");
        return 0;
      }
    }
  }

  printf("No\n");
  return 0;
}



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

int main(){
    int r, D, X;
    cin >> r >> D >> X;
    vector<int> x(11);
    x[0] = X;

    for(int i = 0; i < 10; i++){
        x[i + 1] = r*x[i] - D;
    }

    for(int i = 1; i <= 10; i++){
        cout << x[i] << endl;
    }
   return 0;
}

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

#pragma GCC optimize("O3")
#pragma GCC target("sse4")
// io
#define get(i) scanf("%d", &i)
#define flush fflush(stdin)

// manipulations
#define f(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = n - 1; i >= 0; i--)
#define ff(i, a, b) for (int i = a; i <= b; i++)
#define sz(x) int((x).size())
#define fi first
#define se second

// built-in
#define bitcount __builtin_popcount
#define gcd __gcd

// short
#define pb push_back
#define fill(arr, a) memset(arr, a, sizeof(arr))
#define mp(a,b) make_pair(a,b)

// useful bits
#define IN(i,l,r) (i >= l && i <= r);
#define relax(a,b) a = max(a,b);
#define relaxi(a,b) a = min(a,b);

typedef vector<int> VI;
typedef pair<int, int> PII;
typedef long long ll;
typedef long double ld;

ll modpow(ll a, ll b, ll mod = (ll) (1e9 + 7)) 
{if (!b) return 1; a %= mod; return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod;}

// for rand
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// use uniform_int_distribution<int>(0, i)(rng)

const int N = 2e5 + 19;
vector<vector<int>> adj;
ll arr[N] , lazy[N], n,q;

void dfs(int v,int p , ll add){
	add += lazy[v];
	arr[v] += add;
	for(int u : adj[v])
	{
		if(u == p)continue;
		dfs(u,v,add);
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	#ifndef ONLINE_JUDGE
//	freopen("output.txt", "w" , stdout);
	/* freopen("in.txt" , "r" , stdin); */
	/* clock_t start = clock(); */
	#endif
	cin >> n >> q;
	adj.resize(n);
	for(int i = 0 ; i <  n - 1; i++){
		int u ,v;
		cin >> u >> v;
		adj[--u].pb(--v);
		adj[v].pb(u);
	}
	for(int i = 0; i < q; i++){
		int p , x;
		cin >> p >> x;
		lazy[--p] += x;
		/* cerr << p << " " << lazy[p] << endl; */
	}
	dfs(0,-1,0);
	for(int i = 0; i < n; i++)
		cout << arr[i] << " ";
	cout << endl;
	
	#ifndef ONLINE_JUDGE
	/* cout << setprecision(12) << ld(clock()-start) / CLOCKS_PER_SEC << endl; */
	#endif
	return 0;
}



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

int main()
{
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> s(n);
    int a;
    rep(i, q) {
        cin >> a;
        a--;
        s[a]++;
    }
    rep(i, n) {
        if (q-s[i]<k) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3780
#include <iostream>

#define SIZE 30

int N, M;
int A[SIZE];
int res;

int main() {
    std::cin >> N >> M;
    for (int i=0; i<N; ++i) {
        int K;
        std::cin >> K;
        for (int j=0; j<K; ++j) {
            int a;
            std::cin >> a;
            --a;
            ++A[a];
        }
    }
    for (int i=0; i<M; ++i) {
        if (A[i] >= N) ++res;
    }
    std::cout << res << std::endl;

    return 0;
}

Measured memory_bytes: 256
a,b,k=map(int,input().split())
for i in range(a,min(b+1,a+k)):
    print(i)
if(a+k<b-k+1):
    for i in range(b-k+1,b+1):print(i)
else:
    for i in range(a+k,b+1):print(i)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

// struct path
// {
//     pair<ll, ll> f;
//     pair<ll, ll> t;
// };

// struct cmp
// {
//     bool operator() ( path a, path b ) const
//     { return std::make_pair(a.f,a.t) > std::make_pair(b.f,b.t) ; }
// };

void solve()
{
    string x,y;
    cin>>x>>y;
    y.pop_back();
    if(x==y)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
}

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>

void Shuffle(int [],int,int);

int main(void)
{
	int fuda[50];
	int r,n,c,i,p,j;
	while(1){
	do {
		scanf("%d %d",&n,&r); // n???????±±??????r???????????????
		if(n == 0 && r == 0) goto LOOP;
	}while((0 > n) || (n > 51) || (0 > r) || ( r > 51));
	for(i = n - 1;i >= 0;i--){ // ???????????????????????????
		fuda[i] = n - i;
	}
	
	while(r > 0){
		do{
		scanf("%d %d",&p,&c); //?±±?????????????????????p??????????????????c???????????????????????????????????????
		}while(!((p + c) <= (n + 1)));
		Shuffle(fuda,p,c);
		r--;
	}
	printf("%d\n",fuda[0]);//?????????????±±????????¨???
	}
	LOOP:
	return 0;
}

void Shuffle(int FUDA[],int p,int c){
	int wark[50],i,j;
	for(i = p - 1,j = 0;i < p + c - 1 ;i++,j++){
	wark[j] = FUDA[i]; // p??????p+c???????????§?????????????????????????\????????????????
	}
	for(i = p - 2;i >= 0;i--){
		FUDA[i + c] = FUDA[i]; //???????????????
	}
	for(i = 0;i < c;i++){
		FUDA[i] = wark[i]; //?????????????????\
	}
	return 0;
}

Measured memory_bytes: 596
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    string s;
    cin >> s;

    ll bcnt = 0;
    ll wcnt = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'W'){
            wcnt += bcnt;
        } else {
            bcnt++;
        }
        //cout << wcnt << " " << bcnt << endl;
    }
    cout << wcnt << endl;
}

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

using namespace std;

using int64 = long long;

const int mod0 = 1e9 + 7;
const int mod1 = 1e9 + 9;
const int mod2 = 1e9 + 21;
const int base = 10007;

int64_t power(int64_t x, int64_t n, int64_t mod) {
  int64_t ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}


int64 h0[550001], g0[550001];
int64 h1[550001], g1[550001];
int64 h2[550001], g2[550001];


int main() {

  h0[0] = h1[0] = h2[0] = 1;
  for(int i = 1; i < 550001; i++) {
    h0[i] = h0[i - 1] * base % mod0;
    h1[i] = h1[i - 1] * base % mod1;
    h2[i] = h2[i - 1] * base % mod2;
  }
  g0[550000] = power(h0[550000], mod0 - 2, mod0);
  g1[550000] = power(h1[550000], mod1 - 2, mod1);
  g2[550000] = power(h2[550000], mod2 - 2, mod2);
  for(int i = 549999; i >= 0; i--) {
    g0[i] = g0[i + 1] * (i + 1) % mod0;
    g1[i] = g1[i + 1] * (i + 1) % mod1;
    g2[i] = g2[i + 1] * (i + 1) % mod2;
  }

  int N;
  string S;

  cin >> N;
  cin >> S;

  vector< int64 > latte0, malta0;
  vector< int64 > latte1, malta1;
  vector< int64 > latte2, malta2;
  int64 beet = 0, pos = 250001;
  latte0.push_back(pos), malta0.push_back(beet);
  latte1.push_back(pos), malta1.push_back(beet);
  latte2.push_back(pos), malta2.push_back(beet);
  for(int i = 0; i < N; i++) {
    char c = S[i];
    if(c == '+') (beet += h0[pos]) %= mod0;
    else if(c == '-') (beet += mod0 - h0[pos]) %= mod0;
    else if(c == '<') --pos;
    else ++pos;
    latte0.push_back(pos), malta0.push_back(beet);
  }
  beet = 0, pos = 250001;
  for(int i = 0; i < N; i++) {
    char c = S[i];
    if(c == '+') (beet += h1[pos]) %= mod1;
    else if(c == '-') (beet += mod1 - h1[pos]) %= mod1;
    else if(c == '<') --pos;
    else ++pos;
    latte1.push_back(pos), malta1.push_back(beet);
  }
  beet = 0, pos = 250001;

  for(int i = 0; i < N; i++) {
    char c = S[i];
    if(c == '+') (beet += h2[pos]) %= mod2;
    else if(c == '-') (beet += mod2 - h2[pos]) %= mod2;
    else if(c == '<') --pos;
    else ++pos;
    latte2.push_back(pos), malta2.push_back(beet);
  }


  map< tuple< int64, int64, int64 >, int > mp;
  int64 ret = 0;
  for(int i = N; i >= 0; i--) {
    int64 dx = latte0[i] - latte0[0];
    int64 mul0, mul1, mul2;
    if(dx >= 0) mul0 = h0[dx], mul1 = h1[dx], mul2 = h2[dx];
    else mul0 = power(h0[-dx], mod0 - 2, mod0), mul1 = power(h1[-dx], mod1 - 2, mod1), mul2 = power(h2[-dx], mod2 - 2, mod2);
    ret += mp[make_tuple((malta0[i] + malta0[N] * mul0) % mod0, (malta1[i] + malta1[N] * mul1) % mod1, (malta2[i] + malta2[N] * mul2) % mod2)];
    ++mp[make_tuple(malta0[i], malta1[i], malta2[i])];
  }
  cout << ret << endl;
}


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

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

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

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA... a){
	while (*sdbg != ',') cerr << *sdbg++; cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
	os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
	return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

const int MAXN = 2E5 + 10;

template <typename T>
int LIS(int a[], int n, T cmp){
	static int cnt, len[MAXN];
	len[cnt = 0] = INT_MIN;
	for (int i = 0; i < n; ++i)
		(cmp(len[cnt], a[i]) ? len[++cnt] : *lower_bound(len, len + cnt + 1, a[i], cmp)) = a[i];
	return cnt;
}

constexpr long double pi = 3.141592653589793238462643383279502L;

int n, m;

int x[MAXN], y[MAXN];
vector<pii> a;
int b[MAXN];

int main(){
	int x1, y1, x2, y2;
	scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
	if (x1 > x2)
		swap(x1, x2), swap(y1, y2);
	bool flag = false;
	if (y1 > y2)
		y1 = -y1, y2 = -y2, flag = true;

	scanf("%d", &n);
	for (int i = 0; i < n; ++i){
		scanf("%d%d", x + i, y + i);
		if (flag)
			y[i] = -y[i];
		if (x1 <= x[i] && x[i] <= x2 && y1 <= y[i] && y[i] <= y2)
			a.emplace_back(x[i], y[i]);
	}
	sort(all(a));
	eput(a);
	m = a.size();
	for (int i = 0; i < m; ++i)
		b[i] = a[i].nd;
	int pass = LIS(b, m, less<int>());
	eput(pass);
	int n0 = min(x2 - x1, y2 - y1);

	if (pass > n0)
		printf("%.18Lf\n", (x2 + y2 - x1 - y1) * 100ll - pass * (20 - 5 * pi) + 5 * pi);
	else
		printf("%.18Lf\n", (x2 + y2 - x1 - y1) * 100ll - pass * (20 - 5 * pi));

	return 0;
}



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

using namespace std;

int main(){
        int N;
        int out=0;
        cin>>N;
        N*=3;
        string str;
        int ans=0;
        int run=0;
        while(out<N){
                cin>>str;
                if(str=="HIT"){
                        run++;
                        if(run>=4){
                                ans++;
                                run--;
                        }
                }
                else if(str=="OUT"){
                        out++;
                        if(out%3==0){
                                cout<<ans<<endl;
                                ans=0;
                                run=0;
                        }
                }
                else if(str=="HOMERUN"){
                        run++;
                        ans+=run;
                        run=0;
                }
        }

return 0;
}

Measured memory_bytes: 1212
h,w = map(int,input().split())
c_h,c_w = map(int,input().split())
d_h,d_w = map(int,input().split())
s_list = [[c for c in input()] for _ in range(h)]

move_pattern = [[-1,0],[1,0],[0,-1],[0,1]]
around_area = [[i-2,j-2] for i in range(5) for j in range(5)]
kakutei_set = set([(c_h-1,c_w-1)])
temp_dic = {}
temp_dic[0] = set([(c_h-1,c_w-1)])
temp_num = 0
while True:
    cur_list = list(temp_dic[temp_num])
    for i,j in cur_list:
        for x,y in move_pattern:
            if i+y<0 or i+y>=h or j+x<0 or j+x>=w:
                continue
            elif s_list[i+y][j+x]=="#":
                continue
            elif (i+y,j+x) in kakutei_set:
                continue
            else:
                cur_list.append((i+y,j+x))
                temp_dic[temp_num].add((i+y,j+x))
                kakutei_set.add((i+y,j+x))
    temp_dic[temp_num+1] = set()
    for i,j in temp_dic[temp_num]:
        for x,y in around_area:
            if i+y<0 or i+y>=h or j+x<0 or j+x>=w:
                continue
            elif s_list[i+y][j+x]=="#":
                continue
            elif (i+y,j+x) in kakutei_set:
                continue
            else:
                temp_dic[temp_num+1].add((i+y,j+x))
                kakutei_set.add((i+y,j+x))
    temp_num += 1
    if len(temp_dic[temp_num])==0:
        break
if (d_h-1,d_w-1) not in kakutei_set:
    print(-1)
else:
    for key,value in temp_dic.items():
        if (d_h-1,d_w-1) in value:
            print(key)

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;

  int maximum = max(a, b);

  maximum = max(maximum, c);

  int second;
  int minimum;

  if (a == maximum)
  {
    second = max(b, c);
    minimum = min(b, c);
  }
  else if (b == maximum)
  {
    second = max(a, c);
    minimum = min(a, c);
  }
  else
  {
    second = max(a, b);
    minimum = min(a, b);
  }

  cout << maximum * 10 + second + minimum << endl;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n, a, b = map(int, input().split())

if (a - b) % 2 == 0:
    if a - b > 0:
        print((a-b)//2)
    else:
        print((b-a)//2)
else:
    d = 0
    if a - b > 0:
        d = a - b
    else:
        d = b - a
    min_x = 0
    top_a = a - 1
    top_b = b - 1
    if top_a < top_b:
        min_x = top_a + (d + 1)//2 
    else:
        min_x = top_b + (d + 1)//2 
    
    bot_a = n - a
    bot_b = n - b
    if bot_a < bot_b:
        min_x1 = bot_a + (d + 1)//2 
    else:
        min_x1 = bot_b + (d + 1)//2 
    if min_x > min_x1:
        min_x = min_x1
    print(min_x)
    


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  if(N==K){
    cout << 1 << endl;
    return 0;
  }
  N-=1;
  K-=1;
  int ans = N/K;
  if(N%K!=0)ans++;
  cout << ans << endl;
  return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/05  Problem: 079_arc_b / Link: https://arc079.contest.atcoder.jp/tasks/arc079_b?lang=en  ----- */
/* ------問題------

長さ N の非負整数列 ai に対し、数列の最大値が N−1 以下になるまで以下の操作を繰り返し行うことを考えます。
数列のうち最も大きい要素を求める、複数ある場合はどれか 1 つ選ぶ。この要素の値を N 減らす。これ以外の要素の値を 1 増やす。
なお、この操作を行い続けると、いつかは数列の最大値が N−1 以下になることが証明できます。
ここで、整数 K が与えられるので、この操作を行う回数がちょうど K 回になるような数列 ai を 1 つ求めてください。なお、この問題の入出力の制約下では、かならず 1 つは条件を満たすような数列が存在することが示せます。

-----問題ここまで----- */
/* -----解説等-----

復元を端折れば良い

----解説ここまで---- */

LL N,K;

LL ans = 0LL;

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

	cin >> K;
	N = 50;
	VL a(50, 49);
	LL base = K/N;
	LL modulo = K%N;
	FOR(i, 0, N) {
		a[i] += base;
	}
	FOR(m, 0, modulo) {
		FOR(i, 0, N) {
			if (i == m) a[i]+=N;
			else a[i]--;
		}
	}

	cout << N << endl;
	FOR(i, 0, N) {
		cout << a[i] << " ";
	}cout << endl;

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> data(N);
  for(int i = 0; i < N; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    data.at(i) = s;
  }
  sort(data.begin(), data.end());
  vector<int64_t> count;
  count.push_back(1);
  for(int i = 1; i < N; i++) {
    if(data.at(i) == data.at(i - 1)) {
      count.at(count.size() - 1)++;
    }
    else {
      count.push_back(1);
    }
  }
  int64_t ans = 0;
  for(int i = 0; i < count.size(); i++) {
    if(count.at(i) == 1) {
      continue;
    }
    else {
      ans += (count.at(i) - 1) * count.at(i) / 2;
    }
  }
  cout << ans << endl; 
}


Measured memory_bytes: 6904
n,m=map(int, input().split())

tree=[[] for _ in range(n)]
for i in range(m):
    x,y,w = map(int,input().split())
    tree[x-1].append(y-1)
    tree[y-1].append(x-1)

singles = [ i for i in range(n) if tree[i]==[]]

visited=[False]*n
for i in singles:
    visited[i] = True
ans=len(singles)

from collections import deque
while False in visited:
    ans+=1
    start = visited.index(False)
    visited[start]=True
    q=deque([(start,togo) for togo in tree[start]])
    while q:
        parent,x = q.pop()
        visited[x]=True
        for y in tree[x]:
            if not visited[y]:
                q.append((x,y))
#         print(parent,x,q)
#     print(visited,ans)
print(ans)

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

#define rep(i,n) for (int i = 0; i < (n); i++)

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

int main()
{
    ll x;
    cin >> x;

    for (ll a = 0; a < 10000; a++)
    {
        for (ll b = -a; b <= a; b++)
        {
            if (a*a*a*a*a-b*b*b*b*b == x)
            {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }

    return 0;
}

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

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            return Array().Select(int.Parse).ToArray();
        }
        public long[] LongArray()
        {
            return Array().Select(long.Parse).ToArray();
        }
    }

    class Program
    {
        private int N;
        private int[] A;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            A = sc.IntArray();
        }

        public void Solve()
        {
            Scan();
            Array.Sort(A, (a, b) => -a.CompareTo(b));
            int Alice, Bob;
            Alice = Bob = 0;
            for (int i = 0; i < N; i++)
            {
                if (i % 2 == 0)
                {
                    Alice += A[i];
                }
                else
                {
                    Bob += A[i];
                }
            }
            Console.WriteLine(Alice - Bob);
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

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

int main() {
  int s;
  cin >> s;
  vector<int> A(1000000), B(1000000);
  A.at(0) = s;
  B.at(A.at(0) - 1) = 1;
  for (int i = 1; i < 1000000; i++) {
    if (A.at(i - 1) % 2 == 0) A.at(i) = A.at(i - 1) / 2;
    else A.at(i) = 3 * A.at(i - 1) + 1;
    if (B.at(A.at(i) - 1) == 0) B.at(A.at(i) - 1) = 1;
    else {
      cout << i + 1 << endl;
      break;
    }
  }
}


Measured memory_bytes: 8064
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
c=[[0 for _ in range(w)] for _ in range(h)]
j=a[0]
k=0
t=1
for i in range(h*w):
    if i>=j:
        k+=1
        j+=a[k]
        t+=1
    if i//w%2==0:
        c[i//w][i%w]=str(t)
    else:
        c[i//w][-i%w-1]=str(t)
for t in c:
    print(" ".join(t))

Measured memory_bytes: 41456
// https://atcoder.jp/contests/agc039/tasks/agc039_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int rcnt(string s) {
    int len = s.length();
    int cnt = 0;
    int ret = 0;
    REP(i, len - 1) {
        if (s[i] == s[i + 1]) {
            cnt++;
        } else {
            ret += (cnt + 1) / 2;
            cnt = 0;
        }
    }
    ret += (cnt + 1) / 2;
    return ret;
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    int k;
    cin >> s >> k;
    t += s;
    int t1 = rcnt(t);
    t += s;
    int t2 = rcnt(t);
    t += s;
    int t3 = rcnt(t);
    int a1 = t2 - t1;
    int a2 = t3 - t2;
    int sum = t1 + a2 * ((k - 1) / 2) + a1 * (k / 2);
    cout << sum << endl;

    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 998244353LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

#define maxn 300005

map<int,int> Map ;

int a[maxn] ;

int main()
{
    int n , k ;

    scanf("%d %d",&n,&k) ;

    for(int i=1 ; i<=n ; i++) scanf("%d",&a[i]) ;

    Map[0] = 1 ;

    i64 ans = 0 ;

    for( int i=1 ; i<=n ; i++)
    {
        if( i-k >= 0 )
        {
            int val = ( (a[i-k] - (i-k) )%k + k )%k ;
            Map[ val ] = Map[val] - 1 ;
        }
        a[i] = ( a[i-1] + a[i] )%k ;
        int val = ( (a[i] - i)%k + k )%k ;

        if( Map.find( val ) == Map.end() ) Map[val] = 0 ;
        ans += Map[val] ;
        Map[val] = Map[val] + 1 ;
   //     printf("-- %lld\n",ans) ;
    }

    printf("%lld\n",ans) ;

    return 0 ;
}


Measured memory_bytes: 10496
n = int(input())
a = list(map(int,input().split()))
c = [0 for _ in range(n+1)]
r = []
for i in range(n):
    c[a[i-1]-1] += 1
for i in range(n):
    r.append(c[i])
kai = []
v = []
for i in range(len(r)):
    kai.append((r[i]*(r[i]-1)//2))
    v.append(kai[i] - max(((r[i]-1)*(r[i]-2)//2),0))
#print(v,kai)
ans = sum(kai)
for i in range(len(a)):
    print(ans - v[a[i]-1])

Measured memory_bytes: 26140
n =int(input())
v_seq = list(map(int, input().split()))
c_seq = list(map(int, input().split()))

r_seq = [v_seq[i] - c_seq[i] for i in range(n)]
r_seq.sort(reverse = True)

ans = 0
for r in r_seq:
    if r <= 0:
        break
    ans += r

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

map<ll, ll> primeFactor(ll n) {
  map<ll, ll> res;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}

int main() {
  ll n;
  cin >> n;
  map<ll, ll> mp;
  rep2(i, 2, n + 1) {
    auto p = primeFactor(i);
    for(auto v : p) mp[v.first] += v.second;
  }
  mint ans = 1;
  for(auto v : mp) ans *= v.second + 1;
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

int main()
{
	cin >> n >> m;
	cout << (n - 1)*(m - 1) << endl;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int A, B, C, K; cin >> A >> B >> C >> K;

	int ans = 0;
	if(K <= A) ans = K;
	else if(K <= A + B ) ans = A;
	else{
		int m = K - A - B;
		ans = A - m;
	}

	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
char c[200005];
int n;
map <string,bool> m;
char ch[256];
int dp[200005][3][3];
int f[200005][3];
const int mod=998244353;

void dfs(string s)
{
	if(m[s]) return;
	string t=s;
	m[s]=true;
	for(int i=0;i<(int)s.size()-1;i++)
	{
		if(s[i]!=s[i+1])
		{
			ch['a']=ch['b']=ch['c']=false;
			ch[s[i]]=true;
			ch[s[i+1]]=true;
			for(char cc='a';cc<='c';cc++)
			{
				if(ch[cc]) continue;
				s[i]=s[i+1]=cc;
				dfs(s);
				s=t;
				break;
			}
		}
	}
}

int main() 
{
//	freopen("input.txt","r",stdin);
	scanf("%s",c);
	n=strlen(c);
	if(n<=5)
	{
		string s=c;
		dfs(s);
		cout<<m.size()<<endl;
		return 0;
	}
//	for(auto x:m)
//	{
//		cout<<x.first<<endl;
//	}
//	cout<<m.size()<<endl;
	dp[1][0][0]=dp[1][1][1]=dp[1][2][2]=1;
	for(int i=1;i<n;i++)
	{
		for(int s=0;s<3;s++)
		{
			for(int last=0;last<3;last++)
			{
				for(int newadd=0;newadd<3;newadd++)
				{
					if(last==newadd) continue;
					int& tr=dp[i+1][(s+newadd)%3][newadd];
					tr+=dp[i][s][last];
					if(tr>=mod) tr-=mod;
				}
			}
		}
	}
	f[0][0]=1;
	for(int i=0;i<n;i++)
	{
		for(int s=0;s<3;s++)
		{
			for(int newadd=0;newadd<3;newadd++)
			{
				int& tr=f[i+1][(s+newadd)%3];
				tr+=f[i][s];
				if(tr>=mod) tr-=mod;
			}
		}
	}
	
	bool flag=true;
	for(int i=0;i<n;i++)
	{
		if(c[i]!=c[0]) flag=false;
	}
	if(flag) over(1);
	
	bool diffall=true;
	for(int i=0;i<n-1;i++)
	{
		if(c[i]==c[i+1]) diffall=false;
	}
	
	int s=0;
	for(int i=0;i<n;i++)
	{
		s+=c[i]-'a';
	}
	s%=3;
	
	cout<<((ll)f[n][s]-dp[n][s][0]-dp[n][s][1]-dp[n][s][2]+1LL*mod*5+diffall)%mod<<endl;
	return 0;
}

Measured memory_bytes: 9856
import sys

N, Y = map(int,input().split())

for x in range(N+1):
    if x*10000 > Y:
        break
    for y in range(N+1-x):
        z = N - (x + y)
        if (x*10000 + y*5000 + z*1000) == Y:
            print(x,y,z)
            sys.exit()

print(-1,-1,-1)


Measured memory_bytes: 3060
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int n = scan.nextInt();
        String s = scan.next();
        int out = n;
        for(int i = 0; i < n - 1; i++){
            if(s.charAt(i) == s.charAt(i + 1)){
                out--;
            }
        }
        System.out.println(out);
        scan.close();
    }
}

Measured memory_bytes: 24656
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	vector<vector<int>>cha(M + 1, vector<int>(100002));
	vector<int>sum(100002);
	for (int i = 0; i < N; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		cha[c][a - 1]++;
		cha[c][b]--;
	}
	for (int i = 1; i <= M; i++) {
		for (int j = 1; j < 100002; j++) {
			cha[i][j] += cha[i][j - 1];
		}
	}
	for (int i = 1; i <= M; i++) {
		L = -1;
		for (int j = 0; j < 100002; j++) {
			if (cha[i][j]) {
				if (L == -1) {
					L = j;
				}
			}
			else {
				if (L != -1) {
					sum[L]++;
					sum[j]--;
					L = -1;
				}
			}
		}
	}
	int ans = sum[0];
	for (int i = 1; i < 100002; i++) {
		sum[i] += sum[i - 1];
		ans = max(ans, sum[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12800
#include<stdio.h>
int main()
{
	int n, m, ary[105][105], a[105];
	while(scanf("%d%d", &n, &m)!=EOF)
	{
		for(int i=0;i<n;i++)
		{
			int sum=0;
			for(int j=0;j<m;j++)
			{
				scanf("%d", &ary[i][j]);
				sum+=ary[i][j];
			}
			ary[i][m]=sum;
		}
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<=m;j++)
			{
				printf("%d", ary[i][j]);
				if(j!=m)
				{
					printf(" ");
				}
			}
			puts("");
		}
		for(int i=0;i<=m;i++)
		{
			int sum=0;
			for(int j=0;j<n;j++)
			{
				sum+=ary[j][i];
			}
			printf("%d", sum);
			if(i!=m)
			{
				printf(" ");
			}
		}
		puts("");
	}
	return 0;
} 


Measured memory_bytes: 2660
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<queue>
#include<tuple>
#define lson (now<<1)
#define rson ((now<<1)|1)
#define mid ((nl+nr)>>1)
#define maxn 2000005
using namespace std;
typedef long long ll;
char s[maxn];
int main()
{
	int cnt=0;
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(int i=1;i<=len;i++)
	{
		cnt+=s[i]-'0';
	}
	if(cnt%9)
	{
		printf("No\n");
	}
	else
	{
		printf("Yes\n");
	}
}

Measured memory_bytes: 3952
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define    boost        ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define    nl           "\n"
#define    ll           long long
#define    pb           push_back
#define    mpr          make_pair
#define    fr(i,a,n)    for(ll i=a;i<n;++i)
#define    fr0(i,n)     for(ll i=0;i<n;++i)
#define    pii          pair<int, int>
#define    FO           find_by_order
#define    OK           order_of_key
#define    mem(a)       memset(a,0,sizeof(a))
#define    ff           first
#define    ss           second


typedef tree <
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update >
set_t;


void fio()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
	double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
	time_taken *= 1e-9;
	cout << "\nExecuted in: " << fixed
	     << time_taken << setprecision(9);
	cout << " sec";
#endif
}

///----------------------------- | FUNCTIONS | --------------------------------------///

/*
const int N = 2e5 + 5;

vector<int> adj[N];
bool visited[N];
//int val[N];
int depth[N];
//int parent[N];

void dfs(int v)
{
	visited[v] = true;
	for (int u : adj[v])
	{
		if (!visited[u])
		{
			//parent[u] = v;
			depth[u] = depth[v] + 1;
			dfs(u);
		}
	}
}
*/

// left shift << multiply by 2
// right shift >> divide by 2

///----------------------------- | START FROM HERE | --------------------------------------///

#define int long long //change int main to int32_t main
const int N = 2e5 + 5;
int n, ww;
int w[N], v[N];
int dp[105][N];

int rec(int i, int cap)
{
	if (dp[i][cap] != -1) return dp[i][cap];
	int result = 0;
	if (cap > 0 && i < n)
	{
		if (w[i] > cap)
		{
			result = rec(i + 1, cap);
		}
		else
		{
			int x = rec(i + 1, cap);
			int y = v[i] + rec(i + 1, cap - w[i]);
			result = max(x, y);
		}
	}
	dp[i][cap] = result;
	return result;
}

void solve()
{
	cin >> n >> ww;
	fr0(i, n) cin >> w[i] >> v[i];
	memset(dp, - 1, sizeof(dp));
	int ans = rec(0, ww);
	cout << ans;

}





int32_t main()
{
	auto start = chrono::high_resolution_clock::now();
	boost;
	fio();
	int t;
	t = 1;
	//cin >> t;
	while (t--) solve();
	auto end = chrono::high_resolution_clock::now();
	TIME(start, end);
	return 0;
}




Measured memory_bytes: 167632
#include <stdio.h>
int main(){
    int a,b;
    
    for(;;){
        scanf("%d %d",&a,&b);
        if (a==0 && b==0) break;
        
        if(a<b) printf("%d %d\n",a,b);
        else printf("%d %d\n",b,a);
    }
    
    return 0;
    
}


Measured memory_bytes: 2028
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define Alint(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1ll << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 998244353, INF = 1e9;

struct edge { lint to, cap, rev; };

vector<edge> Graph[20005];
int level[20005];
int iter[20005];
void add_edge(lint from, lint to, lint cap) {
	Graph[from].push_back({ to, cap, SZ(Graph[to]) });
	Graph[to].push_back({ from, 0, SZ(Graph[from]) - 1 });
}
void bfs(lint s) {
	memset(level, -1, sizeof(level));
	queue<lint> que;
	que.push(s);
	level[s] = 0;
	while (!que.empty()) {
		lint v = que.front(); que.pop();
		REP(i, SZ(Graph[v])) {
			edge& e = Graph[v][i];
			if (e.cap > 0 && level[e.to] < 0) {
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

lint dfs(lint v, lint t, lint f) {
	if (v == t) return f;
	for (int& i = iter[v]; i < SZ(Graph[v]); i++) {
		edge& e = Graph[v][i];
		if (e.cap > 0 && level[v] < level[e.to]) {
			lint d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				Graph[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

lint max_flow(lint s, lint t) {
	lint flow = 0;
	for (;;) {
		bfs(s);
		if (level[t] < 0) return flow;
		memset(iter, 0, sizeof(iter));
		lint f;
		while ((f = dfs(s, t, INF)) > 0) {
			flow += f;
		}
	}
}


lint H, W;
char c;

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	//始点 20002 終点 20003
	lint N = 10000;
	cin >> H >> W;
	REP(i, H) {
		REP(j, W) {
			cin >> c;
			if (c == 'X') {
				add_edge(20002, i * W + j + N, INF);
			}
			else add_edge(i * W + j, i * W + j + N, 1);
			if (j < W - 1) {
				add_edge(i * W + j + N, i * W + j + 1, INF);
				add_edge(i * W + j + 1 + N, i * W + j, INF);
			}
			if (i < H - 1) {
				add_edge(i * W + j + N, (i + 1) * W + j, INF);
				add_edge((i + 1) * W + j + N, i * W + j, INF);
			}
			if (i == 0 || j == 0 || i == H - 1 || j == W - 1) {
				add_edge(i * W + j + N, 20003, INF);
			}
		}
	}
	lint ans = max_flow(20002, 20003);
	if (ans >= INF) cout << -1 << endl;
	else cout << ans << endl;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,m;
    cin >> n >> m;
    vi a(m);
    rep(i,m) cin >> a.at(i);
    vi pt(n+1,-1);
    rep(i,m) pt.at(a.at(i)) = 0;
    // i段目までの場合の数を入れて行って、たしていけば良い
    pt.at(0) = 1;
    if(pt.at(1) != 0) pt.at(1) = 1;
    for(int64_t i=2; i<n+1; i++){
        if(pt.at(i) == 0) continue;
        pt.at(i) = pt.at(i-1) + pt.at(i-2);
        pt.at(i) %= INF;
    }
    // rep(i,n+1) cout << "i:" << i << " pt:" << pt.at(i) << endl;
    cout << pt.at(n) << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
    int i,n;
    char m;
    char a[100];

    while(scanf("%s",a)!=EOF)
    {

        n=0;
        for(i=50; i>=1; i--)
        {
            if('F'==a[i])
            {
                n=i+1;
                break;
            }
        }

        for(i=0; i<=n-2; i++)
            printf("%c",a[i]);
            printf("\n");
          for(i=0;i<=50;i++){
            a[i]='0';
          }
    }

    return 0;

}










Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {

  int n; cin >> n;
  vector<int> cnta(n + 1, 0);
  vector<int> cntb(n + 1, 0);

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

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

  for (int i = 1; i <= n; i++) {
    if (cnta[i] + cntb[i] > n) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  // yes が確定

  // 各数の右端
  vector<lint> rb(n + 1, -1);
  for (int i = 0; i < n; i++) {
    rb[b[i]] = i;
  }

  vector<lint> la(n + 1, -1);
  for (int i = n - 1; i >= 0; i--) {
    la[a[i]] = i;
  }

  lint ma = 0;
  for (int i = 1; i <= n; i++) {
    if (rb[i] == -1) continue;
    if (la[i] == -1) continue;
    ma = max(ma, rb[i] - la[i] + 1);
  }

  // cerr << "ma = " << ma << endl;

  // ma だけ左シフト
  vector<int> ans(n);
  for (int i = 0; i < n; i++) {
    ans[i] = b[(i + ma) % n];
  }
  
  for (int i = 0; i < n; i++) {
    if (i == n - 1) cout << ans[i] << endl;
    else cout << ans[i] << " ";
  }

  return 0;
}


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

string s;

int main(void){
	cin >> s;
	lli a, b, c;
	a = b = c = 0;
	rep(i, s.size()){
		if(s[i] == 'a') a++;
		else if(s[i] == 'b') b++;
		else c++;
	}
	lli d = min({a, b, c});
	a-=d;
	b-=d;
	c-=d;
	if(a > 1 || b > 1 || c > 1) cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 3732
A,B,C,X,Y=map(int,input().split())
ans=A*X+B*Y
if X>Y:
    if A+B>2*C:
        ans-=(A+B-2*C)*Y

    if A>2*C:
        ans-=(A-2*C)*(X-Y)
elif X<Y:
    if A+B>2*C:
        ans-=(A+B-2*C)*X
    if B>2*C:
        ans-=(B-2*C)*(Y-X)
elif X==Y:
    if A+B>2*C:
        ans-=(A+B-2*C)*X

print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
bool f(string S) {
	if (S == "ABC") return 1;
	int n = S.size();
	if (n < 5) return 0;
	char x = (S.substr(0,3) == "ABC") ? 'A' : (S.substr(n-3) == "ABC" ? 'C' : 'B');
	string t = "";
	for (int i = 0; i < n; ++i) {
		if (S[i]+1 == S[i+1] && S[i+1]+1 == S[i+2]) { t += x; i += 2; }
		else if (S[i] == x) return 0;
		else t += S[i];
	}
	return t != S && f(t);
}
int main() {
	string S;
	cin >> S;
	cout << (f(S) ? "Yes\n" : "No\n");
}


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

int main(){
    int A, B;
    string S;
    cin >> A >> B >> S;

    for (int i = 0; i != S.size();++i){
        if(i==A){
            if(S[i]!='-'){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            if('0'>S[i] || S[i]>'9'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		if (n == 0) {
			System.out.println(0);
			return;
		}
		StringBuilder st = new StringBuilder();
		while (true) {
			if (n == 0) break;
			if (n%-2 == 0) {
				st.append('0');
			} else {
				st.append('1');
			}
			if (n%-2 < 0) n = (n/-2)+1;
			else n /= -2;
		}
		System.out.print(st.reverse());
	}
}


Measured memory_bytes: 22996
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	int n, x;
	cin >> n >> x;
	int cnt(1), dd(0);
	rep(i, n) {
		int l;
		cin >> l;
		dd += l;
		if (dd <= x) {
			cnt++;
			
			//cout << dd;
		}
		else {
			break;
		}
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 3640
import java.util.*;
import java.util.Collections;
public class Main {
	public static void main(String[] args){	
      Scanner sc = null;
      sc = new Scanner(System.in);
      long N = sc.nextLong();
      String ans = "";
     
      while(N-- > 0){
        ans = (char)('a' + (N%26)) + ans;
        N /= 26;
      }
      System.out.println(ans);
    }
}

Measured memory_bytes: 39200