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

template <int MOD> struct modnum {
	static_assert(MOD > 0, "MOD must be positive");

private:
	using ll = long long;

	int v;

	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}

public:

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }

	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}

	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}

	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<998244353>;

const int MAXV = 5000;
num fact[MAXV];
num ifact[MAXV];
num pow2[MAXV];

num binom(int n, int r) {
	if (0 <= r && r <= n) {
		return fact[n] * ifact[r] * ifact[n-r];
	} else return 0;
}

void precomp() {
	fact[0] = ifact[0] = 1;
	pow2[0] = 1;
	for (int i = 1; i < MAXV; i++) {
		fact[i] = fact[i-1] * i;
		ifact[i] = ifact[i-1] / i;
		assert(fact[i] * ifact[i] == 1);
		pow2[i] = pow2[i-1] * 2;
	}
}

int main() {
	precomp();
	int K, N; cin >> K >> N;
	for (int i = 0; i <= (K - 1) * 2; i++) {
		int numMid = (i % 2 == 0);
		int numPairs = (min(i, (K - 1) * 2 - i) + 1 - numMid) / 2;
		int numOther = K - numMid - 2 * numPairs;
		// pick the count of each
		num res = 0;
		for (int v = 0; v <= numPairs; v++) {
			res += binom(numPairs, v) * binom(N + numOther - 1, v + numOther - 1) * pow2[v];
		}
		if (numMid) {
			for (int v = 0; v <= numPairs; v++) {
				res += binom(numPairs, v) * binom((N - 1) + numOther - 1, v + numOther - 1) * pow2[v];
			}
		}
		cout << res << '\n';
	}

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int n,m;
  cin>>n>>m;
  set<int> s1;
  rep(i,2,sqrt(m)+1){
    if(m%i==0) s1.insert(i);
    if(m%i==0 && m%(m/i)==0) s1.insert(m/i);
  }
  s1.insert(m);
  s1.insert(1);
  for(auto i:s1){
    if(i>=n){
      cout<<m/i<<endl;
      return;
    }
  }
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3660
#define DEBUG
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
 
#define F first
#define S second 
#define pb push_back
#define endl "\n"

#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }

#ifdef DEBUG
    #define dbg(s) {s;}
#endif

#ifndef DEBUG
    #define dbg(s)
#endif

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int grand(int x) { // from [0, x-1]
    return uniform_int_distribution<int>(0, x - 1)(rng);
}

#define int ll
#define i32 int32_t

#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 

#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;

int getInt () {
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}


ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 

const ll mod = 1e9 + 7;

ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}

const int maxn = 1e6 + 7;

const ll inf = 1e9 + 7;


i32 main() {
    //freopen("<file>.in", "r", stdin);
    //freopen("<file>.out", "w", stdout);

    IOS;
    int m1,d1,m2,d2;
    cin>>m1>>d1>>m2>>d2;

    if(m1==1 && d1==31)
        cout<<1<<endl;
    else if(m1==2 && d1==28)
        cout<<1<<endl;
    else if(m1==3 && d1==31)
        cout<<1<<endl;
    else if(m1==4 && d1==30)
        cout<<1<<endl;

    else if(m1==5 && d1==31)
        cout<<1<<endl;
    else if(m1==6 && d1==30)
        cout<<1<<endl;
    else if(m1==7 && d1==31)
        cout<<1<<endl;
 
    else if(m1==8 && d1==31)
        cout<<1<<endl;
    else if(m1==9 && d1==30)
        cout<<1<<endl;
    else if(m1==10 && d1==31)
        cout<<1<<endl;
    else if(m1==11&& d1==30)
        cout<<1<<endl;
    else if(m1==12&& d1==31)
        cout<<1<<endl;
    else
        cout<<0<<endl;

}





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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

ll N, K;
map<ll, ll> counter;
int main(){
   cin >> N >> K;
   REP(i, N){
      ll a; cin >> a;
      counter[a]++;
   }
   vector<ll> v;
   for(auto &e: counter){
      v.push_back(e.second);
   }
   RSORT(v);
   ll ans = 0;
   REP(i, min(K, (ll)v.size())) ans += v[i];
   ans = N - ans;
   cout << ans << endl;
}


Measured memory_bytes: 14964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    cout << min(b/a, c) << endl;
}


Measured memory_bytes: 256
using System;

namespace Vanila
{
    public class Program
    {
        static void Main(string[] args)
        {
            string[] p = Console.ReadLine().Split(' ');
            int[] c = new int[103];
            for (int i = 0; i < 3; i++)
            {
                c[int.Parse(p[i])]++;
            }
            int ans = 0;
            for (int i = 0; i < 101; i++)
            {
                if (c[i] > 0)
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
        public static long Max(long a, long b)
        {
            if (a <= b) return b;
            else return a;
        }
        public static long Min(long a, long b)
        {
            if (a == Max(a, b)) return b;
            else return a;
        }
        public static long GCD(long a, long b)
        {
            while (Max(a, b) % Min(a, b) != 0)
            {
                if (a < b) b %= a;
                else a %= b;
            }
            return Min(a, b);
        }
        public static long LCM(long a, long b)
        {
            return a * b / GCD(a, b);
        }
    }
}


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

int main() {
    long long x;
    scanf("%lld", &x);// don't forget &
    long long ans = 0;
    long long cur = 100;
    while (cur < x) {
        ans++;
        cur = cur + cur / 100;
    }
    printf("%lld", ans);
    return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> board(h);
  rep(i, h) cin >> board[i];
  vector<int> dx = {1, 1, 1, 0, 0, -1, -1, -1};
  vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};
  
  rep(i, h) rep(j, w) {
    if(board[i][j] == '#') continue;
    int cnt = 0;
    rep(d, 8) {
      int yi = i + dy[d];
      int xj = j + dx[d];
      if(yi < 0 || yi >= h) continue;
      if(xj < 0 || xj >= w) continue;
      if(board[yi][xj] == '#') cnt++;
    }
    board[i][j] = char(cnt + '0');
  }
  
  rep(i, h) cout << board[i] << endl;
  return 0;
}

Measured memory_bytes: 3600
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
/**************************************************************************/
const int N = 1e5+2;
signed main()
{
    fast;
    string s,t;
    cin>>s>>t;
    int l = t.size();
    int n = s.size();
    bool flag = 0;
    string ans ="~";
    //ans.pb((char)123);
    for(int i=0;i<n;i++)
        ans.pb('z');
    for(int i=0;i<=n-l;i++)
    {
        int temp = 1;
        string str = s;
        for(int j=0;j<l;j++)
        {
            if(s[i+j]!=t[j] && s[i+j]!='?')
            {
                temp = 0;
                break;
            }
            str[i+j] = t[j];
        }
        if(temp)
        {
            flag = 1;
            replace(all(str),'?','a');
            ans = min(ans,str);
        }   
    }
    if(flag)
        cout<<ans;
    else cout<<"UNRESTORABLE";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main(){
    int n,k,r,s,p;
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    vector<char> te={'r','s','p'};
    vector<int> pt={p,r,s};
    int ans =0;
    vector<bool> used(n,false);
    for(int i=0; i<n; i++){
        if( i-k<0 || !(i-k>=0&&t.at(i)==t.at(i-k) && used.at(i-k))  ){
            for(int j=0; j<3; j++){
                if(te.at(j)==t.at(i)) ans +=pt.at(j);
            }
            used.at(i)=true;
            //cout<<i<<endl;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define BUFSIZE 1000000

int n;
int d[BUFSIZE]={0};



int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

/*
int compare(int start_p){
  if(p[start_p] < p[start_p + 1] && p[start_p + 1] < p[start_p + 2]
    || p[start_p + 2] < p[start_p + 1] && p[start_p + 1] < p[start_p]){
      return 0;
    }
return 1;
}
*/




int main(void){
  scanf("%d",&n);
  for(int i = 0;i < n;i++){
    scanf("%d",&d[i]);
  }




  qsort(d, n, sizeof(int), compare_int);


  printf("%d",d[n/2] - d[n/2 - 1]);


return 0;



}


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

using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		vector<int> w(n);
		for (int i = 0; i < n; ++i) {
			string s; cin >> s;
			w[i] = s.size();
		}
		int ok[] = { 5,7,5,7,7 };
		for (int i = 0; i < n; ++i) {
			int sum = 0, now = 0, j = 0;
			while (now < 5 && sum < ok[now]) {
				sum += w[i + j++];
				if (sum == ok[now]) now++, sum = 0;
			}
			if (now == 5) {
				cout << i + 1 << endl;
				break;
			}
		}
	}

	return 0;
}


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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {
	ll n;
	cin >> n;

	ll x0 = 0;
	ll y0 = 0;
	ll t0 = 0;
	bool ret = true;
	rep(i, n) {
		ll x, y, t;
		cin >> t >> x >> y;

		ll d = absi(x - x0) + absi(y - y0);
		ll a = t - t0;
		if( ( (d % 2) != (a % 2) ) || (d > a) ) {
			debug(i);
			debug((d % 2) != (a % 2));
			debug(d > a);
			ret = false;
			break;
		}

		x0 = x;
		y0 = y;
		t0 = t;
	}

	YesNo(ret);

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math

s = input()
K = int(input())
dic = []

for i in range(len(s)):
    for j in range(i+1, i+6):
        if s[i:j] not in dic:
            dic.append(s[i:j])
dic.sort()
print(dic[K-1])

Measured memory_bytes: 4064
n = int(input())
a_list = list(map(int, input().split()))

print(' '.join(map(str, a_list)))
for i in range(1, n):
    key = a_list[i]
    j = i - 1
    while j >= 0 and a_list[j] > key:
        a_list[j + 1] = a_list[j]
        j = j - 1
    a_list[j + 1] = key
    print(' '.join(map(str, a_list)))


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

int main() {
    int M; cin >> M;
    long long ans = 0, digit = 0;
    for (int i = 0; i < M; i++)
    {
        long long d, c; cin >> d >> c;
        ans += d * c;
        digit += c;
    }

    cout << digit - 1 + ((ans - 1) / 9) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
string number;

while(1){
cin >> number;
if (number == "0") break;
int a=0,b=0,i;
for(i=0 ;i < number.length(); ++i){
a=number[i]-'0';
b=b+a;
}
cout << b << endl;
}
    return 0;
}

Measured memory_bytes: 1188
while True :
    x, y = map(int, input().split())
    if x == 0 and y == 0 :
        break
    
    ans = 0
    while True :
        if y == 0 :
            break
        if x < y :
            x, y = y, x
        x = x % y
        x, y = y, x
        ans += 1
    
    print(x, ans)
        


Measured memory_bytes: 5608
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPI(i,a) for(typeof((a).begin()) i=(a).begin();i!=(a).end();++i)
#define FOR(i,a,b) for(typeof(a) i=a;i!=(b);++i)
#define CLEAR(a,v) memset(a,v,sizeof(a))
#define SORT(a) sort(a,a+sizeof(a)/sizeof(a[0]))
#define ALL(a) (a).begin(),(a).end()
#define MP make_pair
#define PB push_back
using namespace std;
typedef vector<int> VI;
typedef vector<pair<int,int> > VII;

int main(){
    int N, T;
    cin >> N >> T;
    int minp = 0x7FFFFFFF, maxb = 0;
    int minc = 0, maxc = 0, tminc = 0, ret = 0;
    REP(i,N){
        int p;
        cin >> p;
        if(minp > p){
            ret += min(minc, maxc);
            minc = 1;
            maxc = 0;
            minp = p;
        }else if(minp == p){
            tminc++;
        }
        if(maxb < p - minp){
            ret = 0;
            maxc = 1;
            maxb = p - minp;
        }else if(maxb + minp == p){
            minc += tminc;
            tminc = 0;
            maxc++;
        }
    }
    ret += min(minc, maxc);
    cout << ret << endl;
}

Measured memory_bytes: 256
// abc.078 C - HSI

/////////////////
//まだ
//

#include <bits/stdc++.h>
using namespace std;

#define MOD 1000000007

int main( void ) {
    long long n, m, ans = 0;
    cin >> n >> m;
    ans = ( 1900 * m + ( n - m ) * 100 ) * pow( 2, m );
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);

  if(a>b){
    if(a>c){
      if(b>c){
	printf("%d %d %d\n",c,b,a);
      }else{
	printf("%d %d %d\n",b,c,a);
      }
    }

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

  else if(b>c){
    if(c<a){
      printf("%d %d %d\n",c,a,b);
    }else{
      printf("%d %d %d\n",a,c,b);
    }
  }

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

  
  return 0;
}
  

Measured memory_bytes: 596
n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[0] >= 0:
    print(sum(a) - 2 * a[0])
    x, y = a[0], 0
    for i in range(n - 2):
        x -= y
        y = a[i + 1]
        print(x, y)
    x -= y
    print(a[-1], x)
elif a[-1] <= 0:
    print(-sum(a) + 2 * a[-1])
    x, y = a[-1], 0
    for i in range(n - 1):
        x -= y
        y = a[-(i + 2)]
        print(x, y)
else:
    m = 0
    c = 0
    for i in range(n):
        m += abs(a[i])
        if a[i] <= 0:
            c = i
    print(m)
    x, y = a[0], 0
    for i in range(n - 1, c + 1, -1):
        x -= y
        y = a[i]
        print(x, y)
    x -= y
    print(a[c + 1], x)
    x = a[c + 1] - x
    for i in range(1, c + 1):
        y = a[i]
        print(x, y)
        x -= y

Measured memory_bytes: 21004
N,X=map(int,input().split())
dp={}
def f(n,x):
    if (n,x) in dp:
        return dp[(n,x)]
    elif (n,x)==(0,1):
        return 1
    else:
        if x==1:
            answer=0
            return answer
        elif 2<=x<=2**(n+1)-2:
            answer=f(n-1,x-1)
            return answer
        elif x==2**(n+1)-1:
            answer=f(n-1,2**(n+1)-3)+1
            return answer
        elif 2**(n+1)<=x<=2**(n+2)-4:
            answer=f(n-1,2**(n+1)-3)+f(n-1,x-2**(n+1)+1)+1
            return answer
        else:
            answer=2*f(n-1,2**(n+1)-3)+1
            return answer
print(f(N,X))
            
            


Measured memory_bytes: 38384
import bisect
n = int(input())
l = list(map(int,input().split()))
ls = sorted(l)

count = 0
for i in range(n):
    for j in range(i+1, n):
        index = bisect.bisect_left(ls[j+1:], ls[i] + ls[j])
        count += index
print(count)

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

using namespace __gnu_pbds; 
using namespace std;

using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int 			long long int
#define pll 			pair<ll , ll>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007

ll mod_pow(ll a,ll b) {
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) {
	return mod_pow(a , mod-2);
}

void solve() {
    
    int n;
    
    string s;
    
    cin >> n >> s;
    
    for(int i = 0; i < s.size(); ++i) {
    	s[i] = ('A' + (s[i]-'A' + n) % 26);
    }
    
    cout << s;
}       

signed main() {
    fast;
    
    int t = 1;
    
    //cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


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

public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    String i = sc.next();
    String o = "";
    for(int k = 0; k < i.length(); k++)
    {
      o += "x";
    }
    System.out.println(o);
  }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}

//a,b x
int main(){
	//rep1(i,50) pw2[i]=2*pw2[i-1];
	//rep1(i,18) pw10[i]=10*pw10[i-1];
	ll N,M; cin>>N>>M;
	vector<P> p(N);
	priority_queue<ll> que;
    rep(i,N){
        ll A,B; cin>>A>>B;
        p[i]=mp(A,B);
    }
	sort(p.bg,p.ed);

	ll ans=0,j=0;//添え字
	rep1(i,M){
		while(j<N && p[j].a<=M){
			if(p[j].a==i){
				que.push(p[j].b);
				j++;
			}
			else if(p[j].a>i) break;
		}
		if(!que.empty()){
			ans+=que.top(); que.pop();
		}
	} 
	cout<<ans;
}

Measured memory_bytes: 2936
#pragma comment (linker, "/STACK:256000000")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位


signed main() {
	//小文字repは初期値指定なし #やむどぅめも
	int N, A, B;
	cin >> N >> A >> B;
	cout << min(A, B) << " " << max(0LL, (A + B) -N) << "\n";

	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readInt()
    val a = readIntList()
    val b = readIntList()
    val c = readIntList()

    var ans = 0
    var before = -100
    a.forEach { i ->
        ans += b[i - 1]
        if (i - 1 == before) {
            ans += c[i - 2]
        }
        before = i
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

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

const int M=1e5+5;
const int MO=1e9+7;

inline int add(int x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
	return x;
}
inline int sub(int x,int y)
{
	x-=y;
	if(x<0) x+=MO;
	return x;
}
inline int mul(int x,int y)
{
	return 1LL*x*y%MO;
}

vector<int> g[M];

int dp[M][2]; // dp[][0/1] select or not

void dfs(int u,int fa)
{
	dp[u][0]=dp[u][1]=1;
	for(int v:g[u])
	{
		if(v==fa) continue;
		dfs(v,u);
		dp[u][0]=mul(dp[u][0],add(dp[v][0],dp[v][1]));
		dp[u][1]=mul(dp[u][1],dp[v][0]);
	}
}

int main()
{
	int n; scanf("%d",&n);
	int u,v;
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1,0);
	printf("%d\n",add(dp[1][0],dp[1][1]));
	return 0;
}

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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int e;
	int d=min(c,b);
	if(a<b+c){
	e=b+c-a;
}
else{
	e=0;
}
	cout<<d<<" "<<e<<endl;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

# 4 5 6 0 3 8 7 4 0 0 3 7 0 0 0 32


def lands(l):
    l += [0]
    lands = 0
    for i in range(len(l)):
        if l[i] == 0 and l[i-1] != 0:
            lands += 1
    return lands


def r(h, c):
    c += lands(h)
    # print(c)
    h = list(map(lambda x: x - 1 if x != 0 else 0, h))
    if h == [0] * len(h):
        print(c)
    else:
        r(h, c)


r(h, 0)


Measured memory_bytes: 3188
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll frac[10000000];

ll comb(ll a, ll b) {
  if(a<b) return 0;
  ll ans = frac[a];
  ll sh1, sh2;
  ll two;
  ll h = mod1-2;
  while(h>0) {
    two = 1;
    sh1 = frac[b];
    sh2 = frac[a-b];
    while(2*two<h) {
      two *= 2;
      sh1 *= sh1;
      sh1 %= mod1;
      sh2 *= sh2;
      sh2 %= mod1;
    }
    h -= two;
    ans *= sh1*sh2%mod1;
    ans %= mod1;
  }
  return ans;
}

int main() {
  frac[0] = 1;
  for(ll i=1;i<10000000;++i) frac[i] = frac[i-1]*i%mod1;
  ll N, M;
  cin>>N>>M;
  ll ans = comb(3*M+N-1, N-1);
  for(ll i=2*M+1;i<=3*M;++i) {
    ans = (ans-N*comb(3*M-i+N-2, N-2)%mod1+mod1)%mod1;
  }
  for(ll i=0;i<M;++i) {
    ans = (ans-comb(i+N-1, N-1)*comb(N, 3*M-2*i)%mod1+mod1)%mod1;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 81748
n,m,x,y = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split())) 
set1 = set()
set2 = set()
c = 0
maxa = max(a)
minb = min(b)
if maxa < minb:
  for i in range(maxa+1,minb+1):
    set1.add(i)
if x < y:
  for i in range(x+1,y+1):
    set2.add(i)
set3 = set1 & set2
if len(set3) >= 1:
  print("No War")
else:
  print("War")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rkc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define rfl(i,a,b) for(ll i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define test ll t;cin>>t;while(t--)
#define lld long double
const ll M = 1e9 + 7;
const double pi  =3.141592653589793238463;
int main()
{
    rkc;
    ll a,b,c;
    cin>>a>>b>>c;
    ll arr[11]={0};
    arr[0]=c;
    fl(i,1,11)
    {
        arr[i]=a*arr[i-1]-b;
        cout<<arr[i]<<endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

ll N = 999999999;
string query(ll A) {
	cout << "? " << A << endl;
	string ret;

	//ここにお試し処理
	//string SN = to_string(N);
	//string SA = to_string(A);
	//if (A <= N && SA <= SN) ret = "Y";
	//else if (A > N && SA > SN) ret = "Y";
	//else ret = "N";
	//ce(ret);

	//ここに本番処理
	cin >> ret;

	return ret;
}

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


	//いらないか
	//cin >> N;

	bool A[10] = {};
	ll k = 1;
	ll y = 0;
	rep(i, 10) {
		A[i] = (query(k) == "Y");
		if (A[i]) y = k;
		k *= 10;
	}

	if (y == 1000000000) {
		k = 2;
		rep(i, 10) {
			if (query(k) == "Y") break;
			k *= 10;
		}
		cout << "! " << k / 2 << endl;
	}
	else {
		ll L = y * 10;
		ll R = y * 100;
		while (L + 1 < R) {
			ll M = (L + R) / 2;
			if (query(M) == "Y") R = M;
			else L = M;
		}
		cout << "! " << R / 10 << endl;
	}

	Would you please return 0;
}

Measured memory_bytes: 656
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n, x;
    int i, j, k, count;

    for(;;){
      n = sc.nextInt();
      x = sc.nextInt();
      if(n == 0 && x == 0)break;

      count = 0;
      for(i = 1;i <= n;i++){
        for(j = i + 1;j <= n;j++){
          if(x - i - j > j && x - i - j <= n)count++;
        }
      }

      System.out.println(count);
    }


    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17668
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    

def main():
    N, M = map(int, input().split())
    uni = UnionFind(N + M)
    for i in range(N):
        K, *L = map(int, input().split())
        for l in L:
            uni.union(i, N + l - 1)
    
    root = set()
    for i in range(N):
        root.add(uni.find(i))
    
    if len(root) == 1:
        print('YES')
    else:
        print('NO')



main()

Measured memory_bytes: 66904
S = input()

score = 0
for i in range(len(S)):
    if (i % 2) != int(S[i]):
        score += 1

score2 = 0
for i in range(len(S)):
    if ((i+1) % 2) != int(S[i]):
        score2 += 1

print(min(score,score2))

Measured memory_bytes: 3188
#include<stdio.h>
main(){
int s[9000],n,m,t,f,i;
while(scanf("%d%d",&n,&m),i=t=f=1,n){
	while(i<=n+m){scanf("%d",&s[i]);
		if(i>n)if(t+=s[t+=s[i]],t>=n&f==1)
				printf("%d\n",i-n,f=0);
				i++;
	}
}
	
}

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

int main() {
  int n,m;
  cin>>n>>m;
  int a[m];
  vector<int> b[m];
  rep(i,0,m){
    cin>>a[i];
    int k;
    cin>>k;
    rep(j,0,k){
      int l;
      cin>>l;
      b[i].push_back(l-1);
    }
  }
  int dp[m+1][1<<n];
  rep(i,0,m+1){
    rep(j,0,1<<n){
      dp[i][j]=2e8;
    }
  }
  dp[0][0]=0;
  rep(i,0,m){
    int d=0;
    rep(k,0,b[i].size()) d+=1<<b[i][k];
    rep(j,0,1<<n){
      dp[i+1][j]=min(dp[i][j],dp[i][j&(~d)]+a[i]);
    }
  }
  if(dp[m][(1<<n)-1]==2e8) cout<<-1<<endl;
  else cout<<dp[m][(1<<n)-1]<<endl;
}


Measured memory_bytes: 16384
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



const int MAX_N = 2100;
long long con[MAX_N];
vector<long long> xpl;

long long merge(vector<pair<long long, long long> > rec) {
    map<long long,int> xma;
    xpl.clear();
    for (int i = 0; i < rec.size(); ++i) {
        long long xl = rec[i].first, xr = rec[i].second;
        xma[xl]++; xma[xr]++;
    }
    int nx = 0;
    for(map<long long,int>::iterator it = xma.begin(); it != xma.end(); ++it) {
        it->second = nx++; xpl.push_back(it->first);
    }
    
    memset(con, 0, sizeof(con));
    for (int i = 0; i < rec.size(); ++i) {
        int x1 = xma[rec[i].first], x2 = xma[rec[i].second];
        con[x1]++; con[x2]--;
    }
    for (int i = 0; i < nx; ++i) con[i+1] += con[i];
    
    long long res = 0;
    for (int i = 0; i < nx; ++i) if (con[i] > 0) 
        res += (xpl[i+1]-xpl[i]);
    
    return res;
}

int N, M;
int c, d;

int main() {
    //freopen( "/Users/macuser/Dropbox/Contest/input.in", "r", stdin );
    while (cin >> N >> M) {
        vector<pll> rec;
        for (int i = 0; i < M; ++i) {
            cin >> c >> d;
            rec.PB(pll(c, d));
        }
        long long res = merge(rec);
        cout << res*2 + N+1 << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef pair<int, int> P;

void print_line(vector<int> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;

struct Node {
    ll key;
    Node *left, *right, *parent;
};

class Dict {
    Node *begin = NULL;

public:
    void insert(ll k) {
        Node *y = NULL;
        Node *x = begin;
        Node *z = new Node();


        z->key = k;
        z->parent = NULL;
        z->right = NULL;
        z->left = NULL;

        if (x == NULL) {
            begin = z;
            return;
        }

        while (x != NULL) {
            y = x;
            if (z->key < x->key) {
                x = x->left;
            } else {
                x = x->right;
            }
        }
        z->parent = y;
        if (y == NULL) {
            begin = z;
        } else {
            if (z->key < y->key) {
                y->left = z;
            } else {
                y->right = z;
            }
        }
    };

    void inorder() {
        _inorder(begin);
    }

    void preorder() {
        _preorder(begin);
    }

private:
    void _inorder(Node *node) {
        if (node == NULL) return;
        _inorder(node->left);
        cout << ' ' << node->key;
        _inorder(node->right);
    }

    void _preorder(Node *node) {
        if (node == NULL) return;
        cout << ' ' << node->key;
        _preorder(node->left);
        _preorder(node->right);
    }
};

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

    Dict dict;

    rep(i, n) {
        string command;
        cin >> command;
        if (command == "insert") {
            ll k;
            cin >> k;
            dict.insert(k);
        } else if (command == "print") {
            dict.inorder();
            cout << endl;
            dict.preorder();
            cout << endl;
        }
    }

}




Measured memory_bytes: 26644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string a,b;
    cin >> a >> b;
    reverse(a.begin(), a.end());
    if (a == b)
    {
	    cout << "YES" << endl;
    }
    else
    {
	    cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
void solve(){
  string s;
  cin>>s;
  if(s[0]!='A'){
	   cout<<"WA"<<endl; 
	 }
  else{
	   int cnt=0;
	   for(int i=2;i<(int)s.size()-1;i++)cnt+=s[i]=='C';
	   if(cnt!=1)cout<<"WA"<<endl;
	   else{
		    for(int i=0;i<(int)s.size();i++)
		    if(s[i]!='A' and s[i]!='C'){
			  if(isupper(s[i])){
				   cout<<"WA"<<endl;
				   exit(0);
				 }	
			  }
		cout<<"AC"<<endl; 
		  } 
	 }
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}


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

int main(){
    ll int n,temp,ans = 0;
    cin >> n;
    temp = n;
    while(n!=0){
        ans += n%10;
        n /= 10;
    }
    if(temp % ans == 0){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int X,Y,N,x,y,z,w;
		cin>>X>>Y>>N;
		X=2*X;
		Y=2*Y;
		long a[31][31]={};
		for(int j=2;j<31;j+=2){
			a[j][0]=1;
			a[0][j]=1;
		}
		for(int j=0;j<N;j++){
			cin>>x>>y>>z>>w;
			x=2*x;
			y=2*y;
			z=2*z;
			w=2*w;
			if(x==0&&z==0){
				if((y-w)>0){
					for(int k=y;k<31;k+=2){
						a[k][0]=0;
					}
				}
				else{
					for(int k=w;k<31;k+=2){
						a[k][0]=0;
					}
				}
			}
			else if(y==0&&w==0){
				if((x-z)>0){
					for(int k=x;k<31;k+=2){
						a[0][k]=0;
					}
				}
				else{
					for(int k=z;k<31;k+=2){
						a[0][k]=0;
					}
				}
			}
			else  {
				a[(y+w)/2][(x+z)/2]=-1;
			}
		}
		
		for(int j=2;j<31;j+=2){
			for(int k=2;k<31;k+=2){
				if(a[j-1][k]==0)a[j][k]+=a[j-2][k];
				if(a[j][k-1]==0)a[j][k]+=a[j][k-2];
			}
		}
		if(a[Y][X]!=0)cout<<a[Y][X]<<"\n";
		else cout<<"Miserable Hokusai!\n";
	}
	
	return 0;
}

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

int main(){
    int N;cin>>N;
    vector<int> vec(N),ans(N);
    for(int i=0;i<N;i++)cin>>vec.at(i);
    int i=N-1,j=0;
    while(true){
        ans.at(j)=vec.at(i);
        if(i==0)break;
        i--;
        ans.at(N-j-1)=vec.at(i);
        if(i==0)break;
        i--;j++;
    }
    for(int i=0;i<N;i++){
        if(i)cout<<" ";
        cout<<ans.at(i);
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>

int main()
{
	int x, y;
	while(scanf("%d %d", &x, &y), (x || y))
	{
		if(x < y)
		{
			printf("%d %d\n", x, y);
		}
		else
		{
			printf("%d %d\n", y, x);
		}
	}
	return 0;
}


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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int n;
 
signed main(){
	cin>>n;
	vint a(n),b(n);
	rep(i,0,n){
	    cin>>a[i];
	}
	rep(i,0,n){
	    cin>>b[i];
	}
	int res=0;
	rep(k,1,31){
	    int m=1<<k;
	    vint bb(n);
	    rep(i,0,n){
	        bb[i]=b[i]%m;
	    }
	    sort(all(bb));
	    int cnt=0;
	    rep(i,0,n){
	        int aa=a[i]%m;
	        cnt+=(lower_bound(all(bb),m-aa)-lower_bound(all(bb),m/2-aa))+(lower_bound(all(bb),2*m-aa)-lower_bound(all(bb),3*m/2-aa));
	    }
	    res|=(cnt%2)<<(k-1);
	}
	cout<<res<<endl;
	
	
	
	
	
	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
    int a, b, c;
    vector<int> arr(3);
    cin >> arr[0];
    cin >> arr[1];
    cin >> arr[2];

    sort(arr.begin(), arr.end(), greater<int>());

    int first = arr[0];
    int second = arr[1];
    int third = arr[2];

    int ans = ceil((first - second) / 2.0);
    if ((first - second) % 2 == 1) {
        third++;
    }

    if ((first - third) % 2 == 1) {
        first++;
        ans++;
    }
    ans += ((first - third) / 2);

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

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

struct Dice{
    int q1,q2,q3,q4,q5,q6;
};

int main(){
    Dice d;
    char od;
    
    scanf("%d %d %d %d %d %d", &d.q1, &d.q2, &d.q3, &d.q4, &d.q5, &d.q6);
    
    while(scanf("%c", &od) != EOF){
        if(od=='N'){
            int tmp = d.q1;
            d.q1 = d.q2;
            d.q2 = d.q6;
            d.q6 = d.q5;
            d.q5 = tmp;
        }else if(od=='E'){
            int tmp = d.q1;
            d.q1 = d.q4;
            d.q4 = d.q6;
            d.q6 = d.q3;
            d.q3 = tmp;
        }else if(od=='S'){
            int tmp = d.q1;
            d.q1 = d.q5;
            d.q5 = d.q6;
            d.q6 = d.q2;
            d.q2 = tmp;
        }else if(od=='W'){
            int tmp = d.q1;
            d.q1 = d.q3;
            d.q3 = d.q6;
            d.q6 = d.q4;
            d.q4 = tmp;
        }
    }
    
    printf("%d\n", d.q1);
    
    return 0;
}


Measured memory_bytes: 3220
//
// Created by yamunaku on 2019/12/28.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    ll n,a,b;
    cin >> n >> a >> b;
    if((a+b)%2){
        ll na = n-b+1, nb = n-a+1;
        cout << min((b+(a-1))/2, (nb+(na-1))/2) << endl;
    }else{
        cout << (b-a)/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"sort"
)

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	val, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return val
}


// 長い文字列を読み込む時に使う //
var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
    buf := make([]byte, 0, 1000000)
    for {
        l, p, e := rdr.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}
/////////////////////////////


type Shop struct {
	Cost		int
	Num	int
}

type Shops []Shop

func (ss Shops) Len() int {
	return len(ss)
}

func (ss Shops) Swap(i, j int) {
	ss[i], ss[j] = ss[j], ss[i]
}

func (ss Shops) Less(i, j int) bool {
	return ss[i].Cost < ss[j].Cost
}

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()
	M := nextInt()

	shops := make(Shops, 0)

	for i := 0; i < N; i++ {
		shops = append(shops, Shop{nextInt(), nextInt()})
	}

	sort.Sort(shops)

	total := 0
	num := 0
	for _, shop := range(shops) {
		if shop.Num <= M - num {
			num += shop.Num
			total += shop.Num * shop.Cost
		} else {
			total += (M - num) * shop.Cost
			num = M
			break
		}
	}
	fmt.Println(total)
}

Measured memory_bytes: 8172
import java.io.*;
import java.util.Scanner;

class Main {
	private static int[] mulPerm(int[] a, int[] b, int len) {
		int[] c = new int[len + 1];

		for (int i = 1; i <= len; ++i) {
			c[i] = b[a[i]];
		}
		return c;
	}

	private static int[] powPerm(int[] a, int len, long k) {
		int[] p = new int[len + 1];
		for (int i = 1; i <= len; ++i) {
			p[i] = i;
		}

		while (k > 0) {
			if (k % 2 == 1) {
				p = mulPerm(p, a, len);
			}
			a = mulPerm(a, a, len);
			k /= 2;
		}
		return p;
	}

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

		int n = in.nextInt();

		int[] a = new int[n + 1];
		int[] d = new int[n];

		for (int i = 1; i <= n; ++i) {
			a[i] = in.nextInt();
			if (i > 1) {
				d[i - 1] = a[i] - a[i - 1];
			}
		}

		int m = in.nextInt();
		long k = in.nextLong();

		int[] p = new int[n];
		
		for (int i = 1; i <= n - 1; ++i) {
			p[i] = i;
		}

		for (int i = 1; i <= m; ++i) {
			int index = in.nextInt();

			int tmp = p[index];
			p[index] = p[index - 1];
			p[index - 1] = tmp;
		}

		int[] q = powPerm(p, n - 1, k);

		long cur = a[1];
		for (int i = 1; i <= n - 1; ++i) {
			System.out.println(cur);
			cur += d[q[i]];
		}
		System.out.println(cur);
	}
}


Measured memory_bytes: 81332