akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register int i=(a);i<=(b);i++)
#define For(i,a,b) for (register int i=(a);i>=(b);i--)
#define mem(i,j) memset(i,j,sizeof(i))
#define GO(u) for (register int j=f[u];j!=-1;j=nxt[j])
using namespace std;
typedef long long ll;
const int N=100;
int n,a[N],cnt=0;
int read()
{
	int x=0,f=1;
	char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return f*x;
}
int main()
{
	n=read();
	FOR(i,1,n) a[i]=read();
	FOR(i,1,n) if (a[i]!=i) cnt++;
	if (cnt==2||cnt==0) printf("YES\n");
	else printf("NO\n");
	return 0;
}

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

using namespace std;
using ll = long long;
const int N = 30300;
int dp[N][1000][3];
int reach[1000];
string s;
int n;

int rec(int i, int num, int take) {
  if(!take) {
    reach[num] = 1;
    return 0;
  }
  if(i == n) {
    return 0;
  }
  if(dp[i][num][take] != -1) {
    return dp[i][num][take];
  }
  dp[i][num][take] = 0;
  rec(i + 1, num * 10 + (s[i] - '0'), take - 1);
  rec(i + 1, num, take);
  return 0;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  cin >> s;
  memset(dp, -1, sizeof dp);
  memset(reach, 0, sizeof reach);
  rec(0, 0, 3);
  int res = 0;
  for(int i = 0; i < 1000; ++i) {
    if(reach[i]) res++;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 357248
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S; cin >> S; 
	if(S.size() < 26){
		bool used[30] = {}; 
		for(int i = 0; i < S.size(); i++){
			used[S.at(i) - 'a'] = true; 
		}
		for(int i = 0; i < 26; i++){
			if(!used[i]){
				cout << S + (char) ('a' + i) << endl; 
				break; 
			}
		}
    }
	else if(S == "zyxwvutsrqponmlkjihgfedcba"){
		cout << -1 << endl; 
	}
	else{
		int index = 100; 
		for(int i = 25; i >= 1; i--){
			if(S.at(i) > S.at(i-1)){
				index = i; break; 
			}
		}
      	bool used[30] = {}; 
		for(int i = 0; i < index; i++){
			used[S.at(i) - 'a'] = true; 
		}
	    char unused; 
      	for(int i = S.at(index - 1) - 'a'; i <= 25; i++){
			if(!used[i]){
				unused = (char) ('a' + i); 
				break; 
			}
		}
		cout << S.substr(0, index - 1) << unused << endl; 
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <map>
#include <cmath>
#include <bitset>
#include <deque>
#include <queue>
#define INF (1LL<<31)
#define fst first
#define snd second
typedef long long ll;
typedef std::pair<int,int> ii;
using namespace std;

int main(){
  int x,y;
  cin>>x>>y;
  cout<<--x*--y<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,l,r,m;
pair <int,int> a[100005];
main(){
cin>>n>>m;
l=1;
r=n;
for(int k=1;k<=m;k++){
    cin>>a[k].first>>a[k].second;
}
sort(a+1,a+m+1);
for(int k=1;k<=m;k++){
    l=max(l,a[k].first);
    r=min(r,a[k].second);
}
if(r-l+1<=0){
    cout<<0;
}
else cout<<r-l+1;
return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; ++i) {
            arr[i] = sc.nextInt();
        }

        int[] org = Arrays.copyOf(arr, arr.length);

        Arrays.sort(arr);
        int mIdx = (arr.length - 1) / 2;

        for (int i = 0; i < org.length; ++i) {
            if (org[i] > arr[mIdx]) {
                System.out.println(arr[mIdx]);
            } else {
                System.out.println(arr[mIdx + 1]);
            }
        }
    }
}


Measured memory_bytes: 88672
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    string s;
    cin>>s;
    set<char> sc;
    rep(i,s.size()){
        sc.insert(s[i]);
    }
    if(sc.size()==3) cout<<"Yes"<<endl;
    else cout<<"No"<<endl; 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
string S;
typedef pair<int,int>P;
vector<P>v;
vector<P>w;
LL ans[100001];
int main(){
	cin>>S;
	int now=0;
	bool c=true;
	REP(i,S.size()){
		if(S[i]=='R'){
			if(c==true){
			}else{
				w.push_back(P(now,i-1));
				now=i;
				c=true;
			}
		}else{
			if(c==true){
				c=false;
				v.push_back(P(i-1,i));
			}else{			
			}
		}
	}
	w.push_back(P(now,S.size()-1));
	REP(i,S.size()){
		ans[i]=0;
	}
	REP(i,v.size()){
		int x=w[i].first;
		int y=w[i].second;
		//cout<<x<<" "<<y<<endl;
		for(int j=x;j<=y;j++){
			int z=v[i].first;
			if((j+z)%2==0){
				ans[z]++;
			}else{
				ans[z+1]++;
			}
		}
		
	}
	REP(i,S.size()){
		cout<<ans[i];
		if(i!=S.size()-1){
			cout<<" ";
		}else{
			cout<<endl;
		}
	}
}

Measured memory_bytes: 2420
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    string wb = ".#";
    vvint ans(40,vint(100));
    REP(i,20){
        REP(j,100){
            if(j%2==0&&i%2==0&&a>1){
                ans[i][j]=0;
                a--;
            }else{
                ans[i][j]=1;
            }
        }
    }
    REP(i,20){
        REP(j,100){
            if(j%2==0&&i%2==1&&b>1){
                ans[i+20][j]=1;
                b--;
            }else{
                ans[i+20][j]=0;
            }
        }
    }
    cout << 40 << " " << 100 << endl;
    REP(i,40){
        REP(j,100){
            cout << wb[ans[i][j]];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[1001][1001];




	
int main (){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	//input
	int n;
	cin >> n;
	vector<string> S(n);
	vector<string> T(n);
	for(int i=0;i<n;i++)cin >> S[i] >> T[i];


	//alorithm
	for(int i=0;i<n;i++){
		string s,t;
		s=S[i];
		t=T[i];
		memset(dp,0,sizeof(dp));
		for(int i=1;i<=s.size();i++){
			for(int j=1;j<=t.size();j++){
				if(s[i-1]==t[j-1]){dp[i][j]=dp[i-1][j-1]+1;continue;}
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
		cout << dp[s.size()][t.size()] << endl;
	}
}





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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for(int i = 0; i < n; i++) {
    a.at(i).second = i + 1;
    cin >> a.at(i).first;
  }
  sort(a.begin(), a.end());
  for(int i = 0; i < n; i++)
    cout << a.at(i).second << ' ';
  cout << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;

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



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

using namespace std;

int main(void)
{
    int n;
    int a,b;
    int count=0;
    bool flag=0;
    cin >> n;
    while(n--)
    {
        cin >> a >> b;
        if(!flag and a==b)
        {
            count++;
        }
        else if (!flag)
        {
            count=0;
        }
        if(count==3)
        {
            flag=1;
        }
    }

    if(flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0; 
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	REP(i, n){
		cin >> a[i];
	}
	ll ans = 0;
	REP(i, n){
		if(i % 2 == 0 && a[i] % 2 == 1){
			ans ++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#define INF 1e9
#define eps 1e-6
typedef long long ll;

int a, b, c, d;

int main(){

	scanf("%d%d%d", &a, &b, &c);
	d = a > b ? a : b;
	printf("%d\n", (c % d != 0) + c / d);

	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int []f = new int [n];
		
		
		for(int i = 0; i < n ; i++) {
			for(int j = 0 ; j < 10 ; j++) {
				int a = sc.nextInt();
				if(a == 1) {
				f[i] += (int)Math.pow(2, j);
				}
			}
		}
		
		
		int [][]s = new int [n][11];
		
		for(int i = 0; i < n ;i++) {
			for(int j = 0; j <= 10 ; j++) {
				s[i][j] = sc.nextInt();
			}
		}
		
		int p = (int)Math.pow(2, 10);
		int max = -1000000007;
		
		for(int i = 1; i < p ; i++) {
			int temp = 0 ;
			for(int j = 0; j < n ;j++) {
			  temp += s[j][Integer.bitCount(i&f[j])];
			}
			max = Math.max(max,temp);
	}
		System.out.println(max);
		
			}
		

	}



Measured memory_bytes: 26112
#include <bits/stdc++.h>
#define  pb push_back
#define nl "\n"
#define fastScan ios_base::sync_with_stdio(0); cin.tie(NULL);
#define int long long int
using namespace std;
int dp[123456];
int h[123456];
signed main()
{
	fastScan;
	int n;cin>>n;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	dp[1]=0;
	dp[2]=dp[1]+abs(h[1]-h[2]);
	for(int i=3;i<=n;i++)
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	cout<<dp[n]<<nl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
#define MAX_V 1000
struct edge{int to,cap,rev;};

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,G[to].size()});
  G[to].push_back((edge){from,0,G[from].size()-1});
}

int dfs(int v,int t,int f){
  if(v==t)return f;
  used[v]=true;
  for(int i=0;i<G[v].size();i++){
    edge &e=G[v][i];
    if(!used[e.to]&&e.cap>0){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
	e.cap-=d;
	G[e.to][e.rev].cap+=d;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow=0;
  for(;;){
    memset(used,0,sizeof(used));
    int f=dfs(s,t,INF);
    if(f==0)return flow;
    flow+=f;
  }
}

int main(){
  int V,E;
  cin>>V>>E;
  for(int i=0;i<E;i++){
    int u,v,c;
    cin>>u>>v>>c;
    add_edge(u,v,c);
  }
  cout<<max_flow(0,V-1)<<endl;
  return 0;
}



Measured memory_bytes: 3220
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());

            Queue<string> num = new Queue<string>();
            List<long> List = new List<long>();

            num.Enqueue("3");
            num.Enqueue("5");
            num.Enqueue("7");
            while (num.Count > 0)
            {
                string tmp = num.Dequeue();
                if (tmp.Contains("3"))
                    if (tmp.Contains("5"))
                        if (tmp.Contains("7"))
                            List.Add(long.Parse(tmp));
                if (tmp.Length < 11)
                {
                    num.Enqueue(tmp + "3");
                    num.Enqueue(tmp + "5");
                    num.Enqueue(tmp + "7");
                }
            }

            WriteLine(List.Count(x => x <= n && x >= 357));
        }
    }
}


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

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> x(N);
    for(int i = 0; i < N; i++){
        cin >> x[i];
    }
    
    long long ans = 1e9;
    for(int i = 0; i + K - 1 < N; i++){
        long long left = x[i], right = x[i + K - 1];
        ans = min(ans, min(abs(left), abs(right)) + right - left);
    }
    cout << ans << endl;


    return 0;
}

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

const int maxn=1000000;
int main()
{
    int n,w[maxn],ans,m,tmp;
    char rank[maxn];
    while(~scanf("%d",&n))
    {
        scanf("%s",rank+1);
        fill(w+1,w+n,0);
        for(int i=n;i>=1;i--)
        {
            w[i]=w[i+1];
            if(rank[i]=='W') w[i]++;
        }
        m=w[1];
        ans=maxn;
        for(int i=n;i>=1;i--)
        {
            tmp=((n-i)-w[i+1])+(m-w[i]);
            ans=min(ans,tmp);
        }
        printf("%d\n",ans);
    }
    return 0;
}


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

int main(){
	int N;
	cin>>N;
	vector<int>d;
	int tmp;
	for(int i=0;i<N;++i){
		cin>>tmp;
		d.push_back(tmp);
	}
	sort(d.begin(),d.end());
	int M = d[N/2];
	int m = d[N/2-1];
	cout<<M-m<<endl;
}


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

int main() {
  int n;
  int h[100010];
  cin >> n;
  rep(i,n) cin >> h[i];
  int dif[100010];
  rep(i,n - 1) dif[i] = h[i] - h[i + 1];
  int ans = 0;
  int cnt = 0;
  rep(i,n - 1) {
    if (dif[i] >= 0) cnt++;
    else {
      ans = max(ans, cnt);
      cnt = 0;
      continue;
    }
  }
  ans = max(ans, cnt);
  cout << ans << endl;
}

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

#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define FORN(i, m, n) for(int (i) = (m); (i) <= (n); (i)++)
#define FORR(i, m, n) for(int (i) = (m); (i) >= (n); (i)--)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> Vec;

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll r, g, b, n;
	cin >> r >> g >> b >> n;

	ll ans = 0;
	rep(i, n/r+1){
		rep(j, n/g+1){
			if(i*r+j*g > n) break;
			if((n-i*r-j*g)%b == 0) ans++;
		}
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N;
    string s;
    cin >> N >> s;
    int R = 0, B = 0;
    rep(i, N) s[i] == 'R' ? R += 1 : B += 1;
    cout << (R > B ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3608
#include"bits/stdc++.h"
using namespace std;
typedef long long               ll ;
typedef long double             ld ;
typedef unsigned long long      ull ;
typedef pair<int,int>           pii ;
typedef vector<int>             vi ;
typedef vector<vector<int>>     vvi ;
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mem(a) memset(a,0,sizeof(a))
#define mod  1000000007LL
#define     ff          first
#define     ss          second
#define print(p) for(auto x:p){cout<<x<<" ";}


#define bug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}








ll a[100005],b[100005],n,cnt;

int main(){
    fast()
    cin>>n;
    for(ll i=0;i<=n;i++){
        cin>>b[i];//mons
    }
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }

    for(ll i=0;i<=n;i++){
            int   p=b[i+1]+b[i];
            if(a[i]>=p||a[i]>=b[i]){
                    if(a[i]>=p){

                        cnt+=p;
                        b[i+1]=0;
                    }
                    else{
                       
                         if(a[i]>=b[i]){
                            cnt+=b[i];
                            if(b[i+1]>=a[i]-b[i])cnt+=a[i]-b[i];
                            b[i+1]-=a[i]-b[i];

                        }
                    }

            }
            else if(p>=a[i]||b[i]>=a[i]){
                if(b[i]>=a[i]){
                    cnt+=a[i];
                }
                else{
                    cnt+=a[i];
                    b[i+1]=(b[i]-a[i]);
                }
            }

    }
    cout<<cnt<<endl;


     return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  //input
  int n;cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  for(int i = 0; i < n;i++){
      cin >> x[i] >> y[i];
  }
  
  //compute
  vector<int> d(n);
  for(int i = 0; i < n;i++){
      d[i] = x[i] - y[i];
  }

  for(int i = 0; i < n - 2;i++){
        if(d[i] == 0 &&  d[i + 1] == 0 && d[i + 2] == 0 ){
           cout << "Yes" << endl;
           return 0;
         }
  }

  //output
  cout << "No" << endl;
}

Measured memory_bytes: 3632
#![allow(unused_imports)]
#![allow(non_snake_case)]

use procon::*;
use std::cmp::{max, min};
use std::collections::*;
use std::ops::*;
use std::*;

pub fn main() {
    let S = read_line();

    let mut prev = None;
    let mut k = 0;
    for c in S.chars() {
        match prev {
            Some(p) if p != c => {
                k += 1;
            }
            _ => {}
        }
        prev = Some(c);
    }
    println!("{}", k);
    return;
}

pub mod procon {
    use std;
    use std::collections::*;
    use std::io;
    use std::mem;
    use std::str::FromStr;

    pub fn read_line() -> String {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.trim_right().to_owned()
    }

    pub fn read_words<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.split_whitespace()
            .map(|word| T::from_str(word).unwrap())
            .collect()
    }

    pub fn read_vec(len: usize) -> Vec<String> {
        let mut vec = Vec::new();
        while vec.len() < len {
            let line = read_line();
            for word in line.split_whitespace() {
                vec.push(word.to_owned());
            }
        }
        assert!(vec.len() == len);
        vec
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int a,d,n;
  int b[1000000]={};
  int c[1000000]={};
  c[2]=1;
  for(int i=3;i<1000000;i+=2){
    int y=0;
    for(int j=3;j<=sqrt(i);j+=2)
      if(i%j==0){y=1;break;}
    if(y==0)c[i]=1;
  }

  while(1){
    cin>>a>>d>>n;
    if(a==0 && d==0 && n==0)break;
    int i=0,cnt=0;
    while(1){
      i++;
      if(i==1)
	b[1]=a;
      else
	b[i]=b[i-1]+d;
    
      if(c[b[i]]==1)cnt++;

      if(cnt==n){cout<<b[i]<<endl;break;}
    }
  }
  
  return 0;
}

Measured memory_bytes: 10876
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

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

int s[100010];
int x[26];

int main(){
    string ss;  cin >> ss;
    for(int i = 0; i < ss.length(); i++) {
        s[i] = ss[i] - 'a';
    }

    for(int i = 0; i < 26; i++){
        x[i] = -30;
    }

    for(int i = 0; i < ss.length(); i++){
        if (i - x[s[i]] <= 2) {
            cout << x[s[i]]+1 << " " << i+1 << endl;
            return 0;
        }
        else{
            x[s[i]] = i;
        }
    }

    cout << -1 << " " << -1 << endl;

    return 0;

}

Measured memory_bytes: 896
/* Author rumoisen */
/* created 2018/10/13 */

#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include<iostream>
#include <algorithm>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;

int main()
{
    int n,l[210];
    cin>>n;
    for(int i=0;i<2*n;i++) cin>>l[i];
    sort(l,l+2*n);
    int sum=0;
    for(int i=0;i<2*n;i+=2){
        sum+=l[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main(){
    int n;
    int h;
    cin >> n;
    string ans = "Yes";
    string s;
    rep(i,n){
        cin >> s[i];
    }
    if(n%2 == 1){ ans = "No";
    }
    else{
        h = n/2;
        rep(i,n/2){
            if(s[i] != s[i+h]){
                ans = "No";
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
const int MAX = 22;
const int MOD = 1e9 + 7;

int mat[MAX][MAX], dp[1 << (MAX - 1)];

void add_self(int &a, int b)
{
    a += b;

    if(a >= MOD)
        a %= MOD;
}

int nrBits(int x)
{
    int cnt = 0;

    for(int i = 1; i <= x; i <<= 1)
        if(x & i)
            cnt++;

    return cnt;
}

int main()
{
    int n;

    cin >> n;

    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> mat[i][j];

    dp[0] = 1;
    for(int mask = 0; mask < (1 << n); mask++)
    {
        int a = nrBits(mask);

        for(int b = 0; b < n; b++)
            if(mat[a][b] && !(mask & (1 << b)))
            {
                int mask2 = mask ^ (1 << b);

                add_self(dp[mask2], dp[mask]);
            }
    }

    cout << dp[(1 << n) - 1];

    return 0;
}


Measured memory_bytes: 11804
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
 
int popcount(ll X) {
    int res = 0;
    for (int i = 0; i <= 40; i++) {
        if (X >> i & 1) res++;
    }
    return res;
}
 
ll f(ll x) {
    if (x == 0) return 0;
    int cnt = popcount(x);
    return 1 + f(x % cnt);
}
 
int main()
{
    /*
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    */
    ll n; cin >> n;
    string s; cin >> s;
    ll cnt = 0; for (int i = 0; i < s.size(); i++) if (s[i] == '1') cnt++;
    ll f1 = 0;
    ll f2 = 0;
    vector<ll> t1(n + 1, 1), t2(n + 1, 1);
    for (int i = 1; i <= n; i++) {
        t1[i] = t1[i - 1] * 2 % (cnt + 1);
        if (cnt > 1) t2[i] = t2[i - 1] * 2 % (cnt - 1);
    }
    for (int i = 0; i < s.size(); i++) {
        f1 = f1 * 2 + (s[i] == '1');
        if(cnt > 1) f2 = f2 * 2 + (s[i] == '1');
        f1 %= (cnt + 1);
        if(cnt > 1) f2 %= (cnt - 1);
    }
    for (int i = 0; i < n; i++) {
        if (s[i] == '1') {
            if (cnt == 1) puts("0");
            else {
                ll tmp = f2 - t2[n - 1 - i];
                tmp %= (cnt - 1);
                if (tmp < 0) tmp += cnt - 1;
                printf("%lld\n", f(tmp) + 1);
            }
        }
        else {
            ll tmp = f1 + t1[n - 1 - i];
            tmp %= (cnt + 1);
            printf("%lld\n", f(tmp) + 1);
        }
    }
    return 0;
}

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

int main ()
{
	char c;
	cin >> c;
	if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
	{
		cout << "vowel" << endl;
	}
	else
	{
		cout << "consonant" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int g[114][114];


int main(int argc, char const *argv[]) {
    int n,m;
    cin >> n >> m;
    vector<int> A,B;
    REP(i,114) REP(j,114) g[i][j] = INF;
    REP(i,114) g[i][i] = 0;
    
    REP(i,m) {
        int a,b,c;
        cin >> a >> b >> c;
        --a,--b;
        A.push_back(a); B.push_back(b);
        g[a][b] = g[b][a] = c;
    }
    int t[114][114] = {};
    REP(i,114) REP(j,114) t[i][j] = g[i][j];

    REP(k,114) REP(i,114) REP(j,114) g[i][j] = min(g[i][j], g[i][k]+g[k][j]);
    
    ll cnt = 0;
    REP(i,m) {
        // i = 経由する辺
        int edge = t[A[i]][B[i]];
        bool used = false;
        REP(j,n) {
            // j = スタートする頂点
            REP(k,n) {
                // k = ゴールする頂点
                if (j == k) continue;
                int dist = g[j][A[i]]+edge+g[B[i]][k];
                if (dist == g[j][k]) used = true;
                // printf("i = %d, j = %d, k = %d, edge = %d, dist = %d, g[j][k] = %d, used = %d\n",i,j,k,edge,dist,g[j][k],(int)used);
            }
        }
        if (!used) cnt++;
    }

    cout << cnt << endl;
    return 0;
}

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

int main(void) {
	int num = 0;
		while (scanf("%d",&num) != EOF){
		int i = 0,j = 0,k = 0,l = 0,cnt=0;
		for(i = 0;i < 10;i++){
			for(j = 0;j < 10;j++){
				for(k = 0;k < 10;k++){
					for(l = 0;l < 10;l++){
						if((i + j + k + l) == num){
							cnt = cnt + 1;
						}
					}
				}
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 592
MAXN = 30
dp = [0] * (MAXN+1)
dp[1] = 1
dp[2] = 2
dp[3] = 4
for i in range(4,MAXN+1):
    dp[i] = dp[i-1] + dp[i-2] + dp[i-3]

while True:
    N = int(input())
    if N == 0: break
    print((dp[N]-1) // 3650 + 1)



Measured memory_bytes: 5596
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N = inputInt()
	H = inputList()

	ans = 0
	tmp = 0
	for i, val in enumerate(H):
		if i == 0:
			continue
		if val <= H[i-1]:
			tmp += 1
		else:
			if ans < tmp:
				ans = tmp
			tmp = 0

	if ans < tmp:
		ans = tmp

	print(ans)


if __name__ == "__main__":
	main()


Measured memory_bytes: 60252
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

struct info {
    int x,y,h;
    info(int x,int y,int h):x(x),y(y),h(h) {}
    int top(int tx,int ty) {
        return h+abs(tx-x)+abs(ty-y);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<info> v;
    rep(i,n) {
        int x,y,h;
        cin >> x >> y >> h;
        v.emplace_back(x,y,h);
    }
   rep(i,101) rep(j,101) {
        int h = v[0].top(i,j);
        bool cert = v[0].h != 0;
        bool ok = true;
        rep2(k,1,n) {
            int nh = v[k].top(i,j);
            if(v[k].h == 0) {
                if(cert) {
                    if(h > nh) {
                        ok = false;
//                        cout << k << endl;
                        break;
                    }
                } else {
                    chmin(h,nh);
                }
            } else {
                if(cert) {
                    if(h != nh) {
                        ok = false;
//                        cout << k << endl;
                        break;
                    }
                } else {
                    if(nh > h) {
                        ok = false;
//                        cout << k << endl;
                        break;
                    } else {
                        cert = true;
                        h = nh;
                    }
                }
            }
        }
        if(ok && h > 0) {
            cout << i << " " << j << " " << h << endl;
            return 0;
        }
    }
}


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

int main() {
	ll a,b,k;
    cin>>a>>b>>k;
    ll t=0;
    
    for(ll i=1;i<=min(a,b);i++)
      {      
          if(a%i==0&&b%i==0)
            t++;       
       }  
       ll r[t];
       for(ll i=1;i<=min(a,b);i++)
      {      
          if(a%i==0&&b%i==0)
            r[t--]=i;       
       }  
       
      cout<<r[k];
      cout<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int n,a;
    cin >> n;
    for(int i=1;i<=50000;i++){
        int a = i*1.08;
        if(a == n){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define INF 1000000000
#define NV 100000
using namespace std;
class edge
{
  public:
  int t;
  int d;
  edge *nextedge;
  edge(int,int);
};

edge::edge(int tt,int dd)
{
  t=tt;
  d=dd;
  nextedge=NULL;
}

class vertice
{
  public:
  int n;
  edge *firstedge;
  vertice();
};
vertice vertices[NV];
vertice::vertice()
{
}


void create_edge(int s, int t,int d)
{
  edge *newedge=new edge(t,d);
  if(vertices[s].firstedge==NULL)
    vertices[s].firstedge=newedge;
  else
  {
    edge *tmp=vertices[s].firstedge;
    while(tmp->nextedge!=NULL)
    {
      tmp=tmp->nextedge;
    }
    tmp->nextedge=newedge;
  }
}

class source
{
  public:
  int n;
  int dis;
  friend bool operator<(source,source);
};

bool operator<(source a, source b)
{
  return a.dis>b.dis;
}

int main()
{
  int v,e,r;
  cin>>v>>e>>r;
  vector<source> weight(v);
  for(int i=0;i<v;i++)
  {
    vertices[i].n=i;
    vertices[i].firstedge=NULL;
    weight[i].n=i;
    weight[i].dis=INF;
  }
  for(int i=0;i<e;i++)
  {
    int s,t,d;
    cin>>s>>t>>d;
    create_edge(s,t,d);
  }
/*
  for(int i=0;i<v;i++)
  {
    edge *p=vertices[i].firstedge;
    while(p!=NULL)
    {
      cout<<i<<' '<<p->t<<' '<<p->d<<endl;
      p=p->nextedge;
    }
  }
*/
  weight[r].dis=0;
  int current_vertex=r;
  priority_queue<source> queue;
  queue.push(weight[r]);
  while(queue.size()!=0)
  {
    source del=queue.top();
    queue.pop();
    current_vertex=del.n;
//    cout<<current_vertex<<endl;
    edge *p=vertices[current_vertex].firstedge;
    while(p!=NULL)
    {
      int vn=p->t;
      if(weight[vn].dis>weight[current_vertex].dis+p->d)
      {
        weight[vn].dis=weight[current_vertex].dis+p->d;
        queue.push(weight[vn]);
      }
//      cout<<vn<<' '<<weight[vn].dis<<' '<<weight[current_vertex].dis<<' '<<p->d<<endl;
      p=p->nextedge;
    }
  }
  for(int i=0;i<v;i++)
    if(weight[i].dis>=INF)
      cout<<"INF"<<endl;
    else
      cout<<weight[i].dis<<endl;
}

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

int main() {
    int N,x1,y1,t1,x0=0,y0=0,t0=0,flag = 0,mind=0,rem=0;
    cin >> N;

    for (int i = 0; i < N; ++i){
        cin >> t1 >> x1 >> y1;
        mind = x1+y1-x0-y0;
        // impossible ( too far)
        if (mind > t1-t0){
            flag = 1;
            //cout << "NO" << endl;
            //break;
        }
        // まず最短で行かせて、そこから時間が潰せるか
        else
        {
            rem = t1-t0-mind;
            if (rem%2 ==1 ){
                flag = 1;
                //cout << "NO" << endl;
               // break;
            }
        }
        x0 = x1;
        y0 = y1;
        t0 = t1;
        
    }

    if (flag == 0){
            cout << "Yes" << endl;
    }
    else{
            cout << "No" << endl;
    }
        
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int64_t INF = 1LL << 60;

int main() {
 int A,B;
 cin>>A>>B;
 if(A<=9&&A>=1&&B<=9&&B>=1){cout<<A*B<<endl;}
 else{cout<<-1<<endl;}
 
 return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b&&b==c)
    printf("1");
    else if(a==b||a==c||b==c)
    printf("2");
    else
    printf("3");
    return 0;
}

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

int n;
int s[105], ct[105];

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

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        ct[s[i]]++;
    }

    sort(s, s+n);
    if (s[n-1] != s[n-2]) {
        cout << "Impossible\n";
        return 0;
    }

    int mini = 200;

    for (int i = 0; i <= s[n-1]; ++i) {
        int m = max(i, s[n-1]-i);
        mini = min(mini, m+1);
        if (ct[m] == 0) {
            cout << "Impossible\n";
            return 0;
        }
        ct[m]--;
    }

    for (int i = 0; i < mini; ++i)
        if (ct[i] > 0) {
            cout << "Impossible\n";
            return 0;
        }
    cout << "Possible\n";
}

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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

ll n,c,d,x;

bool poss() {
    auto base = -(n-1)*d;
    if (x > -base) return false;
    auto dist = x-base;
    auto jumps = dist/(c+d);

    auto l = base + jumps*(c+d);
    auto r = l + (d-c)*(n-1);

    return l <= x && x <= r;
}

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

    ll a,b;
    cin >> n >> a >> b >> c >> d;
    x = abs(b-a);
    cout << (poss() ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
/*...................bismillahir rahmanir rahim.....................*/
/*
  author :
    Muhammad Najmul hasan Nayeem
    Sust Math 17
*/
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/trie_policy.hpp>
// using namespace __gnu_pbds;
 
using namespace std;

#define m_p make_pair
#define PB push_back
#define eb emplace_back
#define FF first
#define SS second
#define MX5 100005
#define MX6 1000006
#define MOD 1000000007
#define in()({int a;scanf("%d",&a);a;})
#define SI(a) scanf("%d",&a)
#define SII(a,b) scanf("%d%d",&a,&b)
#define SIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SC()({char a;scanf("%c",&a);a;})
#define SL()({long long a;scanf("%lld",&a);a;})
#define SD()({double a;scanf("%f",&a);a;})
#define nl '\n'
#define For(_,n) for(int i=_;i<=n;i++)
#define once "once upon a time\n"
#define FI freopen("input.txt","r+",stdin);
#define FO freopen("output.txt","w+",stdout);
 
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<string,string> PSS;
// typedef tree<PII,null_type,less<PII>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
    return out << "(" << a.FF << ", " << a.SS << ")";
}
 
template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
    out << "[";
    for(int i=0;i<v.size();i++) {
        if(i) out << ", ";
        out << v[i];
    }
    return out << "]";
}
 
#define chk(a) cout<<(#a)<<" = "<<a<<endl;
#define chka(a,_) cout<<(#a)<<"["<<_<<"] = "<<a[_]<<"\n";

// int Set(int n,int pos){ return n | (1<<pos); }
// int Reset(int n,int pos){ return n=n & ~(1<<pos); }
// bool Check(int n,int pos){ return (bool)(n & (1<<pos)); }
 
/*............start.............*/
void solve()
{
    string s;
    cin>>s;
    if(s.back()=='s') s+="es";
    else s+="s";
    cout<<s<<nl;
}
int main()
{
    // clock_t time_start=clock();
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int q=1;
    // cin>>q;
    // SI(q);
    for(int kase=1;kase<=q;kase++)
    {
        // cout<<"Case "<<kase<<": ";
        // printf("Case %d: ",kase );
        solve();
    }
    // clock_t time_end=clock();
    // cerr<<float((time_end-time_start)/CLOCKS_PER_SEC);
    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define NMAX 100005

using namespace std;

int i, ok1, ok2;

int main(){
    ios_base::sync_with_stdio(false);
    string sir;
    cin >> sir;
    for(i=0; i<sir.size(); ++i){
        if(sir[i] == 'C')
            ok1 = 1;
        if(sir[i] == 'F' && ok1 == 1){
            ok2 = 1;
            break;
            }
        }
    if(ok2 == 1)
        cout << "Yes\n";
        else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n;
int main(void){
 cin >> n;
 int ans = 100;
 for(ll i=1;i*i<=n;i++){
  if (n%i==0) ans = min(ans, (int)(to_string(max(i, n/i)).size()));
 }
 cout << ans << endl;
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int main(void){
    string s,t;
    cin >> s >> t;

    int dp[3001][3001];
    for(int i=0; i<=s.size(); i++) dp[0][i] = 0;
    for(int i=0; i<=t.size(); i++) dp[i][0] = 0;


    for(int i=1; i<=s.size(); i++){
        for(int j=1; j<=t.size(); j++){
            if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    int i = s.size();
    int j = t.size();
    string ans = "";
    if(dp[i][j] == 0) string ans = " ";
    while(i>0 && j>0){
        if(dp[i-1][j] == dp[i][j]){
            i--;
        }
        else if(dp[i][j-1] == dp[i][j]){
            j--;
        }
        else{
            ans = s[i-1] + ans;
            i--;
            j--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35456
N,Q=map(int,input().split())
S=input()
lr = [list(map(int,input().split())) for _ in range(Q)]

indices=[0]*(N+1)
for i in range(1,N+1):
  if S[i-1:i+1]=='AC':
    indices[i] += indices[i-1] + 1
  else:
    indices[i] += indices[i-1]

for i in range(Q):
  l,r=lr[i]
  print(indices[r-1]-indices[l-1])

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

int main()
{
    int n,x;
    int ans;
    int a=0,b=0,c=0;
    while(1){
        cin>>n>>x;if(n==0&&x==0)break;
        ans=0;
        for(a=1;a<=n;a++){
        for(b=a+1;b<=n;b++){
        for(c=b+1;c<=n;c++){
            if(a+b+c==x)ans++;
        }}}
        cout<<ans<<endl;
    }  
    return 0;
}




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

using namespace std;

const int max_n = 100111, inf = 1000111222;

int n, q, a[max_n], b[max_n], c[max_n], used[max_n], id[max_n], comps;
vector<int> g[max_n];
long long m;

void wa() {
    puts("No");
    exit(0);
}

void dfs(int v, int p) {
    id[v] = comps;
    used[v] = 1;
    for (int to : g[v]) {
        if (to == p) {
            continue;
        }
        if (used[to] == 0) {
            dfs(to, v);
        } else if (used[to] == 1) {
            //wa();
        }
    }
    used[v] = 2;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> m >> q;
    long long e = 0;
    bool has_1 = false;
    for (int i = 0; i < q; ++i) {
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
        if (c[i] == 0) {
            g[a[i]].push_back(b[i]);
            g[b[i]].push_back(a[i]);
            ++e;
        } else {
            has_1 = true;
        }
    }
    for (int i = 0; i < n; ++i) {
        if (!used[i]) {
            ++comps;
            dfs(i, -1);
        }
    }
    long long add = (1LL * comps * (comps - 1)) / 2;
    if (has_1 && comps <= 2) {
        //cout << "#" << endl;
        wa();
    }
    e = n - comps;
    e += add;
    if (e < m) {
        wa();
    }
    for (int i = 0; i < q; ++i) {
        if (c[i] == 1 && id[a[i]] == id[b[i]]) {
            wa();
        }
    }
    if (has_1 && m == n - 1) {
        wa();
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll,ll> pll;


string s, a;
int main()
{
        cin >> s;
        a = "AKIHABARA\n";
        ll ptr = 0;
        ll i = 0;
        while(i < 9){
                if(ptr < s.length() && s[ptr] == a[i]) {
                        i++; ptr++;
                }else {
                        if(a[i] == 'A') {
                                i++;
                        }else {
                                cout << "NO\n"; return 0;
                        }
                }
        }
        if(ptr == s.length()) cout << "YES\n";
        else cout << "NO\n";
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

void go()
{
    int n;
    cin>>n;
    vector<int> xpy,xmy;
    for(int i=0;i<n;i++)
    {
        int p,q;
        cin>>p>>q;
        xpy.push_back(p+q);
        xmy.push_back(p-q);
    }
    int xpym=*min_element(xpy.begin(),xpy.end());
    int xpyM=*max_element(xpy.begin(),xpy.end());
    int xmym=*min_element(xmy.begin(),xmy.end());
    int xmyM=*max_element(xmy.begin(),xmy.end());
    int ans=max(xpyM-xpym,xmyM-xmym);
    cout<<ans;
}
int main()
{
    FIO;
//    int t;
//    cin>>t;
//    while(t--)
        go();
    return 0;
}

/*
        x1 y1
        x2 y2
        x3 y3
*/


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

int main(void)
{
    int A, B;
    cin >> A >> B;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
using namespace std;


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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

	int N, S;
	cin >> N >> S;

	vector<ll> R(N), W(N);

	for(int i = 0; i < N; i++){
		cin >> W[i] >> R[i];
	}

	vector<vector<ll>> DP(2, vector<ll>(S + 1,0));

	for(int i = 0; i < N; i++){
		
		for(int j = 0; j <= S; j++){
			if(W[i] + j <= S){
				DP[1][W[i] + j] = max(DP[1][W[i] + j], DP[0][j] + R[i]);
			}
		}

		DP[0] = DP[1];
		
	}

	ll ans = 0;

	for(int i = 0; i <= S; i++) ans = max(ans, DP[1][i]);

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


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

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

  long ans = (a%2==0 || b%2==0 || c%2==0) ? 0:min({a*b,b*c,c*a});
  cout<<ans<<endl;

  return 0;


}



Measured memory_bytes: 256