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

int n;
int x[24],y[24],r[24],c[24];
bool overlap[24][24];
bool memo[1<<24];

bool ok(int a,int bit){
    for(int i=0;i<a;i++)if((bit>>i)&1){
        if(overlap[a][i])return false;
    }
    return true;
}

int dfs(int bit){
    memo[bit]=true;

    int ret=n;
    for(int i=0;i<n;i++)if((bit>>i)&1)ret--;

    for(int i=0;i<n-1;i++){
        if(((bit>>i)&1)==0||ok(i,bit)==false)continue;
        for(int j=i+1;j<n;j++){
            if(c[i]!=c[j]||((bit>>j)&1)==0)continue;
            int to_bit=(bit^(1<<i))^(1<<j);
            if(ok(j,bit)&&!memo[to_bit]){
                ret=max(ret,dfs(to_bit));
            }
        }
    }


    return ret;
}

void solve(){
    fill_n(memo,1<<n,false);

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int dist=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
            int sum=(r[i]+r[j])*(r[i]+r[j]);
            overlap[i][j]=dist<sum;
        }
    }
    cout<<dfs((1<<n)-1)<<endl;
}

bool input(){
    cin>>n;
    if(!n)return false;
    for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>r[i]>>c[i];
    return true;
}



int main(){
    while(input())solve();
    return 0;
}

Measured memory_bytes: 17544
n,a,b = map(int,input().split())
mod = 10**9 + 7

def bi(x):
    o = []
    while x != 0:
        o.append(x%2)
        x //= 2
    return o

def modpow(m,n):
    o = bi(n)
    leo = len(o)
    p = [m]*leo
    for i in range(1,leo):
        a = p[i-1]
        a *= a
        a %= mod
        p[i] = a
    b = 1
    for i in range(leo):
        if o[i] != 1:
            continue
        b *= p[i]
        b %= mod
    return b

def combi(a,b):
    aa = a
    mom = 1
    child = 1
    for _ in range(1,b+1):
        mom *= aa
        aa -= 1
        mom %= mod
        child *= _
        child %= mod
    return mom * modpow(child,mod-2) % mod

print((modpow(2,n)-combi(n,a)-combi(n,b)-1)%mod)

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

#define QQ 9
int main() {
	for (int i = 1; i <= QQ; i++) {
		for (int j = 1; j <= QQ; j++) {
			cout << i << "x" << j << "=" << i * j << "\n";
		}
	}
	return 0;
}

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

// nの約数を算出
vector<ll> yaku(ll n) {
	vector<ll> ans;
	for (ll i=1;i*i<=n;++i) {
		if (n%i==0) {
			ans.push_back(i);
			if (i*i!=n) ans.push_back(n/i);
		}
	}
	sort(ans.begin(), ans.end());
	return ans;
}

// a^b
ll pow_ll(ll a, ll b) {
	ll ans = 1;
	rep(i,b) ans *= a;
	return ans;
}

int main() {
	ll n;
	cin >> n;
	ll ans = 0;
	ans += yaku(n-1).size() - 1;
	for (ll k : yaku(n)) {
		if (k >= 2) {
			ll n_tmp = n;
			while(1) {
				ll r = n_tmp % k;
				if (r==0) n_tmp /= k;
				else {
					if (r==1) ans++;
					break;
				}
			}
		}
	}

	/*
	vector<ll> div = yaku(n-1);
	for (ll a : div) {
		if (a*a > n) ans++;
	}

	for (ll k=2;k*k<=n;k++) {
		ll m = 0;
		while(n >= pow_ll(k,m)) {
			ll km = pow_ll(k,m);
			if (n % km == 0LL) {
				ll nkm = n / km;
				if ((nkm >= 1LL) && ((nkm - 1LL) % k == 0LL)) {
					ans++;
				}
			}
			m++;
		}
	}
	*/

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


Measured memory_bytes: 384
integer(16) N,M,K
integer(16) waruno
integer(16) ans,tmp,i,j,com
read*,N,M,K
waruno=10**9+7
com=combination(N*M-2,K-2,waruno)
ans=0
do i=0,M-1
  do j=0,N-1
    tmp=mod((i+j)*(M-i)*(N-j)*com*merge(1,2,i*j==0),waruno)
    ans=mod(ans+tmp,waruno)
  end do
end do
print"(i0)",ans

contains

function combination(n,k,l)
implicit none
integer(16),intent(in)::n,k,l
integer(16) combination,i
integer(16),allocatable,dimension(:)::Kaijo

!まず最初に階乗について計算します
allocate(Kaijo(0:N))
Kaijo(0)=1
do i=1,N
  Kaijo(i)=mod(Kaijo(i-1)*i,l)
end do

!そこから階乗を使ってコンビネーションを計算します
!invはmod 10**9+7の下での逆数です
combination=mod(Kaijo(N)*inv(Kaijo(K),l)*inv(Kaijo(N-K),l),l)

end function combination

function inv(K,L)
integer(16),intent(in)::k,l
integer(16) l2,y
integer(16) inv
!フェルマーの小定理から-1乗とは10**9+7-2乗だよねということで
!10**9+7-2乗を計算します

!計算に使うのは繰り返し二乗法
inv=1
l2=l-2
y=k
do
  if(and(l2,1)==1)inv=mod(inv*y,l)
  y=mod(y*y,l)
  l2=rshift(l2,1)
  if(l2==0)exit
end do
end function inv
end

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

int main(){
  int64_t N, K;
  cin >> N >> K;
  int64_t m = pow(10,9)+7;
  int64_t ans = 0;
  for(int64_t i=K; i<=N+1; i++){
    ans += (i*(N-i+1)+1)%m;
    ans %= m;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
# a, b = map(int, input().split())
# c = list(map(int, input().split()))
# d = [list(map(int, input().split())) for _ in range(n)]
s = input()
w = int(input())
ans = ''

for i in range(len(s)):
    if i % w == 0:
        ans = ans + s[i]

print(ans)

Measured memory_bytes: 2940
N = int(input())
S = input()
hoge=[]
Alphas='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 
for a in S:
  for i, Alpha in enumerate(Alphas):
    if Alpha == a:
      hoge.append(Alphas[(i+N)%26])
      break
mojiretsu=''
for x in hoge:
    mojiretsu += x
print(mojiretsu)

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

typedef pair<int,int> P;

int hoge(int i,int x,int ans){
    for (int i = 1; i < x; i++){
        ans /= 10;
    }
    return i %(ans*10) /ans;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<int>s(m); vector<int>c(m);
    for (int i = 0; i < m; i++){
        cin >> s.at(i) >> c.at(i);
    }
    if (n == 1){
        bool re0 = true;
        for (int i = 0; i < m; i++){
            if (c.at(i) != 0){
                re0 = false;
            }
        }
        if (re0){
            cout << 0 << "\n";
            return 0;
        }
    }
    int ans = 1;
    for (int i = 1; i < n; i++){
        ans *= 10;
    }
    if (m == 0){
        cout << ans << "\n";
        return 0;
    }
    for (int i = ans; i < ans*10; i++){
        bool ok = true;
        for (int j = 0; j < m; j++){

            if (hoge(i,s.at(j),ans) != c.at(j)){
                ok = false;
            }

        }
        if (ok){
            cout << i << "\n";
            return 0;
        }
    }
    cout << -1 << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
string week[7]={"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
 
int main(){
    int m, d, y;
    while(cin>>m>>d&&m!=0){
        y=2004;
        if(m<3){
            y--;
            m=m+12;
        }
        cout<<week[(y+(y/4)-(y/100)+(y/400)+(((13*m+8)/5)+d))%7]<<"\n";
// ツェラーの公式
    }
}

Measured memory_bytes: 1172
from collections import defaultdict

n=int(input())
l=[defaultdict(int) for i in range(n)]
for i in range(n):
    S=input()
    for s in S:
        l[i][s]+=1
t=""
for i in range(26):
    a=10**30
    for j in range(n):
        a=min(a,l[j][chr(i+ord("a"))])
    t+=chr(i+ord("a"))*a
print(t)


Measured memory_bytes: 3316
/******************************************************************************
 
рассвет. 
 
*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int> 
#define vplli vector <pair <lli,lli> >
#define vpulli vector <pair <ulli,ulli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (lli i = a; i < (n); ++i)
#define run(c,s) for(auto c:s) 
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i] << " ";
using namespace std;
 
const lli MOD=1e9+7;
const lli MAXN=1e6+1;
const ld PI=acos(-1);
 
int main(){
    rapgame
    ld a,ans;
    cin >> a;
    ans=2*PI*a;
    cout << fixed << setprecision(20) << ans;
    return 0;
}

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

int main () {
	char s[101];
	cin >> s;
	for (int i=0; s[i]!='\0'; i++) {
		if (i%2==0 && s[i]=='L') {
			cout << "No" << endl;
			return 0;
		}
		if (i%2==1 && s[i]=='R') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

dp = [float("INF")] * N
dp[0] = 0
K = min(N-1, K)
for i in range(1, K+1):
  dp[i] = abs(h[i] - h[0])

for i in range(K, N):
  c = [float("INF")] * (K+1)
  for j in range(1, K+1):
    c[j] = dp[i-j] + abs(h[i] - h[i-j])
  dp[i] = min(c)
  
print(dp[N-1])

Measured memory_bytes: 55264
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	int Q;
	cin >> Q;
	vector<ll> A(Q), B(Q);

	REP(i, Q) {
		cin >> A[i] >> B[i];
	}
	REP(i,Q){
		ll a = A[i], b = B[i];
		if (a > b) swap(a, b);

		if ((b - a) <= 1) {
			cout << 2 * (a - 1) << endl;
		}
		else {
			ll c = sqrt(a*b);
			if (c*(c + 1) < a*b) {
				cout << (a - 1) + 2 * c - a << endl;
			}
			else if(c*c < a*b) {
				cout << (a - 1) + 2 * c - a - 1 << endl;
			}
			else if (c*c == a*b) {
				cout << (a - 1) + 2 * c - a - 1 - 1 << endl;
			}
		}
	}
	system("pause");
	return 0;
}

Measured memory_bytes: 504
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (sc.hasNext()) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			System.out.println( digit(a, b) );
		}

	}
	private static int digit(int a, int b) {
		int dg = Integer.toString(a + b).length();
		return dg;
	}
}


Measured memory_bytes: 26100
import Control.Monad
import Control.Applicative

rate (-1) _ _ = "F"
rate _ (-1) _ = "F"
rate m f r
    | m + f >= 80 = "A"
    | m + f >= 65 = "B"
    | m + f >= 50 = "C"
    | m + f >= 30 = if r >= 50 then "C" else "D"
    | otherwise   = "F"

processInputLine [m,f,r] =
    if m == -1 && f == -1 && r == -1 then return () else putStrLn $ rate m f r

main = do
    mapM_ processInputLine =<< map (map (read :: String->Int) . words) <$> lines <$> getContents

Measured memory_bytes: 3920
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

typedef long long ll;

#define REP(var,n) for(int var=0;var<(n);var++)
#define REPP(var,n) for(int var=1;var<(n);var++)
#define ALL(c) (c).begin(),(c).end()

int main(){
    int N,K; 
    
    cin >> N >> K;

    ll x[N];
    REP(i,N){
        cin >> x[i];
    }

    ll mini = 10000000000;

    REP(i, (N-K+1)){
       ll tmp = min( abs(x[i])+abs(x[i]-x[i+K-1]), abs(x[i+K-1])+abs(x[i]-x[i+K-1]) );
       mini = min(tmp, mini);
    }

    cout << mini << endl;
}

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

/*
   AtCoder contest code
   coder : yoichidon
 */

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] h = new long[N];
        for(int n=0; n<N; n++) h[n]=sc.nextLong();

        long[] cost = new long[N];
        cost[0]=0;
        cost[1]=Math.abs(h[0]-h[1]);
        for(int n=2; n<N;n++) cost[n] = Math.min(cost[n-2]+Math.abs(h[n]-h[n-2]), cost[n-1]+Math.abs(h[n]-h[n-1]));

        System.out.println(cost[N-1]);
    }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,T;
int A[3030],B[3030];
int L[3030][3030];
int R[3030][3030];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>T;
	FOR(i,N) {
		cin>>A[i]>>B[i];
		FOR(x,3030) {
			L[i+1][x]=max(L[i+1][x],L[i][x]);
			if(x+A[i]<=T) L[i+1][x+A[i]]=max(L[i+1][x+A[i]],L[i][x]+B[i]);
		}
	}
	for(i=N-1;i>=0;i--) {
		FOR(x,3030) {
			R[i][x]=max(R[i][x],R[i+1][x]);
			if(x+A[i]<=T) R[i][x+A[i]]=max(R[i][x+A[i]],R[i+1][x]+B[i]);
		}
	}
	FOR(i,N+1) {
		FOR(j,T) {
			L[i][j+1]=max(L[i][j],L[i][j+1]);
			R[i][j+1]=max(R[i][j],R[i][j+1]);
		}
	}
	
	
	int ma=0;
	FOR(i,N) {
		FOR(x,T) {
			y=B[i]+L[i][x]+R[i+1][T-1-x];
			ma=max(ma,y);
		}
	}
	cout<<ma<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 71936
N = int(input())
a = list(map(int,input().split()))

zentai=0
for i in range(N):
    zentai = zentai^a[i]
#print('zentai:', zentai)  ####

out=[]
for j in range(N):
    out.append(str(a[j]^zentai))

print(' '.join(out))

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

using namespace std;
typedef long long ll;
typedef long int lt;
typedef vector<ll> vi;
typedef vector<int> vin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
#define all(a) a.begin(),a.end()
#define rep(i,a,b) for(int i=a;i<b;++i)
#define f(i,b) for(int i=0;i<b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define test(t) int t; cin>>t; while(t--) solve()
#define endl "\n"
#define p1 cout<<"YES"<<endl
#define p0 cout<<"NO"<<endl
#define fst ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int mod=1e9+7;

ll mod_pow(ll a,ll n,ll mod)	//(a^n)%mod
{	ll res=1;
	while(n){	if(n&1)	res=(res*a)%mod; n/=2; a=(a*a)%mod;	}
	return res;
}

void solve();

int main()
{
    fst;
    //test(t);
     solve();
}

/**********************<="Actual code strats here"=>*****************************/


void solve()
{
    ll n;
    cin>>n;
    ll lc=n*360/(__gcd(n,360ll));
    cout<<lc/n<<endl;
}

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

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

const int INF = 2e9;
const int MOD = 1e9+7;
const int MAX = 2e5+10;
const lint LNF = 2e18;


int n, A[MAX];
deque<int> B;
bool fliped;

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	for(int i=1; i<=n; i++) cin>>A[i];
	for(int i=1; i<=n; i++){
		if(fliped){
			B.push_front(A[i]);
		} else {
			B.push_back(A[i]);
		}
		fliped^=true;
	}
	if(fliped) reverse(B.begin(), B.end());
	for(int x:B) cout<<x<<' ';
	cout<<'\n';

	return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <complex>
#include <cmath>
using namespace std;
typedef complex<double> xy_t;

// ??????: a.x*b.x
double dot_product(xy_t a, xy_t b) { 
  return (conj(a)*b).real(); 
}
// ??????: a.x*b.y - b.x*a.y
// ????§???¢????¬????????????¢????????????
double cross_product(xy_t a, xy_t b) { 
  return (conj(a)*b).imag(); 
}
// ?????±: ????????¨ p ??????????????´?????? b ????????±
xy_t projection(xy_t p, xy_t b) { 
  return b*dot_product(p,b)/norm(b); 
}

double x[4], y[4];
int main() {
while (true) {
  for (int i=0; i<4; ++i) cin >> x[i] >> y[i];
  if (!cin) break;
  xy_t a(x[0],y[0]), b(x[1],y[1]), c(x[2],y[2]), p(x[3],y[3]);
  // pab ????¬????????????¢?????? 2 ??????,cross product(a-p,b-p)
  // pbc ????¬????????????¢?????? 2 ??????,cross product(b-p,c-p)
  // pca ????¬????????????¢?????? 2 ??????,cross product(c-p,a-p)
  int aaa = 0;
  if (cross_product(a-p,b-p) > 0) aaa++;
  if (cross_product(b-p,c-p) > 0) aaa++;
  if (cross_product(c-p,a-p) > 0) aaa++;
  bool ok = false;
  if (aaa == 3 || aaa == 0) ok = true;
  cout << (ok ? "YES" : "NO") <<  endl;
  }
}

Measured memory_bytes: 1220
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   if(xs[0]<=xs[1]){
     console.log('unsafe');
   }else{
     console.log('safe');
   }

}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

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

int main() {
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> v(n);
    for(int i = 0; i < n; ++i) {
        int a, x, y;
        cin >> a;
        for(int j = 0; j < a; ++j) {
            cin >> x >> y;
            v[i].push_back(make_pair(x, y));
        }
    }

    int ans = 0;
    for(int bit = 1; bit < (1<<n); ++bit) {
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
                sum++;
                for(int j = 0; j < v[i].size(); ++j) {
                    if(((bit & 1<<(v[i][j].first-1))?1:0) != v[i][j].second) {
                        sum = 0;
                        goto endloop;
                    }
                }
            }
        }
        endloop:
        ans = max(ans, sum);
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
  using namespace std;
  
  int main()
  {
    ios::sync_with_stdio(0);
      cin.tie(0);
      cout.tie(0);

    int x;
    cin >> x;
    int lcm = (x*360)/__gcd(x, 360);
    int ans = lcm/x;
    cout << ans;

    return 0;
  }

Measured memory_bytes: 3636
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

int main()
{
    IOS();
    ll n,a;
    cin>>n>>a;
    if(n % 500 <= a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200100;
const ll MOD = 998244353;//変更
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

long long fac[MAX], finv[MAX], inv[MAX];

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    COMinit();
    ll N, M, K;
    cin>>N>>M>>K;
    ll Ans=0;
    for(ll i=0; i<=K; i++){
        ll Num=M;
        Num*=myPow(M-1, N-i-1, MOD);
        Num%=MOD;
        Num*=COM(N-1, i);
        Num%=MOD;
        Ans+=Num;
        Ans%=MOD;
      	//cout<<Ans<<endl;
    }
    cout<<Ans<<endl;

}

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

int main(void)
{
    int n;
    cin >> n;
    vector<int> p(n);
    int count = 0;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    for (int i = 1; i < n-1; i++) {
        if ((p[i-1] > p[i] && p[i] > p[i+1]) || (p[i+1] > p[i] && p[i] > p[i-1])) {
            count++;
        }
    }
    cout << count << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int ans[200000];
signed main(){
    string s;
    cin>>s;
    int l=s.size();
    int left=-1;
    rep(i,l){
        if(s[i]=='R'&&left==-1)left=i;
        else if(s[i]=='L'&&s[i-1]=='R'){
            if((i-left)%2==0){
                ans[i]+=(i-left)/2+1;
                ans[i-1]+=(i-left)/2;
            }
            else{
                ans[i]+=(i-left)/2+1;
                ans[i-1]+=(i-left)/2+1;
            }
            left=-1;
        }
    }
    int right=-1;
    for(int i=l-1;i>=0;i--){
        if(s[i]=='L'&&right==-1)right=i;
        else if(s[i]=='R'&&s[i+1]=='L'&&right>i+1){
            if((right-i)%2==0){
                ans[i]+=(right-i)/2;
                ans[i+1]+=max((int)(0),(right-i)/2-1);
            }
            else{
                ans[i]+=(right-i)/2;
                ans[i+1]+=(right-i)/2;
            }
            right=-1;
        }
        else if(s[i]=='R')right=-1;
    }
    rep(i,l){
        cout<<ans[i];
        if(i==l-1)cout<<endl;
        else cout<<" ";
    }
    return 0;
}


Measured memory_bytes: 1408
num = gets.chop.split("")
len = num.length - 1

sum = []
cnt = 1
sum << num.join.to_i

while(cnt < (1 << len))
    add = ''
    add_nums = []
    num.each_with_index do |n, i|
        add += n
        unless (cnt & (1 << i)).zero?
            add_nums << add.to_i
            add = ''
        end
    end
    add_nums << add.to_i
    sum << add_nums.sum
    cnt += 1
end
p sum.sum

Measured memory_bytes: 14340
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    veci prime(55560);
    for(int i = 2; i <= 55555; i++) {
        for(int j = i; j <= 55555; j += i) {
            prime[j]++;
        }
    }
    veci ans;
    for(int k = 1; 5*k-2 <= 55555; k++) {
        if(prime[5*k-4] == 1) ans.push_back(5*k-4);
        //if(prime[5*k-2] == 1) ans.push_back(5*k-2);
    }
    REP(i,N) cout << ans[i] << endl;
}

Measured memory_bytes: 3636
#
# abc069 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """internationalization"""
        output = """i18n"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """smiles"""
        output = """s4s"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """xyz"""
        output = """x1z"""
        self.assertIO(input, output)


def resolve():
    s = input()
    print(f"{s[0:1]}{len(s)-2}{s[-1:]}")


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16320
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include<string>
#include<stack>

using namespace std;
typedef long long ll;

int main(){
    int n,m;
    cin>>n>>m;
    ll summer = 0;
    for(int i=0;i<m;i++){
        int el;
        cin>>el;
        summer +=el;
    }
    if(summer>n){
        cout<<-1;
    }
    else{
        cout<<n-summer;
    }
}

Measured memory_bytes: 3644
N,K = map(int, input().split())

B = []
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in range(d):
        if (A[a]-1) not in B:
            B.append(A[a]-1)

ans = 0
for i in range(N):
    if i not in B:
        ans += 1

print(ans)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define FT() int t; scanf("%d",&t); while(t--)
#define pb push_back
#define nl printf("\n")
#define fi(i,start,end) for(int i=start; i < (int)end ; ++i)
#define ip(n)   scanf("%d",&n)
#define mz(a)   memset(a,0,sizeof(a))
#define inpArr(A,n) fi(i,0,n)   ip(A[i]);
#define print(a)  for(auto i : a)   cout<<i<<" "; nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll max(ll a,ll b) { return a>b?a:b;}
ll min(ll a,ll b) { return a<b?a:b;}
void solve()
{   int x,y;
    cin>>x>>y;
    int t = 2*x;
    fi(i,0,x)
    {
        if(t==y)
        {
            cout<<"Yes";
            return;
        }
        t+=2;
    }
    if(t==y)
        cout<<"Yes";
    else
        cout<<"No";
}
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    
    
        solve();

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
    #endif
    return 0;
}


Measured memory_bytes: 3628
N = int(input())
C = [0] * 5
prefix = 'MARCH'

for i in range(N):
    s = input().rstrip()[0]
    if s in prefix:
        C[prefix.find(s)] += 1

ans = 0

for i in range(5):
    for j in range(i+1, 5):
        for k in range(j+1, 5):
            ans += C[i] * C[j] * C[k]

print(ans)


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


vector<vector<int>> costs(10,vector<int>(10));
int arr[200][200];

int main(){

	int h,w;
	cin>>h>>w;

	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			cin>>costs[i][j];
		}
	}

	for(int k = 0;k<10;k++){
	 for(int i=0;i<10;i++){
	     	for(int j=0;j<10;j++){
	     	     costs[i][1] = min(costs[i][1],costs[i][j]+costs[j][1]);
	     }
	 }
  }

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>arr[i][j];
		}
	}

	int res = 0;

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(arr[i][j]!=1 && arr[i][j]!=-1){
				res+=costs[arr[i][j]][1];
			}
		}
	}

	cout<<res;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
	ll x;
	scanf("%lld", &x);
	ll ans = x/11;
	ans *= 2;
	x %= 11;
	if (x >= 7) ans += 2;
	else if (x != 0) ans++;
	printf("%lld\n", ans);
	return 0;
}


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

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

const lli MOD = 1000000007LL;

lli modpow(lli a, lli n){
    lli res = 1;

    for(lli ai = a; n; n>>=1){
        if(1&n) res = (res*ai)%MOD;
        ai=(ai*ai)%MOD;
    }
    return res;
}

lli inv(lli n){
    return modpow(n, MOD-2);
}

lli modperm(lli n, lli k){
    lli res = 1;
    rep(i, k){
        res = (res*(n-i))%MOD;
    }
    return res;
}

lli modcomb(lli n, lli k){
    return (modperm(n, k)*inv(modperm(k, k)))%MOD;
}

lli posmod(lli n){
    lli res = n;
    res %= MOD;
    if(res < 0) res += MOD;
    return res;
}
lli a5, b5;
lli x;

int main(void){
    cin >> x;
    for(lli i = -118; i < 120; i++){
        for(lli j = -119; j < 119; j++){
            a5 = i*i*i*i*i;
            b5 = j*j*j*j*j;
            if(a5-b5 == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#include<ctime>
#include<cstdlib>
#define INF long long int(1e18+1)
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main() {
	vector<string>s{ "SUN","MON","TUE","WED","THU","FRI","SAT" };
	string t;
	cin >> t;
	rep(i, 0, 7) {
		if (t == s[i]) {
			cout << 7 - i << endl;
		}
	}
	
}


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

int main() {
  int A,B,C,D;
  cin>>A;cin>>B;cin>>C;cin>>D;
  int L,R;
  L=A+B;
  R=C+D;

  if(L==R){
    cout<<"Balanced"<<endl;
  }else if(L>R){
    cout<<"Left"<<endl;
  }else if(L<R){
    cout<<"Right"<<endl;
  }
}


Measured memory_bytes: 256
N = int(input())
money = [1]
i = 1
while True:
    i *= 6
    if i <= 100000:
        money.append(i)
    else:
        break
i = 1
while True:
    i *= 9
    if i <= 100000:
        money.append(i)
    else:
        break

M = len(money)

dp = [[10 ** 9 for _ in range(N + 1)] for _ in range(M + 1)]

for i in range(M + 1):
    dp[i][0] = 0

for i in range(1, M + 1):
    for j in range(N + 1):
        if j - money[i - 1] >= 0:
            dp[i][j] = min(dp[i][j - money[i - 1]] + 1, dp[i - 1][j])
        else:
            dp[i][j] = dp[i - 1][j]

print(dp[M][N])



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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++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 irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s;cin>>s;
  int ans=7;
  if(s=="SAT")ans=1;
  if(s=="FRI")ans=2;
  if(s=="THU")ans=3;
  if(s=="WED")ans=4;
  if(s=="TUE")ans=5;
  if(s=="MON")ans=6;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <list>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define LL long long
#define eps 1e-6
using namespace std;
const double pi = 3.1415926535;
/*
https://codeforces.com/contest/1106/problems
https://codeforces.com/contest/1106/submit
*/
const ll mod = 1e9+7;
//快速幂 (a^b)%mod
//如果求逆元，则b = mod-2;
ll pow_quick(ll a,ll b){
    ll r = 1,base = a;
    while(b){
        if(b & 1){
            r *= base;
            r %= mod;
        }
        base *= base;
        base %= mod;
        b >>= 1;
    }
    return r;
}

int main(){
    int a,b;
    char c;
    s(a) gc c = gc;
    s(b)
    if(c == '+'){
        p(a+b);
    }else{
        p(a-b);
    }
	return 0;
 }



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

int main(){
  
  int n, m;
  
  cin >> n;
  vector<int> A(n);
  for(int i = 0;i < n;i++) cin >> A[i];
  
  cin >> m;
  vector<int> B(m);
  for(int i = 0;i < m;i++) cin >> B[i];
  
  cout << includes(A.begin(), A.end(), B.begin(), B.end()) << endl;
  
  return 0;
}


Measured memory_bytes: 4340
from collections import defaultdict, Counter

def main():
  n, *A = map(int, open(0).read().split())
  A.sort()
  n = A[-1]
  isPrime = [True] * (n + 1)
  prep = 0
  for i in A:
    if prep == i:
      isPrime[prep] = False
      continue
    if isPrime[i]:
      for j in range(i * 2, n + 1, i):
        isPrime[j] = False
    prep = i

  prep = res = 0
  for i in A:
    if prep == i:
      continue
    if isPrime[i]:
      res += 1
    prep = i
  print(res)
if __name__ == '__main__':
  main()


Measured memory_bytes: 33332
# A happy new year, AtCoder !
N, M = map(int, input().split())
pS = [input().split() for _ in range(M)]

ac = [0] * N
wa = [0] * N

for i, (pi_str, Si) in enumerate(pS):
    pi = int(pi_str)
    if Si == 'AC':
        ac[pi - 1] = 1
    else:
        if ac[pi - 1] == 0:
            wa[pi - 1] += 1
        else:
            pass

ans_wa = 0
for i, wai in enumerate(wa):
    if ac[i] > 0: ans_wa += wai

print(sum(ac), ans_wa)


Measured memory_bytes: 33680
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


int main()
{
	ios_base::sync_with_stdio(false);

	ll k,a,b,c,n, h, ret = 0;
	string s;
	cin >> s >> k;
	ll nk = k;
	rep(i, s.size()) {
		if (s[i] != '1') {
			cout << s[i] << endl;
			return 0;
		}
		else nk--;
		if (k > 100) {
			continue;
		}
		else if (nk <= 0) {
			cout << 1 << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n,a,b = map(int, input().split())
mod = 10**9 + 7

def modcmb(n,r,mod):
    x,y = 1,1
    for i in range(1, r + 1):
        x *= (n - i + 1)
        x %= mod
        y *= i
        y %= mod
    rtn = x * pow(y, mod - 2, mod) % mod
    return rtn

ans = pow(2, n, mod) - 1
ans -= modcmb(n,a,mod) + modcmb(n,b,mod)
print(ans % mod)


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef i32 i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

//const i64 mod = 1000000007ll;
//const i64 smod = 998244353ll;
//const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

const i64 MAXN = 82;

const i64 C = 160 * 81;

i64 h, w;
i64 a[MAXN][MAXN];
i64 b[MAXN][MAXN];
bool dp[MAXN][MAXN][C * 2 + 2];


int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> h >> w;

    for (i64 i = 1; i <= h; i++) {
        for (i64 j = 1; j <= w; j++) {
            cin >> a[i][j];
        }
    }

    for (i64 i = 1; i <= h; i++) {
        for (i64 j = 1; j <= w; j++) {
            cin >> b[i][j];
        }
    }

    dp[1][1][C + 0] = 1;

    for (i64 s = 2; s <= w * h; s++) {
        for (i64 i = 1; i <= min((i64)(s - 1), h); i++) {
            i64 j = s - i;
            if (j < 1 || j > w) {
                continue;
            }

            i64 d = a[i][j] - b[i][j];

            for (i64 k = 0; k <= C * 2; k++) {
                if (!dp[i][j][k]) {
                    continue;
                }
                i64 t = k - C;
                dp[i + 1][j][C + t + d] = 1;
                dp[i + 1][j][C + t - d] = 1;

                dp[i][j + 1][C + t + d] = 1;
                dp[i][j + 1][C + t - d] = 1;
            }
        }
    }


    i64 R = 0;
    bool f = false;
    i64 d = a[h][w] - b[h][w];
    for (i64 k = 0; k <= C * 2; k++) {
        if (!dp[h][w][k]) {
            continue;
        }
        i64 t = k - C;
        if (!f) {
            R = min((i64)abs(t + d), (i64)abs(t - d));
            f = 1;
        }
        else {
            R = min(R, (i64)abs(t + d));
            R = min(R, (i64)abs(t - d));
        }
    }

    cout << R << endl;


    return 0;
}

Measured memory_bytes: 168448
A,B,C,D,E,F=map(int,input().split())

cand_water=set()
for i in range(1,30//A+1):
  for j in range(30//B+1):
    vol=i*100*A+j*100*B
    if vol<=F:
      cand_water.add(vol)
#print(cand_water)

cand_sugar=set()
if C==1 or D==1:
  cand_sugar=set(range(F+1))
else:
  for i in range(3000//C+1):
    for j in range(3000//D+1):
      vol=i*C+j*D
      if vol<=F:
        cand_sugar.add(vol)
#print(cand_sugar)

max_concent=-1
answer=[0,0]
for water in cand_water:
  for sugar in cand_sugar:
    if water+sugar>F:
      continue
    if sugar/(water+sugar)>E/(100+E):
      continue
      
    if sugar/(water+sugar)>max_concent:
      answer=(water+sugar,sugar)
      max_concent=sugar/(water+sugar)
      
print(*answer)

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

int N;
long long int X;
vector<long long int> a(51), p(51); //各レベルに対する層の数a, パティの数p

long long int patti(int N, long long int X) {
    if (X < 0 || N < 0) {
        return 0;
    } else if (X > a[N] / 2) {
        return p[N] - patti(N - 1, a[N] - X - 1);
    } else {
        return patti(N - 1, X - 1);
    }
}

int main() {
    cin >> N >> X;
    
    a[0] = 1; p[0] = 1;
    for (int i = 0; i < N; i++) {
        a[i + 1] = 2 * a[i] + 3;
        p[i + 1] = 2 * p[i] + 1;
    }
    
    cout << patti(N, X) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first 
#define se second
#define pi pair<ll,ll> 
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main(){ 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int k=0;
  while(a>0 || c>0){
  	   if(k%2==0)
  	   c=c-b;
  	   if(k%2!=0)
  	   a=a-d;
  	   if(a<=0 || c<=0)
  	   break;
  	   k++;
  }
  if(a<=0)
  	cout<<"No"<<endl;
  else
  	cout<<"Yes"<<endl;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    int i=1;
    char c='0';
    while(1)
    {
        c=getchar();
        if(c=='\n'||c==EOF) break;
        if(i%2==0&&c=='R')
        {
            printf("No");
            return 0;
        }
        else if(i%2==1&&c=='L')
        {
            printf("No");
            return 0;
        }
        i++;
    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const long long inf = 1LL << 22;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	char x, y; cin >> x >>y;
	int a = x - 'A';
	int b = y - 'A';
	if (a < b) {
		cout << "<" << endl;
	}
	else if (a == b) {
		cout << "=" << endl;
	}
	else {
		cout << ">" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let x: usize = read();
    let y: usize = read();
    if x * 2 > y || y > x * 4 || y %2 == 1{
        println!("No");
    } else {
        println!("Yes");
    }
}


Measured memory_bytes: 2128
import numpy as np
 
n, a = map(int, input().split())
x = np.array(list(map(int, input().split())))
 
dp = {0:1}
for y in x-a:
    for k, v in dp.copy().items():
        dp[y+k] = dp.get(y+k, 0) + v 
print(dp[0]-1)


Measured memory_bytes: 21772
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

	public void Proc()
	{
        string inpt = Reader.ReadLine();
        string ans = "No";
        if(inpt.StartsWith("YAKI", StringComparison.CurrentCulture)) {
            ans = "Yes";
        }
        Console.WriteLine(ans);
    
    }


    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"


YAKINIKU



";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    int ans = 0;
    rep(i, 3) {
        int d = n % 10;
        if (d == 1) d = 9; else d = 1;
        ans += d * pow(10, i);
        n /= 10;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <map>
#include <vector>
//#include <unordered_map>
//#include <unordered_set>
#include <stack>
#include <set>
#include <queue>
#include <list>
#define LL long long
#define N 100100
#define M 110
#define MOD 1000000007
#define FOR(i,l,r) for (int i = (l); i <= (r); i ++)
#define CLR(a,x) memset(a,x,sizeof(a))
#define INF 0x3f3f3f3f
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define X first
#define Y second
using namespace std;
const int maxn=100005;
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    a=max(a,c);
    b=min(b,d);
    if(b<a) puts("0");
    else cout<<b-a<<endl;
	return 0;
}


Measured memory_bytes: 256