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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    string nums;
    cin >> nums;
    int i=0;
    if(nums[i] == 'A' && nums[i+1] == 'A' && nums[i+2] == 'A'){
        cout<<"No"<<"\n";
    }
    else if(nums[i] == 'B' && nums[i+1] == 'B' && nums[i+2] == 'B'){
        cout<<"No"<<"\n";
    }
    else{
        cout<<"Yes"<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
s1,s2=input(),input()
d1,d2={},{}
for i,j in zip(s1,s2):
  if i not in d1:
    d1[i]=1
  else:
    d1[i]+=1
  if j not in d2:
    d2[j]=1
  else:
    d2[j]+=1
d1=sorted(d1.items(),key=lambda x:x[1])
d2=sorted(d2.items(),key=lambda x:x[1])
for i,j in zip(d1,d2):
  if i[1]!=j[1]:
    print('No')
    break
else:
  print('Yes')

Measured memory_bytes: 9400
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        String a = sc.next();
        String b = sc.next();
        System.out.println(a.compareTo(b)> 0 ? ">" : (a.equals(b) ? "=" : "<"));
    }
}

Measured memory_bytes: 21972
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

string s[100000];
int counts[5];

int main()
{
	for (size_t i = 0; i < 5; i++)
	{
		counts[i] = 0;
	}

	int N;
	cin >> N;

	string march = "MARCH";
	for (size_t i = 0; i < N; i++)
	{
		cin >> s[i];
		for (size_t j = 0; j < 5; j++)
		{
			if (s[i][0] == march[j])
			{
				counts[j]++;
			}
		}
	}

	long long ans = 0;
	for (size_t i = 0; i < 5; i++)
	{
		for (size_t j = i + 1; j < 5; j++)
		{
			for (size_t k = j + 1; k < 5; k++)
			{
				ans += 1LL * counts[i] * counts[j] * counts[k];
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6144
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
long long ni(long long ta, vector<long long> & v) {

}
long long rui(long long n, long long k, long long p) {
	if (k == 0) {
		return 1;
	}
	else {
		long long a = rui(n, k / 2, p);
		if (k % 2 == 0) {
			return (a*a) % p;
		}
		return (((a*a) % p)*n) % p;
	}
}
int main(){
	int n, m; cin >> n >> m;
	long long sun = 0;
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		sun += a;
	}
	for (int i = 0; i < m; i++) {
		int a; cin >> a;
		sum += a;
	}
	cout << sun * sum << endl;
}


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

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

using ll = long long;

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

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<priority_queue<int>> v(N-1);
  rep(i,M){
    int x,y;
    cin>>x>>y;
    v[y-2].push(x-1);
  }
  int k = -1;
  int ans=0;
  rep(i,N-1){
    if(v[i].size()==0)continue;
    if(v[i].top()>k){
      k=i;
      ans++;
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;

long long prime = 1000000007LL;

long long pow(long long a, long long r) {
    if (r == 0) return 1LL;
    long long y = pow(a, r/2);
    long long z = (y * y) % prime;
    return r % 2 == 1 ? (z * a) % prime : z;
}

long long inv(long long a) {
    return pow(a, prime-2);
}

vector<long long> binoms(int r) {
    vector<long long> res(r+1, 1LL);
    for (int i = 0; i < r; ++i) {
        res[i+1] = (((res[i] * (r-i)) % prime) * inv(i+1)) % prime;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<long long> a = binoms(k-1), b = binoms(n-k+1);
    while (b.size() < k+1) {
        b.push_back(0);
    }
    for (int i = 1; i <= k; ++i) {
        cout << (a[i-1] * b[i]) % prime << "\n";
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
namespace io{
	const int l=1<<20;
	char buf[l],*s,*t;
	inline char gc(){
		if(s==t){
			t=(s=buf)+fread(buf,1,l,stdin);
			return s==t?EOF:*s++;
		}
		return *s++;
	}
	char c;
	template<class IT>inline void gi(IT &x){
		x=0;c=gc();while(c<'0'||c>'9')c=gc();
		while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=gc();}
	}
};
using io::gi;
template<class IT>inline void _int(      IT &a,      IT &b  ){if(a>b)swap(a,b);}
template<class IT>inline void cmin(      IT &a,const IT &b=0){if(a>b)a=b;}
template<class IT>inline void cmax(      IT &a,const IT &b=0){if(a<b)a=b;}
template<class IT>inline IT   _min(const IT &a,const IT &b=0){return a>b? b:a;}
template<class IT>inline IT   _max(const IT &a,const IT &b=0){return a<b? b:a;}
template<class IT>inline IT   _abs(const IT &a              ){return a<0?-a:a;}
const int p=998244353;
const ll P=996491788296388609ll;
inline int add(int a){return a<p?a:a-p;}
inline int sub(int a){return a<0?a+p:a;}
const int N=200005;

char y[N],x[N];
int dp[N];
int main(){
//	freopen("c.in","r",stdin);
//	freopen("c.out","w",stdout);
	int n,i,t,k,l,f;ll s=0ll;
	scanf("%d%s",&n,x+1);
	for(i=1;i<=n;++i)if(!(n%i)&&((n/i)&1)){
		f=1;t=0;
		for(k=1;k<=i;++k)t=add(t<<1|(x[k]^'0'));
//		printf("SOLVE i=%d t=%d\n",i,t);
		for(k=1;k<=i;++k)y[k]=x[k];for(k=i+1;k<=n;++k)y[k]=y[k-i]^1;
//		printf("%s %s\n",x+1,y+1);
		for(k=1;k<=n;++k){
			if(y[k]=='0'&&x[k]=='1')     break;
			if(y[k]=='1'&&x[k]=='0'){f=0;break;}
		}
		if(f)t=add(t+1);
//		printf("f=%d\n",f);
		for(k=1;k< i;++k)if(!(i%k)&&((n/k)&1))t=sub(t-dp[k]);
		if((s+=(dp[i]=t)*((ll)i))>=P)s-=P;
	}
	printf("%d",add(((int)(s%p))<<1));
	return 0;
}

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

int main() {

    int N=0;
    cin >> N;

    vector<pair<int, int>> a;

    vector<string> S(N);
    vector<int> P(N, 0);
    vector<int> cnt(N,1);

    for(int i=0; i<N; i++){
        cin >> S.at(i) >> P.at(i);
    }

    for(int i=0; i<N; i++){
        string x = S.at(i);
        
        for(int j=0; j<N; j++){
            string y = S.at(j);

            if(x.compare(y) > 0 && i!=j){
                cnt.at(i) = cnt.at(i) + 1;
            }
            else if(x.compare(y) == 0 && i!= j){
                if(P.at(i) < P.at(j)){
                    cnt.at(i) = cnt.at(i) + 1;
                }
            }

        }
    }

    for(int i=0; i<N; i++){
        a.push_back(make_pair(cnt.at(i), i+1));
    }

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

    for(auto t: a){
        int x, y=0;
        tie(x, y) = t;
        cout << y << endl;
    }

}


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

int dp[100];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	int n = s.size();
	long long int k;
	cin>>k;
	dp[0]=1;
	for(int i=1;i<n;i++)
		if(s[i]==s[i-1])
			dp[i]=dp[i-1]+1;
		else
			dp[i]=1;
	if(dp[n-1]==n)
		cout<<n*k/2<<endl;
	else{
		if(s[0]==s.back()){
			int l=1,r=1;
			while(s[l]==s[l-1])	l++;
			while(s[n-r-1]==s[n-r])	r++;
			int cnt = 0;
			for(int i=l;i<n-r;i++)
				if(dp[i]%2==0)
					cnt++;
			cout<< cnt * k + l/2 + r/2 + (l+r) /2 *(k-1)<<endl;
		}
		else{
			int cnt=0;
			for(int i=0;i<n;i++)
				if(dp[i]%2==0)	cnt++;
			cout<<cnt*k<<endl;
		}
	}
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll H, N;
    cin >> H >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll s = accumulate(A.begin(), A.end(), 0LL);
    if (s >= H) {
        cout << "Yes" << '\n';
    }else{
        cout << "No" << '\n';
    }

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1024
N,X,Y = list(map(int,input().split()))
ans = [0 for i in range(N-1)]
for i in range(1,N):
    for j in range(i+1,N+1):
        A = min(j-i,abs(j-Y)+abs(X-i)+1)
        ans[A-1] += 1
for i in range(N-1):
    print(ans[i])

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 205;

struct state
{
    double px,py,pz,vx,vy,vz,r,vr;
};

struct relate
{
    double t;
    int u,v;
    bool operator<(const relate& another) const {
        return t < another.t;
    }
};

int n;
vector<state> v;
double vanish_time[MAX_N][MAX_N];

double dir(double a,double b,double c,double d,double e,double f)
{
    return (a-d)*(a-d)+(b-e)*(b-e)+(c-f)*(c-f);
}

double v_t(const state& v1,const state& v2)
{
    double a = dir(v1.vx,v1.vy,v1.vz,v2.vx,v2.vy,v2.vz) - (v1.vr+v2.vr)*(v1.vr+v2.vr);
    double b = (v1.vx-v2.vx)*(v1.px-v2.px) + (v1.vy-v2.vy)*(v1.py-v2.py) + (v1.vz-v2.vz)*(v1.pz-v2.pz) + (v1.vr+v2.vr)*(v1.r+v2.r);
    double c = dir(v1.px,v1.py,v1.pz,v2.px,v2.py,v2.pz) - (v1.r+v2.r)*(v1.r+v2.r);
    if(a > 0){
        if(b*b - a*c >= 0){
            double hoge = (-b - sqrt(b*b-a*c)) / a;
            return hoge > 0?hoge:INF;
        }else{
            return INF;
        }
    }else if(a == 0){
        if(b < 0){
            return -c / (2*b);
        }else{
            return INF;
        }
    }else{
        if(b*b - a*c >= 0){
            double hoge = (-b + sqrt(b*b-a*c)) / a;
            return hoge > 0?hoge:INF;
        }else{
            return INF;
        }
    }
}

int main()
{
    while(1){
        cin >> n;
        if(n == 0){
            break;
        }
        v.clear();
        rep(i,n){
            double a,b,c,d,e,f,g,h;
            cin >> a >> b >> c >> d >> e >> f >> g >> h;
            v.pb((state){a,b,c,d,e,f,g,h});
        }
        rep(i,n){
            vanish_time[i][i] = v[i].r/v[i].vr;
            for(int j=i+1;j<n;j++){
                vanish_time[i][j] = v_t(v[i],v[j]);
                vanish_time[j][i] = vanish_time[i][j];
            }
        }
        vector<double> ans(n);
        rep(i,n){
            ans[i] = 0.0;
        }
        vector<relate> vec;
        rep(i,n){
            rep(j,n){
                vec.pb((relate){vanish_time[i][j],i,j});
            }
        }
        sort(all(vec));
        rep(i,vec.size()){
            relate bf = vec[i];
            if(ans[bf.u] == 0 && ans[bf.v] == 0){
                ans[bf.u] = bf.t;
                ans[bf.v] = bf.t;
            }
        }
        rep(i,n){
            printf("%.10f\n",ans[i]);
        }
    }
    return 0;
}

Measured memory_bytes: 4896
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n = I()
P = LI()
ans = 0
tmp = INF
for i in range(n):
    if P[i] < tmp:
        ans += 1
        tmp = P[i]
print(ans)

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

template <typename T> T gcd(T a, T b) {
	if (b == 0) return abs(a);
	T r; while ((r = a % b) != 0) a = b, b = r;
	return abs(b);
}
template <typename T> T lcm(T a, T b) {
	return a/gcd(a, b) * b;
}

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

    ll N, M; cin >> N >> M;
    string S; cin >> S;
    string T; cin >> T;

    ll L = lcm(N, M);
    ll ans = L;
    for (ll i = 0; i < L; i += lcm(L/N, L/M)) {
        // D3(i, S[i / (L/N)], T[i / (L/M)]);
        if (S[i / (L/N)] != T[i / (L/M)]) {
            ans = -1;
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
import sys
rr = lambda: sys.stdin.readline().strip()
ri = lambda: int(rr())
rs = lambda: [int(_) for _ in rr().split()]

A, B, K = rs()
L = []

for i in range(1, 101):
	if A % i == 0 and B % i == 0:
		L.append(i)

print(L[-K])

Measured memory_bytes: 3064
from collections import deque
import sys


H, W = [int(_) for _ in input().split()]

M = []
q = deque([])
for i in range(H):
    A = input()
    M.append(list(A))
    for j in range(W):
        if A[j] == '#':
            q.append([j, i, 0])

depth_now = 0
depth = 0
count = 0
while len(q) > 0:
    p = q.popleft()
    x = p[0]
    y = p[1]
    depth = p[2]
    if x - 1 >= 0 and M[y][x-1] == '.':
        q.append([x-1, y, depth+1])
        M[y][x-1] = '#'
    if x + 1 < W and M[y][x+1] == '.':
        q.append([x+1, y, depth+1])
        M[y][x+1] = '#'
    if y - 1 >= 0 and M[y-1][x] == '.':
        q.append([x, y-1, depth+1])
        M[y-1][x] = '#'
    if y + 1 < H and M[y+1][x] == '.':
        q.append([x, y+1, depth+1])
        M[y+1][x] = '#'
print(depth)


Measured memory_bytes: 171612
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
ll gcd(ll a, ll b){
    if(b == 0) return a;
    gcd(b,a%b);
}


//全てのTの最小公倍数を求める
//2数A,BのLCMはA*B/GCD
//12,18,24
//隣り合う2数Ti,Ti+1のLCMを求める操作を繰り返す

int main() {
    ll N;
	cin >> N;
	vector<ll> T(N);
	for(ll i = 0;i<N;i++){
		cin >> T[i];
	}
	if(N == 1) cout << T[0] << endl;
    else{
	ll ans = (T[0]/gcd(T[0],T[1]))*T[1];
	for(ll i = 2;i<N;i++){
     ans = (ans/gcd(ans,T[i]))*T[i];
	}
	cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include<math.h>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define    ll   long long int
#define    py   printf("Yes\n")
#define    pn   printf("No\n")
using namespace std;

ll hako[200000];
int main()
{
    int n,tmp=0;
    cin>>n;
    int p[n];
    for(int i=0;i<n;i++)
    {
      cin>>p[i];
    }
    sort(p,p+n);
    for(int i=0;i<n-1;i++)
    {
      tmp+=p[i];
    }
    cout<<tmp+p[n-1]/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define lli long long int
#define all(v) (v.begin(),v.end())
#define fr first
#define sc second
#define mp make_pair
using namespace std;

int main()
{
    int n,i;
    cin>>n;
    int a[n][3];
    rep(i,n)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    int dp[n][3];
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(i=1;i<n;i++)
    {
        dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
    }
    cout<<max(dp[n-1][1],max(dp[n-1][0],dp[n-1][2]));
}


Measured memory_bytes: 5880
import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		char[] n  = sc.nextLine().toCharArray();
		String ans = "No";
		long culc = 0;

		for(char num : n) {
			culc += Integer.parseInt(String.valueOf(num));
		}
		
		if(culc % 9 == 0) {
			ans = "Yes";
		}
		
		System.out.println(ans);
		sc.close();
	}
}




Measured memory_bytes: 51268
n, m = map(int, input().split())
bool_lst = [False] * n
ac_lst = [0] * n
wa_lst = [0] * n
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if bool_lst[p] == False:
        if s == 'AC':
            bool_lst[p] = True
            ac_lst[p] += 1
        else:
            wa_lst[p] += 1

ac_cnt = 0
wa_cnt = 0
for i in range(n):
    if bool_lst[i] == True:
        ac_cnt += ac_lst[i]
        wa_cnt += wa_lst[i]

print(ac_cnt, wa_cnt)

Measured memory_bytes: 5364
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <string>
#include <complex>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

typedef vector<int> vi;

int main() {
	int n;
	while(scanf("%d", &n)!=EOF) {
		int s = 0;
		int w = 600 / n;
		rep(i,w) {
			int h = n * i;
			s += h * h * n;
		}
		printf("%d\n", s);
	}
}

Measured memory_bytes: 1188
s = input().split()
num = [int(i) for i in input().split()]
u = input()
num1 = num[0]
num2 = num[1]

if s[0] == u:
    nums = num1 - 1
    print("{} {}".format(nums, num2))
elif s[1] == u:
    nums = num2 - 1
    print("{} {}".format(num1, nums))


Measured memory_bytes: 2940
#include <bits/stdc++.h>//toINFandByd
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define endl "\n"
using namespace std;
typedef long long ll;

void solve(){
    //crane - 2legs
    //turtle - 4legs
    int x,y;
    cin >> x >> y;
    int c = 0,t = 0;
    int r = y-2*x;
    if(r>=0 && r%2==0){
        t = r/2;
        c = x-t;
        if(t>=0 && c>=0 ){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
        return;
    }

    cout << "No" << endl;
}   

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,x;
  cin >> N >> x;
  int a[109];
  for(int i = 0; i <N ; i++)cin >> a[i];
  sort(a,a+N);
  int sum = 0;
  int count = 0;
  for(int i = 0; i < N; i++){
      sum+= a[i];

    if(sum > x){
      break;
    }
    else{
      count++ ;
    }
  }
  if(sum < x && count == N ){
    cout << count-1 << endl;
  }
  else{
    cout << count << endl;
  }
}

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

int main() {
    int N, M; cin >> N >> M;
    priority_queue<int> A;
    REP(i, 0, N) {
        int a; cin >> a;
        A.push(a);
    }

    REP(i, 0, M) {
        int value = A.top(); A.pop();
        A.push(value / 2);
    }

    ll ans = 0;
    while (!A.empty()) {
        ans += A.top();
        A.pop();
    }

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

Measured memory_bytes: 892
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

struct Info
{
	int p, s;

	Info()
	{

	}

	Info(int p, int s)
	{
		this->p = p;
		this->s = s;
	}
};

int main()
{
	vector<Info> a;

	string str;
	for (; cin >> str;)
	{
		stringstream ss;
		ss << str;

		int p, s;
		ss >> p;
		ss.ignore();
		ss >> s;

		if (p == 0 && s == 0)
		{
			break;
		}

		a.push_back(Info(p, s));
	}

	sort(a.begin(), a.end(),
		[](const Info &a, const Info &b)
	{
		return a.s < b.s;
	});

	reverse(a.begin(), a.end());

	int x;
	for (; cin >> x;)
	{
		int old = -1;
		int rank = 0;
		for (int i = 0; i < a.size(); i++)
		{
			if (old != a.at(i).s)
			{
				rank++;
			}

			if (x == a.at(i).p)
			{
				cout << rank << endl;
				break;
			}

			old = a.at(i).s;
		}
	}
}


Measured memory_bytes: 3120
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl



int main(){
	stack<li> stk;
	li x;
	while(cin>>x){
		if(x==0){
			cout<<stk.top()<<endl;
			stk.pop();
		}
		else{
			stk.push(x);
		}
	}
	
	return 0;
}

Measured memory_bytes: 1196
m, n = gets.split.map &:to_i
if m > 2 and n > 2
  p (m-2) * (n-2)
else
  if m == 2 or n == 2
    p 0
  elsif m == 1
    if n == 1
      p 1
    else
      p n-2
    end
  else
    p m-2
  end
end

Measured memory_bytes: 14324
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, T; 
    cin >> n >> T;
    int a[n + 1];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    a[n] = INT64_MAX;
    vector<pii> v;
    v.push_back({a[0], a[0]});
    for(int i = 0; i < n; i++) {
        if(a[i + 1] - a[i] > T) {
            v.back().se = a[i] + T;
            v.push_back({a[i + 1], a[i + 1]});
        }
    }
    int ans = 0;
    for(int i = 0; i < sz(v); i++) {
        ans += v[i].se - v[i].fi;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1792
#include <iostream>
#include <set>
#include <vector>
#include <string>

bool search(const std::string &s, const std::set<int> &ok_set,
            const int d, const bool only_upper, std::vector<int> &result)
{
    const int v = s[d] - '0';
    bool tmp_only_upper = only_upper;
    for (const int o : ok_set)
    {
        if (tmp_only_upper && o < v)
        {
            continue;
        }
        result[d] = o;
        if (d == s.size() - 1)
        {
            return true;
        }
        else
        {
            const bool status = search(s, ok_set, d + 1, only_upper && v == o, result);
            if (status)
            {
                return true;
            }
            tmp_only_upper = true;
        }
    }
    return false;
}

int main()
{
    int n, k;
    std::cin >> n >> k;
    // trueなら使える
    std::vector<bool> flags(10, true);
    std::set<int> ok_set;
    for (int i = 0; i < k; ++i)
    {
        int tmp;
        std::cin >> tmp;
        flags[tmp] = false;
    }
    for (int i = 0; i < 10; ++i)
    {
        if (flags[i])
        {
            ok_set.emplace(i);
        }
    }

    const std::string s = std::to_string(n);
    std::vector<int> result(s.size());

    const bool status = search(s, ok_set, 0, true, result);
    if (status)
    {
        for (const int v : result)
        {
            std::cout << v;
        }
        std::cout << std::endl;
    }
    else
    {
        // 一桁増える
        bool zero = false;
        for (const int v : ok_set)
        {
            if (v == 0)
            {
                zero = true;
                continue;
            }
            if (zero)
            {
                std::cout << v;
                for (int i = 0; i < s.size(); ++i)
                {
                    std::cout << 0;
                }
                std::cout << std::endl;
            }
            else
            {
                for (int i = 0; i < s.size() + 1; ++i)
                {
                    std::cout << v;
                }
                std::cout << std::endl;
            }
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHIM
//SOTO MEAW
//SOTO SONDESH
#include<bits/stdc++.h>

#define ls ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define __ <<" "<<
#define case(z) "Case " << z++ << ": "
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define quit return 0

using namespace std;

void showmyDS(set<int> ds)
{
    set<int> ::iterator it;
    for (it=ds.begin();it!=ds.end();it++)
    {
        cout << *it << endl ;
    }
    cout << endl;
}
int main()
{
    ls
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //int t,l=1;cin>>t;while(t>0){
        int n,l,i;
        cin >> n >> l ;
        string a[n];
        for(i=0;i<n;i++)
            cin >> a[i];
        sort(a,a+n);
        for(i=0;i<n;i++)
            cout << a[i];
    //t--;}

    quit;
}


Measured memory_bytes: 3620
//Don't give up too easy bhai
#pragma GCC optimize("-O3")
 
#include<bits/stdc++.h>
using namespace std;

#define int long long int
#define double long double
#define inf 1e18

typedef pair<int,int> pii;
 
#define forall(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define vi vector<int>
#define vd vector<double>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007
#define br cout<<"\n"
#define whatis(x) cerr << "var "<<#x << " ==> " << x<<"\n"
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define T int __t;cin>>__t;while(__t--)

void solve()
{
    
}

signed main()
{
    fast;

    int n;string s;cin>>n>>s;
    int cnt = count(all(s),'R');
    int x = count(s.begin(),s.begin()+cnt,'R');
    cout<<llabs(cnt-x); 


    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int N = S.size();
  int red = 0;
  int blue = 0;
  for(int i = 0; i< N; i++){
    if(S.at(i) == '0'){
      red++;
    }
    else if(S.at(i) == '1'){
      blue ++;
    }
  }
  int min1 = min(red,blue);
  int ans = 2 * min1;
  cout << ans << endl;
}

Measured memory_bytes: 512
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i32 = read();
    let r: i32 = read();

    let ans = if n >= 10 { r } else { r + 100 * (10 - n) };

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include<algorithm>
#include <iomanip>
#include <math.h>

using namespace std;
typedef long long ll;
///定義場所///
int i, j, k, l, m, n;
int N, M, K;
ll MOD = 1000000007;
int ans = 0;

//関数リスト//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
//(注)pairの型・比較する場所(first/second)は毎回変えて使用する
bool pairCompare(const pair<int ,int> firstElof, pair<int,int> secondElof)
{
	return firstElof.second > secondElof.second;
}
int Keta(ll F) {
	int keta = 1;
	while (F/10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
//////////////

int main()
{
	int N;
	cin >> N;
	vector<int>W(N);
	vector<int> sum(N);
	for (i = 0; i < N; i++) {
		cin >> W[i];
	}
	for (i = 0; i < N; i++) {
		if (i == 0) {
			sum[0] = W[0];
		}
		else {
			sum[i] = sum[i - 1] + W[i];
		}
	}
	int ans = 100000;
	for (i = 0; i < N - 1; i++) {
		ans = min(ans, abs((sum[N - 1] - sum[i]) - sum[i]));
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

#define forll(s,a,b) for(long long s = a;s < b;s++)

using namespace std;

bool isInFirld(int col, int row, const pair<int, int> &point)
{
	const int c = point.second;
	const int r = point.first;
	return (0 <= c && c < col) && (0 <= r && r < row);
}

int bfs(int h,int w,vector<string> map)
{
	pair<int, int> start, goal;
	bool checkFlag = false;

	start.first = 0;
	start.second = 0;

	goal.first = h-1;
	goal.second = w-1;

	vector<vector<int>> memo;
	for (int i = 0; i < map.size(); ++i) {
		vector<int> v(map[i].size(), -1);
		memo.push_back(v);
	}

	if (map[0][0] == '.')
		memo[0][0] = 0;
	else
		memo[0][0] = 1;

	const pair<int, int> points[2] = {
		{ 1, 0 }, { 0, 1 }
	};

	queue<pair<int, int>> data;
	data.push(start);

	while (!data.empty()) {

		pair<int, int> cur = data.front();
		data.pop();

		if (cur == goal) {

			checkFlag = true;
		}

		for (const auto &point : points) {

			pair<int, int> next = { (cur.first + point.first), (cur.second + point.second) };

			if (isInFirld(map[0].size(), map.size(), next)) {

				const char s = map[next.first][next.second];

				if (s == '#') {
					if (map[cur.first][cur.second] == '#')
					{
						if (memo[next.first][next.second] == -1 || memo[next.first][next.second] > memo[cur.first][cur.second]) {

							data.push(next);

							memo[next.first][next.second] = memo[cur.first][cur.second];
						}
					}	
					else
					{
						if (memo[next.first][next.second] == -1 || memo[next.first][next.second] > memo[cur.first][cur.second] + 1) {

							data.push(next);

							memo[next.first][next.second] = memo[cur.first][cur.second] + 1;
						}
					}
				}
				else
				{
					if (memo[next.first][next.second] == -1 || memo[next.first][next.second] > memo[cur.first][cur.second]) {

						data.push(next);

						memo[next.first][next.second] = memo[cur.first][cur.second];
					}
				}
			}
		}
	}

	if (checkFlag)
	{
		return memo[goal.first][goal.second];
	}
	else
	{
		return -1;
	}
}

int main()
{
	int h, w,ans=0;

	cin >> h >> w;

	vector<string> s(h);
	char buf;

	forll(i,0, h)
	{
		forll(j,0, w)
		{
			cin >> buf;
			s[i].push_back(buf);
		}
	}

	ans = bfs(h, w, s);

	cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n, k; cin >> n >> k;
    vector<int> a(n); for(int i = 0; i < n; i++) cin >> a[i];

    int ans = 0;
    for(int left = 0; left <= k; left++) {
        for(int right = 0; right <= k - left; right++) {
            if(left + right > n) break;
            int dispose = k - left - right;
            int now = 0;
            vector<int> s;
            for(int i = 0; i < left; i++) {
                now += a[i];
                s.push_back(a[i]);
            }
            for(int i = n - right; i < n; i++) {
                now += a[i];
                s.push_back(a[i]);
            }
            sort(s.begin(), s.end());
            for(int i = 0; i < dispose; i++) {
                if(i >= s.size()) break;
                if(s[i] > 0) break;
                now -= s[i];
            }
            ans = max(ans, now);
        }
    }

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


Measured memory_bytes: 256
import math

N = int(input())

result = 0
n = math.sqrt(N)
n = math.ceil(n)

for i in range(1, n + 1):
    for j in range(i, N // i + 1):
        if i * j < N:
            if i == j:
                result += 1
            else:
                result += 2
        else:
            break
print(result)

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

int main() {
	bool n,a,sum;
  string s;
  	cin>>s;
  int b,c;
  	a=0;b=0;c=0;
  if(s.at(0)=='A')
    a=1;
  
  for(int i=2;i<s.size()-1;i++){
  	if(s.at(i)=='C'){
    b++;
    }
  }
  
  for(int i=0;i<s.size();i++){
  	if(s.at(i)>'z'||s.at(i)<'a')
      c++;
  }
  
    if(a==1&&b==1&&c==2)
      cout<<"AC"<<endl;
  else
    cout<<"WA"<<endl;
    
    
return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.array, std.conv;

void main() {
    string row;
    foreach (i; 0 .. 300) row ~= "#";
    while (true) {
        int[] tmp = readln.chomp.split.to!(int[]);
        int h = tmp[0], w = tmp[1];
        if (h == 0 && w == 0) break;
        foreach (i; 0 .. h) row[0..w].writeln;
        writeln;
    }
}


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

int main() {
    int k;
    cin >> k;
    int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << arr[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl '\n'
typedef vector<vector<ll>> matrix;
const ll INF = 1e18;
const int MAX = 2e5+4;
const int MOD = 1e9+7;
;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,x;
	cin >> n >> x;
	vector<int> a(n);
	vector<int> dp(n+1);
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}
	for(int i=1;i<=n;i++)
	{
		dp[i]=dp[i-1]+a[i-1];
	}
	sort(dp.begin(),dp.end());
	cout << upper_bound(dp.begin(),dp.end(),x)-dp.begin();
	return 0;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  int c=0;
  for(int i=0;i<2;i++){
	  if(a>=b){
      c+=a;
  	  a--;
	  }
 	 else{
	  c+=b;
  	  b--;
 	 }
  }
  cout<<c<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  char a, b;
  cin >> a >> b;
  char c = min(a, b);
  char d = max(a, b);
  int ic = c - '0';
  int id = d - '0';
  string ans = "";

  rep(i, id) ans = ans + c;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ref(i,n) for(int i=0;i<n;i++)
using namespace std;
#define INF 111111111111
#define mod 998244353
typedef long long ll;
typedef pair<int,int> P;
int n,m;
//ll a[200000],b[200000],c[200000];


int main()
{
ll a,b,v,w,t;
cin>>a>>v>>b>>w>>t;
        if(w>=v) cout<<"NO";
else{
    if(a>b) swap(a,b);
    if((v-w)*t<b-a) cout<<"NO";
    else cout<<"YES";
}
    return 0;
        }

Measured memory_bytes: 3632
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        int a = 1;
        for (int i = 0; i < n; i++) {
            a = Math.min(a * 2, a + k);
        }
        System.out.println(a);
    }

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

int n;
vector<int> G[100010];
int d1[100010], d2[100010];

void dfs1(int now, int pre)
{
    rep(i, G[now].size())
    {
        if (G[now][i] == pre)
            continue;
        int nxt = G[now][i];
        d1[nxt] = d1[now] + 1;
        dfs1(nxt, now);
    }
}
void dfs2(int now, int pre)
{
    rep(i, G[now].size())
    {
        if (G[now][i] == pre)
            continue;
        int nxt = G[now][i];
        d2[nxt] = d2[now] + 1;
        dfs2(nxt, now);
    }
}

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

    int u, v;
    cin >> n >> u >> v;
    u--, v--;
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    if (G[u].size() == 1 && G[u][0] == v)
    {
        cout << 0 << endl;
        return 0;
    }
    dfs1(u, -1);
    dfs2(v, -1);
    int ans = 0;
    rep(i, n)
    {
        if (d1[i] < d2[i])
            ans = max(ans, d2[i] - 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 11264
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

std::vector<int> primeNumbers;
std::vector<bool> isPrime;

void eratosthenes(int n){
    int i, j;
    int s = 4;

    primeNumbers.clear();
    primeNumbers = {2, 3};

    isPrime.assign(std::max(n + 1, 2), true);
    isPrime[0] = false;
    isPrime[1] = false;

    for(i = 4 ; i <= n ; i += 2){
        isPrime[i] = false;
    }
    for(i = 9 ; i <= n ; i += 6){
        isPrime[i] = false;
    }

    for(i = 5 ; i * i <= n ; i += s){
        if(isPrime[i]){
            primeNumbers.emplace_back(i);
            for(j = i * i ; j <= n ; j += i){
                isPrime[j] = false;
            }
        }
        s ^= 6;
    }
    for( ; i <= n ; i += s){
        if(isPrime[i]){
            primeNumbers.emplace_back(i);
        }
        s ^= 6;
    }

    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int x;
    cin >> x;

    eratosthenes(1010101);
    cout << *lower_bound(primeNumbers.begin(), primeNumbers.end(), x) << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N;
    cin>>N;
    if(N%2==1) cout << 0 << endl;
    else{
        int ans=0;
        int i=0;
        int n=N;
        ans+=n/10;
        n/=10;
        while(n>0){
            ans+=n/5;
            n/=5;
        }
        n=N;
        
        
        cout << ans << endl;
    }



}


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

using namespace std;
typedef long long ll;

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

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

    cout << n / 2 * (n - n / 2) << '\n';
    return 0;
}


Measured memory_bytes: 3576
#!/usr/bin/python3
# -*- coding: utf-8 -*-


"""
https://beta.atcoder.jp/contests/abc051/tasks/abc51_c
"""

import sys
import math
from inspect import currentframe

def debug(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=sys.stderr)

sx, sy, tx, ty = map(int, input().split())

# 例であるような経路が必ず最短になる
dx = tx - sx
dy = ty - sy

s_to_t_1st = 'U' * dy + 'R' * dx
t_to_s_1st = 'D' * dy + 'L' * dx

# 一度目の経路を迂回する経路
s_to_t_2nd = 'L' + 'U' * (dy + 1) + 'R' * (dx + 1) + 'D'
t_to_s_2nd = 'R' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U'

print(s_to_t_1st + t_to_s_1st + s_to_t_2nd + t_to_s_2nd)









Measured memory_bytes: 4648
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

var sc = newScanner()

func rank(a []int, f []int) int {
	n := len(a)
	m := make(map[int]bool)
	res := 1
	for i := 0; i < n; i++ {
		x := a[i]
		m[x] = true
		c := 0
		for j := 1; j < x; j++ {
			if !m[j] {
				c++
			}
		}
		res += c * f[n-i-1]
	}
	return res
}

func main() {
	n := scanInt()
	p := scanInts(n)
	q := scanInts(n)
	f := make([]int, 9)
	f[0], f[1] = 1, 1
	for i := 1; i < len(f); i++ {
		f[i] = f[i-1] * i
	}

	ans := rank(p, f) - rank(q, f)
	if ans < 0 {
		ans = -ans
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
/*
Author : Gaurav Singh
*/
#include<bits/stdc++.h>
using namespace std;
#define N 5005
#define MOD 1000000007
#define ll long long
#define ld long double
#define ull unsigned long long
#define li long int
#define str string
#define vll vector<ll>
#define pb push_back
#define frn(i,n) for(ll (i) = 0; (i) <(n) ; (i)=(i+1))
#define fr(i,n) for(ll (i) = 1; (i) <=(n) ; (i)=(i+1))
#define frev(i,n) for(ll (i) = n-1; (i) >=(0) ; (i)--)
#define fr1(j,a,b,c) for(ll (j) = a; (j) <c ; (i)=(i+b))
#define w(t) while(t--)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
map<ll,ll> m;
void primeFactors(ll n)  
{  ll c=0;
    while (n % 2 == 0)  
    {  
        n = n/2;  
        c++;
    }  
    if(c){
        m[2]=c;
    }
    //cout<<c<<" ";
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {   c=0;
        while (n % i == 0)  
        {  
            n = n/i;  
            c++;
        }  
        if(c){
            m[i]=c;
            //cout<<c<<" ";
        }
    }
    if (n > 2)  
        m[n]=1;
        //cout<<n<<" ";
}  
void solve(){
    ll n,i,ans=0;
    cin>>n;
    primeFactors(n);
    for(auto it=m.begin();it!=m.end();it++){
        //cout<<it->first<<" "<<it->second;
        for(i=1;;i++){
            if(it->second >=i){
                ans++;
                it->second-=i;
            }
            else{
                break;
            }
        }
    }
    cout<<ans;
}
int main()
{   
   fast;
   int t=1;
   //cin>>t;
    w(t){
        solve();
    }
   return 0;
}   
            

Measured memory_bytes: 3700
def main():
    n = int(input())
    a = [0] + [int(input()) for _ in range(n)]
    checked = [False for _ in range(n + 1)]
    answer = 0
    ind = 1
    while True:
        answer += 1
        checked[ind] = True
        ind = a[ind]
        if checked[ind]:
            answer = -1
            break
        elif ind == 2:
            break
    print(answer if answer > -1 else -1)


if __name__ == '__main__':
    main()



Measured memory_bytes: 7888
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  ll h;
  cin >> h;
  ll digit = 1;
  ll ans = 0;
  ll cur = h;
  while(true){
    ans += digit;
    if(cur == 1) break;
    digit *= 2;
    cur /= 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
MOD = 10**9+7
n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))
dp = [[0 for _ in range(m+1)] for _ in range(n+1)]
dp[0][0] = 1
cum = [[0 for _ in range(m+1)] for _ in range(n+1)]
cum[0][0] = 1
for i in range(1, n+1):
	cum[i][0] = 1
for j in range(1, m+1):
	cum[0][j] = 1

for i in range(1, n+1):
	for j in range(1, m+1):
		if s[i-1] == t[j-1]:
			dp[i][j] = cum[i-1][j-1]
			dp[i][j] %= MOD
		cum[i][j] = cum[i-1][j] + cum[i][j-1] - cum[i-1][j-1] + dp[i][j]
		cum[i][j] %= MOD

print(cum[n][m])

Measured memory_bytes: 108124
n = int(input())
 
start = 0
startX = 0
startY = 0
 
for i in range(n):
    t, x, y = map(int, input().split())
    t_diff = t - start
    dis = abs(x - startX) + abs(y - startY)
    if t_diff < dis or (dis + t_diff) % 2 != 0:
        print('No')
        exit()
    start, startX, startY = t, x, y
print('Yes')

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

int main() {
  int64_t n, k, l, c = 0, s, b, answer, asum = 0;
  cin >> n >> k;
  vector<int64_t> a(n), f(n);
  for(int64_t i = 0; i < n; i++){
    cin >> a.at(i);
    asum += a.at(i);
  }
  for(int64_t i = 0; i < n ;i++)
    cin >> f.at(i);
  sort(a.begin(), a.end());
  sort(f.begin(), f.end());
  reverse(f.begin(), f.end());
  priority_queue<int64_t> pq;
  for(int64_t i = 0; i < n; i++)
    pq.push(a.at(i)*f.at(i));
  s = pq.top();
  while(pow(2, c) < s) c++;
  c--;
  b = pow(2, c);
  for(int64_t i = c-1; i >= 0; i--){
    l = k;
    bool d = 1;
    for(int64_t j = 0; j < n; j++)
      if(b < a.at(j)*f.at(j)) l -= a.at(j) - b / f.at(j);
    if(l < 0) d = 0;
    if(d){
      answer = b;
      b -= pow(2, i);
    }
    else b += pow(2, i);
  }
  l = k;
  bool d = 1;
  for(int64_t j = 0; j < n; j++){
    if(b < a.at(j)*f.at(j)) l -= a.at(j) - b / f.at(j);
  }
  if(l < 0) d = 0;
  if(d) answer = b;
  if(asum <= k) answer = 0;
  cout << answer << endl;
}

Measured memory_bytes: 5492
#include<iostream>
using namespace std;
int main(){
    string a;
    cin >> a;
    if(a=="A"){
      cout<<"T"<<endl;
    }
  else    if(a=="T"){
      cout<<"A"<<endl;
    }
  else if(a=="G"){
      cout<<"C"<<endl;
    }
  else{
  cout<<"G"<<endl;
  }
}

Measured memory_bytes: 256