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

using namespace std;

#define sz			size()
#define lgt			length()
#define rep(i,n)	for (int i = 0; i < n; i++)
#define ALL(X)		(X).begin(),(X).end()
#define RALL(X)		(X).rbegin(),(X).rend()
#define pb			push_back
#define SORT(a)		sort(ALL(a));
#define RSORT(a)	sort(RALL(a));
#define mp			make_pair
#define dump(x)		cerr<<#x<<" = "<<(x)<<endl;
#define fir			first
#define sec			second

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<string> vs;

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();}
vs form(string a,char s){vs v;string b;rep(i,a.lgt){if(a[i]==s){v.pb(b);b="";}else b+=a[i];}v.pb(b);return v;}
vi formint(string a,char s){vi v;string b;rep(i,a.lgt){if(a[i]==s){v.pb(toInt(b));b="";}else b+=a[i];}v.pb(toInt(b));return v;}

const double EPS=1e-10,PI=acos(-1.0);
const int INF=2100000000;

int res[128], rank[128];
vector <P> ans;

int main(void)
{
	int n;
	cin >> n;
	int len = n * (n - 1) / 2;
	int a, b, c, d;
	for (int i = 0; i < len; i++){
		cin >> a >> b >> c >> d;
		if (c < d) res[b] += 3;
		else if (d < c) res[a] += 3;
		else { res[a]++;	res[b]++; }
	}
	for (int i = 1; i <= n; i++){
		ans.pb(mp(res[i], i));
	}
	RSORT(ans);
	
	int cnt = 1, num = 1;
	for (int i = 0; i < n; i++){
		if (ans[i].fir == ans[i + 1].fir){
			num++;
			rank[ans[i].sec] = cnt;
		}
		else {
			rank[ans[i].sec] = cnt;
			cnt += num;
			num = 1;
		}
	}
	
	for (int i = 1; i <= n; i++){
		cout << rank[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;

    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++)cin >> a[i] >> b[i];
    sort(a.begin(), a.end()), sort(b.begin(), b.end());

    if (n % 2 == 1)cout << b[n / 2] - a[n / 2] + 1 << endl;
    else cout << (b[n / 2] + b[n / 2 - 1]) - (a[n / 2] + a[n / 2 - 1]) + 1 << endl;
    return 0;
}

Measured memory_bytes: 4788
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

ll N, M;

signed main(){
    cin >> N >> M;
    int k = M;
    REP(i, M){
        if(i % 2 == 0) cout << i / 2 + 1 << " " << i / 2 + 1 + k << endl;
        else cout << N - i / 2 - k << " " << N - i / 2 << endl;
        k--;
    }
    return 0;
}

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

#define ll long long
#define endl '\n'
#ifndef _WINDOWS
// no getchar_unlocked on Windows so just call getchar
#define getchar getchar_unlocked
#endif

template <typename Func>
inline void loop(int e, Func&& f) {
    for (int i = 0; i < e; i++) {
        std::forward<Func>(f)(i);
    }
}
template <typename Func>
inline void loop(int s, int e, Func&& f) {
    for (int i = s; i < e; i++) {
        std::forward<Func>(f)(i);
    }
}
template <typename T>
inline void scanpn(T& num) {
    register int c;
    num = 0;
    c = getchar();
    for (; (c > 47 && c < 58); c = getchar()) num = num * 10 + c - 48;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << ' ' << x << ' ' << y << endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<pair<int,int> > D(N);
  for(int i=0;i<N;i++){
    cin >> D.at(i).first >> D.at(i).second;
  }
  bool flag=false;
  for(int i=0;i<N-2;i++){
    if(D.at(i).first==D.at(i).second){
      if(D.at(i+1).first==D.at(i+1).second){
        if(D.at(i+2).first==D.at(i+2).second){
          flag=true;
          break;
        }
      }
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3620
def myAnswer(N:int,A:list) -> int:
   counter = 0
   for i in range(N):
      if(A[A[i]-1] == i + 1):
         counter += 1
   return counter//2


def modelAnswer():
   tmp=1
def main():
   N = int(input())
   A = list(map(int,input().split()))
   print(myAnswer(N,A[:]))
if __name__ == '__main__':
   main()

Measured memory_bytes: 14008
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int i=0;
    double a[30000]={0};
    while(cin>>a[i]){
        i++;
    }
    sort(a,a+i);
    cout<<a[i-1]-a[0]<<endl;
    return 0;
}

Measured memory_bytes: 1528
import java.util.*;

public class Main {

    public static void main(String[] args) {
        List<String> list = new ArrayList<String>();
        String[] mark = {"S", "H", "C", "D"};

        for(int i = 0; i < 4; i++){
            for(int j = 0; j < 13; j++){
                list.add(mark[i] + " " + (j + 1));
            }
        }

        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.nextLine());

        for(int i = 0; i < n; i++){
            list.remove(sc.nextLine());
        }

        for(String str : list){
            System.out.println(str);
        }
    }
}

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

bool equVec(vector<int> a,vector<int> b){
  for(int i=0;i<a.size();i++){
    if(a[i] != b[i]) return false;
  }
  return true;
}

int main(){
  int n;
  cin>>n;
  vector<int> p(n),q(n);
  for(int i=0;i<n;i++) cin>>p[i];
  for(int i=0;i<n;i++) cin>>q[i];

  bool flag=0;
  for(int i=0;i<n;i++){
    if(p[i]>q[i]){
      flag = true;
      break;
    }else if(p[i] < q[i]){
      flag = false;
      break;
    }
  }

  vector<int> v(n),w(n);
  for(int i=0;i<n;i++){
    if(flag){
      v[i] = q[i];
      w[i] = p[i];
    }else{
      v[i] = p[i];
      w[i] = q[i];
    }
  }

  long long cnt = 0;
  while(!equVec(v,w)){
    cnt++;
    /*
    for(int i=0;i<n;i++){
      cout << v[i];
      if(i!=n-1)cout<<" ";
      else cout<<endl;
    }*/
    next_permutation(v.begin(),v.end());
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,u,t[13],ans=1000000000,s[25],e;
void find(int x,int y){
	if(x==13){
		ans=max(ans,y);
		return;
	}
	if(t[x]==1){
		int d=y;
		for(int i=24-x-1;i>0;i--){
			if(s[i]==1){
				d=min(d,24-x-i);
				break;
			}
		}
		for(int i=24-x+1;i<24;i++){
			if(s[i]==1){
				d=min(d,i+x-24);
				break;
			}
		}
		s[24-x]=1;
		find(x+1,d);
		s[24-x]=0;
		d=y;
		for(int i=x-1;i>0;i--){
			if(s[i]==1){
				d=min(d,x-i);
				break;
			}
		}
		for(int i=x+1;i<24;i++){
			if(s[i]==1){
				d=min(d,i-x);
				break;
			}
		}
		s[x]=1;
		find(x+1,d);
		d=y;
		s[x]=0;
	}
	else find(x+1,y);
	return;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&u);
		t[u]++;
		ans=min(ans,u);
	}
	if(t[0]==1){
		printf("0");
		return 0;
	}
	for(int i=1;i<=12;i++){
		if(t[i]==2)ans=min(ans,24-i-i),s[i]=1,s[24-i]=1;
		else if(t[i]>=3)ans=0;
	}
	if(ans==0){
		printf("0");
		return 0;
	}
	else{
		e=ans;
		ans=0;
		find(1,e);
	}
	printf("%d",ans);
	return 0;
}

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


int main() {
	int tate, yoko;

	while (true) {
		cin >> tate >> yoko;
		if (tate == 0 && yoko == 0)
			break;
		for (int i = 0; i < tate; i++)
			for (int j = 1; j <= yoko; j++) {
				if (j < yoko)
					cout << "#";
				else
					cout << "#" << "\n";
			}
		cout << "\n";
	}
}

Measured memory_bytes: 1120
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

n = int(input())
s = [ input() for _ in range(n) ]

ans = len(list(set(s)))

print(ans)

Measured memory_bytes: 110992
package main

import "fmt"

// 2018-08-09T23:03:56+0800
// 2018-08-09T23:08:44+0800
func main() {
	var N int
	fmt.Scanf("%d", &N)
	A := make([]int, N+2)
	sum := 0
	sum += diff(A[0], A[1])
	for i := 1; i < N+1; i++ {
		fmt.Scanf("%d", &A[i])
		sum += diff(A[i], A[i-1])
	}
	sum += diff(A[N], A[N+1])
	for i := 1; i < N+1; i++ {
		fmt.Println(sum + diff(A[i-1], A[i+1]) - diff(A[i-1], A[i]) - diff(A[i], A[i+1]))
	}
}

func diff(a, b int) int {
	c := a - b
	if c < 0 {
		return -c
	}
	return c
}

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

using ll = long long;

#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	string t;
	cin>>t;

	int n=len(t);

	for(int i=0; i<n; i++)
	{
		if(t[i]=='?') t[i]='D';
	}

	cout << t << endl;
	return 0;

	int ans=int(t[n-1]=='D');

	for(int i=0; i<n-1; i++)
	{
		if(t[i]=='D') ans++;
		if(t[i]=='P'&&t[i+1]=='D') ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  vector<int>copy(n);
  for(int i=0;i<n;i++){
    copy.at(i)=a.at(i);
  }
  sort(copy.begin(),copy.end());
  for(int i=0;i<n;i++){
    if(a.at(i)!=copy.at(n-1)){
      cout << copy.at(n-1) << endl;
    }
    else{
      cout << copy.at(n-2) << endl;
    }
  }
}
      

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	string s;
    cin >> s;
    const int mod = 1e9 + 7;
    vector<int> v1(13, 0), v2(13, 0);
    v1[0] = 1;
    for (int i = 0; i < s.size(); i++) {
        v2 = vector<int>(13, 0);
        if (s[i] == '?') {
            for (int k = 0; k <= 9; k++) {
                for (int j = 0; j < 13; j++) {
                    v2[(j * 10 + k) % 13] += v1[j];
                    v2[(j * 10 + k) % 13] %= mod;    
                }
            }
        } else {
            int num = s[i] - '0';
            for (int j = 0; j < 13; j++) {
                v2[(j * 10 + num) % 13] += v1[j];
                v2[(j * 10 + num) % 13] %= mod;
            }
        }
        v1 = v2;
    }
    cout << v1[5] % mod << endl;
}


Measured memory_bytes: 3732
#include <iostream>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
#include<memory.h>
#include <vector>
#include<algorithm>
using namespace std;
struct op
{
    int s;
    int d;
    op(int s,int d)
    {
        this->s=s;
        this->d=d;
    }
};



int arr[109];
int n_element;
int has_reverse;
vector<op> ops;

int n_ops;

void reverse_op()
{
        for(auto & o:ops)
        {
            o.d=n_element-1-o.d;
            o.s=n_element-1-o.s;
        }

}
void reverse_arr()
{
    for(int i=0;i<n_element/2;i++)
    {
        swap(arr[n_element-1-i],arr[i]);
    }
    for(int i=0;i<n_element;i++)
    {
        arr[i]*=-1;
    }
}
void regulate()
{
    has_reverse=0;
    int max_abs=0;
    int loc=-1;
    for(int i=0;i<n_element;i++)
    {
        if(abs(arr[i])>=max_abs)
        {
            max_abs=abs(arr[i]);
            loc=i;
        }
    }
    if(arr[loc]<0)
    {
        has_reverse=1;
        reverse_arr();
        loc=n_element-1-loc;
    }

    if(loc!=1)
    {
            ops.push_back(op(loc,1));
    }
    ops.push_back(op(loc,1));


        for(int i=2;i<n_element;i++)
        {
           ops.push_back(op(i-1,i));
           if(i!=loc)
           {
              ops.push_back(op(loc,i));
           }
        }

    if(has_reverse)
    {
        reverse_op();
    }
}

main()
{
    cin>>n_element;
    for(int i=0;i<n_element;i++)
    {
        cin>>arr[i];
    }
    regulate();
    cout<<ops.size()<<endl;
    for(auto & o:ops)
    {
        arr[o.d]+=arr[o.s];
        cout<<o.s+1<<" "<<o.d+1<<endl;
    }
//    for(int i=0;i<n_element;i++)
//    {
//        cout<<arr[i]<<" ";

//    }
}


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

using namespace std;

void chmin(Int& a, Int b) { if (a > b) { a = b; } };
Int calc(Int a, Int b, Int c) {
	return max({ a, b, c }) - min({ a, b, c });
}

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

	Int ans = 1e18;
	chmin(ans, W * (H % 3 > 0 ? 1 : 0));
	chmin(ans, H * (W % 3 > 0 ? 1 : 0));

	for (Int h = 1; h < H; ++h) {
		Int s1 = h * W;
		Int s2 = (H - h) * (W / 2);
		Int s3 = (H - h) * ((W + 1) / 2);
		chmin(ans, calc(s1, s2, s3));
	}
	for (Int w = 1; w < W; ++w) {
		Int s1 = w * H;
		Int s2 = (W - w) * (H / 2);
		Int s3 = (W - w) * ((H + 1) / 2);
		chmin(ans, calc(s1, s2, s3));
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n,i;
  long long int shoji=1000,kabu=0;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n-1;i++){
    if(a[i]<a[i+1]){
      kabu = shoji/a[i];
      shoji = shoji - kabu*a[i];
      shoji = shoji + kabu*a[i+1];
      kabu = 0;
    }
  }
  printf("%lld",shoji);
  return 0;
}


Measured memory_bytes: 1708
import collections

N = int(input())
S = [0]*N
for i in range(N):
  S[i] = input()

dic = collections.Counter(S)
max_value = max(dic.values())

A = []

for k, v in dic.items():
  if v == max_value:
    A.append(k)

A = sorted(A)

for i in A:
  print(i)

Measured memory_bytes: 99912
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

b = [false] * n

# ループになってるところを探す
visit = []
place = 1

loop do
  b[place - 1] = true
  visit << place
  place = a[place - 1]
  break if b[place - 1]
end

lstrt = visit.find_index place
steps = visit[0...lstrt]
cycle = visit - steps

if k < lstrt
  puts steps[k]
else
  puts cycle[(k - steps.length) % cycle.length]
end


Measured memory_bytes: 37776
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
const int MAXN=500010;
int POW(int x,int k)
{
	int ans=1;
	for (;k;k>>=1,x=1LL*x*x%MOD) if (k&1) ans=1LL*ans*x%MOD;
	return ans;
}
int N,K,fac[MAXN],inv[MAXN];
void pre()
{
	N=500000;
	fac[0]=1;
	for (int i=1;i<=N;++i) fac[i]=1LL*fac[i-1]*i%MOD;
	inv[N]=POW(fac[N],MOD-2);
	for (int i=N-1;i>=0;--i) inv[i]=1LL*inv[i+1]*(i+1)%MOD;
}
int cal(int n,int m)
{
	if (n<m) return 0;
	return 1LL*fac[n]*inv[n-m]%MOD*inv[m]%MOD;
}
int main()
{
	pre();
	cin>>N>>K;
	long long Ans=0;
	K=min(N-1,K);
	for (int i=0;i<=K;++i) Ans+=1LL*cal(N,i)*cal(N-1,N-i-1)%MOD;
	Ans%=MOD;
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#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 mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << min(a, b) + min(c, d) << endl;

  return 0;
}

Measured memory_bytes: 256
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    s = list(map(int,input()))[::-1]
    d = defaultdict(int)
    ans = 0
    ni = 0
    mod = 2019
    d[0] = 1
    n10 = 1
    for i in s:
        ni = (ni+i*n10)%mod
        d[ni] += 1
        n10 = (n10*10)%mod
    for i in d.values():
        ans += i*(i-1)//2
    print(ans)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 79480
local s = io.read()
local n = #s
local pos = 1
local f = false

pos = s:find("KIH", pos)
if pos == 1 or (pos == 2 and s:sub(1, 1) == "A") then
  pos = pos + 3
  local bpos = s:find("B", pos)
  if bpos and bpos < n then
    if bpos == pos or (bpos == pos + 1 and s:sub(pos, pos) == "A") then
      local rpos = s:find("R", bpos)
      if rpos then
        if rpos == bpos + 1 or (rpos == bpos + 2 and s:sub(bpos + 1, bpos + 1) == "A") then
          if rpos == n or (rpos == n - 1 and s:sub(n, n) == "A") then
            f = true
          end
        end
      end
    end
  end
end

print(f and "YES" or "NO")


Measured memory_bytes: 760
from queue import Queue
h, w = map(int, input().split())

fie = [list(input())for i in range(h)]
dx, dy = [0, 1, 0, -1], [1, 0, -1, 0]


cant = 0
que = Queue()
que.put([0,0])

while not que.empty():
        px, py = que.get()
        fie[px][py] = "."
        under = right = 0
        for i in range(4):
                if 0<=px+dx[i]<h and 0<=py+dy[i]<w and fie[px+dx[i]][py+dy[i]]=="#":
                        if i==2 or i==3: cant = 1
                        else:
                                if i==0: under = 1
                                elif i==1: right = 1
                                que.put([px+dx[i],py+dy[i]])
        if under and right: cant = 1

if cant: print("Impossible")
else: print("Possible")

Measured memory_bytes: 4464
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])
      
  if temp!=1:
    arr.append([temp, 1])
    
  if arr==[]:
    arr.append([n, 1])
    
  return arr

a = factorization(int(input()))
b = [1, 3, 6, 10, 15, 21, 28, 36, 43]

ans = 0

if len(a) == 1 and a[0][0] == 1:
  print(0)
  exit()
  
for i in a:
  for j in range(len(b)):
    if i[1] < b[j]:
      ans+=j
      break
    
print(ans)


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

int main() {
  int N;
  cin >> N;
  vector<int> card(N);
  for (int i=0; i<N; i++){
    cin >> card.at(i);
  }
  
  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());
  
  int k=0;
  for (int i=0; i<N; i++){
    if (i%2==0){
      k=k+card.at(i);
    }
    else
      k=k-card.at(i);
  }
  cout << k << endl;
}

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

int main(){
	int a,b;
	cin>>a>>b;
	
	if(a*b%2==0) cout << "Even" << endl;
	else cout << "Odd" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> botton(N);
  for(int i = 0; i < N; i++){
    cin >> botton.at(i);
  }
  int light = 1, cnt;
  for(int i = 0; i < N; i++){
    light = botton.at(light - 1);
    cnt++;
    if(light == 2)
      break;
  }
  if(light == 2)
    cout << cnt << endl;
  else
    cout << -1 << endl;
}

Measured memory_bytes: 640
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var m = intShift();
  var d = intShift();
  
  var sum = m - 1;
  if(m <= d)sum++;
  
  return ~~sum;
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
12 11
`);

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

struct point {
	long long x, y;
};
using data_Ty = long long;

data_Ty ccw(data_Ty ax, data_Ty ay, data_Ty bx, data_Ty by, data_Ty cx, data_Ty cy) {
	return bx*cy - ay*bx - ax*cy - by*cx + ax*by + ay*cx;
}
data_Ty ccw(point a, point b, point c) {
	return b.x*c.y - a.y*b.x - a.x*c.y - b.y*c.x + a.x*b.y + a.y*c.x;
}


data_Ty abss(data_Ty a) {
	if (a < 0)return -a;
	return a;
}
struct segment {
	point a;
	point b;

	long long diffX() {
		return b.x - a.x;
	}
	long long diffY() {
		return b.y - a.y;
	}
	long long sign(long long a) {
		if (a > 0) return 1;
		if (a < 0)return -1;
		return 0;
	}

	bool intersect(segment p) {
		long long a1 = ccw(a, b, p.a);
		long long a2 = ccw(a, b, p.b);
		long long b1 = ccw(p.a, p.b, a);
		long long b2 = ccw(p.a, p.b, b);

		bool A = sign(a1)*sign(a2) < 0;
		bool B = sign(b1)*sign(b2) < 0;
		if (A&&B) {
			return true;
		}
		return false;
	}


};
struct node {
	point a;
	double degree;
	double length;
	int idx;
	bool operator<(const node& p) {
		if (a.y == 0 && p.a.y==0) {
			return length < p.length;
		}
		else if(a.x==0 && p.a.x==0){
			return length > p.length;
		}
		return degree < p.degree;
	}
};
using std::vector;
long long r, c;
bool chk2[100010];
bool chk(long long x1, long long y1) {
	return x1 == r || x1 == 0 || y1 == 0 || y1 == c;
}
int main() {
	int n;
	scanf("%lld%lld%d", &r, &c, &n);
	vector<segment> seg;
	for (int i = 0; i < n; i++) {
		long long x1, y1, x2, y2;
		scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2);
		if (chk(x1, y1) && chk(x2, y2)) {
			seg.push_back({ {x1,y1},{x2,y2} });
		}
	}
	vector<node> sweep;
	for (int i = 0; i < seg.size(); i++) {
		point& a = seg[i].a;
		point& b = seg[i].b;
		sweep.push_back({ a,atan2(a.y,a.x),hypot(a.x,a.y),i });
		sweep.push_back({ b,atan2(b.y,b.x),hypot(b.x,b.y),i });
	}
	std::sort(sweep.begin(), sweep.end());
	std::vector<int> stack;

	bool ans = true;
	for (node& p : sweep) {
		if (!chk2[p.idx]) {
			stack.push_back(p.idx);
			chk2[p.idx] = true;
		}
		else {
			if (stack.back() != p.idx) {
				ans = false;
				break;
			}
			stack.pop_back();
		}
	}

	
	if (ans) {
		printf("YES");
	}
	else {
		printf("NO");
	}
}

Measured memory_bytes: 18536
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)
#define MP make_pair
typedef long long LL;
#define EPS (1e-6)
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef pair<int,int> P;

int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);
  int INF = 1000000;

  int a,b;
  while(cin>>a>>b){
    cout << a+b << endl;
  }

  return 0;
}

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

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

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

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

template<class T>
bool chmax(T &a, initializer_list<T> l)
{
	return chmax(a, *max_element(l.begin(), l.end()));
}

template<class T>
bool chmin(T &a, initializer_list<T> l)
{
	return chmin(a, *min_element(l.begin(), l.end));
}

ll MAX_B = 50;
ll dp[100][2];

int main(int argc, char **argv)
{
	ll N, K; cin >> N >> K;
	vector<ll> A(N); REP(i, N) cin >> A[i];

	REP(i, 100) dp[i][1] = dp[i][0] = -1;
	**dp = 0;

	REP(bi, MAX_B)
	{
		ll mask = 1ll << (MAX_B - bi - 1);

		ll cnt1{0};
		REP(i, N)
		{
			if (mask & A[i]) ++cnt1;
		}

		ll add0 = cnt1 * mask;
		ll add1 = (N-cnt1) * mask;

		if (dp[bi][true] != -1)
			chmax(dp[bi+1][true], dp[bi][true] + max(add0, add1));

		if (dp[bi][false] != -1)
			if (mask & K)
				chmax(dp[bi+1][true], dp[bi][false] + add0);

		if (dp[bi][false] != -1)
		{
			if (mask & K) chmax(dp[bi+1][false], dp[bi][false] + add1);
			else chmax(dp[bi+1][false], dp[bi][false] + add0);
		}
	}
	
	std::cout << max(dp[MAX_B][false], dp[MAX_B][true] )<< std::endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
  int a[1000],b[1000],c[1000],n,i;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d%d%d",&a[i],&b[i],&c[i]); 
  for(i=0;i<n;i++){
    if(a[i]*a[i]==(b[i]*b[i]+c[i]*c[i])||b[i]*b[i]==(c[i]*c[i]+a[i]*a[i])||c[i]*c[i]==(a[i]*a[i]+b[i]*b[i]))
      printf("YES\n");
    else
      printf("NO\n");
  }
  return(0);
}

  

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

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;

int main()
{
  int n,ans=0,lasta=0,firstb=0,con=0;
  cin>>n;
  rep(j,n)
  {
    string s;
    cin>>s;
    int len=s.size();

    rep(i,len-1)
    {
      if(s.at(i)=='A' && s.at(i+1)=='B') ans++;
    }

    if(s.at(0)=='B') firstb++;
    if(s.at(len-1)=='A') lasta++;
    if(s.at(len-1)=='A' && s.at(0)=='B') con++;
  }

  if(firstb==0 && lasta==0) ans+=0;
  else if(con==firstb && con==lasta) ans+=(con-1);
  else ans+=min(firstb,lasta);

  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int>P;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n,W;
const int Maxn=105;
const int Maxw=2e5+5;
int w[Maxn];
ll v[Maxn];
ll dp[Maxw];
int main(){
	cin>>n>>W;
	rep(i,n){
		cin>>w[i]>>v[i];
	}
	rep(i,Maxw)dp[i]=-1e17;
	dp[0]=0;
	rep(i,n){
		for(int j=W;j>=0;j--){
			chkmax(dp[j+w[i]],dp[j]+v[i]);
		}
	}
	ll ans=0;
	rep(i,W+1)chkmax(ans,dp[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
ll mod = 1000000007LL;



int main() {
	string s;
	cin >> s;
	int size = s.size();
	vector<ll> dp(13, 0);
	dp[0] = 1;

	for(char c : s) {
		vector<ll> ndp(13, 0);
		rep(i, 10) if (c == '?' || c - '0' == i) rep(j, 13) {
			int d  = (j * 10 + i) % 13;
			ndp[d] = dp[j] + ndp[d];
			ndp[d] %= mod; 
		}
		dp = move(ndp);
	}


	cout << dp[5] << endl;

	return 0;
}


Measured memory_bytes: 3288
#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; }

int main() {
    int N, M;
    cin >> N >> M;
 
    vector<vector<int>> paid(M + 1);
    rep(i,N) {
        int a, b;cin >> a >> b;
        if (a > M) continue;
        paid[a].push_back(b);
    }
 
    int ans = 0;
    priority_queue<int> que;
    for (int i = 0; i <= M; ++i) {
        for (auto b : paid[i]) que.push(b);
 
        if (!que.empty()) {
            ans += que.top();
            que.pop();
        }
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5632
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[110];
int main(){
	int a;scanf("%d",&a);
	scanf("%s",in);
	int mi=0;
	int now=0;
	for(int i=0;i<a;i++){
		if(in[i]=='(')now++;
		else now--;
		mi=min(mi,now);
	}
	for(int i=0;i<-mi;i++)printf("(");
	now-=mi;
	printf("%s",in);
	for(int i=0;i<now;i++)printf(")");
		printf("\n");
}


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, m;
    cin >> n >> m;
    cout << (n == m ? "Yes" : "No") << endl;
}

int main()
{
    solve();
    return 0;
}


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

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

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

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define MP(a,b) make_pair((a), (b))
#define ROUNDUP(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second
#define DEBUG(a) cout << #a << ": " << a << "\n"
// #define DEBUG(a) {}

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 4 * 1e18 + 1;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

template<typename T>
T debug(T x) {
	DEBUG(x);
	return x;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, y;
	cin >> n >> y;
	y -= n * 1000;
	for(int i = 0; i <= n; ++i){
		for(int j = 0; i + j <= n; ++j){
			int sum = 4000 * i + 9000 * j;
			if(y == sum){
				cout << j << " " << i << " " << (n - i - j) << "\n";
				return 0;
			}
		}
	}
	cout << "-1 -1 -1\n";
	return 0;
}


Measured memory_bytes: 256
x = int(input())

i = 0
tmp = []
for i in range(10 ** 5):
    tmp.append([i ** 5, i])
    tmp.append([(-i) ** 5, -i])
    i += 1

tmp.sort()

tmpset = set([t[0] for t in tmp])

for i in range(len(tmp)):
    if x + tmp[i][0] in tmpset:
        break

b = tmp[i][1]
a5 = x + tmp[i][0]

for j in range(len(tmp)):
    if tmp[j][0] == a5:
        break

a = tmp[j][1]

print(a, b)


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

using namespace std;

const int N = 1010;

char mat[N][N];

vector<string> S[20];

void fb(){
	S[3] = {"acc","a.d","bbd"};
	S[4] = {"adee", "adff", "bbgh", "ccgh"};
	S[5] = {"adf..", "adf..", "beehh", "b.gii", "ccgjj"};
	S[6] = {"adgg..", "adhh..", "beii..", "be..jj", "cf..kk", "cf..ll"};
	S[7] = {"adff...", "adgg...", "beehh..", "b...ikk", "cc..ill", "....jmn", "....jmn"};
	S[11] = {"adg........", "adg........", "beh........", "beh........", "cfii.......", "cf.jj......", "...kllo....", "...kmmo....", ".....nnqqtt", "......prruu", "......pssvv"};
}

void fill(int sx, int sy, int step, int count){
	if(count == 0)
		return;
	for(int i=0 ; i<S[step].size() ; i++)
		for(int j=0 ; j<S[step][i].size() ; j++)
			mat[sx + i][sy + j] = S[step][i][j];
	fill(sx+step, sy+step, step, count-1);
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    fb();
    int n;cin >> n;
    if(n<3){
    	cout << "-1\n";
    	return 0;
    }
    if(n == 3 || n == 7 || n == 11){
    	for(auto s : S[n])
    		cout << s << "\n";
    	return 0;
    }
    for(int i=0 ; i<n ; i++)
    	for(int j=0 ; j<n ; j++)
    		mat[i][j] = '.'; 
    for(int i=0 ; i<=n/4 ; i++){
    	int m = n - 4*i;
    	if(m%5 == 0){
    		fill(0, 0, 4, i);
    		fill(4*i, 4*i, 5, m/5);
    		break;
    	}
    	if(m%6 == 0){
    		fill(0, 0, 4, i);
    		fill(4*i, 4*i, 6, m/6);
    		break;
    	}
    }
    for(int i=0 ; i<n ; i++){
    	for(int j=0 ; j<n ; j++)
    		cout << mat[i][j];
    	cout << "\n";
    }
}




























Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
/*
	vec1.size();
	str1.length();
	vec1.pop_back;
*/
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<pll> vplll;
#define rep(i,l,r) for (ll i = l; i < r; ++i)
#define reprev(i,l,r) for (ll i = r; i >= l; --i)
ll mod = 1e9+7;
ll expo_mod(ll x, ll y, ll p) 
{ 
	ll res = 1;
	x = x % p; 
	if (x == 0) 
		return 0; 
	while (y > 0) 
	{
		if (y%2==1) 
			res = (res*x) % p; 
		y = y>>1; // y = y/2 
		x = (x*x) % p; 
	} 
	return res; 
} 
ll gcd(ll a,ll b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	string str1;
	set <string> s1;
	rep(i,0,n)
	{
		cin>>str1;
		s1.insert(str1);
	}
	ll ans=s1.size();
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 19140
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#define PI 3.14159265358979323846


int main(void) {
	
	int H, W, h, w;
	scanf("%d%d%d%d", &H, &W, &h, &w);

	printf("%d", H * W - (W* h) - (w * (H - h)));

	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T>& a) {
  os << "{";
  for (size_t i = 0; i < a.size(); ++i) os << (i > 0 ? "," : "") << a[i];
  return os << "}";
}

[[maybe_unused]] constexpr ll MOD = 1000000007;
[[maybe_unused]] constexpr int INF = 0x3f3f3f3f;
[[maybe_unused]] constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  string s;
  cin >> s;
  if (s.back() == 's')
    cout << s + "es";
  else
    cout << s + "s";
  return 0;
}


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

int N=0, M=0, k=0;
long long ans=0;

int main(){
  cin >> N >> M;
  // 繋がっているスイッチを格納するベクター
  vector<vector<int>> S(M, vector<int>(N));
  // 各電球に繋がっているスイッチの個数を格納しておく配列
  int K[M];
  // 2で割ったあまりの条件を格納しておく配列
  int P[M];
  // 入力をそれぞれに格納していく
  rep(m, M){
    cin >> K[m];
    rep(i, K[m]){
      cin >> S[m][i];
    }
  }
  rep(m, M){
    cin >> P[m];
  }

  // ここからソルバー
  // bit全探索やる
  // まずは電球のONOFFを表すフラグを2^Nだけ考える
  rep(mask, 1<<N){
    bool flag[N];
    rep(n, N){
      if (mask & (1<<n)) flag[n]=true;
      else flag[n]=false;
    }

    // 全ての電球について2で割ったあまりがPの条件に等しいかどうかを保存するcheckフラグ
    bool check=true;

    rep(m, M){
      // ONの場所はtrueつまり1が格納されているのでインクリメントしていく
      int sum_flag = 0;
      rep(idx, K[m]){
        sum_flag += flag[S[m][idx]-1];
      }
      // Pの条件にあっているかどうかを判断
      if (sum_flag % 2 != P[m]) check=false;
    }
    // checkがいまだにtrueであれば全ての電球についてtureであったということ
    if (check) ans++;
  }
// 解答出力
cout << ans << endl;
}

Measured memory_bytes: 256
object Main {
  case class Line(string: String) {
    def strings: Seq[String] = string.split(' ')
    def ints: Seq[Int] = strings.map(_.toInt)
    def doubles: Seq[Double] = strings.map(_.toDouble)
    def i(n: Int): Int = ints(n)
    def d(n: Int): Double = doubles(n)
  }

  def readLine: Line = Line(io.StdIn.readLine())
  def readLines(n: Int): Seq[Line] = List.fill(n)(Line(io.StdIn.readLine()))

  def yesNo(b: Boolean): String = if (b) "Yes" else "No"

  def main(args: Array[String]) {
    def read: Unit = {
      val ss: Seq[String] = readLine.strings
      val Seq(a, b) = List(ss(0).toInt, ss(2).toInt)
      val op: String = ss(1)

      if (op != "?") {
        val r: Int = op match {
          case "+" => a + b
          case "-" => a - b
          case "*" => a * b
          case "/" => a / b
        }
        println(r)
        read
      }
    }
    read
  }
}

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


int main(){
    int n; cin >> n;
    vector<int> a(n);
    int ma = -1;
    rep(i,n){
        cin >> a[i];
        ma = max(ma,a[i]);
    }
    int r=0, di = INF;
    rep(i,n){
        if(a[i]==ma)continue;
        if(di > abs( (ma/2)-a[i]) ){
            di = abs( (ma/2)-a[i] );
            r = a[i];
        }
    }
    cout << ma << " " << r << endl;
}

Measured memory_bytes: 3788
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int a,b,c;
    cin>>a>>b>>c;

    cout<<max(0,c-(a-b))<<endl;

    return 0;
}





Measured memory_bytes: 256
a,b=map(int,input().split())
if b-a>=2019:
  print(0)
else:
  a=a%2019
  b=b%2019
  if a>=b:
    print(0)
  else:
    c=2019
    for i in range(a,b):
      for j in range(i+1,b+1):
        c=min(c,(i*j)%2019)
    
    print(c)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const int MOD = 1000000007;
        private const string Keyence = "keyence";
        static void Solve()
        {
            var s = Console.ReadLine();
            if(IsValidBack(s) || IsValidBack(s))
            {
                Console.WriteLine("YES");
            }else
            {
                bool ok = false;
                for(int i=1;i<=6;++i)
                {
                    string sz0 = Keyence.Substring(0, i);
                    string sz1 = Keyence.Substring(i, 7-i);
                    if( s.StartsWith(sz0) && s.EndsWith(sz1))
                    {
                        ok = true;
                        break;
                    }
                }
                string ans = ok ? "YES" : "NO";
                Console.WriteLine(ans);
            }
        }
        private static bool IsValidFront (string sz)
        {
            return sz.StartsWith(Keyence);
        }
        private static bool IsValidBack(string sz)
        {
            return sz.EndsWith(Keyence);
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

#define ma 123456789
int G[100][100];

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(n, k);
    if(!(n | k))break;
    rep(i, n)rep(j, n)G[i][j] = ma;

    for(;k--;){
      int(q);
      if(q){
        int3(c, d, e);
        --c; --d;
        G[c][d] = min(e, G[c][d]);
        G[d][c] = min(e, G[d][c]);
        rep(i, n)rep(j, n)G[i][j] = min(G[i][j], G[i][c] + G[c][j]);
        rep(i, n)rep(j, n)G[i][j] = min(G[i][j], G[i][d] + G[d][j]);

      }else{
        int2(a, b);
        --a; --b;
        if(G[a][b] == ma)puts("-1");
        else pri(G[a][b]);
      }
    }

//*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main(void){
    string S;
    cin >> S;
    int front;
    int back;
    front = atoi((S.substr(0,2).c_str()));
    back = atoi((S.substr(2,2).c_str()));
    if(front > 0 && front <= 12 ){
        if (back >0 && back <= 12){
            cout << "AMBIGUOUS";
        }
        else cout << "MMYY";
    }
    else if (back >0 && back <= 12){
        cout << "YYMM";
    }
    else cout << "NA";
}

Measured memory_bytes: 256
S = input()
X,Y = map(int,input().split())

x = True # x軸方向を向いている

Slist = []
import itertools
for key,g in itertools.groupby(S):
  num = len(list(g))
  Slist.append((key, num))
  
xdp = set()
ydp = set([0])
ind = 0

if Slist[0][0] == "F":
  xdp.add(Slist[0][1])
  ind += 1
else:
  xdp.add(0)
  
for i in range(ind, len(Slist)):
  if Slist[i][0] == "T":
    if Slist[i][1] % 2 == 1:
      x ^= True
    continue
  step = Slist[i][1]
  if x:
    next_dp = set()
    for xpos in xdp:
      next_dp.add(xpos + step)
      next_dp.add(xpos - step)
    xdp = next_dp
  else:
    next_dp = set()
    for ypos in ydp:
      next_dp.add(ypos + step)
      next_dp.add(ypos - step)
    ydp = next_dp
    
if X in xdp and Y in ydp:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 10240