akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const int N = 2e5 + 10;
typedef long long ll;
ll n, K, a[N], x[N], tx, y[N], ty;

bool chk(ll lim) {
    ll num = 0;
    if (lim < 0) {
        lim *= -1;
        num = tx * ty;
        rep(i, 1, tx)
            num -= (upper_bound(y + 1, y + ty + 1, lim / x[i]) - y - 1);
    } else if (!lim) {
        num = tx * ty;
    } else {
        num += tx * ty + (n - tx - ty) * (tx + ty) + (n - tx - ty) * (n - tx - ty - 1) / 2;
        rep(i, 1, tx) {
            int j = upper_bound(x + 1, x + i, lim / x[i]) - x - 1;
            if (x[i] * x[j] == lim) --j;
            num += j;
        }
        rep(i, 1, ty) {
            int j = upper_bound(y + 1, y + i, lim / y[i]) - y - 1;
            if (y[i] * y[j] == lim) --j;
            num += j;
        }
    }
    return num < K;
}

int main() {
    cin >> n >> K;
    rep(i, 1, n) scanf("%lld", &a[i]);

    sort(a + 1, a + n + 1);
    rep(i, 1, n) if (a[i] < 0) x[++tx] = -a[i];
    reverse(x + 1, x + tx + 1);
    rep(i, 1, n) if (a[i] > 0) y[++ty] = a[i];

    ll ans = 0, l = -1e18, r = 1e18;
    while (l <= r) {
        ll mid = (l + r) >> 1;
        if (chk(mid)) ans = mid, l = mid + 1;
        else r = mid - 1;
    }
    printf("%lld\n", ans);
    return 0;
}


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

namespace abc066a
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, s;

            string[] word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            int m = a;
            if (b > m) m = b;
            if (c > m) m = c;

            s = a + b + c - m;

            Console.Write(s);
            }
    }
}

Measured memory_bytes: 27500
#include <stdio.h>
#include <string.h>

const int MAX_N = 10005;
const int MAX_D = 105;
const int MOD = 1000000007;

int n,d,dp[MAX_N][MAX_D][2];
char s[MAX_N];

int f(int p, int r, int l)
{
	if (p==n)
		return r==0;
	if (dp[p][r][l]!=-1)
		return dp[p][r][l];
	int ans=0;
	for (int i=(l?9:s[p]-'0'); i>=0; i--)
		ans=(ans+f(p+1,(r+i)%d,l|(i<s[p]-'0')))%MOD;
	return dp[p][r][l]=ans;
}

int main()
{
	scanf("%s",s);
	n=strlen(s);
	scanf("%d",&d);
	for (int i=0; i<n; i++)
		for (int r=0; r<d; r++)
			dp[i][r][0]=dp[i][r][1]=-1;
	printf("%d\n",(f(0,0,0)-1+MOD)%MOD);
	return 0;
}


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

public class Main {


    public Main(FastScanner in, PrintWriter out) {
        int N = in.nextInt();
        int M = in.nextInt();
        if (N % 2 == 1) {
            for (int i = 1, j = N; i <= M; i++, j--) {
                out.printf("%d %d%n", i, j);
            }
        } else {
            boolean change = false;
            for (int i = 1, j = N; i <= M; i++, j--) {
                int cwDist = j - i, acwDist = N - cwDist;
                if (!change && cwDist <= acwDist) {
                    change = true;
                    j--;
                }
                out.printf("%d %d%n", i, j);
            }
        }
    }

    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        // Scanner in = new Scanner(
                // new BufferedReader(new InputStreamReader(System.in)));
        FastScanner in = new FastScanner(System.in);

        Main sol = new Main(in, out);

        out.close();
    }
}


class FastScanner{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public FastScanner(InputStream stream)
    {
        this.stream = stream;
    }

    int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    boolean isSpaceChar(int c)
    {
        return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
    }

    boolean isEndline(int c)
    {
        return c=='\n'||c=='\r'||c==-1;
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String next(){
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isSpaceChar(c));
        return res.toString();
    }

    String nextLine(){
        int c = read();
        while (isEndline(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isEndline(c));
        return res.toString();
    }
}


Measured memory_bytes: 96544
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <complex>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
int bsr(int x) { return 31 - __builtin_clz(x); }

using R = long double;
using P = complex<R>;

const R EPS = 1e-10;
const R PI = acos((R)(-1));

int sgn(R a) {
    if (abs(a) <= EPS) return 0;
    return (a < 0) ? -1 : 1;
}

int sgn(R a, R b) {
    return sgn(b-a);
}

bool near(P a, P b) {
    return !sgn(abs(a-b));
}

bool lessP(P l, P r) {
    if (sgn(l.real(), r.real())) return l.real() < r.real();
    if (sgn(l.imag(), r.imag())) return l.imag() < r.imag();
    return false;
}

R cross(P a, P b) { return a.real()*b.imag() - a.imag()*b.real(); }
R dot(P a, P b) { return a.real()*b.real() + a.imag()*b.imag(); }

R calc(P a, P b) {
    R u = arg(a);
    a *= polar<R>(1, -u);
    b *= polar<R>(1, -u);
    if (b.imag() < 0) b = conj(b);
//    cout << a << b << endl;
    R l = 0, r = a.real()/4;
    for (int i = 0; i < 200; i++) {
        R md = (l+r)/2;
        P aa = a-P(2*md, 0);
        P bb = b * polar<R>(1-(2*md/abs(a)), 0);
        R di = abs(aa)+abs(bb)+abs(aa-bb);
        R u = cross(aa, bb)/di;
        if (md < u) {
            l = md;
        } else {
            r = md;
        }
    }
    return l;
}

int main() {
    ios::sync_with_stdio(0);
    cout << setprecision(20);
    P p[3];
    for (int i = 0; i < 3; i++) {
        R x, y;
        cin >> x >> y;
        p[i] = P(x, y);
    }
    R ans = 0;
    ans = max(ans, calc(p[1]-p[0], p[2]-p[0]));
    ans = max(ans, calc(p[0]-p[1], p[2]-p[1]));
    ans = max(ans, calc(p[0]-p[2], p[1]-p[2]));
    ans = max(ans, calc(p[2]-p[0], p[1]-p[0]));
    ans = max(ans, calc(p[2]-p[1], p[0]-p[1]));
    ans = max(ans, calc(p[1]-p[2], p[0]-p[2]));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = 5e15;
int main(){
    ll N, M;
    cin >> N >> M;
    vector<P> v(M);
    for(auto &p : v) cin >> p.first >> p.second;
    sort(v.begin(), v.end(), [](auto &a, auto &b){return a.second < b.second;});
    ll pre = -1;
    ll ans = 0;
    for(auto p : v){
        if(p.first <= pre - 1 && pre <= p.second) continue;
        ans++;
        pre = p.second;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M, D;
  cin >> N >> M >> D;
  double res;
  if (D == 0) {
    res = 1.0 * (M - 1) / N;
  } else {
    res = 2.0 * (M - 1) / N * (N - D) / N;
  }
  cout << setprecision(10) << fixed << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
const ll INF = 1000000000000000;
ll n, dat[400010],  m;
vector<P> vec[200010];


ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

void init(ll n_)
{
	n = 1;
	while (n < n_)
	{
		n *= 2;
	}

	for (int i = 0; i < 2 * n - 1; i++)
	{
		dat[i] = INF;
	}
}

void update(ll k, ll a)
{
	k += n - 1;
	dat[k] = a;
	while (k > 0)
	{
		k = (k - 1) / 2;
		dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
	}
}

ll query(ll a, ll b, ll k, ll l, ll r)
{
	if (r <= a || b <= l)
	{
		return INF;
	}

	if (a <= l && r <= b)
	{
		return dat[k];
	}
	else
	{
		ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
}

int main(void)
{
	
	cin >> n;

	cout << (n - 1) / 2 << endl;

	int xxx;
	cin >> xxx;
}


Measured memory_bytes: 6400
import itertools
N = int(input())
ans = 0
A = []
aa = []
for n in range(N):
    a = int(input())
    aa.append(a)
    xy = [list(map(int,input().split())) for i in range(a)]
    A.append(xy)
for v in itertools.product([1,0], repeat = N):
    s = 1
    for i in range(N):
        if v[i] == 1:
            t = 1
            for j in range(aa[i]):
                if v[A[i][j][0]-1] != A[i][j][1]:
                    t = 0
                    break
            if t != 1:
                s = 0
                break
    if s == 1:
        break
print(v.count(1))




Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<sstream>

using namespace std;

#define open  freopen("input.txt","r",stdin)
#define close  freopen ("output.txt","w",stdout)
#define db double
#define ll long long
#define lll unsigned long long
#define loop(i,a,n) for(int i=a;i<=n;i++)
#define sf scanf
#define sf1(a) sf("%d",&a)
#define sf2(a,b) sf("%d %d",&a,&b)
#define sf3(a,b,c) sf("%d %d %d",&a,&b,&c)
#define sf4(a,b,c,d) sf("%d %d %d %d",&a,&b,&c,&d)
#define sfd(a) sf("%lf",&a)
#define sfd2(a,b) sf("%lf %lf",&a,&b)
#define sfl1(a) sf("%lld",&a)
#define sfl2(a,b) sf("%lld %lld",&a,&b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pf printf
#define pfi(x) pf("%d",x)
#define pfl(x) pf("%lld",x)
#define NL puts("")
#define bug pf("here is bug\n")
#define pft(tc) printf("Case %d:",tc++)
#define PI (2.0*acos(0.0))
//#define PI acos(-1.0)
#define mem(a,v) memset(a,v,sizeof a)
#define endl '\n'
#define pb push_back
#define xx first
#define yy second
#define mp make_pair
#define all(a) a.begin(),a.end()


template <class T> inline T bigmod(T p,T e,T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a,T b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
template <class T> inline T lcm(T a,T b)
{
    return (a/gcd(a,b))*b;
}
template <class T> inline T modinverse(T a,T M)
{
    return bigmod(a,M-2,M);
}   // M is prime}
template <class T> inline T bpow(T p,T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}




//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={0,1,0,-1};int dy[]={1,0,-1,0}; //4 Direction

#define linf 3000000000000000000ll
#define inf 999999999
#define MX 1000006
#define mod (ll) 1000000007
#define eps 1e-6
#define ub upper_bound // return the right most index of x<val
#define lb lower_bound // return the right most index of x<=val



struct data
{
    int ele1,ele2,ele3;
    data() {}
    data(int a,int b,int c)
    {
        ele1=a,ele2=b,ele3=c;
    }
    bool friend operator<(data a,data b)
    {
        return  a.ele1> b.ele1;// sort decreasingly but increasingly for priority_queue
    }
};


int n,m,k;
ll N,M,K;


int main()
{
    int t,tc=1;
	string a,b,c;
	cin>>a>>b>>c;
	char p=(a[0]-'a')+'A';
	char q=(b[0]-'a')+'A';
	char r=(c[0]-'a')+'A';
	pf("%c%c%c\n",p,q,r);
    return 0;
}

/*



*/


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

int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    if(a+b<=2*c){
        cout << a*x + b*y;
    }else{
        if(x>y){
            if(a>2*c){
                cout << 2*c*x; 
            }else{
                cout << 2*c*y + a*(x-y);
            }
        }else{
            if(b>2*c){
                cout << 2*c*y;
            }else{
                cout << 2*c*x + b*(y-x);
            }
        }
    }
    cout << endl;
}

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

int main(void) {
  ll N;
  cin >> N;
  vector<string> order(N), message(N);
  REP(i, 0, N) cin >> order[i] >> message[i];

  REP(i, 0, N) {
    string s(message[i]);
    ll l = message[i].length();

    REP(j, 0, order[i].size()) {
      char c = order[i][order[i].size() - j - 1];
      string t(s);

      if(c == 'J') {
        REP(k, 0, l) t[(k + 1 + l) % l] = s[k];
      }
      if(c == 'C') {
        REP(k, 0, l) t[(k - 1 + l) % l] = s[k];
      }
      if(c == 'E') {
        REP(k, 0, l / 2) swap(t[k], t[k + l / 2 + l % 2]);
      }
      if(c == 'A') {
        reverse(t.begin(), t.end());
      }
      if(c == 'P') {
        REP(k, 0, l) if('0' <= t[k] && t[k] <= '9') {
          t[k] = (t[k] - 1 - '0' + 10) % 10 + '0';
        }
      }
      if(c == 'M') {
        REP(k, 0, l) if('0' <= t[k] && t[k] <= '9') {
          t[k] = (t[k] + 1 - '0' + 10) % 10 + '0';
        }
      }

      swap(s, t);
    }

    cout << s << endl;
  }
}



Measured memory_bytes: 2988
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "tmp.cpp"

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

  int n, m;
  cin >> n >> m;
  vi h(n);
  REP(i, n) { cin >> h[i]; }

  vector<vector<int>> g(n);
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  int ans = 0;
  REP(i, n) {
    bool good = true;
    for (const auto e : g[i]) {
      if (h[i] <= h[e])
        good = false;
    }
    if (good) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main(void){
    ll k;
    cin >> k;

    queue<ll> q;

    for(ll i=1;i<=9;i++){
        q.push(i);
    }

    rep(i,k-1){
        ll x=q.front();
        q.pop();
        if(x%10!=0)
            q.push(10*x+x%10-1);
        q.push(10 * x + x % 10);
        if (x % 10 != 9)
            q.push(10 * x + x % 10 + 1);
    }

    cout << q.front() << endl;
    return 0;
}


Measured memory_bytes: 1792
N, M ,C = map(int, input().split())
B = list(map(int,input().split()))

ans = 0

for n in range(N):
    A = list(map(int,input().split()))
    tmp_n = C
    for a,b in zip(A,B):
        tmp_n += a*b

    if tmp_n>0:
        ans +=1

print(ans)


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


void solve(long long N, long long M, long long X, long long Y, std::vector<long long> x, std::vector<long long> y){
    x.push_back(X);
    y.push_back(Y);
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    if(x[N]<y[0]) cout << "No War" << endl;
    else cout << "War" << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    std::vector<long long> x(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
    }
    std::vector<long long> y(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&y[i]);
    }
    solve(N, M, X, Y, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 10000000070
#define for0(i, n) for(int i = 0; i < (n); i++)
#define mp make_pair
#define puts(x) cout << x << endl
using namespace std;
int v, e, r, ans[123456];
typedef pair<int, int> P;
vector<P>g[123456];
priority_queue<P, vector<P>, greater<P>>pq;
signed main() {
	cin >> v >> e >> r;
	for0(i, v)ans[i] = mod;
	while (e--) {
		int s, t, d; cin >> s >> t >> d;
		g[s].push_back(mp(t, d));
	}
	pq.push(mp(0, r));
	while (pq.size()) {
		P p1 = pq.top(); pq.pop();
		if (ans[p1.second] != mod)continue;
		ans[p1.second] = p1.first;
		for (P pv : g[p1.second]) {
			if (ans[pv.first] == mod)pq.push(mp(ans[p1.second] + pv.second, pv.first));
		}
	}
	for0(i, v)
		if (ans[i] == mod)puts("INF");
		else puts(ans[i]);
}


Measured memory_bytes: 22052
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define vpii vector< pair<int,int> >
#define mii map<int,int>
#define MOD 1000000007
#define fr(i,k,n) for(int i=k;i<n;i++)
#define fl(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
typedef long long ll;
int prime[100001]={};
void sieve()
{
	prime[0]=1;
	prime[1]=1;
	for(int i=0;i*i<100001;i++)
	{
		if(prime[i]==0)
		{
			for(int j=i*i;j<100001;j+=i)
			{
				prime[j]=1;
			}
		}
	}
}
ll binpow(ll a,ll b,ll m)
{
	ll res=1;
	while(b>0)
	{

	if(b&1)
	{
		res=res*a%m;
	}
	a=a*a%m;
	b>>=1;
   }
   return res;
}
void solve()
{
	ll n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	ll a1[n],a2[n];
	map<ll,ll> m1,m2;
	for(int i=0;i<n;i++)
	{
		a1[i]=a[i]-i;
		m1[a1[i]]++;
		a2[i]=a[i]+i;
		m2[a2[i]]++;
	}
	ll sum=0;
	for(int i=0;i<n;i++)
	{
		if(a1[i]<0)
		{
			sum+=m2[abs(a1[i])];
		}
	}
	cout<<sum<<endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t=1;
//cin>>t;
while(t--)
{
solve();
}

return 0;
}




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

using namespace std;

typedef long long int llint;
typedef unsigned long long int ullint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;

//#define DEBUG
//#define USE_SCANF

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

#ifdef DEBUG
#define dump(i) cout << "[*] " #i ": " << i << endl;
#define line cout << "\n[*]---------------[*]" << endl;
#else
#define dump(i)
#define line
#endif

constexpr int INT_INF = INT_MAX >> 1;
constexpr llint LL_INF = LLONG_MAX >> 1;
// variable -----
constexpr int MAX_N = 2 * 1e5;
int n;
int a[MAX_N];

llint sum;
// --------------

inline void input() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
}

inline void solve() {
	llint s_sum = 0;
	llint ans = LL_INF;

	rep(i, n-1) {
		s_sum += a[i];
		sum -= a[i];
		ans = min(ans, abs(s_sum - sum));
	}

	cout << ans << endl;
}

int main() {
#ifndef USE_SCANF
	ios::sync_with_stdio(false);
	cin.tie(0);
#endif

	input();
	line;
	solve();

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	string x;
 	cin >> x;
 	int ans=0;
 	if (x[0]=='2'){
 		ans++;
 	}
 	if (x[1]=='2'){
 		ans++;
 	}
 	if (x[2]=='2'){
 		ans++;
 	}
 	if (x[3]=='2'){
 		ans++;
 	}
 	cout << ans << endl;
 }

Measured memory_bytes: 256
# 初期入力
import sys
input = sys.stdin.readline
N = int(input())
ac =0
tle =0
wa =0
re =0
for i in range(N):
    S =input().strip()
    if S=="AC":
        ac +=1
    elif S=="TLE":
        tle +=1
    elif S=="WA":
        wa +=1
    elif S=="RE":
        re +=1
print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)

Measured memory_bytes: 9216
import java.util.Scanner;
  
public class Main { 
    public static void main(String[] args) { 
        Scanner scan = new Scanner(System.in);
        int i = 1;
        while(true) {
        int line = scan.nextInt();
        if(line == 0)
            break;

        System.out.println("Case " + i + ": " + line);                      
        i++;
        }
    }   
}   

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


int main()
{
	int a,b,c;
	cin>>a;
	cin>>b;
	cin>>c;
	int count = 0;
	for(int i = a; i <= b; i++){
		if(c % i == 0){
			count++;
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3092
n = int(raw_input())
ls = [int(raw_input()) for _ in range(n)]
sls = sorted(ls)
st = {j for i,j in enumerate(ls) if i % 2 == 1}
sst = {j for i,j in enumerate(sls) if i % 2 == 1}
print len(st.difference(sst))


Measured memory_bytes: 15732
#include<iostream>
#include<vector>
#include<cctype>
#include<sstream>

using namespace std;

vector<string> parse(const string &str){
  vector<string> ret;

  stringstream ss;

  for(int i = 0; i <= str.size(); i++){
    if(i == str.size()){
      ret.push_back(ss.str());
      ss.str("");
    }else if(str[i] == '_'){
      ret.push_back(ss.str());
      ss.str("");
    }else if(isupper(str[i])){
      if(ss.str().size() > 0) ret.push_back(ss.str());
      ss.str("");
      ss << (char)tolower(str[i]);
    }else{
      ss << str[i];
    }
  }

  return ret;
}

string convert(const vector<string> &v, char dist){
  stringstream ss;

  bool first = true;

  for(int i = 0; i < v.size(); i++){
    string tmp = v[i];
    
    if(dist == 'U'){
      tmp[0] = toupper(tmp[0]);
    }else if(dist == 'L'){
      if(!first) 
	tmp[0] = toupper(tmp[0]);
    }else if(dist == 'D'){
      if(!first)
	tmp = "_" + tmp;
    }

    ss << tmp;
    first = false;
  }

  return ss.str();
}

int main(){
  string buff;
  char dist;

  while(cin >> buff >> dist, dist != 'X'){
    cout << convert(parse(buff), dist) << endl;
  }

  return 0;
}

Measured memory_bytes: 0
# ABC074C - Sugar Water
# input
a, b, c, d, e, f = list(map(int, input().rstrip().split()))
A = a * 100
B = b * 100

# default values
x, y = min(a, b) * 100, 0  # density could be 0%
dens = y / x


# exhaustive search
for i in range(f // A + 1):
    for j in range(((f - A * i) // B) + 1):
        if i == 0 and j == 0:
            continue
        water = i * A + j * B
        rest = f - water
        for k in range(rest // c + 1):
            for l in range((rest - c * k) // d + 1):
                sugar = c * k + d * l
                total = water + sugar

                if sugar / total > e / (e + 100):  # compare to e (the max density)
                    break
                else:
                    if sugar / total > dens:
                        dens = sugar / total
                        x, y = total, sugar
print(x, y)

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

#define N 100000

int main(void){
    vector<bool> prime(N+1,true);
    prime[0]=prime[1]=false;
    for (size_t i = 0; i <= sqrt(N); i++)
    {
        if (prime[i])
        {
            for (size_t j = 2; i*j <= N; j++)
            {
                prime[i*j]=false;
            }
        }
    }
    int likeCnt[N];
    for (size_t i = 1; i <= N; i++)
    {
        likeCnt[i]=likeCnt[i-1];
        if (i%2==1&&prime[i]&&prime[(i+1)/2])
        {
            likeCnt[i]++;
        }
    }
    /**************************************/
    int q;
    cin >> q;
    int l[q],r[q];
    for (size_t i = 0; i < q; i++)
    {
        cin >> l[i] >> r[i];
        cout << likeCnt[r[i]] - likeCnt[l[i]-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MAX_N 15
using namespace std;

int data[MAX_N];
int n;

//出力
void print() {
    for(int r = 0; r < n; r++) {
        printf("%d", data[r]);
        if(r == n - 1) putchar('\n');
        else putchar(' ');
    }
}

//不動点であるか判定
bool judge() {
    for(int r = 0; r < n; r++) {
        if(count(data, data+n, data[r]) != data[r]) return(false);
    }
    return(true);
}

//数列を変換
void convert() {
    int tmp[n];
    for(int r = 0; r < n; r++) {
        tmp[r] = (int)count(data,data+n,data[r]);
    }
    memcpy(data, tmp, sizeof(tmp));
}

int solve() {
    int res = 0;
    while(!judge()) {
        convert();
        res++;
    }
    return(res);
}

int main(void) {
    while(cin >> n, n != 0) {
        for(int r = 0; r < n; r++) {
            cin >> data[r];
        }
        printf("%d\n", solve());
        print();
    }
    return(0);
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    a.push_back(a[0] + k);
    int l = 0;
    rep(i, n) { l = max(l, a[i + 1] - a[i]); }
    int ans = k - l;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
   int n;
   cin>>n;
   double a[n],s=0.0;

   for(int i=0;i<n;i++)
   {
      cin>>a[i];
      s=s+(1/a[i]);
   }
   cout<<1.0/s;

    return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    int start = 0;
    cin >> s;
    int end = s.size();
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'A') {
            start = i;
            break;
        }
    }

    for (int i = end; 0 <= i; --i) {
        if (s[i - 1] == 'Z') {
            end = i;
            break;
        }
    }
    cout << (end - start) << endl;

    return 0;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    int count = 0;
    if(a == 7)
    {
        count++;
    }

    if(b == 7)
    {
        count++;
    }
    if(c == 7)
    {
        count++;
    }

    if(count == 1)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static String s = "";

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		long ans = 0;

		long H = sc.nextLong();
		long W = sc.nextLong();

		if(H == 1 || W == 1)
			ans = 1;
		else
			ans = ((W+1) / 2) * ((H+1) / 2) + (W/2) * (H/2);

		System.out.println(ans);

	}

}


Measured memory_bytes: 23760
#include<bits/stdc++.h>
using namespace std;
typedef pair< int, int > Pi;
typedef pair< int, Pi > Pii;
struct edge {
  int to, bit;
};
const static int INF = 1 << 30;

int main()
{
  int N, M, E, S, T, R;
  vector< edge > graph[100];
  int NextBit[100] = {};

  cin >> N >> M >> E >> S >> T >> R;
  for(int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    graph[a].push_back((edge){b, -1});
    graph[b].push_back((edge){a, -1});
  }
  for(int i = 0; i < E; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    NextBit[c] |= 1 << i;
    graph[a].push_back((edge){b, i});
    graph[b].push_back((edge){a, i});
  }

  queue< Pii > Que;
  vector< vector< vector< int > > > v(N, vector< vector< int > >(R + 1, vector< int >(1 << E, INF)));
  Que.push(make_pair(0, make_pair(S, NextBit[S])));
  v[S][0][NextBit[S]] = 0;
  while(!Que.empty()) {
    Pii p = Que.front(); Que.pop();
    if(p.second.first == T) {
      cout << v[p.second.first][p.first][p.second.second] << endl;
      exit(0);
    }
    if(p.first < R) {
      for(int i = 0; i < graph[p.second.first].size(); i++) {
        const edge& e = graph[p.second.first][i];
        if(e.bit != -1 && !((p.second.second >> e.bit) & 1)) continue;
        if(v[e.to][p.first + 1][p.second.second|NextBit[e.to]] <= v[p.second.first][p.first][p.second.second] + 1) continue;
        v[e.to][p.first + 1][p.second.second|NextBit[e.to]] = v[p.second.first][p.first][p.second.second] + 1;
        Que.push(make_pair(p.first + 1, make_pair(e.to, p.second.second|NextBit[e.to])));
      }
    }
    if(v[S][0][p.second.second] <= v[p.second.first][p.first][p.second.second] + 1) continue;
    v[S][0][p.second.second] = v[p.second.first][p.first][p.second.second] + 1;
    Que.push(make_pair(0, make_pair(S, p.second.second)));
  }
  cout << -1 << endl;
}

Measured memory_bytes: 1996
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const mod = 1000000007

func mpow(x, y int) int {
	a := x
	ret := 1
	for y > 0 {
		if y%2 == 1 {
			ret *= a
			ret %= mod
		}
		a = a * a
		a %= mod
		y /= 2
	}
	return ret
}

var fact [500100]int
var ifact [500100]int

func nCk(n, k int) int {
	return fact[n] * ifact[k] % mod * ifact[n-k] % mod
}

func nPk(n, k int) int {
	return fact[n] * ifact[n-k] % mod
}

func main() {
	sc.Split(bufio.ScanWords)

	fact[0] = 1
	for i := 1; i <= 500001; i++ {
		fact[i] = (fact[i-1] * i) % mod
	}
	ifact[500000] = mpow(fact[500000], mod-2)
	for i := 500000; i > 0; i-- {
		ifact[i-1] = (ifact[i] * i) % mod
	}

	N, M := getInt(), getInt()
	ans := 0
	for k := 0; k <= N; k++ {
		x := nCk(N, k) * nPk(M, k) % mod * nPk(M-k, N-k) % mod * nPk(M-k, N-k) % mod
		//out(x)
		if k%2 == 0 {
			ans += x
			ans %= mod
		} else {
			ans -= x
			ans %= mod
			if ans < 0 {
				ans += mod
			}
		}
	}
	out(ans)
}


Measured memory_bytes: 9604
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> arr(n-1);
  for(int i=0;i<n-1;++i)cin>>arr[i];
  
  int sum = arr[0];
  for(int i=1;i<n-1;++i){
    sum+=min(arr[i],arr[i-1]);
  }
  sum+=arr[n-2];
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(void){
  int a=0;
  int b=0;
  int amem[5000]={0};
  int bmem[5000]={0};
  int i=0;
  scanf("%d",&a);
  scanf("%d",&b);
  for(i=0;i<a;i++){
    scanf("%d",&(amem[i]));
  }
  for(i=0;i<b;i++){
    scanf("%d",&(bmem[i]));
  }
  

  int ans=0;
  int ansm=0;
  i=0;
  while(i<b){
    int j=0;
    int m=i;
    while(j<a){
      while(amem[j]!=bmem[m] && j<a)j++;
      if(amem[j]==bmem[m]){
	ans++;
	m++;
	j++;
      }
    }
    if(ans>ansm){ansm=ans;}
    ans=0;
    i++;
  }
  printf("%d\n",ansm);
  return 0;
}

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

int main() {
	int a[12];
	for (int b = 0; b < 12; b++)cin >> a[b];
	sort(a, a + 12);
	if (a[0] == a[3] && a[4] == a[7]&&a[8]==a[11])puts("yes");
	else puts("no");
}

Measured memory_bytes: 3132
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#define f first
#define s second
#define pb push_back
using namespace std;
long long const inf=1e18+5;
int const maxn=1005;
typedef long long ll;
typedef pair<int,int>P;
vector<P>p;
char s[maxn];
int num[30];
ll solve(ll n,ll x){
	ll num = n/x;
	return (x+num*x)*num>>1;
}
int gcd(int a,int b){
	return b==0?a:gcd(b,a%b);
}
int main(){
	int n,res=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			for(int k=1;k<=n;k++)
				res+=gcd((gcd(i,j)),k);
	printf("%d\n",res);
}

Measured memory_bytes: 3828
from sys import stdin

def get_nexts(p):
    d, e = [n for i in range(n)], [n for i in range(n)]
    stack1, stack2 = [], []
    for i in range(n):
        while stack2 and p[stack2[-1]] < p[i]:
            idx = stack2.pop()
            e[idx] = i

        to_append = []
        while stack1 and p[stack1[-1]] < p[i]:
            idx = stack1.pop()
            d[idx] = i
            to_append.append(idx)

        while to_append:
            stack2.append(to_append.pop())
        stack1.append(i)

    dist1, dist2 = [], []
    for i in range(n):
        dist1.append(d[i] - i)
        dist2.append(e[i] - d[i])
    return dist1, dist2

if __name__ == '__main__':
    n = int(stdin.readline().rstrip())
    p = list(map(int, stdin.readline().rstrip().split()))

    dist1, dist2 = get_nexts(p)
    dist3, dist4 = get_nexts(p[::-1])
    dist3, dist4 = dist3[::-1], dist4[::-1]

    ans = 0
    for i in range(n):
        ans += (dist1[i] * dist4[i] + dist2[i] * dist3[i]) * p[i]
    print(ans)


Measured memory_bytes: 76236
def calculate(n,m,arr):
    arr.sort()
    drr = list([])
    for index in range(1,len(arr)):
        drr.append(arr[index] - arr[index-1])
    drr.sort()
    total = 0
    for i in range(m-n):
        total += drr[i]
    print(total)



S = input().split(" ")
n = int(S[0])
m = int(S[1])

S = input().split(" ")

arr = list([int(s) for s in S])


calculate(n,m,arr)



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

using namespace std;
typedef long long ll;

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

/*Solve*/

int main(){
    ll n,m,c;
    cin >> n >> m >> c;
    vector<ll> b;
    rep(i,m){
        ll x;
        cin >> x;
        b.push_back(x);
    }
    ll a[30][30];
    ll ans=0;
    rep(i,n){
        ll tmp=0;
        rep(j,m){
            cin >> a[i][j];
            tmp+=b[j]*a[i][j];
        }
        tmp+=c;
        if(tmp>0)
            ans++;
    }
    cout << ans;
}

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

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

    int N, M;
    cin >> N >> M;
    int Lmax = 0, Rmin = INT_MAX;
    for (int i = 0; i < M; ++i) {
        int L, R;
        cin >> L >> R;
        Lmax = max(Lmax, L);
        Rmin = min(Rmin, R);
    }
    cout << max(0, Rmin - Lmax + 1) << endl;

    return 0;
}

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

template <typename T, typename U> bool cmin(T &a, U b) { return a > b && (a = b, true); }
template <typename T, typename U> bool cmax(T &a, U b) { return a < b && (a = b, true); }

template <typename T, T (*op)(T, T), T (*ie)()> class SegmentTree {
private:
  int N, size, log;
  vector<T> D;
  void apply(int k) { D.at(k) = op(D.at(2 * k), D.at(2 * k + 1)); }
  int ceil_pow(int n) {
    int x = 0;
    while ((1U << x) < (unsigned int)(n)) x++;
    return x;
  }
 
public:
  SegmentTree() : SegmentTree(0) {}
  SegmentTree(int n) : SegmentTree(vector<T>(n, ie())) {}
  SegmentTree(const vector<T> &v) : N((int)v.size()) {
    log = ceil_pow(N);
    size = 1 << log;
    D = vector<T>(2 * size, ie());
    for (int i = 0; i < N; i++) D.at(size + i) = v.at(i);
    for (int i = size - 1; i >= 1; i--) apply(i);
  }
  void set(int p, T x) {
    p += size;
    D.at(p) = x;
    for (int i = 1; i <= log; i++) apply(p >> i);
  }
  T get(int p) { return D.at(p + size); }
  T query(int l, int r) {
    r++;
    T sml = ie(), smr = ie();
    l += size, r += size;
    while (l < r) {
      if (l & 1) sml = op(sml, D.at(l++));
      if (r & 1) smr = op(D.at(--r), smr);
      l >>= 1, r >>= 1;
    }
    return op(sml, smr);
  }
  T query_all() { return D.at(1); }
  template <bool (*f)(T)> int max_right(int l) {
    return max_right(l, [](T x) { return f(x); });
  }
  template <class F> int max_right(int l, F f) {
    if (l == N) return N;
    l += size;
    T sm = ie();
    do {
      while (l % 2 == 0) l >>= 1;
      if (!f(op(sm, D.at(l)))) {
        while (l < size) {
          l = (2 * l);
          if (f(op(sm, D.at(l)))) sm = op(sm, D.at(l++));
        }
        return l - size;
      }
      sm = op(sm, D.at(l++));
    } while ((l & -l) != l);
    return N;
  }
  template <bool (*f)(T)> int min_left(int r) {
    return min_left(r, [](T x) { return f(x); });
  }
  template <class F> int min_left(int r, F f) {
    if (r == 0) return 0;
    r += size;
    T sm = ie();
    do {
      r--;
      while (r > 1 && (r % 2)) r >>= 1;
      if (!f(op(D.at(r), sm))) {
        while (r < size) {
          r = (2 * r + 1);
          if (f(op(D.at(r), sm))) sm = op(D.at(r--), sm);
        }
        return r + 1 - size;
      }
      sm = op(D.at(r), sm);
    } while ((r & -r) != r);
    return 0;
  }
};
 
using mono = int;
mono op(mono a, mono b) { return max(a, b); };
mono ie() { return 0; };
 
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
 
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
 
  int MX = 3e5;
  SegmentTree<mono, op, ie> ST(MX + 1);
  for (int i = 0; i < N; i++) {
    int l = A.at(i) - K;
    cmax(l, 0);
    int r = A.at(i) + K;
    cmin(r, MX);
    ST.set(A.at(i), ST.query(l, r) + 1);
  }
  cout << ST.query_all() << "\n";
}

Measured memory_bytes: 9800
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<char,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
const double PI=acos(-1);
using namespace std;

int main( ) {
    ll X;
    cin>>X;
    if(X>=30) {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    }
    

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define mod1 998244353
#define timepass 1073741824
#define MAXN 200000 + 5
#define LOGN 20
using namespace std;
#define N 505

/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(arr) arr.begin() , arr.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i , a , n) for(int i = a ; i < n ; i++)
#define rrep(i , n , a) for (int i = n - 1 ; i >= a ; i--)
#define ms(arr , val) memset(arr , val , sizeof(arr))
#define sp(a , x) cout << fixed << setprecision(a) << x << endl; 
#define siz(temp) (ll)temp.size()
#define len(temp) (ll)temp.length()
#define int ll
#define s(arr) sort(all(arr))
#define r(arr) reverse(all(arr))
#define rs(arr) s(arr) ; r(arr)
#define pi acos(-1)
#define con continue
#define endl "\n"
#define w(q) while(q--)

//debug
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace7(a, b, c, d, e, f , g) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<< f << " | "<< #g <<": "<<g<<endl
#define trace8(a, b, c, d, e, f , g , h) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<< f << " | " << #g <<": "<< g <<" | "<<#h<< ": " << h << endl

typedef pair<int , int> pii;
typedef pair<int , pii> piii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<piii> vpiii;

signed main()
{
    FAST;
    string str;
    cin >> str;
    int fl = str[3] == str[2] && str[4] == str[5];
    if (fl)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (int)(a); v < (int)(b); ++v)
#define FORE(v, a, b) for(int v = (int)(a); v <= (int)(b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define PF push_front
#define ALL(x) (x).begin(), (x).end()
using namespace std;

void split(string str, char chr, vector< string > *res){
	stringstream ss(str);
	string itm;
	while(getline(ss, itm, chr)){
		(*res).PB(itm);
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, r, p, c;
	list< int > l1, l2;
	
	while(cin >> n >> r, n){
		l1.CLR();
		l2.CLR();
		
		REP(i, n){
			l1.PF(i + 1);
		}
		
		REP(i, r){
			cin >> p >> c;
			
			list< int >::iterator bitr = l1.begin(), eitr = l1.begin();
			advance(bitr, p - 1);
			advance(eitr, p + c - 1);
			
			l2.splice(l2.begin(), l1, bitr, eitr);
			
			l1.splice(l1.begin(), l2);
		}
		
		cout << l1.front() << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
using namespace std;

void print() { std::cout << std::endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
    std::cout << head;
    if(sizeof...(tail) != 0)
        std::cout << " ";
    print(std::forward<Tail>(tail)...);
}
template <class T> void print(std::vector<T> &vec) {
    for(auto &a : vec) {
        std::cout << a;
        if(&a != &vec.back())
            std::cout << " ";
    }
    std::cout << std::endl;
}
template <class T> void print(std::vector<std::vector<T>> &df) {
    for(auto &vec : df) {
        print(vec);
    }
}

int main() {
    string s;
    cin >> s;

    string result = "Good";
    for(int i = 0; i <= 3; i++) {
        if(s[i] == s[i + 1]) {
            result = "Bad";
        }
    }
    print(result);
}


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

using namespace std;

int main()
{
    long long int n,m,l,i,j,k,A[110][110],B[110][110],C[110][110],c;
    cin>>n>>m>>l;

    for(i=1;i<=n;i++)
    {
        for(k=1;k<=m;k++)
    {
     cin>>A[i][k];
    }
    }

    for(k=1;k<=m;k++)
    {
        for(j=1;j<=l;j++)
    {
     cin>>B[k][j];
    }
    }


    for(i=1;i<=l;i++)
    {
        for(j=1;j<=n;j++)
    {
        c=0;
            for(k=1;k<=m;k++)
            {
               c=c + A[j][k]*B[k][i];
            }
            C[j][i]=c;

    }
    }


     for(i=1;i<=n;i++)
    {
        for(j=1;j<=l;j++)
    {

            if(j==l)
            cout<<C[i][j];
          else
            cout<<C[i][j]<<" ";
      }

      cout<<endl;
    }



}



Measured memory_bytes: 3364
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,m;
int main(){
	in(n);in(m);
    if(n<=10)cout<<m+100*(10-n)<<endl;
    else cout<<m<<endl;
	return 0;
}


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

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

fn solve() {
    let (a,b,c,k) = read!(i64,i64,i64,i64);
    let mut ans = 0;
    let mut res = k;
    let mut val = min(res,a);
    ans += val;
    res -= val;
    if res>0 {
        val = min(b,res);
        res -= val;
    }
    if res>0 {
        val = min(c,res);
        ans -= val;
        res -= val;
    }
    println!("{}", ans);
}

fn run() {
    solve();
}


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

int main() {
    int N;
    cin >> N;
    long long a[N + 1], b[N];
    for (int i = 0; i < N+1; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> b[i];
    }

    long long ans = 0;
    for (int i = 0; i < N; i++)
    {
        long long tmp = min(a[i] + a[i + 1], b[i]);
        ans += tmp;
        if(tmp > a[i]) a[i+1] = a[i] + a[i+1] - tmp;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

string solve(int n) {
    if (n == 2 || n == 4 || n== 5 || n == 7 || n == 9) {
        return "hon";
    } else if (n == 0 || n == 1 || n == 6 || n == 8) {
        return "pon";
    } else {
        return "bon";
    }
}

int main() {
    string s;
    cin >> s;
    cout << solve(int(s[s.length() - 1]) - 48);
}

Measured memory_bytes: 3624