akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

typedef complex<double> P;

double cross(P a, P b){
	return a.real()*b.imag() - a.imag()*b.real();
}
int main(){
	double x1,y1,x2,y2,x3,y3,xp,yp; // a x b  = ax*by - ay*bx
	while(~scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)){
		P ta(x1,y1), tb(x2,y2), tc(x3,y3), td(xp,yp);

		double f1 = cross(ta-tb,td-tb);
		double f2 = cross(tb-tc,td-tc);
		double f3 = cross(tc-ta,td-ta);
		
		if( (f1+EPS<0.0 && f2+EPS<0.0 && f3+EPS<0.0) || (f1-EPS>0.0 && f2-EPS>0.0 && f3-EPS>0.0) ){
			puts("YES");
		}else{
			puts("NO");
		}

	}
	return 0;
}

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

int main() {
  int n;cin>>n;
  rep(i,n) {
  	char c;cin>>c;
    if(c=='Y') {
      cout<<"Four"<<endl;
      return 0;
    }
  }
  cout<<"Three"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define MAXN 2*100000+10
int a[MAXN];
int main() {
	int n;
	cin>>n;	
	for (int i=0;i<n;i++)
		cin>>a[i],a[i]-=i;
	sort(a,a+n);
	long long sum=0;
	for (int i=0;i<n;i++)
		sum+=abs(a[i]-a[n/2]);
	cout<<sum<<endl;
	return  0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;

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 pair<double,double> Pdd;

int main(){
    int N;
    while(cin >> N,N>0){
        vector<Pdd> pos(N);
        rep(i,N){
            double x,y;
            cin >> x >> y;
            pos[i]=Pdd(x,y);
        }
        int ans=1;
        rep(i,N){
            rep2(j,i+1,N){
                double x1=pos[i].first,y1=pos[i].second;
                double x2=pos[j].first,y2=pos[j].second;
                double dist=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
                if (dist>2.0){
                    continue;
                }
                else {
                    int count=2;
                    double halfd=dist/2.0;
                    double len=sqrt(1.0-halfd*halfd);
                    double cx=(x1+x2)/2.0,cy=(y1+y2)/2.0;
                    double dx=cx+(y2-y1)*len/dist;
                    double dy=cy-(x2-x1)*len/dist;
                    rep(k,N){
                        if (k==i||k==j){
                            continue;
                        }
                        double x=pos[k].first;
                        double y=pos[k].second;
                        if ((x-dx)*(x-dx)+(y-dy)*(y-dy)<=1.0){
                            count++;
                        }
                    }
                    chmax(ans,count);
                    count=2;
                    dx=cx-(y2-y1)*len/dist,dy=cy+(x2-x1)*len/dist;
                    rep(k,N){
                        if (k==i||k==j){
                            continue;
                        }
                        double x=pos[k].first;
                        double y=pos[k].second;
                        if ((x-dx)*(x-dx)+(y-dy)*(y-dy)<=1.0){
                            count++;
                        }
                    }
                    chmax(ans,count);
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3088
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long int ll;

ll *dp;
ll *a;
/*
ll solution(int s)
{

    if (dp[s] != 0)
    {
        return dp[s];
    }

    dp[s] += min(solution(s+1), (solution(s+2)));
    return dp[s];
}
*/
int main()
{
    int n,W;
    cin>>n>>W;
    ll w[n+1], v[n+1];
    ll dp[n+1][W+1];
    for(int i=1;i<=n;i++){
        cin>>w[i]>>v[i];
    }
    for(int i=0;i<=n;i++)
        dp[i][0] = 0;
    for(int i=0;i<=W;i++)
        dp[0][i] = 0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=W;j++){
            if(w[i]<=j)
                dp[i][j] = max(v[i] + dp[i-1][j - w[i]], dp[i-1][j]);
            else
                dp[i][j] = dp[i-1][j];

        }
    }
    cout<<dp[n][W]<<endl;
    return 0;
}


Measured memory_bytes: 82340
from sys import stdin, stdout
from collections import defaultdict
def readLine_int_list():return list(map(int, stdin.readline().split()))
def readLine_int_list_reverse(): return list(map(int, stdin.readline().split())).reverse()
def readAll_int(): return list(map(int, stdin))
def readLine_str_list():return list(map(str, stdin.readline().split()))
def readAll_str(): return list(map(str, stdin))


def main():
	n,k = readAll_int()
	ans = 1
	for i in range(n):
	    _k = ans + k
	    _d = ans * 2 
	    ans = min(_k, _d)

	print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	clock_t begin = clock();
	int n, m;
	cin >> n >> m;
	vector<int>v(100);
	for (int i = 1; i <= m; i++) {
		int a, b;
		cin >> a >> b;
		v[a]++;
		v[b]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << v[i] << endl;
	}
	clock_t end = clock();
	cerr << "Time run: " << (float)(end - begin) / CLOCKS_PER_SEC << " s" << endl;
}

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

int main(){
  string S;
  cin >> S;
  int max=0;
  int len=0;
  for(int i=0; i<S.size(); i++){
    if(S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T'){
      len++;
    }else{
      if(max<len){
        max=len;
      }
      len=0;
    }
  }
  if(max<len){
    max=len;
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

using namespace std;

inline int dist(int x1,int y1,int x2,int y2)
{
	if(y1>y2){
		swap(x1,x2);
		swap(y1,y2);
	}
	
	int dy=y2-y1;
	if(y1&1)
		return max(max(x2-x1-dy/2,x1-x2-(dy+1)/2),0)+dy;
	else
		return max(max(x2-x1-(dy+1)/2,x1-x2-dy/2),0)+dy;
}

int main()
{
	for(int w,h;scanf("%d%d",&w,&h),w;){
		int s; scanf("%d",&s);
		vector<int> xs(s),ys(s);
		for(int i=0;i<s;i++)
			scanf("%d%d",&xs[i],&ys[i]);
		int t; scanf("%d",&t);
		int res=0;
		while(t--){
			int x,y; scanf("%d%d",&x,&y);
			int tmp=0;
			for(int i=1;i<=h;i++){
				for(int j=1;j<=w;j++){
					int d=1<<29;
					for(int k=0;k<s;k++)
						d=min(d,dist(xs[k],ys[k],j,i));
					if(d>dist(x,y,j,i))
						tmp++;
				}
			}
			res=max(tmp,res);
		}
		printf("%d\n",res);
	}
	
	return 0;
}

Measured memory_bytes: 1032
#include <iostream>
#include <vector>
using namespace std;
int main(void){
   string S; cin >> S;
   int K; cin >> K;
   char ans = '1'; 
   for(int i=0; i < K; i++) {
       if(S[i] != '1') {
           ans = S[i];
           break;
        }
   }
   int res = ans - '0';
   cout << res << endl;
}

Measured memory_bytes: 256
import math
N, M = map(int, input().split())

x = math.factorial(N) * math.factorial(M)

if abs(N - M) >1:
    print(0)
elif (N + M) % 2 == 0:
    print(x * 2 % (10 ** 9 + 7))
else:
    print(x % (10 ** 9 + 7))

Measured memory_bytes: 5192
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int k = Integer.parseInt(sc.next());
		int n = Integer.parseInt(sc.next());
		
		int []a = new int [n];
		boolean []b = new boolean [200];
		
		for(int i = 0 ; i < n  ;i++) {
			a[i] = Integer.parseInt(sc.next());
		}

		Arrays.fill(b, false);
		
		int min = 1000000000;
		int ans = k;
		for(int i = 0 ; i < n  ;i++) {
			b[a[i]] = true;
		}
		
		for(int i = 0 ; i < 200 ;i++) {
			if(min > Math.abs(i-k) && !b[i]) {
				min = Math.abs(i-k);
				ans = i;
			}
		}
		
		System.out.println(ans);

	}
}


Measured memory_bytes: 35748
#include<bits/stdc++.h>
/*	#include <boost/math/common_factor.hpp>  boost::math::lcm(10,20) ---> use it to find lcm. fill_n(&an[0][0],n*m,0); typedef long long ll;*/
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define PI pair<int , int >
#define mpr make_pair
#define ff first
#define ss second
#define endl "\n"
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define FO(i,a,b) for(int i = (int)a;i < (int)b;++i)
#define FE(i,a,b) for(int i = (int)a;i <= (int)b;++i)
const int MOD = 1e9+7;
const int MAXN = 1e5+3;
const int inf = 2e9;
int max(int a,int b){	if(a > b)return a; else return b; }
int min(int a, int b){	if(a < b)return a; else return b; }
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
bool cmp(PI p1,PI p2){
	if(p1.ff < p2.ff)return true;	// You should not be writing p1.ss <= p2.ss !!!
	else if(p1.ff == p2.ff){ if(p1.ss < p2.ss)return true; return false; }
	return false;
}

void solve(){
	int n,k;
	cin >> n >> k;
	int a[n];
	FO(i,0,n)cin >> a[i];
	double s[n];
	s[0] = double(1+a[0])/2;
	FO(i,1,n){
		s[i] = s[i-1] + double(1+a[i])/2;
	}
	double ans = s[k-1];
	FO(i,k,n){
		ans = max(ans,s[i] - s[i-k]);
	}
	cout << ans << endl;
}

int32_t main(){
	IO;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif // ONLINE_JUDGE
	std::cout << std::setprecision(15); std::cout << std::fixed;
	int t; t = 1;
	// cin >> t;
	FE(i,1,t)
		solve();
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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 <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    for (ll d = 1; d * d <= m; d++) {
        if (m % d != 0) continue;
        if (m / d >= n) chmax(ans, d);
        if (d >= n) chmax(ans, m / d);
    }
    cout << ans << endl;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s, t;
    cin >> s >> t;

    int ret = 0;
    for (int i=0; i<s.length(); i++)
        ret += (s[i] != t[i]);

    cout << ret << "\n";

    return 0;
}


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

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

    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let h : u64 = read();
    let a : u64 = read();

    match h % a {
        0 => println!("{}", h/a),
        _ => println!("{}", h/a + 1),
    }
    
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int N;
    cin >> N;

    if (N==1){
        cout << "Hello World" << endl;
    }
    else{
        int A, B;
        cin >> A>>B;
        cout << A+B << endl; 
    }
   return 0;
}

Measured memory_bytes: 256
import math
n, s = [int(input()) for _ in range(2)]

def f(b,n):
    if n<b:
        return n
    elif n >= b:
        # // 少数切り捨ての割り算
        return f(b,(n//b)) + (n%b)

# nとsが同じであれば、n+1が答えであることは自明
# n==s==2の場合、bが2と仮定すると、
# 2進数で各桁の足し算を行うため、
# 2を2進数表記にすると10となる。
# 1+0 = 1となるため、偽

# n==s==2の場合、bが3と仮定すると、
# 3進数で各桁の足し算を行うため、
# 3を2進数表記にすると2となる。
# 2 = 2となるため、真
if n == s:
    print(n + 1)
    exit()
    
# 解がプラスであるときの計算
# 2～√nまでの計算
for b in range(2, int(math.sqrt(n))+1):
    if f(b,n) == s:
        print(b)
        exit()

# √n～0までの計算。-1づつする
for i in range(int(n**.5)+1,0,-1):
    b = (n-s)//i +1
    if b >1 and f(b,n) ==s:
            print(b)
            exit()

print(-1)


Measured memory_bytes: 44268
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n;
  scanf("%d",&n);
  string s, t;
  cin >> s >> t;
  vi a(n+1,INF);
  // vi cp(256,-1);
  // int mx = 0;
  // rep(i,n) {
  //   cp[s[i]] = i;
  //   int x = cp[t[i]];
  //   if (x < mx) dame;
  //   a[i] = x;
  //   mx = x;
  // }
  int si = n-1;
  drep(i,n) {
    while (si >= 0 && (si > i || s[si] != t[i])) --si;
    if (si == -1) dame;
    a[i] = si;
  }
  vi p;
  rep(i,n) if (a[i] != a[i+1]) p.pb(i);
  reverse(rng(p));
  int ans = 0;
  deque<int> q;
  for (int r : p) {
    int l = a[r];
    q.push_front(l);
    while (sz(q)) {
      int i = sz(q)-1;
      if (q[i]-i < r) break;
      q.pop_back();
    }
    maxs(ans,sz(q));
  }
  cout<<ans<<endl;
  return 0;
}































Measured memory_bytes: 14076
#!/usr/bin/env python3
import sys


def solve(N: int, K: int):
    ret = (N - (K - 1)) - 1
    if K == 1:
        ret = 0
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <set>
#include <numeric>
#include <vector>
#include <math.h>

using namespace std;

int main()
{
	int R, G, B, N;

	cin >> R >> G >> B >> N;

	int count = 0;

	for(int r = 0 ; r <= N/R ; r++)
	{
		for (int g = 0; g <= (N - r * R) / G; g++)
		{
			if ((N - r * R - g * G) % B == 0)
			{
				count++;
			}
		}

	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
class Calc:
    def __init__(self, max_value, mod):
        """combination(max_value, all)"""
        fact = [-1] * (max_value + 1)
        fact[0] = 1
        fact[1] = 1
        for x in range(2, max_value + 1):
            fact[x] = x * fact[x - 1] % mod

        invs = [1] * (max_value + 1)
        invs[max_value] = pow(fact[max_value], mod - 2, mod)
        for x in range(max_value - 1, 0, -1):
            invs[x] = invs[x + 1] * (x + 1) % mod

        self.fact = fact
        self.invs = invs
        self.mod = mod

    def nCr(self, n, r):
        r = min(n - r, r)
        if r < 0: return 0
        if r == 0: return 1
        if r == 1: return n
        return self.fact[n] * self.invs[r] * self.invs[n - r] % self.mod

    def nHr(self, n, r):
        return self.nCr(n - 1 + r, r)


def main():
    MOD = 10 ** 9 + 7

    N = int(input())
    A = map(int, input().split())

    B = [-1] * (N + 1)  # はじめて出現する位置(0-ind)
    d = None  # 重複要素の出現位置(2点)
    for i, x in enumerate(A):
        if ~B[x]:
            d = B[x], i
            break
        B[x] = i

    # 重複要素L,R(d[0],d[1]),一度だけ出現する数の列X,Y,Z(|X|>=0,|Y|>=0,|Z|>=0)
    # X...LY...RZ...
    # 重複計上: choose(N+1,K)
    # ここから重複分を差し引く
    # LRを含む個数
    # 0個: 重複計上なし
    # 1個: (X,L,YZ)と(XY,R,Z)が一致する場合に重複計上になる==(X,L/R,Z)
    # ->
    # #==sum(choose(X,a)*choose(Z,K-1-a)),(0<=a<=K-1)
    # 見方を変える
    # Yの区間以外からK個選ぶ
    # ただし,Yの区間外のうちLRから0個取るものと2個取るものを差し引く
    # 残りは(X,L/R,Z)を二重計上したものなので,半分にする
    # (choose(N+1-Y,K) - choose(N+1-2-Y,K) - choose(N+1-2-Y,K-2)) // 2
    # <editorial>
    # LRから1個,XZからK-1個取るchoose(XZ,K-1)=choose(N+1-2-Y,K-1)でよい
    # 2個: 重複計上なし

    calc = Calc(max_value=N + 1, mod=MOD)
    ans = []
    Y = d[1] - 1 - d[0]
    for k in range(1, N + 2):
        ans.append((calc.nCr(N + 1, k) - calc.nCr(N + 1 - 2 - Y, k - 1)) % MOD)

    print(*ans, sep='\n')


if __name__ == '__main__':
    main()


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

#define  quick  ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define s(x) sort(x.begin(),x.end())
#define sr(x) sort(x.begin(),x.end(),greater<ll>())
#define v1 vector<ll>
#define p1 pair<ll,ll>
#define m1 map<ll,ll>
#define ff first
#define ss second
#define ee '\n';
#define pb push_back
#define all(v) v.begin(),v.end()
#define f(i,x,y) for(i=x;i<y;i++)
#define mp make_pair
#define yes cout<<"YES"<<endl
#define no  cout<<"NO"<<endl


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

 int32_t main()
 {
    quick;
    ll t=1;
    //cin>>t;
    while(t--)
    {
       solve();
    }
    return 0;
 }

Measured memory_bytes: 3632
/*================= *\
|  ID : aman__guta__ |
|      LANG: C++     |
\*==================*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double 
#define pb push_back
#define mk make_pair
#define fs first
#define sc second 
#define mod 1000000007
#define sp <<" "<<
#define JOKER ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
int spf[10000001];
long long int fac[200005]; 
void sieve(int n)
{
    spf[1]=1;
    for(int i=2;i<=n;i++) spf[i]=i;
    for(int i=4;i<=n;i+=2) spf[i]=2;
    for(int i=3;i*i<=n;i++)
    {
        if(spf[i]==i)
        {
            for(int j=i*i;j<=n;j+=i)
            {
                if(spf[j]==j) spf[j]=i;
            }
        }
    }
}
long long int power(long long int x, long long int y, long long int p) 
{ 
    long long int res = 1;
    x = x % p;
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p; 
    } 
    return res; 
}
long long int modInverse(long long int n, long long int p) 
{ 
    return power(n, p-2, p); 
} 
long long int nCrModPFermat(long long int n, long long int r, long long int p) 
{ 
   if (r==0) 
      return 1; 
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}
int lps(string s)
{
    int n=s.size();
    int lps[n];
    lps[0]=0;
    int i=1;
    int j=0;
    while(i<n)
    {
        if(s[i]==s[j])
        {
            j++;
            lps[i]=j;
            i++;
        }
        else 
        {
            if(j)
            {
                j=lps[j-1];
            }
            else 
            {
                lps[i]=0;
                i++;
            }

        }
    }
    return min(n/2,lps[n-1]);
}
main()  
{
    JOKER
    int k,n;
    cin>>k>>n;
    int a[n];
    for(int i=0; i<n; i++)
        cin>>a[i];
    int ans=k-a[n-1]+a[0];
    for(int i=1; i<n; i++)
    {
        ans=max(ans,a[i]-a[i-1]);
    }
    cout<<k-ans<<endl;
    cerr<<"Time elapsed : "<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<'\n'; 
    return 0;
} 



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

using namespace std;

#define MAXN 412
#define db(x) cerr << #x << " = " << x << endl;
#define ll long long
#define INF 0x3f3f3f3f3f3f3f3f

int N;
ll vals[MAXN];
int vis[MAXN][MAXN];
ll dp[MAXN][MAXN];

ll sum(int l, int r)
{
	ll result = 0;
	
	for (int i = l; i <= r; i++)
	{
		result += vals[i];
	}
	
	return result;
}


ll solve(int l, int r)
{
	if (r == l)
	{
		return 0;
	}
	
	if (vis[l][r])
	{
		return dp[l][r];
	}
	vis[l][r] = 1;
	
	ll res = INF;
	ll s = sum(l, r);
	for (int i = l; i < r; i++)
	{
		ll left = solve(l, i);
		ll right = solve(i + 1, r);
		ll new_cost = left + right + s;
		
		if (new_cost < res)
		{
			res = new_cost;
		}
	}
	
	dp[l][r] = res;
	return res;
}

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
	{
		scanf("%lld", &vals[i]);
	}
	
	printf("%lld\n", solve(0, N - 1));
}


Measured memory_bytes: 2176
#include <cstdio>
long long a,b,c,d,i,j,k,x,y,z,ans;
int main(){
	ans=0;
	scanf("%lld %lld",&a,&b);
	for (i=0;i<=a;i++){
		x=i;
		c=b-x;
		if ((c>=0) and (c<=a)){
			ans+=c+1;
		}
		if ((c>a) and (c<=2*a)){
			ans+=2*a-c+1;
		} 
	}
	printf("%lld\n",ans);
}

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

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

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

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

    int n;
    cin >> n;
    
    unordered_map<int, int> mp;
    REP(i, n){
        int p;
        cin >> p;
        if(mp[p - 1]) mp[p] = mp[p - 1] + 1;
        else mp[p] = 1;
    }

    int maxi = 0;
    for(auto x : mp) maxi = max(maxi, x.second);
    
    cout << n - maxi << endl;

    return 0;
}

Measured memory_bytes: 8520
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG
#define bigger (char)toupper
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    string s,t,u;
    cin>>s>>t>>u;
    cout<<(char)toupper(s[0])<<(char)toupper(t[0])<<(char)toupper(u[0])<<endl;
}

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

int main() {
		int i, j, n;
		cin >> n;
		int ans[3];
		for (i = 0; i < 3; i++) {
			ans[i] = n % 10;
			n /= 10;
			if (ans[i] == 1) {
				ans[i] = 9;
			} else {
				ans[i] = 1;
			}
		}
		cout << ans[2] << ans[1] << ans[0] <<endl;
		return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  cout.precision(12);
  
  long N;
  cin >> N;

  map<string, vector<pair<long, long>>> mp;

  rep (i, N) {
    string foo;
    long bar;
    cin >> foo >> bar;
    mp[foo].push_back(make_pair(bar, i+1));
  }

  for (auto it: mp) {
    sort(mp[it.first].rbegin(), mp[it.first].rend());
    for (auto it2: mp[it.first]) cout << it2.second << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#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 ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0) 
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n,m,a,b,c,d,x,y,z;
  string s,t;
  //

  // ここから
  IN3(a,b,c);
  REP(i,10){
    OUT(a*c-b);
    c = a*c-b;
  }
}

Measured memory_bytes: 256
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define int long long
   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; }
    const int MAX =1002;
const int MOD =1000000007;

signed main(){
  int n,y;
  cin>>n>>y;y/=1000;
  for(int i=0;i<=n;i++)for(int j=0;j+i<=n;j++)if(i+5*j+10*(n-i-j)==y){
    cout<<n-i-j<<' '<<j<<' '<<i<<endl;
    return 0;
  }
  cout<<-1<<' '<<-1<<' '<<-1<<endl;
}

Measured memory_bytes: 3636
//problem_a.go

package main

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

const (
	mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

// -----------------------------------------

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getIntSlice(n int) []int {
	ns := []int{}
	for i := 0; i < n; i++ {
		ns = append(ns, getInt())
	}
	return ns
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func getStringSlice(n int) []string {
	ss := []string{}
	for i := 0; i < n; i++ {
		ss = append(ss, getString())
	}
	return ss
}

func sortIntSlice(ns []int) []int {
	sort.Sort(sort.IntSlice(ns))
	return ns
}

func rsortIntSlice(ns []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(ns)))
	return ns
}

// -----------------------------------------

func solve() {
	s, t := getString(), getString()
	a, b := getInt(), getInt()
	u := getString()

	println("[DEBUG]", s, t)

	if u == s {
		fmt.Fprintln(wr, a-1, b)
	} else if u == t {
		fmt.Fprintln(wr, a, b-1)
	}
}

// -----------------------------------------

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}


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

bool isNumber( char c )
{
    return c >= '0' && c <= '9';
}

int main( void )
{
    string dp[71][71];
    int W, H;

    while ( true )
    {
        cin >> W >> H;
        if ( W == 0 && H == 0 ) break;

        string C[70];
        for ( int i = 0; i < H; i++ )
        {
            cin >> C[i];
        }

        for ( int i = 0; i < H; i++ ) for ( int j = 0; j < W; j++ ) dp[i][j] = "";

        for ( int i = 0; i < H; i++ )
        {
            for ( int j = 0; j < W; j++ )
            {
                if ( isNumber( C[i][j] ) == false )
                {
                    dp[i][j] = "";
                    continue;
                }
                if ( i == 0 && j == 0 )
                {
                    dp[i][j] = C[i][j];
                }
                else if ( i == 0 )
                {
                    dp[i][j] = dp[i][j-1] + C[i][j];
                }
                else if ( j == 0 )
                {
                    dp[i][j] = dp[i-1][j] + C[i][j];
                }
                else
                {
                    if ( dp[i-1][j].size() > dp[i][j-1].size() )
                    {
                        dp[i][j] = dp[i-1][j] + C[i][j];
                    }
                    else if ( dp[i-1][j].size() < dp[i][j-1].size() )
                    {
                        dp[i][j] = dp[i][j-1] + C[i][j];
                    }
                    else if ( dp[i-1][j] > dp[i][j-1] )
                    {
                        dp[i][j] = dp[i-1][j] + C[i][j];
                    }
                    else
                    {
                        dp[i][j] = dp[i][j-1] + C[i][j];
                    }
                }
            }
        }

        string answer = "";
        for ( int i = 0; i < H; i++ )
        {
            for ( int j = 0; j < W; j++ )
            {
                while ( dp[i][j][0] == '0' ) dp[i][j] = dp[i][j].substr( 1 );

                if ( dp[i][j].size() > answer.size() )
                {
                    answer = dp[i][j];
                }
                else if ( dp[i][j].size() == answer.size() && dp[i][j] > answer )
                {
                    answer = dp[i][j];
                }
            }
        }

        cout << answer << endl;
    }

    return 0;
}

Measured memory_bytes: 1064
import math 
def primeFactors(n): 
    l=[]  
    while n % 2 == 0: 
        l.append(2)
        n = n / 2
    for i in range(3,int(math.sqrt(n))+1,2): 
        while n % i== 0: 
            l.append(int(i))
            n = n / i 
    if n > 2: 
        l.append(int(n))
    return l
n=int(input())
l=primeFactors(n)
l.sort()
s=set(l)
d={}
for i in s:
    d[i]=0
for i in l:
    d[i]=d[i]+1
ans=0
for i,j in d.items():
    c=0
    while j>0:
        if j>=c+1:
            c=c+1
        j=j-c
    ans=ans+c
print(ans)

Measured memory_bytes: 9308
package main

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

func main() {
  io := IO{bufio.NewReaderSize(os.Stdin,100),bufio.NewWriterSize(os.Stdout,100)}
  n,u,v := io.Next3Ints()
  u,v = u-1,v-1
  g := make([][]int,n)
  for i:=0;i<n-1;i++ {
    a,b := io.Next2Ints()
    a,b = a-1,b-1
    g[a] = append(g[a],b)
    g[b] = append(g[b],a)
  }
  lca := NewLca(g)
  x := 0
  for i:=0;i<n;i++ {
    if len(g[i]) > 1 { continue }
    du := lca.Distance(u,i)
    dv := lca.Distance(v,i)
    if du < dv && x < dv { x = dv }
  }
  fmt.Println(x-1)
}

type Lca struct { g [][]int;par [][]int;depth []int }
func NewLca(g [][]int) Lca {
  k := 0
  n := len(g)
  for (1<<uint(k)) < n { k++ }
  par := make([][]int,k)
  for i:=0;i<k;i++ { par[i] = make([]int,n) }
  depth := make([]int,n)
  lca := Lca{g,par,depth}
  lca.Par()
  return lca
}
func(l Lca) Dfs(v,p,d int) {
  l.par[0][v] = p
  l.depth[v] = d
  for _,u := range l.g[v] {
    if u != p { l.Dfs(u,v,d+1) }
  }
}
func(l Lca) Par() {
  l.Dfs(0,-1,0)
  n := len(l.depth)
  for k:=0;k<len(l.par)-1;k++ {
    for i:=0;i<n;i++ {
      if l.par[k][i] < 0 { l.par[k+1][i] = -1;continue }
      l.par[k+1][i] = l.par[k][l.par[k][i]]
    }
  }
}
func(l Lca) Distance(x,y int) int {
  return l.depth[x]+l.depth[y]-2*l.depth[l.Of(x,y)]
}
func(l Lca) Of(x,y int) int {
  if l.depth[x] > l.depth[y] { x,y = y,x }
  for k:=0;k<len(l.par);k++ {
    if ((l.depth[y]-l.depth[x])>>uint(k))&1 == 1 {
      y = l.par[k][y]
    }
  }
  if x == y { return x }
  for k:=len(l.par)-1;k>-1;k-- {
    if l.par[k][x] != l.par[k][y] {
      x,y = l.par[k][x],l.par[k][y]
    }
  }
  return l.par[0][x]
}

type IO struct {
  reader *bufio.Reader
  writer *bufio.Writer
}
func(io *IO) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := io.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(io *IO) Println(a ...interface{}) (int,error) {
  return fmt.Fprintln(io.writer,a...)
}
func(io *IO) Flush() error {
  return io.writer.Flush()
}
func(io *IO) Next2Ints() (int,int) {
  s := strings.Fields(io.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  return x,y
}
func(io *IO) Next3Ints() (int,int,int) {
  s := strings.Fields(io.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  z,_ := strconv.Atoi(s[2])
  return x,y,z
}

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


int main(){
    int N;
    cin >> N;
    bool ans=false;
    for(int i=1; i<=9; i++){
        for(int j=0; j<=9; j++){
            if(i*j==N){
                ans=true;
            }
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include<iostream>	// 入出力
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;


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

	vector<int> s(n);
	int value = 0;

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

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

	if (value % 10 == 0)
	{
		for (int i = 0; i < n; ++i) {
			if (s[i] % 10 == 0) {
				continue;
			}
			cout << value - s[i] << endl;
			return 0;
		}
		cout << 0 << endl;
		return 0;
	}

	cout << value << endl;

	return 0;
}

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

int P[10010];
void init(int N){
  for (int i=0; i<N; i++) P[i] = i;
}
int root (int a){
  if (P[a] == a) return a;
  else {
    P[a] = root(P[a]);
    return P[a];
  }
}
bool is_same_set(int a, int b){
  return root(a) == root(b);
}
void unite(int a, int b){
  P[root(a)] = root(b);
}

int main(){
  int N;
  cin >> N;
  pair <int, int> edge[10010];
  for (int i=0; i<N; i++){
    for (int j=0; j<N; j++){
      cin >> edge[i*N+j].first;
      edge[i*N+j].second = i*N+j;
    }
  }
  sort(edge, edge+N*N);
  init(N);
  int ans = 0;
  int b = 0;
  for (int k=0; k<N*N; k++){
    while(edge[k].first < 0) k++;
    int i = edge[k].second / N;
    int j = edge[k].second % N;
    if (is_same_set(i,j)){}
    else{
      unite(i,j);
      ans += edge[k].first;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1240
lines = readlines
n = lines.shift.chomp.to_i
ab = lines.map{|line| line.chomp.split(' ').map{|x| x.to_i}}

ab.sort_by!{|x| [-(x[0] + x[1]), -x[0]]}

taka = 0
aoki = 0
(0...n).each do |i|
  s = ab.shift
  if i % 2 == 0
    taka += s[0]
  else
    aoki += s[1]
  end
end

puts taka - aoki

Measured memory_bytes: 19688
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N;
  cin >> N;
  vector<i64> A(N);
  for (i64 i = 0; i < N; i++)
    cin >> A[i];
  sort(A.begin(), A.end());
  i64 ans = A[0];
  for (i64 i = 1; i < N; i++)
  {
    if (ans != 0 && (i64)1e18 / ans < A[i])
    {
      cout << -1 << endl;
      return 0;
    }
    ans *= A[i];
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int sum = 0;
  int i = 0;
  for (; i < B-A+1;) {
    int a, b, c, d, e;
    a=(A+i)/10000;
    b=(A+i)%10000/1000;
    c=(A+i)%10000%1000/100;
    d=(A+i)%10000%1000%100/10;
    e=(A+i)%10000%1000%100%10;
    if (a == e && b==d)
      sum++;
    i++;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned ll
#define F first                                                                                         
#define S second
#define mp make_pair
#define pb push_back
#define y1 variable
#define matrix vector<vector<double> > 

using namespace std;

const int MIN = 1e3 + 2;                                                                                                                                   
const int MXN = 1e6 + 3;
const int INF = 1e9 + 7;                                                                                                       
const int base = 1e9;
const ll LINF = 1e18 + 15;
const double EPS = 1e-12;

string st;
bool used[27];
int id = -1;
char ch;

int main(){
    #ifdef Pissoir
		//freopen("input.txt", "r", stdin);                                                                                                              
		//freopen("output.txt", "w", stdout);                       
	#else
		ios_base::sync_with_stdio(0);
		cin.tie(0);             
		cout.tie(0);                                                                                         
		//freopen("twopaths.in", "r", stdin);
  		//freopen("twopaths.out", "w", stdout);			
    #endif
	cin >> st;
	if (st.size() == 26){
     	for (int i = 0; i < st.size(); ++i){
     		for (char j = st[i] + 1; j <= 'z'; ++j){
     			if (!used[j - 'a']){
     				id = i;
     				ch = j;
     				break;	
     			}
     		}
     		used[st[i] - 'a'] = 1;
     	}	
     	if (id == -1){
     		cout << id;
     		return 0;
     	}
     	memset(used, 0, sizeof(used));
     	for (int i = 0; i < id; ++i){
     		cout << st[i];
     		used[st[i] - 'a'] = 1;
     	}                                                        
     	cout << ch;      
   	}
	else {
		cout << st;
		for (int i = 0; i < st.size(); ++i){
			used[st[i] - 'a'] = 1;
		}
		for (char i = 'a'; i <= 'z'; ++i){
			if (!used[i - 'a']){
				cout << i;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(void){
  double xa,ya,ra,xb,yb,rb;
  double x,y,d,ab_d;
  int n,i;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%lf%lf%lf%lf%lf%lf",&xa,&ya,&ra,&xb,&yb,&rb);
    x=xb-xa;
    y=yb-ya;
    d=x*x+y*y;
    d=sqrt(d);
    
    //    printf("%f\n",d);

    if(d>ra+rb)
      puts("0");
    else if(d==ra+rb)
      puts("1");
    ab_d=ra-rb;
    if(ab_d<0)
      ab_d=-ab_d;
    //    printf("%f\n",ab_d);
    if(ab_d<d && d<ra+rb)
      puts("1");
    else if(d==ab_d)
      puts("1");
    else if(d<ab_d){
      if(ra>rb)
	puts("2");
      else
	puts("-2");
    }
  }
  return 0;
}

Measured memory_bytes: 0
io = STDIN
a,b=io.gets.chomp.split.map(&:to_i)
#        -1  0  1
#      a  b
#         a     b
#               a     b
if b<0
  ans = (a..b).size.odd? ? "Negative" : "Positive"
else  #b>=0
  if a<=0
    ans = "Zero"
  else   #
    ans = "Positive"
  end
end
puts ans


Measured memory_bytes: 1788
import Control.Monad
import Data.List

readInts = map read . words <$> getLine :: IO [Int]

f h ds = g 0 h th
  where
    sw = maximum $ map head ds
    th = sort $ filter (<negate sw) $ map (negate . head . tail) ds
    g t r [] = t +div (r + sw - 1) sw
    g t r (x:xs)
      | r+x<=0 = t+1
      | otherwise = g (t+1) (r+x) xs

main = readInts >>= \[n, h] -> f h <$> replicateM n readInts >>= print

Measured memory_bytes: 173436
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
 
int A[30];
 
bool judge(int i,int m){
	if(m==0) return true;
	if(i==0) {
		if(m==A[0]) return true;
		else return false;
	}
	if(judge(i-1,m)) return true;
	else if(judge(i-1,m-A[i])) return true;
	return false;
}
 
int main (){
	int n,q,m;
	cin>>n;
	for(int i = 0;i<n;i++) cin>>A[i];
	cin>>q;
	for(int i = 0;i<q;i++) {
		cin>>m;
		if(judge(n,m)) cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
	return 0;
	
}



Measured memory_bytes: 3104
using System;

namespace pro
{
    class MainClass
    {
        public static void Main()
        {
            string[] str1 = Console.ReadLine().Split(' ');
            int n = int.Parse(str1[0]);
            long k = int.Parse(str1[1]);
            int[] a = new int[n];
            string[] str2 = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(str2[i]);
            }


            int count = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    if (a[i] > a[j])
                    {
                        count++;
                    }
                }
            }
            int count1 = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    if (a[i] > a[j])
                    {
                        count1++;
                    }
                }
            }
            long sum = 0;
            checked
            {
                sum = count * ((k * k - k)/2%(long)(Math.Pow(10, 9) + 7)) ;
                sum = (sum + count1 * k % (long)(Math.Pow(10, 9) + 7)) % (long)(Math.Pow(10, 9) + 7);
                Console.WriteLine(sum);
            }


        }
    }

}

Measured memory_bytes: 13152
cnt = [0]*(10**5+1)
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
for i in range(n):
    cnt[a[i]] += 1
q = int(input())
for i in range(q):
    b,c = map(int,input().split())
    s += (c-b)*cnt[b]
    cnt[c] += cnt[b]
    cnt[b] = 0
    print(s)

Measured memory_bytes: 84196
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

int main(int argc, char* argv[]) {
	int a, b, ans = -1;
	cin >> a >> b;
	for (int p = 2; p <= 10000; ++p) {
		if ((int)(p * 0.08) == a && (int)(p * 0.1) == b) {
			ans = p;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

const ll INF = 1e9+7;

// 各桁の和
template<typename T>
T digit(T num){
  T sum = 0;
  while(num){
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

template<typename T>T gcd(T a,T b){
  if(b == 0)
    return a;
  return gcd(b,a%b);
}
template<typename T>T lcm(T a, T b){
  T g = gcd(a,b);
  return a/g*b; 
}

int main(){
  int n;cin>>n;
  int ans = -n;
  rep(i,n){
    int tmp;cin>>tmp;
    ans+=tmp;
  }
  print(ans)
  return 0;
}


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; -i)
#define INF (1 << 20)
#define MOD 1000000007

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

int N, M, K;
int a, b, Cost, Time;
int tTime[101][101];
int tCost[101][101];

int main() {
	while(scanf("%d %d", &N, &M), N||M) {
		FOR(i, 1, M + 1) FOR(j, 1, M + 1) {
			tTime[i][j] = 1000000;
			tCost[i][j] = 1000000;
		}
		rep(i, N) {
			scanf("%d %d %d %d", &a, &b, &Cost, &Time);
			tTime[a][b] = tTime[b][a] = Time;
			tCost[a][b] = tCost[b][a] = Cost;
		}
		FOR(i, 1, M + 1) FOR(j, 1, M + 1) FOR(k, 1, M + 1) {
			tTime[j][k] = min(tTime[j][k], tTime[j][i] + tTime[i][k]);
			tCost[j][k] = min(tCost[j][k], tCost[j][i] + tCost[i][k]);
		}
		scanf("%d", &K);
		rep(i, K) {
			int p, q, r;
			scanf("%d %d %d", &p, &q, &r);
			printf("%d\n", (r) ? tTime[p][q] : tCost[p][q]);
		}
	}
	return 0;
}

Measured memory_bytes: 3144
def divisors(n):
    res=int(10e+14)
    for i in range(1,int(n**0.5)+1):
        if(n%i==0):
            tmp=max(len(str(i)),len(str(n//i)))
            res=min(res,tmp)
    return res

N=int(input())
print(divisors(N))

Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-10;

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}

ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};
// ll pas[5001][5002];

class SCC {
  private:
	int n;
	vector<bool> used;
	vector<vector<int>> G, rG;

	void dfs(int v) {
		used[v] = true;
		for (int i = 0; i < G[v].size(); i++) {
			if (!used[G[v][i]]) dfs(G[v][i]);
		}
		vs.push_back(v);
	}
	void rdfs(int v, int k) {
		used[v] = true;
		cmp[v]  = k;
		for (int i = 0; i < rG[v].size(); i++) {
			if (!used[rG[v][i]]) rdfs(rG[v][i], k);
		}
	}

  public:
	vector<int> vs, cmp;
	SCC(int n) : n(n) {
		used.resize(n, false);
		G.resize(n);
		rG.resize(n);
		cmp.resize(n);
	}
	void add_edge(int u, int v) {
		G[u].push_back(v);
		rG[v].push_back(u);
	}
	int scc() {
		fill(used.begin(), used.end(), false);
		vs.clear();
		for (int i = 0; i < n; i++) {
			if (!used[i]) dfs(i);
		}
		int k = 0;
		fill(used.begin(), used.end(), false);
		for (int i = vs.size() - 1; i >= 0; i--) {
			if (!used[vs[i]]) rdfs(vs[i], k++);
		}
		return k;
	}
};

int main() {
	IOS();
	ll v, e;
	cin >> v >> e;
	SCC s(v);
	for (int i = 0; i < e; i++) {
		int a, b;
		cin >> a >> b;
		s.add_edge(a, b);
	}
	s.scc();

	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int a, b;
		cin >> a >> b;
		dump(s.cmp[a] == s.cmp[b] ? 1 : 0);
	}
	return 0;
}


Measured memory_bytes: 4464