akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll k, seq[32] = { 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 };
ll camma = 0;

int main() {
	cin >> k;
	cout << seq[k - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int n , k ;
bool bad[30] ;

inline bool ok (int x) {
	while (x) {
		int dig = x % 10 ;
		if (bad[dig]) return 0 ;
		x /= 10 ;
	}
	return 1 ;
}

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

	cin >> n ;

	cin >> k ;
	while (k --) { int x ; cin >> x ; bad[x] = 1 ; }

	n -- ;
	while (++ n) {
		if (ok(n)) return cout << n << '\n' , 0 ; 
	}

	assert(0) ;
}


Measured memory_bytes: 256
//you**can**do**anything 
#include <bits/stdc++.h> 
#define ll long long
#define read(i) scanf("%lli" , &i)
const ll maxn=1e6; 
using namespace std;
 
int fac(ll n)
{
	if(n==1) return 1;
	
	return fac(n-1) * n; 
}
 
int main()
{


ll t;
cin>>t ;
ll ac=0 ,tlm =0 ,wa=0 ,re =0;
while(t--)
{
	string s;
	cin>>s;
	if(s=="AC") ac++;
	else if(s=="TLE") tlm++ ;
	else if(s=="WA") wa++;
	else if(s=="RE") re++;
}

cout<<"AC x "<<ac<<"\n"<<"WA x "<<wa<<"\n"<<"TLE x "<<tlm<<"\n"<<"RE x "<<re;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

static const int N = 100;

int main()
{
    int M[N][N];

    int num, vertexId, numOfEdge, targetVertex;

    scanf("%d", &num);

    for (int i = 0; i < num; i++) {
        for (int j = 0; j < num; j++) {
            M[i][j] = 0;
        }
    }

    for (int i = 0; i < num; i++) {
        scanf("%d %d", &vertexId, &numOfEdge);
        vertexId--; //change to idx
        for (int j = 0; j < numOfEdge; j++) {
            scanf("%d", &targetVertex);
            targetVertex--;
            M[vertexId][targetVertex] = 1;
        }
    }

    for (int i = 0; i < num; i++) {
        for (int j =0; j < num; j++) {
            if (j) cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }

    return 0;
}



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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

signed main() {
  uint64_t a,b,c;
  cin >> a >> b >> c;
  
  if(a<b && b<c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>

int main(){
  char c1[3],c2[3];
  scanf("%s", c1);
  scanf("%s", c2);
  
  if(c1[0]==c2[2] && c1[1]==c2[1] && c1[2]==c2[0]) printf("YES");
else printf("NO");
  return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<bool> vb;
#define setp ios_base::sync_with_stdio(0); cin.tie(0);
#define usaco(a,b) ofstream cout(a); ifstream cin(b);
#define FOR(i, a, b) for (int i=a; i<(b); i++) 
#define F0R(i, a) for (int i=0; i<(a); i++) 
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--) 
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define sz(x) (int)(x).size() 
#define mp make_pair 
#define pb push_back 
#define fs first 
#define sc second 
#define lb lower_bound 
#define ub upper_bound 
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
const ll MOD = 1000000007;
const ll INF = 1e18;
const int MAX = 1e6;


int main() {
	string s; cin>>s;
	int cnt=0,m=0;
	F0R(i,s.size()){
		if(s[i]=='R')cnt++;
		else cnt=0;
		m = max(m,cnt);
	}
	cout<<m<<endl;
 	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N, L; cin >> N >> L;
    vector<string> s(N);
    for(int i=0; i<N; i++) cin >> s[i];

    sort(s.begin(), s.end());
    string ans = "";
    for(int i=0; i<N; i++) ans += s[i];
    cout << ans << endl;
}

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  for(int i=1;i<=2000;i++){
    if((8*i)/100 ==a && i/10==b){
      cout<<i;
      return 0;
    }
  }
  cout<<-1;
  return 0;
  
  
  
}

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

int main()
{
    int x, n, tmp;
    cin >> x >> n;
    vector<int> v(101, 0);

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

    pair<int, int> res(102, -1);
    for(int i = 0; i <= 101; ++i)
    {
        if(v[i] == 0)
        {
            res = min(res, pair<int, int>(abs(x - i), i));
        }
    }

    cout << res.second << "\n";
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long double
vector<long double>v(3005);
int n;
int head;
long double dp[3002][3000];
const int mod=1e9+7;
long double call(int i,int j){
long double &ret=dp[i][j];
if(i>=n && j<head) return 0;

if(ret!=-1) return ret;
//cout<<"HERER"<<endl;
if(i==n && j>=head) return ret=1;
ret=0.00000000000;

ret+=(call(i+1,j+1)*v[i])*1.00000000000;
ret+=(call(i+1,j)*(1-v[i]))*1.00000000000;

return ret;
}
int main(){

cin>>n;
for(int i=0; i<=3000; i++)for(int j=0; j<=3000; j++)dp[i][j]=-1;
for(int i=0; i<n ;i++)
    cin>>v[i];//for(int i=1; i<=43;i ++)cout<<dp[i][i]<<endl;
head= n-(n/2);
long double ans=call(0,0 );
cout<<setprecision(10)<<ans<<endl;


}


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

int  main()
{
	string s; cin >> s;
	deque<char> d;
	string t;
	rep(i, s.size())
	{
		if (s[i] == '0')
			t += '0';
		else if (s[i] == '1')
			t += '1';
		else if (s[i] == 'B' && !t.empty())
			t.pop_back();
	}
	cout << t << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, g, b;
  cin >> N >> A >> g >>b;
  if  (A + N > g + b) {
    cout << "Left" << endl;
  }else 
  if ( A + N < g + b ){
    cout << "Right" << endl;
  }else if(A + N == g + b ){
   cout << "Balanced"<< endl;
  }
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

class Node {
public:
    Node(LL v = unitValue) : value(v) {

    }

    Node operator + (const Node& monoid) const {
        return Node(this->getValue() + monoid.getValue());
    }

    static Node unit() {
        return Node(unitValue);
    }

    void setValue(LL l) {
        this->value = l;
    }

    LL getValue() const {
        return this->value;
    }

private:
    LL value;
    static const LL unitValue = 0;
};

template <class T>
class SegmentTree {
public:
    SegmentTree(int size) {
        init(size);
    }

    void init(int size) {
        vec.clear();
        k = 1;
        while(k < size) {
            k *= 2;
        }
        for(int i = 0; i < 2*k; i++) {
            vec.push_back(T::unit());
        }
    }

    void update(int i, T x) { //iをxに変更する
        i += k-1;
        vec[i] = x;
        while(i > 0) {
            i = (i-1)/2;
            vec[i] = vec[i*2+1] + vec[i*2+2];
        }
    }

    T find(int l, int r) {
        return _find(l, r, 0, 0, k);
    }

private:
    vector<T> vec;
    int k;

    T _find(int l, int r, int k, int x, int y) {
        if (r <= x || y <= l) { //重なってない場合
            return T::unit();
        } else if (l <= x && y <= r) { //完全にかぶってる場合
            return vec[k];
        } else { //中途半端にかぶってる場合
            int mid = (x+y)/2;
            T lNode = _find(l, r, 2*k+1, x, mid);
            T rNode = _find(l, r, 2*k+2, mid, y);
            return lNode + rNode;
        }
    }
};

struct Query {
  int l, r;
  int index;
  bool operator < (const Query& q) const {
    return r < q.r;
  }
  void input(int index) {
    this->index = index;
    cin >> l >> r;
  }
};

const int MAX_N = 500005;

int N, Q;
int C[MAX_N];
Query queries[MAX_N];
SegmentTree<Node> st(MAX_N);
int lastAppeared[MAX_N];
int ans[MAX_N];

signed main()
{
  cin >> N >> Q;
  FOR(n,1,N+1) {
    cin >> C[n];
  }
  REP(q,Q) {
    queries[q].input(q);
  }

  sort(queries, queries+Q);
  int r = 1;
  REP(q,Q) {
    const Query& query = queries[q];
    while(r <= query.r) {
      st.update(lastAppeared[C[r]], 0);
      st.update(r, 1);
      lastAppeared[C[r]] = r;
      r++;
    }
    ans[query.index] = st.find(query.l, query.r+1).getValue();
  }

  REP(q,Q) {
    cout << ans[q] << endl;
  }

  return 0;
}


Measured memory_bytes: 35564
#include<iostream>
using namespace std;
int main(){
  int a[3],i,b=0,j;
  for(i=0;i<3;i++){
    cin>>a[i];
  }
  for(i=0;i<2;i++){
    for(j=i+1;j<3;j++){
      if(a[i]!=a[j]){
        b++;
      }
    }
  }
  if(b==0)
    b=1;
  
  cout<<b;
  
  return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=2e5+5;
vector<int> g[N];
int c[N],tin[N],tout[N],sz[N],timer=0;
void dfs1(int v,int p=0){
    tin[v]=timer++;
    sz[v]=1;
    for(int to:g[v]){
        if(to^p){
            dfs1(to,v);
            sz[v]+=sz[to];
        }
    }
    tout[v]=timer++;
}
int anc(int x,int y){
    return tin[x]<=tin[y]&&tout[y]<=tout[x];
}
vector<int> q[N];
int bad[N];
void dfs2(int v,int p=0){
    for(int to:g[v]){
        if(to^p){
            dfs2(to,v);
        }
    }
    int x=c[v];
    reverse(g[v].begin(), g[v].end());
    for(int to:g[v]){
        if(to==p)continue;
        int z=sz[to];
        while(!q[x].empty()&&anc(to,q[x].back())){
            z-=sz[q[x].back()];
            q[x].pop_back();
        }
        bad[x]+=z*(z+1);
    }
    reverse(g[v].begin(), g[v].end());
    q[x].pb(v);
}
int32_t main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)cin>>c[i];
    forn(i,n-1){
        int x,y;
        cin>>x>>y;
        g[x].pb(y);
        g[y].pb(x);
    }
    dfs1(1);
    dfs2(1);
    int al=n*(n+1);
    for(int i=1;i<=n;++i){
        int z=n;
        for(int j:q[i])z-=sz[j];
        bad[i]+=z*(z+1);
        cout<<(al-bad[i])/2<<'\n';
    }
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	int F[50];
	F[0] = F[1] = 1;
	for (int i = 2; i <= n; i++) 
		F[i] = F[i - 1] + F[i - 2];
	cout << F[n] << endl;
}



Measured memory_bytes: 3116
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
import copy
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)


n = int(input())
A = list(map(int, input().split()))
count = 0
for i in range(n):
    if i%2 == 0 and A[i]%2 == 1:
        count += 1

print(count)



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

int main() {
  int a,b;
  cin>>a>>b;
  if(a%3==0||b%3==0||(a+b)%3==0){
    cout<<"Possible"<<endl;
  }else{
    cout<<"Impossible"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))
"""
20 10100 11010
11 01011 00101
9  01001 00111
24 11000 10110
"""
for i in range(N):
    if i==0:
        now=A[0]
    else:
        now=now^A[i]
for i in range(N):
    ans=now^A[i]
    print(ans, end=" ")

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

int main() {
	int memo1 = 1145140;
	int memo2 = 0;
	int ans = 0;
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'A') memo1 = min(memo1, i);
	}
	for (int j = 0; j < s.length(); j++) {
		if (s[j] == 'Z') memo2 = max(memo2, j);
	}
	ans = memo2 - memo1 + 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    map<string,int> mp;
    rep(i,n){
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
    return 0;
}




Measured memory_bytes: 3620
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll = long long;                    // seq 1 128 | factor   100333 ~2^16.61
using ld = long double;                  //   | grep -v ' .* '  1300111 ~2^20.31
using vl = vector<ll>;                   //                    10300777 ~2^23.30
using vvl = vector<vl>;                  //                   100400999 ~2^26.58
using pll = pair<ll,ll>;                 //                  1300400999 ~2^30.28
using vpll = vector<pll>;                //                 10200500333 ~2^33.25
using vb = vector<bool>;                 //                100200400777 ~2^36.54
using vs = vector<string>;               //               1200300700111 ~2^40.13
const ll oo = 0x3f3f3f3f3f3f3f3fLL;      //              10200300500777 ~2^43.21
const ld eps = 1e-9;                     //             100200300400777 ~2^46.51
#define sz(c) ll((c).size())             //            1200300400600999 ~2^50.09
#define all(c) begin(c),end(c)           //           10200300400600111 ~2^53.18
#define mp make_pair                     //          100200300400600333 ~2^56.48
#define mt make_tuple                    //         1200300400500800999 ~2^60.06
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

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

	ll n;
	cin >> n;
	vl hs(n);
	FOR(i,0,n) cin >> hs[i];

	vl dp(n);
	dp[0] = 0;
	dp[1] = abs(hs[1] - hs[0]);
	FOR(i,2,n) {
		ll a, b;
		a = dp[i-2] + abs(hs[i] - hs[i-2]);
		b = dp[i-1] + abs(hs[i] - hs[i-1]);
		dp[i] = min(a, b);
	}

	cout << dp[n-1] << "\n";

	return 0;
}


Measured memory_bytes: 1792
/*
Author : Chandan Agrawal
College : Poornima College of Engg. jaipur, Raj
Mail : chandanagrawal23@gmail.com


" when you are not practicing someone else is ,
 and the day u meet them u will lose "

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX 200050

#define ll long long
#define ld long double
#define lli long long int

#define pb push_back
#define INF 1000000000000
#define mod 1000000007

// trignometric function always give value in Radians only
#define PI acos(-1) //3.1415926535897932384626433832795028
#define dsin(degree) sin(degree*(PI/180.0))
#define dcos(degree) cos(degree*(PI/180.0))
#define dtan(degree) tan(degree*(PI/180.0))

#define rsin(radian) sin(radian)
#define rcos(radian) cos(radian)
#define rtan(radian) tan(radian)

#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))

#define loop(i,n)  for (lli i = 0; i < n; i++)
#define FOR(i,a,b) for (lli i = a; i < b; i++)

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define makeuniq(v) v.resize(unique(all(v)) - v.begin()); //only uniq element in vector after this
#define sz(x) int(x.size())
#define F first
#define S second

#define mii map<lli,lli>

#define pii pair<lli,lli>

#define vi vector<lli>
#define vvi vector<vi>
#define vpi vector<pii>
#define vbool vector<bool>

#define seti set<lli>

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a/gcd(a,b))*b
#define abs(x) ((x < 0)?-(x):x)

#define endl '\n'

template <typename Head>
void print(Head&& head)
{
    cout<<head<<endl;
}
template <typename Head, typename... Tail>
void print(Head&& head, Tail... tail)
{
    cout<<head<<" ";
    print(tail...);
}

#define scanarr(a,n) for(lli i=0;i<n;i++)    cin>>a[i];
#define scanvec(a,n) for(lli i=0;i<n;i++){ lli x ; cin>>x; a.pb(x);}

#define printarr(a,n) for(lli i=0;i<n;i++)   cout<<a[i]<<" "; cout<<endl;
#define printvec(vec) for(auto xt : vec) cout<<xt<<" ";    cout<<"\n";

#define FD(N) fixed<<setprecision(N)

#define deb(x) cout<<#x<<" "<<x<<endl;

/*
1D vector -  vi dp(n,value);
2D vector -  vvi dp(n,vi(n,value));
*/

// chandan1,2
void chandan1(){int y=1;return;}
void chandan2(){
        loop(i,10){
        lli x=1;
    }
    return(chandan1());
}


int main(){
fastio
lli t=1;
//cin>>t;
chandan2();
while(t--) {
    string s;
    cin>>s;
    if(s[sz(s)-1]=='s')
        cout<<s<<"es";
    else
        cout<<s<<"s";
  }
return 0;
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REPT(x, l, r) for(int x = l; x <=r; ++x)
#define REP(x, n) for(int x = 0; x <n; ++x)
int n, w;
int main(){
    cin>>n>>w;
    int arr[n+1];
    int arr2[n+1];
    int sum = 0;
    REPT(x, 1, n){
        cin>>arr[x]>>arr2[x];
        sum += arr2[x];
    }

    int dp[n+1][sum+1] = {};

    dp[0][0] = 0;

    REPT(x, 0, n){
        REPT(y, 1, sum){
            if(x == 0){
                dp[x][y] = w+1;
            }else{
                if(y < arr2[x]){
                    dp[x][y] = dp[x-1][y];
                }else{
                    dp[x][y] = min(dp[x-1][y], arr[x] + dp[x-1][y-arr2[x]]);
                }
            }
        }
    }
    int maxa = 0;
    for(int x = 1; x<= sum;x++){
        if(dp[n][x] <= w)
            maxa = x;
    }
    cout<<maxa<<endl;


}


Measured memory_bytes: 43060
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type tile struct {
	color, num int
}

type tiles []tile

func (t tiles) Len() int {
	return len(t)
}
func (t tiles) Swap(i, j int) {
	t[i], t[j] = t[j], t[i]
}
func (t tiles) Less(i, j int) bool {
	return t[i].num < t[j].num
}

func main() {
	var h, w, n int
	fmt.Scan(&h, &w, &n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	ts := make([]tile, n)
	for i := range ts {
		var t int
		sc.Scan()
		t, _ = strconv.Atoi(sc.Text())
		ts[i].color = i + 1
		ts[i].num = t
	}
	sort.Sort(sort.Reverse(tiles(ts)))
	// fmt.Println("h", h, "w", w, "n", n, "ts", ts)
	mapout := make([][]int, h)
	for i := range mapout {
		mapout[i] = make([]int, w)
	}
	ci := 0
	for y := 0; y < h; y++ {
		if y%2 == 0 {
			for x := 0; x < w; x++ {
				if ts[ci].num == 0 {
					ci++
				}
				ts[ci].num--
				mapout[y][x] = ts[ci].color
			}
		} else {
			for x := w - 1; x >= 0; x-- {
				if ts[ci].num == 0 {
					ci++
				}
				ts[ci].num--
				mapout[y][x] = ts[ci].color
			}
		}
	}
	// fmt.Println(mapout)
	for y := 0; y < h; y++ {
		for x := 0; x < w; x++ {
			fmt.Print(mapout[y][x], " ")
		}
		fmt.Println()
	}
}


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

using namespace std;

#define int long long
static const int INF = 1LL<<61;

signed main() {
  int n, m, cum[100005] = {0}, pre;
  cin >> n >> m >> pre;
  for (int i = 1; i < m; ++i) {
    int p;
    cin >> p;
    int s = min(pre, p), t = max(pre, p);
    cum[s]++;
    cum[t]--;
    pre = p;
  }

  int sum = 0, ans = 0;
  for (int i = 1; i < n; ++i) {
    sum += cum[i];
    int a, b, c;
    cin >> a >> b >> c;

    if ((c / (a - b)) < sum) {
      ans += sum * b + c;
    } else {
      ans += sum * a;
    }
  }

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

Measured memory_bytes: 1944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

const int INF = (1LL << 31) - 1;

struct segtree
{
    int n;
    vint dat;
    segtree(int count, int start)
    {
        int c = 1 << (int)(log2(count) + 1);
        dat = vint(2 * c, start);
        n = c;
    }

    void update(int i, int x)
    {
        int k = i + n;
        dat[k] = x;
        while (k / 2)
        {
            k /= 2;
            dat[k] = min(dat[k * 2], dat[k * 2 + 1]);
        }
    }

    int subGetMin(int a, int b, int k, int l, int r)
    {
        // out
        if (b <= l || a >= r)
        {
            return INF;
        }
        // completely contained
        if (a <= l && b >= r)
        {
            return dat[k];
        }
        // partially contained
        // call child
        int newK = k * 2;
        int vl = subGetMin(a, b, newK, l, (l + r) / 2);
        int vr = subGetMin(a, b, newK + 1, (l + r) / 2, r);
        return min(vl, vr);
    }

    int getMin(int a, int b)
    {
        return subGetMin(a, b, 1, 0, n);
    }
};

int main()
{
    int n, q;
    cin >> n >> q;
    segtree st(n, INF);
    rep(i, q)
    {
        int t, x, y;
        cin >> t >> x >> y;
        if (t)
        {
            int m = st.getMin(x, y + 1);
            cout << m << endl;
        }
        else
        {
            st.update(x, y);
        }
    }
    return 0;
}


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

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

    int x = *max_element(a.begin(), a.end());                           //最大値
    std::vector<int>::iterator maxIt = max_element(a.begin(), a.end()); //最大値までのイテレーター
    size_t maxIndex = distance(a.begin(), maxIt);                       //最大値の添字

    //cout << "x:" << x << endl;
    //cout << "maxIndex:" << maxIndex << endl;
    for (int i = 0; i < n; i++)
    {
        if (i != maxIndex)
        {
            cout << x << endl;
        }
        else
        {
            int mv = 0;
            for (int i = 0; i < n; i++)
            {
                if (a[i] > mv && i != maxIndex)
                    mv = a[i];
            }
            cout << mv << endl;
        }
    }
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;



int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S, T; cin >> S >> T;
    rep(i, S.length()+T.length()){
        if(i%2==0) cout << S[i/2];
        else cout << T[i/2];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  string a , b ,c;
  cin >> a >> b >> c;
  
  if( a[a.size()-1] == b[0] && b[b.size()-1] == c[0]  )
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(),a = sc.nextInt();
    n = n % 500;
    if(n <= a){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 25172
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int h, w; readV(h, w);

  writeln('#'.repeat.take(w+2));
  foreach (_; 0..h) {
    string s; readV(s);
    writeln('#', s, '#');
  }
  writeln('#'.repeat.take(w+2));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define REP3(i,x,n) for(int i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    ll A,B,C,D;
    scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
    while(A>0&&C>0){
        C-=B;
        A-=D;
        
        
        
    }
    if(C<=0)printf("Yes");
    else if(A<=0)printf("No");
    

    
    return 0;
}

Measured memory_bytes: 3852
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[3];
	for(int i=0;i<3;++i)
		cin>>a[i];
	sort(a,a+3);
	if(a[0]==5&&a[1]==5&&a[2]==7)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll N, M;
bool ok(ll A){

  // A個つくれるかどうか
  if(M < 2 * A){
    return true;
  }else{

    ll sumS = N + (M - 2 * A) / 2;

    if(sumS >= A){
      return false;
    }else{
      return true;
    }
  }
}

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

  cin >> N >> M;

  ll left = -1;
  ll right = 1e13;

  while(right - left > 1){
    ll mid = left + (right - left) / 2;
    if(ok(mid)) right = mid;
    else left = mid;
  }

  cout << left << endl;
 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define pp pair<ll,ll>
#define fore(i,n) for(ll i=0;i<n;i++)
#define vi vector<ll>
using namespace std;
const ll mod=998244353;
ll power(ll a,ll b)
{
if(b==0)
return 1;
else if(b==1)
{
return a;
}
else if(b&1)
{
return (a%mod * power((a%mod * a%mod)%mod,b/2)%mod)%mod;
}
else
{
return power((a%mod * a%mod)%mod,b/2)%mod;
}
}
 
void solve()
{
    int n;
    cin>>n;
    int m=(int)ceil(n*1.00/1000)*1000-n;
    cout<<m<<endl;
}
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  
solve();
 
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
const int N=2e5+5,INF=2e9;
using namespace std;
template<typename tp>inline void r(tp &n){
	n=0;char c=getchar();
	while(!isdigit(c)) c=getchar();
	while( isdigit(c)) n=n*10+c-48,c=getchar();	
}
int n,k;
int a[N];
bool OK(int cur){
	int ret=0;
	for(int i=1;i<=n;++i)
		ret+=((a[i]-1)/cur);
	return ret<=k;	
}
int main(){
	
	int L=1,R=0;
	r(n),r(k);
	for(int i=1;i<=n;++i)
		r(a[i]),R=max(R,a[i]);
	while(L<=R){
		int mid=L+R>>1;
		if(OK(mid)) R=mid-1;
		else L=mid+1;	
	}
	printf("%d\n",R+1);
	return 0;
}


Measured memory_bytes: 4436
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextInt();
        long b = sc.nextInt();
        long c = sc.nextInt();
        long d = sc.nextInt();
        sc.close();
        long ansList[] = {a*c, a*d, b*c, b*d};
        long max = ansList[0];
        for(int i=0; i<ansList.length; i++) {
            if (max<ansList[i]) {
                max=ansList[i];
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 36100
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;


int main() {
	int n;
	vector<string> s;
	vector<int>t;
	string x;
	cin >> n;
	s.resize(n);
	t.resize(n);
	rep(i, n) {
		cin >> s[i] >> t[i];
	}
	cin >> x;
	bool exist = false;
	int ans = 0;
	rep(i, n) {
		if (exist) ans += t[i];
		if (s[i] == x) {
			exist = true;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7
dp=[[0]*(k+2) for i in range(n+1)]
dp[0][0]=1
B=[0]*(2*k+3) #累積和list
for i in range(1,n+1):
  for j in range(k+1):
    B[j]=B[j-1]+dp[i-1][j]
  for j in range(k+1):
    dp[i][j]=(B[j]-B[j-A[i-1]-1])%mod
print(dp[n][k])

Measured memory_bytes: 118128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll N;
    cin>>N;
    vector<ll> pos(N,0);
    for(ll i=0;i<N;i++){
        ll curr;
        cin>>curr;
        curr--;
        pos[curr]=i;
    }
    multiset<ll> ms;
    ms.insert(-1);
    ms.insert(-1);
    ms.insert(N);
    ms.insert(N);
    ll ans=0;
    for(ll i=N-1;i>=0;i--){
        ll curr=pos[i];
        ms.insert(curr);
        auto it=ms.find(curr);
        it--;
        ll p1 = *it;
        it--;
        ll p2 = *it;
        it++;it++;it++;
        ll n1 = *it;
        it++;
        ll n2 = *it;
        ll x=i+1;
        ll count=(n2-n1)*(pos[i]-p1);
        count+=(p1-p2)*(n1-pos[i]);
        ans+=(x*count);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5760
N = gets.to_i
A = gets.chomp.split.map(&:to_i).sort!
max = A.max
ary = Array.new(max, 0)
ans = 0

A.each do |e|
  ary[e-1] += 1
end

A.uniq.each do |e|
  next if ary[e-1] == 0
  ans += 1  if ary[e-1] == 1
  (e-1).step(max, e) do |i|
    ary[i] = 0
  end
end

puts ans
  
    

  






Measured memory_bytes: 44876
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int X, N;
    bool num[102] = {};
    cin >> X >> N;
    REP(i, N) {
        int p;
        cin >> p;
        num[p] = true;
    }
    int ans = 0, len = 1000000;
    REP(i, 102) {
        if (!num[i]) {
            if (abs(X - i) < len) {
                ans = i;
                len = abs(X - i);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define fillarray(array, value, begin, end) fill((array) + (begin), (array) + (end) + 1, value)
#define fillvector(v, value) fill((v).begin(), (v).end(), value)
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
#define vecfirst (*vec.begin())
#define veclast (*vec.rbegin())
#define vecall(v) (v).begin(), (v).end()
#define vecupsort(v) (sort((v).begin(), (v).end()))
#define vecdownsort(v, type) (sort(vecall(v), greater<type>()))
#define veccmpsort(v, cmp) (sort(vecall(v), cmp))
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000);
    system("pause");
#endif
}
int n;

inline void solve()
{
    cin>>n;
    cout << (n == 0) ? 1 : 0;
}

int main()
{
    TIME__START = clock();
    int Test = 1;
    // scanf("%d", &Test);
    while (Test--)
        solve();
    TIME__END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s, t; cin >> s >> t;
  int lens = s.size(), lent = t.size();
  for(int i = lens-lent; i >= 0; i--){
  	bool ok = true;
    for(int j = 0; j < lent; j++){
    	if(s[i + j] == '?') continue;
      ok &= s[i + j] == t[j];
    }
    if(ok){
    	for(int j = 0; j < lent; j++) s[i + j] = t[j];
      for(int j = 0; j < lens; j++) if(s[j] == '?') s[j] = 'a';
      cout << s << endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))
from collections import deque

N, K = mi()
D = li()

r = [i for i in range(10) if i not in D]

if r[0]==0:
    que = deque(r[1:])
    #que = r[:][1:]
else:
    que = deque(r)
    #que = r[:]

for num in que:
    if N <= num:
        print(num)
        exit()
i = 0
while True:
    base = que[i]*10
    for num in r:
        new = base + num
        if new >= N:
            print(new)
            exit()
        que.append(new)
    i += 1


Measured memory_bytes: 3548
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
#include <queue>
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=1;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;

int main(int argc, char const *argv[]) {
    int n, k;
    cin >> n >> k;
    ll ans = 0ll;
    if (k%2 == 0) {
        ll ca = n/k;
        ll cb = n/(k/2)-ca;
        ans = ca*ca*ca+cb*cb*cb;
    } else {
        ll ca = n/k;
        ans = ca*ca*ca;
    }
    cout << ans << std::endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second


template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    VV sind(26);
    rep(i,s.length()){
        sind[s[i]-'a'].pb(i);
    }
    ll ans=0;
    ll now= -1;
    rep(i,t.length()){
        int ind = t[i]-'a';
        auto itr = upper_bound(ALL(sind[ind]),now);
        if(itr==sind[ind].end()){
            if(sind[ind].size()==0){
                cout << -1 << endl;
                return  0;
            }
            now = sind[ind][0];
            ans += s.length();
        }else{
            now = *itr;
        }
    }
    ans += now;
    ans ++;
    cout << ans << endl;
    return  0;
}


Measured memory_bytes: 1736
import sys

input = sys.stdin.readline


def calc_divisors(n):
    divisors_a = []
    divisors_b = []
    for d in range(1, int(n**0.5) + 1):
        if n % d == 0:
            divisors_a.append(d)
            if n // d != d:
                divisors_b.append(n // d)
    divisors = divisors_a + divisors_b[::-1]
    return divisors


def main():
    N = int(input())

    divisors = calc_divisors(N)
    ans = 0
    for divisor in divisors:
        q = divisor
        m = N // q - 1
        if 1 < m and q < m:
            ans += m

    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

typedef unsigned long long ull;

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

    ull a, b;
    cin >> a >> b;  

    ull k = (a + b) / 2;
    if (k * 2 == a + b)
        cout << k;
    else
        cout << "IMPOSSIBLE";


    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# user: herp_sy

import math
import statistics

win = 0
lose = 0
s = input()
for i in range(len(s)):
  if s[i] == 'o':
    win = win + 1
  else:
    lose = lose + 1
if(win + (15 - len(s)) >= 8):
  print('YES')
else:
  print('NO')


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

int main(void){

    string S; cin>>S;
    if(S=="Sunny") S = "Cloudy";
    else if(S=="Cloudy") S = "Rainy";
    else S = "Sunny";
    cout<<S<<endl;

    return 0;
}

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

using namespace std;
int main() {
    string s, t;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    string u;
    cin >> u;
    if (s==u)
        --a;
    else
        --b;
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define MININF -1e18L
#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 ALL(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> intint;

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

int main(void)
{
    int n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }

    ll ans = a[0];
    for (int i = 1; i < n; i++) {
        ans = gcd(ans, a[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n;
  std::cin>>n;

  std::vector<std::vector<ll>> dp(n,std::vector<ll>(3,0));

  std::cin>>dp[0][0]>>dp[0][1]>>dp[0][2];

  rep(i,1,n){
    ll a,b,c;
    std::cin>>a>>b>>c;
    dp[i][0]=a+std::max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=b+std::max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=c+std::max(dp[i-1][0],dp[i-1][1]);
  }

  std::cout<<std::max(dp[n-1][0],std::max(dp[n-1][1],dp[n-1][2]));

  return 0;
}

Measured memory_bytes: 5760
#include <iostream>

typedef long long ll;

const ll MOD = 1000000007;

ll mult(ll a, ll b){ 
   if(b==0) return 1;

   ll g = mult(a, b/2); 
   if(b%2) return g * g % MOD * a % MOD;
   return g * g % MOD;
}

ll C(ll n, ll k){ 
   if(k>n || k<0) return 0;
   ll gt = 1;
   ll rev = 1;
   for(int i=n; i>=n-k+1; --i) gt = (gt*i) % MOD;
   for(int i=1; i<=k; ++i) rev = (rev*i) % MOD;

   return gt * mult(rev, MOD-2) % MOD;
}

int main(){
   ll n, a, b;
   std::cin >> n >> a >> b;

   std::cout << ((mult(2, n) - C(n, a) - C(n, b) - 1 + MOD)%MOD + MOD)%MOD << std::endl;
   return 0;
}


Measured memory_bytes: 256
require "set"

def other_color(c, d)
  if c == d
    return c
  else
    diff = %w(r g b) - [c, d]
    return diff.first
  end
end

def next_worm(worm)
  pairs = worm.split('').each_cons(2).to_a
  others = pairs.map { |pr| other_color(*pr)}

  result = others.each_with_object([]).with_index{|(e, a), i|
    w = worm.dup
    w[i, 2] = e*2
    unless $found.include? w
      $found << w
      a << w
    end
  }
  result
end

def mono_color_time(init)
  $found = Set.new([init]) # 遷移して初期状態に戻る場合
  time = 0
  ws = [init]
  until ws.empty? or ws.any? { |w| w.split('').uniq.size == 1 }
    time += 1
    ws = ws.flat_map { |w| next_worm(w) }.uniq
  end
  ws.empty? ? 'NA' : time
end

loop do
  ln = gets.chomp
  break if ln == '0'
  puts mono_color_time(ln)
end


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

using namespace std;

int n, a[100005], st[100], top;
map<int, int> mp;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", a + i);
	if (n % 3) {
		for (int i = 1; i <= n; ++i) if (a[i]) {
			puts("No");
			return 0;
		}
		puts("Yes");
		return 0;
	}
	int flag = 1;
	for (int i = 1; i <= n; ++i) if(a[i]) flag = 0;
	if (flag) {
		puts("Yes");
		return 0;
	}
	else {
		sort(a + 1, a + n + 1);
		for (int i = 2; i <= n / 3; ++i)
			if (a[i] != a[i - 1]) { puts("No"); return 0; }
		for (int i = n / 3 + 2; i <= n * 2 / 3; ++i)
			if (a[i] != a[i - 1]) { puts("No"); return 0; }
		for (int i = n * 2 / 3 + 2; i <= n; ++i)
			if (a[i] != a[i - 1]) { puts("No"); return 0; }
		if (a[1] ^ a[n / 3 + 1] ^ a[n * 2 / 3 + 1]) { puts("No"); return 0; }
		puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 640