akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
    ll N,X,A[100007],C=0;
    cin >> N >> X;
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N-1){
        if(A[i+1]+A[i]>X){
            C+=min((A[i+1]+A[i])-X,A[i+1]);
            A[i+1]-=min((A[i+1]+A[i])-X,A[i+1]);
        }
        if(A[i+1]+A[i]>X){
            C+=(A[i+1]+A[i])-X;
            A[i]-=(A[i+1]+A[i])-X;
        }
    }
    cout << C << endl;
}

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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int H, W;
char grid[10][10];
char tmp[10][10];

int count() {
  int cnt = 0;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (tmp[i][j] == '#') cnt++;
    }
  }
  return cnt;
}

int main() {
  int K;
  cin >> H >> W >> K;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> grid[i][j];
    }
  }

  // 全探索
  int ans = 0;
  for (int i = 0; i < (1 << H); i++) {
    for (int j = 0; j < (1 << W); j++) {
      // copy
      for (int k = 1; k <= H; k++) {
        for (int l = 1; l <= W; l++) {
          tmp[k][l] = grid[k][l];
        }
      }

      // 操作
      for (int k = 0; k < H; k++) {
        if ((i >> k) & 1) {
          for (int l = 1; l <= W; l++) tmp[k+1][l] = '*';
        }
      }
      for (int k = 0; k < W; k++) {
        if ((j >> k) & 1) {
          for (int l = 1; l <= H; l++) tmp[l][k+1] = '*';
        }
      }

      if (count() == K) ans++;
    }
  }

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

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 998244353
#define N 100010
ll po(ll x,ll y){
 ll res=1;
 for(;y;y>>=1){
  if(y&1)res=res*x%mod;
  x=x*x%mod;
 }
 return res;
}
namespace data{
  unordered_map<ll,ll> mas[N];
  void push(ll x,ll y,ll val){
   mas[x][y]=val; 
  }
  ll find(ll x,ll y){
      if(mas[x].find(y)==mas[x].end())return 2;
      return mas[x][y];
  }
};
struct edge{
  ll to,val;  
};
edge medge(ll to,ll val){
 edge gen;gen.to=to,gen.val=val;
 return gen;
}
vector<edge> g[N];
queue<edge> Q;
namespace solve{
    ll n,m;
    ll main(){
        cin>>n>>m;
        ll ans=n*(n-1)/2;
        for(int u=0;u<m;u++){
         ll x,y,val; cin>>x>>y>>val;
          if(abs(x-y)==0){
              Q.push(medge(x,val));   
           }
         else if(data::find(y,x)<2){
             if(abs(x-y)==1){
              g[x].push_back(medge(y,val xor data::find(y,x)));
              g[y].push_back(medge(x,val xor data::find(y,x)));
             }
             if(abs(x-y)==2){
                 Q.push(medge((x+y)/2,val xor data::find(y,x)));
             }
             if(abs(x-y)>=3){
                 if(val xor data::find(y,x))return 0;
             }
             
         }
         else{
          ans--;
          data::push(x,y,val);
         }
        }
        //cout<<ans<<endl;
        ll t[N]; for(int i=1;i<=n;i++)t[i]=2;
        while(!Q.empty()){
         edge cur=Q.front(); Q.pop();
         ll x=cur.to,val=cur.val;
          //cout<<"#"<<x<<" "<<val<<endl;
         if(t[x]==2){
             t[x]=val;
             for(edge y:g[x]){
                 Q.push(medge(y.to,val xor y.val));
             }
         }
         else{
          if(t[x]!=val)return 0;   
         }
        }
        ll mi=0;
        for(int i=1;i<=n;i++){
         if(t[i]==2){
             ans++;
            mi+=g[i].size();
         }
        }
        ans-=mi/2; //cout<<ans<<endl;
        return po(2,ans);
    }
};

int main(){
 cout<<solve::main()<<endl;
 return 0;   
}


Measured memory_bytes: 11904
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
auto sum(deque<int>deq){
    int res = 0;
    for(int i = 1; i < deq.size();++i) res += abs(deq[i] - deq[i-1]);
    return res;
}

auto cal(vector<int>v){
    deque<int>deq,res;
    for(auto e : v) deq.push_back(e);
    res.push_front(deq.front());
    deq.pop_front();
    int idx = 0;
    while(deq.size() != 0){
        if(deq.size() == 1){
            if(abs(res.front() - deq.front()) > abs(res.back() - deq.front()))
                res.push_front(deq.front());
            else
                res.push_back(deq.front());
            deq.pop_back();
        } else {
            if(idx % 2 == 0){
                res.push_back(deq.back());
                deq.pop_back();
                res.push_front(deq.back());
                deq.pop_back();
            } else {
                res.push_back(deq.front());
                deq.pop_front();
                res.push_front(deq.front());
                deq.pop_front();
            }
        }
        ++idx;
    }
    return sum(res);
}
signed main(){
    int n; cin  >> n;
    vector<int>v(n);
    for(auto &e : v) cin >> e;
    vector<int> u = v;
    sort(all(v));
    sort(all(u),greater<>());
    cout << max(cal(v),cal(u)) << endl;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define space putchar(' ')
#define enter putchar('\n')
#define mp make_pair
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {putchar('-');x = -x;}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N;
int dp[55][105],inv[55],invfac[55],fac[55];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
int C(int n,int m) {
    if(n < m) return 0;
    return mul(fac[n],mul(invfac[m],invfac[n - m]));
}
void update(int &x,int y) {
    x = inc(x,y);
}
void Solve() {
    read(N);
    inv[1] = 1;
    for(int i = 2 ; i <= N ; ++i) inv[i] = mul(inv[MOD % i],MOD - MOD / i);
    fac[0] = invfac[0] = 1;
    for(int i = 1 ; i <= N ; ++i) {
	fac[i] = mul(fac[i - 1],i);
	invfac[i] = mul(invfac[i - 1],inv[i]);
    }
    dp[1][N] = 1;
    dp[1][N - 1] = 1;
    for(int i = 1 ; i <= N ; ++i) {
	for(int j = -i ; j <= i ; ++j) {
	    for(int k = max(1,abs(j)) ; k <= N ; ++k) {
		if(i + k > N) break;
		for(int h = 0 ; h <= k ; ++h) {
		    if((j + 2 * h - k) % 2) continue;
		    int val = (j + 2 * h - k) / 2;
		    if(val < -N || val > N) continue;
		    update(dp[i + k][val + N],mul(dp[i][j + N],mul(C(i + k,k),C(k,h))));
		}
	    }
	}
    }
    out(dp[N][N]);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main() {
	int A,B,C,D;
	
	cin >> A >> B >> C >> D;
	
	int x=0,y=0;
	
	if(A < B){
		x = A;
	}else{
		x = B;
	}
	
	if(C < D){
		y = C;
	}else{
		y = D;
	}
	
	cout << x+y << endl;
	
	return 0;
}


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

int su[200001];
long long sum[200001];

long long abs_(int x){
    if(x < 0) return -x;
    else return x;
}
int n;

long long doo(int i, int ll, int rr){
    long long mx  = max({(sum[i] - sum[ll]), sum[ll], (sum[n] - sum[rr]), (sum[rr] - sum[i])});
    long long mn  = min({(sum[i] - sum[ll]), sum[ll], (sum[n] - sum[rr]), (sum[rr] - sum[i])});
    return mx - mn;
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld",&sum[i]);
        sum[i] += sum[i-1];
    }
    int ll = 1, rr = 3;
    long long ans = 1000000000000000000LL;
    for(int i=2;i<=n-2;i++){
        while(2 * sum[ll+1] <= sum[i]) ll++;
        while(2 * (sum[rr+1] - sum[i]) <= sum[n] - sum[i]) rr++;
        ans = min(ans, min({doo(i, ll, rr), doo(i,ll+1, rr), doo(i, ll, rr+1), doo(i, ll+1, rr+1)}));
        //printf("%d %d %d %lld\n", i, ll, rr, min({doo(i, ll, rr), doo(i,ll+1, rr), doo(i, ll, rr+1), doo(i, ll+1, rr+1)}));
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner scan = new Scanner(System.in);
		boolean result= false;
		int items= scan.nextInt();
		int popItems= scan.nextInt();
		int[] votes= new int[items];
		int count=0;
		for(int i=0; i<items; i++) {
			votes[i]= scan.nextInt();
			count+= votes[i];
		}
		int comp= (int)Math.ceil((1/(4*(double)popItems))*count);
		
		int finalCount=0;
		for(int i=0; i<votes.length; i++) {
			if(votes[i]>=comp) {
				finalCount++;
				if(finalCount>=popItems) {
					result= true;
					break;
				}
			}
		}
		if(result) {
			System.out.print("Yes");
		}else {
			System.out.print("No");
		}
	}
}

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

bool is_kaibun(string S)
{
  int len = S.size();
  bool ans = true;
  for (int i = 0; i < len/2; i++)
  {
    if (S.at(i) != S.at(len-1-i))
    {
      ans = false;
      break;
    }
  }
  return ans;
}

int main()
{
  string S;
  cin >> S;
  bool ans = is_kaibun(S);
  if (ans)
  {
    ans = is_kaibun(S.substr(0, S.size()/2));
    if (ans)
    {
      ans = is_kaibun(S.substr(S.size()/2+1, S.size()/2));
    }
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,t;
	cin>>n>>t;
	int maxv=-1e9;
	int minv=t;
	for(int i=1;i<n;++i){
		cin>>t;
		maxv=max(maxv,t-minv);
		minv=min(minv,t); 
	}
	cout<<maxv<<endl; 
	return 0;
} 


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

int main()
{
  ios::sync_with_stdio(false);
  int a, b, t, p = 0;
  cin >> a >> b >> t;

  for (int i = a; i <= t + 0.5 && a <= t + 0.5; i += a)
  {
    p += b;
  }

  cout << p << "\n";
  return 0;
}

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

int n;

int main()
{
	cin>>n;
  	if(n%2==0)
    {
      	cout<<"0.500000000";
      	return 0;
    }
  	else
    {
      	cout<<fixed<<setprecision(8)<<1.0*(n/2+1)/n;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>

using namespace std;
int main(){
  int r,d,x,x1=0;
  cin >> r >> d >> x;
  for(int i=0;i<10; i++){
    x1 = r*x - d;
    x = x1;
    cout << x1 << endl;
  }
}


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

int main() {
    int N;
    cin >> N;
    vector<int> a(N), b(N);
    for(int i=0; i<N; ++i) cin >> a[i];
    for(int j=0; j<N; ++j) cin >> b[j];

    int res = 0;
    for(int k=0; k<29; ++k) {
        vector<int> A(N), B(N);
        int mask = (1 << (k + 1)) - 1;
        for(int i=0; i<N; ++i) {
            A[i] = a[i] & mask;
            B[i] = b[i] & mask;
        }
        sort(begin(B), end(B));

        int cnt = 0;
        for(int i=0; i<N; ++i) {
            if(A[i] <= (1 << k)) {
                cnt += lower_bound(begin(B), end(B), (1 << (k + 1)) - A[i])
                        - lower_bound(begin(B), end(B), (1 << k) - A[i]);
            } else {
                cnt += lower_bound(begin(B), end(B), (1 << (k + 1)) - A[i]) - begin(B);
                cnt += end(B) - lower_bound(begin(B), end(B), (1 << k) + (1 << (k + 1)) - A[i]);
            }
            cnt %= 2;
        }

        if(cnt) res += (1 << k);
    }
    
    cout << res << endl;
}

Measured memory_bytes: 3432
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
    long long a,n;
    scanf("%lld",&n);
    a=1;  
    for (long long i=1;i<=n;i++) 
     a=a*i%1000000007; 
    printf("%lld",a);
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

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

	ll N, M;
	ll ans = 0;

	cin >> N >> M;

	vector<pair<ll,ll>> key;
	rep(i, M) {
		ll a, b, c, tmp;
		cin >> a >> b;
		c = 0;
		rep(j, b) {
			cin >> tmp;
			c |= (ll)1 << (tmp-1);
		}
		key.emplace_back(c, a);
	}

	vector<ll> dp(1 << N, INF);
	dp[0] = 0;

	rep(i, 1<<N) {
		rep(j, M) {
			ll t = i | key[j].first;
			ll cost = dp[i] + key[j].second;
			dp[t] = min(dp[t], cost);
		}
	}

	ans = dp.back();
	if (ans == INF) ans = -1;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
#include <iostream>    /*atcoder 60*/
using namespace std;
int main(void){
    int a,b,c;
    cin >>a >>b >>c;
    
    int i;
    for(i=0;i<=b;i++){
        if(a*i%b==c){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout <<"NO"<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 100010


int main() {
	vector<long long>a, b;
	long long pre[N];
	long long ans[N];
	priority_queue<pair<long long, long long> >pq;
	long long m,n;
	long long x, y, z, s;
	scanf("%lld %lld",&m, &n);
  a.push_back(m);
	f(i, n) {
		scanf("%lld", &x);
		a.push_back(x);
	}
	b.push_back(a[n]);
	for (long long i = n - 1; i >= 0; i--) {
		if (a[i] < b[b.size() - 1])b.push_back(a[i]);
	}
	s = b[0];
	f(i, b.size()) {
		if (!pq.empty()) {
			for(;;) {
				x = pq.top().first;
				if (x <= b[i])break;
				y = pq.top().second;
				z = ((x-1) / b[i])*b[i];
				s += (z*y);
				pq.pop();
				pq.push(make_pair(x - z, y));
			}
		}
		x = b[i];
		y = s / b[i];
		pq.push(make_pair(x, y));
		s = 0;
	}
	f(i, N) {
		pre[i] = 0;
		ans[i] = 0;
	}
	while (!pq.empty()) {
		x = pq.top().first;
		y = pq.top().second;
		pre[x] += y;
		pq.pop();
	}
	for (long long i = m; i >= 1; i--) {
		ans[i] = ans[i + 1] + pre[i];
	}
	for (long long i = 1; i <= m; i++)printf("%lld\n", ans[i]);


	return 0;
}

Measured memory_bytes: 6512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <list>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    string s;
    cin >> s;

    string ans;
    for(int i=0;i<s.size();i++){
        for(int j=i;j<s.size();j++){
            ans=s.substr(0,i)+s.substr(j,s.size()-j);
            if(ans=="keyence"){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
from itertools import combinations

N = int(input())

k = N // 2
s = N + 1 - N % 2
print(N * (N - 1) // 2 - k)
for p in combinations(range(1, N + 1), 2):
    if sum(p) == s:
        continue
    print(p[0], p[1])



Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N;
	cin >> N;
	vector<int> botton(N);
  
  	for(int i=0;i<N;i++){
     cin >> botton.at(i);    
    }
  
  	int light = 1, cnt;
  	for(int i=0;i<N;i++){
      light = botton.at(light - 1);
      cnt++;
      if(light == 2)
        break; 
    }
  
  	if(light == 2){
      cout << cnt << endl;
    }else {
      cout << -1 << endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	int ans = 0, mn = 1001;
	rep(i, n){
		int in;
		cin >> in;
		ans += in;
		if(in % 10 != 0){
			mn = min(mn, in);
		}
	}
	if(ans % 10 == 0){
		if(mn == 1001) ans = 0;
		else ans -= mn;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import sys

read= sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 1000000007
sys.setrecursionlimit(10**7)

#N,*A = map(int,read().split())
N = int(input())
l = list(map(int,input().split()))

#最初の状態分を加算するため、1からカウント
ans = 1

S = 0 #現在の状態 増加 or 減少 or 初期化

for i in range(1,N):
    X = l[i] - l[i-1]

    X = 0 if X == 0 else 1 if X > 0 else -1

    #同じ値の時l[i] == l[i-1]
    if X == 0:
        continue

    #Stateが初期のときは現在の状態に更新
    elif S == 0:
        S = X

    #Stateが違うときは答えに加算して、Stateを初期値に
    elif S != X:
        ans += 1
        S = 0

print(ans)


Measured memory_bytes: 14484
#include <bits/stdc++.h>
using namespace std;
const int N=2e6+10;

int main()
{
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
	int l,r,x,ans=0;
	cin>>l>>r>>x;
	for(int i=l;i<=r;i++)
	{

		if(i%x==0)ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 3660
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var list = new List<int>();
            string s;
            while ((s = Console.ReadLine()) != null)
            {
                var d = int.Parse(s);
                list.Add(d);
            }
            list.Sort();
            var dict = new Dictionary<int, int>();
            for (int i = 0; i < 100; i++) { dict.Add(i + 1, 0); }
            foreach (var v in list)
            {
                var r = dict[v];
                dict.Remove(v);
                dict.Add(v, ++r);
            }
            var k = dict.Keys;
            var sl = 0;
            var rlist = new List<int>();
            foreach (var v in k)
            {
                if (dict[v] > sl) { rlist.Clear(); }
                if (dict[v] >= sl) { rlist.Add(v); sl = dict[v]; }
            }
            foreach (var va in rlist)
            {
                Console.WriteLine(va);
            }
        }
    }
}

Measured memory_bytes: 12364
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <string>
using namespace std;
const int maxn = 1e3;
int check(int n)
{
    int num[10];
    memset(num,0,sizeof(num));
    int ant = 0;
    while(n)
    {
        num[ant++] = n%10;
        n/=10;
    }
    int Max = 1;
    int cnt = 1;
    for(int i = 1;i < 4;i++)
    {
        if(num[i] == num[i-1])
        {
            cnt++;
            Max = max(Max,cnt);
        }
        else cnt = 1;
    }
    return Max;
}
int main()
{
    int n;
    while(cin >> n)
    {
        int cnt = check(n);
        if(cnt >= 3) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#define pai 3.1415926535

int main(void) {
	int N;
	scanf("%d", &N);
	char u[4];
	double x[10];
	double sum = 0.0;
	for (int i = 0; i < N; i++) {
		scanf("%lf", &x[i]);
		scanf("%s", u);
		if (strcmp(u,"BTC")==0) {
			sum += 380000.0*x[i];
		}
		else {
			sum += x[i];
		}
	}
	printf("%f", sum);


	return 0;
}




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

int main() {
  int n;
  cin >> n;
  bool ok = true;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    if(a % 2) ok = false;
  }
  
  if(ok) cout << "second" << endl;
  else cout << "first" << endl;
}

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

int main(void)
{
    long long N;
    cin >> N;

    vector<long long> a(N + 1);
    for (long long i = 1; i < N + 1; i++)
    {
        cin >> a[i];
    }
    vector<long long> ans(N+1);
    long long M = 0;
    for (long long i = N; i > 0; i--)
    {
        long long sum = 0;
        for (long long j = 2; j <= N / i; j++)
        {
            sum += ans[i * j];
        }
        ans[i] = abs((sum % 2) - a[i]);
        if (ans[i] == 1)
        {
            M++;
        }
    }
    cout << M << endl;
    if (M !=0)
    {
        for (long long i = 1; i < N+1; i++)
        {
            if (ans[i] == 1)
            {
                cout << i << " ";
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 3968
N,K=map(int,input().split())
cnt=0
A=[0]*(N)

for i in range(N):
  cnt=0
  p=i+1
  for j in range(17):
    if p<K:
      p*=2
      cnt+=1
      if p>=K:
        A[i]=cnt
        break

ans=0
for i in A:
    ans+=(1/N)*((0.5)**i)
    
print(ans) 

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define SZ(x) ((int)x.size())
#define debug puts("lyhtsdy")
#define rep(i, l, r) for (int i = l; i < r; i++)
#define _rep(i, l, r) for (int i = l; i <= r; i++)
#define _per(i, r, l) for (int i = r; i >= l; i--)
#define per(i, r, l) for (int i = r - 1; i >= l; i--)
#define FO(x) freopen(#x".in", "r", stdin);freopen(#x".out", "w", stdout);
typedef double db;
typedef __int128 li;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> pii;
constexpr ll MOD = 998244353;
constexpr int Mod = 998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
constexpr int N = 1e6 + 7;
int ch[N][26], tot, tag[N];
void insert(string s) {
  int now = 0;
  for (char c : s) {
    if (!ch[now][c - 'a'])
      ch[now][c - 'a'] = ++tot;
    now = ch[now][c - 'a'];
  }
  ++tag[now];
}
int n, cnt[26];
ll ans;
string a[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  rep(i, 0, n) {
    cin >> a[i];
    reverse(a[i].begin(), a[i].end());
    insert(a[i]);
  }
  rep(i, 0, n) {
    for (char c : a[i])
      ++cnt[c - 'a'];
    int now = 0;
    for (char c : a[i]) {
      rep(i, 0, 26)
        if (tag[ch[now][i]] && cnt[i])
          ++ans;
      --cnt[c - 'a'];
      now = ch[now][c - 'a'];
    }
  }
  cout << ans - n << endl;
  return 0;
}


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

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> a(H,vector<char>(W));
  rep(i,H){
    rep(j,W){
      cin >> a.at(i).at(j);
    }
  }
  rep(i,W+2){
    cout << '#';
  }
  cout << endl;
  rep(i,H){
    cout << '#';
    rep(j,W){
      cout << a.at(i).at(j);
    }
    cout << '#' << endl;
  }
  rep(i,W+2){
    cout << '#';
  }
}


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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long a, b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b));
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n)
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); --i)
#define FROMTO(i,f,t)       for(int i = f; i < t; i++)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define FILL(m,v)           memset(m, v, sizeof(m))
#define mp                  make_pair
#define pb                  push_back
template<class _T> _T MAX(_T p1,_T p2){return (p1>p2)?p1:p2;} 
template<class _T> _T MIN(_T p1,_T p2){return (p1<p2)?p1:p2;} 

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)

#ifdef _DEBUG
template<class _T>
inline void _prfe(const char *_n, _T _c, bool _p = false){
    ITER(_c) _it=_c.begin();
    if(_p){ cout<<_n<<" = ["<<endl;for(;_it!=_c.end();++_it)cout<<"    "<<*_it<<endl;cout<<"]"<<endl; }
    else{ cout<<_n<<" = [ "<<*_it++;for(;_it!=_c.end();++_it)cout<<", "<<*_it;cout<<" ]"<<endl; }
}
#define pf printf
#define pr(n) do{cout<<#n" = "<<(n)<<endl;}while(0)
#define prfe(n) _prfe(#n, n)
#define prfep(n) _prfe(#n, n, true)
#define dbgchk(n) do{if(n)throw;}while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#define prfe(...) /* */
#define prfep(...) /* */
#define dbgchk(...) /* */
#endif

int main(){
    int a[3], n, m;
    while(1){
        cin >> a[0] >> a[1] >> a[2];
        if(a[0] == 0 && a[1] == 0 && a[2] == 0) break;
        sort(a,a+3);
        cin >> n;
        double l1 = a[0]/2.0, l2 = a[1]/2.0;
        double r = sqrt(l1*l1+l2*l2);
        REP(i,n){
            cin >> m;
            puts((m > r)?"OK":"NA");
        }
    }

    return 0;
}

Measured memory_bytes: 1132
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

// dp[i][smaller]: 左から i 桁目まで見たときの最大値
ll dp[50][2];
const int same = 0;
const int smaller = 1;

int main(){
	ll n; ll k; cin >> n >> k;
	vector<ll> a(n);
	for( auto &i : a ) cin >> i;
	bool flag = false;
	if( k == 0 ){
		cout << accumulate( a.begin(), a.end(), 0ll ) << endl;
		return 0;
	}
	for( int d = 0; d <= 42; ++d ){
		ll mask = (1ll<<(42-d));
		ll cnt = 0;
		for( auto &i : a ) if( i & mask ) ++cnt;
		// すでに smaller な場合は好きに桁を選ぶ
		if( dp[d][smaller] > 0 || dp[d][same] > 0 ){
			dp[d+1][smaller] = dp[d][smaller] + max(cnt, n-cnt)*mask;
		}
		// d 桁目に 1 が立っているとき，same から smaller に遷移できる
		if( k & mask ){
			dp[d+1][smaller] = max(dp[d+1][smaller], dp[d][same] + cnt*mask);
		}
		// same のとき，d 桁目を見て判断
		dp[d+1][same] = dp[d][same] + ( ( k & mask ) ? (n-cnt) : (cnt) ) * mask;
	}
	cout << max(dp[43][same], dp[43][smaller]) << endl;
	return 0;
}

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

const ll INF = 1LL << 60;

ll N, K;
vector<ll> A;

int main() {
    cin >> N >> K;
    A.resize(N);

    bool visited[N];
    rep(i, N) {
        cin >> A[i];
        A[i]--;
        visited[i] = false;
    }

    // UnionFind uf = UnionFind(N);
    ll prev = 0;
    vector<ll> v;
    v.push_back(0);
    visited[0] = true;

    ll move = 0;
    ll last_prev = 0;
    ll last_dest = 0;

    rep(i, N) {
        // cout << prev << " " << A[prev] << endl;
        move++;
        if (visited[A[prev]]) {
            last_prev = prev;
            last_dest = A[prev];
            break;
        }
        visited[A[prev]] = true;

        v.push_back(A[prev]);
        prev = A[prev];
    }

    // cout << last_prev << endl;
    // cout << last_dest << endl;

    // //  K でわる
    // ll idx = K % num.size();
    ll last_prev_idx = std::find(v.begin(), v.end(), last_prev) - v.begin();
    // cout << last_prev_idx << endl;

    ll last_dest_idx = std::find(v.begin(), v.end(), last_dest) - v.begin();
    // cout << last_dest_idx << endl;
    // circle の長さ
    ll circl_dist = last_prev_idx - last_dest_idx + 1;

    if (K <= last_prev_idx) {
        cout << v[K] + 1 << endl;
        return 0;
    }

    ll rest = K - last_prev_idx;

    // cout << rest << " " << circl_dist << endl;
    ll mod = rest % circl_dist; 
    if (mod == 0) {
        cout << v[last_prev_idx] + 1 << endl;
        return 0;
    }

    // cout << mod << endl;
    ll target_idx = last_dest_idx + mod - 1;
    cout << v[target_idx] + 1 << endl;
    // cout << mod << endl;
    // cout << rest << endl;
    // rep(i, v.size()) {
    //     cout << v[i] << " ";
    // }
    // if (last_prev + 1 >= K) {
    //     cout << v[K] + 1 << endl;
    // }
}

Measured memory_bytes: 7128
#include <iostream>
#include <fstream>
#include <map>
#include <vector>

#define NMAX 502
#define MOD 1000000007
#define f cin


using namespace std;

//ifstream f("text3.in");
ofstream g("text3.out");

long long int dp[NMAX][NMAX];

long long int n;
long long int v[NMAX], l[NMAX];

long long int get_sum(long long int st, long long int dr) {

    if (st == 0) {
        return l[dr];
    }
    return l[dr] - l[st - 1];

}

int main() {
    f >> n;
    for (long long int i = 0; i < n; ++i) {
        f >> v[i];
        if (i == 0) l[i] = v[i];
        else l[i] = (l[i - 1] + v[i]);
    }

    for (long long int dist = 1; dist < n; ++dist) {
        for (int i = 0; i + dist < n; ++i) {
            long long int vmin = 1e17;
            for (long long int k = i; k < i + dist; ++k) {
                vmin = min(vmin, dp[i][k] + dp[k + 1][i + dist] + get_sum(i, k) + get_sum(k + 1, i + dist) );
            }
            dp[i][i + dist] = vmin;
        }
    }

    cout << dp[0][n - 1];

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

int main(void)
{
    int a, b, c;

    cin >> a >> b >> c;

    if(a*c<=b){
        cout << c << endl;
    }

    else{
        cout << b/a << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string.h>
using namespace std;
char s[105];
int  judge(int a, int b)
{
	for (int i = a; i <= a + (b - a) / 2; i++)
	{
		if (s[i] != s[b - (i - a)])
		{
			return 0;
		}
	}
	return 1;
}
int main()
{
	cin >> s;
	int l = strlen(s);
	if (judge(0, (l - 1) / 2 - 1) == 1 && judge((l + 3) / 2 - 1, l - 1) == 1&&judge(0,l-1)==1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <vector>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <ctime>
#include <fstream>
#include <stdarg.h>
using namespace std;
const bool debug=false;
const bool INJUDGE=false;
#define FASTERCIN cin.tie(0);ios_base::sync_with_stdio(false)
typedef long long ll;
const ll mod=998244353ll;
/*Time:
Status:
Type:
Author:*/
ll k;
ll n,a,b;
ll ans;
ll res[300005];
ll modp(ll aa,ll bb) {
	if(bb==0ll) return 1ll;
	ll ans2=modp(aa,bb/2ll);
	ans2*=ans2;
	if(bb%2ll==1ll) {
		return ans2%mod*aa%mod;
	} else {
		return ans2%mod;
	}
}

ll inv(ll aa) {
	return modp(aa,mod-2ll);
}
int main() {
	cin>>n>>a>>b>>k;
	res[0]=1ll;
	ll t=n;
	for(ll i=1; i<=n; ++i) {
		res[i]=t*inv(i)%mod;
		res[i]*=res[i-1];
		res[i]%=mod;
		--t;
	}
	//cout<<"nnaa"<<endl;
	for(ll i=0; i<=n; i++) {
		///cout<<ans<<endl;
		ll k1=a*ll(i);
		//	cout<<ans<<endl;
		ll k2=k-k1;
		//	cout<<ans<<endl;
		if(k1>k)break;
		//	cout<<ans<<endl;
		if(k2%b)continue;
		//	cout<<ans<<endl;
		ll nnaa=k2/b;
		//	cout<<ans<<" "<<nnaa<<endl;
		if(nnaa>n)continue;
		ans+=res[i]*res[nnaa];
		//	cout<<ans<<endl;
		ans%=mod;
		//	cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2688
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        int c1 = h * w % 2;
        int c2 = h % 2 * w / 2 + w % 2 * h / 2;
        int c4 = (h * w - c2 * 2 - c1) / 4;

        int[] count = new int[26];
        for (int i = 0; i < h; i++) {
            for (char c : scanner.next().toCharArray()) {
                count[c - 'a']++;
            }
        }

        for (int i : count) {
            int j = Math.min(c4, i / 4);
            c4 -= j;
            i -= j * 4;

            j = Math.min(c2, i / 2);
            c2 -= j;
            i -= j * 2;

            c1 -= i;
        }
        System.out.println(c1 == 0 && c2 == 0 && c4 == 0 ? "Yes" : "No");
    }
}

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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back

using namespace std;

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

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

inline void proc_status()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) <<endl;
}

template <typename T> T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

const int Maxn = 1e5 + 100;

int A[Maxn][5], Dp[Maxn][5];

int N;

inline void Solve ()
{
	int ans = 0;
	for (int i = 1; i <= N; ++i)
	{
		for (int j = 1; j <= 3; ++j)
		{
			for (int k = 1; k <= 3; ++k)
				if (j != k)
					Chkmax(Dp[i][j], Dp[i - 1][k] + A[i][j]);
			if (i == N) Chkmax(ans, Dp[N][j]);
		}
	}
	cout<<ans<<endl;
}

inline void Input ()
{
	N = read<int>();
	for (int i = 1; i <= N; ++i) for (int j = 1; j <= 3; ++j) A[i][j] = read<int>();
}

int main()
{
#ifdef hk_cnyali
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
#endif
	Input();
	Solve();
	return 0;
}


Measured memory_bytes: 4096
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Modified: <14/Jul/2019 06:12:00 PM>


#    ✪ H4WK3yE乡
#    Mohd. Farhan Tahir
#    Indian Institute Of Information Technology (IIIT), Gwalior


import sys
import os
from io import IOBase, BytesIO


def main():
    n = int(input())
    arr = get_array()
    c = 0
    for i in range(n):
        c = c ^ arr[i]
    if c == 0:
        print('Yes')
    else:
        print('No')


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        py2 = round(0.5)
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2 == 1:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def get_array(): return list(map(int, sys.stdin.readline().split()))


def get_ints(): return map(int, sys.stdin.readline().split())


def input(): return sys.stdin.readline().strip()


if __name__ == "__main__":
    main()


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

int const N = 20, M = 190, md = 1e9 + 7;
pair<int, int> dp[1 << N - 1];
int edm[M], nn[M + 2][M + 2], fr[1 << N - 1];
vector<pair<int, int> > tr[N + 1];

inline void ad(int &x, int y) { if ((x += y) >= md)x -= md; }
inline int bc(int x){
	int an = 0;
	while (x){
		++an;
		x ^= x & -x;
	}
	return an;
}

int ta;
int go(int v, int p = 0){
	if (v == ta)return 0;
	f(i, 0, tr[v].size()){
		int u = tr[v][i].first, id = tr[v][i].second;
		if (u == p)continue;
		int t = go(u, v);
		if (t == -1)continue;
		return t | 1 << id;
	}
	return -1;
}

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	f(i, 1, m + 2){
		nn[i][i] = i;
		f(j, i + 1, m + 2)nn[i][j] = (ll)nn[i][j - 1] * j % md;
	}
	f(i, 0, m){
		int a, b;
		scanf("%d%d", &a, &b);
		if (i < n - 1){
			tr[a].push_back(make_pair(b, i));
			tr[b].push_back(make_pair(a, i));
		}else {
			ta = b;
			edm[i] = go(a);
		}
	}
	f(i, n - 1, m)++fr[(1 << n - 1) - 1 ^ edm[i]];
	f(i, 0, n - 1)f(j, 0, 1 << n - 1)if (j >> i & 1)fr[j ^ 1 << i] += fr[j];
	f(i, 0, 1 << n - 1)fr[i] = m - (n - 1) - fr[i];
	dp[0] = make_pair(1, 0);
	f(i, 0, 1 << n - 1)f(j, 0, n - 1)if (!(i >> j & 1)){
		int b = bc(i), n = b + fr[i], c = dp[i].first, s = dp[i].second, ni = i | 1 << j, k = fr[ni] - fr[i];
		if (k){
			c = (ll)c * nn[n + 1][n + k] % md;
			s = (ll)s * nn[n + 2][n + 1 + k] % md;
		}
		ad(s, (ll)(b + 1) * c % md);
		ad(dp[ni].first, c);
		ad(dp[ni].second, s);
	}
	printf("%d\n", dp[(1 << n - 1) - 1].second);
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            var array = s.ToCharArray();
            for (int i = 0; i < s.Length; i++)
            {
                int number = (int)array[i];
                number += n;
                if (number > 'Z')
                {
                    number -= 26;
                }
                array[i] = (char)number;
            }
            Console.WriteLine(array);

        }
    }
}


Measured memory_bytes: 11144
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
# define mp make_pair
# define x first
# define y second
using namespace std;
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; }

int main() {
  int n, m; cin >> n >> m;
  vector<int> k(m);
  vector<vector<int>> s(m, vector<int>(0));
  rep(i, m){
    cin >> k[i];
    rep(j, k[i]){
      int a; cin >> a;
      a--;
      s[i].pb(a);
    }
  }
  vector<int> p(m);
  rep(i, m) cin >> p[i];

  int ans = 0;

  for(int i = 0; i < (1 << n); i++){
    bool flag = true;
    rep(j, m){
      int t = 0;
      rep(h, k[j]){
        if(i & (1 << (s[j][h]))) t++;
      }
      if(t%2 != p[j]) flag = false;
    }
    if(flag) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

int main() {
	string s;
	cin >> s;
	cout <<
		(find(find(s.begin(), s.end(), 'C'), s.end(), 'F') != s.end() ? "Yes" : "No")
		<< endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;

int main(void) 
{
    int a, b;
    double f;
    cin >> a >> b;
    printf("%d %d %.10lf\n", a/b, a%b, (double) a/(double)b);

//    cout << (a/b) << " " << (a%b) << " " << ((double)a/(double)b) << endl;

}



Measured memory_bytes: 3220
N,W = map(int,input().split())
INF = 10**9+7
NV = (10**3)*N
dp = [[INF for j in range(NV+1)] for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    w,v = map(int,input().split())
    for j in range(NV+1):
        if j < v:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-v]+w)
ans = 0
for j in range(NV+1):
    if dp[N][j] <= W:
        ans = j
print(ans)


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

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	if ((n-m) > 0)
		cout << "No" << "\n";
	else
		cout << "Yes" << "\n";
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (unsigned long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (unsigned long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end())
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 (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール
constexpr ll p = 1000000007ll;
constexpr int GENOM_EMPTY = 0;
constexpr int GENOM_A = 1;
constexpr int GENOM_T = 2;
constexpr int GENOM_G = 3;
constexpr int GENOM_C = 4;

// 処理内容
int main() {
    
    ll n;
    cin >> n;

    vector<vector<ll>> dp(n+1, vector<ll>(125, 0));

    REP(i, 125) dp[0][i] = 1;

    RANGE(i, 0, n-1) {
        int jend;
        switch (i) {
            case 0: jend = 1; break;
            case 1: jend = 5; break;
            case 2: jend = 25; break;
            default: jend = 125; break;
        }
        REP(j, jend) {
            int pre3 = j / 25;
            int pre2 = (j % 25) / 5;
            int pre1 = j % 5;
            int next = (j % 25) * 5;
            dp[i+1][next + GENOM_A] += dp[i][j];
            dp[i+1][next + GENOM_A] %= p;
            dp[i+1][next + GENOM_T] += dp[i][j];
            dp[i+1][next + GENOM_T] %= p;
            if (!(
                pre2 == GENOM_A &&
                pre1 == GENOM_C
            )) {
                dp[i+1][next + GENOM_G] += dp[i][j];
                dp[i+1][next + GENOM_G] %= p;
            }
            if (!(
                pre2 == GENOM_G &&
                pre1 == GENOM_A
            ) && !(
                pre2 == GENOM_A &&
                pre1 == GENOM_G
            ) && !(
                pre3 == GENOM_A &&
                pre2 != GENOM_EMPTY &&
                pre1 == GENOM_G
            ) && !(
                pre3 == GENOM_A &&
                pre2 == GENOM_G &&
                pre1 != GENOM_EMPTY
            )) {
                dp[i+1][next + GENOM_C] += dp[i][j];
                dp[i+1][next + GENOM_C] %= p;
            }
        }
    }

    ll ans = 0;
    REP(j, 125) {
        ans += dp[n][j];
        ans %= p;
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define pii pair<ll,ll>
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

ll gcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

bool find_any_solution(ll a, ll b, ll c, ll &x0, ll &y0, ll &g) {
    g = gcd(abs(a), abs(b), x0, y0);
    if (c % g) {
        return false;
    }

    x0 *= c / g;
    y0 *= c / g;
    if (a < 0) x0 = -x0;
    if (b < 0) y0 = -y0;
    return true;
}

ll get(ll a, ll b, ll c)
{
    a++;
    ll sig = 1;
    if(a<0)
        sig*=(-1);
    a = abs(a); 
    ll c1 = a/c, c2 = b/c;
    ll r1 = a%c, r2 = b%c;
    
    ll mo = (r1*r2)%c;
    ll temp (c1*c2*c + c1*r2 + c2*r1 + (r1*r2)/c);
    
    if(sig == -1)
        return (-temp);
    if(mo == 0)
        return temp;
    return temp+1;    
}

int main()
{
  FAST/**/
   
   ll n;
   cin>>n;
   
   n*=2;
   
   vector<ll> fac;
   ll lim = sqrt(n);
   for(ll i=1;i<=lim;i++)
   {
       if(n%i == 0)
       {
           fac.pb(i);
           if(i != n/i) 
                fac.pb(n/i);
       }
   }
   
   ll ans = 2*n-1;
   
   autoit(fac,it)
   {
       ll g1 = *it;
       ll g2 = (n/(*it));
       
       ll g = __gcd(g1,g2);
       
       if(g!=1)
            continue;
       ll x0,y0;
       find_any_solution(g1,g2,1,x0,y0,g);
       
       //cout<<x0<<" "<<y0<<" "<<g1<<" "<<g2<<" ";
       
       ll coeff = get(y0,g,g1);
       ld n1 = x0 + coeff*(g2/g);
       ld n2 = y0 - coeff*(g1/g);
      // cout<<n1<<" "<<n2<<"\n";
       n2*=(-1);
       if((n2*(ld)g2)>(2*n-1))
            continue;
       ans = min(ans, (ll)n2*g2);
       
   }
   cout<<ans;
   
   
   return 0;        
}  

  
          
   

Measured memory_bytes: 3804