akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
int a[6];
int main(){
	for(int i=0;i<6;i++)scanf("%d",a+i);
	if(a[4]-a[0]>a[5])printf(":(\n");else printf("Yay!\n");
}

Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
 
main()
{
	char x,y;
	scanf(" %c %c",&x,&y);
	if(x<y) printf("<\n");
	if(x>y) printf(">\n");
	if(x==y) printf("=\n");
		
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int x = 0;
  	cin >> x;
  	cout << (1-x) << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;

int main(){
	int n,t,e,x,ans=-1;
	cin>>n>>t>>e;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(t%x<=e||(t/x+1)*x-t<=e){
			ans=i;break;
		}
	}
	cout<<ans<<endl;
	return 0;
}	

Measured memory_bytes: 1164
# A - Sorted Arrays
N = int(input())
A = list(map(int,input().split()))

if N==1:
    print(1)
    exit()

# 1:plus -1:minus
plus_minus = 0
ans = 0
for i in range(N-1):

    if A[i+1]-A[i]>0:
        if plus_minus == 0:
            ans += 1
            plus_minus = 1
        elif plus_minus == -1:
            plus_minus = 0
        
    elif A[i+1]-A[i]<0:
        if plus_minus == 0:
            ans += 1
            plus_minus = -1
        elif plus_minus == 1:
            plus_minus = 0
    
    if i+1==N-1:
        if plus_minus == 0:
            ans += 1
            continue

print(ans)


Measured memory_bytes: 14432
# -*- coding: utf-8 -*-
"""
C - Vacation
https://atcoder.jp/contests/dp/tasks/dp_c

"""
import sys


def solve(N, acivities):
    pre_A, pre_B, pre_C = 0, 0, 0
    for a, b, c in acivities:
        aa = a + max(pre_B, pre_C)
        bb = b + max(pre_A, pre_C)
        cc = c + max(pre_A, pre_B)
        pre_A, pre_B, pre_C = aa, bb, cc
    return max(pre_A, pre_B, pre_C)


def main(args):
    N = int(input())
    acivities = [[int(i) for i in input().split()] for _ in range(N)]
    ans = solve(N, acivities)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 24260
#include <cstdio>
long long n, a, x, z, C=2500, d[2][5005];
int main() {
	int i, j;
	scanf("%lld%lld", &n, &a);
	d[0][C] = 1;
	for(i=0; i<n; i++, z^=1) {
		scanf("%lld", &x);
		x -= a;
		for(j=0; j<=5000; j++) d[z^1][j] = 0;
		for(j=0; j<=2*C; j++) {
			if(d[z][j]) {
				d[z^1][j] += d[z][j];
				d[z^1][j+x] += d[z][j];
			}
		}
	}
	printf("%lld", d[z][C]-1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl
#define mp make_pair
#define fir first
#define sec second

using namespace std;

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

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10,E = 8e5 + 10;

vector <int> Node[N],Pos[N];
queue <int> Q;
pii id[E],Ans[N];
int to[E],nex[E],beg[N << 1],flow[E],pos[N],vis[N],dis[N << 1],cur[N << 1];
int e = 1,S,T,n;

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-') ch = getchar();
	if(ch == '-') flag = -1,ch = getchar();
	while(isdigit(ch)) x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

inline void Add(int x,int y,int z) {
	to[++e] = y,nex[e] = beg[x],beg[x] = e,flow[e] = z;
	if(x != S && y != T) id[e] = mp(x,y - n + 2);
	to[++e] = x,nex[e] = beg[y],beg[y] = e,flow[e] = 0;
}

inline bool bfs() {
	queue <int> q;
	memset(dis,0,sizeof(dis));
	q.push(S),dis[S] = 1;
	while(!q.empty()) {
		int x = q.front();q.pop();
		if(x == T) return true;
		for(int i = beg[x];i;i = nex[i])
			if(!dis[to[i]] && flow[i]) {
				dis[to[i]] = dis[x] + 1;
				q.push(to[i]);
			}
	}
	return false;
}

inline int dfs(int x,int f) {
	if(x == T || !f) return f;
	int res = f;
	for(int &i = cur[x];i;i = nex[i])
		if(flow[i] && dis[x] + 1 == dis[to[i]]) {
			int val = dfs(to[i],min(res,flow[i]));
			flow[i] -= val,flow[i ^ 1] += val;
			res -= val;
			if(!res) return f;
		}
	return f - res;
}

int main() {
	n = read(),S = n * 2 - 1,T = n * 2;
	For(i,1,n - 1) {
		int sz = read();
		Add(S,i,1);
		For(j,1,sz) {
			int val = read();
			Node[i].push_back(val);
			Pos[val].push_back(i);
			if(val > 1) Add(i,val + n - 2,1);
		}
	}
	For(i,2,n) Add(i + n - 2,T,1);

	int ans = 0,tot = 0;
	while(bfs()) {
		memcpy(cur,beg,sizeof(cur));
		ans += dfs(S,INF);
	}
	if(ans < n - 1) return puts("-1"),0;

	For(i,1,e) if(!flow[i] && id[i].fir) pos[id[i].fir] = id[i].sec;
	Q.push(1);
	while(!Q.empty()) {
		int x = Q.front(); Q.pop();
		For(i,0,Pos[x].size() - 1) {
			int cur = Pos[x][i];
			if(!vis[pos[cur]]) vis[pos[cur]] = true,Ans[cur] = mp(x,pos[cur]),tot++,Q.push(pos[cur]);
		}
	}
	if(tot == n - 1) {
		For(i,1,tot) printf("%d %d\n",Ans[i].fir,Ans[i].sec);
	} else puts("-1");

	return 0;
}

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

int a,b,c,ans; 

inline int read(){
  	int X=0,w=0; 
	char ch=0;
  	while (ch<'0' || ch>'9'){
		w|=ch=='-';
		ch=getchar();
	}
  	while (ch>='0' && ch<='9') 
	    X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
  	return w?-X:X;
}

int main(){
	scanf("%d%d%d",&a,&b,&c);
	ans=min(abs(b-a)+abs(c-b),abs(c-a)+abs(b-c));
	ans=min(ans,abs(b-a)+abs(c-a));
	ans=min(ans,abs(c-b)+abs(a-c));
	ans=min(ans,abs(a-c)+abs(b-a));
	ans=min(ans,abs(b-c)+abs(a-b));
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] A = new int[N];
		for(int i=0; i<N; i++) {
			A[i] = sc.nextInt();
		}

		for(int i=K; i<N; i++) {
			pw.println(A[i]>A[i-K] ? "Yes" : "No");
		}
		
		sc.close();
		pw.close();
	}
}


Measured memory_bytes: 50128
from itertools import groupby, accumulate


def solve(t):
    grp = [(c, len(list(itr))) for c, itr in groupby(t)]
    even_ones = 0
    zeros_splitting_odd_ones = [0]
    for c, cnt in grp:
        if c == '1':
            if cnt % 2 == 0:
                even_ones += cnt
            else:
                even_ones += cnt - 1
                zeros_splitting_odd_ones.append(0)
        else:
            zeros_splitting_odd_ones[-1] += cnt

    # 初期状態で加算されるか
    ad = int(zeros_splitting_odd_ones[0] % 2 == 0)
    is_added_init = [ad]
    for cnt in zeros_splitting_odd_ones[1:]:
        ad ^= (cnt % 2) ^ 1
        is_added_init.append(ad)
    is_added_init.pop()
    acc_added_init = list(accumulate(reversed(is_added_init)))  # 自分より右で、初期状態で足される1の数
    acc_added_init.reverse()

    odd_ones = len(is_added_init)
    ans = 0

    if odd_ones > 0:

        # 先頭の0を全て除くまでのスコア
        zso = zeros_splitting_odd_ones[0]
        zso1 = zso // 2
        zso0 = zso - zso1
        ans += acc_added_init[0] * zso0
        ans += (odd_ones - acc_added_init[0]) * zso1

        # 1に挟まれた0を1箇所1つずつ残して全て除くまでのスコア
        ad = int(zeros_splitting_odd_ones[0] % 2 == 0)
        for i in range(1, odd_ones):
            zso = zeros_splitting_odd_ones[i] - 1
            zso1 = zso // 2
            zso0 = zso - zso1
            left_ones = i
            right_ones = odd_ones - left_ones
            ans += left_ones * zso  # 区間より左の"1"は全てスコアに足される
            ans += left_ones + (right_ones + 1) // 2  # 最後に1つ残った0を削除するときのスコア
            if ad:
                # 除外中の0区間の次の"1"が初期状態で足されるなら、区間を操作する直前にも足される
                ans += acc_added_init[i] * zso0
                ans += (right_ones - acc_added_init[i]) * zso1
            else:
                # 除外中の0区間の次の"1"が初期状態で足されるなら、区間を操作する直前には足されない
                ans += (right_ones - acc_added_init[i]) * zso0
                ans += acc_added_init[i] * zso1
            ad ^= zso % 2

        # 末尾の0を全て除くまでのスコア
        ans += zeros_splitting_odd_ones[-1] * odd_ones

    # 1だけの列を1つずつ除いていくスコア
    all_ones = odd_ones + even_ones
    ao1 = all_ones // 2
    ao0 = all_ones - ao1
    ans += (ao0 * (ao0 + 1) + ao1 * (ao1 + 1)) // 2

    # 0を除いている間の、偶数個の1によるスコア
    all_zeros = len(t) - all_ones
    ans += all_zeros * (even_ones // 2)

    return ans


t = input()
print(solve(t))


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

using namespace std;
#ifdef ONLINE_JUDGE
#define cerr if(false)cerr
#endif

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int long long
#define ld1 long double
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout<<setprecision(14);
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
#define INF (int)1e9
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define endl '\n'
#define vcc vector<char>
#define rep(i,a,b) for(int i=a;i<b;i++)

// if you have no idea just guess the appropriate well-known algo instead of doing nothing -- Benq inspiration
const int mod=998244353;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int powmod(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return powmod(a,mod-2);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

const int N=(int)1e6+6;

void solve(){
    int n; cin >> n;
    int a[n];
    int x=0;

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

    for(int i=0;i<n;i++){
        cout<< (x xor a[i]) <<" ";
    }
    cout<<endl;
}

int32_t main() {
    faster;

#ifndef ONLINE_JUDGE
    READ("input.txt");
    WRITE("output.txt");
    double beg=clock();
#endif

    int t=1;
//    cin>>t;

//    cout<<"hello"<<endl;
    while(t--){
        solve();
    }

#ifndef ONLINE_JUDGE
    double endd=clock();
    cout<<endl;
    cerr<<"*** Total time = "<<(endd-beg)/CLOCKS_PER_SEC;
#endif
}

Measured memory_bytes: 5168
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N, A;
	cin >> N >> A;
	if (N <= A) {
		cout << 0 << endl;
		return 0;
	}
	vector<long long>B(N);
	long long ans = 0;
	for (long long i = 0; i < N; i++) {
		cin >> B.at(i);
	}
	sort(B.begin(), B.end(), greater<int>());
	for (long long i = 0; i < A; i++) {
		B.at(i) = 0;
	}
	for (long long i = 0; i < N; i++) {
		ans += B.at(i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    int n,x;
    scanf("%d%d",&n,&x);
    if (x==1 || x==2*n-1){
        printf("No\n");
    } else {
        printf("Yes\n");
        for (int i=0; i<2*n-1; i++){
            if (x+n-1<2*n-1){
                if (x+n+i<=2*n-1){
                    printf("%d\n",x+n+i);
                } else {
                    printf("%d\n",x-n+i+1);
                }
            } else {
                if (x-n+i+1<=2*n-1){
                    printf("%d\n",x-n+i+1);
                } else {
                    printf("%d\n",x-n+i+1-2*n+1);
                }
            }
        }
    }
	return 0 ;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
char c[5];
int main()
{

    int n,a[105],ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        for(int k=1;k<=n;k++)
        if(i!=j&&j!=k&&i!=k)
        if(a[i]+a[j]>a[k]&&a[i]-a[j]<a[k]&&a[j]-a[i]<a[k]&&a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k]) ans++;
        cout<<ans/6;

}


Measured memory_bytes: 3620
n,m = map(int,input().split())
pre = [[] for _ in range(n)]
num=[]
for i in range(m):
    p,y = map(int,input().split())
    pre[p-1].append([i,y])
for i in range(n):
    pre[i].sort(key=lambda x:x[1])
    for j in range(len(pre[i])):
        num.append([pre[i][j][0],('0'*5+str(i+1))[-6:]+('0'*5+str(j+1))[-6:]])
num.sort(key=lambda x:x[0])
for k in num:
    print(k[1])

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


int main() {
  string S;
  cin>>S;
  
  int K;
  cin>>K;
  
  if(K==1)
    cout<<S.at(0)<<endl;
  else if(S.size()==1)
    cout<<S.at(0)<<endl;
  else{
    int i=0;
    while(S.at(i)=='1'&&i<S.size()-1){
      i++;
    }
    if(K<i+1)
      cout<<1<<endl; 
    else
      cout<<S.at(i)<<endl;    
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

ll h, w, INF=10000000000000000;
ll calc(vll a, vll b){
  vvl c = vv(h+1, h+1, 0, ll), dp = vv(h+1, h+1, INF, ll);dp[0][0] = 0;
  for(int sa=0;sa<h;sa++){
    for(int k=0;k<h;k++){
      if(h-1-k-sa<0) continue;
      c[h-1-k][h-1-k-sa] = c[h-k][h-k-sa] + (a[h-1-k]==b[h-1-k-sa]?1:0);
    }
  }
  for(int sa=0;sa<h;sa++){
    for(int k=0;k<h;k++){
      if(h-1-k-sa<0) continue;
      c[h-1-k-sa][h-1-k] = c[h-k-sa][h-k] + (a[h-1-k-sa]==b[h-1-k]?1:0);
    }
  }
  for(int i=0;i<=h;i++){
    for(int j=0;j<=h;j++){
      if(i!=h) dp[i+1][j] = min(dp[i+1][j], dp[i][j] + c[i][j]);
      if(j!=h) dp[i][j+1] = min(dp[i][j+1], dp[i][j] + c[i][j]);
    }
  }
  return dp[h][h];
}
int main(int argc, char const *argv[]) {
  std::cin >> h >> w;
  vvl d = vv(w, h, -1, ll);
  re(i, h) {
    string s;std::cin >> s;
    re(j, w) d[j][i] = s[j];
  }
  re(i, w) reverse(all(d[i]));
  ll ans = 0;
  for(int i=0;i<w-1;i++) ans += calc(d[i], d[i+1]);
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2464
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(void){

	vector< int > p;
	vector< int > x;

	int p_i, x_i;
	int sum = 0, ave = 0, cnt = 0;

	while( scanf("%d,%d", &p_i, &x_i ) != EOF ) {
		sum += p_i * x_i;
		ave += x_i;
		cnt ++;
	}

	ave *= 10;
	ave /= cnt;
	if( ave % 10 > 4 ) ave = ave / 10 + 1;
	else ave /= 10;

	cout << sum << endl;
	cout << ave << endl;

    return 0;
}

Measured memory_bytes: 1204
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

cnt=0

for i in range(n):
  d=a[i]-1
  cnt+=b[d]
  
for j in range(n-1):
  if a[j]+1==a[j+1]:
    cnt+=c[a[j]-1]

print(cnt)

Measured memory_bytes: 9036
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>
#include <iomanip>
#include <limits>

using namespace std;
using ll = long long;
const ll res = 1000000007;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

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

	while (a > 0 and c > 0) {
		c -= b;
		a -= d;
		if (c <= 0) {
			cout << "Yes" << endl;
		}
		else if (a <= 0) {
			cout << "No" << endl;
		}		
	}
}

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

#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,ans=1e18;
    cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==0){
            k--;
            n--;
            i--;
        }
    }
    if(k==0){
        cout << 0<<endl;
        return 0;
    }
    for(int i=0;i<=n-k;i++){
        if(a[i]<0&&a[i+k-1]>0){
            if(-a[i]>a[i+k-1]){
                ans=min(ans,a[i+k-1]*2-a[i]);
            }
            else{
                ans=min(ans,a[i+k-1]-a[i]*2);
            }
        }
        else{
            if(a[i]<0){
                ans=min(ans,-a[i]);
            }
            else{
                ans=min(ans,a[i+k-1]);
            }
        }
    }
    cout << ans<<endl;
    return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int Mod = 1e9+7;
int S,dp[45][1<<17],ans=1;
int main()
{
    int n,x,y,z,now;
    scanf("%d%d%d%d",&n,&x,&y,&z);
    for(int i=1;i<=n;i++) ans=1LL*ans*10%Mod;
    now=(1<<(x-1))|(1<<(x+y-1))|(1<<(x+y+z-1));
    S=(1<<x+y+z)-1;
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=S;j++)
        {
            for(int k=1;k<=10;k++)
            {
                int T=(j<<k)|(1<<k-1);
                T&=S;
                if((T&now)!=now) dp[i][T]=(dp[i][T]+dp[i-1][j])%Mod;
            }
        }
    }
    for(int i=0;i<=S;i++) ans=(ans-dp[n][i]+Mod)%Mod;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 22400
#include <bits/stdc++.h>
#define inp_out_work ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCase    int T; cin>>T; while(T--)
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,s,e) for(int i=s;i<=e;i++)
#define endl '\n'
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define pb push_back
#define FILE freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);


using namespace std;

typedef long long ll;

int main(){
    inp_out_work
    int n, k;
    cin>>n>>k;
    ll h[n];
    fr(i,n)cin>>h[i];
    ll dp[n];
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        dp[i] = 1e18;
        for(int j = i-1; j >= 0 && j >= i-k; j--)dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
    }
    cout<< dp[n-1] << endl;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll A, B;
    cin >> A >> B;

    if(A == 1){
        if(B==1){
            cout << "Draw" << endl;
            return 0;
        }
        else{
            cout << "Alice" << endl;
            return 0;
        }
    }
    if(B == 1){
        cout << "Bob" << endl;
        return 0;
    }

    if(A>B){
        cout << "Alice" << endl;
        return 0;
    }
    if(A<B){
        cout << "Bob" << endl;
        return 0;
    }
     if(A==B){
        cout << "Draw" << endl;
        return 0;
    }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define rev(r) reverse(r.begin(),r.end())
#define SORT(ar) sort(ar.begin(), ar.end())
#define sz(x) (int)(x).size()
#define len(x) (int)x.length()
#define in(a) scanf("%d",&a)
#define pr(x) printf("%d ",x)
#define endl '\n'
#define read(v,n) for(int h=0;h<n;h++) cin>>v[h];
#define fo(i,a,b) for(i=a;i<b;i++)
#define fi(i,a,b) for(i=a;i>=b;i--)
#define mo 1000000007
#define N 300007
int dp[1002][1002];

int main()
{
    int h,w,i,j,k;
    cin>>h>>w;
    char ch;
    dp[1][1]=1;
    fo(i,1,h+1)
    {
        fo(j,1,w+1)
        {
            cin>>ch;
            if(ch=='.' && (i+j)>2){
                dp[i][j]=(dp[i][j-1]+dp[i-1][j])%mo;;
            }
        }
    }
    cout<<dp[h][w]<<endl;

}


Measured memory_bytes: 4224
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"

	"github.com/emirpasic/gods/trees/binaryheap"
	"github.com/emirpasic/gods/trees/redblacktree"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	h := getNextInt(scanner)
	w := getNextInt(scanner)

	rbt := redblacktree.NewWithIntComparator()
	bh := binaryheap.NewWithIntComparator()
	right := make([]int, w)
	cnt := map[int]int{}
	for i := 0; i < w; i++ {
		rbt.Put(i, 1)
		bh.Push(0)
		right[i] = i
	}
	cnt[0] = w

	for i := 0; i < h; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner)
		x := -1
		for node, ok := rbt.Ceiling(a); ok && node.Key.(int) <= b; node, ok = rbt.Ceiling(a) {
			k := node.Key.(int)
			rbt.Remove(k)
			if x < right[k] {
				x = right[k]
			}
			cnt[k-right[k]]--
			right[k] = -1
		}
		if b < w && x != -1 {
			if right[b] < x {
				right[b] = x
			}
			rbt.Put(b, 1)
			bh.Push(b - right[b])
			cnt[b-right[b]]++
		}
		for p, ok := bh.Peek(); ok && cnt[p.(int)] == 0; p, ok = bh.Peek() {
			bh.Pop()
		}
		if p, ok := bh.Peek(); ok {
			fmt.Fprintln(writer, p.(int)+i+1)
			continue
		}
		fmt.Fprintln(writer, -1)
	}
}


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

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

ll N;
constexpr ll DP_MAX = 100010;
ll dp[DP_MAX][3];
vector<ll> A, B, C;

int main(int argc, char **argv)
{
	cin >> N;
	A.resize(N), B.resize(N), C.resize(N);
	for (ll i = 0; i < N; ++i) cin >> A[i] >> B[i] >> C[i];
	for (ll i = 0; i < DP_MAX; ++i)
		for (ll j = 0; j < 3; ++j)
			dp[i][j] = -(1ll<<50);
	dp[0][0] = dp[0][1] = dp[0][2] = 0;

	for (ll i = 0; i < N; ++i)
	{
		chmax(dp[i+1][0], max(dp[i][1]+A[i], dp[i][2]+A[i]));
		chmax(dp[i+1][1], max(dp[i][0]+B[i], dp[i][2]+B[i]));
		chmax(dp[i+1][2], max(dp[i][0]+C[i], dp[i][1]+C[i]));
	}
	std::cout << max({dp[N][0], dp[N][1], dp[N][2]})<< std::endl;
}


Measured memory_bytes: 4992
n = int(input())
lst = [input().split() for i in range(n)]
# print(lst)

# float型に変換
for i in range(0, len(lst)):
    lst[i][0] = float(lst[i][0])

ans_sum = 0
for i in range(0, len(lst)):
    if lst[i][1] == 'JPY':
        ans_sum += lst[i][0]
    else:
        ans_sum += lst[i][0]*380000

print(ans_sum)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define	pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigboi        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 
//int dp[333][2];	

void solve(){
	int n;
	cin>>n;
	map<string , int> mp;
	FOR(i, 0, n){
		string s;
		cin>>s;
		mp[s]++;
	}
	int res=-1;
	for(pair<string, int> it:mp){
		res = max(res, it.S);
	}
	for(pair<string, int> it:mp){
		if(it.S==res){
			cout<<it.F<<endl;
		}
	}
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 	
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
	//	cout<<"Case #"<<i<<":"<<endl;
		solve();
	}
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
 
}

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

using namespace std;

//#define local
#ifdef local

template<class T>
void _E(T x) { cerr << x; }

void _E(double x) { cerr << fixed << setprecision(6) << x; }

void _E(string s) { cerr << "\"" << s << "\""; }

template<class A, class B>
void _E(pair<A, B> x) {
    cerr << '(';
    _E(x.first);
    cerr << ", ";
    _E(x.second);
    cerr << ")";
}

template<class T>
void _E(vector<T> x) {
    cerr << "[";
    for (auto it = x.begin(); it != x.end(); ++it) {
        if (it != x.begin()) cerr << ", ";
        _E(*it);
    }
    cerr << "]";
}

void ERR() {}

template<class A, class... B>
void ERR(A x, B... y) {
    _E(x);
    cerr << (sizeof...(y) ? ", " : " ");
    ERR(y...);
}

#define debug(x...) do { cerr << "{ "#x" } -> { "; ERR(x); cerr << "}" << endl; } while(false)
#else
#define debug(...) 114514.1919810
#endif
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f
#define ll long long
#define db long double
#define eps 1e-3
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define endl "\n"
#define ls ch[now][0]
#define rs ch[now][1]
const ll mod = 998244353;
const ll maxn = 2e5 + 10;


ll qpow(ll a, ll b) {
    ll ret = 1;
    for (; b; a = a * a % mod, b >>= 1) {
        if (b & 1) {
            ret = ret * a % mod;
        }
    }
    return ret;
}

vector<ll> f(maxn), invf(maxn);

ll inv(ll a) {
    return qpow(a, mod - 2);
}

void prework() {
    f[0] = 1;
    _rep(i, 1, maxn - 1) {
        f[i] = f[i - 1] * i % mod;
    }
    invf[maxn - 1] = qpow(f[maxn - 1], mod - 2);
    for (ll i = maxn - 2; i >= 0; i--) {
        invf[i] = invf[i + 1] * (i + 1) % mod;
    }

}

ll C(ll n, ll m) {
    if (n > m || m < 0)return 0;
    if (n == 0 || m == n) return 1;
    ll res = (f[m] * invf[m - n] % mod * invf[n]) % mod;
    return res;
}

vector<ll> G[maxn];

vector<ll> a;

int solve(int x) {
    ll ret = 0;
    for (auto i:a) {
        ret += (i / x);
        if (i % x == 0)ret--;
    }
    return ret;
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll k, n;
    cin >> n >> k;
    a.resize(n);
    ll l = 1, r = 0;
    for (auto &i:a) {
        cin >> i;
        r = max(r, i);
    }
    sort(all(a));
    ll ans = 0;
    while (l <= r) {
        ll mid = l + r >> 1;
        if (solve(mid) > k) {
            l = mid + 1;
        } else {
            ans = mid;
            r = mid - 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 12696
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define MOD (ll)1000000007

int main(void)
{
	int n;
	scanf("%d", &n);
	int a[101];
	ll ans = 0;
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	for (int i = 1; i <= n - 2; i++)
		for (int j = i + 1; j <= n - 1; j++)
			for (int k = j + 1; k <= n; k++)
			{
				int b[3] = { a[i],a[j],a[k] };
				if ((b[0] == b[1]) || (b[1] == b[2]) ||(b[2] == b[0]))
					continue;
				sort(b, b + 3);
				if (b[0] + b[1] > b[2])
					ans++;
			}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1736
n = int(input())
b = list(map(int, input().split()))
ans = b[0]
a = 0
for i in range(n-2):
    if b[i] >= b[i+1]:
        a = b[i+1]
    else:
        a = b[i]
    ans += a
ans += b[len(b)-1]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////


struct len{
    ll l,r,c;
};
bool comp(len a,len b){
    return a.r<b.r;
}
 
int main(){fastio
    ll n,m;cin>>n>>m;
    len a[m];
    rep(i,0,m-1){
        len b;cin>>b.l>>b.r>>b.c;
        a[i]=b;
    }
    sort(a,a+m,comp);
    ll dp[n+1];rep(i,0,n)dp[i]=inf;
    dp[1]=0;
    ll pos=0;
    while(pos<=m-1){
        vector<len>v;
        v.pb(a[pos]);
        while(pos+1<=m-1&&a[pos].r==a[pos+1].r){
            v.pb(a[pos+1]);pos++;
        }
        for(auto x:v){
            Min(dp[x.r],dp[x.l]+x.c);
        }
        for(ll i=v[0].r;;i--){
            if(dp[i]<dp[v[0].r])break;
            dp[i]=dp[v[0].r];
        }
        //rep(i,1,n)cout<<dp[i]<<" ";cout<<endl;
        
        pos++;
    }
    if(dp[n]==inf)cout<<-1<<endl;
    else cout<<dp[n]<<endl;
    
    
    return 0;
}




Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll;
const int maxn=1e6+10;
const int modn=1e9+7;
ll dp[maxn]={0};
ll mulit(ll a,ll b,ll m){
    ll ans=0;
    while(b){
        if(b&1) ans=(ans+a)%m;
        a=(a<<1)%m;
        b>>=1;
    }
    return ans;
}

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

ll comp(ll a,ll b,ll m){
    if(a<b) return 0;
    if(a==b) return 1;
    if(b>a-b) b=a-b;
    ll 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;
}

ll lucas(ll a,ll b,ll m){
    ll ans=1;
    while(a&&b){
        ans=(ans*comp(a%m,b%m,m))%m;
        a/=m;
        b/=m;
    }
    return ans;
}
int main() {
	int x,y;
	scanf("%d%d",&x,&y);
	if((2*y-x)%3||2*y-x<0){
		printf("0\n");
		return 0;
	}
	int a=(2*y-x)/3;
	cout<<lucas(y-a,a,modn);
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define lep(j,n) for(int j=0; j<(n); j++)
#define reps(i,n) for(int i=1; i<(n); i++)
#define leps(j,n) for(int j=1; j<(n); j++)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const long long mod = 1000000007;
using namespace std;

#define return(Z) re:(Z)

long long h[10000010],x[10000010],z[10000010];

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

  string s;
  cin>>s;
  if(s[0]==s[2]) cout<<"Yes"<<'\n';
  else cout<<"No"<<'\n';
}
 

Measured memory_bytes: 256
from collections import Counter
N, K=list(map(int, input().split()))
A=list(map(int, input().split()))

X=Counter(A)
X2 = sorted(X.items(), key=lambda x:x[1])
ans=0
for i in range(len(X2)-K):
    ans+=X2[i][1]
print(ans)

Measured memory_bytes: 39344
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long 
int arr[10000007]={2};
void solve() {
	int n; cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = i; j <= n; j += i) {
			ans += j;
		}
	}
	cout << ans << "\n";
}
int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;
import java.util.stream.LongStream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int maxW = sc.nextInt();

		long[] value = new long[maxW+1];


		for (int i=0;i<n;i++) {
			int w = sc.nextInt();
			long v = sc.nextLong();
			for (int j=maxW-w;j>=0;j--) {
				value[j+w]=Math.max(value[j+w],value[j]+v);
			}
		}

		System.out.println(LongStream.of(value).max().getAsLong());
	}

}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == 5 && b == 5 && c == 7)cout << "YES";
	else if (a == 5 && b == 7 && c == 5)cout << "YES";
	else if (a == 7 && b == 5 && c == 5)cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 256
program main
    implicit none
    integer:: n, i
    integer, allocatable:: a(:), b(:), c(:)
    integer:: sat

    read*, n

    allocate(a(n), b(n), c(n-1))

    read*, a(1:n)
    read*, b(1:n)
    read*, c(1:n-1)

    sat = sum(b(1:n))
    do i = 1, n-1
        if (a(i+1) - a(i) == 1)then
            sat = sat + c(a(i))
        endif
    end do

    print*, sat

end program

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=86400;
string s,t;
int ls,lt;
bool fun(int p)
{
    for(int i=0; i<lt; i++)
        if(s[p+i]!='?'&&s[p+i]!=t[i])
            return 0;
    return 1;
}
int main()
{
    while(cin>>s>>t)
    {
        ls=s.length();
        lt=t.length();
        bool flag=0;
        int star,end,j;
        for(int i=ls-lt; i>=0; i--)
        {
            if(fun(i))
            {
                for(int k=0; k<lt; k++)
                    s[i+k]=t[k];
                flag=1;
                break;
            }
        }
        if(!flag) puts("UNRESTORABLE");
        else
        {
            for(int i=0; i<ls; i++)
                printf("%c",s[i]=='?'?'a':s[i]);
            puts("");
        }
    }
    return 0;
}

/**
?tc????
coder
??p??d??
abc


**/


Measured memory_bytes: 256
line = input()
X, Y = [int(n) for n in line.split()]


line = input()
numbers = [int(n) for n in line.split()]

predicted_value = 1
for num in numbers:
    if Y - num >= 0:
        predicted_value += 1
        Y -= num
    else:
        break

print(predicted_value)

Measured memory_bytes: 3060
#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N, M, Q = [int(_) for _ in input().split()]
abcd = [[int(_) for _ in input().split()] for i in range(Q)]

com = combinations_with_replacement(range(1, M+1), N)

ma = 0
scores = []
for i in com:
    score = 0
    for j in abcd:
        if i[j[1]-1] - i[j[0]-1] == j[2]:
            score += j[3]
    if score > ma:
        ma = score
print(ma)

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

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;

        rep(i, n) {
            int a[4], b[4];
            rep(j, 4) cin >> a[j];
            rep(j, 4) cin >> b[j];

            cout << a[0]*b[0] - a[1]*b[1] - a[2]*b[2] - a[3]*b[3] << " "
                 << a[0]*b[1] + a[1]*b[0] + a[2]*b[3] - a[3]*b[2] << " "
                 << a[0]*b[2] - a[1]*b[3] + a[2]*b[0] + a[3]*b[1] << " "
                 << a[0]*b[3] + a[1]*b[2] - a[2]*b[1] + a[3]*b[0] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3092
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,avx2,fma,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(0),cin.tie(0), cout.tie(0)
typedef long long ll;


ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

//#######################################

int main(){
  boost;

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

}



Measured memory_bytes: 3668
s=input()

s2 = ''.join(list(reversed(s)))
if s!=s2: print("No")
else:

    e = int((len(s)-1)/2)
    s1=s[:e]
    s2 = ''.join(list(reversed(s1)))
    if s1!=s2: print("No")
    else:
        e = int((len(s)+3)/2)-1
        s1=s[e:]
        s2 = ''.join(list(reversed(s1)))
        if s1!=s2: print("No")
        else: print("Yes")



Measured memory_bytes: 3064
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define MAX 1000100
int MOD=1000000007;
int sosu[MAX]={1,1,0};
vi sos;
void init(){
	for(int i=2;i*i<=MAX;i++)if(!sosu[i])
	for(int j=i*2;j<MAX;j+=i)sosu[j]=true;
	rep(i,MAX)if(sosu[i]==0)sos.pb(i);
}
int main(){
	init();
	int n;
	cin>>n;
	vi in(n+1,inf);
	rep(i,n)cin>>in[i];
	
	if(n==1){
		cout<<!sosu[in[0]]<<endl;
		return 0;
	}
	
	vi dp(n+1);
	dp[n]=1;
	if(!sosu[in[n-1]])dp[n-1]=1;
	for(int i=n-2;i>=0;i--)if(!sosu[in[i]]){
		if(in[i]<in[i+1])(dp[i]+=dp[i+1])%=MOD;
		if(in[i]<in[i+2])(dp[i]+=dp[i+2])%=MOD;
	}
	cout<<dp[0]<<endl;
}







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

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main() {
  int n;
  cin >> n;
  vector<int> A[n];
  rep(i, n) {
    A[i].resize(n-1);
    rep(j, n-1) cin >> A[i][j];
    rep(j, n-1) A[i][j]--;
  }

  int day = 0;
  vector<int> pos(n, 0);
  vector<int> B(n);
  rep(i, n) B[i] = i;
  while(1) {
    vector<bool> yet(n, false);
    vector<int> C;
    for(int i : B) {
      if (yet[i] || pos[i] == n-1) continue;
      int j = A[i][pos[i]];
      if (yet[j] || pos[j] == n-1) continue;
      if (i == A[j][pos[j]]) {
        yet[i] = yet[j] = true;
        pos[i]++; pos[j]++;
        C.push_back(i);
        C.push_back(j);
      }
    }
    if (C.empty()) break;
    swap(B, C);
    day++;
  }
  rep(i, n) if(pos[i] != n-1) {
    cout << -1 << endl;
    return;
  }
  cout << day << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>


static std::vector<long long int> factorial;
static std::vector<long long int> inverse;
constexpr long long int MOD = 1000000007;
long long int comb(int n, int r) {
	return factorial[n] * inverse[n - r] % MOD * inverse[r] % MOD;
}
long long int count_square_sum(int r, int c) {
	long long int result = 0;
	if (r < c) std::swap(r, c);
	for (auto i = 0; i <= c; ++i) {
		result += comb(r + i + 1, i + 1);
		result %= MOD;
	}
	return result;
}
int main(){
	factorial = std::vector<long long int>(2000100, 1);
	inverse = std::vector<long long int>(2000100, 1);
	std::vector<long long int> inv(2000100, 1);
	for (auto i = 2; i < factorial.size(); ++i) {
		factorial[i] = i * factorial[i - 1] % MOD;
		inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
		inverse[i] = inv[i] * inverse[i - 1] % MOD;
	}
	int r1, c1, r2, c2; std::cin >> r1 >> c1 >> r2 >> c2;
	long long int result = 0;
	if (r1 > r2) std::swap(r1, r2);
	if (c1 < c2) std::swap(c1, c2);
	result += count_square_sum(r2, c1);
	result -= count_square_sum(r1 - 1, c1);
	result -= count_square_sum(r2, c2 - 1);
	result += count_square_sum(r1 - 1, c2 - 1);
	result %= MOD;
	result += MOD;
	result %= MOD;
	std::cout << result << std::endl;
}


Measured memory_bytes: 47104
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
    ll A,B,C;
    ll S;
    cin >> A >> B >> C;
    if(A+B>=C){
        S=B+C;
    }
    else{
        S=B+A+B+1;
    }
    cout << S << endl;
}

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

int main(){ 
    int N; cin >> N;
    N = N % 10;

    if(N == 0 || N == 1 || N == 6 || N == 8){
        cout << "pon" << endl;
    } else if(N == 3){
        cout << "bon" << endl;
    } else {
        cout << "hon" << endl;
    }


}


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

int main()
{
  int A, B, sum = 0;

  cin >> A >> B;

  for (int i = A; i < B + 1; i++)
  {
    string num = to_string(i);

    if (num[0] == num[4] && num[1] == num[3])
    {
      sum++;
    }
  }

  cout << sum << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int N, M;
vi A;
vi G[100005];
int vis[100005];

void f(int u, multiset<int> &S) {
    if (vis[u]++)RT;
    S.insert(A[u]);
    each(v, G[u]) {
        f(v, S);
    }
}

void ng() {
    cout << "Impossible" << endl;
    exit(0);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    cin >> N >> M;
    A.resize(N);
    rep(i, N)cin >> A[i];
    rep(i, M) {
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    vector<multiset<int> > U;
    rep(i, N)if (!vis[i]) {
        multiset<int> S;
        f(i, S);
        U.push_back(S);
    }

    auto &S = U[0];
    multiset<pii> un;
    for (int i = 1; i < sz(U); ++i) {
        auto &T = U[i];
        each(a, T) {
            if (sz(T) == 1)un.insert(mp(a + (int)1e9, i));
            else un.insert(mp(a, i));
        }
    }
    vi used(sz(U));
    ll ans = 0;

    for(auto p: un) {
        if (used[p.second]++)continue;
        if (!sz(S))ng();
        auto it = S.begin();
        if (p.first > (int)1e9)p.first -= (int)1e9;
        ans += *it + p.first;
        S.erase(it);
        auto &T = U[p.second];
        each(a, T) {
            if (a > (int)1e9)S.insert(a - (int)1e9);
            else S.insert(a);
        }
        S.erase(S.find(p.first));
    }

    cout << ans << endl;
}

Measured memory_bytes: 19760