akhauriyash/Code-Regression huggingface dataset:
/**
 *
 * Contest - Problema X: Nome (link)
 *
 * Abridge version.
 *
 * Solution: text
 */
#include <iostream>

#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstring>
#include <algorithm>

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;

#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))
#define LOGM(msg) (cerr << (msg))
#define LOGV(vec, sep) { cerr << #vec << " ="; for (const auto& v : vec) cerr << " " << v; cerr << (sep); }
#define LOGA(arr, N, sep) { cerr << #arr << " ="; for (int i = 0; i < N; ++i) cerr << " " << (arr)[i]; cerr << (sep); }
#define LOGA2(arr, N, M, sep) { cerr << #arr << " =\n"; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) cerr << (arr)[i][j] << " "; cerr << endl; } cerr << (sep); }

ostream& operator<<(ostream& os, const ii& p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

const int MAX { 2000010 };
const ll oo { 1LL << 62 };
const int MOD { 1000000007 };

void precomp()
{
}

bool ok(const string& S)
{
    if (S.front() != 'A')
        return false;

    int count = 0, N = S.size();

    for (int j = 2; j < N - 1; ++j)
        count += (S[j] == 'C' ? 1 : 0);

    if (count != 1)
        return false;

    count = 0;

    for (int i = 0; i < N; ++i)
        count += ('A' <= S[i] and S[i] <= 'Z' ? 1 : 0);

    return count == 2;
}

void solve(const string& S)
{
    cout << (ok(S) ? "AC" : "WA") << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    precomp();

    string S;
    cin >> S;

    solve(S);

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int a,b,c,x;
    long num=0;
    int i,j;

    scanf("%d%d%d%d",&a,&b,&c,&x);

    for(i=0;i<=a;i++)
        for(j=0;j<=b;j++)
            if((x-100*j-500*i)>=0&&(x-100*j-500*i)/50<=c&&(x-100*j-500*i)%50==0)
                num++;

    printf("%ld\n",num);

    return 0;
}


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

struct Item {
    ll weight;
    ll value;
};

const int WIDTH = 310;
ll N, W, OFFSET;
vector<Item> items;
ll dp[101][101][WIDTH];

int main() {
    cin >> N >> W;
    rep (i, N) {
        ll w, v;
        cin >> w >> v;
        if (i == 0) {
            OFFSET = w;
        }
        w -= OFFSET;
        items.push_back({w, v});
    }
    rep(i, 101) rep(j, 101) rep(k, WIDTH) dp[i][j][k] = -1;
    dp[0][0][0] = 0;
    ll ans = 0;
    rep(i, N) {
        rep(j, N) {
            rep(k, WIDTH) {
                if (dp[i][j][k] < 0) {
                    continue;
                }
                dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
                //
                int k2 = k + items[j].weight;
                ll w = (i + 1) * OFFSET + k2;
                if (w > W) {
                    continue;
                }
                ll nextV = dp[i][j][k] + items[j].value;
                nextV = max(dp[i + 1][j + 1][k2], nextV);
                dp[i + 1][j + 1][k2] = nextV;
                ans = max(ans, nextV);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 24960
#include<bits/stdc++.h>
#define bug(x) cout<<(#x)<<" "<<(x)<<endl
#define ll long long
#define inf INT_MAX
/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
using namespace std;
const int N=1e5+5;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int dis[N],tot,n,m,fa[N];
bool vis[N];
int find(int x){
	int p=fa[x];
	if(fa[x]!=x) fa[x]=find(fa[x]),dis[x]+=dis[p];
	return fa[x];
}
int main(){
#ifdef Devil_Gary
	freopen("in.txt","r",stdin);
#endif 
	n=read(),m=read();
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1,l,r,d;i<=m;i++) {
		l=read(),r=read(),d=read();
		int x=find(l),y=find(r);
		if(x==y){
			if(dis[l]+d!=dis[r]) return printf("No\n"),0;
		} 
		else{
			int d1=dis[l]-dis[x],d2=dis[r]-dis[y]-d;
			if(d1>d2) fa[y]=x,dis[y]=dis[x]+d1-d2;
		 	else fa[x]=y,dis[x]=dis[y]+d2-d1;
		} 
	}
	return printf("Yes\n"),0;
}


Measured memory_bytes: 1024
n, a, b = map(int,input().split())
mod = 10**9+7
total = pow(2, n, mod) - 1
def c(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p*(n-i)%mod
        q = q*(i+1)%mod
    return p * pow(q, mod-2, mod)%mod

print((total - c(n, a) - c(n, b))%mod)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N;
	cin >> N;
	vector<long long>A(N);
	for (long long i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	string S = "Yes";
	for (long long i = N - 1; i >= 1; i--) {
		if (A.at(i - 1) - A.at(i) > 1) S = "No";
		else if (A.at(i - 1) - A.at(i) == 1) {
			A.at(i - 1)--;
		}
	}
	cout << S << endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

int a[N], b[N];
vector<int> v;
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n;	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = n; i >= 1; i--){
		int x = 0;
		for(int j = 2; j*i <= n; j++)
			x += b[j*i];
		x %= 2;
		if(x != a[i])	
			b[i] = 1, v.push_back(i);	
	}	
	reverse(v.begin(), v.end());
	cout << v.size() << endl;
	for(auto i: v)
		cout << i << " ";
	return 0;
}

Measured memory_bytes: 2936
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int q = sc.nextInt();
    long[] s = new long[a];
    long[] t = new long[b];
    for(int i = 0; i < a; i++) {
      s[i] = sc.nextLong();
    }
    for(int i = 0; i < b; i++) {
      t[i] = sc.nextLong();
    }
    for(int i = 0; i < q; i++) {
      long ans = Long.MAX_VALUE;
      long x = sc.nextLong();
      int left = 0;
      int right = a;
      int a1 = a;
      while(left < right) {
        int med = (left + right) / 2;
        if(s[med] >= x) {
          a1 = med;
          right = med;
        } else {
          left = med + 1;
        }
      }
      left = 0;
      right = b;
      int b1 = b;
      while(left < right) {
        int med = (left + right) / 2;
        if(t[med] >= x) {
          b1 = med;
          right = med;
        } else {
          left = med + 1;
        }
      }
      if(a1 == a) {
        if(b1 == b) {
          ans = Math.min(ans, Math.max(x - s[a - 1], x - t[b - 1]));
        } else {
          if(b1 > 0) ans = Math.min(ans, Math.max(x - s[a - 1], x - t[b1 - 1]));
          ans = Math.min(ans, 2 * (x - s[a - 1]) + t[b1] - x);
          ans = Math.min(ans, 2 * (t[b1] - x) + x - s[a - 1]);
        }
      } else {
        if(b1 == b) {
          if(a1 > 0) ans = Math.min(ans, Math.max(x - s[a1 - 1], x - t[b - 1]));
          ans = Math.min(ans, 2 * (s[a1] - x) + x - t[b - 1]);
          ans = Math.min(ans, 2 * (x - t[b - 1]) + s[a1] - x);          
        } else {
          if((a1 > 0) && (b1 > 0)) ans = Math.min(ans, Math.max(x - s[a1 - 1], x - t[b1 - 1]));
          ans = Math.min(ans, Math.max(s[a1] - x, t[b1] - x));

          if(b1 > 0) ans = Math.min(ans, 2 * (s[a1] - x) + x - t[b1 - 1]);
          if(b1 > 0) ans = Math.min(ans, 2 * (x - t[b1 - 1]) + s[a1] - x);

          if(a1 > 0) ans = Math.min(ans, 2 * (x - s[a1 - 1]) + t[b1] - x);
          if(a1 > 0) ans = Math.min(ans, 2 * (t[b1] - x) + x - s[a1 - 1]);         
        }
      }
      System.out.println(ans);      
    }
  }
}

Measured memory_bytes: 105600
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	string s[8]={"AAA","AA","A","B","C","D","E","NA"};
	double h[8][2]={
	  {35.5,71.0},
	  {37.5,77.0},
	  {40.0,83.0},
	  {43.0,89.0},
	  {50.0,105.0},
	  {55.0,116.0},
	  {70.0,148.0},
	  {1e9,1e9},
	};
	double a,b;
	while(cin>>a>>b){
		rep(i,8)if(h[i][0]>a&&h[i][1]>b){
			cout<<s[i]<<endl;
			break;
		}
	}
}

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

using i64 = int64_t;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    string left = s.substr(0, n/2);
    string right = s.substr(n/2+1);
    string s_rev = s;
    reverse(s_rev.begin(), s_rev.end());
    string left_rev = left, right_rev = right;
    reverse(left_rev.begin(), left_rev.end());
    reverse(right_rev.begin(), right_rev.end());
    if(s == s_rev && left == left_rev && right == right_rev){
        cout << "Yes";
    }else{
        cout << "No";
    }
    cout << endl;

    return 0;
}

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

int main(void){
    int n;
    string s;
    cin >> n >> s;
    int l=1;
    
    for(int i=1;i<n;i++){
        if(s[i]!=s[i-1]) l++; 
    }

    cout << l << endl;

    return 0;
}

Measured memory_bytes: 512
import java.util.*;
import java.util.stream.*;

public class Main {

	static long[] count = new long[51];
	static long[] pa = new long[51];

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		long X = in.nextLong();
		count[0] = pa[0] = 1L;
		for (int i = 1; i <= 50; i++) {
			count[i] = 3L + count[i - 1] * 2L;
			pa[i] = 1L + pa[i - 1] * 2L;
		}
		System.out.println(count(N, X));
	}

	public static long count(int n, long x) {
		if (n == 0) {
			return 1;
		}
		if (x == 1) {
			return 0;
		}

		long ans = 0;

		// 一番した食べる
		x--;

		// 下のN-1次元バーガー
		if (x <= count[n - 1]) {
			return count(n - 1, x);
		} else {
			ans += pa[n - 1];
			x -= count[n - 1];
		}

		if(x < 2) {
			return ans + x;
		}
		// まだ残りがある場合はこの次元の真ん中のP
		ans++;
		x--;
		// 上のN-1次元バーガー
		if (x <= count[n - 1]) {
			return ans + count(n - 1, x);
		}
		return ans + pa[n - 1];
	}
}


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

    int main()
    {
        int n;
        scanf("%d",&n);
        vector<int>a;
        for(int i=0;i<n;i++)
        {
            int temp;
            scanf("%d",&temp);
            a.push_back(temp);
        }
        int counter=0;
        int test=0;
        for(int i=0;i<n-1;i++)
        {
            if(a[i]==a[i+1])
            {
                if(test==0)
                {
                    counter++;
                    test=1;
                }else
                {
                    test=0;
                }
            }else
            {
                test=0;
            }
        }
        printf("%d\n",counter);
    }



Measured memory_bytes: 256
#include<stdio.h>

int dp[50];

int fib(int n){
  if(n==0||n==1) return dp[n]=1;
  if(dp[n] != -1) return dp[n];
  return dp[n]=fib(n-1)+fib(n-2);
}

int main(){
  int n,i;
  for(i=0;i<50;i++) dp[i]=-1;
  scanf("%d",&n);
  printf("%d\n",fib(n));

  return 0;
}



Measured memory_bytes: 2104
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(D)]

last = {}
for i in range(1,27):
    last[i] = 0

for d in range(1,D+1):
    ans = [1,0]
    for i in range(1,27):
        satisfaction = 0
        satisfaction += s[d-1][i-1]
        for j in range(1,27):
            if i != j:
                satisfaction -= c[j-1]*(d-last[j])
        if ans[1] <= satisfaction:
            ans = [i,satisfaction]
    last[ans[0]] = d
    print(ans[0])

Measured memory_bytes: 68516
import java.io.*;
import java.util.*;

class Program{
    String S[];
    ArrayList<Integer> sub = new ArrayList<>();
    int diff = Integer.MAX_VALUE;
    void solve(String S[]){
        for(int i = 0;i<=S.length-3;i++){
            diff = Math.min(diff,Math.abs(753 - Integer.parseInt( S[i]+S[i+1]+S[i+2] )) );        
        }
        System.out.println(diff);
    }
}
class Main{
    public static void main(String[] args) {
        Program obj = new Program();
        Scanner in = new Scanner(System.in);
        obj.solve(in.nextLine().split(""));
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N, M;
vector<int> g[112345];
bool done[112345];

void dfs(int u) {
	if (done[u]) return;
	done[u] = true;
	
	for (int v : g[u]) {
		if (done[v]) continue;
		dfs(v);
	}
}

int main() {
	cin >> N >> M;
	REP(i, M) {
		int x, y, z;
		scanf("%d %d %d", &x, &y, &z);
		x--; y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	
	int ans = 0;
	REP(i, N) if (!done[i]) {
		ans++;
		dfs(i);
	}
	
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

map<char,char> ans;
int n;
char c;

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>c;
        if(ans.count(c)==0){
            ans.insert(make_pair(c,'0'));
        }
        if(ans.size()==4){
            cout<<"Four"<<endl;
            return 0;
        }
    }
    cout<<"Three"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> vec;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a,b;
	cin >> a;
	for(int i=0;i<a;i++){
		cin >> b;
		vec.push_back(b);
	}
	sort(vec.begin(),vec.end());
	int naj = vec[a-1];
	double srodek = naj/2.0;
	int najsr = vec[0];
	for(int i=0;i<a;i++){
		if(abs(srodek - vec[i]) < abs(srodek - najsr))najsr = vec[i];
	}
	cout << naj << " " << najsr;
	return 0;
}

Measured memory_bytes: 892
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N;
    cin>>N;
    vector<ll> a(N);
    ll ans=0;
    REP(i,N) cin>>a[i];
    REP(i,N){
        if(i%2==0&&a[i]%2==1) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3616
n = int(input())
for i in range(5):
    if n == 100000:
        keta = 6
    elif 10**i <= n < 10**(i+1):
        keta = i+1
        break

if keta ==1:
    count = n
elif keta == 2:
    count = 9
elif keta == 3:
    count = 9 + (n - 99)
elif keta == 4:
    count = 9 + 900
elif keta == 5:
    count = 9 + 900 + (n - 9999)
else:
    count = 90909

print(count)

Measured memory_bytes: 3064
N, K = map(int, input().split())
A = list(map(int, input().split()))
idx = 1
S = [idx]
ed = set([idx])

for i in range(1, K+1):
    idx = A[idx-1]
    if idx in ed:
        start = S.index(idx)
        end = len(S)
        n = start + (K - start) % (end - start)
        print(S[n])
        break
    else:
        S.append(idx)
        ed.add(idx)
        continue
else:
    print(idx)

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

vector<ll> v;
ll n, a, b, c, l;

ll dfs(ll i, ll aa, ll bb, ll cc) {
	ll res1, res2, res3, res4;

	if (i == n) {
		if (min(aa, min(bb, cc)) > 0) {
			return abs(aa - a) + abs(bb - b) + abs(cc - c) - 30;
		}
		else {
			return INF;
		}
	}
	
	res1 = dfs(i + 1, aa, bb, cc);
	res2 = dfs(i + 1, aa + v[i], bb, cc) + 10;
	res3 = dfs(i + 1, aa, bb + v[i], cc) + 10;
	res4 = dfs(i + 1, aa, bb, cc + v[i]) + 10;

	return min(res1, min(res2, min(res3, res4)));
}

signed main() {

	cin >> n >> a >> b >> c;

	REP(i, n) {
		cin >> l;
		v.push_back(l);
	}

	cout << dfs(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 1000010

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll x,y;
  cin>>x>>y;

  make_fact(FACSIZE-2);
  make_invfact(FACSIZE-2);

  if( (x+y)%3LL != 0 ){
    cout << 0 << endl;
  }
  else{
    ll n=(x+y)/3LL;
    ll d=(x-y+n)/2LL;
    if( d<0 || d>n ){
      cout << 0 << endl;
    }
    else{
      ll ans= mod_mul( fac[n] , mod_mul( invfac[d] , invfac[n-d] ) );
      cout << ans << endl;
    }
  }

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}


Measured memory_bytes: 15872
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main()
{
    int n,k;
    string s;
    cin >> n >> k >> s;
    int ans = 0;
    for(int i = 1;i < s.size();i++)
    {
        if(s[i - 1] == s[i])
        {
            ans++;
        }
    }
    cout << min(ans + 2 * k,n - 1) << "\n";

    return 0;
}

Measured memory_bytes: 512
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<utility>
#include<queue>
using namespace std;

int main()
{
	int i, j, k, l, m, n,flag,N,M;
	cin >> N;
	vector<long long int>A(N);
	vector<long long int>B(N);
	for (i = 0; i<N; i++) {
		cin >> A[i];
		B[i] = A[i] - i - 1;
	}
	sort(B.begin(), B.end());
	long long int sum, cnt;
	sum = 0;
	flag = 0;
	long long int b;
	b = B[N / 2];
	for (i = 0; i < N; i++) {
		sum += abs(B[i] - b);
	}
	cout << sum << endl;

	
 
    return 0;
}



Measured memory_bytes: 3328
#include <iostream>
using namespace std;
 
int main(){
	int n;
	cin >> n;
	int min = 2000000001;
	int output = -2000000000;
	int temp;
	int temp_o;
	
	// Input
	for(int t=0; t<n; ++t){
		cin >> temp;
		
		temp_o = temp - min;
		if(temp_o > output){
			output = temp_o;
		}

		if(temp < min){
			min = temp;
		}

	}

	cout << output << endl;
	
	return 0;
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; ++i)
  {
    cin >> a[i];
    a[i] -= (i + 1);
  }

  auto f = [&](ll b)
  {
    ll ret = 0;
    for(int i = 0; i < n; ++i)
    {
      ret += abs(a[i] - b);
    }
    return ret; 
  };

  ll le = -1001000001LL, re = 1001000001LL;
  ll lv = f(le);
  ll rv = f(re);
  ll ans = min(lv, rv);
  while(re - le > 1)
  {
    ll mid = (le + re) / 2LL;
    ll mv = f(mid);
    ans = min(ans, mv);
    if (lv < rv)
    {
      re = mid;
      rv = mv;
    }
    else
    {
      le = mid;
      lv = mv;
    }
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 4760
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c = input().split()
    x = int(a + b + c)

    if x % 4 == 0:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()


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

#define INF 1e15

int main(void){
  
  while(true){
    int n, m;
    cin >> n >> m;
    if(n == 0 && m == 0){ break; }

    int x, y;
    long long t;
    string sl;
    vector<vector<long long int> > Lmatrix(n, vector<long long int>(n, INF));
    vector<vector<long long int> > Smatrix(n, vector<long long int>(n, INF));

    for(int i = 0; i < m; i++){
      cin >> x >> y >> t >> sl;
      --x;
      --y;
      if(sl == "L"){
        Lmatrix[x][y] = min(Lmatrix[x][y], t);
        Lmatrix[y][x] = min(Lmatrix[y][x], t);
      }
      else{
        Smatrix[x][y] = min(Smatrix[x][y], t);
        Smatrix[y][x] = min(Smatrix[y][x], t);    
      }
    }

    // ???????????£???
    for(int i = 0; i < n; i++)
      Lmatrix[i][i] = Smatrix[i][i] = 0;
    
    for(int k = 0; k < n; k++){
      for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
          Lmatrix[i][j] = min(Lmatrix[i][j], Lmatrix[i][k] + Lmatrix[k][j]);
          Smatrix[i][j] = min(Smatrix[i][j], Smatrix[i][k] + Smatrix[k][j]);
        }
      }
    }
    
    int r;
    cin >> r;
    vector<int> z(r);
    for(int i = 0; i < r; i++){
      cin >> z[i];
      --z[i];
    }

    // result[i][j]: i?????????????§?????????????j???????????´????????????????????§???????°??????????
    vector<vector<long long int> > result(r, vector<long long int>(n, INF));
    result[0][z[0]] = 0;
    
    // z[i]??????z[i + 1]????§????????????????m1??????m2?????§???????????????     
    for(int i = 0; i < r - 1; i++){
      int start = z[i];
      int goal = z[i + 1];
      for(int j = 0; j < n; j++)
        result[i + 1][j] = result[i][j] + Lmatrix[start][goal];
      
      for(int m1 = 0; m1 < n; m1++){
        for(int m2 = 0; m2 < n; m2++){
          long long int cost = result[i][m1] + Lmatrix[start][m1] + Smatrix[m1][m2] + Lmatrix[m2][goal];          
          result[i + 1][m2] = min(result[i + 1][m2], cost);
        }
      }
    }

    long long int ans = INF;
    for(int i = 0; i < n; i++){ ans = min(ans, result[r - 1][i]); }
    cout << ans << endl;
  }

  return 0;
}

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

const int maxn = 100009;
char s[maxn], t[maxn];
int S[maxn], T[maxn];
int n, m, Q, a, b, c, d;

int main(){
	scanf("%s", s+1); scanf("%s", t+1);
	n = strlen(s+1); 
	for (int i=1; i<=n; i++)
		S[i] = (S[i-1] + (s[i] == 'A' ? 1 : 2)) % 3;
	m = strlen(t+1);
	for (int i=1; i<=m; i++)
		T[i] = (T[i-1] + (t[i] == 'A' ? 1 : 2)) % 3;
	scanf("%d", &Q);
	while (Q--){
		scanf("%d%d%d%d", &a, &b, &c, &d);
		puts((S[b]-S[a-1]+3)%3 == (T[d]-T[c-1]+3)%3 ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
 
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%lf",&x)
#define sl(x) scanf("%lld",&x)
#define pr(x) printf("%d\n",x)
#define prll(x) printf("%lld\n",x)
 
#define ll long long int
#define ull unsigned long long int
#define F first
#define S second
 
#define rep(i,x,y) for(int i=x;i<y;i++)
#define ii pair<int,int> 
#define pll pair<ll,ll> 
#define vi vector<int> 
#define vvi vector< vi > 
#define vl vector<long long int>
#define vvl vector< vl >
#define vii vector< ii >
#define vvii vector< vii >
#define priority_queue pq;
#define sz(a) ll((a).size()) 
#define pb push_back 
#define mp make_pair
 
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end() 
#define tr(i,c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ison(x,i) (((x) >> (i)) & 1)	//checks if ith bit is on
#define set0(x,i) (x & ~(1 << i))		//set ith bit in x to be zero
#define clr(a) memset(a,0,sizeof(a))
 
#define MOD 1000000007
#define INF 4000000000000000000
#define MAX 100000+5
using namespace std;



int main()
{
	ll q,h,s,d,n;
	cin>>q>>h>>s>>d;
	cin>>n;
	q*=8;
	h*=4;
	s*=2;
	ll p = min(min(q,h),min(s,d));
	ll ans = p*(n/2);
	n%=2;
	q/=2;
	h/=2;
	s/=2;
	p = min(s,min(q,h));
	ans += p*n;
	prll(ans);
	return 0;
}

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

class Program
{
    static void Main()
    {
		int a = int.Parse(Console.ReadLine());
		string b = Console.ReadLine();
		string[] c = new string[1000];
		string[] d = new string[1000];
		int e = 0;
		for(int i=0; i<1000; i++) 
		{
			c[i] = ("00" + i.ToString()).Substring(i.ToString().Length - 1);
			d[i] = "";
		}

		for(int i=0; i<a; i++)
		{
			for(int j=0; j<1000; j++)
			{
				if(d[j].Length < 3 && c[j].Substring(d[j].Length, 1) == b[i].ToString()) d[j] += b[i].ToString();
			}
		}
		for(int i=0; i<1000; i++) if(d[i].Length == 3) e++;
		Console.WriteLine(e);
    }
}


Measured memory_bytes: 46260
#include <bits/stdc++.h>
#define fr(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef long double ld;

const ll N = (ll)1e6 + 34;
const ll INF = (ll)1e9 + 41;

ll a[N], b[N];
ll pref[N], suf[N];
ll cnt[N];

void fillArs(int l, int r) {
    for (ll i = l; i <= r; i++) {
        pref[i] = b[i];
        if (i > l)
            pref[i] += pref[i - 1];
    }
    for (ll i = r; i >= l; i--) {
        suf[i] = b[i];
        if (i < r)
            suf[i] += suf[i + 1];
    }
}

ll f(ll l, ll r) {

    if (l == r) {
        fillArs(l, r);
        if (b[l] < 0)
            return 1;
        else
            return 0;
    }
    ll m = (l + r) / 2;
    ll ans = 0;
    ans += f(l, m);
    ans += f(m + 1, r);
    fill(cnt, cnt + (r - l + 1) * 2 + 3, 0);
    ll add = (r - l + 2);
    //cout << l << ' ' << r << ' ' << ans << endl;
    for (ll i = l; i <= m; i++)
        cnt[suf[i] + add]++;
    for (ll i = 1; i < add * 2; i++)
        cnt[i] += cnt[i - 1];
//    for (ll i = add * 2 - 1; i >= 0; i--)
//        cnt[i] += cnt[i + 1];
    for (ll i = m + 1; i <= r; i++)
        ans += cnt[-pref[i] + add - 1];
    fillArs(l, r);
    //cout << l << " " << r << " " << ans << endl;
    return ans;
}

ll fGlob(ll m, ll n) {
    fr(i, n)
        b[i] = (a[i] < m ? -1 : 1);
    return f(0, n - 1);
}

void solve() {
    ll n;
    scanf("%lld", &n);
    for (ll i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
    }
    ll l = 0, r = INF;
//    for (int i = 1; i <= 5; i++)
//        cout << fGlob(i, n) << endl;
    while (r - l > 1) {
        ll m = (l + r) / 2;
        if (fGlob(m, n) <= (n * (n + 1) / 2) / 2)
            l = m;
        else
            r = m;
    }
    cout << l;
}

int main() {
    //freopen("a.in", "r", stdin);
    solve();
}


Measured memory_bytes: 14080
#include<iostream>
using namespace std;
int main(){
int h,w;
while(1){
cin>>h>>w;
if(h==0&&w==0)break;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
if(i==0||i==h-1||j==0||j==w-1){
cout<<"#";
}else{
cout<<".";
}
}
cout<<"\n";
}
cout<<endl;
}
return 0;
}


Measured memory_bytes: 3040
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))


ans=0
for i in range(n):
    if i > 0 and A[i]-A[i-1]==1:
        ans+=C[A[i-1]-1]
    ans+=B[A[i]-1]
print(ans)

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

change = 0  # 1, 0, -1
ans = 1

for i in range(N-1):
    if A[i+1] - A[i] > 0:
        if change == 0:
            change = 1
        elif change == -1:
            ans += 1
            change = 0
        else:
            continue
    elif A[i+1] - A[i] < 0:
        if change == 0:
            change = -1
        elif change == 1:
            ans += 1
            change = 0
        else:
            continue

print(ans)


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

int main() {
  string S;
  cin>>S;
  vector<char> p={};
  for(int i=0;i<S.size();i++){
    if(S.at(i)!='x'){
      p.push_back(S.at(i));
    }
  }
  if(1==0){
    cout<<"-1"<<endl;
  }
  else{
    int Z=0;
    for(int i=0;i<p.size()/2;i++){
      if(p.at(i)!=p.at(p.size()-1-i)){
        Z++;
        break;
      }
    }
    if(Z==1){
      cout<<"-1"<<endl;
    }
    else{
      vector<int>q(p.size()+1);
      int a=0;
      for(int i=0;i<S.size();i++){
        if(S.at(i)=='x'){
          q.at(a)++;
        }
        else{
          a++;
        }
      }
      for(int i=0;i<q.size()/2;i++){
        Z+=abs(q.at(i)-q.at(p.size()-i));
      }
      cout<<Z<<endl;
    }
  }
          
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using P = std::pair<std::string,int>;

int main(){
        int n;
        scanf("%d", &n);

        std::vector<P> st(n);
        for(int i=0; i<n; i++){
                std::cin >> st[i].first >> st[i].second;
        }

        std::string x;
        std::cin >> x;
        int ans = 0;
        bool flag = 0;
        for(int i=0; i<n; i++){
                if(flag) ans += st[i].second;
                if(x==st[i].first) flag = 1;
        }

        printf("%d\n", ans);
        return 0;
}

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

void Tmp(string *x, string *y){
  string tmp=*x;
  *x=*y;
  *y=tmp;
}

int main(){
  int N, L;
  cin >> N >> L;
  
  string Array[N];
  for(int i=0 ; i<N ; i++)
    cin >> Array[i];
  
  for(int i=0 ; i<N-1 ; i++)
    for(int j=i+1 ; j<N ; j++)
      if(Array[i]>Array[j])
        Tmp(&Array[i], &Array[j]);
  
  for(int i=0 ; i<N ; i++)
    cout << Array[i];
  cout << endl;     
}

Measured memory_bytes: 256
public class Main {

	private static final String covconv(String s) {
		final char[] a = s.toCharArray();
		int sp = 0;
		for (int p = 0; p < a.length; ++p) {
			a[sp++] = a[p];
			while (p < a.length && "aiueo".indexOf(a[p]) == -1) ++p;
		}
		return new String(a, 0, sp);
	}
	
	private static final int kenkov(String[] s) {
		int rvalue = 0;
		for (int i = 0; i < s.length; ++i)
			rvalue = Math.max(rvalue, s[i].length());
		return rvalue;
	}
	
	private static final boolean check_disjoint(String[] s, int k) {
		for (int i = 0; i < s.length; ++i) {
			final String s1 = s[i].substring(0, Math.min(s[i].length(), k));
			for (int j = i + 1; j < s.length; ++j) {
				final String s2 = s[j].substring(0, Math.min(s[j].length(), k));
				if (s1.equals(s2))
					return false;
			}
		}
		return true;
	}
	
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			MAINLOOP:
			for (;;) {
				final int n = sc.nextInt();
				if (n == 0) break ;
				final String[] s = new String[n];
				for (int i = 0; i < n; ++i) {
					s[i] = covconv(sc.next());
				}
				final int max_length = kenkov(s);
				int k;
				for (k = 1; k <= max_length; ++k) {
					if (check_disjoint(s, k)) {
						System.out.println(k);
						continue MAINLOOP;
					}
				}
				System.out.println("-1");
			}
		}
	}

}



Measured memory_bytes: 39208
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {
    
    int n,m;
    cin>>n>>m;
    vpii v(n);
    int a,b;
    rep(i,n){
        cin>>a>>b;
        v[i]=mp(a,b);
    }
    vpii w(m);
    rep(i,m){
        cin>>a>>b;
        w[i]=mp(a,b);
    }
    rep(i,n){
        int ans=1;
        int dis=INF;
        rep(j,m){
            int dist=abs(v[i].second-w[j].second)+abs(v[i].first-w[j].first);
            if(dis>dist){
                dis=dist;
                ans=j+1;
            } else if(dis==dist){
                ans=min(ans,j+1);
            }
        }
        fin(ans);
    }
}


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

int main(){
  ll n,x;
  cin>>n>>x;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
  }
  ll ans=0;
  if(a[0]>x){
    ans+=a[0]-x;
    a[0]=x;
  } 
  rep(i,n-1){
    if(a[i]+a[i+1]>x){
      ans+=a[i+1]+a[i]-x;
      a[i+1]=x-a[i];
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4056
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    ans = 0
    for i in range(1, N + 1):
        if i % 3 == 0 or i % 5 == 0:
            continue
        else:
            ans += i
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 67404
//  Created by conan1024hao in 2020.
//  Copyright © 2020 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------
bool cmp(const Pll &l,const Pll &r){
    return l.fi<r.fi;
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s;cin>>s;ll k;cin>>k;
    for(ll i=0;i<s.length();i++){
        if(s[i]=='a')continue;
        ll c='z'-s[i]+1;
        if(c<=k){
            s[i]='a';
            k-=c;
        }
        else
            continue;
        if(k==0)break;
    }
    k%=26;s[s.length()-1]+=k;if(s[s.length()-1]>'z')s[s.length()-1]-=26;
    cout<<s<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------







Measured memory_bytes: 592
import sys

N = int(input())
arr = [list(map(int,input().split())) for i in range(N)]

for i in range(len(arr)):
    if arr[i][0] < arr[i][1]+arr[i][2] or arr[i][0]%2 != (arr[i][1]+arr[i][2])%2:
        print("No")
        exit()

for i in range(len(arr)-1):
    if arr[i+1][0]-arr[i][0] < abs(arr[i+1][1]-arr[i][1])+abs(arr[i+1][2]-arr[i][2]):
        print("No")
        exit()

print("Yes")

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

// dfs（深さ優先探索）
// https://qiita.com/drken/items/4a7869c5e304883f539b
vector<bool> seen;
void dfs(vector<vector<int>> &g, int v) {
	seen[v] = true;
	for(auto nv: g[v]) {
		if(seen[nv]) continue;
		dfs(g, nv);
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> x(m), y(m), z(m);
	rep(i, m) cin >> x[i] >> y[i] >> z[i];
	vector<vector<int>> g(n);
	rep(i, m) {
		x[i]--; y[i]--;
		g[x[i]].push_back(y[i]);
		g[y[i]].push_back(x[i]);
	}
	int ans = 0;
	seen.assign(n, false);
	rep(i, n) {
		if (seen[i] == false) {
			dfs(g, i);
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  vector<string> s;
  s.push_back("Sunny");
  s.push_back("Cloudy");
  s.push_back("Rainy");
  string ss;
  cin >> ss;
  for(int i = 0; i < 3; i++){
    if(s[i] == ss){
      cout << s[(i + 1) % 3];
    }
  }
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0, 0,-1,1,-1, 1,-1};
int dy[]={0,1,-1, 0,1,-1,-1, 1};


vector<LL> fact;
vector<LL> inver(200001);
 
LL combi(int n,int r){
    if(n<r||n<0||r<0) return 0;
    return fact[n]%mod*inver[n-r]%mod*inver[r]%mod;
}
 
 
LL fpow(LL a, LL n){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}
 
void set_combi(){
    LL s=1;
    fact.push_back(1);
    for(int i=1;i<=200000;i++){
        s*=i;
        s%=mod;
        fact.push_back(s);
    }
    inver[200000]=fpow(fact[200000],mod-2);
    for(int i=199999;i>=0;i--){
        inver[i]=inver[i+1]*(i+1)%mod;
    }
}


int main(){
    set_combi();
    LL b,w;cin >> b >> w;
    int n = b + w;
    vector<LL> pb(b + w + 1, 0);
    auto pw = pb;
    for (int i = 0; i < n; i++) {
        pb[i+1] = (pb[i] + combi(i-1,b-1) * fpow(fpow(2, i),mod-2))%mod;
        pw[i+1] = (pw[i] + combi(i-1,w-1) * fpow(fpow(2, i),mod-2))%mod;
    }
    for (int i = 1; i <= n; i++) {
        cout << (1 - pb[i] + pw[i] + mod) * fpow(2, mod-2) %mod << endl;
    }
    return 0;
}


Measured memory_bytes: 8560
#include <iostream>
#include <vector>

using namespace std;

long long root(long long x, vector<long long>& par) {
	if (par[x] < 0) return x;
	return par[x] = root(par[x], par);
}

int main() {
	long long N, M;
	cin >> N >> M;
	vector<pair<long long, long long>> E(M);
	for (long long i = 0; i < M; i++) cin >> E[i].first >> E[i].second;
	vector<long long> Ans(M);
	vector<long long> par(N, -1);
	Ans[M - 1] = N * (N - 1) / 2;
	for (long long i = M - 1; i >= 1; i--) {
		long long a = E[i].first, b = E[i].second;
		Ans[i - 1] = Ans[i];
		long long ra = root(a - 1, par);
		long long rb = root(b - 1, par);
		if (ra != rb) {
			Ans[i - 1] -= -par[ra] * (-par[rb]);
			par[rb] += par[ra];
			par[ra] = rb;
		}
	}
	for (long long a : Ans) cout << a << endl;
}


Measured memory_bytes: 6428
s=input().rstrip()
ans=[0 for i in range(2019)]
tmp=0
a=1
rs=reversed(s)
for i in rs:
    ans[tmp%2019]+=1
    tmp=(tmp+int(i)*a)%2019
    a*=10
    a%=2019
ans[tmp%2019]+=1
count=0
for i in ans:
    count+=int(i*(i-1)/2)
print(count)

Measured memory_bytes: 68468
#include<bits/stdc++.h>
using namespace std;
string a;
int k,n;
long long dp[102][2][100000];
long long solve(int pos,int tight,int cnt){
	if(cnt>k) return 0;
	if(n==pos) return (cnt==k)?1:0;
	if(dp[pos][tight][cnt]!=-1)	return dp[pos][tight][cnt];
	long long ret=0;
	for(int i=0;i<10;i++){
		if(tight&&i>a[pos]-'0') break;
		int nxt_cnt=cnt+(i>0);
		int nxt_tight=tight&&i==(a[pos]-'0');
		ret+=solve(pos+1,nxt_tight,nxt_cnt);
	}
	return dp[pos][tight][cnt]=ret;
}

int main()
{
	cin>>a>>k;
	n=a.size();
	memset(dp,-1,sizeof(dp));
	cout<<solve(0,1,0);
}


Measured memory_bytes: 159616
/*
ID:dyx_6661
TASK:
LANG:
*/
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
#include<deque>
#include<set>
#include<map>
#include<vector>
#include<iostream>
using namespace std;
typedef long long int ll;
typedef double db;
typedef string str;
typedef pair<int,int> pa;
typedef vector<int> vec;

int k,x;

int main(){
//  freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
    scanf("%d %d",&k,&x);
    for(int i=x-k+1;i<=x+k-1;i++){
    	if(i>=-1000000&&i<=1000000) printf("%d ",i);
	}
	return 0;
}


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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


vector<int> primes;
vector<int> smallest_prime_factor;

int sieve(int nmax){
    primes.clear();
    smallest_prime_factor.assign(nmax+1, 0);

    for (int n=2; n<=nmax; ++n) {
        if (!smallest_prime_factor[n]) {
            primes.push_back(n);
            for (int kn=n; kn<=nmax; kn+=n) {
                if (!smallest_prime_factor[kn]) {
                    smallest_prime_factor[kn] = n;
                }
            }
        }
    }
    return primes.size();
}

vector<int> factorize(int x) {
    vector<int> prime_factors;
    while (x > 1) {
        int s = smallest_prime_factor[x];
        if (!s) break;
        prime_factors.push_back(s);
        x /= s;
    }
    return prime_factors;
}



ll solve(ll N, ll P){
    ll sq = (ll)sqrt(P);
    map<ll,int> el;

    sieve(1000001);
    for (int prime: primes) {
        while (P % (ll)prime == 0LL) {
            el[prime]++;
            P /= (ll)prime;
        }
    }
    if (P != 1) el[P]++;

    ll ans = 1;
    for (auto p: el) {
        int u = p.second / N;
        rep(i,u) ans *= p.first;
    }
    return ans;
}

int main() {
    ll N, P; cin >> N >> P;
    cout << solve(N,P) << endl;
    return 0;
}


Measured memory_bytes: 4732
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  ll a, b;
  cin >> a >> b;
  if(a+b == 15) cout << "+" << endl;
  else if(a*b == 15) cout << "*" << endl;
  else cout << "x" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define re register
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const double PI= acos(-1.0);
const int M = 1e5+7;
/*
int head[M],cnt=1;
void init(int n){cnt=1;for(int i=0;i<=n;i++)head[i]=0;}
struct EDGE{int to,nxt,w;}ee[M*2];
void add(int x,int y,int w){ee[++cnt].nxt=head[x],ee[cnt].w=w,ee[cnt].to=y,head[x]=cnt;}
*/

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	int x;
  	cin>>x;
  	if(x==0)cout<<1<<endl;
  	else cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 3660