akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <string.h>
#include <bits/stdc++.h>
#include <math.h>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


// 5		v[4]
//413	v[3]v[0]v[2]
// 2		v[1]
// 6		v[5]

//N
//	  v[4]				v[0]
//v[3]v[0]v[2]	→	v[3]v[1]v[2]
//	  v[1]				v[5]
//	  v[5]				v[4]

//S
//	  v[4]				v[5]
//v[3]v[0]v[2]	→	v[3]v[4]v[2]
//	  v[1]				v[0]
//	  v[5]				v[1]

//E
//	  v[4]				v[4]
//v[3]v[0]v[2]	→	v[5]v[3]v[0]
//	  v[1]				v[1]
//	  v[5]				v[2]

//W
//	  v[4]				v[4]
//v[3]v[0]v[2]	→	v[0]v[2]v[5]
//	  v[1]				v[1]
//	  v[5]				v[3]


class dice
{
public:
	explicit dice(int _dice[6])
	{
		for(int i = 0; i < 6; ++ i)
		{
			v[i] = _dice[i];
		}
	}

	void mov(char c)
	{
		int buf;
		//北方向
		if(c == 'N')
		{
			buf = v[0];
			v[0] = v[1];
			v[1] = v[5];
			v[5] = v[4];
			v[4] = buf;
		}
		else if(c == 'S')
		{
			buf = v[0];
			v[0] = v[4];
			v[4] = v[5];
			v[5] = v[1];
			v[1] = buf;		
		}
		else if(c == 'E')
		{
			buf = v[0];
			v[0] = v[3];
			v[3] = v[5];
			v[5] = v[2];
			v[2] = buf;	
		}
		else if(c == 'W')
		{
			buf = v[0];
			v[0] = v[2];
			v[2] = v[5];
			v[5] = v[3];
			v[3] = buf;				
		}
	}
int operator[](size_t i){return v[i];}
private:
	int v[6];
};

int main(){
    //std::ifstream in("resource/input.txt");
    //std::cin.rdbuf(in.rdbuf());

	int _dice[6];
	REP(i,6)
	{
		cin >> _dice[i];
	}
	string s;
	cin >> s;

	dice d(_dice);
	REP(i,s.size())
	{
		d.mov(s[i]);
	}

	
	cout << d[0] << endl;
    //cout << fixed << setprecision(5) << dm << endl;
	//std::printf("%.5f¥n", res);
	
	return 0;
}




Measured memory_bytes: 3180
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int h = t/3600;
        int m = (t - h*3600) / 60;
        int s = t - (h*3600 + m*60);
        System.out.println(h+":"+m+":"+s);
    }
}



Measured memory_bytes: 26208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;

ll bitCount(ll a){
  ll cnt=0;
  while(a) {cnt+=(a%2); a/=2;}
  return cnt;
}

int main(){
  ll N,K,L,R; cin>>N>>K>>L>>R;
  vi a(N); REP(i,N) cin>>a[i];
  ll ans=0;
  FOR(k,0,K+1) {
    vi x,y;
    REP(i,(1ll<<(N/2))) {
      if(bitCount(i)!=k) continue;
      ll sum=0;
      REP(j,(N/2)) if((1ll<<j)&i) sum+=a[j];
      x.PB(sum);
    }
    REP(i,(1ll<<(N-N/2))) {
      if(bitCount(i)!=K-k) continue;
      ll sum=0;
      REP(j,(N-N/2)) if((1ll<<j)&i) sum+=a[N/2+j];
      y.PB(sum);
    }
    sort(ALL(y));
    for(ll i:x){
      ans+=distance(LB(ALL(y),L-i),UB(ALL(y),R-i));
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 7820
import java.util.Scanner;

class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		if (n % 2 == 0)
			System.out.println(n);
		else
			System.out.println(n * 2);
		
	}
}

Measured memory_bytes: 23124
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int s = a +  b + c;
    if (s >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

struct FlowEdge {
    int to, rev;
    long long cap;
    FlowEdge(int to_, long long cap_, int rev_) :to(to_), rev(rev_), cap(cap_) { }
};
/*
O(fE)
最大フロー
*/
class FordFulkerson {
public:
    FordFulkerson() {}

    FordFulkerson(int n) : G(n), used(n) {}

    void add(int from, int to, long long cap) {
        G[from].emplace_back(to, cap, (int)G[to].size());
        G[to].emplace_back(from, 0, (int)G[from].size() - 1);
    }

    long long get(int s, int t) {
        long long f = 1;
        long long res = 0;
        while (f) {
            fill(begin(used), end(used), false);
            f = dfs(s, t, LLONG_MAX);
            res += f;
        }
        return res;
    }
private:

    vector<vector<FlowEdge>> G;
    vector<bool> used;

    long long dfs(int v, int t, long long f) {
        if (v == t) return f;
        used[v] = 1;
        for (auto &e : G[v]) {
            if (!used[e.to] && e.cap > 0) {
                long long d = dfs(e.to, t, min(e.cap, f));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
};

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

    int N;
    cin >> N;
    vi a(N);

    FordFulkerson ff(N + 2);
    const int src = N, sink = N + 1;

    ll sm = 0;
    rep(i, N) {
        cin >> a[i];
        if (a[i] >= 0) {
            ff.add(src, i, a[i]);
            sm += a[i];
        } else {
            ff.add(i, sink, -a[i]);
        }
    }

    ll INF = (ll)2e11;
    for (int i = 1; i <= N; ++i) {
        for (int j = 2 * i; j <= N; j+=i) {
            ff.add(j-1, i-1, INF);
        }
    }


    ll ans = sm - ff.get(src, sink);
    cout << ans << endl;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int n,m;cin >>n>>m;
    vector<int>a(n);
    ll ans=0;
    unordered_map<ll,int>mp;
    ll sum=0;
    mp[0]++;
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
        a[i]%=m;
        sum+=a[i];
        sum%=m;
        ans+=mp[sum];
        mp[sum]++;
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 6772
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
const int N=2e5;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int a[N];
LL b[N];
int main()
{
	int n=gi()-1,i,m=0,x;char c;
	LL sum=gi(),ans=-1LL<<60;
	for (i=1;i<=n;i++) {
		while ((c=getchar())!='+'&&c!='-');
		sum+=x=gi();
		if (c=='+') b[m]+=x; else a[++m]=x;
	}
	for (i=1;i<=m;i++) {
		ans=max(ans,sum-(a[i]+b[i])*2);
		sum-=a[i]*2;
	}
	cout<<max(ans,sum)<<endl;
	return 0;
}


Measured memory_bytes: 896
#include <iostream>

using namespace std;
long long a[410],dp[410][410],sum[410] = {},x = 0,mx = 1000000000000000;
long long solve(int l, int r){
	if(dp[l][r]!=mx) return dp[l][r];
	if(r-l==1){
		dp[l][r] = 0;
		return 0;
	}
	for(int i=l+1;i<r;i++){
		dp[l][r] = min(dp[l][r],solve(l,i) + solve(i,r) + sum[r-1] - sum[l-1]);
	}
	return dp[l][r];
}

int main(){
	int i,j,n;
	cin >> n;
	for(i=1;i<=n;i++){
		cin >> a[i];
		x += a[i];
		sum[i] = x;
	}
	for(i=0;i<=n+1;i++){
		for(j=0;j<=n+1;j++){
			dp[i][j] = mx;
		}
	}
	cout << solve(1,n+1) << endl;
}

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

using namespace std;

int getMaxSum(vector<int> v)
{
	int sum,max;
	sum=v[0];
	max=v[0];
	for(int i=1;i<v.size();i++)
	{
		if(sum<0)
		{
			sum=0;
		}
		sum+=v[i];
		if(sum>max)
		{
			max=sum;
		}
	}
	return max;
}

int main(void)
{
	int n;
	while(cin>>n)
	{
		if(n==0)
		{
			break;
		}
		vector<int> v;
		for(int i=0;i<n;i++)
		{
			int tmp;
			cin>>tmp;
			v.push_back(tmp);
		}
		cout<<getMaxSum(v)<<endl;
	}
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 2147483647;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin >> n;
    vector<int> cnt(n);
    int MAX = 0, MIN = INF;
    rep(i, n) {
        int a;
        cin >> a;
        cnt[a]++;
        chmax(MAX, a);
        chmin(MIN, a);
    }
    bool ok = 1;
    for (int i = MIN + 1; i <= MAX; i++) {
        ok &= cnt[i] >= 2;
    }
    ok &= cnt[MIN] == (MAX % 2 == 0 ? 1 : 2);
    ok &= MIN == (MAX + 1) / 2;
    cout << (ok ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(a, b) for (ll i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;}
int main(){
    int n,k;
    ll s;
    cin >> n >> k >> s;
    ll nagasa=n-k+1;
    ll ikko=s/nagasa;
    if(ikko==0){
        REP(i,n){
            if(i<k){
                cout << s << " ";
            }
            else{
                cout << 1000000000 << " ";
            }
        }
        cout << endl;
        return 0;
    }
    vector<ll> v(n);
    REP(i,n){
        if(i<nagasa-1){
            v[i]=ikko;
        }
        else if(i==nagasa-1){
            v[i]=s%nagasa+ikko;
        }
        else{
            v[i]=v[i-nagasa];
        }
        cout << v[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 2048
# ABC100D

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))


import itertools
n, m = map(int, input().split())
xs = [None] * n
ys = [None] * n
zs = [None] * n
for i in range(n):
    xs[i],ys[i],zs[i] = map(int, input().split())
best = 0
for sx, sy, sz in itertools.product(*[[-1, 1] for _ in range(3)]):
    dp = [[None]*(m+1) for _ in range(n+1)]
    for j in range(m+1):
        dp[0][j] = 0
    for i in range(n+1):
        dp[i][0] = 0
    for i in range(1, n+1):
        for j in range(1, m+1):
            if i>j:
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-1] + sx*xs[i-1] + sy*ys[i-1] + sz*zs[i-1])
            else:
                dp[i][j] = dp[i-1][j-1] + sx*xs[i-1] + sy*ys[i-1] + sz*zs[i-1]
    best = max(best, dp[n][m])
#     print(dp[n][m])
print(best)

Measured memory_bytes: 192176
#include <algorithm>
#include <iostream>
#include <climits>
#include <cstdio>
#include <queue>
 
using namespace std;
 
const int N=105;
 
char pic[N][N];
bool flag;
int n,m;
 
namespace network
{
	const int INF=INT_MAX>>1;
	const int V=N*N<<1;
	const int E=(N<<1|1)*V<<1;
 
	int tov[E],nxt[E],f[E],v[E],r[E];
	int last[V],lab[V];
	int S,T,tot;
	queue<int> q;
 
	inline void insert(int x,int y,int full,int rev){tov[++tot]=y,f[tot]=full,r[tot]=tot+rev,nxt[tot]=last[x],last[x]=tot;}
	inline void addedge(int x,int y,int full){insert(x,y,full,1),insert(y,x,0,-1);}
 
	inline bool relabel()
	{
		for (int x=1;x<=n*m<<1;++x) lab[x]=0;
		for (lab[S]=1,q.push(S);!q.empty();q.pop())
			for (int x=q.front(),i=last[x],y;i;i=nxt[i])
				if (!lab[y=tov[i]]&&f[i]-v[i]) lab[y]=lab[x]+1,q.push(y);
		return lab[T];
	}
 
	int aug(int x,int flow)
	{
		if (x==T) return flow;
		int ret=0;
		for (int i=last[x],y;i;i=nxt[i])
			if (lab[y=tov[i]]==lab[x]+1&&f[i]-v[i])
			{
				int tmp=aug(y,min(flow,f[i]-v[i]));
				if (tmp)
				{
					v[i]+=tmp,v[r[i]]-=tmp;
					ret+=tmp,flow-=tmp;
					if (!flow) break;
				}else lab[y]=0;
			}
		return ret;
	}
 
	int maxflow()
	{
		int ret=0;
		for (;relabel();) for (int tmp;tmp=aug(S,INF);ret+=tmp);
		return ret;
	}
 
	bool build()
	{
		for (int i=1;i<=n;++i)
			for (int j=1;j<=m;++j)
				if (pic[i][j]!='.')
				{
					int x=(i-1)*m+j;
					addedge((x<<1)-1,x<<1,1);
					if (pic[i][j]=='S') S=x<<1;
					if (pic[i][j]=='T') T=(x<<1)-1;
					for (int k=1;k<=n;++k)
						if (i!=k&&pic[k][j]!='.')
						{
							int y=(k-1)*m+j;
							addedge(x<<1,(y<<1)-1,INF);
						}
					for (int k=1;k<=m;++k)
						if (j!=k&&pic[i][k]!='.')
						{
							int y=(i-1)*m+k;
							addedge(x<<1,(y<<1)-1,INF);
						}
				}
		int src=S+1>>1,tar=T+1>>1;
		int srcx=(src-1)/m+1,srcy=(src-1)%m+1;
		int tarx=(tar-1)/m+1,tary=(tar-1)%m+1;
		return srcx!=tarx&&srcy!=tary;
	}
};
 
int main()
{
	//freopen("lotus.in","r",stdin),freopen("lotus.out","w",stdout);
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i) scanf("%s",pic[i]+1);
	flag=network::build();
	if (flag) printf("%d\n",network::maxflow());
	else printf("-1\n");
	//fclose(stdin),fclose(stdout);
	return 0;
}

Measured memory_bytes: 86272
#include <iostream>

using namespace std;

int main()
{
    long long q , h , s , d;
    long long n;

    cin >> q >> h >> s >> d >> n;

    long long pre = n / 2;
    long long res = 0;
    res = pre * min(min(min(8 * q , 4 * h) , 2 * s) , d);

    res += (n % 2) * min(min(4 * q , 2 * h) , s);

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
int n,k,a[100005],ans;
vector<int>g[100005];
int dfs(int x,int par){
	int mx=0;
	for(auto to:g[x]){
		mx=max(dfs(to,x),mx);
	}
	if(mx==k-1&&a[x]!=1)ans++;
	return (mx+1)%k;
}
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=2;i<=n;i++){
		g[a[i]].push_back(i);
	}
	if(a[1]!=1)ans++,a[1]=1;
	dfs(1,-1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int e=0;
	for(int i=b-a;i>=1;i--)
	{
		e+=i;	
	 }
	  cout<<e-b;
	  return 0;
 } 

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;

#include <assert.h>
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

bool check(ll x, ll a, ll b){
    ll p = a * b;
    ll m = x / 2;
    // cout << x << endl;
    for (ll i = max(1LL, m - 10); i <= min(x, m + 10); i++){
        ll aa = i, bb = x - i + 1;
        if (aa >= a) aa++;
        if (bb >= b) bb++;
        // cout << aa << " " << bb << " " << aa * bb << endl;
        if (aa * bb >= p) return false;
    }
    return true;
}

int main() {
    int q;
    cin >> q;
    while (q--){
        ll a, b;
        cin >> a >> b;
        if (a > b) swap(a, b);
        ll prod = a * b;

        ll ans;
        if (prod <= 2){
            ans = 0;
        }else{
            ll ok = 0, ng = 2e9;
            while (ng - ok > 1){
                ll m = (ok + ng) / 2;
                if (check(m, a, b)) ok = m;
                else ng = m;
            }
            ans = ok;
        }
        cout << ans << endl;
    }


    return 0;
}


Measured memory_bytes: 256
N, weight_capacity = (int(n) for n in input().split())
weights, values = [], []
for _ in range(N):
    w, v = (int(n) for n in input().split())
    weights.append(w)
    values.append(v)

def knapsack_dp(weight_capacity, weights, values):
    """Solve knapsack problem by dynamic programming"""
    N = len(weights)
    dp = [[0] * (weight_capacity + 1) for _ in range(len(weights) + 1)]

    for i in range(N):
        for w in range(weight_capacity + 1):
            if w >= weights[i]:
                dp[i + 1][w] = max(dp[i][w], dp[i][w - weights[i]] + values[i])
            else:
                dp[i + 1][w] = dp[i][w]

    return dp[N][weight_capacity]

print(knapsack_dp(weight_capacity, weights, values))


Measured memory_bytes: 118512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#include <string>
using namespace std;

int main()
{
	int A, B, C, D;

	cin  >> A >> B >> C >> D;

	while (true) {
		C -= B;
		if (C <= 0) { cout << "Yes" << endl; break; }
		A -= D;
		if (A <= 0) { cout << "No" << endl; break; }
	}
}

Measured memory_bytes: 3676
public class Main {
  private static void solve() {
    int n = ni();
    int q = ni();
    char[] s = ns();
    
    long[] a = new long[n + 1];
    for (int i = 1; i < n; i ++) {
      if (s[i-1] == 'A' && s[i] == 'C') {
        a[i+1] = 1;
      }
      a[i+1] += a[i];
    }
    
    for (int i = 0; i < q; i ++) {
      int l = ni();
      int r = ni();
      
      out.println(a[r]-a[l]);
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N+1);
    rep(i, N){
        int a;
        cin >> a;
        A[a]++; 
    }

    sort(all(A));

    auto itr = upper_bound(all(A), 0);
    int A_size = A.end() - itr;
    int ans = 0;

    rep(i, A_size - K){
        ans += *itr;
        itr++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<chrono>
#define ll long long
#define mod 1000000007
#define endl '\n'
#define tab ' '
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pi 3.141592653589793238460
#define F(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define RF(i,a,b) for(int i=(int)a;i>=(int)b;i--)
// a.exe < "C:/Users/Piyush Naithani/Desktop/Codechef/Testfiles/icpc2.txt"
using namespace std;

void solve()
{

    ll a, b;
    cin >> a >> b;

    ll gcd = __gcd(a,b);

    ll lcm = (a * b)/gcd;

    cout<<lcm;
}


int main(){
    fast;
    #ifndef ONLINE_JUDGE
      // freopen("C:\Users\Piyush Naithani\Desktop\Codechef\Testfiles\icpc2.txt","r",stdin);
    
    // freopen("file name","w",stdout);
    #endif

    solve();

    return 0;
}


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

int main () {
  int K,N;

  cin >> K >> N ;

  int subA = 0;
  int preA = 0;
  int A=0;

  int start=0;

  for (int i=0;i<N;i++){
    preA = A;
    cin >>A;
    if (i == 0) {start=A; continue;}
    subA = max(subA,A-preA);
  }
  int end=K-A;

  subA = max(subA,start+end);

cout << (K-subA);
return 0;
}

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


void solve(long long N, long long A, long long B){
    long long ans = 0;
    if( N < A ){
        ans = N;
    }else if( N > A && N < A+B){
        ans = A;
    }else{
        long long iter = N/(A+B);
        long long mod = N%(A+B);
        if(mod > A){
            ans = iter * A + A;
        }else{
            ans = iter * A + mod;
        }
    }

    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
K = int(input())
A = list(map(int, input().split()))
min = 2
max = 2
for i in range(K-1, -1, -1):
    if max < A[i]:
        print(-1)
        exit()
    min += (-min) % A[i]
    max -= max % A[i]
    max += A[i] - 1
    if max < min:
        print(-1)
        exit()
print(min, max)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<long,long>
#define vi          vector<long long>
#define vii         vector<pii>
#define mi          map<long long,long long>
#define mii         map<pii,long long>
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(long long i=a;i<b;i++)
#define repr(i,a,b) for(long long i=a;i>=b;i--)
#define int long long
#define sz(x) (int)x.size()
#define mp make_pair
#define fi first
#define se second
#define io ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;

signed main()
{
	io;
	int n,m,tar;
	cin >> n >> m >> tar;
	map<int,int> r,c;
	set<pii> v;
	
	rep(i,0,tar)
	{
		int x,y;
		cin >> x >> y;
		v.insert(mp(x,y));
		//pii p = mp(x,y);
		//maprc[p] = 1;
		r[x]++;
		c[y]++;

	}
	int mx =0;
	int ansr,ansc;
	vi maxr,maxc;
	for(auto it:r)
	{
		if(mx<it.se)
		{
			mx = it.se;
			ansr = (it.fi);
		}

	}
	for(auto it:r)
	{
		if(mx==it.se)
		{
			maxr.pb(it.fi);
		}

	}
	int ans = mx;
	//int flag = 0;
	
	mx = 0;
	for(auto it:c)
	{
		if(mx<it.se)
		{
			mx = it.se;
			ansc = (it.fi);
		}

	}
	for(auto it:c)
	{
		if(mx==it.se)
		{
			maxc.pb(it.fi);
		}

	}
	ans+=mx;
	//cout << ansr << " " <<ansc<<endl;
	rep(i,0,maxr.size())
	{
		rep(j,0,maxc.size())
		{
			pii p = mp(maxr[i],maxc[j]);
			if(v.find(p)==v.end())
			{
				//cout << maxr[i] << " " <<maxc[j] <<endl;
				cout << ans << endl;
				return 0;
			}
		}
	}
	cout << ans -1<<endl;


}
 
	
		



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

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

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}


void _main() {
        int r; cin >> r;
        cout << r * r;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long

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

	int n,k;
	cin >> n >> k;
	int a[n];
	for(int i=0; i<n; i++) cin >> a[i];
	for(int i=k; i<n; i++){
		if(a[i] > a[i-k]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 4436
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



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




void dfs(int x, vi &dis, vector<vector<int>> &to, vector<vector<int>> &cost){
  
  for (int i=0;i<int(to.at(x).size());i++){
    int thenext=to.at(x).at(i);
    int w=cost.at(x).at(i);
    if (dis.at(thenext)==-1){
      dis.at(thenext)=(dis.at(x)+w)%2;
      dfs(thenext,dis,to,cost);
    }
  }
}


int main(){

  int n;
  cin>>n;

  vector<vector<int>> to(n+1,vector<int>(0));
  vector<vector<int>> cost(n+1,vector<int>(0));
  
  rep(i,n-1){
    int u,v,w;
    cin>>u>>v>>w;
    to.at(u).push_back(v);
    to.at(v).push_back(u);
    cost.at(u).push_back(w%2);
    cost.at(v).push_back(w%2);
  }
  
  vi dis(n+1,-1);
  dis.at(1)=0;
  
  dfs(1,dis,to,cost);
  
  for (int i=1;i<=n;i++){
    if (dis.at(i)%2==0){
      cout<<0<<endl;
    }
    else {
      cout<<1<<endl;
    }
  }

}










Measured memory_bytes: 14848
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
constexpr lli mod = 1e9+7;

lli ExGCD(lli a, lli b, lli &x, lli &y){
    lli d=a;
    x=1; y=0;
    if(b!=0){ d=ExGCD(b, a%b, y, x); y-=a/b*x; }
    return d;
}
lli inverse(lli a){
    lli x,y;
    ExGCD(a, mod, x, y);
    return x>0? x: mod+x;
}

constexpr int arrmax=3000001;
lli fact[arrmax];
lli inv[arrmax];
void maketable(){
    fact[0] = 1;
    for(int i=0; i<arrmax-1; i++){
        fact[i+1] = fact[i]*(i+1) %mod;
    }
    inv[arrmax-1] = inverse(fact[arrmax-1]);
    for(int i=arrmax-1; i>0; i--){
        inv[i-1] = inv[i]*i %mod;
    }
}
lli combination(lli n, lli r){
    return fact[n] *inv[n-r] %mod *inv[r] %mod;
}

int main(){
    maketable();
    while(1){
        int a,b,c,sx,sy;
        cin >> a >> b >> c >> sx >> sy;
        int n = a+b+c;
        if(n == 0) break;

        lli ans = 0;
        lli winpos = fact[n] *inv[a] %mod *inv[b] %mod *inv[c] %mod;
        for(int base=0; sx-base>=a and sy-base>=b; base++){
            if(sx-base > 0 and a==0) continue;
            if(sy-base > 0 and b==0) continue;
            lli sub = winpos;
            sub *= combination(n-1 +base, n-1);
            sub %= mod;
            if(a > 0){
                sub *= combination(sx-base-1, a-1);
                sub %= mod;
            }
            if(b > 0){
                sub *= combination(sy-base-1, b-1);
                sub %= mod;
            }
            ans += sub;
            ans %= mod;
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 49980
#include <iostream>
#include <vector>
#include <math.h>
#include <limits.h>

using namespace std;
int dist(int x1,int y1,int x2,int y2){
  return abs(x1-x2)+abs(y1-y2);
}

int main(){
  ios::sync_with_stdio(false), cin.tie(0);
  int N,M;
  vector<int> a,b,c,d;
  cin >> N >> M;
  a.resize(N);
  b.resize(N);
  c.resize(M);
  d.resize(M);
  for(int i=0;i<N;i++){ cin >> a[i] >> b[i]; }
  for(int j=0;j<M;j++){ cin >> c[j] >> d[j]; }
  for(int i=0;i<N;i++){
    int min=INT_MAX;
    int index=0;
    for(int j=0;j<M;j++){
      int distance = dist(a[i],b[i],c[j],d[j]);
      if(min >  distance ){
         min = distance;
         index=j;
      }
     }
     cout << index+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////

ll pow(ll d) {
	if (d == 0) { return 1; }
	else { return 10 * pow(d - 1); }
}

void query(ll n) {
	cout << "? " << n << endl;
	cout << flush;
}

void ans(ll n) {
	cout << "! " << n << endl;
	cout << flush;
}

int main() {
	char one[11];

	rep(i, 11) {
		query(pow(i));
		cin >> one[i];
	}

	if (one[10] == 'Y') {

		ll t = 1;
		rep(i, 10) {
			query(2 * pow(i));
			char c;
			cin >> c;
			if (c == 'Y') { ans(pow(i)); return 0; }
		}
	}

	else {
		ll d;//桁数
		rep(i, 11) {
			if (one[i] == 'N') { d = i - 1; break; }
		}
		
		ll l = pow(d);
		ll r = pow(d+1) - 1;

		while (r - l > 1) {
			ll m = (r + l) / 2;
			query(m*10);
			char c;
			cin >> c;
			if (c == 'Y') { r = m; }
			else { l = m; }
		}

		ans(r);
		return 0;

	}
	
	system("PAUSE");
}


Measured memory_bytes: 648
import java.util.Scanner;

public class Main {
	public static int gcd(int m,int n) {
		while(true){
			int r;
			r=m%n;
			if(r==0) return n;
			m=n;
			n=r;
		}
	}
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int m,n,ans;
		while(sc.hasNext()){
			m=sc.nextInt();
			n=sc.nextInt();
			ans=gcd(m,n);
			System.out.println(ans);
		}
	}
}

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

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

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

deque<int> dq;

const int MAXN = 2e5 + 5;

int a[MAXN];

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

  REP(i, n) {
    if((i % 2 + n % 2) % 2) {
      dq.push_front(i);
    }
    else {
      dq.push_back(i);
    }
  }

  REP(i, n) {
    cin >> a[i];
  }

  REP(i, n) {
    cout << a[dq[i]] << " ";
  }
}


Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <map>

using std::cin;
using std::cout;
using std::endl;
using std::string;

int main()
{
	int n;
	string str;
	std::map<string, int> map;

	// input
	// calc
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> str;
		map[str] = 1;
	}

	// output
	cout << map.size();
	cout << endl;

	return 0;
}

Measured memory_bytes: 19256
/*
  B - Choose Integers
  <http://abc060.contest.atcoder.jp/tasks/abc060_b>
*/

#include <stdio.h>

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

  int A,B,C;
  int k;

  scanf("%d %d %d", &A, &B, &C);
  for( k=1; k<=B; k++ ){
    if( (k*A)%B == C ){
      printf("YES");
      return 0;
    }
  }
  printf("NO");
  return 0;
}


Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> 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().expect("failed to parse token")
}

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let c: i64 = read();
    let mut ans = a;
    if a == b {
        ans = c;
    }
    if b == c {
        ans = a;
    }
    if c == a {
        ans = b;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int h, a;
    cin >> h >> a;

    cout << (h + a - 1) / a << endl;

    return 0;
}

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

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

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

  bool flag = true;
  int num = 0;

  char x, y; cin >> x >> y;
  if (x < y) cout << "<";
  else if (x > y) cout << ">";
  else cout << "=";
  cout << endl;

  // cout << num << endl;
  // cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n = int(input())
ans = 0

for i in range(1,n+1,2):
    if len(make_divisors(i)) == 8:
        ans += 1

print(ans)

Measured memory_bytes: 3060
use std::io;

fn main() {
    let mut x = String::new();
    let mut a = String::new();
    let mut b = String::new();
    io::stdin().read_line(&mut x)
        .expect("");
    io::stdin().read_line(&mut a)
        .expect("");
    io::stdin().read_line(&mut b)
        .expect("");
    let x: i32 = x.trim().parse().unwrap();
    let a: i32 = a.trim().parse().unwrap();
    let b: i32 = b.trim().parse().unwrap();
    let ans = (x - a) % b;
    println!("{}", ans)
}


Measured memory_bytes: 4352
use utf8;
use strict;

chomp(my $line = <STDIN>);
my @ls = split " ", $line;
my @ref = qw/2 3 4 5 6 7 8 9 10 11 12 13 1/;
my ($a_inx) = grep { $ref[$_] == int $ls[0]} 0 .. $#ref;
my ($b_inx) = grep { $ref[$_] == int $ls[1]} 0 .. $#ref;
if ($a_inx < $b_inx){
    print "Bob\n";
}elsif($a_inx > $b_inx){
    print "Alice\n";
}else{
    print "Draw\n";
}

Measured memory_bytes: 512
import sys

def sum_of_digits(x):
	sum = 0
	while x > 0:
		sum += x % 10
		x = x // 10

	return sum

#fin = open("test.txt", "r")
fin = sys.stdin

while True:
	x = int(fin.readline())

	if x == 0:
		break

	print(sum_of_digits(x))

Measured memory_bytes: 7740
<?php
error_reporting(0);
//list($N,$M,$R) = explode(" ",trim(fgets(STDIN)));
$N = trim(fgets(STDIN));
$K = trim(fgets(STDIN));
$x = explode(" ",trim(fgets(STDIN)));
$res=0;
for($i=0;$i<$N;$i++) {
  $b = $K - $x[$i];
  $a = $x[$i];
  if ($a < $b) {
    $res+=$a*2;
  }
  else {
    $res+=$b*2;
  }
}
printf("%d\n",$res);


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int a = in.Int();
            int b = in.Int();
            if ((a * b) % 2 == 1) {
                out.println("Odd");
            } else {
                out.println("Even");
            }
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21332
import math

n, m, x = input().strip().split(' ')
N, M, X = [int(n), int(m), int(x)]
tollGates  = list(map(int, input().strip().split(' ')))
grids = [int(0)] * N
for i in tollGates:
    grids[i]=1
# print(min(sum(grids[0:X],grids[X+1:N-1])))
print(min(sum(grids[0:X]),sum(grids[X+1::])))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int vis[105];
int main(){
	int x,n;
	cin>>x>>n;
	if(n==0){
		cout<<x;
		return 0;
	}
	int num[n];
	for(int i=0;i<n;i++){
		cin>>num[i];
		vis[num[i]]=1;
	}
	int step=0;
	while(1){
		if(!vis[x-step]){
			cout<<x-step;
			break;
		}
		if(!vis[x+step]){
			cout<<x+step;
			break;
		}
		step++;
	}
	return 0;
}

Measured memory_bytes: 3624
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		//標準入力取得インスタンス生成
		Scanner sc = new Scanner (System.in);
		
		//とる枚数
		int takeCard = sc.nextInt();
		Integer[] arrayCard = new Integer[takeCard];
		int box = 0;
		
		//Alice合計
		int sumAlice = 0;
		//Bob合計
		int sumBob = 0;
		
		if(takeCard >= 1 && takeCard <= 100) {
			
			//取ったカードの枚数だけ、配列に格納
			for(int i = 0; i < takeCard; i++) {
				arrayCard[i] = sc.nextInt();
			}
			
			//arrayCardを大きい順にソート
			Arrays.sort(arrayCard,Collections.reverseOrder());
			/*
			for(int i = 0; i < arrayCard.length; i++) {
				for(int j = i; j < arrayCard.length; j++) {
					if(arrayCard[i] < arrayCard[j]) {
						box = arrayCard[i];
						arrayCard[i] = arrayCard[j];
						arrayCard[j] = box;	
					}
				}
			}
			*/
			//
			for(int i = 0; i < arrayCard.length; i++) {
				if((i == 0) || (i % 2 == 0)) {
					sumAlice += arrayCard[i];
				}else {
					sumBob += arrayCard[i];
				}
			}
			
			//答え
			int ans = sumAlice - sumBob;
			//標準出力
			System.out.println(ans);
			
		}else {
			System.out.print("制約NG");
		}
		
	    // Scannerインスタンスをクローズ
	    sc.close();
	}

}

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

int main() {
    int n;
    cin >> n;
    vector<int> v(100002);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        a++;
        v.at(a - 1)++;
        v.at(a)++;
        v.at(a + 1)++;
    }

    int ans = 0;
    for (int i = 0; i <= 100001; i++) {
        ans = max(ans, v.at(i));
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    bool b = 0;
    int x;
    for(int i = 0; i < n; i++){
        cin >> x;
        if(x % 2 == 1){
            b = 1 - b;
        }
    }
    if(b){
        cout << "NO";
    }
    else{
        cout << "YES";
    }
}


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

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

const int mod  = 100003;
const int maxn = 4e3+10;

int dp[3050][3050];
char a[maxn];
char b[maxn];
int n,m;
int c[maxn];
int pre[maxn];
int lis[maxn];
int main()
{
    scanf("%s",a);
    scanf("%s",b);
    n=strlen(a);
    m=strlen(b);
    for(int i=n-1;i>=0;i--)
    {
        for(int j=m-1;j>=0;j--)
        {
            if(a[i]==b[j])
                dp[i][j]=dp[i+1][j+1]+1;
            else
                dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
        }
    }
    int i=0;
    int j=0;
    while(i<n&&j<m)
    {
        if(a[i]==b[j])
        {
            putchar(a[i]);
            i++;
            j++;
        }else if(dp[i][j]==dp[i+1][j])
        {
            i++;
        }else
        {
            j++;
        }
    }

    return 0;
}


Measured memory_bytes: 39448
#include <queue>
#include <stdio.h>
#include <string.h>
#define R register
#define MN 100005
std::deque<int> q;
int k,dis[MN];bool vis[MN];
int main(){
	scanf("%d",&k);
	memset(dis,0x3f,sizeof(dis));
	dis[1]=0;q.push_back(1);
	while(!q.empty()){
		R int x=q.front();q.pop_front();
		if (vis[x]) continue;
		if (!x) break;vis[x]=1;
		if (dis[x*10%k]>dis[x]){
			dis[x*10%k]=dis[x];
			q.push_front(x*10%k);
		}
		if (dis[x+1==k?0:x+1]>dis[x]+1){
			q.push_back(x+1==k?0:x+1);
			dis[x+1==k?0:x+1]=dis[x]+1;
		}
	}printf("%d\n",dis[0]+1);return 0;
}

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

using namespace std;
#define ll long long 
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
  ll n, k, q;
  ll a[100050] = {};
  ll b[100050] = {0};
  cin >> n >> k >> q;
  
  REP(i, q) cin >> a[i];

  REP(i, q) b[a[i] - 1]++;

  REP(i, n) 
    if(k <= q - b[i]){
      cout << "No" << endl;
    }else{
      cout << "Yes" << endl;
    }
}


Measured memory_bytes: 2176
S = input()

if S[0] != 'A' or S[1].isupper():
  print('WA')
  exit()

ct = {}
for c in S[2:-1]:
  ct[c] = ct.get(c, 0) + 1

if ct.get('C', 0) != 1 or S[-1].isupper():
  print('WA')
  exit()

print('AC')

Measured memory_bytes: 3060
R,G,B = map(int,input().split())
K = int(input())

for i in range(K):
    if G <= R:
        G *= 2
    elif B <= G:
        B *= 2
    # print('Green: ' + str(G) + ' blue:' + str(B))



if R < G and G < B:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int n, k;
ll a[200010];

bool isOK(ll x) {
    ll cnt = 0;
    rep(i, n) cnt += (a[i] + x - 1) / x - 1; 
    if (cnt <= k) return true;
    else return false;
}

ll binary_search(ll key) {
    ll ng = 0;
    ll ok = 1e+9+7;
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (isOK(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){
    cin >> n >> k;
    rep(i, n) cin >> a[i];
    cout << binary_search(k) << endl;

    return 0;
}

Measured memory_bytes: 5084