akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 21:09:01 2020

@author: Kei
"""


A,B,C,K = map(int,input().split())


if K <= A :
    print(K)
elif K - A <= B:
    print(A)
else:
    print(A-(K-A-B))
    




Measured memory_bytes: 9164
import java.io.*;

/**
 * Created by Ayushi on 27 Jun 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int a = Integer.parseInt(br.readLine());
        br.close();
        long b = (long) (a + (Math.pow(a, 2)) + (Math.pow(a, 3)));
        System.out.println(b);
    }
}


Measured memory_bytes: 32636
H, W, m = map(int, input().split())
xs = [0] * H
ys = [0] * W
s = set()
for _ in range(m):
    h, w = map(int, input().split())
    h -= 1
    w -= 1
    xs[h] += 1
    ys[w] += 1
    s.add((h, w))

mx = max(xs)
my = max(ys)
mxs = set()
for i in range(H):
    if xs[i] == mx:
        mxs.add(i)
mys = set()
for i in range(W):
    if ys[i] == my:
        mys.add(i)
for x in mxs:
    for y in mys:
        if not (x, y) in s:
            print(mx + my)
            exit()
print(mx + my - 1)


Measured memory_bytes: 215748
#include <stdio.h>
int main()
{
	int N, K, S;
	scanf("%d%d%d", &N, &K, &S);
	int i = 1;
	for(i;i<=K;i++)
	{
		printf("%d ", S);
	}
	for(i;i<=N;i++)
	{
		if(S+1<=1000000000)
		    printf("%d", S+1);
		else printf("999999999");
		if(i!=N) printf(" ");
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>
int main(void)
{
	int A,B,C,D;
	scanf("%d %d %d",&A,&B,&C);
	if(A==C){
		printf("%d\n",B);
		}
	if(A==B){
		printf("%d\n",C);
		}
	if(B==C){
		printf("%d\n",A);
		}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <cctype>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<long long>
#define vvl vector<vector<long long>>

using namespace std;

typedef long long ll;

int main()
{
  int n;
  cin >> n;
  vi v_o(n / 2);
  vi v_e(n / 2);
  REP(i, n)
  {
    if (i % 2 == 0)
      cin >> v_e[i / 2];
    else
      cin >> v_o[i / 2];
  }

  sort(ALL(v_e));
  sort(ALL(v_o));

  int max_e = 0;
  int max_o = 0;
  int sec_e = 0;
  int sec_o = 0;
  int num_e = v_e[0];
  int num_o = v_o[0];

  int nc = 0;
  int ne = v_e[0];
  REP(i, n / 2)
  {
    if (v_e[i] == ne)
    {
      nc++;
      if (i == n / 2 - 1)
      {
        if (nc > max_e)
        {
          sec_e = max_e;
          max_e = nc;
          num_e = v_e[i - 1];
        }
        else if (sec_e < nc)
        {
          sec_e = nc;
        }
      }
    }
    else
    {
      if (nc > max_e)
      {
        sec_e = max_e;
        max_e = nc;
        num_e = v_e[i - 1];
      }
      else if (sec_e < nc)
      {
        sec_e = nc;
      }
      ne = v_e[i];
      nc = 1;
      if (i == n / 2 - 1 && sec_e < nc)
      {
        sec_e = nc;
      }
    }
  }
  nc = 0;
  int no = v_o[0];
  REP(i, n / 2)
  {
    if (v_o[i] == no)
    {
      nc++;
      if (i == n / 2 - 1)
      {
        if (nc > max_o)
        {
          sec_o = max_o;
          max_o = nc;
          num_o = v_o[i - 1];
        }
        else if (sec_o < nc)
        {
          sec_o = nc;
        }
      }
    }
    else
    {
      if (nc > max_o)
      {
        sec_o = max_o;
        max_o = nc;
        num_o = v_o[i - 1];
      }
      else if (sec_o < nc)
      {
        sec_o = nc;
      }
      no = v_o[i];
      nc = 1;
      if (i == n / 2 - 1 && sec_o < nc)
      {
        sec_o = nc;
      }
    }
  }
  int count;
  if (num_o == num_e)
  {
    if (max_o + max_e == n)
    {
      cout << n / 2 << endl;
      return 0;
    }
    int hoge = (n / 2 - max_o) + (n / 2 - sec_e);
    int fuga = (n / 2 - sec_o) + (n / 2 - max_e);
    count = min(hoge, fuga);
  }
  else
  {
    count = (n / 2 - max_o) + (n / 2 - max_e);
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int b[6][10];
int d[]={-1,0,1};
int n;
int dfs(int idx,int rec){
  int ans=0;
  if(idx==n && rec%2==0)
    return 1;
  for(int i=0;i<3;i++){
    if(idx<n)
      ans+=dfs(idx+1,rec*b[i][idx]);
  }
  return ans;
}
int main(){
  int ans=0;
  int a[10];
  cin >> n;
  for(int i=0;i<n;i++)
    cin >> a[i];
  for(int i=0;i<3;i++){
    for(int j=0;j<n;j++){
      b[i][j]=a[j]+d[i];
      if(b[i][j]%2==0)
        b[i+3][j]=1;
    }
  }
  cout << dfs(0,1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string S,T; cin >> S >> T;
    map<char,char> mp1,mp2;
    bool flag = true;
    rep(i,0,SZ(S)){
        char s = S[i];
        char t = T[i];
        auto itr1 = mp1.find(s);
        if(itr1 != mp1.end()){
            if(mp1[s] != t) flag = false;
        }
        auto itr2 = mp2.find(t);
        if(itr2 != mp2.end()){
            if(mp2[t] != s) flag = false;
        }
        mp1[s] = t;
        mp2[t] = s;
    }

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


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    int n,m;
    cin>>n>>m;
    n--;
    m--;
    cout<<n*m<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  #define Mod 1000000007
  #define INF 9e8
  #define INFL 9e18
  #define EPS 1e-9
  #define pb push_back
  #define mp make_pair
  #define SET(a) memset(a,-1,sizeof(a))
  #define CLR(a) memset(a,0,sizeof(a))
  #define CPY(a,b) memcpy(a,b,sizeof(a))
  #define N 200005
  #define fs first
  #define sc second 
  #define UNIVISITED 0
  #define EXPLORED 1
  #define VISITED 2
  using namespace std;
  typedef  long long int ll;
  typedef pair<ll,ll> ii;
  typedef vector <ii> vii;
  typedef vector <ll> vi;

  ll arr[N],pos[N];

  int main()
  {
  
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x,y,z;
  cin>>x>>y>>z;
  x-=z;
 ll ans=x/(y+z);
  cout<<ans<<endl;



  return 0;


  } 

Measured memory_bytes: 256
def main():
    N, D = list(map(int, input().split()))
    X = []
    for i in range(N):
        X.append(list(map(int, input().split())))

    count = 0
    for i in range(N-1):
        for j in range(i+1, N):
            total = 0.0
            for x, y in zip(X[i], X[j]):
                total += abs(x - y) ** 2
            total = total ** 0.5
            if int(total) == total:
                count += 1

    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    int64_t n;
    cin>>n;
    vector<int64_t> a(n);
    map<int64_t,int64_t> p;
    bool ans = true;
    rep(i,n){
        cin>>a[i];
        p[a[i]]++;
        if(p[a[i]]==2){
            ans = false;
            break;
        }
    }
    if(ans){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }

}

Measured memory_bytes: 14336
#include<iostream>

using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	if(a+b==15){
		cout<<"+"<<endl;
	}else if(a*b==15){
		cout<<"*"<<endl;
	}else{
		cout<<"x"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,t,e,a[100100],f[100100],mn=0x3f3f3f3f;
deque<int>q;
signed main(){
	scanf("%lld%lld%lld",&n,&e,&t);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	q.push_back(0);
	for(int i=1,j=0;i<=n;i++){
		while(j+1<i&&t-2*a[i]+2*a[j+1]<0)mn=min(mn,f[j]-a[j]-2*a[j+1]),j++;
		while(!q.empty()&&q.front()<j)q.pop_front();
		while(!q.empty()&&f[i-1]-a[i-1]<=f[q.back()]-a[q.back()])q.pop_back();
		q.push_back(i-1);
		f[i]=min(f[q.front()]-a[q.front()]+a[i]+t,mn+3*a[i]);
	}
	printf("%lld\n",f[n]+e-a[n]);
	return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
#include <string.h>

// https://atcoder.jp/contests/abc136/tasks/abc136_b

int main(int argc, char *argv[]) {
    int n;
    scanf("%d", &n);

    int i, ans = 0;
    size_t tmp;
    char c[100];
    for (i = n; i >= 1; i--) {
        sprintf(c, "%d", i);
        tmp = strlen(c);
        if (tmp % 2 != 0) {
            ans++;
        }
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define pb push_back
#define mp make_pair
#define ll long long

ll min3(ll a, ll b, ll c)
{
	if (a < b && a < c) return a;
	if (b < c) return b;
	return c;
}

class Diameter
{
public:
	vec<vec<int>> g;
	pair<int, int> ps;
	vec<int> path;
	int n;
	Diameter(int num): g(num) {
		ps.first = 0;
		ps.second = 0;
		n = num;
	}
	
	void edge(int a, int b) {
		g[a].pb(b);
		g[b].pb(a);
	}

	int longest(int a) {
		queue<pair<int, vec<int>>> keep;
		vec<int> hoge = {a};
		keep.push(mp(a, hoge));
		vec<int> dp(n, 0);

		pair<int, vec<int>> cur;
		while(!keep.empty()) {
			pair<int, vector<int>> get = keep.front();
			keep.pop();
			int cur_p = get.first;
			if (dp[cur_p]) continue;
			dp[cur_p] = 1;
			cur = get;
			rep(i, g[cur_p].size()) {
				int v = g[cur_p][i];
				vec<int> v_path = get.second;
				v_path.pb(v);

				keep.push(mp(v, v_path));
			}
		}

		path = cur.second;
		return cur.first;
	}

	vec<int> diameter(void) {
		ps.first = longest(0);
		ps.second = longest(ps.first);
		return path;
	}
};

ll solve(vec<int> cur_p, vec<vec<int>> g)
{
	vec<int> dp(g.size(), 0);
	ll ans;
	if (cur_p.size() == 1) {
		int c = cur_p[0];
		dp[c] = 1;
		ans = (ll)g[c].size();;
		vec<int> next_p;
		rep(i, g[c].size()) {
			next_p.pb(g[c][i]);
		}
		cur_p = next_p;
	} else ans = 2;
	// rep(i, cur_p.size()) cout << cur_p[i] + 1 << " ";
	// cout << endl;

	rep(i, cur_p.size()) dp[cur_p[i]] = 1;

	while(!cur_p.empty()) {
		vec<int> next_p;
		rep(i, cur_p.size()) {
			rep(j, g[cur_p[i]].size()) {
				if (dp[g[cur_p[i]][j]]) continue;
				dp[g[cur_p[i]][j]] = 1;
				next_p.pb(g[cur_p[i]][j]);
			}
		}
		
		ll Max = 1;
		rep(i, cur_p.size()) {
			ll temp = (ll)g[cur_p[i]].size() - 1;
			Max = Max < temp ? temp : Max;
		}
		// cout << Max << endl;
		ans *= Max;
		cur_p = next_p;
		// rep(i, cur_p.size()) cout << cur_p[i] + 1 << " ";
		// cout << endl;
	}
	return ans;
}

int main(void)
{
	int n;
	cin >> n;
	Diameter d(n);
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		d.edge(a, b);
	}

	vec<int> path = d.diameter();

	int l = (int)path.size();
	ll ans = 1;
	if (l % 2 == 0) {
		vec<int> cur_p = {path[l / 2 - 1], path[l / 2]};
		ans = solve(cur_p, d.g);
	} else {
		vec<int> cur_p = {path[l / 2]};
		ans = solve(cur_p, d.g);

		rep(i, d.g[path[l / 2]].size()) {
			vec<int> cur_pp = {path[l / 2], d.g[path[l / 2]][i]};
			ll ans1 = solve(cur_pp, d.g);
			ans = ans < ans1 ? ans : ans1;
		}
	}

	cout << (l + 1) / 2 << " " << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
from math import ceil, sqrt, factorial
from itertools import permutations
def eratosthenes(n):
    l = [1 for i in range(n+1)]
    l[0] = l[1] = 0
    for i in range(2, ceil(sqrt(n))):
        if l[i] == 0: continue
        for j in range(i*2, n+1, i):
            l[j] = 0
    return l

m = factorial(N)
ans = set()

p = eratosthenes(530)

p = [i for i,v in enumerate(p) if v ]

for i in p:
    a = i**74
    if not m % a:
        ans.add(a)
        break

for a,b in permutations(p,2):
    c = a**2*b**24
    if not m % c:
        ans.add(c)
    c = a**4*b**14
    if not m % c:
        ans.add(c)

for a,b,c in permutations(p, 3):
    d = a**2 * b**4 * c ** 4
    if not m % d:
        ans.add(d)

print(len(ans))


Measured memory_bytes: 3064
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <stdio.h>

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

    double a,b,c,d,e,f;
    while (std::cin >> a >> b >> c >> d >> e >> f) {
        double x,y;
        y = (a*f-c*d)/(a*e-b*d);
        x = (c-b*y)/ a;
        printf("%.3f %.3f\n",x,y);
    }
    return EXIT_SUCCESS;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T> 
struct BIT{
  int n;
  vector<T> bit;
  //1-indexed
  BIT():n(-1){}
  BIT(int n_,T d):n(n_),bit(n_+1,d){}
  
  T sum(int i){
    T s=bit[0];
    for(int x=i;x>0;x-=(x&-x))
      s+=bit[x];
    return s;
  }
  void add(int i,T a){
    if(i==0) return;
    for(int x=i;x<=n;x+=(x&-x))
      bit[x]+=a;
  }
};


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<vector<int> > a(3,vector<int>(n));

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

  auto NG=[](){cout<<"No"<<endl;exit(0);};
  set<int> s;
  for(int j=0;j<n;j++){
    if(a[1][j]%3!=2) NG();
    if((a[1][j]/3)%2!=(j&1)) NG();
    if(j%4>=2) swap(a[0][j],a[2][j]);
    if(abs(a[0][j]-a[1][j])!=1) NG();
    if(abs(a[2][j]-a[1][j])!=1) NG();
    if(j%4<2) s.emplace(j*3+1);
    else s.emplace(j*3+3);
  }
    
  for(int j=0;j<n;j++)
    assert(s.count(a[0][j])||s.count(a[2][j]));
  
  auto rot=
    [&](int x){
      assert(0<x&&x+1<n);
      for(int i=0;i<3;i++)
        swap(a[i][x-1],a[i][x+1]);
      swap(a[0][x],a[2][x]);
    };

  for(int j=1;j+1<n;j++)
    if(!s.count(a[0][j])) rot(j),j-=2,chmax(j,0);
  
  if(!s.count(a[0][0])){
    rot(1);rot(2);rot(3);
    if(!s.count(a[0][2])) rot(2);
  }
  if(!s.count(a[0][n-1])){
    rot(n-2);rot(n-3);rot(n-4);   
  }
  
  for(int j=0;j<n;j++) assert(s.count(a[0][j]));  
  
  vector<int> eve,odd;
  for(int j=0;j<n;j++)
    (j&1?odd:eve).emplace_back(a[0][j]);

  const int MAX = 3e5+100;
  auto calc=
    [&](vector<int> v)->int{
      BIT<int> bit(MAX,0);
      int res=0;
      for(int i=0;i<(int)v.size();i++){
        res+=(i-bit.sum(v[i]))&1;
        bit.add(v[i],1);
      }
      return res&1;
    };
  
  if(calc(eve)) NG();
  if(calc(odd)) NG();
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 8056
H = []
W = []
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    else:
        H.append(h)
        W.append(w)
for i in range(len(H)):
    for j in range(H[i]):
        for k in range(W[i]):
            if j%2 == 0 and k%2 == 0:
                print('#',end="")
            elif j%2 == 1 and k%2 == 1:
                print('#',end="")
            else:
                print('.',end="")
        print("")
    print("",end="\n")


Measured memory_bytes: 7020
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef pair<ll , pair<ll, ll> > pi;
int pow(int x,int y){
    int res=1;
    while(y){
        if(y&1) res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}   
struct Compare {
    constexpr bool operator()(pi const & a,
                              pi const & b) const noexcept
    { return a.first < b.first || (a.first == b.first && a.second.first > b.second.first); }
 
};
void prefix_function( string s,ll arr[] )
{
     long long border=0; arr[0]=0;
    for(long long i=1;i<s.size();i++)
    {
      while(border>0 && s[i]!=s[border])
        border=arr[border-1];
     
     if(s[i]==s[border])
         border++;
      else
       border=0;
      
      arr[i]=border;
    }
}//send mod-2 for a^-1 if mod is a prime number

ll mod=998244353;
ll add( ll a , ll b)
{
    return (((a%mod)+(b%mod))%mod);
}
ll mul(ll a,ll b)
{
  return (((a%mod)*(b%mod))%mod);
}
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}
ll subs(ll a,ll b)
{
    return (((a%mod)-(b%mod)+mod)%mod);
}
ll dv(ll a,ll b)
{
    ll inv=binpow(b,mod-2);
    return mul(a,inv);
}

ll dsu_arr[100000];
ll dsu_sz[100000];
void dsu(ll n)
{
    for(ll i=0;i<=n;i++)
    {
        dsu_arr[i]=i;
        dsu_sz[i]=1;
    }
}
ll find(ll x)
{
     ll root=x;
    while (root!=dsu_arr[root])
    {
        root=dsu_arr[root];
    }
    while(x!=dsu_arr[x])
    {
        dsu_arr[x]=root;
        x=dsu_arr[x];
    }
    return root;
}
ll merge(ll x,ll y)
{
    ll root1=find(x);
    ll root2=find(y);
    
    if(root1==root2)
    return 0ll;
 
    if(dsu_sz[x]>dsu_sz[y]){
    dsu_arr[root2]=root1;
    dsu_sz[root1]+=dsu_sz[root2];
    }
    else
    {
         dsu_sz[root2]+=dsu_sz[root1];
        dsu_arr[root1]=root2;
    }
    return 1ll;
}
/*
vector<ll>adj[100005];
bool vis[100005];
ll dist[100005];
void bfs(ll c)
{
  vis[c]=true;
  dist[c]=0;
  q.push(c);
while(!q.empty())
{
    ll x=q.front();
    q.pop();
   
    for(ll i=0;i<adj[x].size();i++)
    {
        ll y=adj[x][i];
        if(!vis[y])
        {
            vis[y]=true;
            dist[y]=dist[x]+1;
            
            q.push(y);
        }
    }
 
}
}
*/

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


}



   
      
    
        



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

// 0-indexed
template <class T, class E>
struct SegmentTreeLaze {
  // a,b:T c,d:E e:E(unit)
  // g(f(a,b),c) = f(g(a,c),g(b,c))
  // g(g(a,c),d) = g(a,h(c,d))
  // g(a,e) = a
  typedef function<T(T, T)> F;
  typedef function<T(T, E)> G;
  typedef function<E(E, E)> H;
  int n, height;
  F f;
  G g;
  H h;
  T tunit;
  E eunit;
  vector<T> dat;
  vector<E> laz;
  SegmentTreeLaze(){};
  SegmentTreeLaze(int newn, F f, G g, H h, T nt, E ne)
      : f(f), g(g), h(h), tunit(nt), eunit(ne) {
    init(newn);
  }
  void init(int newn) {
    n = 1, height = 0;
    while(n < newn) n <<= 1, ++height;
    dat.assign(n << 1, tunit);
    laz.assign(n << 1, eunit);
  }

  inline T reflect(int k) {
    return laz[k] == eunit ? dat[k] : g(dat[k], laz[k]);
  }

  inline void eval(int k) {
    if(laz[k] == eunit) return;
    laz[k << 1] = h(laz[k << 1], laz[k]);
    laz[(k << 1) | 1] = h(laz[(k << 1) | 1], laz[k]);
    dat[k] = reflect(k);
    laz[k] = eunit;
  }

  inline void thrust(int k) {
    for(int i = height; i; --i) eval(k >> i);
  }

  void recalc(int k) {
    while(k >>= 1)
      dat[k] = f(reflect(k << 1), reflect((k << 1) | 1));
  }
  // [a,b)
  void update(int a, int b, E newdata) {
    thrust(a += n);
    thrust(b += n - 1);
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) laz[l] = h(laz[l], newdata), l++;
      if(r & 1) --r, laz[r] = h(laz[r], newdata);
    }
    recalc(a);
    recalc(b);
  }

  void set_val(int k, T newdata) {
    thrust(k += n);
    dat[k] = newdata;
    laz[k] = eunit;
    recalc(k);
  }

  // [a,b)
  T query(int a, int b) {
    thrust(a += n);
    thrust(b += n - 1);
    T vl = tunit, vr = tunit;
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) vl = f(vl, reflect(l++));
      if(r & 1) vr = f(reflect(--r), vr);
    }
    return f(vl, vr);
  }
};

struct data {
  long long l, r, a;
};

long long n, m;
map<long long, vector<data>> mp;

long long solve();

int main() {
  cin >> n >> m;
  for(int i = 0; i < m; ++i) {
    long long l, r, a;
    cin >> l >> r >> a;
    --l;
    mp[r].push_back({l, r, a});
  }

  cout << solve() << endl;
  return 0;
}

long long solve() {
  auto f = [](long long l, long long r) {
    return max(l, r);
  };
  auto g = [](long long l, long long r) { return l + r; };
  auto h = [](long long l, long long r) { return l + r; };
  SegmentTreeLaze<long long, long long> dp(n, f, g, h, 0,
                                           0);
  for(int i = 0; i < n; ++i) {
    dp.update(i, i + 1, dp.query(0, i + 1));
    long long mpsize = mp[i + 1].size();
    for(int j = 0; j < mpsize; ++j)
      dp.update(mp[i + 1][j].l, i + 1, mp[i + 1][j].a);
  }
  return dp.query(0, n);
}


Measured memory_bytes: 30592
n=gets.to_i
m=Math::log10(n)
if m==5 then
  s=90909
elsif m>=4&&m<5 then
  s=n-9090
elsif m>=3&&m<4 then
  s=909
elsif m>=2&&m<3 then
  s=n-90
elsif m>=1&&m<2 then
  s=9
else
  s=n
end
  print s


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
    int ans=0;
    int min_val=10;
    for (int i = 0; i < 5; ++i) {
        int val;
        cin >> val;
        if (val%10==0) {
            ans += val;
        }
        else {
            min_val = min(min_val, val%10);
            ans += ((val + (10 - 1)) / 10)*10;
        }
    }
    ans -= 10;
    ans += min_val;
    cout << ans << endl;
    return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		double x1, y1, x2, y2;
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] coor = in.readLine().split(" ");
		x1 = Double.parseDouble(coor[0]);
		y1 = Double.parseDouble(coor[1]);
		x2 = Double.parseDouble(coor[2]);
		y2 = Double.parseDouble(coor[3]);
		System.out.println(Math.sqrt(Math.pow(Math.abs(x2 - x1), 2)
				+ Math.pow(Math.abs(y2 - y1), 2)));
	}
}

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

int lcs( char *X, char *Y, int m, int n ) 
{ 
	int L[m + 1][n + 1]; 
	for (int i = 0; i <= m; i++) 
	{ 
		for (int j = 0; j <= n; j++) 
		{ 
		if (i == 0 || j == 0) 
			L[i][j] = 0; 
	
		else if (X[i - 1] == Y[j - 1]) 
			L[i][j] = L[i - 1][j - 1] + 1; 
	
		else
			L[i][j] = max(L[i - 1][j], L[i][j - 1]); 
		} 
 } 
	
		
 
	int index =L[m][n];
  char lcsAlgo[index + 1];
  lcsAlgo[index] = '\0';

  int i = m, j = n;
  while (i > 0 && j > 0) {
    if (X[i - 1] == Y[j - 1]) {
      lcsAlgo[index - 1] = X[i - 1];
      i--;
      j--;
      index--;
    }

    else if (L[i - 1][j] > L[i][j - 1])
      i--;
    else
      j--;
  }
  
  cout << lcsAlgo << "\n";
 
}

int main() 
{ 
	char X[3000]; 
	char Y[3000];
	 
	cin>>X;
	cin>>Y;
	int m = strlen(X); 
	int n = strlen(Y); 
	
	
		lcs( X, Y, m, n ); 
	
	return 0; 
}  


Measured memory_bytes: 35456
import System.Exit
import Data.List
import Control.Applicative

main = do
    n <- rd <$> getLine
    case n of
        0.0 -> exitSuccess
        _   -> getLine >>= return . map rd . words >>= (\ds -> print $ solve ds n)
    main

solve :: [Double] -> Double -> Double
solve ds n = let m = (sum ds) / n
              in sqrt $ (sum (map (\d -> (d - m) ^ 2) ds)) / n

rd :: String -> Double
rd = read


Measured memory_bytes: 4872
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    int n, k; cin>>n>>k;
    vector<P> dt(n);
    for(int i=0; i<n; i++){
        int t, d; cin>>t>>d;
        t--;
        dt[i] = P(d, t);
    }
    sort(all(dt), greater<P>());

    vector<bool> ate(n, false);
    ll del = 0, kinds = 0;
    priority_queue<int, vector<int>, greater<int>> pque;
    for(int i=0; i<k; i++){
        int d, t; tie(d, t) = dt[i];
        del += d;
        if(!ate[t]){
            ate[t] = true;
            kinds++;
        }
        else{
            pque.emplace(d);
        }
    }

    ll ans = del + kinds * kinds;
    for(int i=k; i<n; i++){
        if(!pque.size()) break;

        int d, t; tie(d, t) = dt[i];
        if(ate[t]) continue;
        ate[t] = true;
        
        kinds++;
        del -= pque.top(); pque.pop();
        del += d;
        
        chmax(ans, del + kinds * kinds);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
// Aizu Vol-15 1500: ID
// 2017.9.4 bal4u@uu

#include <stdio.h>

char id[100003];
char a[10];
int t[10] = { 0,2,4,6,8,1,3,5,7,9 };
long long p[2][10];

int main()
{
	int n, m, i, j, d, x, k, k1, k2, even;

	scanf("%d%s%d", &n, id+1, &m);
	for (i = 0; i < m; i++) scanf("%d", &d), a[d] = 1;
	p[0][0] = 1, even = !(n & 1);
	for (k1 = 0, k2 = 1, i = 1; i <= n; i++, k1 = k2, k2 = !k2, even = !even) {
		for (j = 0; j < 10; j++) p[k2][j] = 0;
		if (id[i] == '*') {
			for (k = 0; k < 10; k++) {
				if (!a[k]) continue;
				d = even ? t[k] : k;
				for (j = 0; j < 10; j++) {
					if ((x = d + j) >= 10) x -= 10;
					p[k2][x] += p[k1][j];
				}
			}
		} else {
			k = id[i] - '0';
			d = even ? t[k] : k;
			for (j = 0; j < 10; j++) {
				if ((x = d + j) >= 10) x -= 10;
				p[k2][x] += p[k1][j];
			}
		}
	}
	printf("%lld\n", p[k1][0]);
	return 0;
}

Measured memory_bytes: 1820
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <string>
#include <tuple>

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

int main()
{
  int a, b;
  cin >> a >> b;
  if (a <= 5)
    cout << 0 << endl;
  else if (a <= 12)
    cout << b / 2 << endl;
  else
    cout << b << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<long long, int> P;
typedef pair<int, P> P2;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
struct BIT {
  int n;
  vector<int> xs;
  BIT (int n) : n(n) {
    xs.resize(n+1);
  }
  void add(int i, int v) {
    for (int x=i+1; x<=n; x+=x&-x) xs[x] += v;
  }
  int sum(int i) {
    int s = 0;
    for (int x=i+1; x>0; x-=x&-x) s += xs[x];
    return s;
  }
  int kth(int k) {
    int lo = -1, hi = n;
    while (hi - lo > 1) {
      int mid = (lo + hi) / 2;
      if (sum(mid) >= k) hi = mid;
      else lo = mid;
    }
    return hi;
  }
};


int N, Q;
long long A[100000];

vector<P> xs;
int z_index(P x) {
  int p = lower_bound(all(xs), x) - xs.begin();
  assert(xs[p] == x);
  return p;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> Q;
  vector<P2> qs;
  rep(i, N) xs.pb(P(0, -i));
  rep(i, Q) {
    int t;
    cin >> t;
    int x = 0, v = 0;
    cin >> x;

    if (t == 0) {
      cin >> v;
      x--;
      A[x] += v;
      xs.pb(P(A[x], -x));
    }
    qs.pb(P2(t, P(x, v)));
  }
  sort(all(xs));
  uniq(xs);
  BIT bit(xs.size());

  rep(i, N) A[i] = 0;
  rep(i, N) {
    bit.add(z_index(P(0, -i)), 1);
  }
  for (P2 q : qs) {
    int t = q._1, x = q._2._1;
    if (t == 0) {
      int v = q._2._2;
      int a = z_index(P(A[x], -x));
      bit.add(a, -1);
      A[x] += v;
      int b = z_index(P(A[x], -x));
      bit.add(b, 1);
    }
    else {
      int k = bit.kth(N-x+1);
      P p = xs[k];
      cout << -p._2+1 << " "<< p._1 << "\n";
    }
  }
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  if(s.at(2) == s.at(3) && s.at(4) == s.at(5)){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}
    
  

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

int main()
{
	int w, h, n, m = 0, px, py;

	cin >> w >> h >> n;

	cin >> px >> py;

	for (int i = 1; i < n; i++) {
		int x, y;

		cin >> x >> y;
		if ((x - px) * (y - py) > 0)
			m += max(abs(x - px), abs(y - py));
		else
			m += abs(x - px) + abs(y - py);

		px = x;
		py = y;
	}

	cout << m << endl;

	return 0;
}



Measured memory_bytes: 3100
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;

class Point
{
public:
	double x;
	double y;
	Point *prev;
	Point *next;
	Point();
	void MakePointS(Point *p1, Point *p2);
	void MakePointT(Point *p1, Point *p2);
	void MakePointU(Point *s, Point *t);
	void Output();
};

void Link(Point *p1, Point *p2)
{
	p1->next = p2;
	p2->prev = p1;
}

Point::Point()
{
	prev = NULL;
	next = NULL;
}

void Point::MakePointS(Point *p1, Point *p2)
{
	x = p1->x + (p2->x - p1->x) / 3;
	y = p1->y + (p2->y - p1->y) / 3;
	Link(p1, this);
}

void Point::MakePointT(Point *p1, Point *p2)
{
	x = p1->x + (p2->x - p1->x) * 2 / 3;
	y = p1->y + (p2->y - p1->y) * 2 / 3;
	Link(this, p2);
}

void Point::MakePointU(Point *s, Point *t)
{
	Point t0;
	t0.x = t->x - s->x;
	t0.y = t->y - s->y;
	Point t1;
	t1.x = t0.x * cos(M_PI / 3) - t0.y * sin(M_PI / 3);
	t1.y = t0.x * sin(M_PI / 3) + t0.y * cos(M_PI / 3);
	x = t1.x + s->x;
	y = t1.y + s->y;
	Link(s, this);
	Link(this, t);
}

void Point::Output()
{
	cout << fixed << x << " " << y << endl;
	if (next) {
		next->Output();
	}
}

void MakeKochCurve(int n, Point *p1, Point *p2)
{
	if (n <= 0) return;
	Point *s = new Point();
	s->MakePointS(p1, p2);
	Point *t = new Point();
	t->MakePointT(p1, p2);	
	Point *u = new Point();
	u->MakePointU(s, t);
	n--;
	MakeKochCurve(n, p1, s);
	MakeKochCurve(n, s, u);
	MakeKochCurve(n, u, t);
	MakeKochCurve(n, t, p2);
}

int main(void)
{
	//input
	int n;
	cin >> n;

	//KochCurve?
	Point p1;
	p1.x = 0;
	p1.y = 0;
	Point p2;
	p2.x = 100;
	p2.y = 0;
	Link(&p1, &p2);
	MakeKochCurve(n, &p1, &p2);

	//output
	p1.Output();

	return 0;
}


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

using namespace std;

typedef long long ll;

const int maxn = 1e5 + 10;
const int maxl = 18;

int main(){
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	ll answer = 0, tmp = 0;
	for (int i = 0; i < n; i++){
		if (s[i] == 'A')
			tmp ++;
		else{
			if (i < n - 1 and s[i] == 'B' and s[i + 1] == 'C'){
				answer += tmp;
				i ++;
			}
			else
				tmp = 0;
		}
	}
	cout << answer << endl;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
int main(){
    char a,b;
    cin>>a>>b;
    if(a=='H'&&b=='H')cout<<"H"<<endl;
    if(a=='H'&&b=='D')cout<<"D"<<endl;
    if(a=='D'&&b=='H')cout<<"D"<<endl;
    if(a=='D'&&b=='D')cout<<'H'<<endl;
}


Measured memory_bytes: 256
X, K, D = map(int, input().split())

ans = 0

if abs(X) > K*D:
    ans = abs(X) - K*D
else:
    k = abs(X)//D
    if (K-k)%2 == 0:
        ans = abs(X) - D*k
    else:
        ans = D - (abs(X) - D*k)

print(ans)

Measured memory_bytes: 9128
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val N = sc.nextInt
    val A = N / 1000
    val B = N / 100 % 10
    val C = N / 10 % 10
    val D = N % 10
    if (A + B + C + D == 7) {
      printf("%d+%d+%d+%d=7", A, B, C, D)
    } else if (A + B + C - D == 7) {
      printf("%d+%d+%d-%d=7", A, B, C, D)
    } else if (A + B - C + D == 7) {
      printf("%d+%d-%d+%d=7", A, B, C, D)
    } else if (A + B - C - D == 7) {
      printf("%d+%d-%d-%d=7", A, B, C, D)
    } else if (A - B + C + D == 7) {
      printf("%d-%d+%d+%d=7", A, B, C, D)
    } else if (A - B + C - D == 7) {
      printf("%d-%d+%d-%d=7", A, B, C, D)
    } else if (A - B - C + D == 7) {
      printf("%d-%d-%d+%d=7", A, B, C, D)
    } else if (A - B - C - D == 7) {
      printf("%d-%d-%d-%d=7", A, B, C, D)
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 27324
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] D = new int[10];
    for (int i = 0; i < K; i++) {
      D[sc.nextInt()] = 1;
    }
    
    int i = N;
    while(!isValid(i, D)) {
      i++;
    }
    System.out.println(i);
  }
  
  private static boolean isValid(int n, int[] D) {
    while (n != 0) {
      int a = n%10;
      n /= 10;
      if (D[a] == 1) {
        return false;
      }
    }
    return true;
  }
    
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <sstream>
#include <complex>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
#define ll long long
#define ull unsigned long long

const int MAXN = 100005;
const int INF = 0x3f3f3f3f;
const ll INFLL = 9223372036854775807;
const int MOD = 1e9 + 7;
const double PI=2.0*asin(1.0);

int A, B;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	
	while(cin>>A>>B){
		if(A%3==0 || B%3==0 || (A+B)%3==0) puts("Possible");
		else puts("Impossible");
	}
	
	
	return 0;
}


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

int main(){
  long int A, B, K;
  cin >> A >> B >> K;
  if (A - K >= 0) {
    cout << A - K << ' ' << B << '\n';
  } else if (A + B - K > 0) {
    cout << '0' << ' ' << A + B - K << '\n';
  } else {
    cout << '0' << ' ' << '0' << '\n';
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val d = sc.nextInt()
    val t = sc.nextInt()
    val s = sc.nextInt()
    if (t * s >= d) {
        println("Yes")
    } else {
        println("No")
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 34332
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
template<class T>
T gcd(T x, T y) {
	return y ? gcd(y, x % y) : x;
}

template<class T>
vector<T> enum_div(T n) {
	vector<T> ret;
	for (T i = 1; i * i < n; ++i) {

		if (n % i == 0) {
			ret.push_back(i);

			if (i != 1 && i * i != n) {
				ret.push_back(n / i);
			}
		}
	}
	return ret;
}

template<class T>
map<T, int> prime_factorization(T n) {
	map<T, int> ret;

	for (long long i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}

	if (n != 1)ret[n] = 1;
	return ret;
}

template<class T>
long long C(T n, T r) {
	static map<pair<T, T>, long long> _map;
	if (n < r) return 0;
	
	if (n == r || r == 0) {
		_map[make_pair(n, r)] = 1ll;
	}
	else if (_map[make_pair(n, r)] == 0) {
		_map[make_pair(n, r)] = (C(n - 1, r) + C(n - 1, r - 1));
	}

	_map[make_pair(n, r)] %= MOD;
	return _map[make_pair(n, r)];
}

int main() {
	int N, K;
	cin >> N >> K;
	
	for (int i = 1; i <= K; ++i) {
		//cout << C(K, i) << endl;;
		cout << (C(N - K + 1, i)) * (C(K - 1, i - 1)) % MOD << endl;
	}

	return 0;
}

Measured memory_bytes: 125568
#include <stdio.h>

int main(void) {
	char s[3][101];
	int pos[3] = {0};
	int turn = 0;

	scanf("%s %s %s", s[0], s[1], s[2]);

	while (1) {
		if (s[turn][pos[turn]])
			turn = s[turn][pos[turn]++] - 'a';
		else {
			printf("%c\n", 'A' + turn);
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll a[200010], ans;
bool visited[200010];
vector<int>node[200010];
queue<int>qu;
map<pair<int,int>, bool>taken;
int main()
{
    int i, j, v, u, edges, nodes;
    cin  >> nodes >> edges;
    for(i=1;i<=nodes;i++)
    {
        cin >> a[i];
        visited[i] = true;
    }
    for(i=1;i<=edges;i++)
    {
        cin >> u >> v;
        if(a[u]==a[v])
        {
            visited[u] = false;
            visited[v] = false;
        }
        else if(a[u]>a[v])
        {
            visited[v] = false;
        }
        else{
            visited[u] = false;
        }
    }
    for(i=1;i<=nodes;i++)
        ans += visited[i];
    cout << ans << endl;
    return 0;
}
/*8 9
1 2
1 3
2 5
2 4
4 5
5 6
6 8
6 7
3 7*/


Measured memory_bytes: 9208
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>

using namespace std;
#define vsort(v) sort(v.begin(), v.end());

long long memo[86];
bool reached[86];

long long ryuka(int N) {
	if(N == 0) return memo[0] = 2;
	if(N == 1) return memo[1] = 1;
	if(!reached[N]) {
		memo[N] = ryuka(N - 1) + ryuka(N - 2);
		reached[N] = true;
	}
	return memo[N];
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	for(int i = 0; i < 86; i++) reached[i] = false;
	cout << ryuka(N) << endl;
}


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

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    while (A > 0 && C > 0) {
        C -= B;
        A -= D;
    }
    if (C <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
N=int(input())
A=list(map(int, input().split()))
s=set([])
ans=[]
A.sort(reverse=True)
for a in A:
  if a not in s:
    s.add(a)
  else:
    ans.append(a)
    s.discard(a)
  if len(ans)>=2:
    break
if len(ans)<2:
  print(0)
else:
  print(ans[0]*ans[1])

Measured memory_bytes: 14224
#include <stdio.h>

int fib(int n,int *f)
{ 
  if(n==0 || n==1){
    return f[n]=1;
  }
  if(f[n]!=0){
  return f[n];
  }
  return f[n]=fib(n-2,f)+fib(n-1,f);
}

int main(){
  int n,i,f[45];
  
   for(i=0;i<45;i++){
    f[i]=0;
  }

  scanf("%d",&n);
  printf("%d\n",fib(n,f));

  return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <map>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,M;cin >> N;
    string s;
    map<string,int> m;
    REP(i,N) {
        cin >> s; ++m[s];
    }
    cin >> M;
    REP(i,M){
        cin >> s; --m[s];
    }
    int ans = 0;
    for(auto itr=m.begin();itr!=m.end();++itr){
        chmax(ans,itr->second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>
// #include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
// using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

typedef vector<int> vec;
typedef vector<vec> mat;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

long long dp[30005][1005];

int main(void) {
    int H, N; cin >> H >> N;
    vector<int> A(N+1);
    vector<int> B(N+1);
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        cin >> B[i];
    }

    long long inf = 10000000000;
    for (int i = 0; i < 30005; i++) {
        for (int j = 0; j < 1005; j++) {
            dp[i][j] = inf;
        }
    }
    dp[0][0] = 0;

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < 30005; j++) {
            int damage = A[i];
            int mp = B[i];
            if (j+damage >= 30005) continue;
            dp[j][i] = min(dp[j][i-1], dp[j][i]);
            dp[j+damage][i] = min(dp[j+damage][i], dp[j][i] + B[i]);
        }
    }
    int ans = inf;
    for (int i = 0; i < 1005; i++) {
        for (int j = 0; j < 30005; j++) {
            if (j >= H && ans > dp[j][i]) ans = dp[j][i];
        }
    }
    // for (int i = 0; i < 10; i++) {
    //     for (int j = 0; j < 30; j++) {
    //         if (dp[j][i] == inf) cout << "inf ";
    //         else cout << dp[j][i] << " ";
    //     }
    //     cout << endl;
    // }
    cout << ans << endl;
}

Measured memory_bytes: 235904
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return sorted 約数list 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(ALL(v));
  return v;
}


int main() {
    ll n,k;
    cin>>n;
    vector<pair<ll, ll>> m;
    rep(i, n){
        ll u;
        cin>>u;
        m.push_back({u,i+1});
    } 
    sort(ALL(m));
    for(auto it:m){
        cout<<it.second<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 2544
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main(){
    string s;
    cin >> s;
    bool v1 = true;
    bool v2 = true;
    int n = s.size();
    rep(i,n)if(s[i]!=s[n-i-1])v1=false;
    rep(i,(n-1)/2)if(s[i]!=s[((n-1)/2)-i-1])v2=false;
    cout << (v1 and v2 ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 3560