akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <stdio.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
int main(){
  ll A,B,C;
  cin>>A>>B>>C;
  
  putYN(A==B&&A==C);
  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let t: String = read();
    let mut a: i32 = read();
    let mut b: i32 = read();
    let u: String = read();
    if u == s.to_string() {
        a -= 1;
    } else {
        b -= 1;
    }
    println!("{} {}", a, b);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
using namespace std;
int main(void){
    // Your code here!
    int K;
    string S;
    cin >> K >> S;
    decltype(S.begin()) itr = S.begin();
    while (itr != S.end() && K-- != 0)
    {
        cout << *itr;
        advance(itr, 1);
    }
    if (K < 0) cout << "..." << endl;
    return 0;
}


Measured memory_bytes: 3540
#include <iostream>

using namespace std;

typedef long long ll;
ll memo[31];

ll f(int n) {
  if (n == 1) return 1;
  if (n == 2) return 2;
  if (n == 3) return 4;
  if (memo[n]) {
    return memo[n];
  }
  return memo[n] = f(n-1) + f(n-2) + f(n-3);
}



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

    if (n == 0) {
      break;
    }

    cout << f(n) / 10 /365  + 1<< endl;


  }

  return 0;
}

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

struct UnionFind {
    vector<int> tree;

    UnionFind(int n) : tree(n, -1) {}

    int root(int n) {
        if (tree[n] < 0) return n;
        return tree[n] = root(tree[n]);
    }

    void unite(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (tree[a] > tree[b]) swap(a, b);
        tree[a] += tree[b];
        tree[b] = a;
    }

    int size(int n) { return -tree[root(n)]; }
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for (size_t i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a, b);
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
        res = max(res, uf.size(i));
    }
    cout << res << endl;
}


Measured memory_bytes: 4020
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define iFOR(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long UL; // ULLONG_MAX, %llu
typedef unsigned int UI; //UINT_MAX %u
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;

map<string, int> mp;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    FOR(i, 1, n){
        string x;
        cin >> x;
        mp[x]++;
    }
    cout << "AC x " << mp["AC"] << '\n';
    cout << "WA x " << mp["WA"] << '\n';
    cout << "TLE x " << mp["TLE"] << '\n';
    cout << "RE x " << mp["RE"] << '\n';
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long int ll;
#define ipair pair<int,int>
#define mod 1000000007


int main()
{
   int n,k;
   cin>>n>>k;
   int a[101];
   int res=0;
   for(int i=0;i<n;i++)
   {
      cin>>a[i];
      res+=2*min(a[i],abs(a[i]-k));
   }
   cout<<res<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int main(){
	int N,M;
	cin>>N>>M;
	int ans=0;
	rep(i,N){
		cout<<"lst "<<i<<endl;
		int K,gomi;
		cin>>K;
		rep(i,K) cin>>gomi;
		ans+=K*(K-1);
	}
	cout<<"ans "<<ans<<endl;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

int main() {
  int N;
  cin >> N;
  repp(i, N, 999) {
    if (i % 10 == (i / 10) % 10 && (i / 10) % 10 == (i / 100) % 10) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <limits.h>
#define ll long long
#define xx first
#define yy second

using namespace std;

int main () {
	char a[5], b[5];
	scanf ("%s%s", a + 1, b + 1);
	int cnt = (a[1] == b[1]) + (a[2] == b[2]) + (a[3] == b[3]);
	printf ("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define modulo 998244353
#define endl '\n'
#define pb push_back
using namespace std;
vector <int> adj[100001];
ll fxp(ll a, ll b)
{
    if(b == 0)return 1;
	if(b%2 == 0){
		ll c = fxp(a,b/2);
		return (c*c)%1000000007;
	}
	return (a*fxp(a,b-1))%1000000007;
}
int lcm(int c,int d)
{
    int a=c;
    int b=d;
    int ans;
    if(a>=b)
    {
        while(b!=0)
        { 
            int x=b;
            b=a%b;
            a=x;
        }
        ans = ( c*d)/a;
    }
    else
    {
        while(a!=0)
        {
            int x=a;
            a=b%a;
            b=x;
        }
        ans = ( c*d)/b;  
    }
    return ans;
}
int root_find()
{
    ll x;
    for(int i=1;i<100001;i++)
    {
        if(adj[i].size()==1)
        {
            x = i;
            break;
        }
    }
    return x;
}
void dfs(int s,int y)
{
    for(int i=0;i<adj[s].size();i++)
    {
        if(adj[s][i]==y)
        continue;
        dfs(adj[s][i],s);
    }
}
bool isPrime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
ll smallestDivisor(ll n) 
{ 
    // if divisible by 2 
    if (n % 2 == 0) 
        return n/2; 
  
    // iterate from 3 to sqrt(n) 
    for (int i = 3; i * i <= n; i += 2) { 
        if (n % i == 0) 
            return n/i; 
    } 
  
    return n; 
}  
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin>>n;
    ll a[n];
    ll cnt[100001];
    for(int i=0;i<100001;i++)
    cnt[i]=0;
    ll sum=0;
    for(int i=0;i<n;i++)
    {
    cin>>a[i];
    cnt[a[i]]++;
    sum = sum + a[i];
    }
    ll q;
    cin>>q;
    for(int i=0;i<q;i++)
    {
        ll b,c;
        cin>>b>>c;
        //sum= sum + (c-b);
        //cout<<sum<<endl;
        /*while(binary_search(a,a+n,b))
        {
            ll k = upper_bound(a,a+n,b)-a;
            k--;
            a[k]=c;
            sum= sum + (c-b);
        }*/
        sum = sum + cnt[b]*(c-b);
        ll x = cnt[b];
        cnt[b]=0;
        cnt[c]=cnt[c]+x;
        cout<<sum<<endl;
        
        
    }

    return 0;
}

Measured memory_bytes: 7568
#include<iostream>
using namespace std;
int main(){
  int h,w;
  while(cin >> h >> w && h||w){
    for(int j=0;j<w;j++) cout << "#";
    cout << endl;
    for(int i=1;i<h-1;i++){
      cout << "#";
      for(int j=1;j<w-1;j++) cout << ".";
      cout << "#" << endl;
    }
    for(int j=0;j<w;j++) cout << "#";
    cout << endl << endl;
  }
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int t=s.length();
	if(s[t-1]=='2' || s[t-1]=='4' || s[t-1]=='5' || s[t-1]=='7' ||s[t-1]=='9')cout<<"hon";
	else if(s[t-1]=='0' ||s[t-1]=='1' ||s[t-1]=='6' ||s[t-1]=='8')cout<<"pon";
	else if(s[t-1]=='3')cout<<"bon";
	return 0;
}

Measured memory_bytes: 3624
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_3-D: Areas on the Cross-Section Diagram

#include <algorithm>
#include <iostream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

using uint = unsigned int;

struct Area {
  const uint from;
  const uint area;
  Area(const uint from, const uint to) : from(from), area(to-from) { }
};
                     
static stack<Area> prepare_areas(const string& str)
{
  stack<Area> areas;
  stack<uint> s;
  for (auto i = 0u; i < str.size(); ++i) {
    auto c = str[i];
    if (c == '\\') {
      s.push(i);
    } else if (c == '/') {
      if (!s.empty()) {
        areas.push(Area(s.top(), i));
        s.pop();
      }
    } else {
      // nop
    }
  }
  return move(areas);
}

static pair<uint, vector<uint>> accumulate_areas(stack<Area> areas) {
  auto sum = 0u;
  vector<uint> accs;
  while (!areas.empty()) {
    auto p = areas.top();
    areas.pop();
    auto acc = p.area;
    while (!areas.empty() && p.from < areas.top().from) {
      acc += areas.top().area;
      areas.pop();
    }
    sum += acc;
    accs.push_back(acc);
  }
  reverse(accs.begin(), accs.end());
  return move(make_pair(sum, accs));
}

int main()
{
  string str;
  getline(cin, str);
  auto areas = prepare_areas(str);

  auto sum_accs = accumulate_areas(move(areas));
  auto sum = sum_accs.first;
  auto accs = sum_accs.second;

  cout << sum << endl;
  cout << accs.size();
  for (auto acc : accs) {
    cout << " " << acc;
  }
  cout << endl;
}

// eof

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


const int MOD = 1e9 + 7;
const int MAX = 1e6;
int N, mx;
vector<int> A, prime_list;
map<int, int> lcm;
ll inv[MAX];


void input() {
    cin >> N;
    A = vector<int>(N);
    rep(i, N) cin >> A[i];
}


void inv_init() {
    inv[1] = 1;
    for (int i = 2; i <= MAX; i++){
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    }
}


bool is_prime(int x) {
    int sqrt_x = sqrt(x);
    for (int i = 0; prime_list[i] <= sqrt_x; i++) {
        if (x % prime_list[i] == 0) return false;
    }
    return true;
}


void make_prime(int n) {
    if (2 <= n) prime_list.push_back(2);
    int x = 3;
    while (x <= n) {
        if (is_prime(x)) prime_list.push_back(x);
        x += 2;
    }
}


void prime_factor(int n) {
    for (int i : prime_list) {
        int x = 1;
        while(n % i == 0) {
            x *= i;
            n /= i;
        }
        if (x != 1) lcm[i] = max(lcm[i], x);
    }
    if(n != 1) {
        lcm[n] = n;
    }
    // return ret;
}


int main() {
    inv_init();
    input();
    mx = *max_element(A.begin(), A.end());
    mx = sqrt(mx);
    make_prime(mx);
    rep(i, N) prime_factor(A[i]);
    ll L =  1;
    for (auto p : lcm) {
        L = L * p.second % MOD;
    }
    ll ans = 0;
    rep(i, N) {
        ans = (ans + L * inv[A[i]]) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
int n, a[101];

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

	cin >> n;
	int ans = 0;
	for(int i = 1; i<=n; i++){
		cin >> a[i];
		if(i%2 && a[i]%2) ans++;
	}

	cout << ans << endl;

	cout.flush();
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,ans=0; cin >> n;
  vector<int> p(n);
  
  for (int i = 0; i < n; ++i) {
    cin >> p.at(i);
 }
  
  for (int i = 0; i < (n-2); ++i) {
    if((p.at(i) < p.at(i+1) && p.at(i+1) < p.at(i+2) ) ||
       (p.at(i) > p.at(i+1) && p.at(i+1) > p.at(i+2) )){
      ans++;
    }
 }
  
  cout << ans << endl;
  return 0;
}

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

long long pow5(long long n){
  return n * n * n * n * n;
}

int main(void){
  long long x;
  cin >> x;

    bool foundx = false;
    bool foundy = false;
  
  
  
  for(long long i = -1000;i<1001;i++){
    for(long long j = -1000;j<1000;j++){
      if(pow5(i) - pow5(j) == x){
        cout << i << " " << j << endl;
        foundx = true;
        foundy = true;
        break;
      }
    }
    if(foundx && foundy) break;
  }
  
  return 0;
}

  

Measured memory_bytes: 3636
<?php
list($N, $Q) = array_map('intval', explode(' ', trim(fgets(STDIN))));
$S = trim(fgets(STDIN));
$queries = [];
for($i = 0; $i < $Q; $i++) {
    list($l, $r) = array_map('intval', explode(' ', trim(fgets(STDIN))));
    $queries[] = [$l, $r];
}

$qsum = [];
$count = 0;
$i = 0;
while ($i < $N) {
    $qsum[$i] = $count;
    if ($S[$i] == 'A' && $i < $N - 1) {
        $i++;
        if ($S[$i] == 'C') {
            $count++;
            $qsum[$i] = $count;
        }
    } else {
        $i++;
    }
}

//print_r($qsum);
foreach ($queries as $q) {
    list($l, $r) = $q;
    echo ($qsum[$r - 1] - $qsum[$l - 1]). "\n";
}

Measured memory_bytes: 51700
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<time.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


string s;

int main(){
	cin >> s;
	
	bool b = 0;
	for(int i = 0; i < s.size(); i++){
		if(i % 2){
			if(s[i] == 'R') b = 1;
		}
		else{
			if(s[i] == 'L') b = 1;
		}
	}
	
	if(b) cout << "No" << endl;
	else cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 764
from collections import deque
N = 3
m = {8: {7, 5}, 7: {8, 6, 4}, 6: {7, 3}, 5: {8, 4, 2}, 4: {7, 5, 3, 1}, 3: {6, 4, 0}, 2: {5, 1}, 1: {4, 2, 0},
     0: {3, 1}}
goal = 123456780
def g(i, j, a):
    t = a // (10 ** j) % 10
    return a - t * (10 ** j) + t * (10 ** i)
def solve():
    MAP = "".join(input().replace(" ", "") for _ in range(N))
    zero = 8 - MAP.find("0")
    start = int(MAP)
    if start == goal:
        return 0
    dp = deque([(0, start, zero, 1), (0, goal, 0, 0)])
    TABLE = {start: (1, 0), goal: (0, 0)}
    while dp:
        cnt, M, yx, flg = dp.popleft()
        cnt += 1
        for nyx in m[yx]:
            key = g(yx, nyx, M)
            if key in TABLE:
                if TABLE[key][0] != flg:
                    return TABLE[key][1] + cnt
                continue
            TABLE[key] = (flg, cnt)
            dp.append((cnt, key, nyx, flg))
def MAIN():
    print(solve())
MAIN()



Measured memory_bytes: 8488
import sys
sy = sys.stdin.readlines()
N,Q = map(int, sy[0].split())
S = sy[1]
ACindex = [0 for _ in range(N+1)]
count = 0
for n in range(1, N):
  if S[n-1]=="A" and S[n]=="C":
    count += 1
  ACindex[n+1] = count

for i in range(Q):
  l, r = map(int, sy[2+i].split())
  print(ACindex[r]-ACindex[l])


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <ll> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int T=1;
    //cin >> T;
    while(T--){
        ll n,k;
        cin>>n>>k;
        ll a[n];
        rep(i,n) cin>>a[i];
        ll t[n+1]={0};
        t[1]=1;
        ll i=a[0];
        ll c=2;
        vi v;
        v.pb(1);
        while(t[i]==0){
            t[i]=c++;
            v.pb(i);
            i=a[i-1];
        }
        // rep(i,v.size()) cout<<v[i]<<" ";
        // cout<<el;
        // cout<<i<<el;
        if(k<=v.size()-1) cout<<v[k]<<el;
        else{
            k-=(v.size()-1);
            ll cycle=(v.size()-t[i]+1);
            k%=cycle;
            if(k==0) cout<<v[v.size()-1]<<el;
            else{
                cout<<v[t[i]-1+k-1]<<el;
            }
        }

    }

    return 0;
}

Measured memory_bytes: 8380
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main{
	public static void main(String[] args) throws IOException{


		// 読み込み
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] temp;

		line=br.readLine();
		temp=line.split(" ");

		int a = Integer.valueOf(temp[0]);
		String op = temp[1];
		int b = Integer.valueOf(temp[2]);

		if(op.equals("+")){
			System.out.println(a+b);
		}else{
			System.out.println(a-b);
		}


	}
}


Measured memory_bytes: 21332
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(void){
    int n;
    vector<int> s;
    long long ans = 0;
    cin >> n;
    s.assign(n, 0);
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    for(int c = 1; c < n; c++){
        int a = n-1;
        long long scr = 0;
        set<int> usd;
        for(int i=0;a>c&&c*i<n;i++){
            if(usd.find(a) != usd.end())break;
            if(usd.find(c*i) != usd.end())break;
            if(a == c*i)break;
            scr += s[a] + s[c*i];
            usd.insert(a);
            usd.insert(c*i);
            ans = max(ans, scr);
            a -= c;

        }
    }
    cout << ans << endl;
}


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

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

Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int [] in = new int [a];
        int b = 0;
        int c = 1;
        if(a==1){b++;}
        else{for(int i=0;i<a;i++){in[i] = sc.nextInt();                            
                                    }
                Arrays.sort(in);       
                for(int i=0;i<a-1;i++){if(in[i]==in[i+1]){c++;}
                             
                                     else{if(c%2==1){b++;}c=1;
                                         }                            
                                     if(i==a-2){if(c%2==1){b++;}                                     
                                               }                          
                                    }
               }
		System.out.println(b);
	}
}


Measured memory_bytes: 51644
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main(void)
{
	int c, n = 0;
	char s1[100], s2[100];
	
	while (scanf("%s", s1) != EOF){
		c = 0;
		for (int i = 0; i <= strlen(s1); i++){
			s2[i] = s1[i];
		}
		
		reverse(s2, s2 + strlen(s1));
		for (int i = 0; i <= strlen(s1); i++){
			if (s1[i] == s2[i]){
				c++;
				if (c == strlen(s1)){
					n++;
				}
			}
		}
	}
	
	printf("%d\n", n);
	
	return (0);
}

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

static const int MAX_V = 100000;
static const long long INF = 1 << 30;

struct edge{ int to, cost;};
typedef pair<int,int> P;//firstは最短距離,secondが頂点の番号

int V;
vector<edge> G[MAX_V];
int d[MAX_V];
int Prev[MAX_V];

void dijkstra(int s){
    //greater<P>によって、firstが小さい順に取り出せるようになる
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    fill(Prev, Prev + V, -1);
    d[s] = 0;
    que.push(P(0,s));

    while( !que.empty()){
        P p = que.top(); que.pop();//最短距離が小さい順に取り出していく
        int v = p.second;//現在の頂点番号
        if( d[v] < p.first) continue;//もし現在の頂点の最短距離が現在の最短距離と一致しない場合はむし
        for(int i = 0; i < G[v].size(); i++){
            edge e = G[v][i];//見てる頂点から伸びる辺がe
            if(d[e.to] > d[v] + e.cost){//もし、eの伸びる先の頂点の最短距離がvから見た最短距離よりも大きい場合
                d[e.to] = d[v] + e.cost;
                Prev[e.to] = v;
                que.push(P(d[e.to], e.to));//仮の最短距離とその頂点番号
            }
        }
    }
}

// 頂点tへの最短路
vector<int> get_path(int t){
    vector<int> path;
    for(; t != -1; t = Prev[t]) path.push_back(t);//tがsになるまで辿っていく
    reverse(path.begin(), path.end());
    return path;
}

bool visited[MAX_V];

int bfs(int s){
    queue<int> que;
    que.push(s);
    int cnt = 0;
    while(!que.empty()){
        int v = que.front(); que.pop();
        for(auto e: G[v]){
            int u = e.to;
            if(visited[u])continue;
            cnt++;
            que.push(u);
            visited[u] = true;
        }
    }
    return cnt;
}

int main(){
    cin >> V;
    rep(i, V - 1){
        int a, b; cin >> a >> b; a-- , b--;
        G[a].push_back({b, 1});
        G[b].push_back({a, 1});
    }
    dijkstra(0);
    //cout << 2 << endl;
    vector<int> path = get_path(V - 1);
    //cout << 3 << endl;
    int k = path.size();
    const int black = k - ( k / 2), white = k / 2;
    int fennec = black, snuke = white;

    for(auto e: path) visited[e] = true;
    //cout <<  k << endl;

    for(int i = 0; i < k; i++){
        if(i < black){
            fennec += bfs(path[i]);
        }else{
            snuke += bfs(path[i]);
        }
    }
    if(fennec > snuke) puts("Fennec");
    else puts("Snuke");
}

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

using namespace std;

int main()
{
	int n;
	cin>>n;
	vector<int> emp_rep_id(n+1);
	
	for(int i =2; i<=n; i++){
		int val = 0;
		cin>>val;
		emp_rep_id[val]++;
	}
	
	for(int i = 1; i<=n;i++){
		cout<<emp_rep_id[i]<<endl;
	}
		
	return 0;
}


Measured memory_bytes: 3988
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val r = sc.nextInt()

    println(abc156a(n, r))
}

private fun abc156a(n: Int, r: Int): Int {
    var k = r
    if (n < 10) k += 100 * (10 - n)

    return k
}


Measured memory_bytes: 31136
// AOJ 0246: Bara-Bara Manju
// 2017.10.30 bal4u@uu

#include <stdio.h>
#include <string.h>

int f[10];
int ans, sum, tmp;

int pair[36][5][2] = {
{{1,2},{8,1}}, {{1,1},{2,1},{7,1}}, {{1,1},{3,1},{6,1}}, {{1,1},{4,1},{5,1}}, {{2,2},{6,1}},       {{2,1},{3,1},{5,1}}, {{2,1},{4,2}}, {{3,2},{4,1}}, 
{{1,3},{7,1}}, {{1,2},{2,1},{6,1}}, {{1,2},{3,1},{5,1}}, {{1,2},{4,2}},       {{1,1},{2,2},{5,1}}, {{1,1},{2,1}, {3,1},{4,1}}, {{1,1},{3,3}}, {{2,3},{4,1}}, {{2,2},{3,2}}, 
{{1,4},{6,1}}, {{1,3},{2,1},{5,1}}, {{1,3},{3,1},{4,1}}, {{1,2},{2,2},{4,1}}, {{1,2},{2,1},{3,2}}, {{1,1},{2,3},{3,1}}, {{2,5}}, 
{{1,5},{5,1}}, {{1,4},{2,1},{4,1}}, {{1,4},{3,2}},       {{1,3},{2,2},{3,1}}, {{1,2},{2,4}}, 
{{1,6},{4,1}}, {{1,5},{2,1},{3,1}}, {{1,4},{2,3}}, 
{{1,7},{3,1}}, {{1,6},{2,2}}, 
{{1,8},{2,1}}, 
{{1,10}}};

int take(int k)
{
	int i, a, b;
	for (i = 0; (a = pair[k][i][0]) > 0; i++) {
		b = pair[k][i][1];
		if (f[a] < b) return 0;
	}
	for (i = 0; (a = pair[k][i][0]) > 0; i++) f[a] -= pair[k][i][1];
	sum -= 10; tmp++;
	return 1;
}

void back(int k)
{
	int i, a;
	for (i = 0; (a = pair[k][i][0]) > 0; i++) f[a] += pair[k][i][1];
	sum += 10; tmp--;
}

void rec(int k)
{
	int i;

	for (i = k; ans < sum/10 + tmp && i < 36; i++) if (take(i)) rec(i), back(i);
	if (tmp > ans) ans = tmp;
}

int main()
{
	int n, i, k;

	while (scanf("%d", &n) && n > 0) {
		memset(f, 0, sizeof(f));
		while (n-- > 0) scanf("%d", &k), f[k]++;
		for (ans = 0, i = 9; i >= 6; i--) {
			k = f[i]; if (f[10-i] < k) k = f[10-i];
			ans += k, f[i] -= k, f[10-i] -= k;
		}
		ans += f[5]/2, f[5] &= 1;
		f[9] = 0;
#if 0
		if (f[8] > 0) {
			if (f[1] >= 2*f[8]) ans += f[8], f[1] -= 2*f[8];
			else if (f[1] & 1) ans += f[1]/2, f[1] = 1;
			else               ans += f[1]/2, f[1] = 0;
			f[8] = 0;
		}
		if (f[7] > 0) {
			while (f[7] > 0 && f[1] > 0 && f[2] > 0) ans++, f[7]--, f[1]--, f[2]--;
			while (f[7] > 0 && f[1] >= 3) ans++, f[7]--, f[1]-=3;
			f[7] = 0;
		}
		if (f[6] > 0) {
			while (f[6] > 0 && f[1] >  0 && f[3] > 0) ans++, f[6]--, f[1]--, f[3]--;
			while (f[6] > 0 && f[2] >= 2) ans++, f[6]--, f[2]-=2;
			while (f[6] > 0 && f[1] >= 2 && f[2] > 0) ans++, f[6]--, f[1]-=2, f[2]--;
			while (f[6] > 0 && f[1] >= 4) ans++, f[6]--, f[1]-=4;
			f[6] = 0;
		}
#endif
		for (sum = 0, i = 1; i <= 8; i++) sum += i*f[i];
		tmp = ans;
		rec(0);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1808
object Main extends App {
	val Array(a, b) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	val rank = Array(2,3,4,5,6,7,8,9,10,11,12,13,1)

	val a1 = rank.indexOf(a)
	val b1 = rank.indexOf(b)

	if(a1 > b1) println("Alice")
	else if(a1 == b1)  println("Draw")
	else println("Bob")
}

Measured memory_bytes: 27216
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)


int main() {
  int n,x,t; cin >> n >> x >> t;
  cout << (n/x + (n%x!=0)) * t << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <set>
#include <queue>
#include <string>
#include <vector>
#include <math.h>

using namespace std;

// change minimum aよりbの法が小さかったら、aの値をbの値に置き換える
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}

	return false;
}

// change maximum minimumの逆
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

// 一般的な流れ
/*
1.DP配列全体を「DPの種類に応じた初期値」で初期化
2.初期条件を入力
3.ループを回す
4.テーブルから解を得て出力
*/

int main() {
	int n;
	cin >> n;
	vector<int> dp(n+1);

	for (int i = 0; i <= n; i++) {
		dp[i] = 1000000;
	}

	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		chmin(dp[i + 1], dp[i] + 1);
		for (int j = 6; i + j <= n; j *= 6) {
			if (i + j <= n) {
				chmin(dp[i + j], dp[i] + 1);
			}
		}
		for (int j = 9; j + i <= n; j *= 9) {
			if (i + j <= n) {
				chmin(dp[i + j], dp[i] + 1);
			}
		}
	}

	cout << dp[n] << endl;
}

Measured memory_bytes: 640
//#pragma comment(linker,"/STACK:102400000,102400000")
//#include <initializer_list>
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define slla(n) scanf("%lld", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); repp(i,1,___T)

const int dx44[5] = { 0,-1,-1,1,1 };
const int dy44[5] = { 0,-1,1,-1,1 };

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int dx82[9] = { 0,-1,-1,1,1, 2,2,-2,-2 };
const int dy82[9] = { 0,2,-2,2,-2, 1,-1,1,-1 };
const int maxn = 2e6 + 50;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;

ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void extgcd(ll a,ll b,ll& d,ll& x,ll& y){ if(!b){ d=a; x=1; y=0;} else{ extgcd(b,a%b,d,y,x); y-=x*(a/b); }}
ll inverse(ll a,ll n){ ll d,x,y;extgcd(a,n,d,x,y);return d==1?(x+n)%n:-1;}

void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes");}// exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No");}// exit(0); }
void one() { puts("-1"); exit(0); }

int n;
int val[maxn];
ll presum[maxn],prexor[maxn];

ll sum(int le,int ri) {
	return presum[ri] - presum[le-1];
}

ll xo(int le,int ri) {
	return prexor[ri] ^ prexor[le-1];
}

void solve() {
	sa(n);
	repp(i,1,n) {
		int x;
		sa(x);
		presum[i] += x;
		presum[i] += presum[i-1];

		prexor[i] = prexor[i-1] ^ x;
	}
	ll ans = 0;
	repp(i,1,n) {
		int le = i;
		int ri = n;

		while(le<ri) {
			int mid = (le+ri+1)/2;
			if(sum(i,mid)>xo(i,mid)) {
				ri = mid-1;
			}
			else {
				le = mid;
			}
		}
		ans += ri - i + 1;
	}
	cout<<ans<<endl;
}

int main()
{

    solve();
    // system("pause");
    return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int x, y; cin >> x >> y;

    if(y & 1){
        cout << "No" << endl;
        return 0;
    }

    for(int i = 0; i <= x; i++){
        int w = x - i;
        if(i * 2 + w * 4 == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3652
n = int(input())
al = list(map(int, input().split()))

sal=sum(al)
res=10**9+1
temp=0
for i in range(0,n-1):
    temp += al[i]
    res = min(res,abs(sal/2-temp))
    if res <=0.5:
        break

print(int(res*2))

Measured memory_bytes: 23792
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

from collections import Counter
winners_nums = sorted([R, S, P])
winners = Counter({R:'r', S: 's', P: 'p'})

min_winner = winners.get(winners_nums[0])
mapping = {'r': 'p', 's': 'r', 'p': 's'}

ans = 0
done = []
for t in T:
    win = mapping.get(t)
    if len(done) >= K:
        if done[len(done) - K] == win:
            hands = set(['r', 's', 'p']) - set([win])
            if len(T) > len(done) + K:
                not_next = mapping.get(T[len(done) + K])
                hands -= set([not_next])
            done.append(hands.pop())
            continue
    if win =='r':
        ans += R
    elif win == 's':
        ans += S
    else:
        ans += P
    done.append(win)
print(ans)

Measured memory_bytes: 4468
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)














int main() {
    ll n, k;
    cin >> n >> k;
    ll sum = 0;
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
        sum += a[i];
    }
    set<ll> st;
    for(ll i = 1; i <= sqrt(sum); i++){
        if(sum % i == 0){
            st.insert(i);
            st.insert(sum / i);
        }
    }
    ll ans = 0;
    for(auto &x : st){
        vector<pair<ll, ll>> v(n);
        REP(i, n){
            v[i].first = a[i] - a[i] / x * x;
            v[i].second = (a[i] / x + 1) * x - a[i];
        }
        sort(v.begin(), v.end());
        vector<pair<ll, ll>> r(n + 1);
        REP(i, n){
            r[i + 1].first = r[i].first + v[i].first;
            r[i + 1].second = r[i].second + v[i].second;
        }
        /*
        REP(i, n + 1){
            cerr << r[i].first << " " << r[i].second << endl;
        }
        */
        REP(i, n + 1){
            if(r[i].first <= k && r[i].first == r[n].second - r[i].second){
                ans = max(ans, x);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long[] a = new long[N];
		long[] b = new long[N];
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextLong();
			if(a[i] >= 0) {
				b[i] = a[i];
			}
		}
		sc.close();
		long[] c = new long[N + 1];
		long[] d = new long[N + 1];
		for(int i = 0; i < N; i++) {
			c[i + 1] = c[i] + a[i];
			d[i + 1] = d[i] + b[i];
		}
		long max = Long.MIN_VALUE;
		for(int i = 0; i <= N - K; i++) {
			if(i == 0) {
				max = d[N] - d[K];
				if(c[K] > 0) {
					max += c[K];
				}
			}else {
				long t = d[i] + d[N] - d[K + i];
				if(c[K + i] - c[i] > 0) {
					t += c[K + i] - c[i];
				}
				max = Math.max(max, t);
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 62788
#include <bits/stdc++.h>
#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)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
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;
}
///////////////////////////////////////////////

int main(){
    int a[5] = {};
    REP(i,3){
        int A,B;
        cin >> A >> B;
        a[A]++; a[B]++;
    }

    bool ans = true;
    FORq(i,1,4){
        if (a[i] == 3) ans = false;
    }

    if (ans) printf("YES\n");
    else printf("NO\n");

}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

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

	int64 n;
	string s = "";
	cin >> n;
	vector<int64> a(n);
	REP(i, n) cin >> a[i];
	stack<int64> st;
	int64 maxi = 0;
	REP(i, n) {
		while (maxi < a[i]) {
			maxi++;
			st.push(maxi);
			s += "(";
		}
		if (st.top() != a[i]) {
			cout << ":(" << endl;
			return 0;
		}
		s += ")";
		st.pop();
	}
	cout << s << endl;
}



Measured memory_bytes: 4244
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
#include<functional>
using namespace std;

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int H, W; cin >> H >> W;
	char C[101][101];
	for (int h = 1; h <= H; h++) {
		for (int w = 1; w <= W; w++) {
			cin >> C[h][w];
		}
	}
	for (int h = 1; h <= H; h++) {
		for (int i = 0; i < 2; i++) {
			for (int w = 1; w <= W; w++) {
				cout << C[h][w];
			}
			cout << endl;
		}
	}
}

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

#define ms(a,v)        memset(a,v,sizeof a)
#define lll            long long
#define FOR(i,a,b)     for(int i=a;i<=b;i++)
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Read           freopen("READ.txt", "r", stdin)
#define Write          freopen("OUTPUT.txt", "w", stdout)
#define INF            99999
#define Co(x)          cout<<x<<endl;
#define Cos(x)         cout<<x<<" ";

typedef vector<long long>vii;
typedef pair<long long,long long>Pair;
typedef map<long long,long long>Map;

int dr[]={1,0,-1, 0 };
int dc[]={0,1, 0,-1 };

//int dr[]={1,1,0,-1,-1,-1, 0, 1};
//int dc[]={0,1,1, 1, 0,-1,-1,-1};

/*while(1) {
    if(!getline(cin,s)||s.empty()) break;
}*/

const int RT = 10000000;
vector<int>prime;
bitset<10000003> status;

void sieve()
{
    int rt = sqrt(RT);
    //for(int i = 4; i <= rt; i+=2) status[i]=true;
    for(int i = 3; i <= rt; i+=2)
        if(!status[i])
            for(int j = i*i; j < RT; j+=(i<<1))
                status[j] = true;
    prime.push_back(2);
    for(int i = 3; i <= RT; i+=2)
        if(!status[i])
            prime.push_back(i);
}

void Binary_Con(int n)
{
    int binaryNum[70];
    int i = 0;
    while (n > 0) {
        binaryNum[i] = n % 2;
        n = n / 2;
        i++;
    }
    // printing binary array in reverse order
    for (int j = i - 1; j >= 0; j--)
        cout << binaryNum[j];
}


void solve()
{
    string s;
    cin>>s;
    if(s[s.size()-1]=='s') cout<<s<<"es"<<endl;
    else cout<<s<<'s'<<endl;
}

void kick_ass()
{
    fast
    #ifndef ONLINE_JUDGE
    //Read;
    //Write;
    #endif
    solve();
}

int main()
{
   kick_ass();
}


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

int main(){
    double a,b,x;cin>>a>>b>>x;
    double N=a*a*b;
    if(x*2==N)cout<<setprecision(10)<<atan(b/a)*180/M_PI<<endl;
    else if(x*2>N){
        x=N-x;
        cout<<setprecision(10)<<atan(x*2/(a*a*a))*180/M_PI<<endl;
    }
    else{
        cout<<setprecision(10)<<atan(a*b*b/(2*x))*180/M_PI<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#pragma GCC optimize(3)
#define debug(x) cout<<"#"<<x<<endl
#define pb push_back
#define fi first
#define se second
#define rep(i,l,h) for(int i=(l);i<=(h);++i)
#define drep(i,h,l) for(int i=(h);i>=(l);--i)
#define mem(x,y) memset(x,y,sizeof(x))
typedef pair<int,int>pii;

const int MAXN=2e5+5;
int n,A[MAXN],B[MAXN],a[MAXN],b[MAXN];
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);
  cin>>n;
  int ans=0;
  rep(i,1,n)cin>>A[i];
  rep(i,1,n)cin>>B[i];
  rep(k,0,28){
    int T=(1<<k);
    int MOD=T*2;
    rep(i,1,n) a[i]=A[i]%MOD;
    rep(i,1,n) b[i]=B[i]%MOD;
    sort(b+1,b+1+n);
    int cnt=0;
    rep(i,1,n){
      cnt+=upper_bound(b+1,b+1+n,T*2-a[i]-1)-lower_bound(b+1,b+1+n,T-a[i]);
      cnt+=upper_bound(b+1,b+1+n,T*4-a[i]-1)-lower_bound(b+1,b+1+n,3*T-a[i]);
    }//上下界好烦
    if(cnt%2==1)ans+=T;
  }
  cout<<ans<<endl;
  return 0;
}//Arc092 T2


Measured memory_bytes: 6528
MOD = 998244353

n,s = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
dp = Array.new(7000, 0)
dp[0] = 1

a.each do |a|
  s.downto(0) do |i|
    dp[a+i] += dp[i]
    dp[i] *= 2
    dp[i] %= MOD
  end
end

puts dp[s] % MOD


Measured memory_bytes: 14400
import math
n = int(input())
x = list(map(int, input().split()))
p = 0
ans = 0

s = sum(x)/n
a = math.floor(s)
b = math.ceil(s)

if (a-s)**2 > (b-s)**2:
    p = b
else:
    p = a

for i in range(n):
    ans += (x[i]-p)**2

print(ans)


Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <list>
#include <stack>
#include <queue>
using namespace std;

typedef list<int> L;
typedef pair <int,int> P;
typedef vector<int> V;
typedef queue<int> Q;
typedef stack<int> S;
typedef map<string,int> M;

int change (string s) {
    int ten = 1;
    int res = atoi(&s[0]);
    res = (res / 2) + 1;

    return res;
}

int dfs (string str) {
    int corsor = 1;
    int i = 0;
    V v;
    while (i < str.size()) {
        corsor = 1;
        i++;
        string tmp;
        while (corsor) {
            if (str[i] == '[') corsor++;
            else if (str[i] == ']') corsor--;
            if (corsor)
                tmp += str[i];
            i++;
        }
        if (tmp[0] != '[') {
            v.push_back(change(tmp));
        }
        else
            v.push_back(dfs(tmp));
    }
    int res = 0;
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size() / 2 + 1; i++) {
        res += v[i];
    }

    return res;
}

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

    for (int i = 0; i < M; i++) {
        string str;
        cin >> str;
        cout << dfs(str) << endl;
    }

    return 0;
}

Measured memory_bytes: 1324
#include <bits/stdc++.h>
using namespace std;
template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
	~debug(){cerr<<endl;}
	template<class T> debug& operator<<(T x){cerr<<boolalpha<<x; return *this;}
	template<class B, class C> debug& operator<<(pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
	template<class T> debug& operator<<(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
	template<class T> debug& operator<<(vector<T> x){ return *this<<range(x.begin(),x.end());}
#else
	template<class T> debug& operator <<(const T&){return *this;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;


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

    string s;
    cin >> s;
    cout << (s == "ABC" ? "ARC" : "ABC");
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = 0;
vl flag, color, D; vll path;
//***********//
int main() {
	cin >> N;
	vl A(N);
	for (i = 0; i < N; i++) {
		cin >> A[i];
		ans += A[i];
	}
	cout << ans - N;
}

Measured memory_bytes: 256
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var s = Console.ReadLine();
		var t = Console.ReadLine();
		var f = true;
		for (var i = 0; i < 3; i++) f &= s[i] == t[2 - i];
		Console.WriteLine(f ? "YES" : "NO");
	}
}


Measured memory_bytes: 11092
def readInt():
    return int(input())
def readList():
    return list(map(int,input().split()))
def readMap():
	return map(int,input().split())
def readStr():
    return input()
inf=float('inf')
mod = 10**9+7
import math
from itertools import permutations
class DSU:
    def __init__(self,n):
        self.par=list(range(n))
        self.sz=[1]*(n)
    def find(self,x):
        if x!=self.par[x]:
            self.par[x]=self.find(self.par[x])
        return self.par[x]
    def union(self,x,y):
        x,y=self.find(x),self.find(y)
        if x!=y:
            if self.sz[y]>self.sz[x]:
                x,y=y,x
            self.par[y]=x
            self.sz[x]+=self.sz[y]
            self.sz[y]=self.sz[x]
            return True
        return False
    def parent(self,x):
        return self.par[x]

def solve(N,A):
    dsu=DSU(N)
    for a,b in A:
        dsu.union(a-1,b-1)
    cnt=0
    for i in range(N):
        if dsu.parent(i)==i:
            cnt+=1
    return cnt-1



N,M=readMap()
A=[]
for _ in range(M):
    a,b=readMap()
    A.append((a,b))
print(solve(N,A))

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

int main() {
  string S, T;
  int A, B;
  string U;
  cin >> S >> T >> A >> B >> U;

  if (S == U) {
    A -= 1;
  } else if (T == U) {
    B -= 1;
  }

  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

A,B,C,D=(int(x) for x in input().split())

t_count = 0
a_count = 0

while A > 0:
    A -= D
    t_count += 1

while C > 0:
    C -= B
    a_count += 1

if t_count >= a_count:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9176