akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

int64_t Compute(const std::vector<int> &arr, const bool flag)
{
    int sign = flag ? +1 : -1;
    int64_t sum = 0;
    int64_t count = 0;
    for (size_t i = 0; i < arr.size(); ++i)
    {
        sum += arr[i];
        if (sum == 0)
        {
            ++count;
            sum = sign;
        }
        else if (sum * sign > 0)
        {
            // 条件を満たす
        }
        else
        {
            // 条件を満たさない
            count += abs(sum) + 1;
            sum = sign;
        }
        sign *= -1;
    }

    return count;
}

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> arr(n);
    for (int i = 0; i < n; ++i)
    {
        int tmp;
        std::cin >> tmp;
        arr[i] = tmp;
    }

    const auto count = std::min(Compute(arr, true), Compute(arr, false));
    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 3752
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

double ans = 0,P,E,T;
int K;

void recursive(double R,double L,double probability,int count){

	if(L < T-E || R > T+E)return;

	if(count == K){
		if(fabs(T-(R+L)/2.0) <= E){
			ans += probability;
		}
		return;
	}

	double H = (R+L)/2.0;

	double right_R,right_L,wrong_R,wrong_L;

	if(H > T){

		right_R = R,right_L = H;
		recursive(right_R,right_L,probability*(1-P),count+1);

		wrong_R = H,wrong_L = L;
		recursive(wrong_R,wrong_L,probability*P,count+1);

	}else{

		right_R = H,right_L = L;
		recursive(right_R,right_L,probability*(1-P),count+1);

		wrong_R = R,wrong_L = H;
		recursive(wrong_R,wrong_L,probability*P,count+1);
	}
}

int main(){

	double first_R,first_L;

	scanf("%d %lf %lf",&K,&first_R,&first_L);
	scanf("%lf",&P);
	scanf("%lf",&E);
	scanf("%lf",&T);

	recursive(first_R,first_L,1.0,0);

	printf("%.6lf\n",ans);

	return 0;
}

Measured memory_bytes: 2744
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a, b, k; cin >> a >> b >> k;
    ll tmp = a - k;
    if (tmp<0) {
        ll tmp1 = k - a;
        cout << 0 << " " << max(b - tmp1, 0ll) << endl;
    } else {
        cout << tmp << " " << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from collections import deque
N,M=list(map(int,input().split()))
AB=[set() for i in range(N+1)]
room=[0]*(N+1)
pre=[None]*(N+1)
def bfs(i):#１に到達
    Done=set()
    Done.add(i)
    d=deque([i])
    # child=set()
    # child.add(i)
    # count=1
    while(d):
        k=d.popleft()
        # if k not in child:
        #     count+=1
        #     child=child.union(Done)
        # room[k]=count
        for i in AB[k]:
            if i not in Done:
                pre[i]=k
                Done.add(i)
                d.append(i)





for i in range(M):
    A,B=list(map(int,input().split()))
    AB[A].add(B)
    AB[B].add(A)

flag=True
bfs(1)
if pre.count(None)<=N+1:
    for i in range(2,N+1):
        if flag:
            print("Yes")
            flag=False
        if pre[i] is not None:
            print(pre[i])
else:print("No")


Measured memory_bytes: 69596
#include<iostream>
    #include <algorithm>
    using namespace std;
    int main(){
        long i, j, N;
        cin >> N;
        long dp[N];
        for(i=0; i<=N; i++){
            dp[i] = i; 
        }
        for(i=1; i<=N; i++){
            for(j=1; j<=i; j*=6){
                dp[i] = min(dp[i], dp[i-j]+1);
            }
            for(j=1; j<=i; j*=9){
                dp[i] = min(dp[i], dp[i-j]+1);
            }
        }
        cout << dp[N] <<'\n';
        return 0;
    }

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

typedef pair<int,int> pr;
int main(){
  int n,w;
  cin>>n>>w;

  vector<pr> p(n+1);
  int i;
  for(i=1;i<=n;i++){
    int a,b;
    cin>>a>>b;
    p.at(i).first=a;
    p.at(i).second=b;
  }

  int j;
  int ma=0;
  vector<vector<int>> dp(n+1,vector<int>(w+1,0));
  for(i=1;i<=n;i++){
    for(j=0;j<=w;j++){
      if(j-p.at(i).second<0){
        dp.at(i).at(j)=dp.at(i-1).at(j);
      }else{
        int a,b;
        a=dp.at(i-1).at(j);
        b=dp.at(i-1).at(j-p.at(i).second)+p.at(i).first;
        dp.at(i).at(j)=max(a,b);
      }
    }
  }

  cout<<dp.at(n).at(w)<<endl;

}



Measured memory_bytes: 6816
#include <bits/stdc++.h>
#define ll long long int
#define v vector<ll>
#define vv vector<v>
using namespace std;
ll MOD=1e9+7;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vv matrix(n+1,v(n+1,0));
    for (int i=1; i<=n; i++)
        for (int j=1; j<=n; j++)
            cin>>matrix[i][j];
    ll bits=(1<<(n+1))+1;
    vv dp(n+1,v(bits,0));
    dp[0][0]=1;
    for (int i=1; i<=n; i++)
        for (int j=1; j<bits; j++)
        {
            if (__builtin_popcount(j)!=i)
                continue;
            for (int k=1; k<=n; k++)
            {
                if (((j & (1<<k))!=0) && matrix[i][k]==1)
                    dp[i][j]=(dp[i][j]+dp[i-1][j^(1<<k)])%MOD;
            }
        }
    cout<<dp[n][bits-3];
	return 0;
}

Measured memory_bytes: 754048
import numpy as np
N = int(input())
S = [[ord(i) for i in input()] * 2 for _ in range(N)]
S = np.array(S)

ans = 0
for i in range(N):
    tmp = S[:, i: i + N]
    if (tmp == tmp.T).all():
        ans += 1

ans = ans * N
print(ans)


Measured memory_bytes: 15252
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n+10];
    long long sumf=0,suml=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sumf+=a[i];
    }
    if(n<=k)
        cout<<"0"<<endl;
    else
    {
    sort(a,a+n);
    for(int i=n-k;i<n;i++)
        suml+=a[i];
    cout<<sumf-suml<<endl;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MAXN 100005
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(c) (c).begin(), (c).end()
using namespace std;

int n, h[MAXN];

/*void print(int arr[MAXN][MAXN], int r, int s) {
	 for (int i = 0; i < r; ++i) {
		 for (int j = 0; j < s; j++) {
			 cout << arr[i][j] << " ";
		 }
		 cout << "\n";
	 }
}
*/
int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	for (int i = n - 2; i > -1; --i) {
		if (h[i + 1] < h[i]) h[i]--;
	}
	bool sol = true;
	int m = h[0];
	if (m <= 0) sol = false;
	for (int i = 1; i < n; i++) {
		if (h[i] > m) m = h[i];
		if (h[i] < m) {sol = false; break;}
	}
	if (sol) cout << "Yes";
	else cout << "No";	
	return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  set<int> st;
  map<int, int> mp;
  int ans = 0;
  for (int i = 0; i < m; i++) {
    int p;
    string s;
    cin >> p >> s;
    if (s == "AC") {
      st.insert(p);
    } else if (!st.count(p)) {
      mp[p]++;
    }
  }
  for (auto& x : st) {
    ans += mp[x];
  }
  cout << (int) st.size() << ' ' << ans << '\n';
  return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  cin >> A;
  int B=0,C=0;
  
  for(int i=1;i<=A;i += 2){
    //B=0;
   for(int j=1;j<=i;j++){
     if(i%j==0){B++;}
   }
    if(B==8){C++;}
    B=0;
  }
  cout << C << endl;
}

Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		
		Scanner in = new Scanner(System.in);
		
		String S = in.next();
		for(int i = 0; i < S.length() - 1; i++){
			char c = S.charAt(i);
			for(int j = i + 1; j < S.length(); j++){
				if(S.charAt(j) == c){
					System.out.println("no");
					return;
				}
			}
		}
		
		System.out.println("yes");
	}
}


Measured memory_bytes: 22868
import sys

N=int(input())
if N==3:
    print(61)
    sys.exit()
#dp[n][i][j][k]
dp=[[[[0 for i in range(4)] for i in range(4)] for i in range(4)] for i in range(N+1)]
A=0;G=1;C=2;T=3;
mod=10**9+7
dp[0][3][3][3]=1
def check(i,j,k,l):
    if i==A and k==G and l==C:
        return 0
    if j==A and k==G and l==C:
        return 0
    if j==G and k==A and l==C:
        return 0
    if j==A and k==C and l==G:
        return 0
    if i==A and j==G and l==C:
        return 0
    else:
        return 1

for n in range(1,N+1):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                for l in range(4):
                    if check(i,j,k,l):
                        dp[n][j][k][l]+=dp[n-1][i][j][k]
                        dp[n][j][k][l]%=mod
ans=0
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans+= dp[N][i][j][k]
            ans%= mod
print(ans)

Measured memory_bytes: 49520
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N;
	cin >> N;
	ll mi= 999,an=0;
	rep(i, N) {
		ll s;
		cin >> s;
		an += s;
		if (s % 10 != 0) {
			mi = min(s, mi);
		}
	}
	if (an % 10 != 0) {
		cout << an << endl;
	}
	else if (mi != 999) {
		cout << an - mi << endl;
	}
	else {
		cout << 0 << endl;
	}

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int x;
    int rate;

    do {
        scanf("%d", &x);
    } while(x < 400 || 2000 <= x);
    
    if (400 <= x && x < 600) {
        rate = 8;
    }
    else if (600 <= x && x < 800) {
        rate = 7;
    }
    else if (800 <= x && x < 1000) {
        rate = 6;
    }
    else if (1000 <= x && x < 1200) {
        rate = 5;
    }
    else if (1200 <= x && x < 1400) {
        rate = 4;
        
    }
    else if (1400 <= x && x < 1600) {
        rate = 3;
    }
    else if (1600 <= x && x < 1800) {
        rate = 2;
        
    }
    else {
        rate = 1;
    }
    
    printf("%d\n", rate);
    return 0;
}


Measured memory_bytes: 1704
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	vec a={111,222,333,444,555,666,777,888,999};
	cout<<*lower_bound(all(a),read())<<endl;
	return 0;
}



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

using namespace std;

int N;
int K;
vector<int> A;

bool ans;

int main()
{
	cin >> N >> K;
	
	ans = false;
	for (int i = 0; i < N; i++){
		int buf;
		
		cin >> buf;
		
		A.push_back(buf);
		if (!ans && buf >= K){
			ans = true;
		}
	}
	
	int gcd = A[0];
	for (int n : A){
		int a, b;
		
		if (n > gcd){
			a = n;
			b = gcd;
		} else {
			a = gcd;
			b = n;
		}
		
		while (a % b > 0){
			int buf = a % b;
			a = b;
			b = buf;
		}
		gcd = b;
	}
	
	ans &= (K % gcd == 0);
	
	if (ans){
		cout << "POSSIBLE" << endl;
	} else {
		cout << "IMPOSSIBLE" << endl;
	}
	
	return 0;
}


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

int main(void){
  while(1){
    int stone[50];
    for(int k = 0 ; k < 50 ; k++){stone[k] = 0;}

    int bowl;
    int n, p;  // n：候補者人数，p：小石の総数
    cin >> n;
    cin >> p;

    if(n == 0 && p == 0){return 0;}

    bowl = p;

    bool flg = true;
    int ans;

    for(int i = 0 ; flg ; i = (i+1) % n){

      if(bowl == 0){
        bowl = bowl + stone[i];
        stone[i] = 0;
      }else{
        stone[i]++;
        bowl--;
        if(bowl == 0 && stone[i] == p){ans = i; flg = false;}
      }
    }
    cout << ans << endl;
  }
}
                                         


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n, d;
        cin >> n >> d;
        d *= 2;
        d += 1;
        cout << n / d + (n % d != 0) << '\n';
    }
}

Measured memory_bytes: 31488
// inputに入力データ全体が入る
function Main(input) {
  chars = input.split("");
  	
  	//入力が全て同じ文字だったらNoを返す
	if(chars[0] == chars[1] && chars[0] == chars[2] && chars[0] == chars[3]){
       console.log("No");
	}else{
      //chars[i]は後から変わるので、先に定数として定義
      var letter = chars[0];
      
      //最初のアルファベットをまず消す
      chars.splice(0,1);
      var replaced = input.replace(letter, '');
      var search = replaced.search(letter);

      //最初のアルファベットと同じやつがないか探して、あったら消す
      chars.splice(search,1);
      replaced = replaced.replace(letter, '');
      search = replaced.search(letter);

      //残りの２文字が一緒だったらYes、一緒じゃない場合はNo
      if(chars[0] == chars [1]) 
        console.log("Yes");
      else console.log("No");
    }
}
  
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

set<int> primes;
const int MAX = 1000;
const int MOD = 1e9 + 7;

void compute_primes()
{
    primes.insert(2);
    for (int i=3; i<=MAX; i++) {
        bool is_prime = true;
        for (int j=2; j*j<=i; j++) {
            if (i % j == 0) {
                is_prime=false;
                break;
            }
        }
        if (is_prime) {
            primes.insert(i);
        }
    }
}

vector<int> factor(int n)
{
    vector<int> res(1001);
    for (auto p : primes) {
        while (n % p == 0) {
            res[p]++;
            n /= p;
        }
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(false);
    compute_primes();
    // for (auto i : primes) cout << i << endl;

    ll N; cin >> N;

    vector<int> factors(1001);
    for (int i=2; i<=N; i++) {
        vector<int> tmp = factor(i);
        rep(j, 1001) factors[j] += tmp[j];
    }

    ll ans = 1LL;
    for (auto n : factors) {
        if (n > 0) {
            ans *= (n + 1);
            ans %= MOD;
        }
    }
    cout << ans << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> isPair;
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
#define Pll pair<ll,ll>
#define vpll vector<pll>
#define sll set<ll>
#define mll map<ll,ll>

const ll oo=1e18;
const ll maxs = 3e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
#define mp make_pair
#define I insert
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define LB lower_bound
#define UB upper_bound
#define line() cout<<endl;
#define fr(i,a,b) for(int i=a;i<=b;++i)
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fastio(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mst(x,a) memset(x,a,sizeof(x))

ll fact[maxs];

ll fast(ll x,ll y)
{
    ll res = 1;
    while(y)
    {
        if(y&1)
            res  = (res*x)%mod;
            
        y>>=1;
        x = (x*x)%mod;
    }
    return res;
}


int main() 
{
    fastio();
    fact[0] = 1;
    for(ll i=1;i<maxs;i++)
        fact[i] = (fact[i-1]*i)%mod;
	ll t=1;
    //cin>>t;
    while(t--){
        ll n , a , b;
        cin>>n>>a>>b;
        a = min(a,n-a);
        b = min(b,n-b);
        ll A = a;
        ll B = b;
        ll ANS = fast(2,n);
        ANS -= 1;
        if(ANS < 0 )
            ANS += mod;
        
        ll num=1;
        ll tmp = n;
        while(a)
        {
            num = (num*tmp)%mod;
            tmp--;
            a--;
        }
        num = (num*fast(fact[A] , mod-2))%mod;
        
        ANS -= num;
        
        if(ANS < 0)
            ANS += mod;
            
        num=1;
        tmp = n;
        while(b)
        {
            num = (num*tmp)%mod;
            tmp--;
            b--;
        }
        num = (num*fast(fact[B] , mod-2))%mod;
        
        ANS -= num;
        
        if(ANS < 0)
            ANS += mod;
        
        cout << ANS << endl;
            
    }  
    return 0;
}

Measured memory_bytes: 2560
def F(x, t, ans):
    if t != 0:
        if x < 2**t:
            ans += '0'
            t -= 1
            return F(x, t, ans)
        else:
            x_n = x - 2**t + 1
            if x_n % 2 == 1:
                ans += '1'
                t -= 1
                return F(x_n - 1, t, ans)
            else:
                ans += '0'
                t -= 1
                return F(x_n - 1, t, ans)
    else:
        return ans

a,b = [int(_) for _ in input().split()]
t1 = F(a-1, 39, '')
ex = (a-1) % 4
if ex == 0:
    t1 += '0'
elif ex == 1:
    t1 += '1'
elif ex == 2:
    t1 += '1'
elif ex == 3:
    t1 += '0'
t2 = F(b, 39, '')
ex = b % 4
if ex == 0:
    t2 += '0'
elif ex == 1:
    t2 += '1'
elif ex == 2:
    t2 += '1'
elif ex == 3:
    t2 += '0'
print(int(t1, 2) ^ int(t2, 2))

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


i64 N;
string Str;

void solve() {
  i64 s = 0;

  i64 l, r;
  for (i64 i = 0; i < pow(2, N - 1); i++) {
    l = 0, r = 0;
    while (l < N) {
      while (r <= (N - 1) && (i & (1 << r)) == 0) {
        r++;
      }
      r++;
      s += stoll(Str.substr(l, r - l));
      l = r;
    }
  }

  cout << s << endl;
}

int main() {
  cin >> Str;
  N = Str.length();

  solve();

  return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  for(int i=0;i<s.length();i++){
    if(s[i]!=t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int n, x, y;

template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int dist(int a, int b) {
    int ans = INT_MAX;
    chmin(ans, abs(a - b));
    chmin(ans, abs(a - x) + 1 + abs(y - b));
    chmin(ans, abs(a - y) + 1 + abs(x - b));
    return ans;
}

int main() {
    cin >> n >> x >> y;
    x--, y--;
    vector<int> ans(n);
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            ans[dist(i, j)]++;
        }
    }
    for (int i = 1; i < n; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  struct node *left;
  struct node *right;
  struct node *parent;
  int key;
};
struct node *T;
void Insert(int);
void Inorder(struct node*);
void Preorder(struct node*);
int main(){
  int n, i, key;
  char func[6];
  T = (struct node *)malloc(sizeof(struct node) * 1);
  T->parent = T->left = T->right = NULL;
  T->key = -1;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%s",&func);
    if(strcmp(func,"insert") == 0){
      scanf("%d",&key);
      Insert(key);
    }
    else if(strcmp(func,"print") == 0){
      Inorder(T);
      printf("\n");
      Preorder(T);
      printf("\n");
    }
  }
  return 0;
}

void Inorder(struct node* X){
  if(X != NULL){
    Inorder(X->left);
    printf(" %d",X->key);
    Inorder(X->right);
  }
}

void Preorder(struct node* X){
  if(X != NULL){
    printf(" %d",X->key);
    Preorder(X->left);
    Preorder(X->right);
  }
}

void Insert(int key){
  struct node *x, *y, *S;
  if(T->key == -1){
    T->key = key;
    return;
  }
  S = (struct node *)malloc(sizeof(struct node) * 1);
  S->key = key;
  S->parent = S->left = S->right = NULL;
  x = T;
  while(x != NULL){
    y = x;
    if(key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  S->parent = y;
  //if(y == NULL){
  //  T = S;
  //  free(S);
  //}
  if(S->key < y->key)
    y->left = S;
  else
    y->right = S;
}

Measured memory_bytes: 24040
#include<stdio.h>
int main(void)
{
	int i,j,n,x,m[10000],sum,a,w,k,cnt;
	scanf("%d %d",&n,&x);
	for(i=0;i<n;i++){
		scanf("%d",&m[i]);
	}
	sum=0;
	a=0;
	cnt=n;
	for(i=0;i<n;i++){
		sum+=m[i];
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(m[i]>m[j]){
				a=m[i];
				m[i]=m[j];
				m[j]=a;
			}
		}
	}
	w=x-sum;
	if(w<m[0]){
		printf("%d\n",n);
	}
	else{
		k=w/m[0];
		printf("%d\n",cnt+k);
	}
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
        cin >> a[i];
    int ans = 1000000000;
    for (int i = -100; i <= 100; i++) {
        int sum = 0;
        for (int j = 0; j < N; j++) {
            sum += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma region atcoder
/*#include <atcoder/dsu>
using namespace atcoder;*/
#pragma endregion
#pragma region macros
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n - 1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#pragma endregion
#pragma region debug for var, v, vv
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){cout << endl;int cnt = 0;for(const auto& v : vv){cout << cnt << "th : "; view(v); cnt++;} cout << endl;}
#pragma endregion
const ll mod = 1000000007;
const int inf = 1001001001;
const ll INF = 1001001001001001001;
const int MAX = 2000005;
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; }
ll modpow(ll a, ll p){ll ret = 1; while(p){if(p & 1){ret = ret * a % mod;} a = a * a % mod; p >>= 1;} return ret;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

/*-----------------------------------------------------------------------------------------------------*/
int main(){
    int n; cin >> n;
    ll a, b; cin >> a >> b;
    a -= b;
    vl h(n);
    rep(i,n) cin >> h[i];
    ll ok = (ll)1e9 + 1, ng = 0;
    while(ok - ng > 1){
        ll mid = (ok + ng) / 2;
        auto f = [&](){
            ll num = 0;
            vl res = h;
            for(int i = 0; i < n; i++) res[i] -= b * mid;
            for(int i = 0; i < n; i++){
                if(res[i] > 0) num += (res[i] + a - 1) / a;
            }
            if(num <= mid) return true;
            else return false;
        };
        if(f()) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

Measured memory_bytes: 4824
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(ll (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
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; }

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

    int n;
    cin >> n;
    vector<double> a(n);
    FOR(i, 0, n)cin >> a[i];
    SORT(a);
    pair<ll, ll> ans = { LLINF,LLINF };
    FOR(i, 0, n) {
        if (a[i] == a[n - 1])continue;
        chmin(ans, { abs(a[n - 1] / 2 - a[i]),i });
    }
    cout << (int)a[n - 1] << " " << (int)a[ans.second] << "\n";
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int sum = 0;
        for (int i = 0; i < 5; i++) {
            sum += Integer.parseInt(sc.next());
        }

        System.out.println(15 - sum);
        sc.close();
    }
}


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

int main() {
  string O, E;
  cin >> O >> E;
  int len = O.size();
  
  string S = O+E;
  if (E.size() == len){
    for (int i=0; i<len; i++) {
      S.at(2*i) = O.at(i);
      S.at(2*i+1) = E.at(i);
    }
  }
  else{
    for (int i=0; i<len-1; i++) {
      S.at(2*i) = O.at(i);
      S.at(2*i+1) = E.at(i);
    }
    int i=len-1;
    S.at(2*i) = O.at(i);
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <math.h>
using namespace std;

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

int main() {
  int N, K; cin >> N >> K;
  vector<int> l(N);
  for (int i = 0; i < N; i++) cin >> l[i];
  sort(l.begin(), l.end());
  int ans = 0;
  for (int i = N - 1; i >= N - K; i--) ans += l[i];
  cout << ans << endl;
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
#define allsortg(v)sort(v.begin(),v.end(),greater<int>());
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int H, W, N;
	cin >> H >> W >> N;
	vector<int>a(N);
	rep(i, N)cin >> a[i];
	int c[100][100];
	int x = 0;
	rep(i, H) {
		rep(j, W) {
			while (1) {
				if (a[x] == 0)x++;
				else break;
			}
			c[i][j] = x + 1;
			a[x]--;
		}
		i++;
		if (i == H)break;
		rep(j, W) {
			while (1) {
				if (a[x] == 0)x++;
				else break;
			}
			c[i][W-1-j] = x + 1;
			a[x]--;
		}
	}
	rep(i, H) {
		rep(j, W)cout << c[i][j]<<" ";
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int x,y,s;
	while(1) {
	scanf("%d %d",&x,&y);
		if(x==0&&y==0)break;
		if(x>y){
			s=x;
			x=y;
			y=s;
		}
	printf("%d %d\n",x,y);
	}
	
	return 0;
}

Measured memory_bytes: 2560
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
#include "bitset"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string t;
    cin >> t;
    int N = t.size();
    rep(0, i, N)
    {
        if (t.at(i) == '?')
        {
            t.at(i) = 'D';
        }
    }
    cout << t << endl;
}

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

#define int long long

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

int N, X;
int ans = 0;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    ans += (a - a % b) * 2;
    return gcd(b, a % b);
}

signed main() {
    cin >> N >> X;
    if (X < N - X) {
        ans -= gcd(N - X, X);
    } else {
        ans -= gcd(X, N - X);
    }
    ans += N;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
map<ll,vpll> adj;
map<ll,int> d,color;
void dijkstra(ll st){
	priority_queue<pll> PQ;//辺の長さのオーバーフローに注意！
	d[st]=0;
	color[st]=1;
	PQ.push(mp(0,st));
	while(!PQ.empty()){
		pll f=PQ.top();
		PQ.pop();
		ll u=f.second;
		color[u]=2;
		if(d[u]< -f.first) continue;
		rep(j,adj[u].size()){
			ll v=adj[u][j].first;
			if(color[v]==2) continue;
			if(d[v]>d[u]+adj[u][j].second){
				d[v]=d[u]+adj[u][j].second;
				PQ.push(mp(-d[v],v));
				color[v]=1;
			}
		}
	}
}
int main(){
	ll N,M;
	scan(N>>M);
	set<int> starail[100001];
	rep(i,M){
		int p,q,c;
		scan(p>>q>>c);
		p--; q--; c--;
		adj[p+N*c].push_back({q+N*c,0});
		adj[q+N*c].push_back({p+N*c,0});
		starail[p].insert(c);
		starail[q].insert(c);
		d[p+N*c]=INF;
		d[q+N*c]=INF;
	}
	rep(i,N){
		d[i+N*1000000]=INF;
		if(!starail[i].empty()){
			for(auto c:starail[i]){
				adj[i+N*1000000].push_back({i+N*c,0});
				adj[i+N*c].push_back({i+N*1000000,1});
			}
		}
	}
	dijkstra(N*1000000);
	/*for(auto x:d){
		printf("%lld : %d\n",x.first+1,x.second);
	}*/
	if(d[N-1+N*1000000]!=INF) prin(d[N-1+N*1000000]);
	else prin(-1);

	return 0;
}


Measured memory_bytes: 167408
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/


void solve(){
  int test;
  //cin>>test;
  test=1;
  while(test--){
        string s,t;
        cin>>s>>t;
        int n,m;
        cin>>n>>m;
        string x;
        cin>>x;
        
        if(x==s)
        n--;
        else
        m--;
        cout<<n<<" "<<m;    
  }         
}    

    




///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}





Measured memory_bytes: 256
#ABC065C
import math
N,M=map(int,input().split())
if abs(N-M)>=2:
	print(0)
elif N<M or M<N:
	print(math.factorial(N)*math.factorial(M)%(10**9+7))
else:
	print(math.factorial(N)*math.factorial(M)*2%(10**9+7))

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

typedef long long  LL;
int n,a[100010];
LL l,r;

void work()
{
	scanf("%d",&n);
	for (int i=1; i<=n; i++)  scanf("%d",&a[i]);
	l=r=2;
	for (int i=n; i; i--)
		{
			l=(l+a[i]-1)/a[i],r=r/a[i];
			if (l>r)  puts("-1"),exit(0);
			l*=a[i],r*=a[i],r+=a[i]-1;
		}
	printf("%lld %lld\n",l,r);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 640
grid_condition = input().split()
height = int(grid_condition[0])
width = int(grid_condition[1])
color_variety = int(input())
input_condition = input().split()

list_in_list = list()

for i in range(height):
    list_in_list.append(list())

pointer = 0
number = 1

for i in range(1, color_variety + 1):
    times = int(input_condition[i-1])
    for j in range(times):
        list_in_list[pointer].append(i)
        if len(list_in_list[pointer]) == width:
            pointer += 1


for i in range(len(list_in_list)):
    t = ''
    if i%2 == 1:
        list_in_list[i].sort(reverse=True)
    for j in list_in_list[i]:
        t = t + str(j) + " "
    print(t)


Measured memory_bytes: 3564
import java.util.Scanner;

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

		long a = sc.nextLong();
		long v = sc.nextLong();
		long b = sc.nextLong();
		long w = sc.nextLong();
		long t = sc.nextLong();

		if (Math.abs(a - b) <= (v - w) * t) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int num;
    cin >> num;
    int mm = num / 100;
    int yy = num % 100;
    //cout << yy << endl;
    if((1 <= mm && mm <= 12) && (yy >= 1 && yy <= 12)){
        cout << "AMBIGUOUS" << endl;
    }
    else if(1 <= yy && yy <= 12){
        cout << "YYMM" << endl;
    }
    else if(1 <= mm && mm <= 12){
        cout << "MMYY" << endl;
    }
    else{
        cout << "NA" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;    
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int n;
    cin>>n>>s;
    rep(i,s.size()){
      reps(j,n){
	if(s[i]=='Z') s[i]='A';
	else s[i]++;
      }
    }
    cout<<s<<'\n';
    return 0;
}


Measured memory_bytes: 256
(defun f(s)
  (labels ((rec(i)
	     (if (= i (length s))
	       t
	       (if (or (char= #\U (char s i))
		       (char= #\D (char s i)))
		 (rec (1+ i))
		 (if (and (oddp (1+ i))
			  (char= #\R (char s i)))
		   (rec (1+ i))
		   (if (and (evenp (1+ i))
			    (char= #\L (char s i)))
		     (rec (1+ i))
		     nil))))))
    (rec 0)))
(let ((line (read-line nil nil)))
  (format t "~A" (if (f line) "Yes" "No")))


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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

int n;
string s;
int dp[200050][2];
bool c[200050];

int f(int a, bool b){
    if(a==n)
        return 0;
    if(dp[a][b]!=-1)
        return dp[a][b];
    
    return dp[a][b] = min(!c[a]+f(a+1, true),
    b?(int)1e9:c[a]+f(a+1, false));
}

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

    cin >> n;
    cin >> s;
    memset(dp, -1, sizeof dp);
    bool frt;
    for(int i=0; i<n; i++)
        if(s[i]=='#')
            c[i]=true;
        else
            c[i]=false;
    
    cout << f(0, false);
}

Measured memory_bytes: 13716
#include <cstdio>
#include <algorithm>
#define maxn 1005
using namespace std;

int a[maxn];

int main(int argc, char** argv)
{
	int n, k, sum = 0;
	scanf("%d%d", &n, &k);
	for(int i=0; i<n; i++)
		scanf("%d", a + i);
	sort(a, a + n);
	for(int i=0; i<k; i++)
		sum += a[i];
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
    #define _USE_MATH_DEFINES
    using namespace std;
    
    #define ll long long int
    #define pb push_back
    #define rep(i , j , n) for(ll i = j ; i < n ; i++)
    #define per(i , j , n) for(ll i = j ; i >= n ; i--)
    #define all(x) x.begin(), x.end()
    typedef pair<int, int>	pii;
    typedef pair<ll, ll>	pl;
    typedef vector<int>		vi;
    typedef vector<ll>		vll;
    typedef vector<bool>	vb;



int main(){ 
    ll n,k;
    cin >> n >> k;
    ll a[n];
    rep(i,0,n){
        cin >> a[i];
    }
    sort(a,a + n);
    ll ans = 0;
    rep(i,0,k){
        ans += a[i];
    }
    cout << ans;
}

Measured memory_bytes: 3636
// Date: 2020-01-22

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) x.size()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int main() {
	int h, w, n;
	cin >> h >> w >> n;
	if(h < w) swap(h, w);
	cout << (n+h-1)/h;

	return 0;
}

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

ll f(ll n) {
    ll res[]={n,1,n+1,0};
    return res[n&3];
}

int main() {
    ll a,b;
    cin >> a >> b;
    ll ans = f(a-1)^f(b);
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<math.h>
#define ll long long
#define ld long double
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
ll inf = 1e9 + 7;
ll modexp( ll base ,ll power)
 {
     if( power == 0  ) return 1;
     if( power & 1) return base*modexp( base , power-1 )%inf;
     return modexp(base*base%inf,power/2);
 }
 int main()
{
  Summon_Tourist
  //freopen("input.txt" , "r" , stdin ) ;
  ll h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;
  ll x = ( h2 - h1 )*60 +( m2 - m1 ) ;
  ll ans = x - k ;
  cout<<ans;
  return 0;

}


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

using namespace std;

int main() {
	
	
	string s;
	cin >> s;
	long long k;
	cin >> k;
	
	long long len = s.length();
	long long pair = 0;
	long long joint = 0;
	
	long long firstChain = 1;
	bool keepChain = true;
	
	for (long long i = 0; i < len; i++)
	{
		if (keepChain && i > 0)
		{
			// 最初の同じ文字の塊の文字数チェック
			if (s[i] == s[0])
				firstChain += 1;
			else
				keepChain = false;
		}
		
		// 最後の文字の処理
		if (i == len-1)
		{
			if (s[i] == s[0] && firstChain%2 == 1)
				joint += 1;
			
			break;
		}
		
		// 同じ文字のペア数をカウント
		if (s[i] == s[i+1])
		{
			pair += 1;
			i += 1;
			if (keepChain)
				firstChain += 1;
		}
	}
	
	long long ans = pair * k;
	if (firstChain == len)
		ans += joint * (k/2);
	else
		ans += joint * (k-1);
	
	cout << ans;
	return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    string S;
    cin >> S;
    int m = (S[5] - '0') * 10 + (S[6] - '0');
    cout << (m <= 4 ? "Heisei" : "TBD") << endl;
}


Measured memory_bytes: 256
import queue
import sys
input = sys.stdin.readline

class Tree:
    def __init__(self, ind):
        self.children = []
        self.counter = 0
        self.index = ind
        self.parent = -1


N, Q = map(int, input().strip().split(" "))
tree = [Tree(i) for i in range(N)]
ans = [0 for i in range(N)]
for i in range(N - 1):
    a, b = map(int, input().strip().split(" "))
    tree[a - 1].children.append(b - 1)
    tree[b - 1].children.append(a - 1)

for i in range(Q):
    p, x = map(int, input().strip().split(" "))
    tree[p - 1].counter += x

# bfs
que = queue.Queue()
que.put(0)  # root is 0

while not que.empty():
    ind = que.get()
    ans[ind] = tree[ind].counter
    for child in tree[ind].children:
        if child == tree[ind].parent:
            continue
        tree[child].counter += tree[ind].counter
        tree[child].parent = ind
        que.put(child)

print(' '.join([str(a) for a in ans]))

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

int main()
{
    int k, s;
    cin >> k >> s;
    int num = 0;
    for (int x = 0; x < k + 1; x++) {
        for (int y = 0; y < k + 1; y++) {
            int z = s - x - y;
            if (z >= 0 && z <= k) {
                num++;
            }
        }
    }
    cout << num << "\n";
}

Measured memory_bytes: 256