akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJProblems
{
    class Program
    {
        static bool ExhaustiveSearch(int i, int m)
        {
            if(m == 0)
            {
                return true;
            }
            if(i >= n)
            {
                return false;
            }
            bool res = ExhaustiveSearch(i + 1, m) || ExhaustiveSearch(i + 1, m - a[i]);
            return res;
        }

        static int n;
        static int[] a;

        static void Main(string[] args)
        {
            n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');

            a = new int[n];
            
            for(int i = 0; i < n; i++)
            {
                a[i] = int.Parse(str[i]);
            }

            int q = int.Parse(Console.ReadLine());
            string[] strer = Console.ReadLine().Split(' ');
            int m = 0;
            var result = new List<string>();
            for(int i = 0; i < q; i++)
            {
                m = int.Parse(strer[i]);
                if(ExhaustiveSearch(0, m))
                {
                    result.Add("yes");
                }
                else
                {
                    result.Add("no");
                }
            }

            foreach (var s in result)
            {
                Console.WriteLine(s);
            } 
        }
    }
}



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

int main(){
    int n=0;
    cin >> n;
    map<string,int> s;
    rep(i,n){
        string temp;
        cin >> temp;
        s[temp];
    }
    cout << s.size() <<endl; 
}

Measured memory_bytes: 19020
#include <stdio.h>

int main(void) {
  int n, i, j, y, x1, x2, x3, k, t = 0;
  scanf("%d %d", &n, &y);
  y /= 1000;
  for(i = 0; i <= n; ++i) {
    for(j = 0; j <= n - i; ++j) {
       k = n - i - j;
       if(10 * i + 5 * j + k == y) {
        t = 1;
        x1 = i, x2 = j, x3= k;
        break;
      }
    }
    if(t) break;
  }
  if(t) printf("%d %d %d\n", x1, x2, x3);
  else printf("-1 -1 -1\n");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn =2e3+5;
const double pi=acos(-1);

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double jiao1=2*pi*m/60.0;
	double shi=h*60.0+m;
	double jiao2=2*pi*shi/720.0;
	/*if(jiao1>=pi)
    {
        jiao1=2.0*pi-jiao1;
    }
    if(jiao2>=pi)
    {
        jiao2=2.0*pi-jiao2;
    }*/
    //cout<<jiao1<<" "<<jiao2<<'\n';
    double jiao=abs(jiao1-jiao2);
    double ans=sqrt(a*a+b*b-2.0*a*b*cos(jiao));
    //double ans=sqrt(a*a+b*b-2.0*a*b*cos(jiao));
    cout<<fixed<<setprecision(15)<<ans<<'\n';



}


Measured memory_bytes: 4192
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;


int main(){
  int a, b, c, d; cin >> a >> b >> c >> d;
  cout << max(0, min(b, d) - max(a, c)) << endl;
}


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

int main() {
	string S,ans;
	cin>>S;
	for(int i=0;i<S.size();i++){
		if(S[i]=='0'||S[i]=='1'){
			ans+=S[i];
		}else if(S[i]=='B'){
			if(!ans.empty()){
				ans.pop_back();
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> sum_a(n + 1), sum_b(m + 1);
    sum_a[0] = 0;
    sum_b[0] = 0;
    int a, b;
    rep(i, n) {
        cin >> a;
        sum_a[i+1] = sum_a[i] + a;
    };
    rep(i, m) {
        cin >> b;
        sum_b[i+1] = sum_b[i] + b;
    };
    int ans = 0;
    int max_j = m;
    rep(i, n + 1){
        if(sum_a[i] > k) break;
        int j = max_j;
        while(k - sum_a[i] < sum_b[j]){
            j--;
        }
        ans = max(ans, i + j);
        max_j = min(j, max_j);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6408
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int test)
{
  string s;
  cin >> s;
  int64 ans = 0;
  int a = 0;
  for (size_t i = 0; i < s.size() - 1; ++i) {
    if (s[i] == 'A') {
      ++a;
      continue;
    }
    if (s[i] == 'B' && s[i + 1] == 'C') {
      ans += a;
      i += 1;
      continue;
    }
    a = 0;
  }
  cout << ans << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

typedef long double D;
typedef complex<D>P;
const D PI=acos(-1);


int N,K;
P p[222222];

inline D cross(const P &p,const P &q){
    return real(p)*imag(q)-imag(p)*real(q);
}

inline D getS(int i,int j,int k){
    return abs(cross(p[j]-p[i],p[k]-p[i]))/2;
}

bool C(D s){
    int cnt=0;
    for(int i=1;i<N-1;i++){
        int lb=-1,ub=(i+1)/2;
        while(ub-lb>1){
            int mid=(ub+lb)/2;
            if(getS(N-1,i,mid)>s)ub=mid;
            else lb=mid;
        }
        cnt+=ub*2;
        if(i%2&&ub==(i+1)/2)cnt--;
    }

    if(N%3==0&&getS(0,N/3,N/3*2)<=s)cnt+=2;
    cnt/=3;
    cnt*=N;
    return cnt>=K;
}

signed main(){
    cin>>N>>K;

    for(int i=0;i<N;i++)p[i]=polar((D)1.0,2*PI/N*i);

    D lb=0.0,ub=2*PI;

    for(int i=0;i<50;i++){
        double mid=(ub+lb)/2;
        if(C(mid))ub=mid;
        else lb=mid;
    }

    cout<<setprecision(10);
    cout<<ub<<endl;
    return 0;
}


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

int A[4];

int main() {
	cin >> A[0] >> A[1] >> A[2] >> A[3];
	sort(A, A + 4);
	if (A[0] == 1 && A[1] == 4 && A[2] == 7 && A[3] == 9) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 764
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
using namespace std; const int N=200010;
inline int read()
{
	int s=0, w=1; ri char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar(); return s*w;
}
int n,m,v,p,a[N],now,res;
inline bool cp(int x,int y) { return x>y; }
signed main()
{
	n=read(), m=read(), v=read(), p=read();
	for(ri int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+1+n,cp); now=p;
	for(ri int i=p+1;i<=n;res+=a[p]-a[i], i++)
	{
		if(a[p]>a[i]+m) break; // m 次全部加上去还不如别人不加
		if(p-1+n-i+1>=v || ((v-(p-1+n-i+1))*m-res-1)/(i-p)<=a[i]-a[p]-1+m) now++;// 否则把数都加给 i 和后面以及 p-1 和前面
		// 还有一种情况，还得给 p 到 i-1 这里放，那么尽量使得放了之后平均最小即可。 
	} printf("%lld\n",now);
	return 0;
}

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

int n, k;
int a[100000];
int ra[100001];	//ra[i] = a[0] + ??? + a[i-1]

int main() {
	while (cin >> n >> k) {
		for(int i = 0; i < n; i++) cin >> a[i];
		if (!n) { break; }
		ra[0] = 0;
		for (int i = 0; i < n; i++) {
			ra[i+1] = ra[i] + a[i];
		}

		int ans = -1000000001;
		for (int i = k; i <= n; i++) {
			ans = max(ans, ra[i] - ra[i-k]);
		}

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

Measured memory_bytes: 1940
#include<iostream>
#include<queue>
using namespace std;
queue<int> Q[3];
int main(){
	string s;
	for(int i=0;i<3;i++){
		cin>>s;
		for(int j=0;j<s.size();j++)Q[i].push(s[j]-'a');
	}
	int t=0;
	while(true){
		if(Q[t].size()==0)break;
		int r=Q[t].front();
		Q[t].pop();t=r;
	}
	char z=t+'A';
	cout<<z<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int n;
long long f[87];

int main(void){
	scanf("%d",&n);
	f[0]=2,f[1]=1;
	for(int i=2;i<=n;i++)
		f[i]=f[i-1]+f[i-2];
	printf("%lld\n",f[n]);
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int cnt1=0,cnt2=0,cnt3=0,cnt4=0;
    string s;
    for (int i=0;i<n;i++){
        cin>>s;
        if(s=="AC") cnt1++;
        else if(s=="WA") cnt2++;
        else if(s=="TLE") cnt3++;
        else cnt4++;
    }
    cout<<"AC x "<<cnt1<<"\n";
    cout<<"WA x "<<cnt2<<"\n";
    cout<<"TLE x "<<cnt3<<"\n";
    cout<<"RE x "<<cnt4<<"\n";
	return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef tuple<int,int,int> PP;
typedef pair<int,int> P;
int n;
int s[11],t[11],u[11];
set<P> used[11];
int st,en;
map<PP,int> m;
void dfs(int d,int a,int b){
  if(used[d].count(P(a,b))) return;
  used[d].insert(P(a,b));
  if(d&&b-a>en-st) return;
  if(d==n){
    if(b-a<en-st||(b-a==en-st&&a<st)) st=a,en=b;
    return;
  }
  for(int k=0;k<6;k++){
    for(int i=0;i<60;i++){
      auto latte=make_tuple((s[d]+i)%60,(t[d]+i)%60,(u[d]+i)%60);
      if(m.count(latte))
	dfs(d+1,min(a,m[latte]),max(b,m[latte]));
    }
    if(k%2==0) swap(t[d],u[d]);
    if(k%2==1) swap(s[d],u[d]);
  }
}
string calc(int x){
  string h=to_string((x/3600)%24);
  string m=to_string((x/60)%60);
  string s=to_string(x%60);
  while(h.size()<2) h="0"+h;
  while(m.size()<2) m="0"+m;
  while(s.size()<2) s="0"+s;
  return h+":"+m+":"+s;
}
signed main(){
  for(int i=0;i<43200;i++)
    m[make_tuple((i/720)%60,(i/60)%60,i%60)]=i;
  //cout<<m.size()<<endl;
  while(cin>>n,n){
    for(int i=0;i<11;i++) used[i].clear();
    for(int i=0;i<n;i++) cin>>s[i]>>t[i]>>u[i];
    st=0,en=43200;
    dfs(0,43200,0);
    cout<<calc(st)<<" "<<calc(en)<<endl;
  }
  return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  int p = 700;
  int a = S.size();
  
  for (int i = 0; i < a; i++) {
    if (S.at(i) == 'o') p += 100;    
  }
  
  cout << p << endl;
}


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


typedef pair<int, bool> button;

int main(void){
    // 入力部分
    int N; // ボタンの総数
    cin >> N;
    
    button buttons[N]; // ボタンを表すpairの配列
    for (int i=0; i<N; i++){
        cin >> buttons[i].first;
        buttons[i].second = false;
    }
    
    
    // 処理部分
    int button_index = 0; // 何番目のボタンを押しているかを表す
    int counter = 0; // 何回ボタンを押したかを表す
    while(!buttons[button_index].second && button_index != 1){
        buttons[button_index].second = true;
        counter++;
        button_index = buttons[button_index].first - 1;
    }
    
    if (button_index == 1){
        cout << counter << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> LLLL;

const LL MOD = 1000000007;
static const size_t MAX_N = 1000001;

struct modll {
	long long x;
	modll() { }
	modll(int _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(int y) { return (x + y + MOD) % MOD; }
	modll operator+=(int y) { x = (x + y + MOD) % MOD; return *this; }
	modll operator-(int y) { return (x - y + MOD) % MOD; }
	modll operator-=(int y) { x = (x - y + MOD) % MOD; return *this; }
	modll operator*(int y) { return (x * y) % MOD; }
	modll operator*=(int y) { x = (x * y) % MOD; return *this; }
	modll operator/(int y) { return (x * modpow(y, MOD - 2)) % MOD; }
	modll operator/=(int y) { x = (x * modpow(y, MOD - 2)) % MOD; return *this; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		LL n = -1, a, b;
		cin >> n;
		if (n < 0) return 0;
		map<LLLL, LL> m;
		LL zc = 0;
		for (int i = 0; i < n; ++i) {
			cin >> a >> b;
			LL g = gcd(a, b);
			if (a == 0 && b == 0) {
				++zc;
				continue;
			} else if (a == 0) {
				b = -1;
			} else if (b == 0) {
				a = 1;
			} else {
				a /= g, b /= g;
			}
			if (a < 0) {
				a = -a, b = -b;
			}
			m[LLLL(a, b)] += 1;
		}
		set<LLLL> s;
		modll ans = 1;
		for (auto kv : m) {
			if (s.find(kv.first) != s.end()) continue;
			s.insert(kv.first);
			LL c = kv.first.second, d = -kv.first.first;
			if (c < 0) {
				c = -c, d = -d;
			}
			LLLL dis(c, d);
			auto it = m.find(dis);
			modll x = modll::modpow(2, kv.second);
			if (it != m.end()) {
				s.insert(dis);
				x += modll::modpow(2, it->second) - 1;
			}
			ans *= x;
		}
		ans += zc - 1;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 28588
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define y1 zzz
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,PII >
#define PII3 pair<PII,int >
#define PII4 pair<PII,PII >
#define all(x) (x).begin(),(x).end()
#define pb push_back
int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int n;
void solve()
{
    cin>>n;
    cout<<a[n-1];
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("STRWC.inp","r",stdin);
    //freopen("STRWC.out","w",stdout);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}


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

int main() {
    string s; cin >> s;
    int ans;
    rep(i,1,s.size()/2) {
        if (s.substr(0, i) == s.substr(i, i)){
            ans = i * 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
import java.util.Scanner;
     
    public class Main {
     
    	public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
    String S = sc.next();
    if (S.contains("A") && S.contains("B")) {
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
        }
    }

Measured memory_bytes: 35572
parseInt(x) = parse(Int, x)
parsemap(x::Array{SubString{String},1}) = map(parseInt, x)
using DataStructures

function main()
    n::Int=parseInt(readline())
    a::Vector{Int}=sort(parsemap(split(readline())),rev=true)
    bet=Queue{Int}()
    enqueue!(bet,a[1])
    ans::Int=0
    for i in 2:n
        ans+=dequeue!(bet)
        enqueue!(bet,a[i])
        enqueue!(bet,a[i])
    end
    println(ans)
end
main()

Measured memory_bytes: 215852
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin>>s;
  int a = s.size();
  vector<char> tappu(a);
  for(int i=0;i<a;i++)
    tappu.at(i)=s.at(i);
  for(int i=0;i<a;i++){
    if((i+2)%2==0&&tappu.at(i)=='L'){
      cout<<"No"<<endl;
      break;
    }
    if((i+2)%2==1&&tappu.at(i)=='R'){
      cout<<"No"<<endl;
      break;
    }
    if(i+1==a){
      cout<<"Yes"<<endl;
    break;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int d[3];
int main(){
	for(int i=0;i<3;i++)cin>>d[i];
	sort(d,d+3);
	do{
		if(d[0]==d[1]&&d[1]!=d[2]){
			cout<<"Yes"<<endl;
			return 0;
		}
	}while(next_permutation(d,d+3));
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		
		if (a == 1) {
			a = 14;
			if (b == 1) {
				b = 14;
			}
		} else if (b == 1) {
			b = 14;
			if (a == 1) {
				a = 14;
			}
		} else {
			
		}
		
		if (a > b) {
			System.out.println("Alice");
		} else if (a == b){
			System.out.println("Draw");
		} else {
			System.out.println("Bob");
		}
	}
}

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

using namespace std;

template<class T>
T square(const T &x) { return x * x; }

template<class T>
bool chmin(T &a, const T &b) { return b < a && (a = b, 1); }

const int INF = 2147483647;

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

  vector<int> a(N);
  for (int &i : a) cin >> i;

  int res = INF;
  for (int i = -100; i <= 100; ++i) {
    int sum = 0;
    for (const int &x : a) sum += square(x - i);
    chmin(res, sum);
  }

  cout << res << endl;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll n;
    cin >> n;
    NREP() {
        ll a;
        cin >> a;
        if (a % 2 == 0) {
            if (a % 3 != 0 && a % 5 != 0) {
                MSG("DENIED")
                exit(0);
            }
        }
    }
    MSG("APPROVED")
}


Measured memory_bytes: 256
"""
Problem A: ICPC 得点集計ソフトウェア
"""
if __name__ == '__main__':
    ans = []
    while(True):
        n = int(input())
        if n == 0:
            break
            
        l = [int(input()) for _ in range(n)]
        maxi = max(l)
        mini = min(l)
        ans.append((sum(l) - maxi - mini)//(n-2))
    print(*ans, sep='\n')



Measured memory_bytes: 5624
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
  int N; cin >> N;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];
  vector<ll> sum(N+1);
  rep(i,N){
    sum[i+1] = sum[i] + a[i];
  }
  ll ans = LINF;
  repr(i,1,N){
    ll now = abs(sum[i]-(sum[N]-sum[i]));
    ans = min(ans,now);
  }
  cout << ans << endl;

}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  int n;
  cin >> n;
  cout << n * 800 - n/15 * 200 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int S, h, m, s;
    
    scanf("%d", &S);
    
    h = S / 3600;
    m = S % 3600 / 60;
    s = (S % 3600) % 60;
    
    printf("%d:%d:%d\n", h, m, s);
    
    return 0;
}




Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a = 0,b = 0,c = 0,d = 0,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>S;

    for(int i=0;S[i];i++)
        if(S[i]=='N')a = 1;
        else if(S[i]=='S')b = 1;
        else if(S[i]=='W')c = 1;
        else d = 1;

    if((a^b)||(c^d))cout<<"No\n";
    else cout<<"Yes\n";

    return 0;
}


Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    a, b, k = list(map(int, input().rstrip('\n').split()))
    x = []
    for i in range(1, max(a, b) + 1):
        if a % i == 0 and b % i == 0:
            x.append(i)
    print(sorted(x)[-k])


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 303030
void build(){

}
LL n , a[ N ];
void init(){
  n = getint();
  for( int i = 0 ; i < 3 * n ; i ++ )
    a[ i ] = getint();
  sort( a , a + 3 * n );
  reverse( a , a + 3 * n );
}
void solve(){
  LL ans = 0;
  for( int i = 0 ; i < n ; i ++ )
    ans += a[ i * 2 + 1 ];
  cout << ans << endl;
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 2560
mod=1000000007
N,M = map(int,input().split())
dp = [-1]*(N+1)
dp[0] = 1

for i in range(M):
    dp[int(input())] = 0
    
for i in range(1, 1+N):
    if dp[i] == 0:
        continue
    else:
        if i == 1:
            dp[i] = dp[i-1]%mod
        else:
            dp[i] = (dp[i-1]+dp[i-2]) % mod
if dp[N] == -1:
    print(0)
else:
    print(dp[N])


Measured memory_bytes: 6900
N=int(input())
A=[]
dd=0
LL,RR=[],[]

for i in range(N):
  L,R=map(int, input().split())
  LL.append(L)
  RR.append(R)
  A.append((L,-R))
LL=sorted(LL)
RR=sorted(RR)
A=sorted(A)
dl,dr=0,10**9+1
el,er=0,10**9+1
D=[0 for i in range(N-1)]
E=[0 for i in range(N-1)]

for i in range(N-1):
  dl=max(dl,A[i][0])
  dr=min(dr,-A[i][1])
  D[i]=dr-dl+1
  el=max(el,A[-1-i][0])
  er=min(er,-A[-1-i][1])
  E[-i-1]=er-el+1
ans=dd
for i in range(len(D)):
  d=max(0,D[i])+max(0,E[i])
  ans=max(d,ans)
for L,R in A:
  l=LL[-1]
  r=RR[0]
  if l==L:
    l=LL[-2]
  if r==-R:
    r=RR[1]
  d=(-R-L+1)+max(0,r-l+1)
  ans=max(ans,d)
print(ans)  

Measured memory_bytes: 35092
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n, m, c;
    cin >> n >> m >> c;
    vi b(m);
    rep(i, m) cin >> b[i];
    int ans = 0;
    rep(_, n) {
        int sum = c;
        rep(i, m) {
            int a;
            cin >> a;
            sum += a * b[i];
        }
        if(sum > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

const int N = 1e3 + 5;

int main()
{
	string s; cin >> s;
	if (s.size() >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=10e9+7;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}

int main(void){
    ll N;
    cin>>N;
    vector<ll> A(N),B(N,0);
    rep(i,N) cin>>A.at(i);
    for(ll i=N;i>0;i--){
        ll kosu=0;
        for(ll j=2*i;j<=N;j+=i){
            kosu+=B.at(j-1);
        }
        if(kosu%2!=A.at(i-1)) B.at(i-1)=1;
    }
    vector<ll> ans(0);
    rep(i,N) if(B.at(i)) ans.push_back(i+1);
    cout<<ans.size()<<endl;
    if(ans.size()==0) return 0;
    rep(i,ans.size()-1) cout<<ans.at(i)<<" ";
    cout<<ans.at(ans.size()-1)<<endl;
    return 0;
}


Measured memory_bytes: 4980
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_variables)]
        #[allow(unused_mut)]
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, string).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, string).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("parse error")
    };
}

fn main() {
    input!{
        n: usize,
        v: [i32; n]
    }
    let mut costs: Vec<i32> = vec![std::i32::MAX; n + 1];
    costs[0] = 0;
    for i in 1..n {
        let costa = (v[i-1] - v[i]).abs() + costs[i - 1];
        let costb =
            if i < 2 {std::i32::MAX}
            else {(v[i-2] - v[i]).abs() + costs[i - 2]};
        costs[i] = cmp::min(costa, costb);
    }
    println!("{}", costs[n - 1]);
}


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

int n, t, a, b, e[2], ans;
long long dp[35], ac, INF = 1e9+7;
P s[2][200005];

int main(){
	scanf("%d%d", &n, &t); t++;
	rep(i,n){
		scanf("%d%d", &a, &b);
		s[!a][e[!a]++] = {a+1,b+1};
	}
	sort(s[0], s[0]+e[0], [](P &a, P &b){
		return a.second * (b.first-1) < b.second * (a.first-1);
	});
	sort(s[1], s[1]+e[1]);
	fill(dp,dp+30, INF);
	dp[0] = 1;
	rep(i,e[0]) for(int j=29; j>0; j--){
		dp[j] = min(dp[j], dp[j-1] * s[0][i].first + s[0][i].second);
	}
	rep(i,e[1]+1){
		ans = max(ans,(int)(i+upper_bound(dp, dp+30, t-ac)-dp-1));
		if(i<e[1]){
			ac += s[1][i].second;
			if(t <= ac) break;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 5888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp11
{
    class Class32
    {
        static void Main()
        {
            var I = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = I[0];
            var B = I[1];
            var C = I[2];
            for(int i = 1; i <= B; i++)
            {
                if (A * i % B == C)
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 11348
N, M, C = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

count = 0
for _ in range(N):
    A = [int(i) for i in input().split()]
    su = C
    for ai, bi in zip(A, B):
        su += ai * bi
    if su > 0:
        count += 1

print(count)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

int gcd(int a,int b) {return b==0 ? a : gcd(b, a%b);}
int lcm(int a,int b) {return a / gcd(a,b) * b;}
int gcd(vector<int> &v) {
    int ret = v[0];
    for(int i = 1; i < (int)v.size(); ++i) ret = gcd(ret, v[i]);
    return ret;
}
int lcm(vector<int> &v) {
    int ret = v[0];
    for(int i = 1; i < (int)v.size(); ++i) ret = lcm(ret, v[i]);
    return ret;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    cout << lcm(a) << endl;
    return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n;
	cin >> n;
	vi a(n), f(n);
	Foz(i, n) cin >> a[i];
	f[0] = a[0];
	For(i, 1, n) f[i] = f[i - 1] + max(0, a[i] - a[i - 1]);
	cout << f[n - 1] << '\n';
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

long long modinverse(long long a, long long b, long long s0 = 1, long long s1 = 0) { return b == 0 ? s0 : modinverse(b, a % b, s1, s0 - s1 * (a / b)); }
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long mul(long long a, long long b, long long m) {
	long long q = (long double) a * (long double) b / (long double) m;
	long long r = a * b - q * m;
	return (r + m) % m;
}
 
struct Equation {
	Equation(long long a, long long m) { mod = m, ans = a, valid = true; }
	Equation() { valid = false; }
	Equation(Equation a, Equation b) {
		ans = -1;
		if(!a.valid || !b.valid) {
			valid = false;
			return;
		}
		long long g = gcd(a.mod, b.mod);
		if((a.ans - b.ans) % g != 0) {
			valid = false;
			return;
		}
		valid = true;
		mod = a.mod * (b.mod / g);
		ans = a.ans +
			  mul(
					mul(a.mod, modinverse(a.mod, b.mod), mod),
					(b.ans - a.ans) / g
			  , mod);
		ans = (ans % mod + mod) % mod;
	}
	long long mod, ans;
	bool valid;
};

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	long long x;
	std::cin >> x;
	long long ans = 2*x;
	std::vector<long long> primes;
	{
		long long m = x;
		for(long long l = 2; l * l <= m; l++) {
			long long e = 1;
			while(m % l == 0) {
				e *= l;
				m /= l;
			}
			if(e > 1) primes.push_back(e);
		}
		if(m > 1) {
			primes.push_back(m);
		}
	}
	auto test = [&](long long val) {
		//std::cout << "testing " << val << '\n';
		if(val <= 1) return false;
		if((val % 2 == 0 ? mul(val/2, val-1, x) : mul((val-1)/2, val, x)) == 0) {
			ans = std::min(ans, val-1);
			return true;
		}
		return false;
	};
	test(x+1);
	test(x);
	test(2*x);
	test(2*x-1);
	int n = (int) primes.size();
	for(int i = 0; i < (1 << n); i++) {
		long long a = 1, b = 1;
		for(int j = 0; j < n; j++) {
			if(i & (1 << j)) {
				a *= primes[j];
			} else {
				b *= primes[j];
			}
		}
		assert(a * b == x);
		{
			// val % (2*a) == 0
			// val % b == b-1
			auto eq = Equation(Equation(0, 2*a), Equation(b-1, b));
			test(eq.ans);
			test(eq.ans+1);
		}
		{
			// val % a == 0
			// val % b == b-1
			auto eq = Equation(Equation(0, 2*a), Equation(b-1, b));
			test(eq.ans);
			test(eq.ans*2);
			test(eq.ans+1);
			test(eq.ans*2+1);
		}
		{
			// val % a == 0
			// val % (2*b) == 2*b-1
			auto eq = Equation(Equation(0, a), Equation(2*b-1, 2*b));
			test(eq.ans);
			test(eq.ans*2);
			test(eq.ans+1);
			test(eq.ans*2+1);
		}
	}
	std::cout << ans << '\n';
	return 0;
	for(int i = 1; 1; i++) {
		if(test(i+1)) {
			std::cout << "real answer is " << i << '\n';
			break;
		}
	}
}

Measured memory_bytes: 3644
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
    int n,ans=-1;
    cin >> n;
    int a[110000];
    for(int i=0;i<n;i++){
        int b;
        cin >> b;
        a[b]++;
    }
    for (int i=1;i<=100000;i++) {
        ans = max(ans,a[i-1]+a[i]+a[i+1]);
    }
    cout << ans;
}

Measured memory_bytes: 640
N, M, X = map(int, input().split())
costs = []
incs = []
for _ in range(N):
    C, *inc = map(int, input().split())
    costs.append(C)
    incs.append(inc)
ans = 1e100
for i in range(1 << N):
    tot = 0
    skills = [0] * M
    for j in range(N):
        if (i & (1 << j)) == 0:
            continue
        tot += costs[j]
        for k in range(M):
            skills[k] += incs[j][k]
    if min(skills) >= X:
        ans = min(ans, tot)
if ans == 1e100:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 68752
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

#include<bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using boost::multiprecision::cpp_int;
#define inf  (int)1e18
#define EPS   1e-9
#define MOD 1000000007
#define all(k) k.begin(),k.end()
#define Pi 3.14159
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define repk(i,a,n) for(int i=a;i<=(n);i++)
#define ll  long long unsigned int
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vc vector<char>
#define vl vector<ll>
#define vi vector<int>
#define vc vector<char>
#define vvc vector<vc>
#define mi map<int,int>
#define ml map<ll,ll>
#define umap unordered_map<int,int>
using namespace std;

void sol() {
	string s;
	cin >> s;
	string s1 = "s", s2 = "es";
	// s.resize(s.length());
	int id = s.length();
	if (s[s.length() - 1] == 's')
	{s.insert(id, s2); }
	else
		s.insert(id, s1);

	cout << s;
}



int main() {


	int t = 1;


	// for (cin >> t; t; t--)
	sol();


	return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<bool> dp(K, false);
  for (int k = 1; k <= K; k++) {
    for (int i = 0; i < N; i++) {
      if (k - A[i] >= 0 && dp[k - A[i]] == false) dp[k] = true;
    }
  }
  string ans;
  if (dp[K])
    ans = "First";
  else
    ans = "Second";
  cout << ans << endl;
  return 0;
}

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

using namespace std;

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

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

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

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

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

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	ll x[114], y[114], h[114];
	cin>>n;
	REP(i, n){
		cin>>x[i]>>y[i]>>h[i];
	}
	for(ll c1=0; c1<=100; ++c1){
		for(ll c2=0; c2<=100; ++c2){
			bool f=false, ok=true;
			ll H=1e18;
			REP(i, n){
				if(f){
					if(h[i]==0){
						if(H>abs(x[i]-c1)+abs(y[i]-c2)){
							ok=false;
							i=n;
						}
					}
					else if(H!=h[i]+abs(x[i]-c1)+abs(y[i]-c2)){
						ok=false;
						i=n;
					}
				}
				else{
					if(h[i]==0){
						H=min(H, abs(x[i]-c1)+abs(y[i]-c2));
					}
					else if(H<h[i]+abs(x[i]-c1)+abs(y[i]-c2)){
						ok=false;
						i=n;
					}
					else{
						H=h[i]+abs(x[i]-c1)+abs(y[i]-c2);
						f=true;
					}
				}
			}
			if(ok && H>=1){
				cout<<c1<<' '<<c2<<' '<<H<<'\n';
				return 0;
			}
		}
	}
	return 0;
}


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

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

using namespace std;
using ll = long long;
using ld = long double;

const int L = 1e5 + 1;
const ll MOD = 1e9 + 7;
const ll INF = (1LL << 61);

int n, m;

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

    cin >> n >> m;
    cout << (n == m ? "Yes" : "No");

    return 0;
}
/// ACTUAL CODE STARTS HERE:
/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */


Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]

r = 0
ans = 0
for i in range(N):
    if r == 1:
        if A[i] != 0:
            A[i] += 1
        else:
            r = 0
    ans += A[i]//2
    r = A[i]%2

print(ans)

Measured memory_bytes: 80660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1005,mod=1e9+7;
ll h,w,dp[N][N];
char a[N][N];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>h>>w;
    for(ll i=1;i<=h;i++)for(ll j=1;j<=w;j++)cin>>a[i][j];
    dp[1][1]=1;
    for(ll i=1;i<=h;i++){
        for(ll j=1;j<=w;j++){
            if(i-1>=1 && a[i-1][j]=='.')dp[i][j]+=dp[i-1][j];
            if(j-1>=1 && a[i][j-1]=='.')dp[i][j]+=dp[i][j-1];
            dp[i][j]%=mod;
        }
    }
    cout<<dp[h][w];
}

Measured memory_bytes: 9088
import java.util.*;

public class Main {
	static class StringRangeQuery {
		int N;
		boolean[][] v;
		char[] str;
		
		public StringRangeQuery(String s) {
			str = s.toCharArray();
			N=1;
			while(N<s.length())
				N<<=1;
			v = new boolean[26][N*2-1];
			for(int i=0; i<s.length(); i++)
				set(str[i], i, true);
		}
		
		public void set(char c, int i, boolean on) {
			i+=N-1;
			v[c-'a'][i] = on;
			while(i>0) {
				i = (i-1)/2;
				v[c-'a'][i] = v[c-'a'][i*2+1] | v[c-'a'][i*2+2];
			}
		}
		
		//maximum value in range [a, b)
		public long countCharcterType(int a, int b) {
			int ans = 0;
			for(int i=0; i<26; i++)
				if(contain(a, b, 0, 0, N, i))
					ans++;
			return ans;
		}
		public boolean contain(int a, int b, int k, int l, int r, int c) {
			if(a<=l && r<=b) {
				return v[c][k];
			} else if(r<=a || b<=l) {
				return false;
			} else {
				return contain(a, b, k*2+1, l, (l+r)/2, c) | contain(a, b, k*2+2, (l+r)/2, r, c);
			}
		}
		
		public void set(int i, char c) {
			if(str[i]==c)
				return;
			set(c, i, true);
			set(str[i], i, false);
			str[i] = c;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		String S = sc.next();
		int Q = sc.nextInt();
		StringRangeQuery srq = new StringRangeQuery(S);
		
		for(int i=0; i<Q; i++) {
			int type = sc.nextInt();
			if(type==1) {
				int idx = sc.nextInt()-1;
				char c = sc.next().toCharArray()[0];
				srq.set(idx, c);
			} else {
				int l = sc.nextInt()-1;
				int r = sc.nextInt();
				System.out.println(srq.countCharcterType(l, r));
			}
		}
		
		sc.close();
	}

}



Measured memory_bytes: 102272
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF = 100000000;
ll i,j,k;
ll mod=1000000007;
vector<ll> sum;
void pre_process(vector<ll> &a,vector<ll> &s){//累積和のvector
    ll n=(ll)a.size();
    s.assign(n+1,0);
    for(i=0;i<n;i++){
        s[i+1]=s[i]+a[i];
    }
}
ll query(ll i,ll j,vector<ll> &s){//区間[i,j]の和
    return (s[j]-s[i]);
}

int main(){
    ll n,q;cin>>n>>q;
    string s;cin>>s;

    vector<ll> AC(n,0);

    for(i=0;i<n-1;i++){
        if(s[i]=='A' && s[i+1]=='C'){AC[i]=1;}
        //ACのときAの番号に1を代入
    }
    
    pre_process(AC,sum);//累積和の作成
    vector<ll> ans(n);

    for(i=0;i<q;i++){
        ll l,r;
        cin>>l>>r;
        ans[i]=query(l-1,r,sum);
        if(s[r-1]=='A' && s[r]=='C'){ans[i]--;}//Aが端っこに入ってしまった場合(ACの出来損ない)
    }

    for(i=0;i<q;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3456
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-6;

using namespace std;

int main()
{
	int table[18];
	int wait[100];
	memset(table, -1, sizeof(table));
	memset(wait, 0, sizeof(wait));
	table[17] = 1;

	int front = 0;
	int len = 2;
	for (int i = 0; front < 100; ++i)
	{
		while (i >= front*5 && front < 100)
		{
			int l = 0;
			int p = -1;
			for (int j = 0; p == -1 && j < 17 + 1; ++j)
			{
				if (table[j] <= 0)
					++l;
				else
				{
					if (l >= len)
						p = j - l;
					l = 0;
				}
			}
			if (p != -1)
			{
				for (int j = 0; j < len; ++j)
					table[p+j] = 17*(front%2) + 3*(front%3) + 19;
				wait[front] = i - front*5;
				len = ++front % 5 == 1 ? 5 : 2;
			}
			else
				break;
		}
		for (int j = 0; j < 17; ++j)
			--table[j];
	}

	int n;
	while (scanf("%d", &n) != EOF)
		printf("%d\n", wait[n]);

	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

#define int long long
#define ll long long

ll INF = (1LL << 60);

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


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

int main() {
  int k, N, C = 0;
  string S, S1, S2;
  cin >> S;

  N = S.length() / 2;

  for (int i = 0; i < N; i++) {
    S1 = S.substr(0, i);
    S2 = S.substr(i, i);
    if (S1 == S2){
      C = i;
    }
  }
  C = C * 2;
  cout << C << endl;
}

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

using namespace std;

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

  string O,E;
  cin >> O >> E;
  int n = O.size();
  int m = E.size();
  for(int i = 0; i < n; i++){
    cout << O[i];
    if(i != m) cout << E[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(){
  char colorsA[100000] = {};
  int resultA = 0;
  int i;
  char pre = '0';
  
  if(scanf("%s", colorsA) < 1){
    exit(1);
  }
  
  for(i = 0; colorsA[i] != '\0' ; i++){
      if(i > 0){
          if(colorsA[i] == pre) {
            if(colorsA[i] == '0') {
                colorsA[i] = '1';
            }else{
                colorsA[i] = '0';
            }
            resultA++;
        }
      }
      pre = colorsA[i];
  }
  

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


Measured memory_bytes: 256