akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

const int N=105;

int cnt[26];

void solve(){
	int h,w;
	cin>>h>>w;
	string s;
	rep(i,0,h){
		cin>>s;
		rep(j,0,w){
			cnt[s[j] - 'a']++;
		}
	}
	
	int odds = 0 , multof2 = 0;
	rep(i,0,26){
		if(cnt[i]%2) odds++;
		if(cnt[i]%4 == 2) multof2++;
	}
	if((odds > 1 || (odds == 1 && (h%2 == 0 || w%2 == 0))) || (odds == 0 && h%2 && w%2)){
		cout<<"No";
		return;
	}
	
	int perm = 0;
	if(h%2) perm += w/2;
	if(w%2) perm += h/2;
	
	if(perm < multof2){
		cout<<"No";
		return;
	}
	cout<<"Yes";
	
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SIEVE
		sieve();
	#endif
	#ifdef NCR
		init();
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 3608
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define out(x) cout << x << '\n'
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
//---------------------------------------------------------------------------------------------------
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
//---------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------
void solve()
{
  lli a = 0, b = 0, c = 0, h = 0, x, k, d, n = 0, w = 0, ans = 0, count = 0;
  string s = "", t = "";
  vector<pair<lli, lli>> pr;
  map<lli, lli> mp;
  set<lli> st;

  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> x >> k >> d;
  ans = k * d;
  if (d <= abs(x) / k)
  {
    out(abs(x) - ans);
  }
  else
  {
    count = abs(x) / d;
    a = abs(x) - (count * d);
    if (count % 2 == k % 2)
    {
      out(a);
    }
    else
    {
      b = abs(a - d);
      c = abs(a + d);
      if (b < c)
      {
        out(b);
      }
      else
      {
        out(c);
      }
    }
  }
}

//---------------------------------------------------------------------------------------------------
signed main()
{
  solve();
}

Measured memory_bytes: 3644
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <complex>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second

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

//AOJ2372
LL fib(int k){//k番目のfibonacci数を求める
	LL a[2][2]={{1,1},{1,0}};
	LL t[2][2];
	LL b[2][2]={{1,0},{0,1}};
	if(k==0)return 1;
	k--;
	while(k){
		if(k&1){
			memset(t,0,sizeof(t));
			REP(p,2)REP(q,2)REP(r,2)t[p][q] += (a[p][r]*b[r][q]) % MOD;
			REP(p,2)REP(q,2)b[p][q]=(t[p][q]%MOD);
		}
		memset(t,0,sizeof(t));
		REP(p,2)REP(q,2)REP(r,2)t[p][q] += (a[p][r]*a[r][q]) % MOD;
		REP(p,2)REP(q,2)a[p][q]=(t[p][q]%MOD);
		k>>=1;
	}
	return (b[0][0]+b[0][1])%MOD;
}

int main(){
	LL u,l,f,g,s,k;
	cin >> k;
	u=2000000000;
	l=0;
	while(u-l>1){
		LL mid=(u+l)/2;
		if(k<=mid*(mid+1))u=mid;
		else l=mid;
	}
	if(k<=u*(u+1))f=u;
	else f=l;
	g=k-f*(f-1);
	if(k<=f*f)s=2*f;
	else{
		g-=f;
		s=2*f+1;
	}
	if(g*2<=f+1)g=2*g-1;
	else{
		g-=(f+1)/2+1;
		g=f-2*g-(f%2);
	}
	cout << (fib(g)*fib(s-g)%MOD) << endl;
	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main(){
int n,k;
  cin>>n>>k;
  int *arr=new int[n];
  for(int i=0;i<n;i++) cin>>arr[i];
  long dp[n+1][k+1];
  
  for(int i=1;i<=n;i++){
    for(int j=0;j<=k;j++){
       if(i==1) dp[i][j]= j>arr[i-1]? 0: 1 ;   
       else if(j==0) dp[i][j]=1;
      else if(arr[i-1]>=j) dp[i][j]=(mod+dp[i-1][j]+dp[i][j-1])%mod;
        else dp[i][j]=(mod+dp[i][j-1]+dp[i-1][j]-dp[i-1][j-arr[i-1]-1])%mod;
    }
  }
  //for(int i=0;i<=n;i++){
  //	for(int j=0;j<=k;j++){
  //		cout<<dp[i][j]<<" ";
  //	}
  //	cout<<endl;
  //}
  cout<<dp[n][k];
 }

Measured memory_bytes: 78336
# -*- coding: utf-8 -*-

def inpl(): return tuple(map(int, input().split()))

N, A, B = inpl()
a, b = 0, 0

a += A-1
b += N-B

x = (N-A - b - 1)


if x%2:
    print("Alice")
else:
    print("Borys")  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int maxn = 60;
long long len[maxn], ps[maxn];
long long f(long long n, long long k){
	if(n == 0) return (k <= 0 ? 0 : 1);
	else if(k <= 1 + len[n - 1]) return f(n-1,k-1);
	return ps[n - 1] + 1 + f(n - 1, k - 2 - len[n - 1]);
}
int main() {
	len[0] = 1, ps[0] = 1;
	for(int i = 1; i < maxn; ++i){
		len[i] = 1 + len[i - 1] + 1 + len[i - 1] + 1;
		ps[i] = ps[i - 1] + 1 + ps[i - 1];
	}
	long long n, k;
	cin >> n >> k;
	cout << f(n, k);
	return 0;
}

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

int main(void){
    int n = 0; 
    int k = 0;
    int now = 1;

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

    for(int i = 0; i < n; i++){
        if(now * 2 <= now + k){
            now = now * 2;
        }else{
            now = now + k;
        }
        fprintf(stderr, "i = %d now = %d\n", i, now);
    }

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

} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define i64 long long
#define maxn (int)(1e5)
#define pii pair<int,int>
#define L first 
#define R second
#define all(x) x.begin(),x.end()
using namespace std;
bool cmp(int val1, int val2){
	return val1>val2;
}

int cntDiv(int n){
	int cnt =0;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			cnt++;
			if(i!=(n/i)) cnt++;
		}
	}
	return cnt;
}
int main(){
	int n; cin>>n;
	int cnt=0;
	for(int i=1;i<=n;i+=2){
		if(cntDiv(i)==8) cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		for (int i = 0; i < n; i++) {
			int C = scanner.nextInt();
			int A = scanner.nextInt();
			int N = scanner.nextInt();
			int ans = 0;
			int min = Math.min(C, Math.min(A, N));
			C -= min;
			A -= min;
			N -= min;
			ans += min;
			int mi = Math.min(C / 2, A);
			ans += mi;
			C -= mi * 2;
			ans += C / 3;

			System.out.println(ans);
		}
	}
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#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++)

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

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct SegmentTree {
  vector< vector<int> > data;
  int sz;
  SegmentTree(int n) {
    sz = 1; while(sz < n) sz *= 2;
    data.resize(2*sz-1);
  }
  void init(vector<int> x) {
    rep(i, x.size()) data[sz-1+i].push_back(x[i]);
    for(int i = sz-2; i >= 0; i--) {
      data[i].resize(data[2*i+1].size()+data[2*i+2].size());
      merge(all(data[2*i+1]), all(data[2*i+2]), data[i].begin());
    }
  }
  int query(int a, int b, int u, int d, int k, int l, int r) {
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) {
      return upper_bound(all(data[k]), u) - lower_bound(all(data[k]), d);
    }
    int vl = query(a, b, u, d, 2*k+1, l, (l+r)/2);
    int vr = query(a, b, u, d, 2*k+2, (l+r)/2, r);
    return vl+vr;
  }
  int query(int a, int b, int u, int d) {
    return query(a, b, u, d, 0, 0, sz);
  }
};

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int D;
  cin >> D;
  vector<int> x(D);
  rep(i, D) cin >> x[i];
  SegmentTree seg(D);
  seg.init(x);
  int Q;
  cin >> Q;
  rep(i, Q) {
    int l, r, e;
    cin >> l >> r >> e;
    l--, r--;
    int a, b;
    tie(a, b) = minmax(x[l], x[r]);
    cout << r-l+1 - seg.query(l, r+1, b+e, a-e) << endl;
  }

  return 0;
}

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

using namespace std;

int main() {

    int n, len = 0;

    cin >> n;

    int num[n], dp[n];

    for(int i = 0; i < n; ++i) {
        cin >> num[i];
    }

    dp[0] = num[0];
    for(int i = 1; i < n; ++i) {
        if(dp[len] < num[i]) {
            dp[++len] = num[i];
        } else {
            *lower_bound(dp, dp + len, num[i]) = num[i];
        }
    }

    cout << len + 1 << endl;

}

Measured memory_bytes: 1940
#include<stdio.h>

int main(){

	int r,c,i,j;
	int a[101][101]={0};

	scanf("%d %d",&r,&c);
	for(i=0; i<r; i++){
		for(j=0; j<c; j++){
			scanf("%d",&a[i][j]);
			
		}
	}

	for(i=0; i<r; i++){
		for(j=0; j<c; j++){
			a[i][c] += a[i][j];
			a[r][j] += a[i][j];
		}
	}
	for(i=0; i<r; i++){
		a[r][c] += a[i][c];
	}

	for(i=0; i<r+1; i++){
		for(j=0; j<c+1; j++){
			if(j<c) printf("%d ",a[i][j]);
			else printf("%d\n",a[i][j]);
		}
	}
	
return 0;
}

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

using namespace std;

struct SatoMizu{
    int sato;
    int water;
};


int main(){
    int A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;

    int suger, water;
    water = 100*A;
    suger = 0;
    double max = 0.0;
    const double max_node = 100.0*E/(100.+E);
    for(int ia=0;ia<=F/(100*A);ia++){
        for(int ib=0;ib<=F/(100*B);ib++){
            int total_water = 100*(A*ia + B*ib);
            if(total_water > F) break;

            for(int ic=0;ic<=F/C;ic++){
                if(total_water + C*ic > F) break;
                for(int id=0;id<=F/D;id++){
                    int total_suger = C*ic + D*id;

                    if(total_suger + total_water > F) break;
                    double tmp = 100.0*total_suger / (total_water + total_suger);
                    if(max < tmp && tmp <= max_node){
                        max = tmp;
                        suger = total_suger;
                        water = total_water;
                    }
                }
            }
        }
    }
    cout << suger+water << " " << suger << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		        Scanner sc = new Scanner(System.in);
		        int money = sc.nextInt();

		        int point = 0;
		        //moneyが5以上ならくり返す
		        while(money >= 5) {
		        	//moneyが500以上か
		        	if(money >=500){
		        		point += 1000;
		        		money -= 500;
		        	}
		        	else if(money >= 5) {
		        		point += 5 ;
		        		money -= 5;
		        	}


		        }
		        System.out.println(point);
	}


}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=200010;
const int inf=2147483647;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x*f;
}
int n,a[Maxn],b[Maxn];
char s[Maxn];
int main()
{
	n=read();
//	if(n==1)return puts("0"),0;
	scanf("%s",s+1);
	a[0]=0;
	for(int i=1;i<=n;i++)
	{
		a[i]=a[i-1];
		if(s[i]=='#')a[i]++;	
	}
	b[n+1]=0;
	for(int i=n;i;i--)
	{
		b[i]=b[i+1];
		if(s[i]=='.')b[i]++;
	}
	int ans=inf;
	for(int i=0;i<=n;i++)ans=min(ans,a[i]+b[i+1]);
	printf("%d",ans);
}


Measured memory_bytes: 2048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();

			int ans = 0;
			for (char c : s) {
				if (c == '+') {
					ans++;
				} else {
					ans--;
				}
			}

			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 21332
#include<stdio.h>
#include<stdlib.h>

int main(void){
    int N;
    scanf("%d", &N);
    int d[101] = {0};

    int i;
    for(i=0; i<N; i++) {
        int temp;
        scanf("%d", &temp);
        if(d[temp] == 0) {
            d[temp] = 1;
        }
    }
    int sum = 0;
    for(i=0; i<=100; i++) {
        if(d[i] == 1) {
            sum++;
        }
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
int a[100010], b[50010];
int n, q;
int main()
{
	int i;
	cin >> n;
	for(i = 0; i < n; ++ i)
		cin >> a[i];
		
	int sum = 0;
	cin >> q;
	for(i = 0; i < q; ++ i)
	{
		cin >> b[i];
		if(*lower_bound(a, a + n, b[i]) == b[i])	sum ++;
	}
	
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 3668
K,N = map(int, input().split())
A = list(map(int, input().split())) 
B = sorted(A)
C = [0]*(N)
C[0] = B[1]-B[0]
for i in range (1,N-1):
    C[i] = B[i+1] -B[i]
C[N-1] = K-B[N-1] +B[0]
print(K-max(C))

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

int main (){
    int m1,d1,m2,d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1+1==m2){
        if(d2==1){
            cout << "1" << endl;
        }
    }else{
    	cout << "0" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <ctime>
#include <random>
#include <queue>
  
using namespace std;
 
const int MAXN = 1e5 + 10;

long long k, a[50], n;

int main(){
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
#ifndef _DEBUG
    /*freopen("trap.in", "r", stdin);
    freopen("trap.out", "w", stdout);*/
#endif
    cin >> k;
    n = 50;
    for (int i = 0; i < n; i++){
        a[i] = n + k / n - i;
    }
    int l = 0;
    for (int j = 0; j < n - (k % n); j++){
        a[0] -= n;
        for (int i = 1; i < n; i++){
            a[i]++;
            swap(a[i], a[i - 1]);
        }
    }
    cout << n << "\n";
    for (int i = 0; i < n; i++){
        cout << a[i] << " ";
    }
    /*while (a[0] > n - 1){
        a[0] -= n;
        for (int i = 1; i < n; i++){
            a[i]++;
            swap(a[i], a[i - 1]);
        }
        l++;
    }
    cout << l;*/
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,a;
vector<int>v[100010],d[100010];
int dfs(int x){
	for(int y:v[x])d[x].pb(dfs(y));
	sort(all(d[x]));
	int res=0,i=d[x].size();
	for(int y:d[x]){
		res=max(res,y+i);
		i--;
	}
	return res;
}
signed main(){
	cin>>n;
	for(int i=2;i<=n;i++){
		cin>>a;
		v[a].pb(i);
	}
	cout<<dfs(1)<<endl;
	return 0;
}


Measured memory_bytes: 20480
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ld = long double;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;
constexpr long double kPI = 3.14159265358979323846;

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  vll A(N), diffs(N, 0);
  REP(i, 0, N) {
    cin >> A[i];

    if (i > 0) {
      diffs[i] = A[i] - A[i - 1];
//      cout << diffs[i] << endl;
    }
  }


  ll stk = 0;
  ll ans = 1000;
  REP(i, 0, N - 1) {
    if (stk > 0) {
      if (diffs[i] >= 0 && diffs[i + 1] < 0) {
        ans += stk * A[i];
        stk = 0;
      }
    } else {
      if (diffs[i] <= 0 && diffs[i + 1] > 0) {
        ll cnt = ans / A[i];
        ans -= cnt * A[i];
        stk = cnt;
      }
    }
//    cout << i << ":" << ans << ", " << stk << endl;
  }
  if (stk > 0) {
    ans += stk * A[N - 1];
    stk = 0;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  int ans;
  for(int p=1; p<(int)s.size()-1; p+=2){
    int half = (p+1)/2;
    bool flag = true;
    REP(i, half){
      if(s[i]!=s[i+half]){
        flag = false;
        break;
      }
    }
    if(flag) ans = p+1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int N,c,d;
    c = 4;
    d = 7;
    cin >> N;
    bool flag = false;
    string ans = "No";
    for(int i=0;i<26;i++){
        int sum;
        for(int j=0;j<15;j++){
            sum = c*i + d*j;
            if(sum == N){
                ans = "Yes";
                break;
            }
        }
        if(ans=="Yes") break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <utility>
#include <algorithm>

using namespace std;
vector<pair<long long,long long>> l1,l2,r1,r2,y;
bool used[100010];
long long ans1=0,ans2=0,i,n,l,r;
int main(){
	cin >> n;
	for(i=0;i<n;i++){
		cin >> l >> r;
		y.push_back(make_pair(l,r));
		l1.push_back(make_pair(l,i));
		l2.push_back(make_pair(l,i));
		r1.push_back(make_pair(r,i));
		r2.push_back(make_pair(r,i));
		used[i] = true;
	}
	sort(l1.begin(),l1.end());
	sort(l2.begin(),l2.end());
	sort(r1.rbegin(),r1.rend());
	sort(r2.rbegin(),r2.rend());
	
	int x = 0,k=0;
	while(k<n){
		if(k%2==0){
			if(used[l1.back().second]){
				k++;
				if(y[l1.back().second].first <= x && x <= y[l1.back().second].second){
					ans1 += 0;
				}else{
					ans1 += abs(l1[l1.size()-1].first-x);
					x = l1[l1.size()-1].first;
					used[l1[l1.size()-1].second] = false;
				}
			}else{
				l1.pop_back();
			}
		}else{
			if(used[r1.back().second]){
				k++;
				if(y[r1.back().second].first <= x && x <= y[r1.back().second].second){
					ans1 += 0;
				}else{
					ans1 += abs(r1.back().first-x);
					x = r1.back().first;
					used[r1.back().second] = false;
				}
			}else{
				r1.pop_back();
			}
		}
	}
	ans1 += abs(x);
	for(i=0;i<n;i++){
		used[i] = true;
	}
	x = 0; k = 0;
	while(k<n){
		if(k%2==0){
			if(used[r2.back().second]){
				k++;
				if(y[r2.back().second].first <= x && x <= y[r2.back().second].second){
					ans2 += 0;
				}else{
					ans2 += abs(r2[r2.size()-1].first-x);
					x = r2.back().first;
					used[r2.back().second] = false;
				}
			}else{
				r2.pop_back();
			}
		}else{
			if(used[l2.back().second]){
				k++;
				if(y[l2.back().second].first <= x && x <= y[l2.back().second].second){
					ans2 += 0;
				}else{
					ans2 += abs(l2.back().first-x);
					x = l2.back().first;
					used[l2.back().second] = false;
				}
			}else{
				l2.pop_back();
			}
		}
	}
	ans2 += abs(x);
	cout << max(ans1,ans2) << endl;
}

Measured memory_bytes: 8440
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;

ll f(ll n){
  n++;
  ll ret = 0;
  if(n%4 == 2 || n%4 == 3)
    ret += 1;

  ll base = 2;
  for(int i=1; i<40; i++){
    ret += base * (max(0ll, n%(base<<1) - base)%2);
    base = base << 1;
  }
  return ret;
}

int main(int argc, const char * argv[]) {
  ll A, B; cin >> A >> B;
  cout << (f(B)^f(A)^A) << endl;
  return 0;
}

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

pu = []
ma = []
for x, y in zip(a, b):
    if x - y < 0:
        ma.append(x - y)
    else:
        pu.append(x - y)
if sum(pu) + sum(ma) < 0:
    print(-1)
else:
    cnt = len(ma)
    ma_sum = sum(ma)
    pu.sort(reverse = True)
    while ma_sum < 0:
        cnt += 1
        ma_sum += pu.pop(0)
    print(cnt)

Measured memory_bytes: 18292
import bisect
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

sa=[0]
sb=[0]

gen=0
for i in range(n):
    gen+=a[i]
    sa.append(gen)

gen=0
for i in range(m):
    gen+=b[i]
    sb.append(gen)


ans=0

for i in range(n+1):
    if(sa[i]>k):
        break
    basho=bisect.bisect_right(sb,k-sa[i])-1
    if(ans<i+basho):
        ans=i+basho

print(ans)

Measured memory_bytes: 127156
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, A: "List[int]", B: "List[int]"):

    L2 = [(b,b-a,a,b) for a,b in zip(A,B) ]
    L2.sort()

    t = 0
    for l in L2:
        if t > l[1]:
            print(NO)
            return
        t += l[2]

    print(YES)


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]" 
    B = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, A, B)

if __name__ == '__main__':
    main()


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

int main(){
    int N; string S;
    cin >> N >> S ;

    rep(i,S.size()){
        cout << char('A' + ((S[i] - 'A' +  N) + 26) % 26) ;
    }

    cout << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pchar = pair<char, char>;

int simulate(const string &s, const vector<pchar> &td, int pos) {
    for (auto c : td) {
        if (s[pos] != c.first) continue;
        if (c.second == 'L') --pos;
        else ++pos;
        if (pos < 0) return -1;
        if (pos >= (int)s.size()) return 1;
    }
    return 0;
}

int solve(int N, const string &s, const vector<pchar> &td) {
    int low = -1, high = N;
    while (high - low > 1) {
        int mid = (low + high) / 2;
        if (simulate(s, td, mid) == -1) low = mid;
        else high = mid;
    }
    int left_fall = high;
    
    low = -1, high = N;
    while (high - low > 1) {
        int mid = (low + high) / 2;
        if (simulate(s, td, mid) == 1) high = mid;
        else low = mid;
    }
    int right_fall = N-high;

    return N - (left_fall + right_fall);
}
int main()
{
    int N, Q; cin >> N >> Q;
    string s; cin >> s;
    vector<pchar> td(Q);

    for (int i = 0; i < Q; ++i) cin >> td[i].first >> td[i].second;
    cout << solve(N, s, td) << endl;

}

Measured memory_bytes: 900
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------

int main(void){
  ll A,B,C;cin>>A>>B>>C;
  if( (A==B&&A!=C)||
      (A!=B&&B==C)||
     (A==C&&C!=B))cout<<"Yes";
  else cout<<"No";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,ans = 0;
  cin >> N;
  vector<int>str(N);

  for ( int i = 0; i < N; ++i)
    cin >> str.at(i);

  sort(str.begin(),str.end());
  reverse(str.begin(),str.end());
  for ( int j = 0; j < N; ++j){
    if (j%2 == 0)
      ans += str.at(j);
    else
      ans -= str.at(j);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int N,i,act,min=9999999;
  char s[200002];
  int ct[200002]={0},ct2[200002]={0};
  scanf("%d",&N);
  scanf("%s",s);
  act = 0;
  for(i = 0;i <= N;i++){
    ct[i+1] = ct[i] + (s[i]=='#');
    ct2[N-i] =ct2[N+1-i] + (s[N-i] == '.');
  }
  for(i = 0;i <= N;i++){
    if(ct[i]+ct2[i] < min){min = ct[i]+ct2[i];}
  }
  printf("%d\n",min);
  return 0;
}

Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Speed Skating Badge Test
 */
public class Main {

	static final double TIME_NA = 361.0;

	static final String[] RANK = {
			"AAA",
			"AA",
			"A",
			"B",
			"C",
			"D",
			"E",
			"NA",
	};

	static final double[] TIME1 = {
			35.5,
			37.5,
			40.0,
			43.0,
			50.0,
			55.0,
			70.0,
			TIME_NA,
	};

	static final double[] TIME2 = {
			71.0,
			77.0,
			83.0,
			89.0,
			105.0,
			116.0,
			148.0,
			TIME_NA,
	};

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			double t1, t2;
			t1 = Double.parseDouble(line.substring(0, line.indexOf(' ')));
			t2 = Double.parseDouble(line.substring(line.indexOf(' ') + 1));

			int r1 = 0, r2 = 0;
			for (; r1 < RANK.length; r1++) if (t1 < TIME1[r1]) break;
			for (; r2 < RANK.length; r2++) if (t2 < TIME2[r2]) break;

			System.out.println(RANK[Math.max(r1, r2)]);

		}
	}
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)

#define SORT(c) sort((c).begin(),(c).end())
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;
const int MAX = 10001;

struct init{
    init(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
} init;

LL N,X;
std::vector<LL> layerL;
std::vector<LL> patyL;

void input(){
  std::cin >> N >> X;
  layerL.reserve(N+1); layerL[0] = 1;
  patyL.reserve(N+1); patyL[0] = 1;
  REP1(i,N){
    layerL[i] = layerL[i-1]*2+3;
    patyL[i] = patyL[i-1]*2+1;
  }
}


LL rec(LL N, LL X){
  if (N==0) {
    return (X<=0) ? 0 : 1 ;
  }else if ( X <= 1 + layerL[N-1] ){
    // (最下部バン+下のN-1バーガーを食べきれない)場合
    // N-1バーガーから X - |最下部バン| 枚を食べる
    return rec(N-1, X-1);
  }else {
    // 下のN-1パティと, 上のN-1パティの中から
    // X - |N-1バーガー1個分| - |最下部バン&中間パティ| 枚
    return patyL[N-1] + 1 + rec(N-1, X-2-layerL[N-1]);
  }
}

void solve(){
  LL ans = rec(N, X);
  std::cout << ans << '\n';
}


int main(int argc, char const *argv[]) {
  input();
  solve();

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<queue>
#include<cstdio>
#include<cmath>
#include<sstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<ctime>
#include<cstdlib>
#include<map>
#include<utility>
#include<iomanip>
#include<set>
#include<stack>
//#include<Windows.h>
using namespace std;
typedef long long ll;typedef pair<int,int> pii;
typedef pair<ll,ll> pll;typedef vector<string> vss;
typedef vector<int> vii;typedef vector<pii> vpi;
typedef vector<ll> vll;typedef vector<pll> vpl;
typedef unsigned long long ul;typedef queue<int> qii;typedef queue<pii> qpi;
string s;
int main()
{
	cin>>s;
	cout<<s.substr(0,(int)s.size()-8)<<'\n';
	return 0;
}


Measured memory_bytes: 384
x, y, a, b, c = map(int, input().split())

p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)

eat_list = []

for i in range(x):
    eat_list.append(p[i])
for i in range(y):
    eat_list.append(q[i])
for i in range(c):
    eat_list.append(r[i])
    
eat_list.sort(reverse=True)

ans = 0

for i in range(x+y):
    ans += eat_list[i]

print(ans)

Measured memory_bytes: 23328
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    int n;
    cin>>n;
    vec c(3);
    rep(i,3){
        c[i]=n%10;
        n/=10;
    }
    if(c[2]<c[1]) cout<<(c[2]+1)*100+(c[2]+1)*10+c[2]+1;
    else if(c[2]>c[1]) cout<<c[2]*100+c[2]*10+c[2];
    else{
        if(c[1]<c[0]) cout<<(c[2]+1)*100+(c[2]+1)*10+c[2]+1;
        else cout<<c[2]*100+c[2]*10+c[2];
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://code-festival-2017-quala.contest.atcoder.jp/tasks/code_festival_2017_quala_c>
問題文============================================================
 縦 H 行、横 W 列の行列 A があります。
 上から i 行目、左から j 列目の要素を aij とします。 各 aij は英小文字です。
 
 すぬけ君は、A の要素を自由に並べ替え、縦 H 行、横 W 列の行列 A' を作ろうとしています。
 このとき、次の条件が成り立つようにします。
 
 A' のどの行およびどの列もそれぞれ回文になっている。
 条件を満たす A' が存在するか判定してください。
 
 1≤H,W≤100
 aij は英小文字である。

=================================================================

解説=============================================================

================================================================
*/
string solve(){
    int H,W; cin >> H >> W;
    int alpha[26] = {};
    for(int i = 0; i < H;i++){
        for(int j = 0; j < W;j++){
            char c; cin >> c;
            alpha[c-'a']++;
        }
    }
    int four = 0, two = 0, one= 0;
    if(H&1) two += W/2;
    if(W&1) two += H/2;
    if(H&W&1) one = 1;
    four = H*W - two*2 - one; four/=4;
  //  cout << one << " " << two << " " << four << endl;
    // 確定で決められるものを先にはじく
    for(int i = 0; i < 26;i++){
        if(alpha[i] == 0) continue;
        if(alpha[i]%2 == 1){
            if(one == 0) return "No";
            one--;
            alpha[i] -= 1;
        }
        if(alpha[i] == 0) continue;
        if(alpha[i]%2 == 0 && alpha[i]%4 != 0){
            if(two == 0) return "No";
            two--;
            alpha[i] -= 2;
        }
        if(alpha[i] == 0) continue;
        if(alpha[i]%4 == 0){
            int minf = min(alpha[i]/4,four);
            alpha[i] -= minf*4;
            four -= minf;
        }
    }
    if(four != 0) return "No";
    
    for(int i = 0; i < 26;i++){
        two -= alpha[i]/2;
        if(two < 0) return "No";
    }
    
    return "Yes";
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    N = int(input())
    csf = []
    for i in range(N-1):
        c,s,f = map(int, input().split())
        csf.append((c,s,f))
        
    for i, val in enumerate(csf):
        ans = 0
        c,s,f = val
        ans += s + c
        for j, vol in enumerate(csf):
            if i >= j:
                continue
                
            cc,ss,ff = vol
            if ans <= ss:
                ans = ss + cc
            else:
                tmp = ans - ss
                if tmp == 0:
                    ans += cc
                    continue
                    
                tmp2 = (tmp // ff)
                if tmp % ff != 0:
                    tmp2 += 1
                tmp2 = (tmp2 * ff) + ss
                ans = ans + (tmp2 - ans) + cc
        print(ans)
                
    print(0)
    
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 41964
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  string s;
  cin>>N;
 cin>>s;
  
  
  if(N%2==1){
  cout<<"No"  ;  
  }
  else{
  int l=N/2;
    bool a=true;
    for(int i=0;i<l;i++){
    if(s.at(i)!=s.at(i+l)){
    a=false;
      cout<<"No";
      break;
    }
   
    }
     if(a==true){
    cout<<"Yes";
    }
  }
}

Measured memory_bytes: 256
R,G,B,N = gets.strip.split.map(&:to_i)

c=0
rmax=(N/R).floor
(0..rmax).each do |r|
    gmax=((N-r*R)/G).floor
    (0..gmax).each do |g|
        nokori=N-r*R-g*G
        if nokori%B==0
            c+=1
        end
    end
end


puts c


Measured memory_bytes: 1788
N, M = map(int, input().split())

AB = [tuple(map(int,input().split())) for i in range(M)]

es = [[] for _ in range(N)]
for a, b in AB:
    es[a-1].append(b-1)
    es[b-1].append(a-1)

ans = [-1] * N
ans[0] = 0

from collections import deque
que = deque([0])

while que:
    s = que.popleft()
    for v in es[s]:
        if ans[v] == -1:
            ans[v] = s+1
            que.append(v)

print("Yes")
print(*ans[1:], sep="\n")

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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	int ans = 0;
	vector<int> v;
	for (int i = 0; i < 3; i++) {
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
	}

	sort(v.begin(), v.end());

	ans = v[2] * 10 + v[1] + v[0];

	cout << ans << endl;

}


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

using namespace std;

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

  vector<array<int, 3>> vp(n);
  for (auto &p : vp) {
    cin >> p[0] >> p[1] >> p[2];
  }

  int t = 0, x = 0, y = 0;
  bool ans = true;
  for (auto &p : vp) {
    int tt = p[0] - t;
    int dist = abs(x - p[1]) + abs(y - p[2]);
    if (dist > tt || (tt - dist) % 2 == 1) {
      ans = false;
      break;
    }

    t = p[0];
    x = p[1];
    y = p[2];
  }

  if (ans) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
}

Measured memory_bytes: 4144
using System;
using System.Collections.Generic;

namespace Volume0_0002
{
	class Program
	{
		static void Main(string[] args)
		{
			List<Tuple<int, int>> ts = new List<Tuple<int, int>>();

			for(int i = 0; i < 200; i++) {
				string str = Console.ReadLine();
				if(str == null) {
					break;
				}

				string[] vs = str.Split(' ');
				ts.Add(Tuple.Create(int.Parse(vs[0]), int.Parse(vs[1])));
			}

			foreach(Tuple<int, int> t in ts) {
				string a = (t.Item1 + t.Item2).ToString();

				Console.WriteLine(a.Length);
			}
		}
	}
}



Measured memory_bytes: 17996
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


ll le[MAX], ri[MAX], num[MAX];


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



  cin >> s;
  ll pos = 0;
  n = s.size();
  rep(i, n) {
    if (s[i] == 'R') pos = i;
    else {
      tmp = i - pos;
      if (tmp % 2) {
        num[pos + 1]++;
      }
      else {
        num[pos]++;
      }
    }
  }
  pos = n - 1;
  rrep(i, n) {
    if (s[i] == 'L') pos = i;
    else {
      tmp = pos - i;
      if (tmp % 2) {
        num[pos - 1]++;
      }
      else {
        num[pos]++;
      }
    }
  }
  rep(i, n) cout << num[i] << " ";
  cout << endl;



  return 0;
}


Measured memory_bytes: 1488
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read_vec::<String>();
    println!("A{}C", s[1].chars().next().unwrap());
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>

using namespace std;

int N, A, B;
long long K;
const int mod = 998244353;

vector<int> range_mod_inverse(int n, const int mod) {
  vector<int> ret(n + 1);
  ret[1] = 1;
  for (int i = 2; i <= n; i++)
    ret[i] = (long long)(mod - mod / i) * ret[mod%i] % mod;
  return ret;
}

vector<int> getFactorials(int n, const int mod) {
  vector<int> ret(1, 1);
  for (int i = 1; i <= n; i++) ret.push_back((long long)ret.back()*i%mod);
  return ret;
}

vector<int> getInverseFactorials(int n, const int mod) {
  vector<int> invmod(range_mod_inverse(n, mod));
  vector<int> ret(1, 1);
  for (int i = 1; i <= n; i++) ret.push_back((long long)ret.back()*invmod[i] % mod);
  return ret;
}

vector<int> facts, ifacts;

long long comb(int a, int b) {
  if (a < 0 || b < 0 || b > a) return 0;
  unsigned long long d = facts[a];
  d *= (unsigned long long)ifacts[b]; d %= mod;
  d *= (unsigned long long)ifacts[a - b]; d %= mod;
  return d;
}

int main() {
  scanf("%d%d%d", &N, &A, &B);
  scanf("%lld", &K);
  facts = getFactorials(N + 1, mod);
  ifacts = getInverseFactorials(N + 1, mod);
  long long ans = 0;
  for (long long x = 0; x <= N; x++) {
    if (x*A > K) break;
    long long y = (K-x*A) / B;
    if ((K - x*A) % B) continue;
    if (y < 0 || y > N) continue;
    long long c;
    c = comb(N, x);
    c *= comb(N, y);
    ans += c % mod;
  }
  ans %= mod;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 5616
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include <vector>   
using namespace std;
long long f(long long a){
	long long rem[]={a,1,a+1,0};
	return rem[abs(a)%4];
}
long long getxor(long long a,long long b){
	return f(b)^f(a-1);
}
int main()
{
	long long n,k;
	cin>>n>>k;
	if(n==0){
		cout<<k;
		return 0;
	}else if(k==0){
		cout<<n;
		return 0;
	}
	cout<<getxor(n,k);
	
}

Measured memory_bytes: 764