akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#pragma GCC optimize ("Ofast")

using namespace std;
#define ms(x,a) memset(x,a,sizeof x)
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7,seed=131,MAXN=0;

int main(){
    cin.tie(0)->sync_with_stdio(0);
    map<string,int> m;
    string uwu; int n; cin >> n;
    for (int i=0;i<n;++i){
        cin >> uwu;
        m[uwu]++;
    }
    cout << "AC x " << m["AC"] << '\n';
    cout << "WA x " << m["WA"] << '\n';
    cout << "TLE x " << m["TLE"] << '\n';
    cout << "RE x " << m["RE"] << '\n';
}

Measured memory_bytes: 3660
import java.util.Scanner;
public class Main {
    public static int a;
    public static int b;
    public static String op;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            a = sc.nextInt();
            op= sc.next();
            b = sc.nextInt();
            switch(op){
                case "?" :{
                    sc.close();
                    return;
                }
                case "*": System.out.println (a*b); break;
                case "+": System.out.println (a+b); break;
                case "-": System.out.println (a-b); break;
                case "/": System.out.println (a/b); break;
            }
        }
    }
}


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

int main(){
    int a, b;
    while(cin >> a >> b){
        if(a == 0 && b == 0)return 0;
        for(int i=0; i < a; i++){
            for(int j=0; j < b; j++){
                if(i == 0 || i == a-1 || j == 0 || j == b-1)cout << '#';
                else cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 2992
import numpy as np
n,s=map(int,input().split())
a=list(map(int,input().split()))
mod=998244353
f=np.zeros(3001,int)

ans=0
for ai in a:
  ff=np.zeros(3001,int)
  ff+=f
  ff[ai:]+=f[:-ai]
  ff[0]+=1
  ff[ai]+=1
  f=ff
  f%=mod
  ans+=f[s]
  ans%=mod
print(ans)



Measured memory_bytes: 12488
#include <bits/stdc++.h>
using namespace std;
int digit(int n){
    int a=n%10;
    n/=10;
    while(n){
        if((a-(n%10))!=1){
            return 0;
        }
        a=n%10;
        n/=10;
    }
    return 1;
}
int main()
{
    int n;
    scanf("%d",&n);
    int i,ar[1001],num[100001];
    for(i=0; i<n; i++){
        scanf("%d",&num[i]);
    }
    int j,k;
    int mx=-1;
    for(i=0; i<n; i++){
        int prod;
        for(j=i+1; j<n; j++){
            prod=num[i]*num[j];
            if(digit(prod)) mx=max(mx,prod);
        }
    }
    printf("%d\n",mx);
    return 0;
}

Measured memory_bytes: 3240
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  ll n,a,b; 
  cin >> n >> a >> b;
  ll ans = 0;
  ll c = n / (a+b);
  n -= c*(a+b);
  
  ans += c * a;
  if(n >= a) ans += a;
  else ans += n;

  cout << ans << endl;
  
}

Measured memory_bytes: 3632
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var k = int.Parse(spl[1]);
        var ary = ToIntArray(input.ReadLine(), k);

        var tbl = new int[10];
        foreach(var x in ary) {
            tbl[x] = 1;
        }

        Func<long, bool> f = (v) => {
            var x = v;
            while(v != 0) {
                if(tbl[v % 10] > 0) return false;
                v /= 10;
            }
            return true;
        };

        long y = n;
        while (true) {
            if(f(y)) break;
            y++;
        }

        return y;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main(){
  int i, len, ans=100000;
  char s[12];
  cin >> s;
  len = strlen(s);
  for(i=0; i<len-2; i++){
    ans=min(abs((s[i]-'0')*100+(s[i+1]-'0')*10+s[i+2]-'0'-753),ans);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
ans = 0
A = []
for i in range(N):
    A.append(list(map(int,input().split())))
    S = C
    for j in range(M):
        S += A[i][j] * B[j]
    if S > 0:
        ans += 1
    else:
        ans += 0
print(ans)

Measured memory_bytes: 3064
n = input()
a = map(int, raw_input().split())
b = map(int, raw_input().split())
c = map(int, raw_input().split())
ans = 0
for i in range(n):
    ans = ans + b[i]
for i in range(n-1):
    if a[i+1] - a[i] == 1:
        ans += c[a[i]-1]
print ans


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

using namespace std;

int main(){
    int n;
    cin >> n;
    long long ans = 0;
    for(int i=1; i<n; i++){
        int t = n/i;
        if(n%i==0) t--;
        // cout << i << ' ' << t << "\n";
        ans += t;
    }
    cout << ans;
}

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


int main()
{

   ll a,b,d;
   cin>>a>>b>>d;
   if(a%d==0){
    cout<<b/d-a/d+1<<endl;
   }
   else{cout<<b/d-a/d<<endl;}

    return 0;
}

Measured memory_bytes: 3592
def solve(inp):
    N = int(inp.readline().strip())
    XY = [[] for i in range(N)]
    for i in range(N):
        a = int(inp.readline().strip())
        XY[i] = [list(map(int, inp.readline().strip().split(' '))) for j in range(a)]

    r = 0
    for b in range(1, pow(2, N)):
        f = True
        for i in range(N):
            if b & (1 << i) != 0:
                for (x, y) in XY[i]:
                    if y == 1 and b & (1 << (x - 1)) == 0:
                        f = False
                        break
                    if y == 0 and b & (1 << (x - 1)) != 0:
                        f = False
                        break
                if not f:
                    break
        if f:
            rr = 0
            for i in range(N):
                if b & (1 << i) != 0:
                    rr += 1
            r = max([r, rr])

    return str(r)


def main():
    import sys
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  
  for (int i = 0; i < n-1; i++) {
    if (s[i][s[i].size()-1] != s[i+1][0]) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i - 1; j++) {
      if (s[i] == s[j]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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

const int N = 1e5 + 5;
int arr[N];
int n, a, b;
int d;

bool valid(ll step) {
    ll extra = 0;
    loop(i, n) {
        if (step > arr[i] / b)continue;
        ll need = arr[i] - step * b;
        if (need <= 0)continue;
        extra += (need + d - 1) / d;
    }
    return extra <= step;
}

ll bs(ll st, ll ed) {
    while (st < ed) {
        ll mid = st + (ed - st) / 2;
        if (valid(mid))
            ed = mid;
        else
            st = mid + 1;
    }
    return st;
}

int main() {

#ifndef ONLINE_JUDGE
    freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> a >> b;
    d = a - b;
    loop(i, n)cin >> arr[i];
    cout << bs(1, 1e15) << endl;

    return 0;
}


Measured memory_bytes: 4008
from itertools import product
#%%
def resolve():
    h,w=map(int,input().split())
    A=[list('.'+input()+'.') for _ in range(h)]
    A=[['.']*(w+2)]+A+[['.']*(w+2)]

    for i,j in product(range(1,h+1),range(1,w+1)):
        if A[i][j]=='.':
            A[i][j]=((A[i-1][j-1]=='#')+(A[i-1][j]=='#')+(A[i-1][j+1]=='#')
            +(A[i][j-1]=='#')+(A[i][j+1]=='#')
            +(A[i+1][j-1]=='#')+(A[i+1][j]=='#')+(A[i+1][j+1]=='#'))

    for i in range(1,h+1):
        print(*A[i][1:w+1],sep='')
resolve()

Measured memory_bytes: 43376
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int n; cin >>n;

    int f = n/100;
    int s = n - f*100;

    if(1 <= f && f <= 12) {
        if(1 <= s && s <= 12) {
            cout << "AMBIGUOUS" << endl;
            return 0;
        } else {
            cout << "MMYY" << endl;
            return 0;
        } 
    } 
    if(f == 0 || f > 12) {
        if(1 <= s && s <= 12) {
            cout << "YYMM" << endl;
            return 0;
        }
    } 

    cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
I = list(map(int, input().split()))
cnt = 0
for i in range(N):
    min_index = i
    for j in range(i, N):
        if (I[j] < I[min_index]):
            min_index = j
    if (min_index != i):
        tmp = I[i]
        I[i] = I[min_index]
        I[min_index] = tmp
        cnt += 1

print(str(I).replace(',','').replace('[','').replace(']',''))
print(cnt)


Measured memory_bytes: 5596
n=int(input())
p=list(map(int,input().split()))
cnt = 0
for i in range(1,n-1):
    if p[i-1] < p[i+1]:
        a = True if p[i] > p[i-1] and p[i] < p[i+1] else False
    elif p[i-1] > p[i+1]:
        a = True if p[i] < p[i-1] and p[i] > p[i+1] else False
    if a:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
dist=[]
for x in range(0,5):
    dist.append(int(input()))
k=int(input())
sub=[]
for var1 in dist:
    for var2 in dist:
        if var1!=var2:
            sub.append(var2-var1)
max=max(sub)

if max<=k:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 1; i <= b; i++) {
	if ((a * i) % b == c) {
	  cout << "YES" << endl;
	  return 0;
	}
  }
  cout << "NO" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int INF = 2e9;
int main(){
  int N;
  cin >> N;
  int M = INF;
  for (int i = 0; i < N; i++){
    int A, B;
    cin >> A >> B;
    M = min(M, A + B);
  }
  cout << M;
}

Measured memory_bytes: 256
h,n=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
mx=max(a for a,b in ab)
dp=[10**10]*(h+1+mx)
dp[0]=0
for i in range(1,h+1+mx):
  dp[i]=min(dp[i-a]+b for a,b in ab)
print(min(dp[h:]))

Measured memory_bytes: 3832
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache
from numba import jit

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	n = I()
	a_list = LI()
	a_list.sort()
	ans = a_list[-1]
	if n % 2 == 0:
		for i in range(1,(n-2)//2+1):
			ans += a_list[-1-i]*2
	else:
		for i in range(1,(n-3)//2+1):
			ans += a_list[-1-i]*2
		ans += a_list[-1-(n-3)//2-1]
	print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 110604
n,m = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
ans = 0
for switch in range(1 << n):
    target = str(bin(switch))[2:]
    if len(target) < n:
        target = "0"*(n-len(target)) + target
    flag = True
    for i in range(m):
        count = 0
        for j in ks[i][1:]:
            if target[j-1] == "1":
                count += 1

        if count % 2 != p[i]:
            flag = False
    if flag:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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(b<a){a=b;return 1;}return 0;}

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,count=0;
	cin>>n;
	vector<int>h(n);
	rep(i,n)cin>>h[i];
	while(1){
		bool flag=true;
		rep(i,n)if(0<h[i])flag=false;
		if(flag)break;
		rep(i,n){
			if(i==0){
				if(0<h[i])count++;
			}else if(0<h[i]&&h[i-1]<=0)count++;
		}
		rep(i,n)h[i]--;
	}
	cout<<count<<endl;
}

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

const int NUM = 7;

void grooping(int y, int x, int w, int h, char** room, unsigned long*** group, unsigned long* next)
{
	if (room[y][x] != '#') {
		for (int i = y - 1; i <= y + 1; i++) {
			for (int j = x - 1; j <= x + 1; j++) {
				if (i < 0 || j < 0 || i >= h || j >= w) {
					continue;
				}
				if ((i == y && j != x) || (i != y && j == x)) {
					for (int k = 0; k < NUM; k++) {
						group[y][x][k] |= group[i][j][k];
					}
				}
			}
		}
		for (int i = 0; i < NUM; i++) {
			if (group[y][x][i] == 0UL && next[i] != 0UL) {
				group[y][x][i] |= next[i];
				next[i] <<= 1;
				break;
			}
		}
	}
}

int main()
{
	int w, h;
	while (true) {
		cin >> w >> h;
		if (w == 0 && h == 0) {
			break;
		}

		unsigned long next[NUM] = { 1UL, 1UL, 1UL, 1UL, 1UL, 1UL, 1UL };
		char** room = new char*[h];
		unsigned long*** group = new unsigned long**[h];
		int x, y;
		for (int i = 0; i < h; i++) {
			room[i] = new char[w];
			group[i] = new unsigned long*[w];
			for (int j = 0; j < w; j++) {
				cin >> room[i][j];
				if (room[i][j] == '@') {
					x = j;
					y = i;
				}
				group[i][j] = new unsigned long[NUM];
				for (int k = 0; k < NUM; k++) {
					group[i][j][k] = 0UL;
				}
			}
		}

		for (int k = 0; k < 50; k++) {
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					grooping(i, j, w, h, room, group, next);
				}
			}
			for (int i = h - 1; i >= 0; i--) {
				for (int j = w - 1; j >= 0; j--) {
					grooping(i, j, w, h, room, group, next);
				}
			}
			for (int j = 0; j < w; j++) {
				for (int i = 0; i < h; i++) {
					grooping(i, j, w, h, room, group, next);
				}
			}
			for (int j = w - 1; j >= 0; j--) {
				for (int i = h - 1; i >= 0; i--) {
					grooping(i, j, w, h, room, group, next);
				}
			}
		}

		int count = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				for (int k = 0; k < NUM; k++) {
					if ((group[i][j][k] & group[y][x][k]) != 0UL) {
						count++;
						break;
					}
				}
			}
		}

		cout << count << '\n';

		for (int i = 0; i < h; i++) {
			delete[] room[i];
			for (int j = 0; j < w; j++) {
				delete[] group[i][j];
			}
			delete[] group[i];
		}
		delete[] room;
		delete[] group;
	}

	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define dbg(x) cout<< #x << ": " << x << "\n";
using namespace std;
#define inf 1e9+7
#define PI  3.14159265358979323846264338327950L
#define pii pair<ll,ll> 



const int mx=1e4+2;
int ans[mx];
int  main(){
	ios_base::sync_with_stdio(0); 
	cin.tie(0); 
	cout.tie(0); 
	int n;
	cin>>n;
	for(int i=1; i<=sqrt(n); ++i){
		for(int j=1; j<=sqrt(n); ++j){
			for(int k=1; k<=sqrt(n); ++k){
				int p = i*i + j*j +k*k + i*j +j*k + i*k;
				if(p<mx) ans[p]+=1;
			}
		}
	}
	for(int i=0; i<n; ++i){
		cout<<ans[i+1]<<"\n";
	}
}
    

	




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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/04  Problem: ABC 097 C / Link: http://abc097.contest.atcoder.jp/tasks/abc097_c  ----- */


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

	string s; cin >> s;
	LL K; cin >> K;
	VS a;
	FOR(i, 0, SZ(s)) {
		string t = "";
		FOR(j, 0, K+1) {
			int k = i + j;
			if (k < SZ(s)) {
				t += s[k];
				a.push_back(t);
			}
		}
	}
	SORT(a); UNIQ(a);
	string ans = a[K-1];
	
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 2044
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s);
    let n :u32 = s.trim().parse().unwrap();
    let m :u32 = n % 10;
    if m == 2 || m == 4 || m == 5 || m == 7 || m == 9 {
        println!("hon")
    }else if m == 0 || m == 1 || m == 6 || m == 8 {
        println!("pon")
    }else{
        println!("bon");
    }
}

Measured memory_bytes: 2140
#include<iostream>
using namespace std;
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#define int long long int
#define mod 1000000007
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string str;
	cin>>str;
	int n=str.size();
	if(str[n-1]=='s')
	{
		str+="es";
	}
	else
	  str+="s";
	cout<<str<<endl;
}


Measured memory_bytes: 3652
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=5e5+69, INF=2e9+6969;

int qq;

int main()
{
	int n,k,mx=0,t[R];
	scanf("%d%d", &k, &n);
	//  scanf("%d%d", &k, &k);
	for(int i=0;i<n;++i) scanf("%d", &t[i]);
	mx = t[0];
	mx = max(mx,k-t[n-1]+t[0]);
	for(int i=1;i<n;++i)
	{
		mx=max(mx,t[i]-t[i-1]);
	}
	printf("%d\n", k-mx);
	return 0;
}


Measured memory_bytes: 4624
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
int a,b,c,x,y;
int main()
{
    scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
    printf("%d",min(a*x+b*y,min(min(x,y)*2*c+(x-min(x,y))*a+(y-min(x,y))*b,max(x,y)*2*c)));
    return(0);
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i =0; i < n; ++i)
        cin >> a[i];
    long long sum = 0;
    for (int i =0 ; i < n; ++i)
        for (int j = i + 1; j < n; ++j)
            sum += a[i] * a[j];
    cout << sum << '\n';
}


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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

#include <boost/range/algorithm.hpp> // boost::sort(arr)


int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> pref_city(n, vector<pair<int, int>>{});
  map<int, string> id;
  rep(i, m) {
    int p, y;
    cin >> p >> y;
    pref_city[p - 1].emplace_back(y, i);
  }
  rep(i, n) {
    boost::sort(pref_city[i]);
    string pref_id = to_string(i + 1);
    while (pref_id.size() < 6) {
      pref_id.insert(0, "0");
    }
    int cnt = 1;
    for (auto& year_city : pref_city[i]) {
      int city;
      tie(ignore, city) = year_city;
      string city_id = to_string(cnt);
      while (city_id.size() < 6) {
        city_id.insert(0, "0");
      }
      city_id.insert(0, pref_id);
      id[city] = city_id;
      ++cnt;
    }
  }
  rep(i, m) cout << id[i] << endl;
}


Measured memory_bytes: 19456
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

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

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

int N, M;
int h[1100000], v[1100000];
int a[1100], b[1100];

int main(){
    cin >> N >> M;
    fill(h, h+N*M+1, -1);
    fill(v, v+N*M+1, -1);
    for(int i = 0; i < N; i++){
        cin >> a[i];
        h[a[i]] = i;
    }
    for(int i = 0; i < M; i++){
        cin >> b[i];
        v[b[i]] = i;
    }
    
    ll res = 1;
    ll vline = 0, hline = 0;
    ll grid = 0;
    for(ll x = N*M; x >= 1; x--){
        // 2個現れた
        if(h[x] != -1 && v[x] != -1){
            grid += (vline + hline);
            vline++;
            hline++;
        }
        // 1個だけ(行)
        else if(h[x] != -1){
            grid += (vline-1);
            res = mul(vline, res);
            hline += 1;
        }
        // 1個だけ(列)
        else if(v[x] != -1){
            grid += (hline-1);
            res = mul(hline, res);
            vline += 1;
        }
        else{
            res = mul(grid, res);
            grid -= 1;
        }
    }

    cout << res << endl;

    return 0;

}



Measured memory_bytes: 10496
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
#define ll long long 
// #define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=2*1e5+2;

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

	int a[3];
	for(int i=0;i<3;i++)
	{
		cin>>a[i];
	}
	if(a[0]==a[1]&&a[0]!=a[2])
	{
		cout<<"Yes\n";
	}
	else if(a[0]==a[2]&&a[0]!=a[1])
	{
		cout<<"Yes\n";
	}
	else if(a[1]==a[2]&&a[1]!=a[0])
	{
		cout<<"Yes\n";
	}
	else cout<<"No\n";
} 
// I never lose. I either win or I learn


Measured memory_bytes: 256
#include<iostream>
#include <numeric>
// #include<string>
#include<vector>
#include <algorithm>
#include <cmath>
// #include <functional>

using namespace std;

int main()
{
    // Input
    int n, m;
    cin >> n >> m;

    int ans;
    ans = n*(n-1)/2 + m*(m-1)/2;

    cout << ans;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;
#define MAX_N (100010)


bool binarySearch( int S[], int n, int key );

int main()
{
    int n, q;
    int S[MAX_N];
    int ans = 0;
    scanf("%d", &n);
    for ( int i = 0; i < n; i++ ) {
	scanf("%d", &S[i]);
    }

    scanf("%d", &q);
    for ( int i = 0; i < q; i++ ) {
	int t;
	scanf("%d", &t);
	if ( binarySearch( S, n, t ) ) {
	    ans++;
	}
    }

    printf("%d\n", ans);
    return 0;
}


bool binarySearch( int S[], int n, int key )
{
    int left  = 0;
    int right = n;

    while( left < right ) {
	int mid = ( left + right ) >> 1;
	if ( S[mid] == key ) {
	    return true;
	}
	else if ( S[mid] < key ) {
	    left = mid + 1;
	}
	else if ( S[mid] > key ) {
	    right = mid;
	}
    }
    
    return false;
}

Measured memory_bytes: 1416
n = int(input())
A= list(map(int, input().split()))
B= list(map(int, input().split()))
r = 0
for i, b in enumerate(B):
    if b <= A[i]:
        r += b
    else:
        b -= A[i]
        r += A[i]
        if b <= A[i+1]:
            A[i+1] -= b
            r += b
        else:
            r += A[i+1]
            A[i+1]=0
            
print(r)

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

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

    vector<int> factor(n+1);
    for(int i = 2; i <= n; i++){
        int cur = i;
        for(int j = 2; j <= i; j++){
            while(cur % j == 0){
                factor[j]++;
                cur /= j;
            }
        }
    }

    auto num = [&](int m){
        int res = 0;
        for(auto p : factor){
            if(p >= m-1) res++;
        }
        return res;
    };

    cout << num(75) + num(25) * (num(3)-1) + num(15) * (num(5) - 1)
        + num(5) * (num(5)-1) / 2 * (num(3)-2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

#define NOT(x) ((x=='S') ? 'W' : 'S')

char s[200000];
char test[200000];

void func(int n) {
    test[n-1] = 'S';
    test[0] = 'S';
    for(int i=0; i<n; i++) {
        if(s[i] == 'o') {
            if(test[i] == 'S')
                test[(i+1)%n] = test[(i-1+n)%n];
            else
                test[(i+1)%n] = NOT(test[(i-1+n)%n]);
        } else {
            if(test[i] == 'W')
                test[(i+1)%n] = test[(i-1+n)%n];
            else
                test[(i+1)%n] = NOT(test[(i-1+n)%n]);
        }
    }
    if(test[n-1] == 'S' && test[0] == 'S') {
        puts(test);
        return;
    }

    test[n-1] = 'S';
    test[0] = 'W';
    for(int i=0; i<n; i++) {
        if(s[i] == 'o') {
            if(test[i] == 'S')
                test[(i+1)%n] = test[(i-1+n)%n];
            else
                test[(i+1)%n] = NOT(test[(i-1+n)%n]);
        } else {
            if(test[i] == 'W')
                test[(i+1)%n] = test[(i-1+n)%n];
            else
                test[(i+1)%n] = NOT(test[(i-1+n)%n]);
        }
    }
    if(test[n-1] == 'S' && test[0] == 'W') {
        puts(test);
        return;
    }

    test[n-1] = 'W';
    test[0] = 'S';
    for(int i=0; i<n; i++) {
        if(s[i] == 'o') {
            if(test[i] == 'S')
                test[(i+1)%n] = test[(i-1+n)%n];
            else
                test[(i+1)%n] = NOT(test[(i-1+n)%n]);
        } else {
            if(test[i] == 'W')
                test[(i+1)%n] = test[(i-1+n)%n];
            else
                test[(i+1)%n] = NOT(test[(i-1+n)%n]);
        }
    }
    if(test[n-1] == 'W' && test[0] == 'S') {
        puts(test);
        return;
    }

    test[n-1] = 'W';
    test[0] = 'W';
    for(int i=0; i<n; i++) {
        if(s[i] == 'o') {
            if(test[i] == 'S')
                test[(i+1)%n] = test[(i-1+n)%n];
            else
                test[(i+1)%n] = NOT(test[(i-1+n)%n]);
        } else {
            if(test[i] == 'W')
                test[(i+1)%n] = test[(i-1+n)%n];
            else
                test[(i+1)%n] = NOT(test[(i-1+n)%n]);
        }
    }
    if(test[n-1] == 'W' && test[0] == 'W') {
        puts(test);
        return;
    }
    puts("-1");
}

int main(void) {
    int n;
    scanf("%d",&n);
    scanf("%s",s);
    func(n);
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6+5;
#define pi acos(-1)
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX+10],cnt=0,spf[MAX+10],freq[MAX];
bool mark[MAX];
void solve(int n)
{
    if(mark[n])
        return;
    if(freq[n]==1)
        cnt++;
    for(int i=n; i<=1e6; i+=n)
        mark[i]=1;
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>arr[i];
        freq[arr[i]]++;
    }
    sort(arr+1,arr+n+1);
    for(int i=1; i<=n; i++)
    {
        solve(arr[i]);
    }
    cout<<cnt<<endl;


    return 0;
}


Measured memory_bytes: 9248
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for (ll i=0; i<N; i++) cin >> A[i];
  map<ll, ll> memo; // 町keyに最初に訪問したのは何回目の移動後か
  ll current = 0, per = 0, start = -1; // 今どの町にいるか，周期，周期のスタート
  memo[1] = 0;
  for (ll i=0; i<N; i++) {
    current = A[current]-1;
    if (!memo.count(current+1)) memo[current+1] = i+1;
    else {
      start = memo[current+1];
      per = i+1-memo[current+1];
      break;
    }
  }
  if (start>K) {
    for (auto p: memo) {
      auto key = p.first;
      auto value = p.second;
      if (value==K) {
        cout << key << endl;
        break;
      }
    }
  }
  else {
    for (auto p: memo) {
      auto key = p.first;
      auto value = p.second;
      if (value==(K-start)%per+start) {
        cout << key << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 17244
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>

using namespace std;

char A[105];
char B[105];
char C[105];
int flaga,flagb,flagc,flag;

int main()
{
	/*scanf("%s",A);
	scanf("%s",B);
	scanf("%s",C);*/
	while(cin >> A >> B >> C){
	int la = strlen(A);
	int lb = strlen(B);
	int lc = strlen(C);
		flag = 1;//Alice先来
		flaga = -1;
		flagb = -1;
		flagc = -1;
	while(true){

		if(flaga == la){
			printf("A\n");
			break;
		}
		else if(flagb == lb){
			printf("B\n");
			break;
		}
		else if(flagc == lc){
			printf("C\n");
			break;
		}
		if(flag == 1){
			flaga++;
			flag = A[flaga] - 'a' + 1;
		}
		else if(flag == 2){
			flagb++;
			flag = B[flagb] - 'a' + 1;
		}
		else if(flag == 3){
			flagc++;
			flag = C[flagc] - 'a' + 1;
		}
	}
	}
	return 0;
}

Measured memory_bytes: 256
tarop = hanakop = 0
for i in range(int(input())):
    taro, hanako = input().split()
    if taro > hanako:
        tarop += 3
    elif taro < hanako:
        hanakop += 3
    else:
        tarop += 1
        hanakop += 1
print(tarop, hanakop)

Measured memory_bytes: 7632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
namespace Mylib{
    using namespace std;
    
}
int main(void){
    using namespace std;
    int N,M;
    
    cin >> N >> M;
    
    int A[M];
    int tempInt;
    
    for(int i=0;i<M;i++){
        cin >> tempInt;
        A[i]=tempInt;
    }
    int rem=N;//残り日数
    for(int x:A){
        rem-=x;
    }
    if(rem>=0){
        cout << rem << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

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

int a[100001];

vector<int> e[100001];

signed main()
{
	int n,m;
	cin>>n>>m;
	
	for(int i=1;i<=n;i++)
		cin>>a[i];
	
	int x,y;
	for(int i=1;i<=m;i++)
	{
		cin>>x>>y;
		e[x].push_back(y);
		e[y].push_back(x);
	}

	int cnt=0;
	bool f;
	for(int i=1;i<=n;i++)
	{
		f=true;
		for(int j=0;j<e[i].size();j++)
			if(a[i]<=a[e[i][j]])
				f=false;
		if(f) cnt++;
	}
		
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 10200
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>

using namespace std;

int64_t zero_xor(int64_t x) {
  if ((x+1) % 2 != 0) {
    if (((x+1)/2) % 2 == 0) {
      return x ^ 0;
    } else {
      return x ^ 1;
    }
  } else {
    if (((x+1)/2) % 2 == 0) {
      return 0;
    } else {
      return 1;
    }
  }
}

int main() {
  int64_t A, B;
  cin >> A >> B;
  cout << (zero_xor(A-1) ^ zero_xor(B)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = INF;

int main()
{
ll n;
cin >> n;
ll t[n] = {};
rep(i, n){
    cin >> t[i];
    if(i!=0)t[i]+=t[i-1];
}

rep1(i,n){
  ans=min(ans,abs(t[n-1]-2*t[i]));
}

cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    unsigned long long int N; cin >> N;
    vector<unsigned long long int> L(N + 1, 0);
    L[0] = 2, L[1] = 1;
    for (int i = 2; i <= N; ++i) L[i] = L[i - 1] + L[i - 2];
    cout << L[N] << endl;
}


Measured memory_bytes: 3592
/*
g++ -std=c++11 -o2 -Wall ABC082C.cpp -o ./out/ABC082C.out
./out/ABC082C.out
*/

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

typedef long long ll;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//int a[100005];

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int ans = 0;
  int n;
  cin >> n;
  int a;
  map<int, int> m;
  for (int i = 0; i < n; ++i) {
//    cin >> a[i];
    cin >> a;
    ++m[a];
  }
  int k, v;
  for (auto& kv : m) {
      k = kv.first;
      v = kv.second;
      if (v >= k) {
        ans += v - k;
      } else {
        ans += v;
      }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 4736
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int n;
	cin >> n;
	string s;
	cin >> s;
	if (n % 2 == 0) {
		string substr = s.substr(0, n / 2);
		string substr1 = s.substr(n / 2, n);
		//cout << substr << substr1 << endl;
		if(substr==substr1)
			cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <stack>
#include <string>
#include <cstdlib>
#include <sstream>
using namespace std;


#define abs(N) ((N>0)?N:-1*N)
#define lt(A,B) ((A>B)?B:A)
#define gt(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

int main(){
	string buf,str;
	char cstr[1000];
	cin.getline(cstr,sizeof(cstr));
	str = string(cstr);
	stringstream ss(str);
	stack<int> st;
	st.push(0);
	while(getline(ss,buf,' ')){
		if(buf=="+" || buf == "-" || buf == "*"){
			int r1,r2,ret;
			r1 = st.top();st.pop();
			r2 = st.top();st.pop();
			if(buf=="+"){
				ret = r1+r2;
			}
			if(buf=="-"){
				ret = r2-r1;
			}
			if(buf=="*"){
				ret = r1*r2;
			}
			st.push(ret);
		}else{
			st.push(atoi(buf.c_str()));
		}
	}
	println(st.top());

	return 0;
}



Measured memory_bytes: 3200
using System;
using System.IO;
using System.Linq;

namespace A
{
	internal class Program
	{
		static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };

		public static void Main(string[] args)
		{
			var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
			var t = line[0];
			var x = line[1];
			sw.WriteLine((double) t / x);
			sw.Flush();
		}
	}
}

Measured memory_bytes: 13396
#include "bits/stdc++.h"
using namespace std;

#define ll long long

int main() {
	string s, t;
	cin >> s;
	cin >> t;
	int i, j;
	int min = INT_MAX;
	int buf;
	for(i=0;i<s.length()-t.length()+1;i++){
		buf = 0;
		for (j = 0; j < t.length(); j++) {
			if (s[i + j] != t[j])buf++;
		}
		if (buf < min)min = buf;
	}
	cout << min << endl;

	return 0;
}


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

using namespace std;

typedef long long int ll;
ll pts[200005][6]={0};

ll mnht(ll pt[200005][6], int kth, int idx, int d)
{
    ll dist=0;

    for(int i=0;i<d;i++)
    {
        dist+=abs(pt[kth][i]-pt[idx][i]);
    }

    return dist;
}
   /*
   10
   -70 -64 -6 -56 64 61 -57 16 48 -98
   */
ll max_cmb(ll cmbn[6], ll pt[200005][6], int n, int d)
{
    ll pk=0;ll idx=0;

   for(int i=0;i<n;i++)
   {
       ll val=0;

       for(int j=0;j<d;j++)
       {
           val+=(1-2*cmbn[j])*pt[i][j];
       }

       if(val>pk)
       {
           pk=val;
           idx=i;
       }
   }

   return idx;
}

int main()
{
   int n, d;
   cin >> n;
   d = 2;

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

   ll pk[2<<d];

   for(int j=0;j< 1<<(d);j++)
   {
       ll cmbn[6]={0};
       for(int dig=0;dig< d; dig++)
       {
           if(j & 1<<dig)
             cmbn[dig]=1;
          // cout<<cmbn[dig]<<" ";
       }
//cout<<endl;
       pk[j]=max_cmb(cmbn, pts, n, d);
   }

   ll maxd=0;
   for(int i=0;i<n;i++)
   {
       for(int j=0;j< 1<<(d);j++)
       maxd=max(maxd, mnht(pts, i, pk[j], d));
   }

   cout<<maxd<<endl;
   return 0;
}


Measured memory_bytes: 12984
#include <iostream>
#include <cstring>

using namespace std;

char dx[] = {-1,1,0,0};
char dy[] = {0,0,-1,1};
char dice[6][2] = {
	{4,2}, {3,5}, {5,0}, {1,4}, {0,3}, {2,1}
};

int board[9], goal[9];

void dfs(int x, int y, int px, int py, int step, int &res){
	if(step >= res) return;

	int dif = 0;
	for(int j=0;j<9;j++) dif += (goal[j]!=board[j]/2);
	if(dif==0){ res = step; return; }

	int space = 3*x+y;
	for(int i=0;i<4;i++){
		int nx = x + dx[i], ny = y + dy[i];
		if(nx<0||3<=nx||ny<0||3<=ny) continue;
		if(nx==px&&ny==py) continue;
		int mv = 3*nx+ny;
		int tmp = board[mv];
		dif -= (goal[space]!=board[space]/2) + (goal[mv]!=board[mv]/2);
		board[space] = dice[board[mv]][i/2];
		board[mv] = 6;
		dif += (goal[space]!=board[space]/2) + (goal[mv]!=board[mv]/2);
		if(step+dif-1<res) dfs(nx, ny, x, y, step+1, res);
		dif -= (goal[space]!=board[space]/2) + (goal[mv]!=board[mv]/2);
		board[space] = 6;
		board[mv] = tmp;
		dif -= (goal[space]!=board[space]/2) + (goal[mv]!=board[mv]/2);
	}
}

int main(){
	int x, y;
	while(cin >> y >> x, y){
		char c;
		for(int i=0;i<9;i++) {
			cin >> c;
			if(c=='W') goal[i] = 0;
			if(c=='B') goal[i] = 1;
			if(c=='R') goal[i] = 2;
			if(c=='E') goal[i] = 3;
		}
		memset(board,0,sizeof(board));
		board[3*(x-1)+y-1] = 6;
		int res = 31;
		dfs(x-1,y-1,-1,-1,0,res);
		cout << (res==31?-1:res) << endl;
	}
}

Measured memory_bytes: 868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	int n;
	cin >> n;
	int c = 0;
	for(int i = 1;i<=n;i++)
	{
		for(int j = 1;j<=n;j++)
		{
			if(i%2==1&&j%2==0)c++;
		}
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define trav(a, x) for(auto& a : x)
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;

int n;
ll k;

vi mult(const vi &a, const vi &b){
    vi ans(n);
    rep(i,0,n){
        ans[i] = a[b[i]];
    }
    return ans;
}

vi inv(const vi &a){
    vi ans(n);
    rep(i,0,n){
        ans[a[i]] = i;
    }
    return ans;
}

vi powr(vi a, ll m){
    vi ans(n);
    rep(i,0,n){
        ans[i] = i;
    }
    while(m>0){
        if(m%2){
            ans = mult(ans, a);
        }
        a = mult(a,a);
        m/=2;
    }
    return ans;
}

int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

    cin >> n >> k;
    k--;
    vi p(n);
    vi q(n);
    rep(i,0,n){
        cin >> p[i];
        p[i]--;
    }
    rep(i,0,n){
        cin >> q[i];
        q[i]--;
    }
    vi pinv = inv(p);
    vi qinv = inv(q);
    vi r = mult(q, mult(pinv, mult(qinv, p)));
    ll kk = k/6;
    vi rr = powr(r, kk);
    k -= 6*kk;
    while(k>0){
        vi pp = q;
        q = mult(q, inv(p));
        p = pp;
        k--;
    }
    vi ans = mult(rr, mult(p, inv(rr)));
    trav(x, ans){
        cout << x+1 << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 4448
def mergeSort(A, left, right, n):
    if left + 1 < right:
        mid = int((right + left ) / 2 )
        mergeSort(A, left, mid, n)
        mergeSort(A, mid, right, n)
        return (merge(A, left, mid, right, n))

def merge(A, left, mid, right, n):
    n1 = mid - left
    n2 = right - mid
    L = A[left:mid]  + [10 ** 9 + 1]
    R = A[mid:right] + [10 ** 9 + 1]
    i , j = 0, 0
    for k in range(left, right):
        A[n] += 1
        if L[i] <= R[j]:
            key = L[i]
            A[k] = key
            i += 1
        else:
            key = R[j]
            A[k] = key
            j += 1
    return A

n = int(input())
A = list(map(int, input().split()))
A.append(0)
S = mergeSort(A, 0, len(A) - 1, n)
print(" ".join(list(map(str, S[:n]))))
print(S[n])


Measured memory_bytes: 70492
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1e6+5
#define quick_pow_mod 1e9+7
#define PII pair<int,int>
const int factor_N = 1e7 + 5;
const int tree_arr_N = 1e6 + 5;
using namespace std;
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (; isdigit(c); c = getchar())
		x = x * 10 + c - 48;
	return x * f;
}
string s[7];
int h, w, k, ans;
int nth(int num, int n) {
	return (num >> n) & 1;
}
int main() {
	h = read(); w = read(); k = read();
	for_int(i, 0, h-1) cin >> s[i];
	for(int i=0;i<(1<<h);++i)
		for (int j = 0; j < (1 << w); ++j) {
			int cnt = 0;
			for(int k=0;k<h;++k)
				for(int l=0;l<w;++l)
					if(nth(i,k)&&nth(j,l)&&s[k][l]=='#') cnt++;
			if (cnt == k) ans++;
		}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3652
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

int64_t gcd(int64_t val1, int64_t val2) {
    if(val1 == 0) return val2;
    return gcd(val2%val1, val1);
}
int64_t lcm(int64_t val1, int64_t val2) {
    if(val1 > val2) swap(val1, val2);
    return val1 / gcd(val1, val2) * val2;
}

int main(void) {
    int snum, tnum;
    cin >> snum >> tnum;
    vector<string> str(2);
    cin >> str[0];
    cin >> str[1];
    int64_t len = lcm(snum, tnum);

    bool flag = 1;
    map<int64_t, char> map;

    // judge existance
    for(int k = 0; k < 2; k++) {
        int unit = len/str[k].length();
        debug("%d\n", unit);
        for(int64_t i = 0; i < len; i+=unit) {
            int idx = (int)(i/unit);
            if(map[i] && map[i] != str[k][idx]) {
                flag = 0;
                break;
            }
            map[i] = str[k][idx];
        }
    }
    cout << (flag ? len : -1) << endl;
    return 0;
}

Measured memory_bytes: 14148