akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

#define MP make_pair
#define MT make_tuple
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

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

	LL ai, ao, at, aj, al, as, az;
	cin >> ai >> ao >> at >> aj >> al >> as >> az;

	LL ret = 0;
	
	if((ai % 2 + aj % 2 + al % 2 >= 2) && ai && aj && al){
		ret += 3;
		ai -= 1;
		aj -= 1;
		al -= 1;
	}
	
	ret += ai / 2 * 2;
	ai -= ai / 2 * 2;

	ret += ao / 1 * 1;

	ret += aj / 2 * 2;
	aj -= aj / 2 * 2;

	ret += al / 2 * 2;
	al -= al / 2 * 2;


	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 384
def main():
    n, m = map(int, input().split())
    ans = []
    t = [True]*(n+1)
    l = n//2 - 1
    for i in range(1, n//2):
        if l <= 0:
            break
        if not t[i] or not t[i+l]:
            continue
        ans.append([i, i+l])
        t[i] = False
        t[i+l] = False
        l -= 2
    if n % 2 == 1:
        l = n//2
        for i in range(n//2, n):
            if l <= 0:
                break
            if not t[i] or not t[i+l]:
                continue
            ans.append([i, i+l])
            t[i] = False
            t[i+l] = False
            l -= 2
    else:
        l = n//2 - 2
        for i in range(n//2, n):
            if l <= 0:
                break
            if not t[i] or not t[i+l]:
                continue
            ans.append([i, i+l])
            t[i] = False
            t[i+l] = False
            l -= 2
    for i in range(m):
        print(ans[i][0], ans[i][1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 23964
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <iterator>

#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

const int cons = 1e9 + 7;

//C

int main(void) {
	ll n;
	cin >> n;
	vector<ll> smaller = vector<ll>(n);
	rep(0, n) {
		cin >> smaller[i];
	}
	sort(smaller.begin(), smaller.end());

	ll ansPattern1 = 0, ansPattern2 = 0;
	
	ll plus1 = 0, plus2 = 0, minus1 = 0, minus2 = 0;
	if (n % 2 == 0) {
		plus1 = 1;
		minus1 = 1;
		plus2 = minus2 = (n - 2) / 2;
	}
	else {
		plus1 = 2;
		minus2 = 1 + (n - 3) /2;
		plus2 = (n - 3) / 2;
	}
	ll smallIndex = 0, largeIndex = n - 1;
	rep(0, plus2) {
		ansPattern1 += 2 * smaller[largeIndex];
		largeIndex--;
	}
	rep(0, minus2) {
		ansPattern1 -= 2 * smaller[smallIndex];
		smallIndex++;
	}
	rep(0, plus1) {
		ansPattern1 += smaller[largeIndex];
		largeIndex--;
	}
	rep(0, minus1) {
		ansPattern1 -= smaller[smallIndex];
		smallIndex++;
	}

	plus1 = 0, plus2 = 0, minus1 = 0, minus2 = 0;
	if (n % 2 == 1) {
		minus1 = 2;
		plus2 = 1 + (n - 3) / 2;
		minus2 = (n - 3) / 2;

		ll smallIndex = 0, largeIndex = n - 1;
		rep(0, plus2) {
			ansPattern2 += 2 * smaller[largeIndex];
			largeIndex--;
		}
		rep(0, minus2) {
			ansPattern2 -= 2 * smaller[smallIndex];
			smallIndex++;
		}
		rep(0, plus1) {
			ansPattern2 += smaller[largeIndex];
			largeIndex--;
		}
		rep(0, minus1) {
			ansPattern2 -= smaller[smallIndex];
			smallIndex++;
		}
	}
	
	cout << max(ansPattern1, ansPattern2) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
typedef vector<P> Pol;
D eps=1e-9;
bool eq(D a,D b){return abs(a-b)<eps;}
int sig(D a){return eq(a,0)?0:(a>0?1:-1);}
void fix(D &x){if(sig(x)==0) x=0;}
D cro(P a,P b){return imag(conj(a)*b);}
int ccw(P a,P b,P c){
	if(sig(cro(b-a,c-a))==1) return 1;
	if(sig(cro(b-a,c-a))==-1) return -1;
	if(eq(abs(a-c)+abs(c-b),abs(a-b))) return 0;
	if(eq(abs(a-b)+abs(c-b),abs(a-c))) return -2;
	return 2;
}
D aPol(Pol p){
	int N=p.size();
	D ret=0;
	rep(i,N) ret+=cro(p[i],p[(i+1)%N])/2;
	return ret;
}
bool iLSex(L l,L s){
	return sig(cro(l.sc-l.fs,s.fs-l.fs)*cro(l.sc-l.fs,s.sc-l.fs))<0;
}
P intLL(L a,L b){
	D t=cro(a.sc-a.fs,a.sc-b.fs)/cro(a.sc-a.fs,b.sc-b.fs);
	return b.fs+t*(b.sc-b.fs);
}
Pol convexcut(Pol p,L l){
	Pol ret;
	int N=p.size();
	rep(i,N){
		if(ccw(l.fs,l.sc,p[i])!=-1) ret.pb(p[i]);
		L s=L(p[i],p[(i+1)%N]);
		if(iLSex(l,s)) ret.pb(intLL(l,s));
	}
	return ret;
}
int H,W;
D la,ra,lb,rb,mx;
string s[50];
int main(){
	cin>>H>>W>>la>>ra>>lb>>rb>>mx;
	rep(i,H) cin>>s[i];
	int ca=0,cb=0,cx=0;
	D xa=0,xb=0,xx=0,ya=0,yb=0,yx=0;
	rep(i,H) rep(j,W){
		if(s[i][j]=='A'){
			xa+=j+0.5,ya+=i+0.5,ca++;
		}else if(s[i][j]=='B'){
			xb+=j+0.5,yb+=i+0.5,cb++;
		}else if(s[i][j]=='X'){
			xx+=j+0.5,yx+=i+0.5,cx++;
		}
	}
	xa/=ca,ya/=ca,xb/=cb,yb/=cb,xx/=cx,yx/=cx;
	mx*=cx;
	la*=ca,ra*=ca,lb*=cb,rb*=cb;
	D ans=0;
	rep(ii,H) rep(jj,W){
		D x=jj,y=ii;
		Pol pol;
		pol.pb(P(la,lb));
		pol.pb(P(ra,lb));
		pol.pb(P(ra,rb));
		pol.pb(P(la,rb));
		{
			D A=xa-x,B=xb-x,C=(xx-x)*mx;
			fix(A),fix(B),fix(C);
			if(B!=0){
				P p(0,-C/B),q(1,-(C+A)/B);
				if(B<0) swap(p,q);
				pol=convexcut(pol,L(p,q));
			}else if(A!=0){
				P p(-C/A,0),q(-C/A,1);
				if(A>0) swap(p,q);
				pol=convexcut(pol,L(p,q));
			}else{
				if(C<0) pol.clear();
			}
		}
		{
			D A=xa-x-1,B=xb-x-1,C=(xx-x-1)*mx;
			fix(A),fix(B),fix(C);
			if(B!=0){
				P p(0,-C/B),q(1,-(C+A)/B);
				if(B>0) swap(p,q);
				pol=convexcut(pol,L(p,q));
			}else if(A!=0){
				P p(-C/A,0),q(-C/A,1);
				if(A<0) swap(p,q);
				pol=convexcut(pol,L(p,q));
			}else{
				if(C>0) pol.clear();
			}
		}
		{
			D A=ya-y,B=yb-y,C=(yx-y)*mx;
			fix(A),fix(B),fix(C);
			if(B!=0){
				P p(0,-C/B),q(1,-(C+A)/B);
				if(B<0) swap(p,q);
				pol=convexcut(pol,L(p,q));
			}else if(A!=0){
				P p(-C/A,0),q(-C/A,1);
				if(A>0) swap(p,q);
				pol=convexcut(pol,L(p,q));
			}else{
				if(C<0) pol.clear();
			}
		}
		{
			D A=ya-y-1,B=yb-y-1,C=(yx-y-1)*mx;
			fix(A),fix(B),fix(C);
			if(B!=0){
				P p(0,-C/B),q(1,-(C+A)/B);
				if(B>0) swap(p,q);
				pol=convexcut(pol,L(p,q));
			}else if(A!=0){
				P p(-C/A,0),q(-C/A,1);
				if(A<0) swap(p,q);
				pol=convexcut(pol,L(p,q));
			}else{
				if(C>0) pol.clear();
			}
		}
		if(s[ii][jj]!='.') ans+=(aPol(pol)/(ra-la)/(rb-lb));
	}
	printf("%.12f\n",ans);
}

Measured memory_bytes: 3416
#include <iostream>

using namespace std;

int main(int argc, const char *argv[]) {
  using ll = long long;
  ll a, b, k;
  cin >> a >> b >> k;

  if (a >= k) {
    // 青木くんのクッキーは無傷
    cout << a - k << " " << b;
  } else {
    cout << 0 << " " << max(0ll, b - (k - a));
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int N,i,j,cnt=0,a[101];
	scanf("%d",&N);
	for(i=0;i<N;i++){scanf("%d",&a[i]);}
	for(i=0;i<N;i++){
		int max=i;
		for(j=0;j<N;j++){if(a[max]<a[j]){max=j;}}
		cnt+=i%2==0?a[max]:-a[max];
		a[max]=0;
	}
	printf("%d",cnt);
	return 0;
}

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

int main(void){
    string s;
    cin >> s;
    
    int a = 0;
    while(s[a] != 'A'){
        a++;
    }
    
    int z = s.length() - 1;
    while(s[z] != 'Z'){
        z--;
    }
    
    cout << z - a + 1 << endl;
    
    return 0;
}


Measured memory_bytes: 640
N = "0" + input()
ans, carry = 0, 0
for i in range(len(N) - 1, 0, -1):
    n = int(N[i]) + carry
    ans += min(10 - n, n)
    carry = 1 if n > 5 or (n == 5 and int(N[i - 1]) >= 5) else 0

print(ans + carry)


Measured memory_bytes: 5492
import os,re
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy
setrecursionlimit(10**6)

s=input()
res=[]
cnt=1
now=s[0]
for i in range(1,len(s)):
    if now!=s[i]:
        res.append((now,cnt))
        cnt=1
        now=s[i]
    else:
        cnt+=1
res.append((now,cnt))
ans=[]
for i in range(0,len(res),2):
    nowt=res[i][0]*res[i][1]+res[i+1][0]*res[i+1][1]
    ind=nowt.index("RL")
    for j in range(len(nowt)):
        if j!=ind and j!=ind+1:
            ans.append(0)
        else:
            if (j+1)%2==0:
                ans.append(len(nowt[1::2]))
            else:
                ans.append(len(nowt[0::2]))
print(*ans)

Measured memory_bytes: 59168
#include<bits/stdc++.h>
using namespace std;
main()
{
	int n,i,j,r=0,g=0,b=0;
	unsigned int x;
	string s;
	cin>>n;
	cin>>s;
	for(i=0;i<n;i++){
		if(s[i]=='R') r++;
		else if(s[i]=='G') g++;
		else if(s[i]=='B') b++;
	}
	x=r*b*g;
	for(i=0;i<=n/2;i++){
		for(j=0;j+2*i<n;j++){
			if(s[j]!=s[i+j] && s[j]!=s[2*i+j] && s[i+j]!=s[2*i+j]) x--;
		}
	}
	cout<<x<<'\n';
}

Measured memory_bytes: 3536
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    private static FastScanner sc = new FastScanner();
    private static long mod = 1000000007;

    public static void main(String[] args) {
    	int N = sc.nextInt();
    	int K = sc.nextInt();
    	long[] frac = new long[2001];
    	frac[0] = 1;
    	for(int i=1; i<=2000; i++) {
    		frac[i] = frac[i-1] * i % mod;
    	}
    	for(int i=1; i<=K; i++) {
    		if(N-K+1 < i) {
    			System.out.println(0);
    			continue;
    		}
    		System.out.println(frac[N-K+1] * power(frac[i], mod-2) % mod *  power(frac[N-K+1-i], mod-2) % mod * frac[K-1] % mod * power(frac[i-1], mod-2) % mod *  power(frac[K-i], mod-2) % mod);
    	}
    }

    static long power(long m , long n){
    	if(n == 0) {
    		return 1;
    	}else if(n == 1){
            return m;
        }else if(n % 2 == 0){
            long s = power(m, n/2);
            return ( (s % mod) * (s % mod) ) % mod;
        }else{
            return ( (m % mod) * (power(m, n-1) % mod) ) % mod;
        }
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 22100
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());
#define usort(a) sort(a.rbegin(),a.rend());

using namespace::std;

int jo(ll int a, ll int b){//累乗
    ll int num=1;
    rep(i,0,b) num=num*a;
    return num;
}
char tobig(char s){//char大文字化
  return (s-0x20);
}
char tolow(char s){//char小文字化
  return (s+0x20);
}
int ctoi(char a){//char->int
  if('0'<=a&&a<='9') return (a-'0');
  return -1;
}

int gcd(ll int a,ll int b) {//最大公約数
  if(a<b) return gcd(b,a);
  int c;
  while ((c=a%b)) {
    a=b;
    b=c;
  }
  return b;
}
int lcm(ll int a,ll int b){//最小公倍数
 return (a*b)/gcd(a,b);
}


int main(){
  int A,B,C; cin>>A>>B>>C;
  cout<<(A+B+C>21?"bust":"win");
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート
//  sort(変数名.rbegin(),変数名.rend());//降順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順

Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);int[]p=new int[30];int i=0,e=2;for(;i<30;p[i++]=e++)for(;f(p,e)<1;e++);for(;(e=s.nextInt())>0;System.out.println(e-2+" "+e))for(;e>4;--e)if(f(p,e)+f(p,e-2)>1)break;}static int f(int[]p,int n){for(int e:p)if(e>0&&n!=e&&n%e<1)return 0;return 1;}}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mkmap;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<vi> vv;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
const ll mod=1000000007;
const int sz=1000001;
#define endl "\n"
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b) for(i=a;i<b;++i)
#define rrep(i,a,b) for(i=a;i>=b;--i)
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db(x) cout << (#x) << " = " << x << endl;

inline ll mult(ll a, ll b) {return (((a % mod) * (b % mod)) % mod);}



int main(){
    fast;
    int t,tt,tti,n,m,x,y,z,i,j,k,temp,count,o,e,f,ans,sum,l,r,mx,mn;
    ll lx,ly,lz,ltemp;
    double fx,fy,fz;
    string s;
    
    cin>>n>>m;
    int dp1[1001],dp2[1001]={};
    string a[n];
    rep(i,0,n) cin>>a[i];
    dp2[1]=1;
    rep(i,0,m){
        dp1[0]=dp2[0];
        dp2[0]=0;
        rep(j,1,n+1){
            dp1[j]=dp2[j];
            if(a[j-1][i]=='#') dp2[j]=0;
            else dp2[j]=((ll)dp1[j]+dp2[j-1])%mod;
        }
    }
    cout<<dp2[n];
}

/*
    
*/

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

using namespace std;

typedef long long ll;
string s;
int N;

int main(){
        cin>>s;
        N=s.length();
        ll res=0;
        //bitで+の位置を表す
        for(int i=0;i<1<<(N-1);i++){
                ll sm=0;
                ll a=s[0]-'0';
                for(int j=0;j<N-1;j++){
                        //bitが立っているか(+があるか)
                        if(i&(1<<j)){
                                sm+=a;
                                a=0;
                        }
                        a=a*10+(s[j+1]-'0');
                }
                sm+=a;
                res+=sm;
        }
        cout<<res<<endl;
        return 0;
}


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

const long long INF = 10000000000;
int v,e;
long long d[100][100];

int main(){
  scanf("%d %d",&v,&e);
  fill(d[0],d[0]+10000,INF);
  for(int i=0;i<v;i++) d[i][i] = 0;
  for(int i=0;i<e;i++){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    d[a][b] = c;
  }
  for(int k=0;k<v;k++){
    for(int i=0;i<v;i++){
      for(int j=0;j<v;j++){
        if(d[i][k]!=INF&&d[k][j]!=INF){
          d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
        }
      }
    }
  }
  bool flag = false;
  for(int i=0;i<v;i++){
    if(d[i][i]<0){
      flag = true;
    }
  }
  if(flag){
    printf("NEGATIVE CYCLE\n");
  }else{
    for(int i=0;i<v;i++){
      for(int j=0;j<v;j++){
        if(j!=0) printf(" ");
        if(d[i][j]==INF) printf("INF");
        else printf("%lld",d[i][j]);
      }
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 2820
a, b, c, K = gets.split.map(&:to_i)
k = K
sum = 0

if a > K then
    sum = K
else
    k -= a
    sum += a * 1
    if k > 0 then
        k -= b
        k = 0 if k <= 0
    end
    if k > 0 then
        sum += k * -1
    end
end

puts sum


Measured memory_bytes: 14332
#-*-coding:utf-8-*-

def main():
    n, k = map(int, input().split())
    okashi = set()
    for i in range(k):
        d = int(input())
        okashi |= set(list(map(int, input().split())))
    print(n - len(okashi))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9204
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
/*-------------------------------------------------------------------------------------------------------------------------------------*/
#define MOD 1000000007
#define endl "\n" 
#define int long long // remove when constraints are tight.
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/

int32_t main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int n,r;
	cin>>n>>r;
	if(n<10)
	{
		cout<<r+100*(10-n)<<endl;
	}
	else
	{
		cout<<r<<endl;
	}
	
}


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

using namespace std;
vector<int>g[100002];
int h[100002];
int main()
{
    int n, m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        h[i]=x;
    }
    for(int i=0;i<m;i++){
        int x, y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    int cnt=0;
    for(int j=1;j<=n;j++){
        int a=j;
        bool good=true;
        for(int i=0;i<g[a].size();i++){
            if(h[g[a][i]]>=h[a]){
                good=false;
            }
        }
        if(good==true){
            cnt++;
        }
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
int main(){
 	int n,m,a;
  	while(cin>>n>>m>>a){
      if(n==0&&m==0&&a==0){break;}
      int v[1010][110]={0};
      for(int i=0; i<m; i++){
        int h,p,q;
        cin>>h>>p>>q;
        v[h][p]=q,v[h][q]=p;
      }
      for(int i=1000; i>=0; i--){
		if(v[i][a])a=v[i][a];
      }
      cout<<a<<endl;
    }
}







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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
#define MAX_N 100010
struct edge{
  ll to, cost;
};

ll d[MAX_N];
vector<edge> vertex[MAX_N];
ll n;

bool bfs(ll s, ll count){
  priority_queue<pll, vector<pll>, greater<pll>> que;
  que.push(pll(0, s));

  REP(i, n)
    d[i] = LLINF;
  d[s] = 0;

  while(!que.empty()){
    pll p = que.top();
    que.pop();

    ll dist = p.FI;
    ll v = p.SE;
    if(d[v] < dist)
      continue;

    for(ll i = 0; i < vertex[v].size(); i++){
      edge e = vertex[v][i];
      if(d[e.to] > dist+e.cost){
        d[e.to] = dist + e.cost;
        que.push(pll(d[e.to], e.to));
      }
    }
  }



}


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;

  ll u, v, w;
  REP(i, n-1){
    cin >> u >> v >> w;
    u--;
    v--;
    vertex[u].push_back({v, w});
    vertex[v].push_back({u, w});
  }

  ll s = 0;
  bfs(s, 0);
  REP(i, n){
    cout << d[i]%2 << endl;
  }

}


Measured memory_bytes: 8704
#include <string>
#include <vector>
#include <map>
#include <deque>
#include <iostream>
#include <queue>
#include <math.h>
#include <algorithm>
#include <fstream>

using namespace std;
typedef long long ll;


int main(void) {
	int a, b;
	double n;
	cin >> a >> b;
	if (b == 1) {
		cout << 0;
		return 0;
	}
	n = ceil(double(b-1) / (a - 1));
	cout << n;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int l,r,d;

int main()
{
	int ans=0;
	cin>>l>>r>>d;
	for(int i=l;i<=r;i++) if(i%d==0) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3624
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    /*
    a = 0
    b = 1
    c = 2
    */
    
    String str[] = new String[3];
    int count[] = new int[3];
    for(int i = 0 ; i < 3 ; ++i){
      str[i] = sc.next();
      count[i] = str[i].length();
    }
	
    //最初はAさん
    int i = 0;
    
    while(true){    
 
      //あがりの人いるかな
      if(count[i]==0&&i==0){
        System.out.println("A");
        return;
      }else if(count[i]==0&&i==1){
        System.out.println("B");
        return;
      }else if(count[i]==0&&i==2){
        System.out.println("C");
        return;
      }

      //次の人誰かな
      if(str[i].charAt(str[i].length()-count[i])=='a'){
        count[i]--;
        i=0;
      }else if(str[i].charAt(str[i].length()-count[i])=='b'){
        count[i]--;
        i=1;
      }else if(str[i].charAt(str[i].length()-count[i])=='c'){
        count[i]--;
        i=2;
      }
      
      /*カードぽいっ
      count[i]--;*/
 
    }

  }
}

Measured memory_bytes: 35828
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<string> a(N);
  vector<int> b(N);
  rep(i,N)
  {
    cin >> a[i];
    cin >> b[i];
    b[i] = 100 - b[i];
  }
  vector<tuple<string,int,int>> c;
  rep(i,N)
  {
    c.push_back(make_tuple(a[i],b[i],i+1));
  }
  sort(ALL(c));
  rep(i,N)
  {
    cout << get<2> (c[i]) << endl;
  }
  return 0;
}


Measured memory_bytes: 3604
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        List<Integer> coefficient = new ArrayList<Integer>();
        List<String> answers = new ArrayList<String>();
        while (scanner.hasNext()) {
            for (int i = 0; i < 6; i++) {
                coefficient.add(Integer.parseInt(scanner.next()));
            }
            SimultaneousEquation equation = new SimultaneousEquation(coefficient);
            equation.compute();
            answers.add(String.format("%.3f", equation.getX()) + " " + String.format("%.3f", equation.getY()));

            coefficient.clear();
        }

        for (String answer : answers) {
            System.out.println(answer);
        }
    }

    private static class SimultaneousEquation {
        private double a, b, c, d, e, f, x, y;

        SimultaneousEquation(List<Integer> coefficient) {
            this.a = coefficient.get(0);
            this.b = coefficient.get(1);
            this.c = coefficient.get(2);
            this.d = coefficient.get(3);
            this.e = coefficient.get(4);
            this.f = coefficient.get(5);
        }

        void compute() {
            double denominator = a * e - d * b;
            if (denominator != 0) {
                this.x = (c * e - f * b) / denominator;
                this.y = (a * f - d * c) / denominator;

                if (this.x == 0) {
                    this.x = Math.abs(this.x);
                }
                
                if (this.y == 0) {
                    this.y = Math.abs(this.y);
                }
            }
        }

        double getX() {
            return this.x;
        }

        double getY() {
            return this.y;
        }
    }
}

Measured memory_bytes: 17228
#include <stdio.h>
#include <string.h>
void cipher(void);
int main(void){
	int i,j,k,n,len,a,b;
	char data1[1024],data2[1024];
	scanf("%d ",&n);
	for(i=0;i<n;i++){
		gets(data1);
		for(j=0;j<1024;j++){
			data2[j]='\0';
		}
		len=strlen(data1);
		for(a=0;a<26;a++){
			for(b=0;b<26;b++){
				if(strstr(data2,"this")!=NULL) goto end;
				if(strstr(data2,"that")!=NULL) goto end;
				for(k=0;k<len;k++){
					if(data1[k]>='a' && data1[k]<='z')	data2[k]=(a*(data1[k]-'a')+b)%26+'a';
					if(data1[k]==' ') data2[k]=' ';
					if(data1[k]=='.') data2[k]='.';
				}
			}
		}
	end:
		puts(data2);
	}
	return 0;
}

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

#define ll long long
#define endl "\n";
#define mod 1000000007
#define pii pair<int,int>
#define vii vector<pii>
#define mp make_pair
#define all(a) a.begin(), a.end()
#define mk(arr,n,type) type *arr=new type[n];

void fastio() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main() {
    fastio();
    string s1,s2;
    cin >> s1 >> s2;

    int n = s1.length();
    int ans = 0;
    for (int i=0; i<n; i++) {
        if (s1[i]!=s2[i]) {
            ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3796
#include <stdio.h>

int main()
{
    int m, f, r;
    do
    {
        scanf("%d %d %d", &m, &f, &r);
        if (m != -1 || f != -1 || r != -1)
        {

            if (m == -1 || f == -1)
            {
                printf("F\n");
            }
            else if (m + f >= 80)
            {
                printf("A\n");
            }
            else if (m + f >= 65)
            {
                printf("B\n");
            }
            else if (m + f >= 50)
            {
                printf("C\n");
            }

            else if (m + f >= 30 )
            {
                if (r >= 50)
                {
                    printf("C\n");
                }
                else
                {
                    printf("D\n");
                }
            }
            else
            {
                printf("F\n");
            }
        }
     } while (m != -1 || f != -1 || r != -1);

        return 0;
    }
    


Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  int64_t co = 0;
  int64_t ans = 0;
  rep(i, N) {
    cin >> vec.at(i);
  }
  while(true) {
    rep(i, N) {
      if(vec.at(i) % 2 == 0) {
        co++;
        vec.at(i) = vec.at(i) / 2;
      }
    }
    if(co < N) {
      break;
    }
    ans++;
    co = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(){
  int i;
  int b,c,g,h,s;
  int d[6]={6,7,5,5,20,15};
  int m[7][7];
  m[0][1]=300;
  m[0][2]=500;
  m[0][3]=600;
  m[0][4]=700;
  m[0][5]=1350;
  m[0][6]=1650;
  m[1][2]=350;
  m[1][3]=450;
  m[1][4]=600;
  m[1][5]=1150;
  m[1][6]=1500;
  m[2][3]=250;
  m[2][4]=400;
  m[2][5]=1000;
  m[2][6]=1350;
  m[3][4]=250;
  m[3][5]=850;
  m[3][6]=1300;
  m[4][5]=600;
  m[4][6]=1150;
  m[5][6]=500;
  for(;;){
    scanf("%d",&c);
    if(c==0)
      break;
    scanf("%d%d",&h,&g);
    scanf("%d",&b);
    s=0;
    for(i=(c<b?c:b)-1;i<(c>b?c:b)-1;i++)
      s+=d[i];
    if(s<=40){
      if(1050<=h*60+g&&h*60+g<=1170){
	scanf("%d%d",&h,&g);
	printf("%d\n",m[(c<b?c:b)-1][(c>b?c:b)-1]/2+m[(c<b?c:b)-1][(c>b?c:b)-1]/2%50);
      }else{
	scanf("%d%d",&h,&g);
	if(1050<=h*60+g&&h*60+g<=1170)
	  printf("%d\n",m[(c<b?c:b)-1][(c>b?c:b)-1]/2+m[(c<b?c:b)-1][(c>b?c:b)-1]/2%50);
	else
	  printf("%d\n",m[(c<b?c:b)-1][(c>b?c:b)-1]);
      }
    }else{
      scanf("%d%d",&h,&g);
      printf("%d\n",m[(c<b?c:b)-1][(c>b?c:b)-1]);
    }
  }
  return 0;
}
    
	  

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>





using namespace std;
int main() {


	int a, b, c;
	cin >> a >> b >> c;
	cout << c / a*b << endl;
		
	

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    void run(){
	while(sc.hasNext()){
	    int w = sc.nextInt();
	    int n = sc.nextInt();
	    int[][] lot = new int[n+1][w+1];
	    int i=1;
	    while(i<=n){
		String s = sc.next();
		int j=0;
		while(!s.substring(j, j+1).equals(",")) j++;
		int a = Integer.parseInt(s.substring(0, j));
		int b = Integer.parseInt(s.substring(j+1, s.length()));

		lot[i][a] = b;
		lot[i][b] = a;
		
		//System.out.println(i+" "+lot[i][a]+" "+lot[i][b]);
		i++;
	    }

	    i=1;
	    int[] ans = new int[w];
	    while(i<=w){
		ans[check(lot, i, n)-1] = i;
		i++;
	    }
	    for(i=0; i<w; i++)
		System.out.println(ans[i]);
	}
    }

    int check(int[][] lot, int i, int n){
	int k = 1;
	while(k<=n){
	    //System.out.println("*"+i+" "+lot[k][i]);
	    if(lot[k][i]!=0)
		i = lot[k][i];
	    k++;
	}
	//System.out.println();
	return i;
    }
}

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

int main() {
  int n;
  int count=0;
  int ans=0;
  cin>>n;
  vector<int> a(n);
  vector<bool> b(n,0);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    if(a.at(i)==i+1)b.at(i)=1;
  }
  for(int i=0;i<n;i++){
    if(b.at(i)==1)count++;
    else{
      ans+=(1+count)/2;
      count=0;
    }
  }
  ans+=(1+count)/2;
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <stdio.h>
int main (void){
	char a[10000],b[100];
	int i,j,k,n,m;
	k=0;
	while(1){
		n=m=0;
		k++;
		scanf("%s",a);
		if(strcmp(a,"EOF")==0)break;
		for(i=0;a[i]!='\0';i++){
			for(j=0;j<3;j++)b[j]=a[i+j];
			if(strcmp(b,"JOI")==0)n++;
			else if(strcmp(b,"IOI")==0)m++;
		}
		printf("%d\n%d\n",n,m);
		if(k==5)break;
	}
	return 0;
}



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

using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned int;
using vi  = vector<int>; using vb  = vector<bool>; using vd  = vector<double>; using vl  = vector<ll>;
using vvi = vector<vi>;  using vvb = vector<vb>;   using vvd = vector<vd>;     using vvl = vector<vl>;

#define REP(i,n) for(ll i=0; i<(n); ++i)
#define FOR(i,b,n) for(ll i=(b); i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define TEN(x) ((ll)1e##x)

template<typename T> inline string join(const vector<T>& vec, string sep = " ") { stringstream ss; REP(i, vec.size()) ss << vec[i] << ( i+1 == vec.size() ? "" : sep ); return ss.str(); }


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

#define EPS (1e-10)
#define NEXT(x, i) (x[(i + 1) % x.size()])

template<class T> using CR = const T &;
using P = complex<ld>;
using G = vector<P>;

int sgn(ld a, ld b = 0) {
	if (a > b + EPS) return 1;
	if (a < b - EPS) return -1;
	return 0;
}

ld dot(P a, P b) { return real(conj(a)*b); }
ld cross(P a, P b) { return imag(conj(a)*b); }

int contain(CR<G> g, P p) {
	bool in = false;
	REP(i, g.size()) {
		P a = g[i] - p, b = g[(i + 1) % g.size()] - p;
		if (imag(a) > imag(b)) swap(a, b);
		if (imag(a) <= 0 && 0 < imag(b)) if (cross(a, b) < 0) in = !in;
		if (cross(a, b) == 0 && dot(a, b) <= 0) return -1;
	}
	return in ? 1 : 0;
}

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

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	ll n; cin >> n;

	G g(n);
	REP(i,n){
		ld x, y;
		cin >> x >> y;
		g[i] = { x, y };
	}

	ll q; cin >> q;
	REP(i, q) {
		ld x, y;
		cin >> x >> y;
		int a = contain(g, { x, y });
		cout << (a==1 ? 2 : a==-1?1:0) << endl;
	}

	return 0;
}

Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 1;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans %= mod;
        ans *= power(i + 1, mod - 2);
        ans %= mod;
    }
    return ans;
}

bool c(string s){
    bool f = true;
    rep0(i, s.size() / 2)if(s[i] != s[s.size() - i - 1])f = false;
    return f;
}

int main(){
    string s;
    cin >> s;
    if(c(s) && c(s.substr(0,(s.size() - 1)/2)) && c(s.substr((s.size() + 3) / 2 - 1,(s.size() - 1) / 2)))pf("Yes");
    else pf("No");
    return 0;
}


Measured memory_bytes: 256
typedef struct{double x,y,k;}w;w p[101],b;m,v[100],n,j;z(w*c,w*d){return c->k>d->k?-1:c->k<d->k;}double o(q,r,s){return p[q].x*(p[r].y-p[s].y)+p[r].x*(p[s].y-p[q].y)+p[s].x*(p[q].y-p[r].y);}main(i){double k,t;for(;~scanf("%d",&n),j=n;){for(m=i=0;i<n;i++)scanf("%lf,%lf",&p[i].x,&p[i].y),p[m].y>p[i].y?m=i:0;b=p[m];p[m]=*p;*p=b;p[100].x=b.x;p[100].y=b.y+1;for(i=1;i<n;i++){k=o(0,i,100);t=(p[i].x-b.x)*(p[i].x-b.x)+(p[i].y-b.y)*(p[i].y-b.y);k*=k/t;if(b.x>p[i].x)k=-k;p[i].k=k;}qsort(p+1,n-1,sizeof(w),z);v[0]=0;v[1]=1;v[2]=j=2;for(i=3;i<n;i++){for(;o(v[j-1],v[j],i)<=0;j--);v[++j]=i;}printf("%d\n",n+~j);}exit(0);}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

template<typename Monoid>
class SegmentTree{
    public:
        SegmentTree(int N, const function<Monoid(Monoid, Monoid)> f, const Monoid& M1) : f(f), M1(M1) {
            sz = 1;
            while(sz < N) sz <<= 1;
            seg.assign(2 * sz, M1);
        }

        void set(int k, const Monoid& x){
            seg[k + sz] = x;
        }

        void build(){
            for(int k = sz - 1; k > 0; k--){
                seg[k] = f(seg[2 * k], seg[2 * k + 1]);
            }
        }

        void update(int k, const Monoid& x){
            k += sz;
            seg[k] = x;
            while(k >>= 1){
                seg[k] = f(seg[2 * k], seg[2 * k + 1]);
            }
        }

        // [a, b)
        Monoid query(int a, int b){
            Monoid L = M1, R = M1;
            for(a += sz, b += sz; a < b; a >>= 1, b >>= 1){
                if(a & 1) L = f(L, seg[a++]);
                if(b & 1) R = f(seg[--b], R);
            }
            return f(L, R);
        }

        Monoid operator[](const int& k) const{
            return seg[k + sz];
        }

    private:
        vector<Monoid> seg;
        const function<Monoid(Monoid, Monoid)> f;
        const Monoid M1;
        int sz = 1;
};

ll H, W, M;
vector<ll> bomb[300010];
ll cnt[300010];

signed main(){
    cin >> H >> W >> M;
    ll x, y;
    REP(i, M){
        cin >> x >> y;
        x--; y--;
        bomb[x].push_back(y);
        cnt[y]++;
    }
    SegmentTree<ll> seg(W, [](ll x, ll y) -> ll{return max(x, y);}, LONG_LONG_MIN);
    REP(j, W) seg.set(j, cnt[j]);
    seg.build();
    ll ans = 0;
    REP(i, H){
        for(auto j : bomb[i]){
            seg.update(j, cnt[j] - 1);
        }
        ans = max(ans, (ll)bomb[i].size() + seg.query(0, W));
        for(auto j : bomb[i]){
            seg.update(j, cnt[j]);
        }
    }
    PRINT(ans);
    /*
    REP(i, H){
        for(auto x : bomb[i]) cerr << x << " ";
        cerr << endl;
    }
    REP(j, W) cerr << cnt[j] << " ";
    cerr << endl;
    */
    return 0;
}

Measured memory_bytes: 30160
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>

using namespace std;

int main()
{
	int n;
	vector<pair<int,int>> out[1001][1001];
	int in[1001][1001] = { 0, };
	int i, j;
	int u, v, temp;
	int pu, pv;
	queue<pair<int, int>> q, buf;
	int cnt = 0, sol = 0;
	pair<int, int> cur;

	scanf("%d", &n);

	for (i = 1; i <= n; i++)
	{
		u = i;

		scanf("%d", &v);

		if (u > v)
		{
			temp = u;
			u = v;
			v = temp;
		}

		pu = u;
		pv = v;

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

			scanf("%d", &v);

			if (u > v)
			{
				temp = u;
				u = v;
				v = temp;
			}

			out[pu][pv].push_back(make_pair(u, v));
			in[u][v]++;

			pu = u;
			pv = v;
		}
	}

	for (i = 1; i < n; i++)
	{
		for (j = i + 1; j <= n; j++)
		{
			if (!in[i][j])
			{
				q.push(make_pair(i, j));
			}
		}
	}

	for (i = 0; i < n*n; i++)
	{
		if (cnt + q.size() == n*(n - 1) / 2 || q.empty())
		{
			break;
		}

		while (!q.empty())
		{
			cur = q.front();
			q.pop();

			cnt++;

			u = cur.first;
			v = cur.second;

			for (j = 0; j < out[u][v].size(); j++)
			{
				if (!(--in[out[u][v][j].first][out[u][v][j].second]))
				{
					buf.push(out[u][v][j]);
				}
			}
		}

		i = i;

		while (!buf.empty())
		{
			q.push(buf.front());
			buf.pop();
		}
	}

	if (cnt + q.size() != n*(n - 1) / 2)
	{
		printf("-1\n");
	}

	else
	{
		printf("%d\n", i + 1);
	}

	return 0;
}

Measured memory_bytes: 43264
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		rep(i,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};

template<class T=ll>struct Dijkstra:Graph<T>{
	using Graph<T>::Graph;
	Dijkstra(int N=1):Graph<T>::Graph(N){}
	const T mval=numeric_limits<T>::max()/2;
	vector<T>dist(ll s){
		vector<T> ret(this->n,mval);
		priority_queue<tuple<T,ll>> q;
		q.emplace(T(),s);
		while(!q.empty()){
			T c; ll p; tie(c,p)=q.top(); q.pop();
			if(ret[p]!=mval)continue;
			ret[p]=c=-c;
			for(auto&e:this->edge[p]){
				ll nxt;T cost;
				tie(nxt,cost)=e;
				if(ret[nxt]<=ret[p]+cost)continue;
				q.emplace(-ret[p]-cost,nxt);
			}
		}
		return ret;
	}
	T dist(ll s,ll t){return dist(s)[t];}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	Dijkstra<ll> g(n*3);
	int u,v,s,t;
	rep(i,m){
		cin>>u>>v;u--;v--;
		rep(j,3)g.add(u+n*(j),v+n*((j+1)%3),1,true);
	}
	cin>>s>>t;
	ll ans=g.dist(s-1,t-1);
	cout<<(ans%3==0&&ans!=4611686018427387903?ans/3:-1)<<endl;

}


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

int main() {
  int n, a, x = 1000001, y = -1000001;
  long long b = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    b = b + a;
    if (a > y) y = a;
    if (a < x) x = a;
  }
  cout << x << " " << y << " " << b << endl;
}



Measured memory_bytes: 3020
yyyy, mm, dd = map(int, input().split('/'))
if yyyy <= 2018:
  print('Heisei')
  quit()
elif yyyy == 2019:
  if mm <= 4:
    print('Heisei')
    quit()
  else:
    print('TBD')
    quit()
else:
  print('TBD')
  quit()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using P =pair<ll,ll>;
const ll maxV = (1ll << 18)+5;
const ll maxL = ll(1e5)+5;
const ll half = 1ll << 9;
ll N;
ll V[maxV],W[maxV];
ll mdp[half+5][maxL];

void dfs(ll t){
    // cerr <<"t=" <<t << endl;
    if(t>=(half)){
          return;
    }
  
    
    for(int i=0;i<maxL;i++){
        if(W[t-1] <=i){
            mdp[t][i] = max(mdp[t/2][i],mdp[t/2][i-W[t-1]] + V[t-1]);
        }else{
            mdp[t][i] = mdp[t/2][i];
        }
    }
    
    dfs(t*2);
    dfs(t*2+1);
}

ll revDfs(ll t,ll w){
    // cerr <<"t=" <<t << endl;
    if(t<(half)){
        // cerr <<"mdp=" << mdp[P(t,w)] << endl;
        return mdp[t][w];
    }
    if(W[t-1]<=w){
        return max(revDfs(t/2,w),revDfs(t/2,w-W[t-1]) + V[t-1]);
    }else{
        return revDfs(t/2,w);
    }
}

int main() {
   
    cin >> N;
    for(int i=0;i<N;i++){
        scanf("%lld",&V[i]);
        scanf("%lld",&W[i]);
    }
    dfs(1);
    ll Q;
    cin >> Q;
    // cerr <<"Q=" << Q << endl;
    for(int q=0;q<Q;q++){
        ll v,L;
        scanf("%lld",&v);
        scanf("%lld",&L);
        cout << revDfs(v,L) << "\n";

    }

    return 0;
}

Measured memory_bytes: 407012
#include<iostream>
#include<algorithm>
using namespace std;
string s;
int a[1<<17],c,f;
main()
{
	cin>>s;
	s+=s[s.size()-1]^1;c++;
	for(int i=1;i<s.size();i++)
	{
		if(s[i]!=s[i-1])
		{
			a[f++]=c,c=1;
		}
		else c++;
	}
	int ans=1e9,t=0;
	for(int i=0;i<f;i++)
	{
		t+=a[i];
		ans=min(ans,max(t,(int)s.size()-t-1));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int ac = 0;
		int[] wa = new int[N];

		boolean[] result = new boolean[N];
		for (int i = 0; i < N; i++) {
			result[i] = false;
		}
		if (M == 0) {

		} else {
			for (int i = 0; i < M; i++) {
				int p = sc.nextInt();
				String S = sc.next();

				if (S.equals("AC")) {
					if (result[p - 1] == false) {
						result[p - 1] = true;
						ac++;
					}
				} else {
					if (result[p - 1] == false) {
						wa[p-1]++;
					}
				}
			}
		}
		int WA = 0;
		for(int i=0;i<N;i++) {
			if(result[i]==true) {
				WA += wa[i];
			}
		}
		System.out.println(ac + " " + WA);

	}
}


Measured memory_bytes: 64456
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <string>

using namespace std;
typedef pair<int, int> P;

#define pi 3.141592653589793)
#define mod 1000000007

int N, D, X, A[101];
int ans;

void solve() {
    for(int i = 0; i < N; i++) {
        ans += (D-1) / A[i] + 1;
    }
    ans += X;
    cout << ans << endl;
}

int main() {
    cin >> N >> D >> X;
    for(int i = 0; i < N; i++) cin >> A[i];
    solve();
    return 0;
}

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

int main() {

    int a, b;
    scanf("%d %d", &a, &b);

    if (a >= b) {

        for (int i = 0; i < a; i++) {
            printf("%d", b);
        }

    } else {
        for (int i = 0; i < b; i++) {
            printf("%d", a);
        }
    }

    return 0;

}

Measured memory_bytes: 128
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	l = readline() |> split |> parseMap
	k = sum(l)
	flg = 0
	for i in 1:n
		if l[i] >= k-l[i]
			flg = 1
			break
		end
	end
	println(flg == 0?"Yes":"No")
end
 
main()

Measured memory_bytes: 111512
#include <bits/stdc++.h>
using namespace std;
int dp[100005];
int a[3000], n, k, mn;
bool calc(int m)
{

    if(dp[m] != -1)
        return dp[m];

    dp[m] = 0;
    //if(m < mn) return 0;
    for (int i = 0; i < n; ++i) {
        if(a[i] <= m && !calc(m - a[i])) {
            dp[m] = 1;
            //break;
        }
    }

    return dp[m];

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

    memset(dp, -1, sizeof(dp));

    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        mn = min(mn, a[i]);
    }

    cout << (calc(k)?"First":"Second") << endl;
    return 0;
}

Measured memory_bytes: 5376