akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    re0;
}

Measured memory_bytes: 256
I=lambda:map(int,input().split())
N,M=I()
d={i+1:0 for i in range(N)}
for _ in[0]*M:
  a,b=I()
  if a in [1,N]:d[b]+=1
  if b in [1,N]:d[a]+=1
#print(d)
for i in range(2,N):
  if d[i]==2:print("POSSIBLE");exit()
print("IMPOSSIBLE")

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

int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='1')s[i]='9';
        else if(s[i]=='9')s[i]='1';
    }
    cout<<s<<endl;
}

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

class Dice{
public:
    long r[6];
    Dice(){};
    void roll(long a, long b, long c, long d){
        swap(r[a], r[b]);swap(r[b], r[c]);swap(r[c], r[d]);
    }
    void spinW(){roll(0, 2, 5, 3);}
    void spinN(){roll(0, 1, 5, 4);}
};

int main() {
    bool ans = 0;
    int n;
    cin >> n;
    vector<Dice> D(n);
    for (int i = 0; i < n ; i++) {
        for (int j = 0; j < 6; j++) cin >> D[i].r[j];
    }
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            char SWS[8]={"NNNWNNN"};
            for (int k = 0; k < 8; k++){
                if (D[i].r[1] == D[j].r[1]) break;
                if (SWS[k] == 'W') D[j].spinW();
                else D[j].spinN();
            }
            for (int k = 0; k < 4; k++){
                if (D[i].r[0] == D[j].r[0]){
                    if (D[i].r[1] == D[j].r[1] && D[i].r[2] == D[j].r[2] && D[i].r[3]==D[j].r[3] && D[i].r[4] == D[j].r[4] && D[i].r[5] == D[j].r[5])
                        ans = 1;
                }
                D[j].spinW();
            }
        }
    }
    if (ans == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

int main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> s(H);
	for (int i = 0; i < H; ++i) { cin >> s[i]; }

	vector<vector<int>> wc(H + 1, vector<int>(W + 1, 0));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			wc[i + 1][j + 1] = (s[i][j] == '1');
		}
	}
	for (int i = 0; i <= H; ++i) {
		for (int j = 0; j < W; ++j) { wc[i][j + 1] += wc[i][j]; }
	}
	for (int j = 0; j <= W; ++j) {
		for (int i = 0; i < H; ++i) { wc[i + 1][j] += wc[i][j]; }
	}

	int ans = 1e8;
	for (int b = 0; b < (1<<(H - 1)); ++b) {
		vector<int> h;
		h.push_back(0);
		int tmp = 0;
		for (int i = 0; i < H - 1; ++i) {
			if ((b>>i) & 1) {
				h.push_back(i + 1);
				++tmp;
			}
		}
		h.push_back(H);

		int l = 0;
		bool ok = true;
		for (int j = 1; j <= W; ++j) {
			if (!ok) { continue; }
			for (int i = 1; i < h.size(); ++i) {
				int h1 = h[i - 1], h2 = h[i];
				int k = wc[h2][j] - wc[h2][l] - wc[h1][j] + wc[h1][l];
				if (k > K) { ok = false; }
			}
			if (!ok && l + 1 < j) {
				l = j - 1;
				++tmp;
				ok = true;
			}
		}
		if (ok) { ans = min(ans, tmp); }
	}
	cout << ans << endl;

	return 0;
}


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

int main(){
  int h, w;
  cin >> h;
  cin >> w;
  string str[h];
  int i, j;
  for(i = 0; i < h; i++){
    cin >> str[i];
  }
  string ans[2 * h];
  j = 0;
  for(i = 0; i < h; i++){
    ans[j] = str[i];
    j++;
    ans[j] = str[i];
    j++;
  }
  for(int i = 0; i < 2 * h; i++) cout << ans[i] << endl;
  return 0;
}

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

int main(void){
    int n,t;
    cin >> n >> t;
    int a[n];
    for(int i = 0;i < n;i++)cin >> a[i];
    long long int sum = 0,start = a[0];
    for(int i = 1;i < n;i++){
        if(a[i-1]+t < a[i]){
            sum += a[i-1]+t-start;
            start = a[i];
        }
        if(n-1 == i)sum += a[i]+t-start;
    }
    if(n == 1)sum = t;
    cout << sum << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sc(x) scanf("%lld",&x);
int A[105];
const int mod = 1e9+7;
int qp(int n)
{
    int ans = 1;
    int x = 2;
    while(n){
        if(n&1)ans=(ans*x)%mod;
        x = (x*x)%mod;
        n>>=1;
    }
    return ans;
}

int mulit(int a,int b,int m){
    int ans=0;
    while(b){
        if(b&1) ans=(ans+a)%m;
        a=(a<<1)%m;
        b>>=1;
    }
    return ans;
}

int quick_mod(int a,int b,int m){
    int ans=1;
    while(b){
        if(b&1){
            ans=mulit(ans,a,m);
        }
        a=mulit(a,a,m);
        b>>=1;
    }
    return ans;
}

int comp(int a,int b,int m){
    if(a<b) return 0;
    if(a==b) return 1;
    if(b>a-b) b=a-b;
    int ans=1,ca=1,cb=1;
    for(int i=0;i<b;i++){
        ca=ca*(a-i)%m;
        cb=cb*(b-i)%m;
    }
    ans=ca*quick_mod(cb,m-2,m)%m;
    return ans;
}
signed main()
{
    int ans,n,a,b;
    sc(n)sc(a)sc(b)
    ans = qp(n);
    ans = (ans-1+mod)%mod;
    int x = comp(n,a,mod);
    ans = (ans-x+mod)%mod;
    int y = comp(n,b,mod);
    ans =(ans-y+mod)%mod;

    cout<<ans<<'\n';
}


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

using namespace std;

#define pb push_back
#define prr pair<int,int> 
#define int long long
#define fir first
#define sec second
#define double long double
#define ll long long



int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int k;
    cin>>k;
    int a,b;
    cin>>a>>b;
    if(b<k){
        cout<<"NG";
        return 0;
    }
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG";

}



Measured memory_bytes: 3652
using System;
using System.Linq;

// AtCoder Educational DP -C Vacation
// [len,3]のdp？参照範囲は-2 (-1 ~ +1？)
// [x,A-C] は、x番目にA-Cを取れるルートで、もっとも最大のルート
// [x,A]は、x番目にAを取る場合の最大値、2個前のABCから全計算かな？


public class Program{

	public static void Main(){
	
		int WAY = 3;
		var N = int.Parse(Console.ReadLine());
		var ABC = new int[N+1,3];
		int[] h;
		for(int i = 1; i <= N ; i++){
			h = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
			ABC[i,0] = h[0];
			ABC[i,1] = h[1];
			ABC[i,2] = h[2];
		}
		
		var dp = new int[N + 1,3];
		dp[0,0] = 0;
		dp[0,1] = 0;
		dp[0,2] = 0;
		dp[1,0] = ABC[1,0];
		dp[1,1] = ABC[1,1];
		dp[1,2] = ABC[1,2];
		
		int sum = 0;
		for(int outer = 2; outer <= N; outer++){
		
			for(int i = 0; i < WAY; i++){
				for(int k = 0; k < WAY; k++){
					for(int j = 0; j < WAY; j++){
						if(j != k && i != k)
							dp[outer,j] = Math.Max(dp[outer,j], dp[outer-2,i] + ABC[outer-1,k] + ABC[outer,j]);
					}
				}
			}
		}
		
		Console.WriteLine(Math.Max(dp[N,0], Math.Max(dp[N,1], dp[N,2])));
		
	
	
	}
	




}

Measured memory_bytes: 17340
#include<bits/stdc++.h>
using namespace std;
int main(){int s;cin>>s;vector<long>a(s);long long m=0;
       for(int i=0;i<s;i++)cin>>a.at(i);
           sort(a.rbegin(),a.rend());
    for(int i=1;i<s;i++)m+=a.at(i/2);
           cout<<m<<endl;}

Measured memory_bytes: 4840
N,K=map(int,input().split())
H=list(map(int,input().split()))
H.sort()
count=0
if N>K:
  for i in range(K):
    count+=H[N-i-1]
  print(sum(H)-count)
else:
  for i in range(N-K):
    count+=H[i]
  print(count)

Measured memory_bytes: 26180
# coding: utf-8
# Your code here!
n=int(input())
s=[]
ans=-10000
for i in range(n):
    s.append(input())
m=int(input())
t=[]
for j in range(m):
    t.append(input())
for k in range(n):
    if s.count(s[k])-t.count(s[k])>ans:
        ans=s.count(s[k])-t.count(s[k])
if ans>0:
    print(ans)
else:
    print(0)
    

Measured memory_bytes: 3064
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/
const int limit = 1000000;
int main()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);

	int c[3][3];
	int b[2];
	int a[2];
	b[0] = b[1] = limit;

	a[0] = a[1] = limit;

	bool ret = true;
	rep(i, 3)
	{
		rep(j, 3)
		{
			cin >> c[i][j];
			if (j > 0)
			{
				if (b[j-1] == limit) 
				{
					b[j-1] = c[i][j] - c[i][j-1];
				}
				else
				{
					if (b[j-1] != (c[i][j] - c[i][j-1]))
					{
						ret = false;
					}
				}
			}

			if (i > 0)
			{
				if (a[i-1] == limit) 
				{
					a[i-1] = c[i][j] - c[i-1][j];
				}
				else
				{
					if (a[i-1] != (c[i][j] - c[i-1][j]))
					{
						ret = false;
					}
				}
			}
		}
	}

	if (ret)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}


	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  int a,b,k,num = 0;
  cin >> a >> b >> k;
  for (int i = a+b; i > 0; i--) {
    if(a%i ==0 && b%i == 0) {
      num++;
    }
    if(num == k) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


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

int main()
{
      int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int dp[n]={0};
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        dp[i]=min((abs(a[i]-a[i-1])+dp[i-1]),(abs(a[i]-a[i-2])+dp[i-2]));
    }
    cout<<dp[n-1];
  return 0;
}

Measured memory_bytes: 1024
s=io.read()
t={}
for i=1,#s do
    table.insert(t,s:sub(i,i))
end
table.sort(t)
x=table.concat(t,"")
if string.match(x,"E+N+S+W+") or string.match(x,"E+W+")==x or string.match(x,"N+S+")==x then
    print("Yes")
else
    print("No")
end

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> R[i];
    }
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for(int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
    
    return 0;
}


Measured memory_bytes: 3884
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);	
		
		int[] in = Stream.of(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		
		int on = in[0] * in[1];
		int two = in[2] * in[3];
		
		int res = (on == two) ? on : (on > two) ? on : two;
		
		System.out.println(res);
	}
}


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

const int maxn = 2e5 + 100;

typedef long long ll;

ll tree[4 * maxn];
ll lazy[4 * maxn];

void push(int node, int l, int r)
{
    if(lazy[node] == 0)
        return;
    tree[node] += lazy[node];
    if(l != r)
    {
        lazy[2*node] += lazy[node];
        lazy[2*node+1] += lazy[node];
    }
    lazy[node] = 0;
}

void update(int node, int l, int r, int x, int y, ll val)
{
    //cout << node << " " << l << " -- " << r << endl;
    push(node,l,r);
    if(l > r || l > y || r < x)
        return;
    if(x <= l && r <= y)
    {
        lazy[node] += val;
        push(node,l,r);
        return;
    }

    int mid = (l+r) >> 1;
    update(2*node,l,mid,x,y,val);
    update(2*node+1,mid+1,r,x,y,val);
    tree[node] = max(tree[2*node], tree[2*node+1]);
}

ll query(int node, int l, int r, int x, int y)
{
    push(node,l,r);
    if(l > r || l > y || r < x)
        return -(1LL << 60);
    if(x <= l && r <= y)
    {
        return tree[node];
    }

    int mid = (l+r) >> 1;
    return max(query(2*node,l,mid,x,y),query(2*node+1,mid+1,r,x,y));
}

vector<pair<int,int> >que[maxn];

int main()
{
    // for(int i = 0; i < 4*maxn; i++)
    //     tree[i] = -(1LL << 60);
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i = 0 ; i < m ; i++)
    {
        int l,r,d;
        scanf("%d %d %d",&l,&r,&d);
        que[r].push_back({l,d});
    }

    for(int i = 1 ; i <= n; i++)
    {   
        ll q = query(1,1,n,1,i);
        update(1,1,n,i,i,q);
        for(auto &x : que[i])
        {
            update(1,1,n,x.first,i,x.second);    
        }
    }
    printf("%lld\n",max(0LL,query(1,1,n,1,n)));
    return 0;
}

Measured memory_bytes: 22912
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    A = tuple(tuple(map(int, input().split())) for i in range(3)) #改行行列
    N = int(input())
    B = tuple(int(input()) for i in range(N))
    tset=set()
    for b in B:
        for i in range(3):
            for j in range(3):
                if A[i][j]==b:
                    tset.add(i*4+j)
    flag=False
    for i in range(3):
        if i*4 in tset and i*4+1 in tset and i*4+2 in tset:
            flag=True
        elif i in tset and 4+i in tset and 8+i in tset:
            flag=True
    if 0 in tset and 5 in tset and 10 in tset:
        flag=True
    elif 2 in tset and 5 in tset and 8 in tset:
        flag=True

            
    if flag:
        print('Yes')
    else:
        print('No')





if __name__ == "__main__":
    main()

Measured memory_bytes: 38256
N = int(input())
ichi = 9
hyaku = 900
man = 90000
if N < 10:
  print(N)
elif 10 <= N < 100:
  print(ichi)
elif 100 <= N <= 999:
  ans = N - 99
  print(ichi+ans)
elif 1000 <= N <= 9999:
  print(ichi+hyaku)
elif 10000 <= N <= 99999:
  ans = N - 9999
  print(ichi+hyaku+ans)
else:
  print(90909)

Measured memory_bytes: 9200
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#define LL long long
using namespace std;
int n,m;
int a[105],sum;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){scanf("%d",&a[i]);sum+=a[i];}
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		printf("%d\n",sum-a[x]+y);
	}
	return 0;
}




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

int main() {
	int Number = 0;
	int Alice = 0;
	int Bob = 0;
	int Max = 0;
	int Cheak = 0;
	int Max_index = 0;
	cin >> Number;
	vector<int> Card(Number); 
	for (int Loop = 0; Loop < Number; Loop++) {
    	cin >> Card.at(Loop);
    }  
	for (int Loopi = 0; Loopi < Number; Loopi++) {
        Max = 0;
        Max_index = 0;
		for (int Loopii = 0; Loopii < Number; Loopii++) {
        	Cheak = Card.at(Loopii);
    		if (Cheak > Max) {
            	Max = Cheak;
        		Max_index = Loopii;
            }
        }
        	if (Loopi % 2 == 0) {
            	Alice += Max;
            }
      		else {
            	Bob += Max;
            }
         	Card.at(Max_index) = 0;
    }
    cout << Alice - Bob << endl;
}

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

#define int long long
#define double long double

const int INF=2147483647;
const int MOD=1000000007;
const int mod=998244353;
const double eps=1e-18;

using namespace std;

int h,w;
char grid[1001][1001];
int ch,cw,dh,dw;

vector< pair<int,int> > edge[1000001]; /// dis,to
priority_queue< pair<int,int> , vector< pair<int,int> > , greater< pair<int,int> > > pq ;
int dis[1000001];

void Dijkstra(int v){

    int d1=dis[v];

    for(int i=0;i< edge[v].size() ;i++ ){
        int d2=edge[v][i].first;
        int u=edge[v][i].second;
        if( d1+d2<dis[u] ){
            dis[u]=d1+d2;
            pq.push( pair<int,int>(dis[u],u) );
        }
    }

}

signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int dx[25];
    int dy[25];
    for(int i=0;i<25;i++){
        dx[i]=(i/5)-2;
        dy[i]=(i%5)-2;
    }
    int adj[4]={7,11,13,17};

    cin>>h>>w;
    cin>>ch>>cw>>dh>>dw;
    ch--;
    cw--;
    dh--;
    dw--;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>grid[i][j];
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){

            if(grid[i][j]=='.'){

                for(int k=0;k<4;k++){

                    int nx=i+dx[ adj[k] ];
                    int ny=j+dy[ adj[k] ];

                    if( 0<=nx and nx<h and 0<=ny and ny<w ){
                        if(grid[nx][ny]=='.'){
                            edge[i*w+j].push_back( pair<int,int>( (int)0 , nx*w+ny ) );
                        }
                    }
                }

            }

        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){

            if(grid[i][j]=='.'){

                for(int k=0;k<25;k++){

                    int nx=i+dx[k];
                    int ny=j+dy[k];

                    if( 0<=nx and nx<h and 0<=ny and ny<w ){
                        if(grid[nx][ny]=='.'){
                            edge[i*w+j].push_back( pair<int,int>( (int)1 , nx*w+ny ) );
                        }
                    }
                }

            }

        }
    }

    for(int i=0;i<h*w;i++){
        dis[i]=INF;
    }

    pq.push(  pair<int,int>(0,ch*w+cw)  );
    dis[ ch*w+cw ]=0;

    while( pq.empty()==0 ){
        int v=pq.top().second;
        pq.pop();
        Dijkstra(v);
    }

    if(dis[ dh*w+dw ]==INF){
        cout<<-1<<endl;
    }
    else{
        cout<<dis[ dh*w+dw ]<<endl;
    }

    /***debug***
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<dis[i*w+j];
        }
        cout<<endl;
    }
    cout<<endl;
    ***debug***/

    return 0;
}


Measured memory_bytes: 206020
/*
	Nishant Singh
	nishant.ns19@gmail.com
*/
#include <bits/stdc++.h>
#include <functional> 
#include <iostream> 

// ******** Big Integer ********
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// #define ll1024  int1024_t
// ******** Big Integer ********

// ******** Using PBDS ********
// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ook order_of_key    //count of strictly smaller elements
// #define fbo find_by_order   //find element at an index 
// ******** Using PBDS ********

using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vll vector<ll>
#define vec vector
#define setcount(x) __builtin_popcountll(x)
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define REV(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define in insert
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
#define pq priority_queue
#define ffl fflush(stdout)
#define mset multiset
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define ub upper_bound
#define lb lower_bound 
#define ln "\n"
#define Y "YES"
#define N "NO"
ll const mod=1e9 + 7;
ll const inf=2e18;

// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********

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

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

inline ll sub(ll a,ll b) 
{ 
	return (a%mod - b%mod + mod)%mod; 
}

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

ll modexp(ll x, ll n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}

ll modinv(ll n)
{
	return modexp(n,mod-2);
}

// ******** GLOBAL VARIABLES ********


// ******** GLOBAL VARIABLES ********

void solve(){
	string s;
	cin>>s;
	if(s[s.size()-1]=='s'){
		s=s+"es";

	}
	else
	{
		s=s+"s";

	}
	cout<<s;
	

}  

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll T=1;
	// cin>>T; 	
	for(int t=1;t<=T;t++)
	{
		// cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3664
class my_segment_tree:
    def __init__(self, base_array, size, f=lambda a, b: a + b, default_value = 0):
        self.f = f
        self._seg_size = 2 ** (size.bit_length() + 1) - 1
        self._default_value = default_value
        self._array = [default_value] * (self._seg_size)
        k = 2 ** size.bit_length() - 1  # 一番下の最初のindex

        for i in range(size):
            self._array[k + i] = base_array[i]

        while k > 0:
            for i in range((k + 1) // 2):
                self._array[(k + 2 * i) // 2] = f(self._array[k + 2 * i], self._array[k + 2 * i + 1])
            k //= 2
    def update(self, i, v):
        i += (self._seg_size // 2)
        self._array[i] = v
        while i > 0:
            i = (i - 1) >> 1
            self._array[i] = self.f(self._array[2 * i + 1], self._array[2 * i + 2])

    def get(self, left, right):
        return self._get(left, right, 0, self._seg_size // 2, 0) #どちらも閉空間

    def _get(self, left, right, l, r, i):
        if left <= l and r <= right:
            return self._array[i]

        a = 0
        if left <= (l + r) // 2:
            a = self._get(left, min(right, (l + r) // 2), l, (l + r) // 2, 2 * i + 1)
        b = 0
        if (l + r) // 2 + 1 <= right:
            b= self._get(max(left, (l + r) // 2 + 1), right, (l + r) // 2 + 1, r, 2 * i + 2)

        return self.f(a, b)

def main():
    N = int(input())
    S = input()
    M = int(input())
    A = [0 for i in range(N)]

    for i, c in enumerate(S):
        A[i] = 1 << ord(c) - ord('a')

    st = my_segment_tree(A, N, lambda a, b: a | b)

    for i in range(M):
        p, a, b = input().split()
        a  = int(a) - 1
        if p == '1':
            st.update(a, 1 << (ord(b) - ord('a')))

        if p == '2':
            s = st.get(a, int(b) - 1)
            print(bin(s).count('1'))


if __name__ == '__main__':
    main()

Measured memory_bytes: 48420
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  vi B(N);
  set<pii> S;
  S.insert(mp(0,-1));
  rep(i,0,N){
    auto p=*rbegin(S);
    if(p.first<A[i]){
      B[i]=i-p.second;
    }
    else{
      auto q=S.lower_bound(mp(A[i],0));
      q--;
      auto r=*q;
      B[i]=i-r.second;
    }
    S.insert(mp(A[i],i));
    while(1){
      auto s=*rbegin(S);
      if(s.first>A[i]) S.erase(s);
      else break;
    }
  }
  S.clear();
  S.insert(mp(0,N));
  REP(j,1,N){
    int i=N-j;
    auto p=*rbegin(S);
    if(p.first<A[i]){
      B[i]*=p.second-i;
    }
    else{
      auto q=S.lower_bound(mp(A[i],0));
      q--;
      auto r=*q;
      B[i]*=r.second-i;
    }
    S.insert(mp(A[i],i));
    while(1){
      auto s=*rbegin(S);
      if(s.first>A[i]) S.erase(s);
      else break;
    }
  }
  int ans=0;
  rep(i,0,N) ans+=A[i]*B[i];
  cout<<ans<<endl;
  }



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

int main(){
    string s;
    cin >> s;
    int n=s.size();
    int ans=0;
    rep(i,n-1){
        if(s[i]=='B' && s[i+1]=='W')ans++;
        else if(s[i]=='W' && s[i+1]=='B')ans++;
    }
    cout << ans << endl;
    
}

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

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		 Scanner in = new Scanner(System.in);
	     int n = in.nextInt();
	     int k = in.nextInt();
	     int[] arr = new int[n+1];
	     int[] cost = new int[n+1];
	     for(int i =1; i<= n; i++)
	    	 arr[i] = in.nextInt();
	     
	     for(int i =1; i<= n ; i++) {
	    	 cost[i] = in.nextInt();
	     }
	     
	     boolean[] used = new boolean[n+1];
	     long re= Integer.MIN_VALUE;
	     long  cur =0;
	     int idx =0;
	     
	     for(int i =1; i<=n; i++)  {
	    	 idx = arr[i];
	    	 cur = cost[idx];
	    	 re= Math.max(re, cur);
	    	 
	    	 used[i]=true;
	    	 
	    	 int count =1;
	    	 while(true) {
	    		 if(used[idx] || count>=k) break;
	    		 
	    		 used[idx]=true;
	    	     count++;
	    	     idx = arr[idx];
	    	     cur+= cost[idx];
	    	     re= Math.max(re, cur);
	    	 }
	    	 
	    	 used = new boolean[n+1];
	    	 if(cur>0 && k>=count) {
	    		 cur = cur * (k/count-1);
	    		 int idx2 = arr[i];
	    		 for(int j =0; j< count +(k%count); j++) { // residuo
	    			 cur += cost[idx2];
	    			 idx2= arr[idx2];
	    			 re= Math.max(re, cur);
	    		 }
	    	 }
	     }
	     
         System.out.println(re);
	}	

}

Measured memory_bytes: 57608
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()

import math

d = {}
for i in range(2,math.floor(math.sqrt(N))+1):
    if N % i == 0:
        r = 0
        while N % i == 0:
            N //= i
            r += 1
        d[i] = r
if N != 1:
    d[N] = 1

ans = 0
for i in d.keys():
    r = d[i]
    b = 1
    a = 0
    while r > 0:
        r -= b
        if r >= 0:
            b += 1
            a += 1
        else:
            break
    ans += a

print(ans)

Measured memory_bytes: 63548
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const ll mod = 1000000007;

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

    Graph to(n), cost(n);
    rep(i, n-1) {
        int a, b, w;
        cin >> a >> b >> w;
        a--;  b--;
        to[a].push_back(b);
        to[b].push_back(a);
        cost[a].push_back(w);
        cost[b].push_back(w);
    }

    vector<int> dist(n, -1);  // dist[i] : 頂点iの根からの距離
    queue<int> Q;

    const int root = 0;  // デフォルトで根は頂点0
    dist[root] = 0;
    Q.push(root);
    while(!Q.empty()) {

        int v = Q.front();
        Q.pop();

        rep(i, to[v].size()) {
            
            int u = to[v][i];
            
            if(dist[u] != -1) {
                continue;
            }
            
            dist[u] = (dist[v] + cost[v][i])%2;
            Q.push(u);
        }
    }

    rep(i, n) {
        cout << dist[i] << "\n";
    }
    
    return 0;
}

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

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

  vector<int> vec(N);

  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  sort(vec.begin(), vec.end());

  string ans = "YES";

  for (int i = 0; i < N - 1; i++) {
    if (vec.at(i) == vec.at(i + 1)) {
      ans = "NO";
      break;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll = long long;
ll n, a, b, sum;
int main() {
    sum = 0;
    std::cin >> n >> a >> b;
    ll c = a + b;
    ll m = n % c;
    sum += std::min(a, m);
    ll res = (n-m)/c;
    sum += (res * a);
    std::cout << sum << std::endl; 
}

Measured memory_bytes: 256
A, B, K = map(int, input().split(" "))

if 2 * K <= B - A:
    x = 0
    while x < K:
        print(A + x)
        x += 1
    x = K
    while x > 0:
        print(B - x + 1)
        x -= 1
    
else:
    x = A
    while x <= B:
        print(x)
        x += 1

Measured memory_bytes: 3060
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

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

    std::vector<int> l(n);
    for (int i = 0; i < n; i++) {
        std::cin >> l[i];
    }

    int count = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (l[i] < l[j] + l[k] && l[j] < l[k] + l[i] && l[k] < l[i] + l[j]) {
                    count++;
                }
            }
        }
    }

    std::cout << count << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    for(int i=1;i<3000; i++){
    cin >> x >> y;
    if(x > y){
        swap(x,y);
    }
    if(x==0&&y==0){break;}
    cout<<x<<" "<<y<<endl;
    }
    return 0;
}



Measured memory_bytes: 3072
#pragma GCC optimize("Ofast")

#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>

using namespace std;

template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}

template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define left left228
#define right right228
#define ld long double
// #define prev prev228
#define mp make_pair
#define list list228
#define all(v) v.begin(), v.end()

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    for (int i = 0; i < (int)s.size(); ++i) {
        if ((i & 1) && s[i] != 'i') {
            cout << "No\n";
            return 0;
        }
        if (!(i & 1) && s[i] != 'h') {
            cout << "No\n";
            return 0;
        }
    }
    if ((int)s.size() & 1) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    return 0;
}

/*
3
1 1 2
2 2 2
3 3 2
2 1 1
3 2 1


2 2
1 1 2
2 2 2
1 2 3
2 1 1

2
2 1 2 2 3
2 2 2 1 1

5
1 2
2 3
3 4
3 5
1
2 3
1 2
4 3
2 3 5

*/

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define inf 0x3f3f3f3f
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

/* 
 * * stuff you should look for
 * * int overflow, array bounds
 * * special cases (n=1?), set tle
 * */

int main(){
    fcin;

    int n;
    cin >> n;

    string s, t;
    cin >> s >> t;

    string ans;
    for(int i = 0; i < n; i++){
        ans += s[i];
        ans += t[i];
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
using namespace std;

int main()
{
    int n, m, k, tmp_a;
    cin >> n >> m;
    vector<vector<int>> a(n);
    for (int i=0; i<n; ++i){
        cin >> k;
        for (int j=0; j<k; ++j){
            if(j == 0){
                a[i].resize(k);
            }
            cin >> tmp_a;
            a[i][j] = tmp_a;
        }
    }
    set<int> ans;
    bool isLike = true;
    for (int i=1; i<=m; ++i){
        isLike = true;
        for (int j=0; j<n; ++j){
            for (int p=0; p<a[j].size(); ++p){
                // cout << a[j][p] << " ";
                if(a[j][p] == i){
                    break;
                }
                if(a[j][p] != i && p == a[j].size() - 1){
                    isLike = false;
                }
            }
            // cout << endl;
        }
        if(isLike){
            ans.insert(i);
        }
    }
    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long N;
    cin >> N;
    vector<long long> A(N+1),B(N);
    for(long long i = 0; i < N+1; i++){
        cin >> A[i];
    }
    for(long long i = 0; i < N; i++){
        cin >> B[i];
    }
    long long Count = 0;
    
    for(long long i = 0; i < N; i++){
 
        if(A[i] >= B[i]){
        Count += B[i];
        A[i] -= B[i];
        B[i] = 0;
        }
        else{
        Count += A[i];
        B[i] -= A[i];
        A[i] = 0;
        }
    
        if(A[i+1] >= B[i]){
        Count += B[i];
        A[i+1] -= B[i];
        B[i] = 0;
        }
        else{
        Count += A[i+1];
        B[i] -= A[i+1];
        A[i+1] = 0;
        }
    }
    cout << Count << endl;
}

Measured memory_bytes: 1792
N = int(input())
S = [[s == '1' for s in input()] for _ in range(N)]

M = [set(y for y in range(N) if S[x][y]) for x in range(N)]
v_max = -1
for i in range(N):
  V = [set([i])]
  nodes = set(range(N)) - V[0]
  while len(nodes) > 0:
    V.append(set().union(*[M[x] for x in V[-1]]).intersection(nodes))
    for v in V[-1]:
      if V[-1] & M[v]:
        break
    else:
      nodes -= V[-1]
      continue
    break
  else:
    v_max = max(v_max, len(V))
print(v_max)

Measured memory_bytes: 4980
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
const int INF = 1 << 30;
using namespace std;

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

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

  int n; cin >> n;
  vector<int> h(100010, 0);
  rep(i, n) cin >> h[i];

  vector<int> dp(100010, INF);
  dp[0] = 0;
  rep(i, n) {
    chmin(dp[i+1], dp[i] + abs(h[i+1]-h[i]));
    chmin(dp[i+2], dp[i] + abs(h[i+2]-h[i]));
  }

  cout << dp[n-1] << '\n';
  return 0;
}


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

int main(){
    int n; string s;
    cin>>n>>s;
    int r=0,g=0,b=0;
    rep(i,n){
        if(s[i]=='R')r++;
        if(s[i]=='G')g++;
        if(s[i]=='B')b++;
    }
    ll ans=(ll)r*g*b;
    rep(i,n){
        for(int j=i+1; j<n; ++j){
            int k=j+j-i;
            if(k>=n)continue;
            if(s[i]!=s[j]&&s[j]!=s[k]&&s[k]!=s[i])ans--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define pp push_back
#define ff first
#define ss second

using namespace std;

ll t,n,m,r,l,h,i,j,x[1000001],y[1000001],z,g,a,b,c,d,dp[1000001],k,q;
vector <ll> v[1000001];
vector <pair <ll,ll> > vv;
queue <pair <ll,ll> > qq;
pair <ll,ll> p[1000001];
map <ll,ll> mp,mpp,mppp,mx,vis;
set <pair<ll,ll>, greater<pair<ll,ll> > > se;
set <ll> :: iterator it;
string s[1000001],sss;
char cc;

int main()
{
    ios::sync_with_stdio(0);
    cin >> n >> k;
    for(i=0;i<n;i++)
        cin >> x[i];
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    for(i=0;i<n;i++)
    {
        for(j=1;j<=k && i+j<n;j++)
        {
            if(dp[i+j]==-1)
                dp[i+j]=dp[i]+abs(x[i]-x[i+j]);
            else
                dp[i+j]=min(dp[i+j],dp[i]+abs(x[i]-x[i+j]));

        }
    }
    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 43392
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    vector<int>v(n);
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> v[i];
        sum = sum + v[i];
    }
    int x = sum/(4*m) + (sum % (4*m) != 0), k = 0;
    for(int i = 0; i < n; i++){
        if(v[i] >= x){
            k++;
        }
    }
    if(k >= m){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>

int main()
{
    std::array<int, 3> L;
    for (auto& l : L) {
        std::cin >> l;
    }

    std::sort(std::begin(L), std::end(L));

    std::cout << ((L[0] == 5 and L[1] == 5 and L[2] == 7)? "YES" : "NO") << '\n';
}

Measured memory_bytes: 3588
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
        if(a%2==1){System.out.println("No");}
		else{String s = sc.next();
             String ans = "Yes";
        for(int i=0;i<a/2;i++){if(s.charAt(i)!=s.charAt(a/2+i))
        {ans="No";break;                                                 
        }                           
                              }       
		System.out.println(ans);}
	}
}

Measured memory_bytes: 23892
#include <stdio.h>
int main()
{
  int ta[100],ha[100],ts,hs,t,h,at,ah,min,i,j;
  while(1){
    scanf("%d %d",&t,&h);
    if(t==0&&h==0)break;
    hs=0;
    ts=0;
    for(i=0;i<t;i++){
      scanf("%d",&ta[i]);
      ts+=ta[i];
    }
    for(i=0;i<h;i++){
      scanf("%d",&ha[i]);
      hs+=ha[i];
    }
    ///printf("%d %d %d %d\n",ts,hs,t,h);///
    min=10000;
    at=-100;
    ah=-100;
    for(i=0;i<t;i++){
      for(j=0;j<h;j++){
	if(ts-ta[i]+ha[j]==hs-ha[j]+ta[i]){
	  if(ta[i]+ha[j]<min){
	    at=ta[i];
	    ah=ha[j];
	    min=ta[i]+ha[j];
	  }
	}
      }
    }
    if(at!=-100&&ah!=-100)printf("%d %d\n",at,ah);
    else  printf("-1\n");
  }
  return 0;
}

Measured memory_bytes: 1040
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {
  int n, d;
  cin >> n >> d;
  cout << (n + 2 * d) / (2 * d + 1) << endl;
}


Measured memory_bytes: 256
use std::io;


fn main() {
    let i = read::<String>();
    if i[0] < i[1] { println!("<"); }
    else if i[0] > i[1] { println!(">"); }
    else { println!("="); }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<iostream>
#include<string>

using namespace std;	//���O��Ԏw��

int main(){
	string str1,str2,str3;  //���[k��ϐ��Ƃ��āAstr�𐶐�
	int count = 0,SZ;
	cin >>SZ;
	cin >> str1 >>str2 >> str3;
//	SZ = str1.length();
	for(int i=0; i < SZ; ++i){
		if(str1[i] != str2[i] && str1[i] != str3[i] &&str2[i] != str3[i])
		{
			count = count +2;
		}else if (str1[i]==str2[i] && str1[i] == str3[i]){
		}else{
		count = count +1;
		}

	}
	cout << count;
	
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define for(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int a,b,k; cin >> a >> b >> k;
    vector <int> vec{};
    for(i,1,min(a,b)+1){
        if(a%i==0 && b%i==0){
            vec.push_back(i);
        }
    }
    cout << vec[vec.size()-k] << endl;

    return 0;
}

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

int main(){
  int n; cin >> n;
  for( int i = 0; i < n; i++ ){
    int dp[1010][1010];
    for( int i = 0; i < 1010; i++ ) dp[i][0] = dp[0][i] = 0;
    
    char x[1010], y[1010];
    cin >> x >> y;

    for( int i = 0; i < strlen( x ); i++ ){
      for( int j = 0; j < strlen( y ); j++ ){
	if( x[i] == y[j] ){
	  dp[i + 1][j + 1] = dp[i][j] + 1; 
	}else if( dp[i][j + 1] >= dp[i + 1][j] ){
	  dp[i + 1][j + 1] = dp[i][j + 1];
	}else{
	  dp[i + 1][j + 1] = dp[i + 1][j];
	}
      }
    }

    cout << dp[strlen( x )][strlen( y )] << endl;
  }
}



Measured memory_bytes: 7088
while True:
    n = input()
    if n == 0: break
    s = [int(x) for x in raw_input().split()]
    cnt = 0
    
    while True:
        c = [0] * n
        for i in range(n):
            c[i] = s.count(s[i])
        if s == c: break
        else:
            s = c
            cnt += 1
    
    print cnt
    print " ".join([str(x) for x in c])

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

long long a, b;
int ma, mb;

auto msb = [&](long long n) {
    for (int i = 61; i >= 0; i--) {
        if (n & (1LL << i)) return i;
    }
    return -1;
};

int calc() {
    long long c = a | (1LL << mb);
    long long d = 1LL << mb;
    for (int i = mb-1; i >= 0; i--) {
        if (b & (1LL << i)) {
            d += (1LL << (i+1)) - 1;
            break;
        }
    }
    long long ans = d - a + 1;
    c = max(d+1, c);
    ans += ((1LL << (mb+1)) - 1) - c + 1;
    cout << ans << "\n";
    return 0;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> a >> b;
    if (a == b) {
        cout << 1 << "\n";
        return 0;
    }
    while (true) {        
        ma = msb(a), mb = msb(b);
        if (ma != mb) {
            return calc();
        } else {
            a ^= 1LL << ma, b ^= 1LL << mb;
        }
    }
    return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

h,w = inpl()
s = [input() for i in range(h)]
# print(s)
dx = [1,0,-1,0]
dy = [0,1,0,-1]
res = -INF
for y in range(h):
    for x in range(w):
        if s[y][x] == '#':
            continue
        ans = 0
        dist = [[-1]*w for i in range(h)]
        dist[y][x] = 0
        q = deque([[x,y]])
        while q:
            v = q.popleft()
            # print(v)
            vx,vy = v[0],v[1]
            for dir in range(4):
                ny = vy + dy[dir]
                nx = vx + dx[dir]
                if ny<0 or ny>h-1 or nx<0 or nx>w-1:
                    continue
                if s[ny][nx] == '#' or dist[ny][nx] != -1:
                    continue
                dist[ny][nx] = dist[vy][vx] + 1
                ans = max(ans, dist[ny][nx])
                q.append([nx,ny])
        # if y == 0 and x == 0:
            # pprint.pprint(dist)
        res = max(res, ans)
print(res)

Measured memory_bytes: 72024
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N;
	
	cin >> N;

	int a[N];
	int c[100010];
	memset(c, 0, sizeof(c));

	int count = 0;

	rep(i, N)
	{
		cin >> a[i];
		if (a[i] > N)
		{
			count++;
		}
		else
		{
			c[a[i]]++;
		}
	}

	//sort(c, c+10010, greater<int>());

	int i = 0;
	/*
	while(c[i] > 0)
	{
		cout << i << " " << c[i] <<endl;
		if (c[i] < i)
		{
			count += c[i];
		}
		else if (c[i] > i)
		{
			count += c[i] - i;
		}
		i++;
	}
	*/
	for(int i = 0; i < 100010;i++)
	{
		if (c[i] < i)
		{
			count += c[i];
		}
		else if (c[i] > i)
		{
			count += c[i] - i;
		}
	}

	cout << count << endl;

	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{

  int N,K;
  cin>>N>>K;
  if(K == 1) K = N;
  cout<<N- K <<endl;
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 256