akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
  	int N;
  	cin >> N;
  	int A[N];
  	for (int i = 1; i < N; i++) cin >> A[i];
  
  	int num[N];
  
  	for (int i = 0; i < N; i++) num[i] = 0;
  
  	for (int i = 1; i < N; i++){
      	num[A[i] - 1]++;
    }
  
  	for (int i = 0; i < N; i++) cout << num[i] << endl;
}

Measured memory_bytes: 5160
n = int(input())
h = list(map(int, input().split()))
tmp = 0
ans = 0

for i in range(1,n):
    if h[i-1] >= h[i] :
        tmp += 1
    else:
        if tmp > ans:
            ans = tmp
        tmp = 0
if tmp > ans:
    print(tmp)
else:
    print(ans)


Measured memory_bytes: 14224
#include<stdio.h>
 
int A[1000000],n;
 
int binarySearch(int key){
    int left=0;
    int right=n;
    int mid;
    while(left<right){
        mid=(left+right)/2;
        if(key==A[mid])return 1;
        if(key>A[mid])left=mid+1;
        else if(key<A[mid])right=mid;
    }
    return 0;
}
 
int main(){
    int i,q,k,sum=0;
     
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
     
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&k);
        if(binarySearch(k))sum++;
    }
    printf("%d\n",sum);
     
    return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define int ll
//const int INF = 100100100;
const int INF = (1LL << 32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;

int n;
vector<int> a;

int solve(bool isFirstPlus) {
	int sum = 0;
	int ans1 = 0;
	bool plus = isFirstPlus;
	for (int i = 0; i < n; i++) {
		sum += a[i];
		if (plus and sum <= 0) {
			while (sum != 1) {
				sum++;
				ans1++;
			}
		}
		else if (!plus and sum >= 0) {
			while (sum != -1) {
				ans1++;
				sum--;
			}
		}
		plus = !plus;
	}
	return ans1;
}

signed main() {
	ios::sync_with_stdio(false);
	cin >> n;
	rep(i, n) {
		int x;
		cin >> x;
		a.pb(x);
	}
	int ans1 = solve(true);
	int ans2 = solve(false);
	cout << min(ans2, ans1) << endl;
	return 0;
}



Measured memory_bytes: 1400
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
int main()
{
	int i=0,j=0;
	char a[5],b[5];
	scanf("%s",&a);
	scanf("%s",&b);
	for(i=0;i<3;i++)
	{
		if(a[i]!=b[2-i])
		{
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main () {
  int n,k,d;
  cin >>n>>k;
  set<int>a;
  for(int i=1;i<=n;i++){
    a.insert(i);
  }

  for(int i=0;i<n;i++){
    cin>>d;
    vector<int>check(d);
    for(int j=0;j<d;j++){
      cin >>check.at(j);
      if(a.count(check.at(j)))a.erase(check.at(j));
    }
  }
  cout<<a.size()<<endl;
}


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

int main(){
    string S, T;
    cin >> S >> T;
    int i;
    int ans = 0;
    for(i=0;i<S.size();i++){
        if(S.at(i)!=T.at(i)){
            ans++;
        }
    }

    cout << ans << endl;
}

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

int main(){
    double n; cin>>n;
    vector<int> x(n);
    rep(i,n) cin>>x[i];
    double sum=0;
    rep(i,n){
        sum+=x[i];
    }
    double ave=sum/n;
    if((ave-int(ave))<0.5) ave=int(ave);
    else ave=int(ave)+1;
    //cout<<ave<<endl;
    int ans=0;
    rep(i,n){
        ans+=(x[i]-ave)*(x[i]-ave);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i, x;
    
    for (i=1; ; i++) { //
        scanf("%d", &x);
        if (x==0) {
            break;
        }
        printf("Case %d: %d\n",i,x);
    }
    return 0;
}



Measured memory_bytes: 2028
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		
        // Date型変換
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
        Date date1=null;
        Date date2=null;
		try {
			date1 = sdf.parse(S);
	        date2 = sdf.parse("2019/04/30");
		} catch (ParseException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
        if(date1.compareTo(date2) == -1 || date1.compareTo(date2) == 0) {
        	System.out.println("Heisei");
        }
        else {
            System.out.println("TBD");
        }
	}
}


Measured memory_bytes: 22224
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<cassert>

using namespace std;

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

int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};

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

	int n;
	ll d,a;
	pair<ll,ll> x[212345];

	cin>>n>>d>>a;
	for(int i=0;i<n;i++) cin>>x[i].first>>x[i].second;

	sort(x,x+n);

	ll xx[212345];
	for(int i=0;i<n;i++) xx[i]=x[i].first;

	xx[n]=1e18;
	ll res=0;

	ll t[212345];
	fill(t,t+n,0);
	for(int i=0;i<n;i++)
	{
		x[i].second-=t[i]*a;
		t[i+1]+=t[i];
		if(x[i].second>0)
		{
			ll cnt=(x[i].second+a-1)/a;
			res+=cnt;
			ll pos=upper_bound(xx,xx+n+1,x[i].first+d*2)-xx;
			t[i+1]+=cnt;
			t[pos]-=cnt;
		}
	}

	cout<<res<<endl;

	return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N, K; cin >> N >> K;
    string S; cin >> S;
    S[K-1] = S[K-1] - 'A' + 'a';
    cout << S << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    vector<int> rev(N);
    for (int i = 0;i < N; i++) {
        rev.at(A.at(i) - 1) = i + 1;
    }

    for (int i = 0; i < N; i++) {
        cout << rev.at(i) << endl;
    }
}

Measured memory_bytes: 1664
# coding: utf-8

n,m = map(int,input().split())
gyo_A = []
vec_b = []
ans = ""

for i in range(n):
    temp = [int(x) for x in input().split()]
    gyo_A.append(temp)

vec_b = [int(input()) for x in range(m)]

for i in range(n):
    vec_c = 0
    for j in range(m):
        vec_c += gyo_A[i][j] * vec_b[j]
    
    print(vec_c)



Measured memory_bytes: 6012
import math

a, b, h, m = list(map(int, input().split()))
deg = 30 * h - 6 * m + 30 * (m / 60.0)
if deg < 0:
  deg += 360
elif deg > 180:
  deg = 360 - deg

cos = math.cos(math.radians(deg))
c_2 = a * a + b * b - 2 * a * b * cos
print(math.sqrt(c_2))

Measured memory_bytes: 9472
h,w=map(int,input().split())
s=[input() for _ in range(h)]
dp=[[float('inf')]*w for _ in range(h)]
if s[0][0]=='#':
    dp[0][0] = 1
else:
    dp[0][0] = 0
dx=[1,0]
dy=[0,1]
for i in range(h):
    for j in range(w):
        for dir in range(2):
            ni=i+dy[dir]
            nj=j+dx[dir]
            if ni>=h or nj>=w:
                continue
            add=0
            if s[ni][nj]=='#' and s[i][j]=='.':
                add=1
            dp[ni][nj] = min(dp[ni][nj], dp[i][j]+add)
print(dp[-1][-1])

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 30;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  vector<ll> r(n, 0), l(n, 0);
  rep(i, n-1) {
    if(i%2==0) {
      ++r[i];
      --r[i+1];
      --l[i];
      ++l[i+1];
    }
    else {
      --r[i];
      ++r[i+1];
      ++l[i];
      --l[i+1];
    }
  }
  sort(ALL(l));
  sort(ALL(r));
  ll rans = 0, lans = 0;
  rep(i, n) {
    rans += r[i]*a[i];
    lans += l[i]*a[i];
  }
  cout << max(rans, lans) << endl;
}

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

int main()
{
	int tasks[3];
	for (int i = 0; i < 3; i++)
	{
		cin >> tasks[i];
	}
	
	sort(tasks, tasks + 3);
	
	cout << tasks[1] - tasks[0] + tasks[2] - tasks[1] << endl;
	return 0;
}

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

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            string s = ReadLine();
            string t = ReadLine();
            string s2 = string.Concat(s.OrderBy(x => x));
            string t2 = string.Concat(t.OrderByDescending(x => x));

            if (string.Compare(s2, t2) < 0)
            {
                WriteLine("Yes");
            }
            else WriteLine("No");
        }
    }
}

Measured memory_bytes: 13536
#include <iostream>
#include <stdio.h>
#include <string>
#include <cctype>
using namespace std;

int main() {
    char ch;
    do {
        scanf("%c", &ch);
        if (islower(ch)) printf("%c", toupper(ch));
        else printf("%c", tolower(ch));
    } while(ch != '\n');
    return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
int main()
{
    using namespace std;
    int K, a, b, sum(0);
    cin >> K;
    for (int i = 1; i <= K; i++)
    {
        for (int j = i; j <= K; j++)
        {
            for (int k = j; k <= K; k++)
            {
                if (i == j && j == k)
                {
                    sum += i;
                }
                else if (i < j && j < k)
                {
                    a = gcd(j, k);
                    b = gcd(i, a);
                    a = gcd(i, k);
                    sum += (b * 6);
                }
                else
                {
                    a = gcd(i, k);
                    sum += (a * 3);
                }
            }
        }
    }
    cout << sum << endl;
}

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

main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	int ans=-1;
	for (int i = 0; i < n; ++i)
	{
		for (int j = i+1; j < n; ++j)
		{
			int now=a[i]*a[j],p=now%10;
			bool f=1;
			now/=10;
			while(now>0)
			{
				if(now%10!=p-1) f=0;
				--p;
				now/=10;
			}
			if(f) ans=max(ans,a[i]*a[j]);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,ll> pi;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	int a,b,c;
	cin >> a >> b >> c;
	int cnt[11];
	cnt[a]++, cnt[b]++, cnt[c]++;
	if (cnt[5]==2 && cnt[7]==1) {
		cout << "YES";
	} else {
		cout << "NO";
	}
	return 0;
}


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

using ll = long long;

int main(){
    int n; cin >> n;
    ll ans1 = 0LL, ans2 = 0LL;
    vector<ll> a(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    ll cur; // 今見ている項までの総和

    // <<< パターン1 >>>
    // 第1項までの和が正 -> 第2項までの和が負 -> 第3項までの和が正 -> ...
    if (a.at(0) <= 0) {
        ans1 += -a.at(0) + 1; // 第1項が負なので+1にする
        cur = 1;
    } else {
        cur = a.at(0);
    }
    for (int i = 1; i < n; i++) {
        if ((0 < cur && 0 <= cur + a.at(i)) || (cur < 0 && cur + a.at(i) <= 0)) { // 今見ている項までの総和に次の項を足しても符号が反転しなかった場合
            ans1 += abs(cur + a.at(i)) + 1;
            if (0 < cur) {
                cur = -1;
            } else {
                cur = 1;
            }
        } else {
            cur += a.at(i);
        }
    }

    // <<< パターン2 >>>
    // 第1項までの和が負 -> 第2項までの和が正 -> 第3項までの和が負 -> ...
    if (0 <= a.at(0)) {
        ans2 += a.at(0) + 1;
        cur = -1;
    } else {
        cur = a.at(0);
    }
    for (int i = 1; i < n; i++) {
        if ((0 < cur && 0 <= cur + a.at(i)) || (cur < 0 && cur + a.at(i) <= 0)) {
            ans2 += abs(cur + a.at(i)) + 1;
            if (0 < cur) {
                cur = -1;
            } else {
                cur = 1;
            }
        } else {
            cur += a.at(i);
        }
    }

    cout << min(ans1, ans2) << endl;
    return 0;
}


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

int main() {
    int x;
    cin >> x;
    int degree = x;
    int ans = 1;
    while(degree%360!=0) {
        degree += x;
        ++ans;
    }

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


Measured memory_bytes: 3592
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)]

N, M, K = list(map(int, input().split()))

tree = UnionFind(N)
friends = [set() for i in range(N)]
blocks = [set() for i in range(N)]

for i in range(M):
    a, b = list(map(int, input().split()))
    friends[a-1].add(b-1)
    friends[b-1].add(a-1)
    tree.union(a-1, b-1)

for i in range(K):
    c, d = list(map(int, input().split()))
    blocks[c-1].add(d-1)
    blocks[d-1].add(c-1)

cnt = []

for i in range(N):
    group_size = tree.size(i)
    friend_cnt = len(friends[i])
    block_cnt = len([j for j in blocks[i] if tree.same(i, j)])
    cnt.append(group_size - friend_cnt - block_cnt - 1)

print(' '.join(list(map(str, cnt))))

Measured memory_bytes: 154384
X = int(input())

if 1800 <= X:
    print(1)
elif 1600 <= X:
    print(2)
elif 1400 <= X:
    print(3)
elif 1200 <= X:
    print(4)
elif 1000 <= X:
    print(5)
elif 800 <= X:
    print(6)
elif 600 <= X:
    print(7)
elif 400 <= X:
    print(8)


Measured memory_bytes: 9168
#include <cstdio>
#include <string>
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    uint64_t ans = 0;
    int b_count = 0;
    int l = s.length();
    for (int i=l; i > 0; i--) {
        if (s[i-1] == 'B'){
            ans += l - i - b_count;
            b_count++;
        
        }
    }
    printf("%llu\n", ans);
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long n,A[1<<20],F[1<<20];
long long k;
int cmp(int x,int y){return x>y;}
int main(){
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)scanf("%lld",&A[i]);
	for(int i=1;i<=n;i++)scanf("%lld",&F[i]);
	sort(A+1,A+1+n,cmp);
	sort(F+1,F+1+n);
	long long L = -1,R = A[1]*F[n];
	while(R-L>1){
		long long mid = (L+R)/2;
		long long required = 0;
		for(int i=1;i<=n;i++){
			required += max(0LL,A[i]-(mid/F[i]));
		}
		if(required <= k){
			R = mid;
		}else{
			L = mid;
		}
	}
	printf("%lld\n",R);
	return 0;
}

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

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

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

	sort(a.begin(), a.end());
	
	cout << a[n - 1] - a[0] << endl;

	return 0;
}

Measured memory_bytes: 256
S = list(input())
if len(set(S)) == 2:
    if(S[0] == S[1] and S[2]==S[3]):
       print('Yes')
    elif(S[0] == S[2]and S[1]==S[3]):
       print('Yes')
    elif(S[0] == S[3]and S[1]==S[2]):
       print('Yes')
    else:
      print('No')
else:
  print('No')
        
  


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  int max=a.at(N-1);
  cout << max << " ";
  int c,C,ans;
  for(int i=0;i<N;i++){
    c=a.at(i)*2-max;
    if(c>=0){
      ans=i;
      break;
    }
    C=c;
  }
  if(abs(C)>abs(c))
    //iが最小
    cout << a.at(ans);
  else
    cout << a.at(ans-1);
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
    int a,b,op;
    while(1){
    scanf("%d %c %d", &a, &op, &b);
    if(op=='?'){break;}
    else if(op=='+'){printf("%d\n", a+b);}
    else if(op=='-'){printf("%d\n", a-b);}
    else if(op=='*'){printf("%d\n", a*b);}
    else if(op=='/'){printf("%d\n", a/b);}
    }

    return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)

lld arr[111111];
bool eq(double a,double b){
	if(abs(a-b)<0.000000001) return true;
	return false;
}
int main(void){
	int n;
	scanf("%d",&n);
	lld pp = 1;
	int err = 0;
	for(int e=0;e<n;e++){
		scanf("%lld",&arr[e]);
		if(arr[e]==0) err++;
	}
	if(err){
		printf("0");
		return 0;
	}
	for(int e=0;e<n;e++){
		if(((long double)pp>(long double)1e18/(long double)arr[e])){
			printf("-1");
			return 0;
		}
		pp *= arr[e];
	}
	if((long double)pp>1e18) printf("-1");
	else printf("%lld",pp);
	return 0;
}


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

using namespace std;
using LL = long long int;

LL X, Y;

int main()
{
  cin >> X >> Y;
  LL ans = 1;
  while(X <= Y) {
    X *= 2;
    if(X <= Y) {
      ans++;
    } else {
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
int n, m;
int ans;
int main(){
	while(~scanf("%d", &n)){
		ans = n * 800;
		m = n / 15;
		printf("%d\n", ans - ( m * 200));
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;

ll mov[13][4] = {
	{2,-1,-1,-1},
	{2,5,-1,-1},
	{0,1,3,6},
	{2,7,-1,-1},
	{5,-1,-1,-1},
	{1,4,6,9},
	{2,5,7,10},
	{3,6,8,11},
	{7,-1,-1,-1},
	{5,10,-1,-1},
	{6,9,11,12},
	{7,10,-1,-1},
	{10,-1,-1,-1},
};

ll sw(ll l, int i, int j) {
	int a, b;
	a = (l >> (4 * i)) & 0xfL;
	b = (l >> (4 * j)) & 0xfL;

	l &= ~(0xfL << (4*i));
	l &= ~(0xfL << (4*j));

	l |= (ll)b << (4 * i);
	l |= (ll)a << (4 * j);

	return l;
}

int main() {
	while(1) {
		ll in = 0;
		for(int i = 0; i < 13; i++) {
			int tmpin;
			cin >> tmpin;
			if(tmpin < 0)
				return 0;
			in |= ((ll)tmpin << (4*i));
		}

		queue<ll> q;
		set<ll> s;
		q.push(in);
		s.insert(in);
		int ans = -1;
		// debug
		int failcount = 0;
		for(int i = 0; i <= 20; i++) {
			queue<ll> next;
			while(!q.empty()) {
				ll l = q.front(); q.pop();
				if(l == 0xba9876543210) {
					ans = i;
					goto OUTPUT_ANSWER;
				}
				else {
					int cnt = 0;
					for(int j = 0; j < 13; j++) {
						ll t = 0xba9876543210;
						if(((l >> 4*j) & 0xfL) != ((t >> 4*j) & 0xfL)) {
							cnt++;
						}
					}
					if(cnt > 20 - i + 2)
						continue;
				}

				for(int j = 0; j < 13; j++) {
					if(((l >> (4*j)) & 0xfL) == 0) {
						for(int k = 0; k < 4; k++) {
							ll p;
							if(mov[j][k] < 0)
								break;
							p = sw(l, j, mov[j][k]);
							if(s.find(p) == s.end()) {
								s.insert(p);
								next.push(p);
							}
							else {
								failcount++;
							}
						}
					}
				}
			}
			q = next;
		}

OUTPUT_ANSWER:;
		if(ans < 0)
			cout << "NA" << endl;
		else
			cout << ans << endl;
//		cout << failcount << endl;
	}
}

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

typedef long long ll;
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define rerepi(i, a, b) for(int i = int(a)-1; i >= b; --i)
#define rerep(i, n) rerepi(i, n, 0)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) {o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const long long INF = 1LL << 60;

// 降順ソート
// std::sort(data.begin(),data.end(),std::greater<ll>());
// 昇順ソート
// std::sort(data.begin(),data.end());

// ここから開始だよ！
ll N, M;
std::vector<ll> v;
std::vector<ll> DP(10010, -1);
std::vector<ll> ans;
ll dict[] = {0,2,5,5,4,5,6,3,7,6};

int main() {
	// 呪文エリア
	cin.tie(0);
	ios::sync_with_stdio(false);
	// 詠唱完了
  
	cin >> N >> M;
	rep(i, M) {
		ll tmp;
		cin >> tmp;
		v.push_back(tmp);
	}
	
	DP[0] = 0;
	rep(i, N+1) {
		repi(j, 0, v.size()) {
			ll tmp = v[j];
			if (i-dict[tmp] >= 0 && DP[i-dict[tmp]] != -1) {
				chmax(DP[i], DP[i-dict[tmp]] + 1);
			}
		}
	}
	
	ll hon = N;
	std::sort(v.begin(),v.end(),std::greater<ll>());
	rerep(i, DP[N]+1) {
		rep(j, v.size()) {
			ll tmp = v[j];
			if (DP[hon-dict[tmp]] == DP[hon]-1 && hon - dict[tmp] >= 0) {
				ans.push_back(tmp);
				hon -= dict[tmp];
				break;
			}
		}
	}
	
	rep(i, ans.size()) {
		cout << ans[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define Set set<int>
#define int long long
#define P pair<int,int>
const int maxn = 1e6;
const int INF = 1e18 +6;
using namespace std;
int n,m,a[maxn],b[maxn],c[maxn];
//bool operator<(const P& a, const P& b) {
//    return a.parameter<b.parameter;
//}
priority_queue<P>T;
int32_t main() {
    IOS;
    cin>>n>>m;
    int sum=0;
    fu(i,1,n)
    {
        cin>>a[i];
        sum+=a[i];
    }
    sort(a+1,a+n+1);
    fu(i,1,m)
    {
        cin>>b[i]>>c[i];
        T.push({c[i],b[i]});
    }
    int zuo=0;
    int key=0;
    while(!T.empty())
    {
        auto h=T.top();
        T.pop();
        int C=h.first;
        int B=h.second;
        fu(i,1,B)
        {
            if(a[++zuo]<C && zuo<=n){
                sum+=C-a[zuo];
            }else{
                key=1;
                break;
            }
        }
        if(key)break;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 11124
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N,H,W = map(int,readline().split())
RCA = [tuple(int(x) for x in line.split()) for line in readlines()]

RCA.sort(key = lambda x: -x[2])

RCA

root = list(range(H+W))
size = [0] * (H+W)
no_cycle = [True] * (H+W)

def find_root(x):
    y = root[x]
    if x == y:
        return y
    z = find_root(y)
    root[x] = z
    return z

def merge(x,y):
    x,y = find_root(x),find_root(y)
    sx,sy = size[x],size[y]
    if sx < sy:
        sx,sy = sy,sx
        x,y = y,x
    root[y] = x
    no_cycle[x] = no_cycle[x] and no_cycle[y]

answer = 0
for R,C,A in RCA:
    x,y = R-1,H+C-1
    rx,ry = find_root(x),find_root(y)
    if rx == ry:
        if not no_cycle[rx]:
            continue
        no_cycle[rx] = False
    else:
        if (not no_cycle[rx]) and (not no_cycle[ry]):
            continue
        merge(rx,ry)
    answer += A

print(answer)



Measured memory_bytes: 100784
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

typedef pair<int, int> II;
typedef pair<double, II> DII;

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		const int INF = 1 << 29;
		int h = -1, n = -1, a, b;
		cin >> h >> n;
		if (h < 0) return 0;
		vector<DII> v;
		for (int i = 0; i < n; ++i) {
			cin >> a >> b;
			double p = a, q = b;
			v.push_back({ p, {a, b} });
		}
		sort(v.begin(), v.end());
		vector<int> dp(20002, INF);
		dp[0] = 0;
		for (int i = 0; i < n; ++i) {
			a = v[i].second.first;
			b = v[i].second.second;
			if (i > 0 && v[i - 1].second.first == a) {
				continue;
			}
			for (int j = 0; j <= 20000 - a; ++j) {
				dp[j + a] = min(dp[j + a], dp[j] + b);
			}
		}
		int ans = INF;
		for (int i = h; i <= 20000; ++i) {
			ans = min(ans, dp[i]);
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define var auto
using namespace std;
using ll = long long;

int main() {
  int n, r;
  cin >> n >> r;

  if (n > 9) {
    cout << r << endl;
  } else {
    cout << (r + (100 * (10 - n))) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
	int n;
	ll x;
	cin>>n;
	ll s = 0;
	map<ll,ll>mp;
	rep(i,0,n){
		cin>>x;
		s+=x;
		mp[x]++;
	}
	int q;
	cin>>q;
	while (q--){
		ll a,b;
		cin>>a>>b;
		mp[b] += mp[a];
		s = s - mp[a]*a + mp[a]*b;
		mp[a] = 0;
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 9552
from math import factorial
from math import sqrt
def nCr(n,r):
    return factorial(n)//(factorial(r)*factorial(n-r))
"""
def factorize(p):
    b=[]

    for i in range(2,int(sqrt(p)+2)):
        a=0
        while((p%i)==0):
            a+=1
            p=p//i
          
        if a!=0:
            b.append(a)
        if p==1:
          break
    return b
"""

INF=10**9+7
N,m=map(int,input().split())


sum=1
#B=factorize(M)
yd = {}
i = 2
while m != 1:
  while m % i == 0:
    if i in yd:
      yd[i] += 1
    else:
      yd[i] = 1
    m //= i
  i += 1
for b in yd.values():
    sum*=nCr(N-1+b,N-1)
    sum%=INF
print(sum)


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

struct Card{
  char suit;
  char value;
};

void bubble(struct Card A[], int N){
  int i,j;
  for(i=0; i<N; i++){
    for(j=N-1; j>=i+1; j--){
      if( A[j].value < A[j-1].value ){
	Card t = A[j];
	A[j] = A[j-1];
	A[j-1] = t;
      }
    }
  }
}

void selection(struct Card A[],int N){
  int i,j,minj;
  for(i=0; i<N; i++){
    minj = i;
    for(j=i; j<N; j++){
      if( A[j].value < A[minj].value ) minj = j;
    }
    Card t = A[i];
    A[i] = A[minj];
    A[minj] = t;
  }
}

void print(struct Card A[], int N){
  int i;
  for(i=0; i<N; i++){
    if( i>0 ) cout << " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N){
  int i;
  for(i=0; i<N; i++){
    if( C1[i].suit != C2[i].suit ) return false;
  }
  return true;
}

int main(){
  Card C1[100], C2[100];
  int N,i;
  char ch;

  cin >> N;
  for(i=0; i<N; i++){
    cin >> C1[i].suit >> C1[i].value;
  }

  for(i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  cout << "Stable" << endl;
  print(C2,N);
  if( isStable(C1,C2,N) ){
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }

  return 0;
}



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

int main(){
	int a,b,c,d,e,f;
	while(cin>>a>>b>>c>>d>>e>>f){
		if(a==0&&b==0&&c==0&&d==0&&e==0&&f==0)break;
		
		int sum=100;
		int im=(3*f)-(3*e)-(a*5)-(b*3);
		sum-=im;
		sum+=a*15;
		sum+=a*75;
		sum+=b*15;
		sum+=b*45;
		sum+=c*7;
		sum+=d*2;		
		cout<<sum<<endl;
		}
		return 0;
	}

Measured memory_bytes: 2996
package main

import (
	"fmt"
	"strconv"
	"time"
)

func main() {
	var s string
	fmt.Scan(&s)

	y, _ := strconv.Atoi(s[0:4])
	m, _ := strconv.Atoi(s[5:7])
	d, _ := strconv.Atoi(s[8:10])

	t1 := time.Date(y, time.Month(m), d, 0, 0, 0, 0, time.UTC)
	t2 := time.Date(2019, 4, 30, 0, 0, 0, 0, time.UTC)
	if t1.After(t2) {
		fmt.Println("TBD")
	} else {
		fmt.Println("Heisei")
	}
}


Measured memory_bytes: 512
#include<algorithm>
#include<cmath>
#include<cctype>
#include<iomanip>
#include<iostream>
#include<map>
#include<string>
#include<vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define each(e, v) for (auto&& e : v)
#define clamp(v,lo,hi) min(max(v,lo),hi)
#define debug(i) cout<<"point :"<< i << endl;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef vector<int> vint;
typedef vector<long> vl;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef map<string, int> mapstri;
typedef map<int, int> mapii;
typedef std::pair<int, int> pairii;

int main () {
    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    ll t = n % k;
    ll a = k - t;
    ans = min(a,t);
    out (ans)
    return 0;
}

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

#define DUMP(x) cout << #x << " = " << (x) << endl;
#define REP(i, n) for(size_t i = 0; i < (n); i++)
#define REPR(i, n) for(size_t i = (n); i >= 0; i--)
#define FOR(i, a, b) for(size_t i = (a); i < (b); i++)
#define FOREACH(x, a) for(auto& (x) : (a))

const int INF = 1e9;
const int MOD = 1e9 + 7;
const int MAX_N = 1e9;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int N; cin >> N;
    int A[N + 1]; 
    int B[N + 1];
    FOR(i, 1, N + 1) {
        cin >> A[i] >> B[i];
    }
    ll ans = 0;
    for(size_t i = N; i > 0; i--) {
        if ((A[i] + ans) % B[i] != 0) {
            ans += (B[i] - (A[i] + ans) % B[i]); 
        }
    }
    cout << ans << "\n";
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

const ll longinf=1LL<<60;

struct LazySegmentTree{
private:
   int n;
   vector<ll> node,lazy;
public:
   LazySegmentTree(int sz,ll init=0){
      n=1;
      while(n<sz)n*=2;
      node.resize(2*n-1,init);
      lazy.resize(2*n-1,0);
   }
 
   void eval(int k,int l,int r){
      if(lazy[k]!=0)node[k]+=lazy[k];
      if(r-l>1){
          lazy[2*k+1]+=lazy[k];
          lazy[2*k+2]+=lazy[k];
      }
      lazy[k]=0;
   }
      //[a,b)にxを加算
   void add(int a,int b,ll x,int k=0,int l=0,int r=-1){
       if(r<0)r=n;
       eval(k,l,r);
       if(r<=a||b<=l)return;
       if(a<=l&&r<=b){
          lazy[k]+=x;
          eval(k,l,r);
       }
       else {
          add(a,b,x,2*k+1,l,(l+r)/2);
          add(a,b,x,2*k+2,(l+r)/2,r);
          node[k]=max(node[2*k+1],node[2*k+2]);
        }
   }
   //[a,b)でのmaxを返す
   ll get(int a,int b,int k=0,int l=0,int r=-1){
      if(r<0)r=n;
      eval(k,l,r);
      if(r<=a||b<=l)return 0;
      if(a<=l&&r<=b)return node[k];
      ll xl=get(a,b,2*k+1,l,(l+r)/2);
      ll xr=get(a,b,2*k+2,(l+r)/2,r);
      return max(xl,xr);
   }
};

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

	vector<P_ii> R[N];
	REP(i, M){
		int l, r, a;
		cin >> l >> r >> a;
		R[r-1].push_back({l-1, a});
	}
    
	LazySegmentTree sg(N+1, 0);

	REP(i, N){
		ll now = sg.get(0, i);
		sg.add(i, i+1, now);
		for(auto s : R[i]){
			int l = s.first;
			sg.add(l, i + 1, s.second);
		}
	}
	cout << sg.get(0, N) << endl;

    return 0;
}

Measured memory_bytes: 21376
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(b==1) return a;else if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    LL(a,b,c,d);
    ll ans=-1000000000000000001;
    ans=max(ans,a*d);
    ans=max(ans,a*c);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    out(ans);
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.14159265
#define MOD 1000000007
#define PSET(x,y) fixed<<setprecision(y)<<x
#define ll long long
#define ld long double
#define lop(i,a,b) for(ll i=a;i<b;i++)
#define lopr(i,a,b) for(ll i=a;i>=b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
using namespace std;

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    
    fast_io()
    
    int a,b,c;
    cin>>a>>b>>c;

    cout<<(b*a)/2;

    return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    let mut v2 = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let v = s.trim().split_whitespace()
            .map(|e| e.parse().ok().unwrap()).collect();
        v2.push(v);
    }
    v2
}

fn a179(){

    let s:String = read();
    let mut result = "".to_string();
    if s.chars().last().unwrap() == 's' {
        result = s.clone() + "es";
    }
    else{
        result = s.clone() + "s";
    }
    println!("{}",result);
}


fn main() {
    a179();
}


Measured memory_bytes: 2168
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Sn = String.valueOf(N).chars().map(Character::getNumericValue).sum();

        System.out.println(
                N % Sn == 0
                ? "Yes"
                : "No"
        );
    }

}


Measured memory_bytes: 26580
n = int(input())
h = list(map(int,input().split()))

st = 0
fst = 0
tmph = -1
span = 0
for i in range(1,n):  
  if h[i] > h[i-1]:
    span = max(span,i-1-st) 
    st = i
    
span = max(span,n-1-st)

print(span)

Measured memory_bytes: 15020
#include<bits/stdc++.h>
#define For(i, a, b)  for(int i = a, _b = b; i <= _b; ++i)
#define Ford(i, a, b) for(int i = a, _b = b; i >= _b; --i)
#define FileName      "test"
#define ll            long long
#define ld            long double
#define ull           unsigned long long
#define Print(x)      cerr << #x << "is " << x << '\n';
#define pb            push_back
#define X             first
#define Y             second
//#define Karma

using namespace std;

template<typename T> inline void Cin(T &x)
{
    char c;
    T sign = 1;
    x = 0;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        if (c == '-') sign = -1;
    for (; c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    x *= sign;
}
template <typename T> inline void Out(T x) {if(x > 9) Out(x / 10); putchar(x % 10 + '0');}
template <typename T> inline void Cout(T x, char c) {if(x < 0) putchar('-'); x = abs(x); Out(x); putchar(c);}
template <typename T, typename... Args> inline void Cin(T& a, Args&... args) {Cin(a);Cin(args...);}
template <typename T, typename... Args> inline void Cout(T a, char c, Args... args) {Cout(a, c);Cout(args...);}

typedef pair<int, int> pii;
typedef pair<ll, int> plli;
const int N = 1e5 + 7;

vector<int> a[N];
int n, m, u, v, in[N], f[N];
queue<int> q;

void Enter()
{
     Cin(n, m);
     For(i, 1, m)
     {
         Cin(u, v);
         a[v].pb(u);
         ++in[u];
     }
     For(i, 1, n) if(in[i] == 0) q.push(i);
}

void Solve()
{
     int res = 0;
     while(!q.empty())
     {
         int u = q.front();
         q.pop();
         res = max(res, f[u]);
         for(int v: a[u])
         {
             if(f[v] < f[u] + 1) f[v] = f[u] + 1;
             --in[v];
             if(in[v] == 0) q.push(v);
         }
     }
     cout << res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef Karma
    freopen(FileName".inp", "r", stdin);
    freopen(FileName".out", "w", stdout);
#endif // Karma

    Enter();
    Solve();

    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> h(n);
  REP(i, n) { cin >> h[i]; }
  vector<bool> isGood(n, true);
  REP(i, m) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    if (h[a] > h[b]) {
      isGood[b] = false;
    } else if (h[a] == h[b]) {
      isGood[a] = isGood[b] = false;
    } else {
      isGood[a] = false;
    }
  }
  ll ans = 0;

  REP(i, n) {
    if (isGood[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4048
li=[]
count=0
a=set()
n,k=map(int,input().split())
for i in range(k):
  d=int(input())
  b=list(map(int,input().split()))
  for j in range(len(b)):
      a.add(b[j])
a=list(a)
for k in range(1,n+1):
    if k not in a:
        count=count+1
print(count)   
  
  
  

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;

vector<P> to[100005];
int dist[100005];

int main(){
    int k;
    cin >> k;
    for (int i=1; i<=k-1; i++) {
        to[i].emplace_back(i+1, 1);
    }
    for (int i=1; i<=k-1; i++) {
        int j = (i*10-1)%k+1;
        to[i].emplace_back(j, 0);
    }
    for (int i=1; i<=k; i++) {
        dist[i] = INF;
    }
    auto comp = [](P a, P b) {
        return a.second>b.second;
    };
    priority_queue<P, vector<P>, decltype(comp)> q{comp};
    q.emplace(1, 1);
    dist[1] = 1;
    while (!q.empty()) {
        P now = q.top();
        q.pop();
        int x = now.first;
        int d = now.second;
        for (auto e: to[x]) {
            int dd = d + e.second;
            if (dist[e.first]<=dd) continue;
            dist[e.first] = dd;
            q.emplace(e.first, dd);
        }
    }
    
    int ans = dist[k];
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9680
using System;
namespace HelloWorld
{
    class Program
    {
        static void Main()
        {
            const int NUMS = 4;
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                string[] str = line.Split();
                string[] auth = Console.ReadLine().Split();
                var hit = 0;
                var hitblow = 0;
                for (int i = 0; i < NUMS; ++i)
                {
                    if (str[i] == auth[i])
                    {
                        hit++;
                    }
                    for (int j = 0; j < NUMS; ++j)
                    {
                        if (auth[i] == str[j])
                        {
                            hitblow++;
                        }
                    }
                }
                Console.WriteLine("{0} {1}", hit, hitblow - hit);
            }
        }
       
    }
}


Measured memory_bytes: 15756
#include<bits/stdc++.h>
using namespace std;
int n,a[100100];
map<int,int> S;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	for(int i=1;i<=n;i++) S[a[i]]++;
	if(S.size()>3) return puts("No"),0;
	if(S.size()==1)
	{
		if(S.begin()->first==0) puts("Yes");
		else puts("No");return 0;
	}
	if(n%3) return puts("No"),0;
	if(S.size()==2)
	{
		if(S.begin()->first==0&&S.begin()->second==n/3) puts("Yes");
		else puts("No");return 0;
	}
	if(S.size()==3)
	{
		int v=0;
		for(map<int,int>::iterator it=S.begin();it!=S.end();it++)
		{
			v^=it->first;
			if(it->second!=n/3) return puts("No"),0;
		}
		if(v) puts("No");else puts("Yes");return 0;
	}
}


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

int main(){
    int n;
    cin >> n;
    vector<string> w(n);
    string tmp;
    rep(i, n){
        cin >> w[i];
        //w.push_back(tmp);
    }

    bool flg = true;
    repa(i, 1, n){
        if(w[i-1].back() != w[i].front()) flg = false;
        rep(j, i){
            if(w[i] == w[j]) flg = false;
        }
    }

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

Measured memory_bytes: 3616
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
H = int(input())
W = int(input())

print((N - H + 1) * (N - W + 1))



Measured memory_bytes: 7876
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i > 0; i--)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
template <typename Iter> std::string join(Iter begin, Iter end, std::string const& separator){ std::ostringstream result; if (begin != end){ result << *begin++; }; while (begin != end){ result << separator << *begin++; }; return result.str(); }
using namespace std;
typedef long long ll;
void solve() {
  ll A, B; cin >> A >> B;
  cout << (B - 1 + (A - 1) - 1) / (A - 1) << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 256