akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

using Gragh = vector<vector<int>>;

int n, q;
vector<int> ans;

void dfs(const Gragh &G, int v, int p = -1) {
    for(auto nv : G[v]) {
        if(nv == p) continue;
        ans[nv] += ans[v];
        dfs(G, nv, v);
    }
}

int main() {
    cin >> n >> q;
    Gragh G(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    ans.resize(n);
    rep(i, q) {
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(G, 0);
    for(auto x : ans) cout << x << endl;

    return 0;
}

Measured memory_bytes: 26624
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <cmath>
#include <string.h>
#include <queue>
#include <functional>

#define NMAX 200001
#define MOD 1000000007
#define INF 2000000000
#define PI 3.1415926535
#define EPS 1.e10-6

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) > 0 ? (a) : (-a))

typedef unsigned long long ull;
typedef long long ll;

using namespace std;

ull a, b, k;

int main()
{
	cin >> a >> b >> k;

	ull ownCookies = MIN(a, k);
	a -= ownCookies;
	k -= ownCookies;
	if (b > k)
		b -= k;
	else
		b = 0;

	cout << a << ' ' << b << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <complex>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef complex<double> P;

int bitcount(int a) {
    int c = 0;
    while (a) c++, a&=a-1;
    return c;
}

inline double cross(const P& a, const P& b) { return imag(conj(a)*b); }
inline double dot(const P& a, const P& b) { return real(conj(a)*b); }

inline int ccw(const P& a, P b, P c) {
    b -= a, c -= a;
    if (cross(b, c) > 0) return 1;
    if (cross(b, c) < 0) return -1;
    if (dot(b, c) < 0) return 2;
    if (norm(b) < norm(c)) return -2;
    return 0;
}

inline bool intersectSS(const P& s0, const P& s1, const P& t0, const P& t1) {
    return ccw(s0, s1, t0) * ccw(s0, s1, t1) <= 0
        && ccw(t0, t1, s0) * ccw(t0, t1, s1) <= 0;
}

int n, g[32];
vector<P> ps[32];

int main() {
    for (;;) {
        scanf("%d", &n);
        if (n == 0) return 0;
        rep (i, n) {
            ps[i].clear();
            int m;
            scanf("%d", &m);
            rep (_, m) {
                double x, y;
                scanf("%lf%lf", &x, &y);
                ps[i].push_back(P(x, y));
            }
        }
        memset(g, 0, sizeof(g));
        rep (i, n) g[i] |= 1<<i;
        rep (i, n) rep (j, ps[i].size()-1) {
            rep (x, i) rep (y, ps[x].size()-1) {
                if (intersectSS(ps[i][j], ps[i][j+1], ps[x][y], ps[x][y+1])) {
                    g[i] |= 1<<x, g[x] |= 1<<i;
                }
            }
        }
        const int nn = 1<<n;
        int ans = 0;
        rep (b, nn) {
            bool f = true;
            rep (i, n) if ((b&(1<<i)) && (g[i]&b)!=b) {
                f = false;
                break;
            }
            if (f) ans = max(ans, bitcount(b));
        }
        printf("%d\n", ans);
    }
}

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

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

    int D[2][N];

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

    int count = 0;

    for (int i = 0; i < N - 2; i++)
    {
        if (D[0][i] == D[1][i])
        {
            if (D[0][i + 1] == D[1][i + 1])
            {
                if (D[0][i + 2] == D[1][i + 2])
                {
                    count++;
                }
            }
        }
    }

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

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(void) {
    int64_t N, D, A;
    cin >> N >> D >> A;
    vector< pair<int64_t,int64_t> > monster(N);
    for(int i=0; i<N; i++) {
        cin >> monster[i].first >> monster[i].second;
    }

    sort(monster.begin(), monster.end());

    int64_t ans = 0;
    int64_t damage = 0;
    queue< pair<int64_t,int64_t> > q;
    for(int i=0; i<N; i++) {
        while(!q.empty() && q.front().first < monster[i].first) {
            damage -= q.front().second;
            q.pop();
        }
        monster[i].second -= damage;
        if(monster[i].second <= 0) continue;
        int64_t cnt = (monster[i].second + A-1) / A;
        ans += cnt;
        damage += cnt*A;
        q.emplace(monster[i].first + 2*D, cnt*A);
    }

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


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
#define MAX 1000001
#define mod 1000000007
#define pie 3.14159265358979323846
void solve()
{
	ll int n,i,s=0;
	cin>>n;
	ll int a[n];
	map<ll int,ll int> mp;
	for(i=0;i<n;i++){
		cin>>a[i];
		s+=a[i];
		mp[a[i]]++;
	}
	ll int q;
	cin>>q;
	while(q--){
		ll int x,y;
		cin>>x>>y;
		s-=mp[x]*x;
		s+=mp[x]*y;
		mp[y]+=mp[x];
		mp[x]=0;
		cout<<s<<"\n";
	}
}
int main()
{ 
    cool;
    int t;
    //cin>>t;
    t=1;
    while(t--){
    	solve();
	}
    return 0;
}


Measured memory_bytes: 10312
N = int(input())
nums = {}

for a in map(int, input().split()):
    if a not in nums:
        nums[a] = 0
    nums[a] += 1

q = int(input())

csum = sum([k*v for k, v in nums.items()])

for i in range(q):
    b, c = list(map(int, input().split()))
    if b not in nums:
        print(csum)
        continue
    if c not in nums:
        nums[c] = 0
    nums[c] += nums[b]
    csum = csum + nums[b] * c - nums[b] * b
    nums[b] = 0
    print(csum)

Measured memory_bytes: 21656
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nk = readln.split.to!(long[]);
    auto N = nk[0];
    auto K = nk[1];
    auto AS = readln.split.to!(long[]);

    int[60] bs;
    foreach (a; AS) {
        foreach (i; 0..60) if (a & (1L<<i)) bs[60-i-1] += 1;
    }
    long X;
    bool u;
    foreach (i; 0..60) {
        X <<= 1;
        auto j = 60-i-1;
        if (bs[i] <= N/2) {
            if ((K & (1L<<j)) || u) X += 1;
        } else {
            if (K & (1L<<j)) u = true;
        }
    }
    long r;
    foreach (a; AS) r += a^X;
    writeln(r);
}

Measured memory_bytes: 4732
N=int(input())
cnt=0
L=list(map(int,input().split()))
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      if (L[i]!=L[j] and L[j]!=L[k] and L[i]!=L[k]) and ((L[i]+L[j])>L[k] and (L[j]+L[k])>L[i] and (L[i]+L[k])>L[j]):
        cnt+=1
print(cnt)

Measured memory_bytes: 9104
#include <iostream>

int main()
{
    std::size_t n, x;
    std::cin >> n >> x;
    x = std::min(x, n - x);
    std::size_t a = x, b = n - x; // Short, Long
    std::size_t sum = 0;
    sum += a + b;
    while(b % a)
    {
        sum += b / a * a * 2;
        b %= a;
        std::swap(a, b);
    }
    sum += (b / a - 1) * a * 2 + a;
    std::cout << sum << std::endl;
    return 0;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 #-}
import Control.Monad (replicateM)

reachable :: [(Int,Int,Int)] -> Bool
reachable ps = and $ zipWith reach ps (tail ps)

reach :: (Int, Int, Int) -> (Int, Int, Int) -> Bool
reach (t0,x0,y0) (t1,x1,y1) = accessible && sameParity
  where
    tick = t1 - t0
    shortest = abs (x1 - x0) + abs (y1 - y0)
    accessible = shortest <= tick
    sameParity = even (tick - shortest)

readTriple :: IO (Int, Int, Int)
readTriple = do
  [t,x,y] <- map read . words <$> getLine
  return (t,x,y)

main :: IO ()
main = do
  n <- readLn
  ps <- replicateM n readTriple
  putStrLn $ if reachable ((0,0,0):ps) then "Yes" else "No"


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll r,g,b;
	cin >>r>>g>>b;
	int k;
	cin >>k;
	while(g <= r && k>0)
	{
		g = 2*g;
		k--;
	}
	while(b <= g && k >0)
	{
		b = 2*b;
		k--;
	}
	if(g > r && b > g)
	{
		cout <<"Yes\n";
	}
	else
	{
		cout <<"No\n";
	}
	
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
signed main(){
    string s;cin >> s;
    int n = s.size();
    char now = s[0];
    int cnt = 0;
    rep(i,n-1){
        if(s[i+1] != now){
            now = s[i+1];
            cnt++;
        }

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

Measured memory_bytes: 512
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int fh,oh,ft,result,count;
		count = 0;
		fh = sc.nextInt();
		oh = sc.nextInt();
		ft = sc.nextInt();
		result = sc.nextInt();
		for(int i=0;i<=fh;i++){
			for(int j=0;j<=oh;j++){
				for(int l=0;l<=ft;l++){
					if(i*500 + j*100 + l*50 == result){
						count++;
					}
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21972
N, K = map(int, input().split())
S = input()
nums = []
now = 1
cnt = 0
for i in range(N):
    if S[i] == str(now):
        cnt += 1
    else:
        nums.append(cnt)
        now = 1 - now
        cnt = 1
if cnt != 0:
    nums.append(cnt)
if len(nums) % 2 == 0:
    nums.append(0)

csum = [0] * (len(nums) + 1)
for i in range(len(nums)):
    csum[i + 1] = csum[i] + nums[i]

add = 2 * K + 1
ans = 0
tmp = 0
for i in range(0, len(nums), 2):
    left = i
    right = min(i + add, len(nums))
    tmp = csum[right] - csum[left]
    ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 7884
import java.util.Scanner;

public class Main {

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

		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int tmp;

		tmp = A+B;
		if (tmp < A-B) {
			tmp = A-B;
		}
		if (tmp < A*B) {
			tmp = A*B;
		}

		System.out.println(tmp);

	}

}


Measured memory_bytes: 23636
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(x, y):
    return (x * y) // gcd(x, y)



M, N = map(int, input().split())
S = input()
T = input()

MA = [S[0]]
NA = [T[0]]

L = lcm(M, N)

m = L/M
n = L/N

for i in range(M):
    if i % n == 0:
        MA.append(S[i])

for i in range(N):
    if i % m == 0:
        NA.append(T[i])

if MA == NA:
    print(L)
else:
    print("-1")






Measured memory_bytes: 3828
// ABC153_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <cstring>  // std::memset
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
#define rep(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define rep1(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define repr(i, n) for (ll i=n-1; i >= 0; i++)  // n-1 ~ 0
#define all(vec) (vec).begin(), (vec).end()
#define sum(vec) accumulate(all(vec), 0LL)  // 0 は初期値
#define min_vec(vec) min_element(all(vec))  // iterator: * を先頭につける
#define max_vec(vec) max_element(all(vec))  // iterator: * を先頭につける
#define idx(vec, element_iter) distance((vec).begin(), element_iter)
const ll INF = 1LL<<60;  // 10^18（const int inf = 1<<29;）
const double PI = acos(-1);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    // input(sunippets: inpv, inpn, inps)
    ll H, N;
    cin >> H >> N;
    vector<ll> vec(N);
    rep(i, N) cin >> vec[i];
    
    // calculation
    sort(vec.begin(), vec.end(), greater<>());  // ll big -> small
    ll sm = sum(vec);
    
    
    if (sm >= H) cout << "Yes" << "\n";
    else cout << "No" << "\n";
    
    return 0;
}



Measured memory_bytes: 1024
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let cols = lines.shift().split(/\s/).map((v) => v - 0);
    let H = cols[0], W = cols[1];
    let A = [];
    for (let n = 0; n < H; n++) {
        let cols = lines.shift().split(/\s/).map((v) => v - 0);
        cols.forEach((v) => A.push(v));
    }
    const yx = (v) => `${Math.floor(v / W) + 1} ${(v % W) + 1}`;
    const wh = W * H;
    const wh0 = W * (H - 1);
    let N = 0;
    let op = "";
    for (let n = 0; n < wh; n++) {
        if (A[n] % 2) {
            let a = -1;
            if (n < wh0) {
                a = n + W;
            } else if (n < wh - 1) {
                a = n + 1;
            }
            if (a > 0) {
                A[n] -= 1;
                A[a] += 1;
                op += `\n${yx(n)} ${yx(a)}`;
                N += 1;
            }
        };
    }
    console.log(N + op);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 59136
import java.util.*;
public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] moji = sc.next().toCharArray();
        boolean flag = true;
        Arrays.sort(moji);
        int cnt = 0;
        for(int i = 0;i<moji.length-1;i++){
            if(moji[i]==moji[i+1]){
                cnt++;
            }else{
                if(cnt%2!=1){
                    flag = false;
                    break;
                }
                cnt=0;
            }
        }

        if(flag&&moji.length!=1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }




    }
}






Measured memory_bytes: 22612
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <numeric>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

#define bs(n) (1ull<<(ull)(n))
#define rep(i, n) for(ll (i) = 0;(i) < (n);(i)++)
#define rrep(i, n) for(ll (i) = 1;(i) <= (n);(i)++)

int main() {
    ll kk, s = 0;
    cin >> kk;
    rrep(i, kk)rrep(j, kk)rrep(k, kk)s += gcd(gcd(i, j), k);
    cout << s << endl;
}


Measured memory_bytes: 3624
H , W = map(int, input().split())
tile = [[x for x in  input()] for _ in range(H)]
#print(tile)
checktile = [[0] * H] * W
#print(checktile)
flg = True
for i in range(H):
    for j in range(W):
        tempflg = False
        if tile[i][j] == "#":
                #右をチェック、
            if j < W -1:
                if tile[i][j+1] == "#":
                    tempflg = True
                #下をチェック
            if i < H -1:
                if tile[i+1][j] == "#":
                    tempflg = True
            #上をチェック
            if i > 0:
                if tile[i-1][j] == "#":
                    tempflg = True
            #左をチェック
            if j > 0:
                if tile[i][j-1] == "#":
                    tempflg = True
            if tempflg == False:
                #print("i:j:",i,j)
                flg = False
                
print("Yes" if flg else "No")

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}

map<int,int> mp1,mp2;
vector<int> ns1,ns2;

bool func1(int a,int b){
  return mp1[a]>mp1[b];
}
bool func2(int a,int b){
  return mp2[a]>mp2[b];
}

int main(int argc,char* argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG=1;}
  dprint("start");

  int N; cin>>N;
  int v[N];
  
  REP(i,N){
    cin>> v[i];
    if(i%2==0){
      ++mp1[ v[i] ];
      if(mp1[ v[i] ]==1){
        ns1.push_back(v[i]);
      }
    }else{
      ++mp2[ v[i] ];
      if(mp2[ v[i] ]==1){
        ns2.push_back(v[i]);
      }
    }
  }
  sort(ALL(ns1),func1);
  sort(ALL(ns2),func2);

  int ans = 0;
  if(ns1[0]!=ns2[0]){
    ans =  N - mp1[ ns1[0]  ] - mp2[ ns2[0] ];
  }else{
    ans = min( N - mp1[ ns1[0]  ], N - mp2[ ns2[0] ] );
    if(ns1.size()>1){
      chmin(ans,  N - mp1[ ns1[1] ] - mp2[ ns2[0] ]);
    }
    if(ns2.size()>1){
      chmin(ans,  N - mp1[ ns1[0] ] - mp2[ ns2[1] ]);
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 8632
#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 PB push_back
#define MP make_pair
#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()
#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)
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 = 1e9+7;

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 N;
	cin >> N;
	int ans = 0;
	FORq(i,1,N){
		int keta = 0;
		int n = i;
		while(n != 0){
			keta++;
			n = n / 10;
		}
		if (keta % 2 == 1) ans++;
	}

	cout << ans << "\n";
}


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

using namespace std;
 map<string,int> mp;
int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        char str[10];
        cin>>str;
        mp[str]++;

    }
    printf("AC x %d\n",mp["AC"]);
    printf("WA x %d\n",mp["WA"]);
    printf("TLE x %d\n",mp["TLE"]);
   printf("RE x %d\n",mp["RE"]);
    //printf("AC x %d\n",mp["AC"]);
    return 0;
}


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

const int maxn=100005;

inline int read(){
	register int x=0,w=1,ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')w=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-48;
	return w*x;
}

int n,s,x[maxn];
long long p[maxn];

long long calc(int l,int r,int lst){
	if(s<x[l])return x[r]-s;
	if(x[r]<s)return s-x[l];
	if(p[l]>=p[r]){
		p[l]+=p[r];
		return calc(l,r-1,l)+(lst==r)*(x[r]-x[l]);
	}
	else{
		p[r]+=p[l];
		return calc(l+1,r,r)+(lst==l)*(x[r]-x[l]);
	}
}

int main(){
	n=read(),s=read();
	for(int i=1;i<=n;i++)
		x[i]=read(),p[i]=read();
	cout<<calc(1,n,p[1]<p[n]?1:n)<<'\n';
	return 0;
}

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

int main()
{
    int N, A;
    cin >> N >> A;
    int black = N * N - A;
    cout << black << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;

vector<vector<int> > g, gr;
vector<int> used;
vector<int> d;

void dfs(int pos, int pr) {
    //cerr << pos << " " << pr << endl;
    used[pos] = 1;
    int c = 0;
    for (int i = 0; i < g[pos].size(); ++i) {
        int to = g[pos][i];
        if (used[to]) {
            if (to == pr)
                continue;
            if (pos < to) {
                ++c;
                cout << pos + 1 << " " << to + 1 << "\n";
            }
            continue;
        }
        gr[pos].push_back(to);
        gr[to].push_back(pos);
        dfs(to, pos);
    }
    d[pos] = c & 1;
}

int dfs2(int pos, int pr) {
    int c = d[pos];
    for (int i = 0; i < gr[pos].size(); ++i) {
        int to = gr[pos][i];
        if (to == pr)
            continue;
        c += dfs2(to, pos);
    }
    if (pr == -1) {
        return 0;
    }
    if (c & 1) {
        cout << pos + 1 << " " << pr + 1 << "\n";
    }
    else {
        cout << pr + 1 << " " << pos + 1 << "\n";
    }
    c = (c + 1) & 1;
    return c;

}

void solve() {
    int n, m;
    cin >> n >> m;
    g.resize(n);
    int a, b;
    for (int i = 0; i < m; ++i) {
        cin >> a >> b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    if (m & 1) {
        cout << -1 << endl;
        return;
    }
    used.assign(n, 0);
    gr.resize(n);
    d.assign(n, 0);
    dfs(0, -1);
    dfs2(0, -1);
}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 20992
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
using ll = long long; using ld = long double; const char nl = '\n';
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */

#include <bits/extc++.h>
namespace pbds =  __gnu_pbds;
template <typename key, typename val=pbds::null_type, typename comp=less<key>>
using ostree=pbds::tree<key,val,comp,pbds::rb_tree_tag,pbds::tree_order_statistics_node_update>;
using vi = vector< int >; using vll = vector< ll >;
#define all(x) std::begin(x), std::end(x)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&);
string to_string(string const&s){return '"'+s+'"';}
string to_string(char const &c) {return to_string(string(1,c));}
string to_string(char const *c) {return to_string(string(c));}
string to_string(bool const &b) {return (b ? "1" : "0");}
template<typename... Args> string to_string(pair<Args...> const&p)
{return "("+to_string(p.first)+", "+to_string(p.second)+")";}
template <typename...Args, template<typename...> typename T> string to_string(T<Args...> const&S)
{string s = "{"; for(auto const& e: S)s+=" "+to_string(e);s+=" }"; return s;}
template<typename Tail> void debug_out(Tail t) {cerr<<" "<<to_string(t)<<" ]"<<endl;}
template<typename Head, typename... Tail> void debug_out(Head h, Tail... t)
{cerr << " " << to_string(h) << ","; debug_out(t...);}
#define pr(...) cerr<<"["<<(#__VA_ARGS__)<<"] : [", debug_out(__VA_ARGS__)
template <typename T> void dbr(T lb, T ub)
{cerr<<'{';for(auto it=lb; it!=ub; it++)cerr<<' '<<to_string(*it); cerr<<" }"<<endl;}
template<typename T, typename Comp=less<T>> bool smin(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(v, mem) ? mem = v, true : false;}
template<typename T, typename Comp=less<T>> bool smax(T &mem, T const&v, Comp const&cmp=Comp())
{return cmp(mem, v) ? mem = v, true : false;}
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */


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

  int n;
  string s; cin >> n >> s;
  ll cc[256];
  ll const mod = 7+(ll)1e9;
  fill(cc, cc+256, 0);
  for(char c: s) cc[(int)c]++;

  ll ans = 1;
  for(char c='a'; c<='z'; c++) ans = (ans * (1+cc[(int)c])) % mod;
  ans = (ans + mod - 1) % mod;
  cout << ans << nl;

}
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */



Measured memory_bytes: 640
#include <iostream>
#include <cstdio>

using namespace std;
const int MAXN = 2e5 + 5;

int n, sum, a[MAXN];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) 
		scanf("%d", a + i), sum ^= a[i];
	for (int i = 1; i <= n; i++) 
		printf("%d%c", a[i] ^ sum, " \n"[i == n]);
	return 0;
} 

Measured memory_bytes: 3920
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        long mod = 1000000007L;
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        char[] s1 = sc.next().toCharArray();
        char[] s2 = sc.next().toCharArray();
        long ans = 1;
        long prev = 0;
        for(int i = 0; i < n; i++){
            if(s1[i] == s2[i]){
                ans *= (3-prev);
                prev = 1;
            }else{
                if(prev != 2){
                    ans *= (3-prev)*(2-prev);
                }else{
                    ans *= 3;
                }
                prev = 2;
                i++;
            }
            ans %= mod;
        }
        System.out.println(ans);
    }
}


class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 24532
#include <stdio.h>

int main()
{
  int a,b;
  scanf("%d %d", &a, &b);
 
  if(a<b)
    printf("a < b\n");
  else if(a>b)
    printf("a > b\n");
  else
    printf("a == b\n");
 
   
  return 0;
}


Measured memory_bytes: 2084
#include <iostream>
using namespace std;
 
int main()
{
    while(true){
        int h, w;
        cin >> h >> w;
 
        if(h==0 && w==0)
            break;
 
        int d = h*h+w*w;
 
        int H = 150;
        int W = 150;
        int D = 150*150+150*150;
 
        for(int y=1; y<=150; y++){
            for(int x=y+1; x<=150; x++){
                int z = y*y+x*x;
 
                if(z<=d){
                    continue;
                }
                else{
                    if(z<D){
                        H = y;
                        W = x;
                        D = z;
                    }
                    break;
                }
            }
        }
 
        for(int y=h+1; y<150; y++){
            bool flg = false;
 
            for(int x=y+1; x<=150; x++){
                int z = y*y+x*x;
 
                if(z==d){
                    H = y;
                    W = x;
                    D = z;
 
                    flg = true;
                }
 
                if(z>=d)
                    break;
            }
 
            if(flg)
                break;
        }
 
        cout << H << ' ' << W << endl;
    }
 
    return 0;
}


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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);                      \
	cin.exceptions(cin.failbit);
#define int long long int //Comment when Unnecessary
#define ll long long
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define pii pair<int, int>
#define vi vector<int>
#define F first
#define S second
#define endl "\n" // Remove on Interactive

const int N = 300009;
const int mod = 1000000007;

int n;
string s;

void pre()
{
}

int32_t main()
{
	IOS;
	pre();
	cin>>n;
	cout<<((n+1)/2)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k;
    cin >>n>>k;
    vector<long long>a(n);
    for (int i=0;i<n;i++){
        cin >> a[i];
    }
    
    for(int i=k;i<n;i++){
        if(a[i-k]<a[i])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 4840
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#define ll long long

using namespace std;

int gcd(int x, int y) {
	if (x == y) return x;
	int a = max(x, y);
	int b = min(x, y);
	if (y % (x%y) == 0) {
		return x % y;
	}
	else {
		return gcd(y, x%y);
	}
}

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

	cout << gcd(x, y) << endl;



}




Measured memory_bytes: 3116
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
const int MOD = 1000000007;

#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define mod_mul(x, y) x*y%MOD
#define mod_add(x, y) (x+y)%MOD
#define mod_sub(x, y) (x-y)%MOD
#define INF_INT 2147483647

typedef std::vector<std::vector<int>> Matrix;

long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}

long lcm( long m, long n ){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}


long nCr(long n, long r){
    if(n==r || r==0){
        return 1;
    } else {
        return mod_add(nCr(n-1,r),nCr(n-1,r-1));
    }
}

long long cur = 0;
long long cnt = 0;
bool first = true;
long long ans = 1;
long long N,P;

void decompositPrime(long long n){
    // 割る数の初期値
    long long a = 2;
    while (n >= a * a) {
        if (n % a == 0) {
            if(first){
                cur = a;
                first = false;
            }

            if(a == cur){
                cnt++;
            } else {
                cur = a;
                cnt = 1;
            }
            if (cnt == N){
                ans = ans * a;
                cnt = 0;
            }

            // printf("%d * ", a);
            n /= a;
        } else {
            a++;
        }
    }
    // 最後に残った n は素因数


    //printf("%d\n", n);
    if(n == cur){
        cnt++;
    } else {
        cur = n;
        cnt = 1;
    }
    if (cnt == N){
        ans = ans * n;
        cnt = 0;
    }
}


int main(){
    cin >> N >> P;
    decompositPrime(P);
    cout << ans << endl;


    return 0;

}


Measured memory_bytes: 256
fun main(){
    val n = readLine()!!.split(" ")[0].toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }
    var total = 0L
    for (i in 0 until n){
        total += a[i]
    }
    var ans = 0L
    for (i in 0 until n){
        total -= a[i]
        ans += ((total % 1000000007) * a[i]) % 1000000007
    }
    println(ans % 1000000007)
}

Measured memory_bytes: 64988
/*
* @Author: Kabid
* @Date:   2020-04-26 18:01:07
* @Last Modified by:   Kabid
* @Last Modified time: 2020-05-10 18:17:38
*/
#include<bits/stdc++.h>

#define ll long long
#define  in(x) scanf("%d",&x);
#define out(x) printf("%d",x);
#define  ins(x)  scanf("%s",x);
#define outs(x) printf("%s",x);
#define lin puts("");
#define _ putchar(' ');
using namespace std;

int t;       //test cases
ll  n=0, k,m; //variables
long long w,x;
ll  a, b, d;
ll c;
string s,p;
set<ll>st;
ll i,j;
int main() {
	cin>>s;
	cin>>p;
	p.pop_back();
	if(s==p){
		puts("Yes");
	}
	else{
		puts("No");
	}
	//cout<<s<<endl<<p;
	
	

	return 0;
	}
	



Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <queue>
#include <cmath>
#include <iomanip>
// #include <fstream>
 
int main()
{
    long int a, b, c, k;
    std::cin >> a >> b >> c >> k;
    
    if(k%2==0)
    {
        std::cout << a-b << std::endl;
    }
    else
    {
        std::cout << b-a << std::endl;
    }
    return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int x; cin>>x;
	int ans=1;
	for(int i=2;i*i<=x;++i){
		for(int j=i*i;j<=x;j*=i){
			ans=max(ans,j);
		}
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair



int main() {
    int X; cin >> X;
    if (X >= 30) PRINT("Yes");
    else PRINT("No");
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
 
using namespace std;
 
int n, ta, tb;
vector< int > x[100005];
 
int dfs(int a, int b) {
	int re = 0;
	for (int i = 0; i < x[a].size(); i++)
		if (x[a][i] != b)
			re ^= dfs(x[a][i], a) + 1;
	return re;
}
 
int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		scanf("%d%d", &ta, &tb);
		x[ta].push_back(tb);
		x[tb].push_back(ta);
	}
	printf(dfs(1, 0) ? "Alice\n" : "Bob\n");
	return 0;
}

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

using namespace std;

typedef long long ll;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

const int inf = 1e9 + 7;
const int mod = 1e9 + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  if (a < 0) a += mod;
}

inline int mul(int a, int b) {
  return (a * (ll) b) % mod;
}

inline int pw(int x, int n) {
  int res = 1;
  while (n > 0) {
    if (n % 2) {
      res = mul(res, x);
      n--; 
    } else {
      x = mul(x, x);
      n /= 2;
    }
  }
  return res;
}

const int N = 1e5 + 7;

vector <int> g[N];
vector <int> ord;
bool used[N];
int dp[N];

void dfs(int v) {
  if (used[v]) {
    return;
  }
  used[v] = true;
  for (int to : g[v]) {
    dfs(to);
  }
  ord.push_back(v);
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
  }
  for (int i = 0; i < n; i++) {
    if (!used[i]) {
      dfs(i);
    }
  }
  reverse(ord.begin(), ord.end());
  for (int i = 0; i < n; i++) {
    for (int to : g[ord[i]]) {
      dp[to] = max(dp[to], dp[ord[i]] + 1);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, dp[i]);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 8824
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
ll a[maxn],sum = 0;
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%I64d",&a[i]);
		sum += a[i];
	}
	ll cur = 0;
	ll ans = 1e18;
	for(int i=1;i<n;i++){
		cur += a[i];
		ll a = max(sum-cur,cur);
		ll b = min(sum-cur,cur);
		ans = min(ans,a-b);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
string s[8];
int ng[8][8];
bool flg;
void dfs(int r){
  if(r==8){
    flg=1;
    return;
  }
  for(int c=0;c<8;c++){
    if(s[r][c]=='Q'){
      dfs(r+1);
      return;
    }
  }
  for(int c=0;c<8;c++){
    if(ng[r][c]) continue;
    s[r][c]='Q';
    for(int j=0;j<8;j++){
      if(r+j<8 ) ng[r+j][c]++;
      if(r-j>=0) ng[r-j][c]++;
      if(c+j<8 ) ng[r][c+j]++;
      if(c-j>=0) ng[r][c-j]++;
      if(r+j<8 &&c+j<8 ) ng[r+j][c+j]++;
      if(r-j>=0&&c+j<8 ) ng[r-j][c+j]++;
      if(r-j>=0&&c-j>=0) ng[r-j][c-j]++;
      if(r+j<8 &&c-j>=0) ng[r+j][c-j]++;
    }
    dfs(r+1);
    if(flg) return;
    s[r][c]='.';
    for(int j=0;j<8;j++){
      if(r+j<8 ) ng[r+j][c]--;
      if(r-j>=0) ng[r-j][c]--;
      if(c+j<8 ) ng[r][c+j]--;
      if(c-j>=0) ng[r][c-j]--;
      if(r+j<8 &&c+j<8 ) ng[r+j][c+j]--;
      if(r-j>=0&&c+j<8 ) ng[r-j][c+j]--;
      if(r-j>=0&&c-j>=0) ng[r-j][c-j]--;
      if(r+j<8 &&c-j>=0) ng[r+j][c-j]--;
    }
  }
}
signed main(){
  for(int i=0;i<8;i++) s[i]=string(8,'.');
  int n;
  cin>>n;
  memset(ng,0,sizeof(ng));
  for(int i=0;i<n;i++){
    int r,c;
    cin>>r>>c;
    s[r][c]='Q';
    for(int j=0;j<8;j++){
      if(r+j<8 ) ng[r+j][c]++;
      if(r-j>=0) ng[r-j][c]++;
      if(c+j<8 ) ng[r][c+j]++;
      if(c-j>=0) ng[r][c-j]++;
      if(r+j<8 &&c+j<8 ) ng[r+j][c+j]++;
      if(r-j>=0&&c+j<8 ) ng[r-j][c+j]++;
      if(r-j>=0&&c-j>=0) ng[r-j][c-j]++;
      if(r+j<8 &&c-j>=0) ng[r+j][c-j]++;
    }
  }
  flg=0;
  dfs(0);
  for(int i=0;i<8;i++) cout<<s[i]<<endl;
  return 0;
}

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

int main () {
  string s;
  cin >> s;
  int size = s.size();
  if (s[size-1] == 's') {
    cout << s + "es";
  }
  else {
    cout << s + "s";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3620
while True:
    l = input().split()
    a  = int(l[0])
    op = l[1]
    b  = int(l[2])
    if op == '?':
        break

    if   op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)
    else:
        print('Undefined')




Measured memory_bytes: 5592
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
double speed;
int main()
{
  double height;
  while(cin>>speed){
    height = (pow(speed,2))*5/98;
  int n = 1;
  while(5*n-5<height){
    n++;
  }
  cout <<n<<endl;
  }
  return 0;
}

Measured memory_bytes: 1224
'''
Created on 2020/08/28

@author: harurun
'''
def main():
  from collections import deque
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  n=int(pin())
  a=list(map(int,pin().split()))
  b=deque([])
  if n%2==0:
    for i in range(n):
      if i%2==0:
        b.append(a[i])
      else:
        b.appendleft(a[i])
  else:
    for j in range(n):
      if j%2==0:
        b.appendleft(a[j])
      else:
        b.append(a[j])
  for k in range(n):
    pout(str(b[k]))
    if k!=n-1:
      pout(" ")
  pout("\n")
  return 
main()
    

Measured memory_bytes: 32636
s = input()
l = len(s)
sl = s[:(l-1)//2]
sr = s[((l+3)//2 -1):]
#print(sl)
#print(len(sl)//2)
#print(sr)
#print(len(sr)//2)

def f(s):
    l = len(s)
    j = False
    for i in range(l//2 +1):
        if s[i] == s[l-1-i]:
            j = True
        else :
            j = False
            break

    return j

if f(s) and f(sl) and f(sr):
    print("Yes")
else :
    print("No")



#print(f(s))
#print(f(sl))
#print(f(sr))

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<string>
using namespace std;
#define rep2(x,from,to) for(long long x=from;x<to;x++)
#define rep(x,to) rep2(x,0,to)
long long h;
long long n;
long long b[20006];
long long a[20006];
long long w[20006];
int main()
{
    cin>>h>>n;
    rep(i,n)cin>>a[i]>>b[i];
    rep(i,20006)w[i]=1000000000;
    w[h]=0;

    rep(i,n)
    {
        for(int j=h;j>=0;j--)
        {
            long long res;
            res=w[j]+b[i];
            int t=j-a[i];
            if(t<0)t=0;
            if(w[t]>res)w[t]=res;
        }
    }
    cout<<w[0]<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define nmax 51
const int inf=INT_MAX;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
ll a,b,c,a1,b1,c1,i;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>a>>b>>c;
    if(a&1 || b&1 || c&1)rc(0);
    else if(a==b && b==c && c==a)rc(-1);
    while(!(a&1) && !(b&1) && !(c&1))
	{
		a1=a,b1=b,c1=c;
		a=b1/2+c1/2;
		b=a1/2+c1/2;
		c=a1/2+b1/2;
		i++;
	}
	cout<<i<<endl;
    return 0;
}

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

using namespace std;

int expression();
int term();
int factor();
int number();

int now;
string s;

int expression(){
	int res=term();
		while(true){
		if(s[now]=='+')now++,res+=term();
		else if(s[now]=='-')now++,res-=term();
		else break;
	}
	return res;
}

int term(){
	int res=factor();
	while(true){
		if(s[now]=='(')res+=factor();
		else if(s[now]=='*')now++,res*=factor();
		else if(s[now]=='/')now++,res/=factor();
		else break;
	}
	return res;
}

int factor(){
	int res=0;
	if(s[now]=='('){
		now++;
		res=expression();
		now++;
	}
	else return number();
	
	return res;
}

int number(){
	int res=0;
	while('0'<=s[now] && s[now]<='9'){
		res*=10;
		res+=s[now++]-'0';
	}
	return res;
}


int main(void){
	int n;
	cin >> n;
	
	while(n--){
		cin >> s;
		now=0;
		cout << expression() << endl;
	}
	
	return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll x(ll n) {
    ll res = 0;

    ll s = n / 4 * 4;

    for (ll i = s; i <= n; ++i) {
        res ^= i;
    }

    return res;
}

int main() {

    ll a, b;
    cin >> a >> b;

    ll ans = x(b) ^ x(a - 1);

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int cnt = 0;
	while (true) {
		C -= B;
		if (C <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		A -= D;
		if (A <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}
}


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


int main(void) {
    using namespace std;

    long n;
    cin >> n;
    vector<long> p(n);
    for(auto &x: p) cin >> x, x--;

    vector<long> rev(n);
    for(int i=0; i<n; i++)
        rev[p[i]] = i;

    long r = 1;
    long s = 1;
    for(int i=1; i<n; i++) {
        if(rev[i] > rev[i-1])
            r = max(r, ++s);
        else
            s = 1;
    }
    cout << (n-r) << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 21
#define EPS 1e-9
#define INF 1e9

struct Point{
  double x, y;
}; 

int N;
Point h, d, crystal[MAX];
 
double dist(Point a, Point b){
  return sqrt(pow(a.x-b.x,2) + pow(a.y-b.y,2));
}

bool rec(int S, int v, double total_dist){
  if(S == (1 << N) - 1){
    return true;
  }
  for(int u = 0 ; u < N ; u++){
    if(!(S >> u & 1)){
      if(total_dist + dist(crystal[v],crystal[u]) >= dist(d, crystal[u])){
        return false;
      }
    }
  }
  for(int u = 0 ; u < N ; u++){
    if(!(S >> u & 1)){
      if(rec(S | 1 << u, u, total_dist + dist(crystal[v],crystal[u]))){
        return true;
      }
    }
  }
}

bool solve(){
  for(int i = 0 ; i < N ; i++){
    if(rec(0,i,dist(h,crystal[i]))){
      return true;
    }
  }  

  return false;
}
 
int main(){
  while(cin >> N >> h.x >> h.y >> d.x >> d.y, (N + h.x + h.y + d.x + d.y)){
    for(int i = 0 ; i < N ; i++){
      cin >> crystal[i].x >> crystal[i].y;
    }
    cout << (solve() ? "YES" : "NO") << endl;
  }
  
  return 0;
}

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

int main(){
	bool existBall[3] = { 1, 0, 0 };
	bool tm;

	char a, b;
	string s;

	while (getline(cin, s), s != "\0"){
		a = s[0];
		b = s[2];
		
		tm = existBall[b - 'A'];
		existBall[b - 'A'] = existBall[a - 'A'];
		existBall[a - 'A'] = tm;

	}
	
	s = "";
	for (int i = 0; i < 3;++i)
	if (existBall[i])
		cout << s + (char)('A' + i) << endl;

	return 0;

}

Measured memory_bytes: 1172