akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// 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())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Coffee | diff Coffee.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Coffee.cpp && ./a.out

/*
 
 3/28/2020
 
 5:00-
 
 */
string S;
bool solve() {
  return S[2]==S[3]&&S[4]==S[5];
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>S;
  cout<<(solve()?"Yes":"No")<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int r;
	cin >> r;
	cout << 2 * r * M_PI << endl;
	return 0;
}


Measured memory_bytes: 3260
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int64_t sum_two_times(int64_t a, int64_t b);

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

    int64_t a, b = 0;
    cin >> a >> b;

    int64_t sum = sum_two_times(a, b);

    cout << sum << endl;

    // test code.
    // assert(sum_two_times(5, 3) == 9);
    // assert(sum_two_times(3, 4) == 7);
    // assert(sum_two_times(6, 6) == 12);
}

int64_t sum_two_times(int64_t a, int64_t b)
{
    int64_t sum = 0;
    for(size_t i = 0; i < 2; ++i)
    {
        if (a >= b) {
            sum += a;
            a--;
        } else {
            sum += b;
            b--;
        }
    }

    return std::move(sum);
}

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

int main(){
  int n;
  cin>>n;
  string str;
  cin>>str;
  n=str.size();
  int I=0,J=0,O=0,IO=0,JO=0,IOI=0,JOI=0;

  for(int i=0;i<n;i++){
    if(str[i]=='I'){
      I++;
      if(O*J*JO)J--,JO--,O--,JOI++;
      else if(O*I*IO)IO--,O--,IOI++;

    }
    if(str[i]=='O') {
      if(I-IOI+J>O) O++;
      if(J>JO) JO++;
      if(I-IOI>IO) IO++;
    }
    if(str[i]=='J') J++;
  }
  //cout<<J<<' '<<O<<' '<<I<<endl;
  //cout<<JOI<<' '<<IOI<<endl;
  int ans=JOI;
  I-=JOI;
  ans+=min(IOI,I/2);
  cout<<ans<<endl;
  



return 0;
}

Measured memory_bytes: 2072
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    int a[3][3];
    bool h[3][3];
    for (int i = 0; i < 3; ++i)
        for (int j = 0; j < 3; ++j) cin >> a[i][j];
    for (int i = 0; i < 3; ++i)
        for (int j = 0; j < 3; ++j) h[i][j] = false;
    int n;
    cin >> n;
    for (int i = 0, b; i < n;++i){
        cin >> b;
        for (int j = 0; j < 3; ++j) for (int k = 0; k< 3; ++k)
                if (a[j][k] == b) h[j][k] = true;
    }
    
    bool bingo = true;
    for(int i=0;i<3;++i) if (!h[i][i]) bingo = false;
    if (bingo) return cout << "Yes",0;
    bingo = true;
    for(int i=0;i<3;++i) if (!h[i][2 - i]) bingo = false;
    if (bingo) return cout << "Yes",0;
    for (int i = 0; i < 3;++i){
        bingo = true;
        for (int j = 0; j < 3; ++j) if (!h[i][j]) bingo = false;
        if (bingo) return cout << "Yes", 0;
    }
    for (int i = 0; i < 3;++i){
        bingo = true;
        for (int j = 0; j < 3; ++j) if (!h[j][i]) bingo = false;
        if (bingo) return cout << "Yes", 0;
    }
    cout << "No";
}

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

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

using namespace std;

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

template <class Iterator>
P f(Iterator first, Iterator last) {
    ll S = *(last - 1) - *first;
    auto ub = upper_bound(first + 1, last, *first + S / 2);
    int n = distance(first, last) - 1;
    int i1 = distance(first, ub);
    int j1 = n - i1;
    int i0 = i1 - 1;
    int j0 = j1 + 1;
    ll Si1, Si0, Sj1, Sj0;
    if (i1 >= 1 && j1 >= 1) {
        Si1 = *(first + i1) - *first;
        Sj1 = S - Si1;
    } else {
        Si1 = LLONG_MAX;
        Sj1 = LLONG_MIN;
    }
    if (i0 >= 1 && j0 >= 1) {
        Si0 = *(first + i0) - *first;
        Sj0 = S - Si0;
    } else {
        Si0 = LLONG_MIN;
        Sj0 = LLONG_MAX;
    }
    return P(min(Si1, Sj0), max(Sj1, Si0));
}

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    vector<ll> acc_A(N + 1);
    acc_A[0] = 0;
    REP(i, N) acc_A[i + 1] = acc_A[i] + A[i];

    ll result = LLONG_MAX;
    FOR(center, 2, N - 2 + 1) {
        ll S[4];
        tie(S[0], S[1]) = f(acc_A.begin(), acc_A.begin() + center + 1);
        tie(S[2], S[3]) = f(acc_A.begin() + center, acc_A.end());
        ll diff = *max_element(S, S + 4) - *min_element(S, S + 4);
        result = min(result, diff);
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 3456
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<iterator>
#include<iostream>
#include<sstream>
#include<cctype>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<list>
#include<stack>
#include<functional>
#include<utility>
#include<numeric>
#include<bitset>
#include<iterator>
#define INF (int)1e9
#define MOD 1000000007
#define tr(c, it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define debug(x) cout<<#x" = "<<(x)<<endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz size
#define ll long long
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MEM(a, b) memset(a, (b), sizeof(a))
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?"\n":" ")
#define printv(a) printa(a,0,a.size())
#define print2d(a,r,c) for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?"\n":" ")
#define PRE(i, m, n, in) for(int (i)=(m);(i)<(n);i+=in)
#define RFOR(i, n) for(int i=n ; i>=0 ; i--)
#define RPRE(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define ERS(A, P) A.erase(A.begin() + P)
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define INS(A, P, B) A.insert(A.begin() + P, B)
#define rev(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define grtsrt(v) sort(v.begin(),v.end(),greater<int>())
#define mnv(v) *min_element(v.begin(),v.end())
#define mxv(v) *max_element(v.begin(),v.end())
#define countv(v,a) count(v.begin(),v.end(),a)
#define toint(a) atoi(a.c_str())
using namespace std;
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
typedef vector <int> VI;
typedef vector <ll> VL;
typedef vector<string> VS;
typedef vector <VS> VSS;
typedef vector <II> VII;
typedef vector <LL> VLL;
typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VII> VVII;
typedef vector <VLL> VVLL;
typedef map<int,int> MPII;
typedef map<ll,ll> MPLL;
typedef map<string, int>MPSI;
typedef map<string, ll>MPSL;
typedef map<int, string>MPIS;
typedef map<ll, string> MPLS;
typedef map<string, string> MPSS;
typedef set<int> SETI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.txt", "r", stdin);
    int a, b, t; cin >> a >> b >> t;
    cout << int((t + 0.5)/a)*b << "\n";
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;
	vector<ll> a(n);
	for (auto &i : a) cin >> i;

	auto b = a;
	ll x = 0;
	for (auto &i : b)
		i = __gcd(i, x), x = i;

	x = 0;
	ll ans = 0;
	b.insert(b.begin(), 0);
	for (int i = n; i > 0; --i)
	{
		ans = max(ans, __gcd(x, b[i-1]));
		x = __gcd(x, a[i-1]);
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
int main() {
    int n, m, vote = 0, count = 0, a[100];
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; i++)
    {
        vote = vote + a[i];
    }
    for (int i = 0; i < n; i++)
    {
        if (a[i] >= vote / (4.0 * m))
        {
            count = count + 1;
        }

    }

    if (count >= m)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 1644
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int n,m;
V s,z;
V &Me(const V &_x,const V &_y){
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(_x[slice(i*n,n,1)]*_y[slice(j,n,n)]).sum()%m;
	return z;
}
V &Mx(const V &_x){
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(_x[slice(i*n,n,1)]*_x[slice(j,n,n)]).sum()%m;
	return z;
}
void O(const V &r){
	int i=0;
    for(;i<n-1;i++)printf("%d ",(r[slice(i*n,n,1)]*s).sum()%m);
    printf("%d\n",(r[slice(i*n,n,1)]*s).sum()%m);
}
main(){
s.resize(99);
	int i,a,b,c,t;
	for(;scanf("%d%d%d%d%d%d",&n,&m,&a,&b,&c,&t),n;){
		
		for(i=0;i<n;i++)scanf("%d",&s[i]);
		V x(n*n);
		V e(n*n);
		//e.resize(0);
		//e.resize(n*n);
		z.resize(n*n);

		x[0]=b;
		x[1]=c;
		e[0]=1;
		for(i=1;i<n-1;i++){
			x[i*n+i-1]=a;
			x[i*n+i]=b;
			x[i*n+i+1]=c;
			e[i*n+i]=1;
		}
		x[i*n+i-1]=a;
		x[i*n+i]=b;
		e[i*n+i]=1;
		for(;t;t>>=1){
			if(t&1)e=Me(e,x);
			x=Mx(x);
		}
		O(e);
	}
}

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

N, M = [int(x) for x in input().split()]
G = [[] for _ in range(N + 1)]

for _ in range(M):
    a, b = [int(x) for x in input().split()]
    G[a].append(b)
    G[b].append(a)

import itertools
l = [x for x in range(2, N + 1)]
per = list(itertools.permutations(l))

cnt = 0

for i in range(len(per)):
    route = [1] + list(per[i])
    flag = 1
    for k in range(len(route) - 1):
        if route[k + 1] not in G[route[k]]:
            flag = 0
            break
    cnt += flag

print(cnt)
    

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>

using namespace std;

#define PI 3.141592653589793
#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define RFOR(i,a,b) for(int i=int(b)-1;i>=int(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)

class Dice{
public:
    Dice()
    {
        face = new int[6];
        move = new int[6];
    }
    ~Dice()
    {
        delete[] face;
        delete[] move;
    }
    void roll(char c)
    {
        REP(i,6) move[i]=face[i];
        if (c=='E') setLabel(move[3],move[1],move[0],move[5],move[4],move[2]);
        else if (c=='N') setLabel(move[1],move[5],move[2],move[3],move[0],move[4]);
        else if (c=='S') setLabel(move[4],move[0],move[2],move[3],move[5],move[1]);
        else setLabel(move[2],move[1],move[5],move[0],move[4],move[3]);
    }
    void setLabel(int i,int n) {face[i] = n;}
    void setLabel(int f0,int f1,int f2,int f3,int f4,int f5)
    {
        face[0] = f0;
        face[1] = f1;
        face[2] = f2;
        face[3] = f3;
        face[4] = f4;
        face[5] = f5;
    }
    int getAns() {return face[0];}
private:
    int *face;
    int *move;
};

int main() {
    Dice d;
    int n,l;
    string str;
    REP(i,6) {
        cin >> n;
        d.setLabel(i,n);
    }
    cin >> str;
    l = str.size();
    REP(i,l) d.roll(str[i]);
    cout << d.getAns() << endl;
    return 0;
}



Measured memory_bytes: 3180
//Created by Young Charlie
#include<bits/stdc++.h> 
using namespace std;
int f(int n){
	return (n % 2 == 0 ? n / 2 : 3 * n + 1);
}
int32_t main(){
	int s; cin>>s;
	vector<int> a(1, s);
	set<int> set;
	set.insert(s);
	while(true){
		a.push_back(f(s));
		s = f(s);
		if(set.count(s)){
			cout<<a.size()<<endl;
			return 0;
		}
		set.insert(s);
	}
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] hikakuStr = line.split("[\\s]+");

		int a = Integer.parseInt(hikakuStr[0]);
		int b = Integer.parseInt(hikakuStr[1]);
		int c = Integer.parseInt(hikakuStr[2]);
		int count = 0;
		// TODO ?????????????????????????????????????????????
		for (int i = a; i <= b; i++) {
			if (c % i == 0) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 24632
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    k = ii()
    a,b = mi()
    tmp = 0
    while tmp < b+1:
        if tmp>=a:
            print('OK')
            exit()
        tmp+=k

    print('NG')




main()




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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[125252];
int b[125252];
int c[125252];


vector<int> g[125252];
int subsz[125252];
int dfs(int p,int bef){
  subsz[p] = 1;
  for(int to : g[p])if(to != bef){
    subsz[p] += dfs(to,p);
  }
  return subsz[p];
}
ll solve(){
  REP(i,n)g[i].clear();
  REP(i,n-1){
    g[a[i]].push_back(b[i]);
    g[b[i]].push_back(a[i]);
  }
  dfs(0,-1);
  vi centroid;
  REP(i,n){
    int sz = 0;
    for(int to : g[i]){
      if(subsz[to] > subsz[i]){
        CHMAX(sz, n-subsz[i]);
      }else{
        CHMAX(sz, subsz[to]);
      }
    }
    if(sz <= n/2){
      centroid.push_back(i);
    }
  }
  ll ans = 0;
  ll mn = 1e18;
  REP(i,n-1){
    int s = a[i];
    int t = b[i];
    int x = subsz[s] > subsz[t] ? t : s;
    ll mul = min(subsz[x],n-subsz[x]);
    ans += mul * c[i] * 2ll;
    if(centroid.size()==2){
      if(find(ALL(centroid),s)!=centroid.end() && find(ALL(centroid),t)!=centroid.end()){
        CHMIN(mn, (ll)c[i]);
      }
    }else if(find(ALL(centroid),s)!=centroid.end() || find(ALL(centroid),t)!=centroid.end()){
      CHMIN(mn,(ll)c[i]);
    }
  }
  ans -= mn;
  return ans;
}


vector<pii> g3[125252];
int g2[125][125];
void dfs(int from,int p,int bef,int d){
  g2[from][p] = d;
  for(pii P : g3[p]){
    int to = P.first;
    int c = P.second;
    if(to==bef)continue;
    dfs(from,to,p,d+c);
  }
}
vi ord;
ll solve2(){
  REP(i,n)g3[i].clear();
  REP(i,n-1){
    g3[a[i]].push_back(pii(b[i],c[i]));
    g3[b[i]].push_back(pii(a[i],c[i]));
  }
  REP(i,n){
    dfs(i,i,-1,0);
  }
  ll ans = 0;
  vi V(n);
  REP(i,n)V[i] = i;
  do{
    ll tmp = 0;
    REP(i,n-1)tmp += g2[V[i]][V[i+1]];
    if(tmp>ans){
      ans = tmp;
      ord = V;
    }
  }while(next_permutation(ALL(V)));
  return ans;
}


int main(){
  #if 1
  scanf("%d",&n);
  REP(i,n-1){
    scanf("%d%d%d",a+i,b+i,c+i);
    --a[i];--b[i];
  }
  printf("%lld\n",solve());
  #else
  srand(time(NULL));
  while(true){
    n = 9;
    REP(i,n-1){
      a[i] = rand()%(i+1);
      // a[i] = i;
      b[i] = i+1;
      c[i] = rand()%n + 1;
    }
    ll x = solve();
    ll y = solve2();
    if(x != y){
      DEBUG(x);
      DEBUG(y);
      DEBUG_VEC(ord);
      DEBUG(n);
      REP(i,n-1){
        printf("%d %d %d\n",a[i],b[i],c[i]);
      }
      return 0;
    }
  }
  #endif
  return 0;
}


Measured memory_bytes: 14976
#include <iostream>
#include <cmath>
using namespace std;
int prime(int n);
int main(){
    int a[50000];
    for (int j=0;j<50000;j++)
        a[j]=prime(j);

    int b;
    Loop:
    while(true){
    int count =0;
    cin >> b;
    if (b==0)
        break;
    for(int x=2;x<b/2+1;x++){
        if(a[x]!=0){
            if(x<=b-x){
                if(a[x]+a[b-x]==b)
                    count++;
            }
        }
        }
    cout << count << endl;
    }

    }

int prime(int n){
    if(n==1)
        return 0;
    if (n==2 || n==3)
        return n;
    if (n%2==0)
        return 0;
    for(int i=3;i<sqrt(n)+2;i++){
        if (n%i==0)
            return 0;
    }
    return n;
}

Measured memory_bytes: 1356
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <string>
#include <tuple>
#include <vector>
#include <set>
#include <map>
#include <iterator>
#include <random>
#include <cmath>

using namespace std;
using lint = long long int;

int main() {
	int n;
	cin >> n;
	int* a = new int[n];

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

	int counter = 1;
	int breakNum = 0;
	for (int i = 0; i < n; i++) {
		if (counter == a[i]) {
			counter++;
			continue;
		}
		breakNum++;
	}

	if (counter == 1) 
		cout << -1;
	else
		cout << breakNum;

	return 0;

}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
   int i,j,a[20],b[20],s,n,m;

   scanf("%d",&n);
   for(i=0;i<n;i++) scanf("%d",&a[i]);
   for(i=0;i<n;i++) scanf("%d",&b[i]);

   m=0;
   for(j=0;j<n;j++){
      s=0;
      s=a[j]-b[j];
      if(s<0)
        m=m+0;
      else
        m=m+s;
    }


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

    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
  int a, c;
  int d;
  string b;
  cin >> a >> b >> c;
  if (b == "+") {
    d = a + c;
  }
  else if (b == "-") {
    d = a - c;
  }
  cout << d << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int n;
vector<int> a, e, r;

int memo[105][105];
void dfs(int exp, int hp, int sum){
	if(memo[exp][hp] <= sum) return;
	memo[exp][hp] = sum;

	rep(i,n){
		if(exp < r[i]) continue;
		dfs(min(100, exp + e[i]), max(0, hp - a[i]), sum + 1);
	}
}

int main(){
	int d;
	while(cin >> d >> n, d||n){

		a = vector<int>(n);
		e = vector<int>(n);
		r = vector<int>(n);
		rep(i,n){
			cin >> a[i] >> e[i] >> r[i];
		}

		const int INF = 1e8;
		rep(i,105) rep(j,105) memo[i][j] = INF;
		dfs(0, d, 0);

		int ans = INF;
		rep(i,101){
			if(memo[i][0] == -1) continue;
			ans = min(ans, memo[i][0]);
		}
		if(ans == INF) cout << "NA" << endl;
		else cout << ans << endl;
	}
}



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

int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];
  sort(a, a+n);

  int ans;
  int buf = 0;
  rep(i, 1e5) {
    int tmp = distance(lower_bound(a, a+n, i-1), upper_bound(a, a+n, i+1));
    if (buf < tmp) {
      buf = tmp;
      ans = i;
    } 
  }
  cout << buf << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
using VI = vector<int>;

using DBL = double;
const DBL EPS = 1e-9, INF = 1e5;
bool EQ(DBL a, DBL b) {
  return fabs(a - b) < EPS;
}
bool LE(DBL a, DBL b) {
  return EQ(a, b) || a < b;
}

struct vec {
  DBL x, y;
  vec(): x(0), y(0) {}
  vec(DBL a, DBL b): x(a), y(b) {}
  vec rotate90() const {
    return vec(-y, x);
  }
  vec operator+ (const vec& v) const {
    return vec(x + v.x, y + v.y);
  }
  vec operator- (const vec& v) const {
    return vec(x - v.x, y - v.y);
  }
  vec operator* (DBL s) const {
    return vec(x * s, y * s);
  }

  DBL dot(const vec& v) const {
    return x * v.x + y * v.y;
  }
  DBL cross(const vec& v) const {
    return x * v.y - y * v.x;
  }
  DBL norm() const {
    return hypot(x, y);
  }
};

struct line {
  vec a, v;
};

line perp_bisect(const vec& a, const vec& b) {
  line l;
  l.a = (a + b) * 0.5;
  l.v = (b - a).rotate90();
  return l;
}
bool intersect(const line& a, const line& b, vec& p) {
  if (EQ(0, a.v.cross(b.v))) {
    return false;
  }
  DBL alpha = (b.a - a.a).cross(b.v) / a.v.cross(b.v);
  p = a.a + a.v * alpha;
  return true;
}

struct circle {
  vec c; DBL r;
  bool inside(const vec& p) const {
    return LE((p - c).norm(), r);
  }
};

circle circumcircle(const vec& a, const vec& b, const vec& c) {
  line l1 = perp_bisect(a, b);
  line l2 = perp_bisect(a, c);
  vec cc;
  if (intersect(l1, l2, cc)) {
    return circle { cc, (cc - a).norm() };
  } else {
    return circle { vec(), INF };
  }
}

bool check(const circle& c, const vector<vec>& pts) {
  for (auto& p: pts) {
    if (!c.inside(p)) return false;
  }
  return true;
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; cin >> n;
  vector<vec> pts(n);
  for (int i = 0; i < n; i++) {
    cin >> pts[i].x >> pts[i].y;
  }

  DBL ans = INF;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      circle c { (pts[i] + pts[j]) * .5, (pts[i] - pts[j]).norm() / 2 };
      if (check(c, pts)) {
        ans = min(ans, c.r);
      }
      for (int k = j + 1; k < n; k++) {
        c = circumcircle(pts[i], pts[j], pts[k]);
        if (check(c, pts)) {
          ans = min(ans, c.r);
        }
      }
    }
  }

  cout << setprecision(10) << fixed << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1],tot;
	cin>>a[1];
	tot=a[1];
	for(int i=2;i<=n;i++)
	{
		cin>>a[i];
		tot=a[i]^tot;
	}
	for(int i=1;i<=n;i++)
		cout<<int(tot^a[i])<<" ";
    return 0;
}

Measured memory_bytes: 4304
# coding: utf-8
# Here your code !
employeeSalesList = []

def resetDataset():
    del employeeSalesList[0 : len(employeeSalesList) + 1]

def readDataCount():
    return int(input())

def searchEmployeeSales(employeeId):
    for data in employeeSalesList:
        if data[0] == employeeId:
            return data
    
    newData = [employeeId, 0]
    employeeSalesList.append(newData)
    return newData

def checkSales():
    employeeId, price, volume = list(map(int, input().split(" ")))
    employeeSales = searchEmployeeSales(employeeId)
    employeeSales[1] += price * volume

answerList = []
def printEmployeeOfDataset():
    found = False
    for data in employeeSalesList:
        if data[1] >= 1000000:
            answerList.append(data[0])
            found = True
    if not found:
        answerList.append("NA")

resetDataset()
dataCount = readDataCount()
while dataCount > 0:
    for _ in range(dataCount):
        checkSales()
    printEmployeeOfDataset()
    resetDataset()
    dataCount = readDataCount()

for row in answerList:
    print(row)

Measured memory_bytes: 7876
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from itertools import accumulate

    n = int(input())
    a = list(map(int, readline().split()))
    a_cum = [0] * (n + 1)
    a_cum[n] = a[n]

    for i in range(n - 1, -1, -1):
        a_cum[i] = a_cum[i + 1] + a[i]

    b = [0] * (n + 1)
    b[0] = 1

    for i in range(n):
        b[i + 1] = min((b[i] - a[i]) * 2, a_cum[i + 1])

    ans = 0
    for i in range(n + 1):
        if b[i] < a[i]:
            print(-1)
            sys.exit()
        ans += b[i]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 670920
MOD = 10**9+7
n = int(input())
A, C, G, T = 0, 1, 2, 3
dp = [[[[1 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(n+1)]
dp[3][A][G][C] = 0
dp[3][A][C][G] = 0
dp[3][G][A][C] = 0

for i in range(4, n+1):
	for j in range(4):
		for k in range(4):
			for l in range(4):
				dp[i][j][k][l] = 0
				for h in range(4):
					if l == C:
						if h == A and k == G:
							continue
						if h == A and j == G:
							continue
					dp[i][j][k][l] += dp[i-1][h][j][k]

				dp[i][j][k][l] %= MOD

	dp[i][A][G][C] = 0
	dp[i][A][C][G] = 0
	dp[i][G][A][C] = 0

ans = 0
for j in range(4):
	for k in range(4):
		for l in range(4):
			ans += dp[n][j][k][l]
			ans %= MOD
print(ans)

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

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back

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

	//  code starts
  int n;cin>>n;
  string s;cin>>s;
  if (n<3200){
    cout<<"red";
    return 0;
  }
  
    cout<<s;
	
	return 0;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    string s;
    int cnt=0;
    cin >> s;
    for(char c : s)cnt+=c-'0';
    if(cnt%9)cout << "No";
    else cout << "Yes";
    return 0;
}

Measured memory_bytes: 3740
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <map>

using namespace std;

int main(){
  int i,j,k,n,m;
  cin >> n;
  for(i=111;i<=999;i+=111){
    if(i>=n){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int a,b,n;

int main(void){
	while(~scanf("%d%d%d",&a,&b,&n)){
		int sum=0;
		a=a%b;
		for(int j=0;j<n;j++){
			a*=10;
			sum+=a/b;
			a=a%b;
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
	int x, y;
	scanf("%d %d", &x, &y);
	while((x != 0)||(y != 0)){
		if(x < y)
			printf("%d %d\n",x ,y);
		else
			printf("%d %d\n",y ,x);
		scanf("%d %d", &x, &y);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()

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();}

//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

int main() {
    int N,b;
    ll a;
    ll mod=1e9+7;
    cin >> N;
    map<ll,ll> v;
    REP(i,N){
        cin >> a >> b;
        v[b];
        v[b] += a;
    }
    ll s = 0;
    // SORT(v);
    for (auto ix = v.begin();ix!=v.end();ix++) {
        s += ix->second;
        // cout << ix->first << ' ' << s << endl;
        if (s > ix->first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

const long long MAX = 100000;
long long cnt[MAX + 1];
signed main(void)
{
	long long n, k;
	cin >> n >> k;
	vector<long long> ans(n);

	rep(i, n)
	{
		long long a, b;
		cin >> a >> b;
		cnt[a] += b ;
	}
	rep(i, MAX + 1)
	{
		if (k <= cnt[i])
		{
			cout << i << endl;
			break;
		}
		k -= cnt[i];
	}
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
#define MAX_SIZE 500010
#define INFTY 2000000000
using namespace std;

int D[MAX_SIZE];


int fib(int n) {
    if (D[n] > 0) {
        return D[n];
    }
    if (n <= 1) {
        return 1;
    }
    D[n] = fib(n -1) + fib(n - 2);
    return D[n];
}

int main(){
    int n;
    cin >> n;
    cout << fib(n) << endl;
} 


Measured memory_bytes: 3080
n,q = map(int,input().split())
s = list(input())
t = [0]*len(s)
list_q = [list(map(int,input().split())) for i in range(q) ]
count = 0
for i in range(len(s)-1):
    if s[i] == "A" and s[i+1] =="C":
        count += 1
    t[i+1] = count
for i in range(q):
    j,k = list_q[i][0],list_q[i][1]
    print(t[k-1]-t[j-1])


Measured memory_bytes: 72440
from itertools import permutations as perm
from math import factorial

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]

all_sum = 0
for a in perm(XY):
    sum_num = 0
    for j in range(N-1):
        x1, y1 = a[j]
        x2, y2 = a[j+1]
        r = (abs(x1-x2)**2 + abs(y1-y2)**2)**(1/2)
        sum_num += r
    all_sum += sum_num

print(all_sum / factorial(N))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s;cin >> s;
  vector<int> nums(3,0);
  for(const char&c : s){
    int n = c-'a';
    ++nums[n];
  }
  sort(all(nums));
  YESNO(nums[2]-nums[0]<=1);
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/range.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>
using namespace std;
constexpr char nl = '\n';
using ll = long long;
using boost::irange;
namespace rng { using namespace boost; using namespace boost::range; }
namespace adp { using namespace boost::adaptors; }

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> auto operator>>(istream& in, C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, istream&>::type {
    for (auto& v : c) { in >> v; } return in; }
template<class C> auto operator<<(ostream& out, const C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, ostream&>::type {
    int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
constexpr auto color_s_ = "\033[2m\033[33m", color_e_ = "\033[0m";
template<class T> void trace_(const T& v) { cerr << v; }
template<class T> void trace_(const vector<vector<T>>& m) { cerr << "\n"; for (const auto& v : m) { trace_(v); cerr << "\n"; } }
template<class T> void trace_(const char* s, const T& v) { cerr << color_s_ << s << "="; trace_(v); cerr << color_e_ << "\n"; cerr.flush(); }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { cerr << color_s_; for (; *s != ','; ++s) { cerr << *s; } cerr << "="; trace_(v); cerr << ","; trace_(++s, vs...); }
#define TRACE(...) trace_(#__VA_ARGS__, __VA_ARGS__)
#else
#define TRACE(...)
#endif

int main() {
    int n, m;
    cin >> n >> m;
    for (int i : irange(m)) {
        int l = (n / 2 - i), r = (n / 2 + i + 1);
        if (2*i+1 >= n/2 && n % 2 == 0) {
            r++;
        }
        cout << l << " " << r << nl;
    }
}


Measured memory_bytes: 3660
def main():
    N, Y = map(int, input().split())

    x_max = int(Y/10000)

    for x in range(x_max+1):
        tmp_Y = Y - x*10000
        y_max = int(tmp_Y/5000)

        for y in range(y_max+1):
            tmp_Y2 = tmp_Y - y*5000
            z = int(tmp_Y2/1000)

            if x + y + z == N:
                print(x, y, z)
                exit()

    print(-1, -1, -1)

if __name__ == "__main__":
    main()

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

int a,b;

int main(){
  cin >> a >> b;
  if(b==1){
    cout << 0 << endl;
    return 0;
  }
  if(a>=b){
    cout << 1 << endl;
    return 0;
  }
  int tmp = a;
  for(int i=2;i<=100;i++){
    tmp+=a-1;
    if(tmp>=b){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

ll atack(ll N, ll ans, int cnt) {
    if (N == 0) return ans;
    else return atack(N / 2, ans += (ll)pow(2, cnt), cnt + 1);
}

int main() {
    ll H;
    cin >> H;
    cout << atack(H, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 4060
#include <stdio.h>

int binarySearch(int *, int, int);


int main() {
  int i, j, n, q, count = 0, flag = 0;
  int datas[100000], dataq[50000];

  scanf("%d", &n);
  for (i= 0; i < n; i++) {
    scanf("%d", &datas[i]);
  }
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &dataq[i]);
  }

  for (i = 0; i < q; i++) {
    flag = binarySearch(datas, n, dataq[i]);
    if (flag == 1) count++;
  }
  
  printf("%d\n", count);



  return 0;
}


int binarySearch(int *s, int n, int key) {
  int left, right, mid;
  left = 0;
  right = n;

  while (left < right) {
    mid = (left + right) / 2;
    if (s[mid] == key) return 1;

    else if (key < s[mid]) right = mid;

    else left = mid + 1;
  }

  return 0;
}



Measured memory_bytes: 2292
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int N; cin >> N;
    string s, t; cin >> s >> t;
    IREP(i, N + 1){
        if(s.substr(N - i, i) == t.substr(0, i)){
            cout << 2 * N - i;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = {}

for i in range(n):
    ss = input()

    if ss in s:
        s[ss] += 1
    else:
        s[ss] = 1

s2 = sorted(s.items(), key=lambda x:x[1])

s2.reverse()

max_value = s2[0][1]
ret = []

for sss in s2:
    if sss[1] == max_value:
        ret.append(sss[0])
    else:
        break

ret2 = sorted(ret)
for r in ret2:
    print(r)

Measured memory_bytes: 47324
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
/* テンプレートここまで */

int main() {
  int N; cin >> N;
  vector<ll> a(3*N); REP(i, 3*N) cin >> a[i];

  multiset<int> st;

  //i=0,1,...,Nに対し，
  //a[0], a[1], ..., a[N-1+i]のうち，上位N個の和を記録
  vector<ll> former(N+1, 0); 
  //a[3N-1], a[3N-2], ..., a[2N-i]のうち，下位N個の和を記録
  vector<ll> latter(N+1, 0);

  REP(i, N){
    st.insert(a[i]);
    former[0] += a[i];
  }

  FOR(i, 1, N+1){
    auto min_it = st.begin();
    ll tmp = *min_it;
    if(a[N-1+i] > tmp){
      st.erase(min_it);
      st.insert(a[N-1+i]);
      former[i] = former[i-1] + a[N-1+i] - tmp;
    }else{
      former[i] = former[i-1];
    }
  }

  multiset<int> st2;

  REP(i, N){
    st2.insert(a[3*N-1-i]);
    latter[0] += a[3*N-1-i];
  }

  FOR(i, 1, N+1){
    auto max_it = st2.rbegin();
    ll tmp = *max_it;
    if(a[2*N-i] < tmp){
      //参考：http://izmiz.hateblo.jp/entry/2014/11/01/140233
      st2.erase(--max_it.base()); 
      st2.insert(a[2*N-i]);
      latter[i] = latter[i-1] + a[2*N-i] - tmp;
    }else{
      latter[i] = latter[i-1];
    }
  }

  ll ans = -INF;

  REP(i, N+1){
    ans = max(ans, former[i] - latter[N-i]);
  }

  cout << ans << endl;
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int main() {
  int n;cin>>n;
  string s;cin>>s;
  string t=s;
  reverse(ALL(t));
  int l[n],r[n],x,y;
  l[0]=x=0;r[0]=y=0;
  reps(i,n-1){
    if(s[i-1]=='W')x++;
    if(t[i-1]=='E')y++;
    l[i]=x;r[i]=y;
  }
  int ans=n+1;
  rep(i,n)chmin(ans,l[i]+r[n-i-1]);
  cout <<ans;
}

Measured memory_bytes: 3332
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {

    int a,b,c,d ;
    
    cin >> a >> b >> c >> d;
    
    while(a>=0 || c >=0){
        c = c-b;
        if(c<=0){
            cout << "Yes" << endl;
            break;
        }
        
        a = a-d;

        if(a<=0){
            cout << "No" << endl;
            break;
        }

        
    }


    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>

using namespace std;

/*
int main(void)
{
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<vector<int> > lrmap(N, vector<int>(N, 0));

	for (int i = 0; i < M; i++){
		int l, r;
		cin >> l >> r;
		lrmap[l-1][r-1]++;
	}

	vector<vector<int> > ruisekiwa(N, vector<int>(N+1, 0));
	for (int l = 0; l < N; l++){
		ruisekiwa[l][0] = 0;
		for (int r = 1; r <= N; r++){
			ruisekiwa[l][r] = ruisekiwa[l][r - 1] + lrmap[l][r-1];
		}
	}
	for (int k = 0; k < Q; k++){
		int cnt = 0;
		int q1, q2;
		cin >> q1 >> q2;
		for (int l = q1-1; l <= q2-1; l++){
			cnt += ruisekiwa[l][q2] - ruisekiwa[l][q1-1];
		}
		cout << cnt << endl;
	}
}

*/

int main(void)
{
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<vector<int> > lrmap(N+1, vector<int>(N+1, 0));

	for (int i = 0; i < M; i++){
		int l, r;
		cin >> l >> r;
		lrmap[l][r]++;
	}
	for (int l = 1; l <= N; l++){
		for (int r = 1; r <= N; r++){
			lrmap[l][r] += lrmap[l][r - 1];
		}
	}
	for (int l = 1; l <= N; l++){
		for (int r = 1; r <= N; r++){
			lrmap[l][r] += lrmap[l-1][r];
		}
	}
	
	for (int k = 0; k < Q; k++){
		int q1, q2;
		cin >> q1 >> q2;
		cout << lrmap[q2][q2] - lrmap[q1 - 1][q2] - lrmap[q2][q1 - 1] + lrmap[q1 - 1][q1 - 1] << endl;
	}
}

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

using namespace std;

#define all(v) (v).begin(), (v).end()
#define _sz(v) (int)(v).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned long long ull;



const int N = (int)2e5 + 5;

struct SegmentTree {
    struct Node {
        Node *l, *r;
        int sz;
        int mx;

        Node(): sz(0), mx(0) {};

        Node(int _sz): sz(_sz), mx(0) {
            if (sz != 1) {
                l = new Node(sz / 2);
                r = new Node(sz - sz / 2);
            }
        }

        void recalc() {
            if (sz != 1)
                mx = max(l->mx, r->mx);
        }

        void modify(int pos, int val) {
            if (sz == 1) {
                mx = val;
            } else {
                if (pos < sz / 2)
                    l->modify(pos, val);
                else
                    r->modify(pos - sz / 2, val);
                recalc();
            }
        }
        int get(int i) {
            if (i >= sz)
                return mx;
            if (i <= 0)
                return 0;
            return max(l->get(i), r->get(i - sz / 2));
        }
    };

    int n;
    Node* root;
    vector<int> memory[N];

    SegmentTree() {};
    SegmentTree(int _n): n(_n) {
        root = new Node(n);
        for (int i = 0; i < n; ++i)
            memory[i] = {0};
    }

    int get(int r) {
        return root->get(r);
    }
    void modify(int pos, int val) {
        memory[pos].push_back(val);
        root->modify(pos, val);
    }
    void rollback(int pos) {
        memory[pos].pop_back();
        root->modify(pos, memory[pos].back());
    }
};


int a[N];
vector<int> g[N];
SegmentTree tree;
int ans[N];

void dfs(int v, int p) {
    int val = 1 + tree.get(a[v]);
    ans[v] = max(ans[v], val);
    tree.modify(a[v], val);
    for (int u : g[v]) {
        if (u != p) {
            ans[u] = ans[v];
            dfs(u, v);
        }
    }
    tree.rollback(a[v]);
}

int main()
{
    //freopen("input.txt", "r", stdin);


    int n;
    scanf("%d", &n);

    vector<int> xs;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        xs.push_back(a[i]);
    }
    sort(all(xs));
    xs.erase(unique(all(xs)), xs.end());
    for (int i = 0; i < n; ++i)
        a[i] = lower_bound(all(xs), a[i]) - xs.begin();

    /*
    for (int i = 0; i < n; ++i)
        printf("%d ", a[i]);
    printf("\n");
    */

    for (int i = 1; i < n; ++i) {
        int u, v;
        scanf("%d %d", &u, &v);
        --u; --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    tree = SegmentTree(n);

    dfs(0, -1);

    for (int i = 0; i < n; ++i) {
        printf("%d\n", ans[i]);
    }


}


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

signed main(){
	int n, m, a, b, f = 1;
	string S;
	
	cin>>a>>b;
	
	if(a%2 == 0 || b%2 == 0) f = 0;
	cout<<(f?"Yes":"No")<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <math.h>
#define ll long long
ll gcd(ll a,ll b){
    ll s=1,c;
    while(a&&b){
        if((~a&1)&&(~b&1))
            a>>=1,b>>=1,s<<=1;
        else if(~a&1)a>>=1;
        else if(~b&1)b>>=1;
        else if(a>b)a=a-b;
        else c=b-a,b=a,a=c;
    }
    if(!a)return b*s;
    if(!b)return a*s;
}
using namespace std;
int main(){
	int x,n;
	cin>>x>>n;
	int a[n];
	int ans[200];
	ans[0]=x;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=1;i<200;i=i+2){
	ans[i]=x-(i+1)/2;
	ans[i+1]=x+(i+1)/2;
}	
	for(int i=0;i<200;i++){
		for(int j=0;j<n;j++){
			if(ans[i]==a[j])
				break;
			if(j==n-1){
				cout<<ans[i]<<endl;
				return 0;
			}
		}
	}
	if(n==0)
	cout<<x<<endl;
	return 0;
}


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

int main()
{
int a, b;
vector<int> as, bs;

scanf("%d%d", &a, &b);
as.resize(a);
bs.resize(b);
for(int i = 0; i < a; ++i)
scanf("%d", &as[i]);
for(int i = 0; i < b; ++i)
scanf("%d", &bs[i]);

int ans = 0;

for(int start = 0; start < b; ++start) {
int apos = -1;
for(int bpos = start; bpos < b; ++bpos) {
apos += 1;
while(apos < a && as[apos] != bs[bpos]) ++apos;
if(apos < a)
ans = max(ans, bpos - start + 1);
}
}

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

return 0;
}

Measured memory_bytes: 1068
A,B,C,K = map(int,input().split())
sum = 0;
if A <= K:
	sum += A;
	K -= A
else:
	sum += K;
	K -= K
if B <= K:
	K -= B
else:
	K -= K
if C <= K:
	sum -= C
	K -= C
else:
	sum -= K
	K -= K
print(sum)

Measured memory_bytes: 9156
#include <stdio.h>

int main(){

    int a,n,k,x,an = 1;
    scanf("%d %d",&n,&k);
    for( x = 0 ; x < n ; x++ ) scanf("%d",&a);

    n -= k;
    k--;

    while( n > 0) {
        n -= k;
        an++;
    }

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

    return 0;
}

Measured memory_bytes: 128