akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

void solve()
{
    int n;cin>>n;
	vector<vector<int> >t(n);
	vector<pair<int,int>>ab;
	rep(i,1,n){
		int a,b;cin>>a>>b;
		a--;b--;
		t[a].pb(b);
		t[b].pb(a);
		ab.pb(mp(a,b));
	}

	queue<int>que;	que.push(0);
	vector<bool>used(n,0);	used[0]=1;
	vector<int>parentcolor(n,0);
	map<pair<int,int>,int> ans;
	int k=0;
	while(!que.empty()){
		int u=que.front();que.pop();
		k=max(k,(int)t[u].size());
		int color=1;int pc=parentcolor[u];
		for(auto v:t[u]){
			if(used[v])continue;
			if(color==pc)color++;
			parentcolor[v]=ans[mp(u,v)]=ans[mp(v,u)]=color++;
			used[v]=1;
			que.push(v);
		}
	}

	cout<<k<<endl;
	for(auto it:ab)cout<<ans[it]<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 19704
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static final void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int R = sc.nextInt();
        ArrayList<Integer> r = new ArrayList<>();
        int[][] d = new int[N + 1][N + 1];
        int[][] md = new int[R][R];
        ArrayList<Integer>[] linked = new ArrayList[N + 1];
        for (int i = 0; i < R; i++) r.add(sc.nextInt());
        for (int i = 0; i < N + 1; i++) {
            linked[i] = new ArrayList<>();
            Arrays.fill(d[i], -1);
        }
        for (int i = 0; i < M; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            linked[a].add(b); linked[b].add(a);
            d[a][b] = d[b][a] = c;
        }
        for (int i = 0; i < R - 1; i++) {
            for (int j = i + 1; j < R; j++) {
                int s = r.get(i);
                int g = r.get(j);
                boolean[] visited = new boolean[N + 1];
                PriorityQueue<Pair> stk = new PriorityQueue<>();
                stk.add(new Pair(0, s));
                while (true) {
                    Pair p = stk.poll();
                    visited[p.b] = true;
                    if (p.b == g) {
                        md[i][j] = md[j][i] = p.a;
                        break;
                    }
                    for (int nc : linked[p.b]) {
                        if (!visited[nc]) {
                            stk.add(new Pair(p.a + d[p.b][nc], nc));
                        }
                    }
                }
            }
        }

        int ans = Integer.MAX_VALUE;
        int BR = (1 << R);
        int[][] dp = new int[BR][R];
        for (int i = 0; i < BR; i++) Arrays.fill(dp[i], Integer.MAX_VALUE);
        for (int s = 0; s < R; s++) {
            for (int i = 0; i < R; i++) {
                dp[1 << i][i] = md[s][i];
            }
            for (int S = 1; S < BR; S++) {
                for (int i = 0; i < R; i++) {
                    if ((S & (1 << i)) == 0) continue;
                    for (int j = 0; j < R; j++) {
                        if ((S & (1 << j)) != 0) continue;
                        int newDist = dp[S][i] + md[i][j];
                        if (dp[S|(1 << j)][j] > newDist) {
                            dp[S|(1 << j)][j] = newDist;
                        }
                    }
                }
            }
            if (dp[BR - 1][s] < ans) {
                ans = dp[BR - 1][s];
            }
        }

        System.out.println(ans);
    }

    static class Pair implements Comparable<Pair> {
        public int a, b;
        public Pair(int a, int b) {
            this.a = a; this.b = b;
        }

        @Override
        public int compareTo(Pair o) {
            return Integer.compare(a, o.a);
        }
    }
}


Measured memory_bytes: 49924
#include <stdio.h>

int main()
{
    int n,i,j,k,l,a,point;
    scanf("%d",&n);
    int p[50];
    for(k = 0;k < n;k++)
    {
        scanf("%d",&p[k]);
    }
    for(i = 0;i < n;i++)
    {
        for(j = 0;j < n;j++)
        {
            a =  p[i];
            p[i] = p[j];
            p[j] = a;
            for(l = 0;l < n;l++)
            {
                if(p[l] == l + 1)
                {
                    point++;
                }
            }
            if(point == n)
            {
                break;
            }
            point = 0;
            p[j] = p[i];
            p[i] = a;
        }
        if(point == n)
        {
            printf("YES");
            break;
        }
    }
    if(point == 0)
    {
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 128
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)

void debug_out() {}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

int run(istream& in, ostream& out) {
    ll N, K;
    in >> N >> K;
    vector<ll> H(N);
    REP(i, N) {
        in >> H[i];
    }
    sort(H.begin(), H.end(), std::greater<ll>());
    ll ans = 0;
    if (K < N) {
        REP(i, K) {
            H[i] = 0;
        }
        REP(i, N) {
            ans += H[i];
        }
    }
    out << ans << endl;
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 1792
def dist(a, b, x, y, h):
    return h + abs(a - x) + abs(b - y)

N = int(input())
P = []
for i in range(N):
    x, y, h = map(int, input().split())
    P.append([h, x, y])
P.sort(reverse = True)

for i in range(101):
    for j in range(101):
        H = dist(i, j, P[0][1], P[0][2], P[0][0])
        for p in P[1:]:
            if max(H - abs(p[1]-i)-abs(p[2]-j), 0) != p[0]:
                break
        else:
            print(i, j, H)
            break

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    ll n,k; cin >> n >> k;
    cout << min(n%k, k - n%k);
    return 0;
}

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


int main()
{
    int n;
    cin>>n;
    int b[n-1],a[n];
    for(int i=0;i<n-1;i++)
    {
        cin>>b[i];
    }
    a[0]=b[0];
    a[n-1]=b[n-2];
    for(int i=1;i<n-1;i++)
    {
        a[i]=min(b[i],b[i-1]);
    }
    int s=0;
    for(int i=0;i<n;i++)
    {
        s+=a[i];
    }
    cout<<s<<endl;


}



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

int main(){
	int n,b=1,c=0,d;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	while(a[b-1]!=0&&a[b-1]!=2){
		d=b;
		b=a[b-1];
		a[d-1]=0;
		c++;
	}
	if(a[b-1]==2) cout<<c+1<<endl;
	else cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 640
//fold
#ifndef KHALIL
#include <bits/stdc++.h>
#else
#include "header.h"
#endif
#define endl '\n'
#define mp make_pair
#define tostr(x) static_cast<ostringstream&>((ostringstream()<<dec<<x)).str()
#define rep(i,begin,end) for(auto i = begin;i < end;i++)
#define repr(i,begin,end) for(auto i = begin-1;i >= end;i--)
#define pb push_back
#define sz(a) ((int)(a).size())
#define fi first
#define se second
#define abs(a) ((a) < (0) ? (-1)*(a) : (a))
#define SQ(a) ((a)*(a))
#define eqd(a,b) (abs(a-b)<1e-9)
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename t> t in(t q){cin >> q;return q;}
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v){os << "[";for (int i = 0; i < sz(v); ++i) { os << v[i]; if (i != sz(v) - 1) os << ",";}os << "]";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const map<T, S>& v){for (auto it : v)os << "(" << it.first << ":" << it.second << ")";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const pair<T, S>& v){os << "(" << v.first << "," << v.second << ")";return os;}
const long double PI = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
//endfold
#define  N  (200'005)
#define MOD (1000000000l + 7l)
#define OO (1050000000)
#define OOL (1100000000000000000ll)

//global
int n;
ll a[N];
ll dp[N][2];

ll ans(int i, bool t){
	if(i >= n) return t*(-OOL);
	if(a[i]-t < 0) return -OOL;
	if(dp[i][t] != -1) return dp[i][t];
	if(a[i]-t == 0){
		dp[i][t] = ans(i+1,0);
		return dp[i][t];
	}
	dp[i][t] = max(ans(i+1,1)+(a[i]-t-1)/2+1,ans(i+1,0)+(a[i]-t)/2);
	return dp[i][t];
}

int main(){
	//fold
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << setprecision(10);
	//endfold
	memset(dp,-1,sizeof dp);
	cin >> n;
	rep(i,0,n){
		cin >> a[i];
	}
	cout << ans(0,0) << endl;
	return 0;
}

Measured memory_bytes: 9088
#include <iostream>
#include <algorithm>
#include <string>
#define int long long
using namespace std;
int gcd(int a, int b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a%b);
}
signed main() {
	int n, x; cin >> n >> x;
	int ans;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		if (i)ans = gcd(ans, abs(x - a));
		else ans = abs(x - a);
	}cout << ans << endl;
}

Measured memory_bytes: 256
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
const int INF = 1e9;
const int MX = (3e5);
Long T[1LL << 20];
Long N = 1;
void update(Long pos, Long val) {
  pos += N;
  T[pos] += val;
  while (pos > 0) {
    pos >>= 1;
    T[pos] = max(T[2 * pos], T[2 * pos + 1]);
  }
}
Long query(Long l, Long r) {
  l += N;
  r += N;
  Long ans = 0;
  while (l < r) {
    //cout << l << " " << r << endl;
    if (l & 1) ans = max(ans, T[l++]);
    if (r & 1) ans = max(ans, T[--r]);
    l >>= 1;
    r >>= 1;
  }
  return ans;
}
map<Long, vector<Long>> px, py;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int n, m, q;
  cin >> n >> m >> q;
  while (N < m) N <<= 1;
  while (q--) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    px[a].pb(b);
    py[b].pb(a);
    update(b, +1);
  }
  Long ans = 0;
  fore(i, 0, MX) {
    //fijo el I, entonces la respuesta actual es
    Long cur = SZ(px[i]);
    for (Long x : px[i]) {
      update(x, -1);
    }
    cur += query(0, MX);
    ans = max(ans, cur);
    for (Long x : px[i]) {
      update(x, +1);
    }
  }
  cout << ans << '\n';

  return 0;
}

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

int main(void) {
  int N, M;
  cin >> N >> M;
  bool danger[N + 1] = {};
  long long dp[N + 1] = {}, mod = 1000000007;
  for (int i = 0; i < M; i++) {
    int d;
    cin >> d;
    danger[d] = true;
  }

  dp[0] = 0;
  dp[1] = danger[1] ? 0 : 1;
  dp[2] = danger[2] ? 0 : dp[1] + 1;

  for (int i = 3; i <= N; i++) {
    if (danger[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
  }

  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<iomanip>

using namespace std;

typedef long long ll;

int main(){
  ll W,H,x,y; cin >> W >> H >> x >> y;
  
    cout << setprecision(9) <<  (long double)( W * H) / 2 << " ";
   if( x + x == W && y + y == H){ cout << '1';}
  else{cout << '0';}
  
      
  return 0;}
  


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    total = 3**N
    odd = 1
    for i in range(N):
        if A[i]%2==0:
            odd *= 2
    print(total-odd)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
eval"H,W,*A="+`dd`.split*?,
a=
d=[1<<t=10**4]+[0]*~-W
A.pop(H*W).zip(A){|a,b|a=(a-b).abs;d.size%W<1&&N=0;N|=d[-W];d<<N=N<<a|N>>a}
p (0..2*t).map{|i|(t-i*N[i]).abs}.min

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<vector<P>> te(n, vector<P>());
    rep(i,n) {
        cin >> a[i];
        rep(j,a[i]) {
            int x, y;
            cin >> x >> y;
            x--;
            te[i].push_back(P(x,y));
        }
    }

    int bit = pow(2,n);
    int ans = 0;
    for (int i = 0; i <= bit; ++i) {
        vector<int> p(n);
        rep(j,n) if ((i>>j)&1) p[j] = 1;
        int now = 0;
        bool flag = true;
        rep(j,n) if (p[j]) {
            now++;
            rep(k,a[j]) if (p[te.at(j).at(k).first] != te.at(j).at(k).second) flag = false;
        }
        
        if (flag) ans = max(ans, now);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def dist(p, q):
    return abs(p[0] - q[0]) + abs(p[1] - q[1])

n = int(input())
ans = 0
peri = []
P = [tuple(map(int, input().split())) for _ in range(n)]
P.sort(key=lambda p: (p[0], p[1]))
peri.append(max(P, key=lambda p: (p[0], p[1])))
peri.append(min(P, key=lambda p: (p[0], p[1])))
peri.append(max(P, key=lambda p: (p[0], -p[1])))
peri.append(min(P, key=lambda p: (p[0], -p[1])))
peri.append(max(P, key=lambda p: (-p[0], p[1])))
peri.append(min(P, key=lambda p: (-p[0], p[1])))
peri.append(max(P, key=lambda p: (-p[0], -p[1])))
peri.append(min(P, key=lambda p: (-p[0], -p[1])))
peri.append(max(P, key=lambda p: (p[1], p[0])))
peri.append(min(P, key=lambda p: (p[1], p[0])))
peri.append(max(P, key=lambda p: (-p[1], p[0])))
peri.append(min(P, key=lambda p: (-p[1], p[0])))
peri.append(max(P, key=lambda p: (p[1], -p[0])))
peri.append(min(P, key=lambda p: (p[1], -p[0])))
peri.append(max(P, key=lambda p: (-p[1], -p[0])))
peri.append(min(P, key=lambda p: (-p[1], -p[0])))
peri.append(max(P, key=lambda p: p[0]+p[1]))
peri.append(max(P, key=lambda p: -p[0]+p[1]))
peri.append(max(P, key=lambda p: p[0]-p[1]))
peri.append(max(P, key=lambda p: -p[0]-p[1]))

peri = set(peri)

for p in P:
    for q in peri:
        ans = max(ans, dist(p, q))
print(ans)

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define N             (int)(1e6+5)
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    int a,b; cin>>a>>b;
    int a1=0,a2=0;
    rep(i,1,a){
        a1+=b;
        a1*=10;
    }
    rep(i,1,b){
        a2+=a;
        a2*=10;
    }
    cout<<max(a1/10,a2/10);
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}


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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=302;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

int n,m;
int a[M+2][M+2];
int col_pos_in_row[M+2];
bool chk(int mx)
{
    queue<int>q;
    int cnt[m+2],vis[m+2];clr(vis);
    f(i,1,n)col_pos_in_row[i]=1;
    clr(cnt);
    for(int i=1;i<=n;i++)
    {
         cnt[a[i][1]]++;
         if(cnt[a[i][1]]>mx && vis[a[i][1]]==0)
         {
             q.push(a[i][1]);
             vis[a[i][1]]=1;
         }
    }
    while(!q.empty())
    {
        int game=q.front();
        q.pop();
        for(int i=1;i<=n;i++)
        {
            if(a[i][col_pos_in_row[i]]==game)
            {
                while(1)
                {
                    col_pos_in_row[i]++;
                    if(col_pos_in_row[i]>m)return false;
                    int gm=a[i][col_pos_in_row[i]];
                    if(vis[gm]==0)
                    {
                        break;
                    }
                }
                int ngm=a[i][col_pos_in_row[i]];
                cnt[ngm]++;
                if(cnt[ngm]>mx && vis[ngm]==0)
                {
                    q.push(ngm);
                    vis[ngm]=1;
                }
            }
        }
    }
    return true;
}
 main()

{
    fast
    cin>>n>>m;
    f(i,1,n)f(j,1,m)cin>>a[i][j];
    int lo=1,hi=n;
    while(hi-lo>=2)
    {
        int mid=(lo+hi)>>1;
        if(chk(mid))hi=mid;
        else lo=mid+1;
    }
    f(i,lo,hi)
    {
        if(chk(i))
        {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"ERROR"<<endl;
    return 0;

}





































Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n;
    cin>>n;
    vector<ll>a(n);
    map<ll,ll>m;
    rep(i,n){
        cin>>a[i];
        m[a[i]]=i;
    }
    ll cnt=0;
    sort(all(a));
    rep(i,n){
        if(i%2!=m[a[i]]%2)cnt++;
    }
    cout<<cnt/2<<endl;
}

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

const int N = 1e+5 + 5;
long long int n, W, w[103], v[103];
long long int dp[103][N];

int main()
{
    cin >> n >> W;
    for (int i = 1; i <= n; i++)
        cin >> w[i] >> v[i];

    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= W; j++)
        {
            dp[i][j] = dp[i - 1][j];
            if (j >= w[i])
                dp[i][j] = max(dp[i][j], dp[i-1][j - w[i]] + v[i]);
        }
    }
    cout<<dp[n][W];
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

template <typename T> using Matrix = vector<vector<T>>;

template <typename T>
void warshall_floyd(Matrix<T> &g, T inf) {
  for (int k = 0; k < g.size(); k++) {
    for (int i = 0; i < g.size(); i++) {
      for (int j = 0; j < g.size(); j++) {
        if (g[i][k] == inf || g[k][j] == inf) continue;
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
}

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

  int H,W;
  cin >> H >> W;
  auto c = make_v<int>(10,10);
  cin >> c;
  auto A = make_v<int>(H,W);
  cin >> A;
  warshall_floyd<int>(c,INF);
  int ans = 0;
  REP(i,H) REP(j,W) if (A[i][j] >= 0) ans += c[A[i][j]][1];
  cout << ans << endl;

  return 0;
}

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

int main()
{
  int64_t n;
  cin >> n;
  valarray<int64_t> v(5);
  for (auto&& e : v) cin >> e;
  cout << (n + v.min() - 1) / v.min() + 4 << endl;
}


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

string a;
string b;
int n;
int last;
using ll =long long;
ll ans;
const ll MOD=1e9+7;

int main()
{
    cin>>n>>a>>b;
    for (int i=0;i<n;i++)
    {
        if (a[i]==b[i])
        {
            if (last==0) ans=3;
            else if (last==1) ans=(ans*2)%MOD;//shu zhe de
            else if (last==2) ;
            last=1;
        }
        else
        {
            if (last==0) ans=6;
            else if (last==1) ans=(ans*2)%MOD;//shu zhe de
            else if (last==2) ans=(ans*3)%MOD;
            last=2;
            i++;
        }
    }
    cout<<ans<<endl;
}

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

int main(void){
	int x[3],temp;
	cin >> x[0] >> x[1] >> x[2];
	
	for (int i = 0; i < 3-1; i++){
		for (int j = 3-1; j>i; j--){
			if (x[j] <  x[j-1]){
				temp = x[j];
				x[j] = x[j-1];
				x[j-1] = temp;
			}
		}
	}

	cout << x[0] << " " << x[1] << " " << x[2] << "\n";

	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;
using P = pair<int, int>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  int n;
  cin >> n;

  map<pair<int, int>, int> mp;

  for (int i = 1; i <= n; i++) {
    int xx;
    if (i >= 100000) xx = i / 100000;
    else if (i >= 10000) xx = i / 10000;
    else if (i >= 1000) xx = i / 1000;
    else if (i >= 100) xx = i / 100;
    else if (i >= 10) xx = i / 10;
    else xx = i;
    int yy = i % 10;
    mp[{xx, yy}]++;
  }

  int ans = 0;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      ans += mp[{i, j}] * mp[{j, i}];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			C();
		}
		public static void C()
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int m = cin.Int();
			int[] ls = new int[m];
			int[] rs = new int[m];
			for (int i = 0; i < m; i++) {
				ls[i] = cin.Int();
				rs[i] = cin.Int();
			}

			int min = 1;
			int max = n;
			for (int i = 0; i < m; i++) {
				if (ls[i] > min) {
					min = ls[i];
				}

				if (rs[i] < max) {
					max = rs[i];
				}
			}

			int count = max - min + 1;
			if (count < 0) {
				count = 0;
			}
			Console.WriteLine(count);
		}

	}

	public class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 17340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string S;
    cin >> S;
    int cnt = 0;
    string ans = "            ";
    for(int i=0;i<S.size();i++){
        if(S[i]=='0'){
            ans[cnt] = '0';
            cnt++;
        }else if(S[i]=='1'){
            ans[cnt] = '1';
            cnt++;
        }else{
            if(cnt>0){
                cnt--;
            }
        }
    }
    string ans_ = ans.substr(0,cnt);
    cout << ans_ << endl;
    return 0;
}

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

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.st <<","<<P.nd <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAXN = 1e6+6;

int x, y, a, b, c;
LL res;
int red[MAXN];
int green[MAXN];
int lack[MAXN];

void read(int t[], int n) {
  for (int i = 1; i <= n; ++i) {
    cin >> t[i];
  }
  sort(t + 1, t + 1 + n);
}

int main() {
  cin >> x >> y >> a >> b >> c;
  read(red, a);
  read(green, b);
  read(lack, c);

  priority_queue<pair<int, int>> q;
  for (int i = a; i >= 1; --i) {
    if (x == 0) {
      break;
    }
    --x;
    q.push({-red[i], 0});
    debug(red[i]);
  }

  for (int i = b; i >= 1; --i) {
    if (y == 0) {
      break;
    }
    --y;
    q.push({-green[i], 0}); 
    debug(green[i]);
  }

  for (int i = c; i >= 1; --i) {
    int low = -q.top().first;
    int col = q.top().second;
    if (lack[i] <= low) {
      break;
    }
    debug(lack[i], low);
    q.pop();
    q.push({-lack[i], col});
  }

  while (!q.empty()) {
    auto x = q.top();
    res += (LL)-x.first;
    q.pop();
  }

  cout << res << endl;
}


Measured memory_bytes: 10996
#include<bits/stdc++.h>
using namespace std;
long long pi = 3.14159265358979323846264338327;
int a,b,ans=0;
int main() {
	cin >> a >> b;
	ans += max(a,b);
	ans += max(max(a,b)-1,min(a,b));
	cout << ans << endl;
 	return 0;
}


Measured memory_bytes: 3504
t_hp, t_atk, a_hp, a_atk = map(int, input().split())
t_life_span = -(-t_hp//a_atk)
a_life_span = -(-a_hp//t_atk)
#print(t_life_span,a_life_span)
print("Yes" if t_life_span >= a_life_span else "No")

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


int main() {
    long long int a, b;
    cin >> a >> b;
    long long int ans = -1;
    long long int A = a*12.5, B = b*10;
    if (a%2 == 0){
        if ((B-A < 13)&&(B-A > -10)) ans = max(A, B);
    }
    else {
        if ((B-A < 12)&&(B-A > -11)) ans = max(A+1, B);
    }
    cout << ans << endl;
}

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


for i in range(n):
    if a[i] >= b[i]:
      kill += b[i]
    else:
      kill += a[i]
      if a[i+1] >= b[i] - a[i]:
            a[i+1] -= b[i] - a[i]
            kill += b[i] - a[i]
      else:
          kill += a[i+1]
          a[i+1] = 0

print(kill)

Measured memory_bytes: 19156
#include<bits/stdc++.h>
using namespace std;
int a[60];
int main(){
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
    scanf("%d",&a[i]);
  int ans=0;
  for(int i=1;i<n;i++)
    for(int j=i+1;j<=n;j++)
      ans+=a[i]*a[j];
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

vector<ll> Eratosthenes(const ll N) {
  bool is_prime[1000000 + 1];
  vector<ll> P;
  for (ll i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  for (ll i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (ll j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  int n;
  cin >> n;
  ivec p(n), q(n);
  REP(i, n) { cin >> p[i]; }
  REP(i, n) { cin >> q[i]; }

  ivec a(n);
  REP(i, n) { a[i] = i + 1; }

  map<ivec, int> mp;
  do {
    mp[a] = mp.size();
  } while (next_permutation(ALL(a)));

  int ans = abs(mp[p] - mp[q]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
 
using namespace std;
 
typedef long long ll;
const ll nmax = 1e9 + 7;
const ll mod = 998244353;
const double PI = 2 * asin(1);

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  for (int i = 100; i > 0; i--) {
    if (A % i == 0) {
      if (B % i == 0) {
        K--;
        if (K == 0) {
          cout << i << endl;
          break;
        };
      };
    };
  };
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        double[] arr = Console.ReadLine().Split(' ').Select(v => double.Parse(v)).ToArray();
        IEnumerable<double> arrTwo = Console.ReadLine().Split(' ').Select(v => double.Parse(v));
        double line =  arrTwo.Sum() / 4 / arr[1];
        double count = arrTwo.Where(v => v >= line).Count();
        Console.WriteLine(count >= arr[1] ? "Yes" : "No");


    }

  

}



Measured memory_bytes: 18984
#include<bits/stdc++.h>
int main()
{
    char x;
    scanf("%c",&x);
    if(x=='A')
    {
        printf("T");
    }
    else if(x=='T')
    {
        printf("A");
    }
    else if(x=='C')
    {
        printf("G");
    }
    else if(x=='G')
    {
        printf("C");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]

INF = 10 ** 12

def solve(n, cost, a, b, c):
	if n == N:
		if 0 == min(a, b, c):
			return INF
		return abs(a - A) + abs(b - B) + abs(c - C) + cost - 30
	ret1 = solve(n + 1, cost, a, b, c)
	ret2 = solve(n + 1, cost + 10, a + L[n], b, c)
	ret3 = solve(n + 1, cost + 10, a, b + L[n], c)
	ret4 = solve(n + 1, cost + 10, a, b, c + L[n])
	return min(ret1, ret2, ret3, ret4)

print(solve(0, 0, 0, 0, 0))


Measured memory_bytes: 3064
n, m = input().split()
l = sorted(list(map(int, input().split())))
sum_touhyou = sum(l)
line_touhyou = sum_touhyou * (1 / (int(m) * 4))

r = [i for i in l if i >= line_touhyou]

if len(r) >= int(m):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var n = ReadLineStringSplit();
            var re = "NO";

            if(int.Parse(n[0] + n[1] + n[2]) % 4 == 0) {
                re = "YES";
            }

            Console.WriteLine(re);
            ReadLine();
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }
    }
}

Measured memory_bytes: 13268
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int maxWeight = scn.nextInt();
		int[][] itemvaw = new int[n+1][2];
		
		for(int i=1;i<=n;i++){
		    itemvaw[i][0] = scn.nextInt();
		    itemvaw[i][1] = scn.nextInt();
		}
		System.out.println(knapsack_dp(itemvaw,maxWeight));
	}
	
	public static long knapsack_dp(int[][] itemvaw, int capacity) {
		int n = itemvaw.length - 1;
		long[][] memo = new long[n + 1][capacity + 1];
		for (int cii = n; cii > 0; cii--) {
			for (int capacityLeft = capacity; capacityLeft > 0; capacityLeft--) {
				if (cii == n) {
					memo[cii][capacityLeft] = capacityLeft >= itemvaw[cii][0] ? itemvaw[cii][1] : 0;
					continue;
				}
				long o1 = capacityLeft - itemvaw[cii][0] >= 0 ?
				          itemvaw[cii][1] + memo[cii + 1][capacityLeft - itemvaw[cii][0]] : Integer.MIN_VALUE;
				// knapsack_memoized(cii + 1, itemvaw, capacityLeft - itemvaw[cii][0], memo)
				long o2 = memo[cii + 1][capacityLeft];
				// knapsack_memoized(cii + 1, itemvaw, capacityLeft, memo);
				memo[cii][capacityLeft] = Math.max(o1, o2);
			}
		}
		return memo[1][capacity];
	}
}


Measured memory_bytes: 140596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#define int long long
using namespace std;
string s;
signed main(){
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]>'C'){
            s[i]-=3;
        }else s[i]+=23;
    }
    cout<<s<<endl;
    return 0;
}

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

int top, data[1000];

void push(int x);
int pop();

int main(void)
{
    int a, b;
    top = 0;
    char moji[100];

    while (scanf("%s", moji) != EOF) {
        if (moji[0] == '+') {
            b = pop();
            a = pop();
            push(a + b);
        } else if (moji[0] == '-') {
            b = pop();
            a = pop();
            push(a - b);
        } else if (moji[0] == '*') {
            b = pop();
            a = pop();
            push(a * b);
        } else {
            push(atoi(moji));
        }
    }

    printf("%d\n", pop());

    return 0;
}

void push(int x)
{
    data[++top] = x;
}

int pop()
{
    top--;
    return data[top + 1];
}



Measured memory_bytes: 2132
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	int M = max(max(A, B), C);
	int sum = A + B + C;
	if ((M * 3 - sum) % 2) M++;

	cout << (M * 3 - sum) / 2 << endl;
}

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

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTS(s) printf("%s\n",(s))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

typedef long long ll;

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	int a, b, c;
	int x;
	scanf("%d %d %d %d", &a, &b, &c, &x);
	int ans = 0;
	REP(i, a+1) {
		REP(j, b+1) {
			REP(k, c + 1) {
				if (500 * i + 100 * j + 50 * k == x)ans++;
			}
		}
	}
	PRINTD(ans);
}

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

int main(void)
{
    long long int a,b,k;
    cin >> a >> b >> k;
    if(k<=a)
        cout << a-k << ' ' << b;
    else if(a+b<=k)
        cout << "0 0";
    else
        cout << "0 " << a+b-k;
    return 0;
}

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


void solve(long long A, long long B, long long C, long long K){

  if(K <= (A+B)) {
    cout << min(K, A) << endl;
  }
  else {
    cout << A - min(K-(A+B), C) << 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 A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long C;
  scanf("%lld",&C);
  long long K;
  scanf("%lld",&K);
    solve(A, B, C, K);
    return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    string s;
    int k;
    cin>>s>>k;
    set<string> ss;
    for(int j=1;j<=k;j++){
        for(int i=0;i<s.size()-j+1;i++){
            //cout<<"Yes"<<endl;
            ss.insert(s.substr(i,j));
            //cout<<s.substr(i,j)<<endl;
        }
    }
    int cnt = 0;
    for(auto u:ss){
        cnt++;
        //cout<<u<<endl;
        if(cnt==k){
            cout<<u<<endl;
        }
    }
    return 0;
}

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

using namespace std;

int main(){
  int n;
  int l[300001] = {};
  int r[300001] = {};
  int min_cost = 300002;
  string s;
  cin >> n;
  cin >> s;

  for (int i=0;i<n-1;i++) {
    if (s[i]=='W') {
      l[i+1] = l[i] + 1;
    } else {
      l[i+1] = l[i];
    }
    //    cout << l[i+1];
  }
  //    cout << endl;
  for (int i=n-1;i>0;i--) {
    if (s[i]=='E') {
      r[i-1] = r[i] + 1;
    } else {
      r[i-1] = r[i];
    }
  }
  for (int i=0;i<n;i++) {
    //    cout << r[i];
    if (min_cost > l[i] + r[i]) {
      min_cost = l[i] + r[i];
    }
  }
  //  cout << endl;
  cout << min_cost << endl;
  return(0);
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int n, k, ans=0;
	vector<int> v;

	cin>> n >> k;
	v.resize(n);

	rep(i, n) cin >> v[i];

	for(int i=k;i<n;i++){
		if(v[i-k]<v[i]) cout<< "Yes" << endl;
		else cout<< "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 4056
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
int main() {
	int N;
	int L;
	cin >> N >> L;
	int sum = 0;
	int min;
	int max;
	if (L > 0) {
		cout << L * N + N * (N + 1) / 2 - L-N;
	}
	else if (L + N - 1 < 0) {
		cout << L * N + N * (N + 1) / 2 - N - (L + N - 1);
	}
	else {
		cout << L * N + N * (N + 1) / 2 - N;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define vl vector<ll>
#define pl pair<ll,ll>
#define pb push_back
#define F first
#define S second
using namespace std;
ll tako(ll a,ll b)
{
	if(a>=b)
      return 1;
  return 1+tako(a,b-a+1);
}
int main()
{
	ll a,b;
	cin >> a >> b;
	if(b==1)
	cout << "0";
	else
	cout << tako(a,b);
	
	return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    set<int> st;
    while (k--)
    {
        int d;
        cin >> d;
        for (int i = 0; i < d; i++)
        {
            int x;
            cin >> x;
            st.insert(x);
        }
    }
    cout << n - st.size() << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <math.h>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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(){
    cin.tie(0);
   	ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> L(N);

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

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

    int L_sum;
    L_sum = 0;
    for(int i = 0; i < N-1; i++){
        L_sum += L[i];
    }

    if(L_sum > L[N-1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256