akhauriyash/Code-Regression huggingface dataset:
n  = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
    tmp = input()
    if tmp == 'AC':
        ac +=1
    elif tmp == 'WA':
        wa  +=1
    elif tmp == 'TLE':
        tle +=1
    else:
        re +=1
print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))

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


int main(){
    string s;
    cin >> s;
    int bits=0;
    for(bits; bits<(1<<3); bits++){
        int total=s[0]-'0';
        for(int i=0; i<3; i++){
            if((bits>>i) & 1){
                total+=s[i+1]-'0';
            }
            else total-=s[i+1]-'0';
        }
        if(total == 7) break;
    }
    for(int i=0; i<3; i++){
        char op;
        if((bits>>i) & 1) op='+';
        else op='-';
        cout << s[i] << op;
    }
    cout << s[3] << "=7" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define ARRAY_MAX 105

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


int main() {

	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;


	vector<int> vec;

	if (s[0] == '0')
	{
		//番兵
		vec.push_back(0);
	}
	vec.push_back(0);
	vec.push_back(0);
	int cnt = 1;

	for (int i = 1; i < n; i++)
	{
		if (s[i] == s[i - 1])
		{
			cnt++;
		}
		else
		{
			vec.push_back(cnt);
			cnt = 1;
		}
	}
	vec.push_back(cnt);
	vec.push_back(0);

	int vec_siz = vec.size();

	for (int i = 0; i < vec_siz; i++) {
		if (i + 2 < vec_siz)
		{
			vec[i + 2] += vec[i];
		}
	}

	int maxi = 0;
	for (int i = 0; i < vec_siz - 1; i += 2)
	{
		//cout << i << endl;
		if (i + 2 * (k + 1) < vec_siz)
		{

			maxi = max(maxi, vec[i + 2 * (k + 1)] - vec[i] + vec[i + 2 * (k + 1) - 1] - vec[i + 1]);
		}
		else
		{
			maxi = max(maxi, vec[vec_siz - 1] - vec[i] + vec[vec_siz - 2] - vec[i + 1]);
		}
		//cout << "maxi = " << maxi << endl;
	}

	cout << maxi << endl;

}



Measured memory_bytes: 1020
//
// Created by 佐竹俊哉 on 2019/11/11.
//

#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

int main() {
    ll N; cin >> N;
    ll ans = TEN(18);
    for (ll i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            chmin(ans, i + N / i - 2);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
using P = pair<int, int>;
const long long INF = 1LL << 60;

int main(){
  string S; cin >> S;
  rep(i,S.length()) cout << "x";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N,K,Q=map(int,input().split())
A=[int(input()) for i in range(Q)]
ANS=[K-Q]*N

for a in A:
    ANS[a-1]+=1

for ans in ANS:
    if ans>0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 10424
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    vector<int> b(m);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,m){
        cin >> b[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    rep(i,n-1){
        if(a[i]==a[i+1]){
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i,m-1){
        if(b[i]==b[i+1]){
            cout << 0 << endl;
            return 0;
        }
    }
    ll mod = 1e9+7;
    ll ans = 1;
    for(int i = n*m;i>0;i--){
        bool x = *lower_bound(a.begin(),a.end(),i)==i;
        bool y = *lower_bound(b.begin(),b.end(),i)==i;
        if(x && y){
            ans*=1;
        }
        else if(y){
            ans *= a.end() - lower_bound(a.begin(),a.end(),i);
            ans %=mod;
        }
        else if(x){
            ans *= b.end() - lower_bound(b.begin(),b.end(),i);
            ans %=mod;
        }
        else{
            ll tmp= a.end() - lower_bound(a.begin(),a.end(),i);
            tmp *= b.end() - lower_bound(b.begin(),b.end(),i);
            tmp -= n*m-i;
            ans*=tmp;
            ans %=mod;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
def resolve():
    n = int(input())

    from heapq import heappop, heappush
    q = []
    for i in range(n):
        a, b = map(int, input().split())
        heappush(q, (b, a))

    curr = 0
    while len(q) > 0:
        b, a = heappop(q)
        curr += a
        if curr > b:
            print("No")
            return
    print("Yes")
    
resolve()

Measured memory_bytes: 74200
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';
using namespace std;

struct Per{
    vector<int> fr, bl;
    bool finished;
    bool finished2;
    int block;
    int frnu;
};

Per per[100003];
int N, M, K;
queue<int> visited;

void retrack(int a){
    per[a].block=0;
    per[a].finished2=true;
    rep(i, per[a].fr.size()){
        if(per[per[a].fr[i]].finished2==false) retrack(per[a].fr[i]);
    }
}

void track(int a){
    visited.push(a);
    per[a].finished=true;
    //cout<<endl;
    //cout<<a<<sp<<per[a].block<<sp;
    rep(i, per[a].bl.size()){
        per[per[a].bl[i]].block++;
        //cout<<"&"<<sp<<per[per[a].bl[i]].block<<"&"<<sp;
    }
    //cout<<per[a].block<<endl<<endl;
    rep(i, per[a].fr.size()){
        if(per[per[a].fr[i]].finished==false) track(per[a].fr[i]);
    }
}



int main(void){
    cin>>N>>M>>K;
    int a, b, c, d;
    rep(i, N) per[i].finished=false,per[i].finished2=false, per[i].block=0, per[i].frnu=0;
    rep(i, M){
        cin>>a>>b;
        per[a-1].fr.push_back(b-1);
        per[b-1].fr.push_back(a-1);
    }
    rep(i, K){
        cin>>c>>d;
        per[d-1].bl.push_back(c-1);
        per[c-1].bl.push_back(d-1);
    }
    rep(i, N){
        if(per[i].finished==true) continue;
        retrack(i);
        track(i);
        int si=visited.size();
        rep(j, si){
            int th;
            th=visited.front();
            visited.pop();
            per[th].frnu=si-per[th].block-per[th].fr.size()-1;
            //cout<<si<<sp<<per[th].block<<sp<<per[th].fr.size()<<endl;
        }
        
    }
    rep(i, N-1){
        cout<<per[i].frnu<<sp;
    }
    cout<<per[N-1].frnu<<endl;
    return 0;
}


Measured memory_bytes: 14080
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(B, A * N) << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline()

A, B, C, X = [int(input()) for i in range(4)]

cnt = 0
for a in range(A+1):
	for b in range(B+1):
		for c in range(C+1):
			if 500*a + 100*b + 50*c == X:
				cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE false
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 6/18/2018
 
 15:00-
 
 */

// $ g++ -std=c++11 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_M=1e5+1,MAX_N=1e5+1;
int N,M;
LL X[MAX_M],Y[MAX_M];

int cnt[MAX_N],F[MAX_N];
void solve() {
  REP(i,N) cnt[i]=1;
  F[0]=1;
  REP(i,M) {
    int x=X[i],y=Y[i];
    assert(cnt[x]>0);
    --cnt[x],++cnt[y];
    if(F[x]) F[y]=1;
    if(cnt[x]==0) F[x]=0;
    dump2(x,y);
    dump4(cnt[x],F[x],cnt[y],F[y]);
  }
  int res=0;
  REP(i,N)res+=F[i];
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N>>M;
  REP(i,M) cin>>X[i]>>Y[i],--X[i],--Y[i];
  solve();
  return 0;
}


Measured memory_bytes: 2560
import java.util.*;


import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		long n  = nl();
		long result = (n - 1) * n / 2;
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		} 
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

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

typedef long long ll;

int N;
int A[52], B[52];
ll mask;

int cc[52][52][52];
int dp(int a, int b, int p) {
    int &ret = cc[a][b][p];
    if(ret != -1) return ret;
    if(a == b) return ret = 1;
    if(a <= 2 * b) return ret = 0;
    if(p == 0) return ret = 0;

    ret = 0;
    ret |= dp(a, b, p - 1);
    if(mask & (1LL << p)) {
        ret |= dp(a % p, b, p - 1);
    }
    return ret;
}

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    for(int i = 0; i < N; i++) {
        scanf("%d", &B[i]);
    }

    for(int i = 0; i < N; i++) {
        if(A[i] == B[i]) continue;
        if(A[i] <= 2 * B[i]) {
            printf("-1");
            return 0;
        }
    }

    for(int i = 50; i >= 1; i--) {
        mask ^= (1LL << i) - 1;

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

        bool ok = true;
        for(int j = 0; j < N; j++) {
            if(!dp(A[j], B[j], 50)) {
                ok = false;
                break;
            }
        }
        mask ^= (1LL << i) - 1;
        if(ok) continue;
        else mask |= (1LL << i);
    }

    printf("%lld", mask);
}


Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(x>=r&&y>=r&&x<=W-r&&y<=H-r){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793


   
int main(){
   int n;
   cin >> n;
   VI a(n+2);
   a[0]=0;
   a[n+1]=0;
   for(int i=1;i<=n;i++){
      cin >> a.at(i);
   }
   ll ro=0;
   rep(i,n+2){
      ro+=abs(a[i]-a[i+1]);
   }
   for(int i=1;i<=n;i++){
      if((a[i]-a[i-1])*(a[i+1]-a[i])>=0){
         cout << ro << endl;
      }
      else{
         int z=min(abs(a[i]-a[i-1]),abs(a[i+1]-a[i]));
         cout << ro-2*z << endl;
      }
   }
}
    

Measured memory_bytes: 3760
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{ 
 int n,i,j,ans;
  
 cin>>n;
  if(n<10){cout<<n;return 0;}
  j=0;i=1;
 while(n/i>=1)
 {
   j++;
   i*=10;
 }
 
  ans=0;
  
  if(j%2!=0){ans=n-i/10+1; j=j-2;i=i/100;}
  else{j=j-1;i=i/10;}
  
  while(j!=0)
  { 
   
    if(j%2==1){ans=ans+i-1;}
    else{ans=ans-i+1;}
    i=i/10;
    j--;
  }
  cout<<ans;
}

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

typedef long long int lli;
typedef long double lld;
typedef long long ll;
//Datatype
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vvlli vector<vector<long long int>>
#define ppi pair<int, int>
#define rppi pair<int, pair<int, int>>
#define lppi pair<pair<int, int>, int>
#define vppi vector<pair<int, int>>
#define sppi stack<pair<int int>>
#define qppi queue<pair<int, int>>
//function
#define f first
#define s second
#define pb(x) push_back(x)
#define mkp(i, j) make_pair(i, j)
#define lmkp(i,j,k) make_pair(make_pair(i,j),k)
#define rmkp(i,j,k) make_pair(i,make_pair(j,k))
//loop
#define loop(i,n) for (i = 0; i < n; ++i)
#define loops(i,k,n) for (i = k; i <= n; ++i)
#define looprev(i,k,n) for (i = k; i >= n; --i)
//Const
#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
//Print
#define prd(n) printf("%d", n)
#define prl(n) printf("%lld", n)
#define prdn(n) printf("%d\n", n)
#define prln(n) printf("%lld\n", n)
#define prf(n) printf("%f", n)
//Scan
#define scd(n) scanf("%d", &n)
#define scd2(a, b) scanf("%d %d", &a, &b)
#define scd3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scl(n) scanf("%lld", &n)
#define scl2(a, b) scanf("%lld %lld", &a, &b)
#define scl3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define scf(n) scanf("%f", &n)

using namespace std;

lli dp[3001][3001];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli i, j, k;
    loop(i, 3001){
        loop(j, 3001){
            dp[i][j] = 0;
        }
    }
    string s, t, res = "";
    cin>>s>>t;
    lli M = s.size(), N = t.size();
    loop(i, M+1){
        loop(j, N+1){
            if(i == 0 || j == 0){
                dp[i][j] = 0;
            }
            else if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j-1]+1;
            }
            else{
                dp[i][j] = max(dp[i-1][j-1], max(dp[i-1][j], dp[i][j-1]));
            }
        }
    }
    /*loop(i, M+1){
        loop(j, N+1){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    i = M, j = N;
    while(i > 0 && j > 0){
        if(dp[i-1][j-1]+1 == dp[i][j] && dp[i-1][j]+1 == dp[i][j] && dp[i][j-1]+1 == dp[i][j]){
            i--;
            j--;
            res = s[i]+res;
        }
        else if(dp[i][j-1] > dp[i-1][j]){
            j--;
        }
        else{
            i--;
        }
    }
    cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 74048
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;

int main()
{

	long X;
	cin >> X;
	
	for(long a = -200; a <= 200; a++){
		for(long b = -200; b <= 200; b++){
			if(X == a*a*a*a*a - b*b*b*b*b){
				cout << a << " " << b << endl;
				return 0;
				
			}	
		}	
	}
		

}

Measured memory_bytes: 3640
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [N, K] = input[0].map(Number);
  const prices = input[1].map(Number).sort((a, b) => a - b);

  const buy = prices.slice(0, K);

  return buy.reduce((result, cur) => {
    return result + cur;
  }, 0);
};

console.log(main(read()));


Measured memory_bytes: 29720
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    println(ifelse(chomp(readline())==reverse(chomp(readline())),"YES","NO"))
end
main()

Measured memory_bytes: 163848
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  map<int,int>M;
  for(int i=0;i<N;i++){
  int a;
    cin>>a;
      if(M.count(a))
        M.erase(a);
    else
      M[a]=1;
 }int ans=M.size();
  cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4864
from heapq import heapify, heappop

N = int(input())
A = list(map(int, input().split()))

que = [(-a, i + 1) for i, a in enumerate(A)]
heapify(que)

ans = [0] * (N + 1)
cnt = 0
while que:
    a, now = heappop(que)
    cnt += 1
    ans[now] = -a * cnt

    while que and que[0][1] > now:
        a, _ = heappop(que)
        ans[now] += -a
        cnt += 1

    if que:
        ans[now] -= -que[0][0] * cnt

print(*ans[1:], sep='\n')


Measured memory_bytes: 23220
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
    int a[3];

    for(int i=0; i<3;i++)
        cin >> a[i];

    // bubble sort
    for(int i=2; i>0; i--)
        for(int j=0; j<i;j++)
            // if(a[j] > a[i]) swap(a[j], a[i]);
            if(a[j] > a[j+1]) swap(a[j], a[j+1]);

    printf("%d %d %d\n", a[0], a[1], a[2]);

    return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

int a[10005];
int dp[2][10005][2];

int main(){
    cin.tie(0);

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

    int INF = 1000000000;
    fill(**dp, **dp+2*10005*2, INF);
    
    dp[0][1][0] = 0;
    dp[0][0][1] = 0;

    for (int i = 0; i < N; i++){
        for (int j = 0; j <= N; j++){
            if (j-1 >= 0) dp[(i+1)&1][j][0] = min(dp[i&1][j-1][0], dp[i&1][j-1][1] + a[i]);
            dp[(i+1)&1][j][1] = min(dp[i&1][j][0] + a[i], dp[i&1][j][1]);
        }
    }
    cout << min(dp[(N-1)&1][N/2][0], dp[(N-1)&1][N/2][1]) << endl;

    
}



Measured memory_bytes: 3284
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
  double a,b,c,PI=3.1415926535;
  cin >> a >> b >> c;
  printf("%.5f\n",a*b*sin(c*PI/180)/2);
  printf("%.5f\n",sqrt(a*a+b*b-2*a*b*cos(c*PI/180))+a+b);
  printf("%.5f\n",b*sin(c*PI/180));
  return 0;
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

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

int main(){fastio

    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll dp[n][n];rep(i,0,n-1)rep(j,0,n-1)dp[i][j]=inf;
    ll sm[n+1];sm[0]=0;rep(i,1,n)sm[i]=sm[i-1]+a[i-1];
    rep(len,0,n-1){
        rep(i,0,n-1){
            ll j=i+len;
            if(j>=n)continue;
            if(i==j){dp[i][j]=0;continue;}
            rep(k,i,j-1){
                Min(dp[i][j],dp[i][k]+dp[k+1][j]+sm[j+1]-sm[i]);
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
    
    return 0;
}



Measured memory_bytes: 1536
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	ll a;
	double b;
	cin >> a >> b;
	b *= 100;
	string bs = to_string(b);
	string cs = "";
	for(int i = 0;i < (int)bs.size();i++){
		if(bs[i] != '.')cs += bs[i];
		else break;
	}


	int c = stoi(cs);
	cout << (a * c) / 100 << endl;
}


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

int main(){
  string S;
  long long K;
  cin >>S>>K;
  int flag=0;

  for (int i=0;i<S.length();i++){
    if(!(S.at(i)=='1')){
      flag=i;
      break;
    }
  }
  
  if(flag+1<=K){
    cout<<S.at(flag)<<endl;
    return 0;
  }
  cout<<1<<endl;
  return 0;

}

  

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

int main() {
  int times, plus, Dresult, Presult, number = 1;// 順に繰り返し回数、Kの値、Double result, Plus result, 計算結果
  cin >> times >> plus;
    for (int i = 0; i < times; i++){
      Dresult = number * 2;
      Presult = number + plus;
      if (Dresult < Presult){
        number = Dresult;
      }
      else{
        number = Presult;
      }
    }
  cout << number << endl;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

s = STR()
n = len(s)
stack = deque(s[0])
for i in range(1, n):
    if not len(stack) or stack[len(stack)-1] == s[i]:
        stack.append(s[i])
    else:
        stack.pop()
print(n - len(stack))


Measured memory_bytes: 6224
while 1:
	m,f,r=map(int,raw_input().split())
	if (m==-1 and f==-1 and r==-1):
		break
	elif (m+f>=80):
		print "A"
	elif (m+f>=65 and m+f<80):
		print "B"
	elif (m+f>=50 and m+f<65 or r>=50):
		print "C"
	elif (m+f>=30 and m+f<50 and r<50 and m!=-1 and f!=-1):
		print "D"
	elif (m+f<30 or m==-1 or f==-1):
		print "F"

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

  int N = 100000;
  vector<int> prime;
  vector<bool> alive(N, true);
  alive[0] = alive[1] = false;
  rep2(i, 2, N) {
      if (alive[i]) {
          prime.emplace_back(i);
          for (int j = 2 * i; j < N; j += i) {
              alive[j] = false;
          }
      }
  }

  int n;
  while (cin >> n) {
    auto itr = upper_bound(all(prime), n);;
    int b = *itr;
    itr--;
    if (*itr == n) itr--;
    int a = *itr;
    cout << a << " " << b << endl;
  }
}



Measured memory_bytes: 3344
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define REP(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int
main(int argc, char *argv[])
{
  ll a, b, n;
  scanf("%lld %lld %lld", &n, &a, &b);

  if(n > 1){
    if(a > b) printf("0\n");
    else printf("%lld\n", (a + (n - 1) * b) - ((n - 1) * a + b) + 1);
  }
  else{
    if(a != b) printf("0\n");
    else printf("1\n");
  }

  return 0;
}


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

int h,w,c;
int data[8][8];


int done[8][8];
int change(int x,int y,int color,int to){
	if(y >= h || x < 0 || y < 0 || x >= w) return 0;
	
	if(data[y][x] != color) return 0;
	else data[y][x] = to;
	
	if(done[y][x] == true) return 0;
	else done[y][x] = true;
	
	int dx[] = {-1,0,1,0};
	int dy[] = {0,1,0,-1};
	for(int i = 0 ; i < 4 ; i++)
		change(x+dx[i] , y+dy[i] , color , to);
}
int count(int x,int y,int color){
	if(y >= h || x < 0 || y < 0 || x >= w) return 0;
	if(data[y][x] != color) return 0;
	if(done[y][x] == true) return 0;
	else done[y][x] = true;
	int ans = 0;
	int dx[] = {-1,0,1,0};
	int dy[] = {0,1,0,-1};
	for(int i = 0 ; i < 4 ; i++)
		ans += count(x+dx[i] , y+dy[i] , color);
	return ans+1;
}
int ans = 0;
int dfs(int n){
	if(n == 5){
		for(int x = 0 ; x < 8 ; x++)
			for(int y = 0 ; y < 8 ; y++)
				done[x][y] = 0;
		ans = max(ans,count(0,0,c));
		return 0;
	}
	int tmp[8][8];
	
	for(int i = 0 ; i < 6 ; i++){
		for(int x = 0 ; x < 8 ; x++)
			for(int y = 0 ; y < 8 ; y++)
				tmp[x][y] = data[x][y] ,done[x][y] = 0;
		change(0,0,data[0][0],i);
		dfs(n+1);
		
		for(int x = 0 ; x < 8 ; x++)
			for(int y = 0 ; y < 8 ; y++)
				data[x][y] = tmp[x][y], done[x][y] = 0;
		
	}
	
}
int main(){
	while(cin >> h >> w >> c , h){
		c--;
		for(int i = 0 ; i < h ; i++)
			for(int j = 0; j < w ; j++)
				cin >> data[i][j] , data[i][j]--;
		ans = 0;
		dfs(0);
		cout << ans << endl;
	}
}

Measured memory_bytes: 872
/********************/
                    /*user -> tushar284*/
                    /******************/
#include<bits/stdc++.h>
                                                    /*********/            
using namespace std;                             /*   __   __   */
#define  f              first                    /*   @ ) ( @   */
#define  s              second                   /*     / \     */            
#define  mp             make_pair                /*  __  -  __  */
#define  loop(i,s,e)    for(int i=s;i<e;i++)     /*    ..^..    */
#define  rev(i,s,e)     for(int i=s;i>=e;i--)     /*     |     */
#define  mod            1000000007                  /*   |   */
#define  pb             push_back                      /***/
#define  start	        int main()                     
#define  fast           ios_base::sync_with_stdio(false);cin.tie(0);
#define  test            int t; cin>>t;while(t--)
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;


start
{   
    ll a,b,n,x;
    cin>>a>>b>>n;
    x = min(b-1,n);
    ll ans =  (((a*x)/b )- (a*(x/b)) );
    cout<<ans;
	return 0;
}

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadLineInt();
            var x = ReadLineIntSpilit();
            var total = int.MaxValue;

            for (int i = 0; i <= 100; i++) {

                var add = 0;

                for (int q = 0; q < n; q++) {

                    add += (int)Math.Pow(x[q]-i, 2);
                }

                if (total > add) total = add;

            }

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

        //メモ

        //降順
        //var sort = array.OrderBy(x => -x).ToArray();

        //最大公約数
        static int gcd(int a, int b)
        {
            if (a > b) {
                return gcd(b, a);
            }

            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }

            return a;
        }

        //最小公倍数
        static int lcm(int a, int b) => a * b / gcd(a, b);

        /// <summary>
        /// コンビネーション
        /// </summary>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        public static string ReadLine() => Console.ReadLine();
        public static int ReadLineInt() => int.Parse(Console.ReadLine());
        public static long ReadLineLongInt() => long.Parse(Console.ReadLine());
        public static string[] ReadLineStringSplit(char a = ' ') => ReadLine().Split(a).ToArray();
        public static int[] ReadLineIntSpilit(char a = ' ') => ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        public static long[] ReadLineLongSpilit(char a = ' ') => ReadLine().Split(a).Select(x => long.Parse(x)).ToArray();
        static string[] GetAplhaLowerArray() => new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
        static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    }
}


Measured memory_bytes: 11220
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef pair<int, int> pii;
typedef double lf;
typedef long long ll;
const int inf=0x3f3f3f3f, mod=1000000007;
int pos[100100];

inline int read()
{
    int x=0,f=1; char ch=getchar();
    for (; ch<'0' || ch>'9'; ch=getchar()) if (ch=='-') f=-1;
    for (; ch>='0' && ch<='9'; ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}

int main()
{
    int n=read(), l=read(), t=read(), start=0;
    for (int i=1; i<=n; i++)
    {
        pos[i]=read(); int w=read();
        if (w==1) pos[i]+=t; else pos[i]-=t;
        start+=pos[i]/l;
        if (pos[i]%l<0) start--;
        pos[i]=(pos[i]%l+l)%l;
    }
    sort(pos+1, pos+n+1); start=(start%n+n)%n;
    for (int i=start+1; i<=n; i++) printf("%d\n",pos[i]);
    for (int i=1; i<=start; i++) printf("%d\n",pos[i]);
    return 0;
}


Measured memory_bytes: 1536
import java.util.*;
class Graph2{
	private int totalVertex;
	boolean[] explore;
	int[] firstDisc;
	int[] endTime;
	int count = 0;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph2() { totalVertex = 0; }
	
	public LinkedList<LinkedList<Integer>> loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		explore = new boolean[totalVertex+1];
		firstDisc = new int[totalVertex+1];
		endTime = new int[totalVertex+1];
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt();
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt();
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
		return adjList;
	}

	public void recurse(LinkedList<LinkedList<Integer>> G, int v) {
		if(!explore[v]) {
			explore[v] = true;
			count++;
			firstDisc[v] = count;
			for(int e : G.get(v-1)) {
				recurse(G, e);
			}
			count++;
			endTime[v] = count;
		}
		
	}

	void print() {
		for(int i = 1; i <= totalVertex; i++) {
			System.out.println(i +" "+ firstDisc[i] + " " + endTime[i]) ;
		}
	}
}
//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph2 g = new Graph2();
		LinkedList<LinkedList<Integer>> matrix = g.loadAdjList();
		for(int i = 1; i <= matrix.size(); i++) {
			g.recurse(matrix, i);
		}
		g.print();
	}
}


Measured memory_bytes: 28008
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;
int main(){
  string s,t;
  cin>>s>>t;
  int sum =0;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      sum ++;
    }
  }
  cout<<sum;
  

}


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

int N, T;
int M[101];

double solve() {
  double dp[101][101]; // [T][N]
  double inv6 = 1.0/6.0;
  fill(dp[0], dp[101], 0);
  dp[0][0] = 1.0;

  for(int i = 0; i < T; ++i) {
    for(int j = 0; j <= N; ++j) {
      if(j == N) {
	dp[i+1][N] += dp[i][N];
	continue;
      }
      if(dp[i][j] != 0) {
	for(int k = 1; k <= 6; ++k) {
	  int nn = j+k;
	  if(nn > N) {
	    nn = N-(nn-N);
	  }

	  if(M[nn] == 1) {
	    if(i+2 <= T) dp[i+2][nn] += dp[i][j]*inv6;
	  } else if(M[nn] == 2) {
	    dp[i+1][0] += dp[i][j]*inv6;
	  } else {
	    dp[i+1][nn] += dp[i][j]*inv6;
	  }
	}
      }
    }
  }

  return dp[T][N];
}

main() {
  int L, B;
  while(( cin >> N >> T >> L >> B ) && ( N || T || L || B ) ) {
    fill(M, M+N, 0);
    for(int i = 0; i < L; ++i) {
      int p;
      cin >> p;
      M[p] = 1;
    }

    for(int i = 0; i < B; ++i) {
      int p;
      cin >> p;
      M[p] = 2;
    }

    printf("%.6f\n", solve());
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    // ios::sync_with_stdio(false);
    // cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int d;
    cin >> d;
    vi  c(26);
    int mxc = 0;
    int mxc_c = 0;
    REP(i, 26) {
        cin >> c[i];
        if (chmax(mxc, c[i])) mxc_c = i + 1;
    }
    vvl s(d, vl(26));
    int mx = 0;
    int mx_c = 0;
    REP(i, d) REP(j, 26) {
        cin >> s[i][j];
        if (chmax(mx, (int)s[i][j])) mx_c = j + 1;
    }

    vi last(26);
    ll ans = 0;
    vi a(d);
    REP(i, d) {
        ll ans2 = -LINF;
        ll ans_i = -1;
        REP(x, 26) {
            ll tmp = s[i][x];
            REP(j, 26) {
                if (x != j) tmp -= c[j] * ((i + 1) - last[j]);
            }
            if (chmax(ans2, tmp)) ans_i = x;
        }
        last[ans_i] = i + 1;
        ans += ans2;
        // cout << ans_i + 1 << endl;
        a[i] = ans_i + 1;
    }
    mt19937 mt{ random_device{}() };
    uniform_int_distribution<int> dist_d(1, d);
    uniform_int_distribution<int> dist_c(1, 26);
    REP(_, 200000) {
        vi lst(26);
        ll ans_n = 0;
        int x = dist_d(mt);
        int y = (_ % 15 == 0 ? mx_c : _ % 15 == 8 ? mxc_c : dist_c(mt));
        REP(i, d) {
            int t = a[i];
            if (x - 1 == i) t = y;
            ans_n += s[i][t - 1];
            lst[t - 1] = i + 1;
            REP(j, 26) if (t - 1 != j) ans_n -= c[j] * ((i + 1) - lst[j]);
        }

        if (ans_n > ans) {
            a[x - 1] = y;
            ans = ans_n;
        }
    }
    printlnv(a);
    // cout << ans << endl;
}


Measured memory_bytes: 3720
N, M = map(int, input().split())

L, R = [], []
for _ in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)
diff = min(R) - max(L) + 1
if diff > 0:
    print(diff)
else:
    print(0)

Measured memory_bytes: 10996
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

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

const ll inf = 1LL<<60;

int main()
{
  ll n; cin >> n;
  ll m; cin >> m;
  ll k; cin >> k;
  vector<ll> a(n);
  for (int i=0; i<n; i++){
    cin >> a[i];
  }
  vector<ll> b(m);
  ll ans = 0;
  for (int i=0; i<m; i++){
    cin >> b[i];
  }
  for (int i=1; i<n; i++) {
    a[i] += a[i-1];
    if (a[i] <= k) ans = max(ans, (ll)i+1);
  }
  for (int i=1; i<m; i++) {
    b[i] += b[i-1];
    if (b[i] <= k) ans = max(ans, (ll)i+1);
  }
  ll bi = m-1;
  for (int i=0; i<n; i++) {
    while (bi >= 0 && b[bi] > k-a[i]) bi--;
    if (bi < 0) {
      if (a[i] > k) continue;
      ans = max(ans, (ll)i+1);
      continue;
    }
    if (a[i]+b[bi] > k) continue;
    ans = max(ans, i+bi+2);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6424
import java.util.*;

public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int A = sc.nextInt();
		int count = 0;
		while(H > 0) {
			H -= A;
			count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 35740
def cmb(n, r, mod,g1,g2):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod



def main():
    mod = 10**9+7 #出力の制限
    N = 10**5+1
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル
    for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )

    import sys
    N,K=list(map(int,sys.stdin.readline().split()))
    A=list(map(int,sys.stdin.readline().split()))
    A.sort()
    if K==1:
        print(0)
        return

    rcom=[0]*N
    rcom[0]=A[-1]
    for i in range(1,N):
        rcom[i]=rcom[i-1]+A[-i-1]

    lcom=[0]*N
    lcom[0]=A[0]
    for i in range(1,N):
        lcom[i]=lcom[i-1]+A[i]

    result=0
    for i in range(N-1):
        result+=(rcom[i]-lcom[i])*cmb(N-2-i,K-2,mod,g1,g2)
        result%=(10**9+7)

    print(result)

main()

Measured memory_bytes: 63348
q=[1.0]+[k=0]*n=gets.to_i
g=[]
$<.map{|s|a,b=s.split;(g[a.to_i-1]||=[])<<b.to_i-1}
g.map{|h|h.map{|t|q[t]+=q[k]/h.size};k+=1}
e=[a=0]*n
(n-2).downto(0){|i|s=m=0.0;g[i].map{|t|s+=c=e[t];m=[m,c].max}
e[i]=1+s/z=g[i].size
z>1&&a=[a,q[i]*=(s-m)/~-z-s/z].min}
p e[0]+a

Measured memory_bytes: 6396
p = 10 ** 9 + 7
N = 10**6  #Nの取りうる最大
R = 10**6  #Rの取りうる最大

fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
  fact.append((fact[-1] * i) % p)
  
for i in range(2, R + 1):
  inv.append((-inv[p % i] * (p // i)) % p)
  factinv.append((factinv[-1] * inv[-1]) % p)

def comb(n, r, p):
  if (r < 0) or (n < r):
    return 0
  r = min(r, n - r)
  return fact[n] * factinv[r] * factinv[n-r] % p


a,b=map(int,input().split())
if (a+b)%3==0:
  T=int((a+b)/3)
  K=a-T
  print(comb(T,K,p))
else:
  print(0)

Measured memory_bytes: 212884
using System;
class Program
{
	static void Main(string[] args)
	{
        long x = long.Parse(Console.ReadLine());
      
        long gohyaku = x / 500;
        long amari = x - gohyaku * 500;
        long go = amari / 5;
      
        long ans = gohyaku * 1000 + go * 5;
		//出力
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

int main(){
    int n;
    pair<int,int> cnt[2][100001];
    cin >> n;
 
    rep(i,100001) cnt[0][i] = cnt[1][i] = make_pair(0,i);
    rep(i,n){
        int v;
        cin >> v;
        cnt[i%2][v].fs--;
    }
    sort(cnt[0],cnt[0]+100001);
    sort(cnt[1],cnt[1]+100001);

    if(cnt[0][0].sc!=cnt[1][0].sc){
        cout << n+cnt[0][0].fs+cnt[1][0].fs << endl;
    }
    else{
        cout << min(n+cnt[0][0].fs+cnt[1][1].fs,n+cnt[0][1].fs+cnt[1][0].fs) << endl;
    }
    return 0;
}

Measured memory_bytes: 1792