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

int H, W;
uint8_t d[2][190][190][190], pos[190][190][190], down[190][190];
char A[190][190];

int main() {
	scanf("%d%d", &H, &W);
	for (int i = 1; i <= H; ++i)
		scanf("%s", A[i] + 1);
	for (int i = H; i; --i)
		for (int j = 1; j <= W; ++j)
			if (i < H && A[i + 1][j] == A[i][j])
				down[i][j] = down[i + 1][j];
			else
				down[i][j] = i;
	for (int i = 1; i <= H; ++i)
		for (int l = W; l; --l) {
			d[0][i][l][l] = down[i][l];
			int p = l - 1;
			for (int r = l + 1; r <= W; ++r) {
				d[0][i][l][r] = A[i][r] != A[i][l] ? 0 : min(d[0][i][l][r - 1], down[i][r]);
				while (p + 1 < r && d[0][i][l][p + 1] > d[0][i][p + 2][r])
					++p;
				pos[i][l][r] = p;
			}
		}
	if (d[0][1][1][W] == H) return puts("0"), 0;
	for (int k = 1;; ++k) {
		memset(d[k & 1], 0, sizeof d[k & 1]);
		for (int i = 1; i <= H; ++i)
			for (int l = W; l; --l)
				for (int r = l, p = l - 1; r <= W; ++r) {
					d[k & 1][i][l][r] = max({
						d[k - 1 & 1][i][l][r],
						d[k - 1 & 1][d[k - 1 & 1][i][l][r] + 1][l][r],
						pos[i][l][r] >= l && pos[i][l][r] < r ? d[k - 1 & 1][i][pos[i][l][r] + 1][r] : (uint8_t)0,
						pos[i][l][r] + 1 >= l && pos[i][l][r] + 1 < r ? d[k - 1 & 1][i][l][pos[i][l][r] + 1] : (uint8_t)0});
					while (p + 1 < r && d[k & 1][i][l][p + 1] > d[k & 1][i][p + 2][r])
						++p;
					pos[i][l][r] = p;
				}
		if (d[k & 1][1][1][W] == H) return printf("%d\n", k), 0;
	}
}


Measured memory_bytes: 20352
import sys
n, y = map(int, input().split())
m = y//1000 # すべて1000円の時

r = m-n
# r = c_9*9 + c_4*4 で表せるとき、可能
# 枚数(c_10k, c_5k, c_1k) 
#   -> (c_10k+1, c_5k, c_1k-10)  sum: -9
#   -> (c_10k, c_5k+1, c_1k-5)   sum: -4
for c_9 in range(r//9 +1):
    for c_4 in range(r//4 +1):
        if c_9*9 + c_4*4 == r:
            if m-c_9*10-c_4*5>=0:
                print('{} {} {}'.format(c_9, c_4, m-c_9*10-c_4*5))
                sys.exit()
            
print('{0} {0} {0}'.format(-1))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	string ss[] = {"Sunny", "Cloudy", "Rainy"};
	string s; cin >> s;
	rep(i,3) {
		if(s == ss[i]) {
			cout << ss[(i + 1) % 3] << endl;
		}
	}
	return 0;
}

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

int dp[N];

int main(){
  int n,a,b,c;
  int d[100];
  int ans = 0;

  cin >> n >> a >> b >>c;
  for(int i=0;i<n;i++)cin >> d[i];
  for(int j=0;j<N;j++)dp[j] = 0;
  dp[a] = c;

  for(int i=0;i<n;i++){
    for(int j=N-1;j>=a;j--){
      if(dp[j] && j+b<=N){
	dp[j+b] = max(dp[j+b],dp[j] + d[i]);
      }
    }
  }
  for(int j=a;j<N;j++)ans = max(ans,dp[j]/j);
    
  cout << ans << endl;
}

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

typedef long long LL;
const int M = 14, N = 1 << M | 5;
const int mod = 998244353;

int fac[N], ifac[N];

namespace Poly {
  int w[N], rev[N];
  inline LL Pow(LL x, LL exp = mod - 2) {
    LL res = 1;
    for (; exp; exp >>= 1, x = x * x % mod)
      if (exp & 1) res = res * x % mod;
    return res;
  }
  inline void Init() {
    fac[0] = w[0] = 1;
    LL per = Pow(3, (mod - 1) >> M);
    for (int i = 1; i < N; i ++) {
      if (i & 1) rev[i] = rev[i - 1] | (1 << (M - 1));
      else rev[i] = rev[i >> 1] >> 1;
      w[i] = w[i - 1] * per % mod;
      fac[i] = (LL) fac[i - 1] * i % mod;
    }
    ifac[N - 1] = Pow(fac[N - 1]);
    for (int i = N - 1; i; i --)
      ifac[i - 1] = (LL) ifac[i] * i % mod;
  }
  inline void Dft(int *a) {
    int E = 1 << M;
    for (int i = 1; i < E; i ++)
      if (rev[i] < i) swap(a[rev[i]], a[i]);
    register int y;
    static int swp[N];
    for (int i = 1, d = 1; i <= M; i ++, d <<= 1) {
      for (int j = 0, k = 0; k < d; j += (E >> i), k ++) swp[k] = w[j];
      for (int j = 0; j < E; j += d + d)
        for (int k = j; k < j + d; k ++) {
          y = (LL) a[k + d] * swp[k - j] % mod;
          a[k + d] = a[k] - y;
          if (a[k + d] < 0) a[k + d] += mod;
          a[k] += y;
          if (a[k] >= mod) a[k] -= mod;
        }
    }
  }
  inline void IDft(int *a) {
    int E = 1 << M;
    reverse(a + 1, a + E); Dft(a);
    LL inv = Pow(E);
    for (int i = 0; i < E; i ++) a[i] = a[i] * inv % mod;
  }
}
using Poly :: Dft;
using Poly :: IDft;

int a[N], b[N], s[N], r[N];
int n, m;

inline LL C(int x, int y) {
  return (LL) fac[x] * ifac[y] % mod * ifac[x - y] % mod;
}

int main() {
  Poly :: Init();
  scanf("%d%d", &n, &m);
  int *x = a, *y = b;
  for (int i = 0; i <= n; i ++) r[i] = ifac[i + 2];
  Dft(r);
  x[0] = 1;
  for (int t = 1; t <= m; t ++) {
    memset(y, 0, sizeof a);
    for (int i = 1; i <= n; i ++) {
      y[i] = (mod - x[i] * C(i + 2, 2) % mod
              + x[i] * ( C(i + 1, 2) + 1 ) ) % mod;
      x[i] = (LL) x[i] * ifac[i] % mod;
    }
    Dft(x);
    for (int i = 0; i < N; i ++)
      x[i] = (LL) x[i] * r[i] % mod;
    IDft(x);
    y[0] = 1;
    for (int i = 1; i <= n; i ++)
      y[i] = ( y[i] + (LL) x[i] * fac[i + 2] ) % mod;
    swap(x, y);
  }
  LL ans = 0;
  for (int i = 0; i <= n; i ++) ans += C(n, i) * x[i] % mod;
  printf("%lld\n", (ans % mod + mod) % mod);
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const char *nl = "\n";

int k;
string s;

int main() {
    cin >> k >> s;
    if (s.size() <= k) {
        cout << s << nl;
    } else {
        cout << s.substr(0, k) << "..." << nl;
    }
    return 0;
}



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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define out(n) cout << n << '\n'
#define rep(i, n) for (ll i = 0; i < (n); i++)
const int inf = 1000000000;
const ll linf = (ll)inf * (ll)inf;
void solve()
{
    int n;
    in(n);
    int a[n];
    int b = 0;
    rep(i, n)
    {
        in(a[i]);
        b ^= a[i];
    }
    rep(i, n)
    {
        int c = a[i] ^ b;
        if (i != 0)
        {
            cout << " ";
        }
        cout << c;
    }
    cout << endl;
}

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

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

typedef pair<ll, int> P;
ll a[300010];
int removed[300010];

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

	int N;
	cin >> N;

	priority_queue<P, vector<P>, greater<P>> q1, q3;// 小さいもの優先
	priority_queue<P> q2;// 大きいもの優先
	ll sum1 = 0, sum2 = 0;
	for(int i = 0; i < 3 * N; i++){
		cin >> a[i];
		if(i < N){
			q1.push({ a[i], i });
			sum1 += a[i];
		}
		else{
			q2.push({ a[i], i });
			sum2 += a[i];
		}
	}

	// 大きいものN個
	for(int i = 0; i < N; i++){
		ll val = q2.top().first;
		int id = q2.top().second;
		q3.push(q2.top());
		q2.pop();
		sum2 -= val;
		removed[id] = 1;
	}

	ll ans = sum1 - sum2;
	for(int i = 0; i < N; i++){
		// i + Nを右から左へ
		q1.push({ a[i + N], i + N });
		sum1 += a[i + N];
		// 左からremove数を増やす
		sum1 -= q1.top().first;
		q1.pop();
		// 右からremove数を減らす
		if(!removed[i + N]){
			sum2 -= a[i + N];
			while(q3.top().second < i + N) q3.pop();
			sum2 += q3.top().first;
			removed[q3.top().second] = 0;
			q3.pop();
		}
		ans = max(ans, sum1 - sum2);
	}
	cout << ans << endl;
}


Measured memory_bytes: 12396
W,C;R(char*i){*i>45?*i=0,C++,R(i-1),R(i+1),R(i-W),R(i+W):0;}main(d,m){for(;scanf("%d%*d",&W)*W;C=!printf("%d\n",C))memset(m,W++,484),scanf("%[^0-9]",m+W),R(strchr(m,64));}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <list>
#include <set>
using namespace  std;

#define int long long int

constexpr int INF = std::numeric_limits<int>::max();
constexpr int MAGIC = 753;

int nprime = 25;
int prime[25] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
int cnt[25];

    int u74;
    int u24;
    int u14;
    int u4;
    int u2;


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

    int N;
    cin >> N;
    for (int i = 2; i <= N; i++) {
        for (int p = 0; p < nprime; p++) {
            int n = i;
            while (n % prime[p] == 0) {
                cnt[p]++;
                n = n / prime[p];
            }
        }
    }
    // for (int i = 0; i < nprime; i++) {
    //     cout << cnt[i] << " ";
    // }
    // cout << endl;

    for (int i = 0; i < nprime; i++) {
        u2  += (cnt[i] >= 2) ? 1 : 0;
        u4  += (cnt[i] >= 4) ? 1 : 0;
        u14 += (cnt[i] >= 14) ? 1 : 0;
        u24 += (cnt[i] >= 24) ? 1 : 0;
        u74 += (cnt[i] >= 74) ? 1 : 0;
    }

    // cout << "u74: " << u74 << endl;
    // cout << "u24: " << u24 << endl;
    // cout << "u14: " << u14 << endl;
    // cout << "u4: " << u4 << endl;
    // cout << "u2: " << u2 << endl;

    int p75 = u74;
    int p25x3 = u24 * (u2 - 1);
    int p15x5 = u14 * (u4 - 1);
    int p5x5x3 = (u4 * (u4 - 1) / 2) *  (u2 - 2);

    int ans = p75 + p25x3 + p15x5 + p5x5x3;
    cout << ans << endl;
}

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

int main()
{
  int H, W;
  cin >> H >> W;

  vector<vector<char>> a(H, vector<char>(W));
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin >> a.at(i).at(j);
    }
  }

  for (int i = 0; i < W + 2; i++)
  {
    cout << "#";
  }
  cout << endl;
  for (vector<char> i : a)
  {
    cout << "#";
    for (char j : i)
    {
      cout << j;
    }
    cout << "#" << endl;
  }
  for (int i = 0; i < W + 2; i++)
  {
    cout << "#";
  }
  cout << endl;
}


Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    d = {}
    for _ in range(M):
        s, c = map(int, input().split())
        if s == 1 and c==0 and N > 1:
            print('-1')
            return
        if s in d and d[s] != c:
            print('-1')
            return
        if s > N:
            print('-1')
            return
        d[s] = c

    s = ''
    if N == 1:
        if 1 in d:
            s += str(d[1])
        else:
            s += '0'
    else:
        for n in range(1, N+1):
            if n in d:
                s += str(d[n])
            else:
                if n==1:
                    s += '1'
                else:
                    s += '0'
    print(s) 

main()

Measured memory_bytes: 3064
import sys

input = sys.stdin.readline

H, W = map(int, input().split())

if H == 1 or W == 1:
    print(1)
    exit()
if (H * W) % 2 == 0:
    print((H*W) // 2)
else:
    print((H*W) // 2 + 1)
 


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int dp[2][20002000];

int main() {

    string s;
    cin >> s;
    
    reverse(ALL(s));
    s += string(1000005, '0');

    dp[0][0] = 0;
    dp[1][0] = 1<<30;

    for(int i = 0; i < 1000005; i++) {
        dp[0][i+1] = min(dp[0][i]+(s[i]-'0'), dp[1][i]+(s[i]-'0'+1));
        dp[1][i+1] = min(dp[0][i]+10-(s[i]-'0'), dp[1][i]+10-(s[i]-'0'+1));
    }

    // ll sum = 0;
    // for(ll i = 0; i < n.size(); i++) {        
    //     if (n[i] - '0' >= 6) {
    //         sum += 10 - (n[i] - '0') + 1;
    //         cout << 10 - (n[i] - '0') + 1 << endl;
            
    //     } else {
    //         cout << n[i]-'0' << endl;
            
    //         sum += n[i]-'0';
    //     }
    // }

    // cout << sum << endl;

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

Measured memory_bytes: 12508
#include<stdio.h>
#include<string.h>
int main()
{
int n=0,i,N;
char a[200000];
scanf("%s",&a);
N=strlen(a);

for(i=0;i<N-1;i++)
{
if(a[i]!=a[i+1])          //不同，就需要反转一次
n++;
}

printf("%d",n);


return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		StringBuffer sb = new StringBuffer();
		for (int i=0; i<s.length; i++) {
			if (s[i] == '0') sb.append("0");
			else if (s[i] == '1') sb.append("1");
			else if (s[i] == 'B') {
				if (sb.length() > 0)
					sb.delete(sb.length()-1, sb.length());
			}
		}
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;
int main(){
int i,n,x,y,c,d;
x = -100010;
y = 100010;
cin >> n;
int a[n];
for(i=0;i<n;i++){
	cin >> a[i];
	if(x<a[i]){
		c = i+1;
	}
	x = max(x,a[i]);
	if(y>a[i]){
		d = i+1;
	}
	y = min(y,a[i]);
	}
cout << 2*n-1 << endl;
	if(x>-y){
		for(i=1;i<=n;i++){
			cout << c <<" "<< i << endl;
		}
		for(i=1;i<n;i++){
			cout << i <<" "<< i+1 << endl;
		}
	}else{
		for(i=1;i<=n;i++){
			cout << d <<" "<< i << endl;
		}
		for(i=n;i>1;i--){
			cout << i <<" "<< i-1 << endl;
		}
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
inline void Rd(int &res){
	char c;res=0;
	while(c=getchar(),c<'0');
	do{
		res=(res<<1)+(res<<3)+(c^48);
	}while(c=getchar(),c>='0');
}
const int M=(int)1e5+5;
const int P=(int)1e9+7;
int n,fact[M];
int A[M],cnt[M],x;
int Pow(int x,int k){
	int rs=1;
	while(k){
		if(k&1)rs=(ll)rs*x%P;
		x=(ll)x*x%P;
		k>>=1;
	}
	return rs;
}
int C(int m,int n){
	return (ll)fact[n]*Pow(fact[m],P-2)%P*Pow(fact[n-m],P-2)%P;
}
int main(){
	Rd(n);
	for(int i=1;i<=n+1;i++){
		Rd(A[i]),cnt[A[i]]++;
		if(cnt[A[i]]>1)x=i;
	}
	int fi;
	for(int i=1;i<=n+1;i++)
		if(A[i]==A[x]){fi=i;break;}
	fact[0]=1;
	for(int i=1;i<=n+1;i++)
		fact[i]=(ll)fact[i-1]*i%P;
	for(int k=1;k<=n+1;k++){
		int ans=C(k,n+1);
		if(n-x+fi>=k-1)ans-=C(k-1,n-x+fi);
		if(ans<0)ans+=P;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2432
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   

int main(){
    std::ios::sync_with_stdio(false);
    int r;
    cin>>r;
    if(r<1200){
    	cout<<"ABC"<<endl;
    }
    else if(r<2800){
    	cout<<"ARC"<<endl;
    }
    else{
    	cout<<"AGC"<<endl;
    }
    return 0;     
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MAX_N = 1<<24;
bool Hash[MAX_N];
int getHash(string s)
{
    int res = 1, x = 1;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'A') res += x * 1;
        if(s[i] == 'C') res += x * 2;
        if(s[i] == 'G') res += x * 3;
        if(s[i] == 'T') res += x * 4;
        x *= 5;
    }
    return res;
}
void insert(string s)
{
    int num = getHash(s);
    Hash[num] = true;
}
bool find(string s)
{
    int num = getHash(s);
    return (Hash[num] ? true : false);
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    for(int i = 0; i < MAX_N; i++) Hash[i] = false;
    int n; cin >> n;
    for(int i = 0; i < n; i++)
    {
        string s, t; cin >> s >> t;
        if(s == "insert") insert(t);
        else cout << (find(t) ? "yes" : "no") << endl;
    }
    return 0;
}




Measured memory_bytes: 19580
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		while(input.hasNext()){
			String st = input.nextLine();
			boolean[] mati = new boolean[9];
			for(int j = 1 ; j <= 9 ; j++){
				int[] num = new int[14];
				num[0] = j;
				for(int i = 0 ; i < st.length() ; i++){
					num[i+1] = Character.digit(st.charAt(i),10);
				}
				Arrays.sort(num);
				
				String newst = "";
				int count = 0;
				for(int i = 0 ; i < num.length ; i++){
					newst += num[i];
					if(num[i] == j)count++;
				}
				if(count > 4){
					mati[j-1] = false;
				}else{
					mati[j-1] = majhong(newst);
				}
				//System.out.println(mati[j-1]);
			}
			StringBuilder agari = new StringBuilder();
			for(int i = 0 ; i < mati.length ; i++){
				if(mati[i])agari.append((i+1)+" ");
			}
			if(agari.length() != 0){
				System.out.println(agari.substring(0,agari.length()-1));
			}else{
				System.out.println(0);
			}
		}
		input.close();
	}
	
	public static boolean majhong(String st){
		Queue<String> q = new LinkedList<String>();
		q.add(st+","+0);
		while(!q.isEmpty()){
			String[] str = q.poll().split(",");
			String nst = str[0];
			//System.out.println(nst+","+str[1]);
			String makest = "";
			int atama = Integer.parseInt(str[1]);
			int[] nums = new int[nst.length()];
			
			for(int i = 0 ; i < nst.length() ; i++){
				nums[i] = Character.digit(nst.charAt(i),10);
			}
			
			//System.out.println(nst);
			
			//atama
			if(nums.length >= 2){
			
				if(atama != 1 && nums[0] == nums[1]){
					
					for(int i = 2 ; i < nst.length() ; i++){
						makest += nums[i]+"";
					}
					//System.out.println(makest+"aaa");
					if(makest.length() == 0)return true;
					q.add(makest.substring(0,makest.length())+","+1);
				}
				makest = "";
				
				if(nums.length >= 3){
					//anko
					if(nums[0] == nums[1] && nums[1] == nums[2]){
						
						for(int i = 3 ; i < nst.length() ; i++){
							makest += nums[i]+"";
						}
						//System.out.println(makest+"anko");
						if(makest.length() == 0)return true;
						q.add(makest.substring(0,makest.length())+","+atama);
					}
					
					
					//syuntu
					makest = "";
					int nm = nums[0];
					int nmplus_i = -1;
					int nmplustwo_i = -1;
					for(int i = 1 ; i < nst.length(); i++){
						if(nmplus_i == -1 && nums[i] == nm+1){
							nmplus_i = i;
						}
						
						if(nmplustwo_i == -1 && nums[i] == nm+2){
							nmplustwo_i = i;
						}
					}
					
					for(int i = 0 ; i < nst.length() ; i++){
						if(i != 0 && i != nmplus_i && i != nmplustwo_i){
							makest += nums[i]+"";
						}
					}
					if(nmplus_i != -1 && nmplustwo_i != -1){
						//System.out.println("syuntu"+makest+","+nmplus_i+","+nmplustwo_i);
						q.add(makest.substring(0,makest.length())+","+atama);
					}
					if(makest.length() == 0)return true;
				}
			}
		}
		return false;
	}
}

Measured memory_bytes: 31040
#include<bits/stdc++.h>
#define ft(i,l,r) for(register int i=l;i<=r;i++)
#define fd(i,r,l) for(register int i=r;i>=l;i--)
using namespace std;
int n,x,mx,bo;
int main()
{
	cin>>n;
	ft(i,1,n)
	{
		scanf("%d",&x);
		mx=max(mx,x);
		if(mx-x>=2) bo=1;
	}
	if(bo==1) cout<<"No";
	else cout<<"Yes";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3760
import math
n, d = [int(s) for s in input().split(" ")]
pts = []
for _ in range(n):
  pts.append([int(s) for s in input().split(" ")])

def dist(x, y):
  sum = 0
  for xx, yy in zip(x, y):
    sum += (xx - yy)**2
  return math.sqrt(sum)

cnt = 0
for i in range(n):
  for j in range(i + 1, n):
    d = dist(pts[i], pts[j])
    if int(d) == d:
      cnt += 1

print("%d" % cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int INF = 0x3f3f3f3f;
int mod = 1e9+7;
int MAXN = 12345;
double eps = 1e-7;

int dcmp(double a, double b) 
{
    return (a - b < eps)? -1: (a - b >= eps);
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    int n, m;

    scanf("%d", &n);

    int pre = 112345, x;
    int ans = 0;
    for (int i = 0; i < n-1; ++i)
    {
        scanf("%d", &x);
        ans += min(pre, x);
        pre = x;
    }

    ans += x;

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

    return 0;
}


Measured memory_bytes: 256
"use strict";

const main = arg => {
    const x = arg.split("\n")[0].split(" ")[0];
    const a = arg.split("\n")[0].split(" ")[1];
    const b = arg.split("\n")[0].split(" ")[2];
    console.log(Math.abs(x-a) < Math.abs(x-b) ? "A" : "B");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var n = long.Parse(Console.ReadLine());
        if (n == 2)
        {
            Console.WriteLine(1);
            return;
        }
        HashSet<long> res = new HashSet<long>();
        {
            res.Add(n - 1);
            long i;
            for (i = 2; i * i < n - 1; i++)
            {
                if ((n - 1) % i != 0) continue;
                res.Add(i);
                res.Add((n - 1) / i);
            }
            if (i * i == n - 1) res.Add(i);
        }
        {
            res.Add(n);

            long i;
            for (i = 2; i * i < n; i++)
            {
                if (n % i != 0) continue;
                if (isValid(i, n)) res.Add(i);
                if (isValid(n / i, n)) res.Add(n / i);
            }
            if (i * i == n)
                if (isValid(i, n)) res.Add(i);
        }
        Console.WriteLine(res.Count);
    }
    static bool isValid(long i, long n)
    {
        var tmp = n;
        while (tmp % i == 0) tmp /= i;
        return (tmp - 1) % i == 0;
    }
}


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

#define int long long

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

  int H, W;
  cin >> H >> W;

  vector<int> A(H);
  for ( int i = 0; i < H; i++ ) {
    cin >> A[i];    
  }

  sort(A.begin(), A.end());
  vector<int> cum(H, 0);  
  cum[0] = A[0];
  for ( int i = 1; i < H; i++ ) {
    cum[i] += cum[i-1]+A[i];    
  }

  int ans = 0;
  for ( int i = 0; i < W; i++ ) {
    int b;
    cin >> b;
    int p = upper_bound(A.begin(), A.end(), b) - A.begin();
    p--;
    if ( p >= 0 ) ans += cum[p];
    if ( H-p-1 >= 0 ) ans += b*(H-p-1);    
  }

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



Measured memory_bytes: 4488
main = do
  [_,x] <- map read . words <$> getLine :: IO [Int]
  ns <- map read . words <$> getLine :: IO [Int]
  print $ solve x ns

solve :: Int -> [Int] -> Int
solve _ [_] = 0
solve x (a:b:as) 
  | a+b <= x = 0 + solve x (b:as)
  | otherwise =
      let 
         d = a+b-x
         d' = d-b
       in if d' <= 0
             then d + solve x ((b-d):as)
             else b + d' + solve x (0:as)

Measured memory_bytes: 36220
import java.util.*;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		for (int i = 0 ; i < n ; i++) {
			int a = sc.nextInt();
			x = x + (d+a-1) / a;
		}
		System.out.println(x);
	}
}


Measured memory_bytes: 21844
#include <stdio.h>

int main(void)
{
    char n[4];
    scanf("%s",&n);

    if(n[0]=='7'){
        printf("Yes");
    }else if(n[1]=='7'){
        printf("Yes");
    }else if(n[2]=='7'){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

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

int main() {
    int L, R;

    cin >> L >> R;

    int minv = 2019;
    R = min(R, L + 2019 * 2);
    for (int i = L; i < R; i++) {
        for (int j = i + 1; j <= R; j++) {
            minv = min(minv, ((i % 2019) * (j % 2019)) % 2019);
        }
    }
    cout << minv << endl;

    return 0;
}

Measured memory_bytes: 384
const main = stdin => {
  const S = stdin.trim()
  if (S[2] === S[3] && S[4] === S[5]) {
    console.log('Yes')
  } else {
    console.log('No')
  }
}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29512
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/abc171/tasks/abc171_f

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

//https://github.com/atcoder-live/library/blob/master/mint.cpp
struct mint {
  LL x; 
  mint(LL x=0):x((x%mod+mod)%mod){}
  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 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;
  }
};
 
struct combination {
  vector<mint> fact, ifact;//factに階乗を計算、ifactはその各々に対する逆元
  combination(LL n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (LL i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (LL i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(LL n,LL k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

LL K;
string S;

mint ans = 0;

void solve(){
	combination c(2000001);
	//25のi乗をpow25[i]とする
	vector<mint> pow25(2000001,1);
	for(int i=1;i<=2000000;i++) pow25[i] = pow25[i-1]*25;
	//26のi乗をpow26[i]とする
	vector<mint> pow26(2000001,1);
	for(int i=1;i<=2000000;i++) pow26[i] = pow26[i-1]*26;

	LL N = S.size();
	//文字列Sを部分文字列に含む、
	//長さK+Nの文字列の総数が答えとなる

	for(LL i=N;i<=K+N;i++){
		ans += pow25[i-N]*c(i-1,N-1)*pow26[K+N-i];
	}
}

int main(){
    cin >> K >> S;

    solve();

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

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

// @author: pashka

int temp = 100000;
int cnt = 0;

void mless(int x, int y, int z) {
    cout << "< " << x << " " << y << " " << z << "\n";
    cnt++;
}
void mplus(int x, int y, int z) {
    cout << "+ " << x << " " << y << " " << z << "\n";
    cnt++;
}

void mand(int x, int y, int z) {
    mless(x, y, temp);
    mless(y, x, temp + 1);
    mplus(x, y, temp + 2);
    mplus(temp, temp + 1, temp + 3);
    mless(temp + 3, temp + 2, z);
}

int one = 3;
int k = 4;

int MAX = 30;

void mbin(int x) {
    mplus(2, 2, temp);
    mplus(2, one, temp + 1);
    for (int i = 1; i < MAX - 1; i++) {
        mplus(temp + i, temp + i, temp + i + 1);
        mplus(temp + i + 1, one, temp + i + 1);
    }
    for (int i = MAX - 1; i >= 0; i--) {
        mless(temp + i, x, k + i);
        mplus(2, k + i, temp + MAX);
        for (int j = 0; j < i; j++) {
            mplus(temp + MAX, temp + MAX, temp + MAX);
        }
        for (int j = 0; j < i; j++) {
            mplus(temp + MAX, temp + j, temp + j);
        }
    }
    k += MAX;
}

int main() {
    ios::sync_with_stdio(false);
    cout << "33481\n";
    mand(0, 1, one);
    int ap = k;
    mbin(0);
    int bp = k;
    mbin(1);
    for (int i = 0; i < MAX; i++) {
        for (int j = 0; j < MAX; j++) {
            mand(ap + i, bp + j, k);
            for (int t = 0; t < i + j; t++) {
                mplus(k, k, k);
            }
            mplus(2, k, 2);
        }
    }
    cerr << cnt << "\n";
    return 0;
}

Measured memory_bytes: 3544
#include <iostream>
using namespace std;
const int inf = 1e9;
int main(){
    string s;
    cin >> s;
    int c=inf, f=-inf;
    for(int i=0; i<(int)s.length(); i++){
        if(s[i]=='C'){
            c=i;
            break;
        }
    }
    for(int i=s.length()-1; i>=0; i--){
        if(s[i]=='F'){
            f=i;
            break;
        }
    }
    if(c<f){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <limits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
const int inf = 1000000000; //10^9

ll N,M,X;
vector<ll>C;
vector<vector<ll>>A;
int ans=inf;

void search(int x,int cost,vector<int>level){
    if (x==N)
    {
        bool ok = true;
        for (int i = 0; i < M; i++)
        {
            if (level[i]<X)
            {
                ok = false;
            }
        }
        if (ok) //boolだからtかfしかない
        {
            ans = min(ans,cost);
        }
        return; 
    }
    search(x+1,cost,level);
    for (int i = 0; i < M; i++)
    {
        level[i]+=A[x][i];
    }
    search(x+1,cost+C[x],level);

}



int main(){
    cin >> N >> M >> X;
    C.resize(N);
    A.resize(N,vector<ll>(M));
    for (ll i = 0; i < N; i++)
    {
        cin >> C[i];
        for (ll j = 0; j < M; j++)
        {
            cin >> A[i][j];
        }  
    }
    vector<int>level(M,0);
    search(0,0,level);

    if (ans == inf)
    {
        cout << -1 << endl;
        return 0;
    }

    cout << ans << endl;
    
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int N;
    cin>>N;
    rep2(i,1,10){
        rep2(j,1,10){
            if(i*j==N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main(void){
	int x,y;
	cin>>x>>y;
	cout<<x+y/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
 
int main(){
    ll N,D;
    ll d;
    int count=0;
    cin>>N>>D;
    vector<pair<ll,ll>>p(N);
    for(int i=0;i<N;i++){
        cin>>p.at(i).first>>p.at(i).second;
    }
    rep(i,N){
        d=p.at(i).first*p.at(i).first+p.at(i).second*p.at(i).second;
        if(d<=D*D){
            count++;
        }
    }
    cout<<count<<endl;



}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    while(K>0){
        if(A>=B){
            B*=2;
        }else{
            C*=2;
        }
        K--;
    }
    if(A<B && B<C){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


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

const long long P=1e9+7;

long long n,m,ans=1;

int main()
{
	cin>>n>>m;
	if(m-n>1||n-m>1)
	{
		cout<<0;
		return 0;
	}
	for(long long i=1;i<=n;i++)
		ans=(i*ans)%P;
	for(long long i=1;i<=m;i++)
		ans=(i*ans)%P;
	if(m-n==0)
	cout<<ans*2ll%P;
	else
	cout<<ans;
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF INT_MAX/2

typedef vector<int> vi;

enum dir
{
	LEFTWARD = 0,
	DOWNWARD,
	RIGHTWARD,
	UPWARD
};

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

int main()
{
	while (1)
	{
		int N; cin >> N;
		if (N == 0) return 0;

		vi n(N), d(N);
		rep(i, 1, N) cin >> n[i] >> d[i];

		vi x(N), y(N);
		x[0] = y[0] = 0;
		rep(i, 1, N)
		{
			x[i] = x[n[i]] + dx[d[i]];
			y[i] = y[n[i]] + dy[d[i]];
		}

		int x_max = -1, x_min = INF;
		int y_max = -1, y_min = INF;
		rep(i, 0, N)
		{
			x_max = max(x_max, x[i]);
			x_min = min(x_min, x[i]);
			y_max = max(y_max, y[i]);
			y_min = min(y_min, y[i]);
		}

		cout << (x_max - x_min + 1) << " " << (y_max - y_min + 1) << endl;
	}
}

Measured memory_bytes: 3020
#include <bits/stdc++.h>
using namespace std;
 typedef long long ll;
 
int main() {
map <int, int> m;
int n;
cin>>n;
for(int i=0;i<n;i++){
int l;
cin>>l;
m[l]++;
}
int ans=0;
for(auto x : m){
if(x.first != x.second){
    if(x.first < x.second)ans+=x.second-x.first;
    else ans+=x.second;
}

}
cout<<ans<<endl;


}


Measured memory_bytes: 4736
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int main() {
  string s;
  int k;
  cin >> s >> k;
  vector<string> res;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 1; j <= k; j++) res.emplace_back(s.substr(i, j));
  }
  sort(res.begin(), res.end());
  res.erase(unique(res.begin(), res.end()), res.end());
  cout << res[k - 1] << endl;

    return 0;
}



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

int main()
{
	const long long int INF = 1LL << 60;

	int N, K;
	cin >> N >> K;
	vector<long long int> H(N+K+1, INF);
	for(int i = 0; i < N; i++) cin >> H[i];

	vector<long long int> dp(N+K+1, INF);
	dp[0] = 0;

	for(int i = 0; i < N; i++)
	{
		for(int j = 1; j <= K; j++)
		{
			dp[i+j] = min(dp[i+j], dp[i] + abs(H[i] - H[i+j]));
		}
	}

	cout << dp[N-1] << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int solve(int n,int r){
    vector<int> m;
    for(int i=0;i<n;i++){
        m.push_back(i);
    }
    for(int i=0;i<r;i++){
        int p,c;
        scanf("%d %d",&p,&c);
        rotate(m.begin(),m.begin()+p-1,m.begin()+p+c-1);
    }
    return n-m[0];
}

int main(){
    while(1){
        int n,r;
        scanf("%d %d",&n,&r);
        if(n==0&&r==0) return 0;
        printf("%d\n",solve(n,r));
    }
}

Measured memory_bytes: 1056
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    if(S=="RRR") cout<<"3"<<endl;
    if(S=="RRS"||S=="SRR") cout<<"2"<<endl;
    if(S=="RSS"||S=="SRS"||S=="SSR"||S=="RSR") cout<<"1"<<endl;
    if(S=="SSS") cout<<"0"<<endl;
    
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define SI size()
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PF push_front
#define PB push_back
#define VE vector<int>
#define VP vector<PA>
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
//
int main(){
  int N;
  int A[100];
  cin>>N;
  FOR(i,0,N){
    cin>>A[i];
  }
  sort(A,A+N,greater<int>());
  int a=0,b=0;
  FOR(i,0,N){
    if(i%2==0){
      a+=A[i];
    }else{
      b+=A[i];
    }
  }
  cout<<a-b<<endl;
  return 0;
}


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

void A()
{
  // 入力
  string S, T;
  cin >> S >> T;
  
  // 出力
  // Tの先頭からSの長さの部分文字列がSと一致すればOK
  if( S == T.substr(0, (int)S.length()) )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

void B()
{
  // 入力
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  // 出力
  // できるだけ1のカードを取る
  // 1のカードだけでたりる
  if( K <= A )
    cout << K << endl;
  // 1と0のカード
  else if( K <= A + B )
    cout << A << endl;
  // 全部のカード
  else
    cout << A - (K - A - B) << endl;
}

int main()
{
  //A();
  B();
  
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() { 
  int a,b,c,d,e ;
  cin>> a>>b>>c>>d>>e;
  if(a==0){
     cout<< 1<<endl;
  }
  if(b==0){
     cout<<2 <<endl;
  }
  if(c==0){
     cout<< 3<<endl;
  }
  if(d==0){
     cout<< 4<<endl;
  }
  if(e==0){
     cout<<5 <<endl;
  }
  
  return 0;
}


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

typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;

int add(int a, int b){
    return (a+b)%MOD;
}

int mul(int a, int b){
    return((ll)a*b)%MOD;
}

vector <int> graf[100005];
int dp[100005][2];

void dfs(int v, int parent){
    dp[v][0] = dp[v][1] = 1;
    for(auto c : graf[v]){
        if(c == parent) continue;
        dfs(c, v);
        dp[v][0] = mul(dp[v][0], add(dp[c][1], dp[c][0]));
        dp[v][1] = mul(dp[v][1], dp[c][0]);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n;
    cin >> n;
    for(int i=1; i<n; i++){
        int a, b;
        cin >> a >> b;
        graf[a].push_back(b);
        graf[b].push_back(a);
    }
    dfs(1, 0);
    cout << add(dp[1][1], dp[1][0]) << "\n";
    return 0;
}


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

int main(){
	for(int D=0; D<100; D++){
		int t, n, h = 0;
		cin >> t;
		if(t == 0)break;

		else{

			cin >> n;

			for(int i =0; i<n; i++){
				int s, f;
				cin >> s >> f;
				h += (f-s);
			}
			
			if(h >= t){
				cout << "OK" << endl;
			}
			else{
				cout << t-h << endl;
			}

		}
		
	}
	return 0;

}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
////////////////////////////////////////////////////////////
#define all(x) (x).begin(), (x).end() 
const int inf = 1e9;
const long long INF=1e15;
#define endl '\n'
#define rep(i, n) for(int i=0;i<(n);++i)
#define repp(i, a, b) for(int i=(a);i<=(b);++i)
#define pb push_back
#define eb emplace_back
#define fastio ios::sync_with_stdio(false);cin.tie(0); //cout.tie(0);

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

void vplus(vi& a, vi& b) {
	int n = a.size();
	rep(i, n) a[i] += b[i];
}
int main() {
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	vector<vi> c(h, vi(w));
	rep(i, h) cin >> s[i];
	rep(i, h) rep(j, w) c[i][j] = s[i][j] - '0';
	int mini = 1e9;
	for(int bit=0;bit<(1<<h-1);bit++) {
		vector<vi> cw;
		vi t(w, 0);
		for(int i=0;i<h;i++) {
			vplus(t, c[i]);
			// ith bit 1 : i ~ i+1 cut
			if(bit & (1<<i)) {
				cw.push_back(t);
				t = vi(w, 0);
			}
		}
		cw.push_back(t);
		
		int cut = __builtin_popcount(bit);
		int hs = cw.size();
		vi sum(hs, 0);
		bool fail = false;
		for(int i=0;i<hs;i++) {
			sum[i] = cw[i][0];
			if(sum[i] > k) fail = true;
		}
		for(int i=1;i<w;i++) {
			bool needcut = false;
			for(int j=0;j<hs;j++) if(sum[j] + cw[j][i] > k) needcut = true;
			if(needcut) {
				cut++;
				for(int j=0;j<hs;j++) {
					sum[j] = cw[j][i];
					if(sum[j] > k) fail = true;
				}
			} else {
				for(int j=0;j<hs;j++) sum[j] += cw[j][i];
			}
			if(fail) break;
		}
		if(fail) continue;
		mini = min(mini, cut);
	}
	cout << mini;
}

Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
using namespace std;

struct Node {
public:
    vector<int> to_child; // first = node_Number, second = cost;
};

vi BFS(vector<Node> nodes,int start = 0) { // {(distance from Start, x-coordinate of max_dist,y-coordinate of max_dist}
    queue<int> q;
    vi dp(nodes.size(), pint_INF);
    vi parents(nodes.size());
    parents[start] = start;
    dp[start] = 0;
    q.push(start);

    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (int i = 0; i < nodes[u].to_child.size(); i++) {
            if (dp[u] + 1 < dp[nodes[u].to_child[i]]) {
                dp[nodes[u].to_child[i]] = dp[u] + 1;
                parents[nodes[u].to_child[i]] = u;
                q.push(nodes[u].to_child[i]);
            }
        }
    }

    return parents;
}

int main() {
    int N, M; cin >> N >> M;
    vector<Node> nodes(N);

    rep(i, M) {
        int a, b; cin >> a >> b;
        a--; b--;
        nodes[a].to_child.push_back(b);
        nodes[b].to_child.push_back(a);
    }
    vi ans = BFS(nodes, 0);

    cout << "Yes" << endl;
    for (int i = 1; i < ans.size(); i++) {
        cout << ans[i] + 1 << endl;
    }
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
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...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
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);
}

//main code

int main(int argc, char *argv[])
{
	LL n,z,w;
	cin >> n >> z >> w;
	VL a(n);
	cin >> a;
	if (n==1) {
		cout << abs(a[0] - w) << endl;
		return 0;
	}
	LL ans = max(abs(a[n-1] - w), abs(a[n-2] - a[n-1]));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
using namespace std;

int n,c;
vector<pair<int,int> > v[35];
int temp[200002];
int sum[200002];
int t[200002];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
   cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
 cin>>n>>c;
 for(int i=0;i<n;i++){//i<=x<i+1
  int a,b,u;
  cin>>a>>b>>u;
  v[u].push_back(make_pair(2*a-1,2*b));
 }
 for(int i=1;i<=30;i++){
  for(int j=0;j<200002;j++){
   t[j]=0;
  }
  for(int j=0;j<(int)v[i].size();j++){
   t[v[i][j].fi]++;
   t[v[i][j].se]--;
  }
  for(int j=1;j<200002;j++){
   t[j]=t[j-1]+t[j];
  }
  for(int j=0;j<200002;j++){
   if(t[j]>0){
    sum[j]++;
   }
  }
 }
 int ans=0;
 for(int i=0;i<200002;i++){
  ans=max(ans,sum[i]);
 }
 cout<<ans<<endl;
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 3072