akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu ()
{
    cerr << endl;
}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}

void f()
{
    ll n,cnt=0;
    cin>>n;
    ll a[n+1];
    lo(i,0,n)
    cin>>a[i];
    lo(i,1,n)
    {
        if(a[i]<=a[i-1])
        {
            cnt+=(a[i-1]-a[i]);
            ///dbg(cnt);
            a[i]=a[i-1];
        }
    }
    cout<<cnt<<nl;
}

int main()
{
    su;
    ///tt
    f();
    return 0;
}


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

using namespace std;

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

int n , m , a[200011],x,y,freq[200011],cov[200011],
it[200011];

int main() {
	//freopen("input.txt", "r", stdin);
	scanf("%d%d",&n,&m);
	for (int i = 1; i <= n; ++i){
		it[i] = i;
		scanf("%d",&a[i]);
		freq[a[i]]++;
	}
	for(int i = 0 ; i <= n ; i++){
		it[i] = i - freq[i];
		for(int j = i-1 ; j >= max(0,it[i]);j--){
			cov[j]++;
		}
	}
	int cnt = 0;
	for(int i = 0 ; i < n ; i++){
		if(cov[i])
			cnt++;
	}
	for (int i = 0; i < m; ++i){
		scanf("%d%d",&x,&y);
		if(it[a[x]] >= 0){
			cov[it[a[x]]]--;
			if(cov[it[a[x]]] == 0)
				cnt--;
		}
		it[a[x]]++;
		a[x] = y;
		it[a[x]]--;
		if(it[a[x]] >= 0){
			cov[it[a[x]]]++;
			if(cov[it[a[x]]] == 1)
				cnt++;
		}
		printf("%d\n",n-cnt );
	}
	return 0;
}

Measured memory_bytes: 4608
import java.math.*;
import java.io.*;


class Main
{
    
    public static void main(String args[])throws IOException
    {
	BigInteger a = new BigInteger("1");
	for(int i=2;i<=1501;i++)
	    a = a.multiply(new BigInteger(Integer.toString(i)));
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));   
	a = a.add(new BigInteger("2"));
	int n = Integer.parseInt(in.readLine());
	System.out.println(a);
	for(int i=2;i<n+2;i++)
	    System.out.println(i);

    }

}

Measured memory_bytes: 26276
#include <stdio.h>
#include <string.h>
#include <ctype.h>
 
int main() {
  int x;
  scanf("%d%*c", &x);
  if (x < 1200) {
    printf("ABC\n");
  } else {
    printf("ARC\n");
  }
  return 0;
}



Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
int main(){
  long long int a,b,n,x,ans=0;
  scanf("%lld %lld %lld",&a,&b,&n);
  if(b-1<=n){
  x=b-1;
  }else{
  x=n;
  }
  ans=(floor(a*x/b)-a*floor(x/b));
  printf("%lld",ans);
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, T;
    cin >> n >> T;
    vi t(n);
    rep(i, n) {
        cin >> t[i];
    }
    int now = 0;
    int cnt = 0;
    rep(i, n) {
        if (i == 0) {
            now = T;
        } else {
            if (now < t[i]) {
                cnt += t[i] - now;
            }
            now = t[i] + T;
        }
    }
    int ans = t[n-1] + T - cnt;
    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String str = sc.next();
	boolean isKeyence = str.matches(".*keyence")
	    || str.matches("k.*eyence")
	    || str.matches("ke.*yence")
	    || str.matches("key.*ence")
	    || str.matches("keye.*nce")
	    || str.matches("keyen.*ce")
	    || str.matches("keyenc.*e")
	    || str.matches("keyence.*");
	if(isKeyence) {
	    System.out.println("YES");
	}else {
	    System.out.println("NO");
	}
    }
}

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

using namespace std;
using ll = long long;

int main()
{
	ll n, d, x, y, c = 0;
	cin >> n >> d;
	for (ll i = 0; i < n; ++i)
	{
		cin >> x >> y;
		if (sqrt(x*x + y*y) <= d)
			c++;
	}
	cout << c << endl;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;cin>>s;
    int q;cin>>q;
    int rev = 0;
    string pre = "", suf = "";
    for(int i=0; i<q; i++){
        int t;cin>>t;
        if(t==1)rev++;
        else{
            int f;cin>>f;
            char c;cin>>c;
            if(rev%2==1)f=3-f;
            if(f==1)pre.push_back(c);
            else suf.push_back(c);
        }
    }
    if(rev%2==1)reverse(s.begin(),s.end());
    if(rev%2==0){
        reverse(pre.begin(), pre.end());
        cout<<pre+s+suf<<endl;
    }
    else {
        reverse(suf.begin(), suf.end());
        cout<<suf+s+pre<<endl;
    }

    return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int A[20];

void solve() {
	int a, b, c; cin >> a >> b >> c;
	A[a]++; A[b]++; A[c]++;
	if(A[5] == 2 && A[7] == 1) cout << "YES\n";
	else cout << "NO\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 384
#include <stdio.h>
int main(){
    int str[200000],max,min;
    int j,i,n;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&str[i]);
    min=str[0];
    max=str[1]-str[0];
    for(j=1;j<n;j++){
        if(max<str[j]-min)
            max=str[j]-min;
        
        if(min>str[j])
            min=str[j];
    }
    printf("%d\n",max);
    
    return 0;
}

Measured memory_bytes: 1376
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

base = 0
diff = 0
for i in range(N):
    for j in range(i + 1, N):
        if A[i] > A[j]:
            base += 1
    for j in range(N):
        if A[i] > A[j]:
            diff += 1

MOD = 1000000007
result = base * K + (diff * K * (K - 1) // 2)
result %= MOD
print(result)


Measured memory_bytes: 3188
using System;    
	namespace AtCoder190810_A
    {
        class Program
        {
            static void Main()
            {
                string[] input = Console.ReadLine().Split();
              	int a = int.Parse(input[0]);
              	int b = int.Parse(input[1]);
              
              	Console.WriteLine($"{Math.Max(a+b, Math.Max(a-b, a*b))}");
            }
        }
    }

Measured memory_bytes: 13140
# Manhattan Distance
distance = (
    (),
    (0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6),
    (1, 0, 1, 2, 2, 1, 2, 3, 3, 2, 3, 4, 4, 3, 4, 5),
    (2, 1, 0, 1, 3, 2, 1, 2, 4, 3, 2, 3, 5, 4, 3, 4),
    (3, 2, 1, 0, 4, 3, 2, 1, 5, 4, 3, 2, 6, 5, 4, 3),
    (1, 2, 3, 4, 0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5),
    (2, 1, 2, 3, 1, 0, 1, 2, 2, 1, 2, 3, 3, 2, 3, 4),
    (3, 2, 1, 2, 2, 1, 0, 1, 3, 2, 1, 2, 4, 3, 2, 3),
    (4, 3, 2, 1, 3, 2, 1, 0, 4, 3, 2, 1, 5, 4, 3, 2),
    (2, 3, 4, 5, 1, 2, 3, 4, 0, 1, 2, 3, 1, 2, 3, 4),
    (3, 2, 3, 4, 2, 1, 2, 3, 1, 0, 1, 2, 2, 1, 2, 3),
    (4, 3, 2, 3, 3, 2, 1, 2, 2, 1, 0, 1, 3, 2, 1, 2),
    (5, 4, 3, 2, 4, 3, 2, 1, 3, 2, 1, 0, 4, 3, 2, 1),
    (3, 4, 5, 6, 2, 3, 4, 5, 1, 2, 3, 4, 0, 1, 2, 3),
    (4, 3, 4, 5, 3, 2, 3, 4, 2, 1, 2, 3, 1, 0, 1, 2),
    (5, 4, 3, 4, 4, 3, 2, 3, 3, 2, 1, 2, 2, 1, 0, 1)
)
 
def get_distance(board):
    sd = 0
    for i in range(16):
        p = board[i]
        if p == 0:
            continue
        sd += distance[p][i]
    return sd
 
adjacent = (
    (1, 4),         # 0
    (0, 2, 5),      # 1
    (1, 3, 6),      # 2
    (2, 7),         # 3
    (0, 5, 8),      # 4
    (1, 4, 6, 9),   # 5
    (2, 5, 7, 10),  # 6
    (3, 6, 11),     # 7
    (4, 9, 12),     # 8
    (5, 8, 10, 13), # 9
    (6, 9, 11, 14), # 10
    (7, 10, 15),    # 11
    (8, 13),        # 12
    (9, 12, 14),    # 13
    (10, 13, 15),   # 14
    (11, 14)        # 15
)
 
GOAL = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]
 
import sys
import heapq
 
# A* algorithm
def solve():
    board = list(map(int, sys.stdin.read().split()))
    h_cost = get_distance(board)
    state = (h_cost, board)
     
    q = [state] # priority queue
    d = {tuple(board): True}
     
    while q:
        state1 = heapq.heappop(q)
        h_cost, board = state1
        if board == GOAL:
            return h_cost
        space = board.index(0)
        for i in adjacent[space]:
            p = board[i]
            new_board = board[:]
            new_board[space], new_board[i] = p, 0
            new_h_cost = h_cost + 1 - distance[p][i] + distance[p][space]
 
            key = tuple(new_board)
            if key not in d and new_h_cost <= 45:
                new_state = (new_h_cost, new_board)
                heapq.heappush(q, new_state)
                d[key] = True
 
print(solve())

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

const int maxn = 610;
long double E[maxn];
vector <int> adj[maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	long double ans = 2000;
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i ++){
		int v, u;
		cin >> v >> u;
		v --;
		u --;
		adj[v].push_back(u);
	}
	for (int i = n; i >= 0; i --){
		if (i != n && adj[i].size() == 1)
			continue;
		E[n - 1] = 0;
		for (int j = n - 2; j >= 0; j --){
			long double y = 0, x = 0;
			for (auto u: adj[j]){
				y += E[u];
				x = max(x, E[u]);
			}
			if (i == j){
				E[j] = 1 + (y - x) / (adj[j].size() - 1);
			}
			else
				E[j] = 1 + y / adj[j].size();
		}
		ans = min(ans, E[0]);
	}
	cout << setprecision(15) << fixed << ans;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	cin>>a;
	if(a=="Sunny"){
		cout<<"Cloudy"<<endl;
	}
	else if(a=="Cloudy"){
		cout<<"Rainy"<<endl;
	}
	else cout<<"Sunny"<<endl;
	
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
   long long int i,n,k,j,s=0;
    scanf("%lld%lld",&n,&k);
    long long int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(a[i]>a[j])
            {
                a[i]=a[i]+a[j];
                a[j]=a[i]-a[j];
                a[i]=a[i]-a[j];
            }
        }
    }
    for(i=0;i<k;i++)
    {
        s=s+a[i];
    }
    printf("%lld\n",s);
}


Measured memory_bytes: 1692
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;


ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
bool root(string s){
    int n=s.length();
    if(n==2){
        if(s[0]==s[1]){
            return true;
        }
        else return false;
    }
    if(n==3){
        if(s[0]==s[2]){
            return true;
        }
        else return false;
    }
 
    return false;
}
 
 
//深さ優先
vector<int> seen;
vector<ll> h;
 
//普通の深さ優先探索seenを返す感じ
void dfs(const Graph &G,int v){

    seen[v] = 0; //v探索済み
 
    P good=make_pair(v,h[v]);
    for(auto next_v :G[v]){
        if(seen[next_v]!=-1) continue;//もう探索していた
        if(h[next_v]>good.second){
            good=make_pair(next_v,h[next_v]);
        }
        dfs(G,next_v);
    }
 
    if(!(h[v]==good.second && v==good.first)){
        seen[good.first]=1;
    }
}


int n;

void dfs(string s, char mx){
    if(s.length()==n){
        cout<<s<<endl;
    }else{
        for(char c='a';c<=mx;c++){
            dfs(s+c,((c==mx) ? (char)(mx+1) : mx));
        }
    }
}


int mod = 998244353;
int m,k;

int dfs(int cnt,int pred, int sk){
    int sum=0;
    if(cnt==n){
        return 1LL;
    }
    for(int i=1;i<=m;i++){
        if(i==pred){
            if(sk+1<=k){
                sum+=dfs(cnt+1,i,sk+1)%mod;
            }
        }else{
            sum+=dfs(cnt+1,i,sk)%mod;
        }
    }

    return sum;
}

int num(int n,int a,int b){
    return n-(n/a)-(n/b)+(n/(a/gcd(a,b)*b));
}

signed main(){ 
    int a,b,c,d; cin>>a>>b>>c>>d;

    cout<<num(b,c,d)-num(a-1,c,d)<<endl;

}  

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

using namespace std;

int dp[3005][3005];
typedef pair <int,int> P ;

int main(){
    int res = 0;
    int n,t;
    cin >> n >> t;
    vector <P> p(n);
    for(int i = 0;i<n;i++){
        cin >> p[i].first >> p[i].second;
    }
    sort(p.begin(),p.end());
    for(int i = 0;i<n;i++){
        for(int j = 0;j<t;j++){
            dp[i+1][j] = max(dp[i][j],dp[i+1][j]);
            int nj = j + p[i].first;
            if(nj < t){
                dp[i+1][nj] = max(dp[i+1][nj],dp[i][j] + p[i].second);
            }
        }
        res = max(res,dp[i][t-1] + p[i].second);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 38848
import collections
s  = list(input())
n = len(s)
alp = "abcdefghijklmnopqrstuvwxyz"
alp = list(alp)
co_alp = collections.Counter(alp)
if n==26:
    for i in range(n-1):
        if s[-i-1] >s[-i-2]:
            q = "z"
            for sj in s[-i-1:]:
                if sj >s[-i-2]:
                    q = min(q,sj)
            l = s[:-i-2]
            l.append(q)
            print("".join(l))
            break
    else:
        print(-1)
    exit()

for i in range(n):
    co_alp[s[i]]+=1
for w,num in sorted(co_alp.items()):
    if num==1:
        s.append(w)
        break
print("".join(s))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
using namespace std;

const int N = 2e5+1;
vector<int>graph[N];
int in_degree[N];
int ans[N];

void dfs(int cur,int parent=-1){
	for(int child : graph[cur]){
		ans[child] = max(ans[child],ans[cur]+1);
		in_degree[child]--;
		if(in_degree[child] == 0) dfs(child,cur);
	}
}

int main(){
	ios_base::sync_with_stdio(false);

	int n , m;
	cin >> n >> m;

	for(int i=0;i<m;i++){
		int x,y;
		cin >> x >> y;
		graph[x].push_back(y);
		in_degree[y]++;
	}

	// 0 vertex will connect with every other vertex

	for(int i=1;i<=n;i++){
		graph[0].push_back(i);
		in_degree[i]++;
	}

	dfs(0);

	cout << *(max_element(ans,ans+n+1)) - 1 << endl;

	return 0;
}


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

using namespace std;

#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i=(a); i<(n); i++)


int main() {
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;
}


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


int main()
{
    /*A
    int x,a;
    cin>>x>>a;
    if(x<a)
    {
        cout<<0<<endl;
    }
    else
    {
        cout<<10<<endl;
    }
    */

    int n,x;
    cin>>n>>x;
    vector <int> l(n);
    rep(i,n)
    {
        cin>>l[i];
    }

    int count=0;
    long long sum=0;
    while(sum<=x)
    {
        sum+=l[count];
        count++;
        if(count==n+1)
        {
            cout<<n+1<<endl;
            return 0;
        }
    }

    cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string.h>
#include<math.h>
#include<string>
using namespace std;
typedef long long int llint;

bool check(string a, string b) {
	return a < b;
}

int main() {
	int n, l;
	cin >> n >> l;
	string s[110];
	for (int i = 0;i < n;i++) {
		cin >> s[i];
	}
	sort(s, s + n, check);
	for (int i = 0;i < n;i++) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

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

const int MAX_NUM_PACKAGES = 100000;
const int MAX_NUM_TRUCKS = 100000;
const int MAX_WEIGHT = 10000;
int w[MAX_NUM_PACKAGES], n, k;

int check(long long p) {
  int j {0};
  for (int i = 0; i < k; i++) {
    long long s {0};
    while (s + w[j] <= p && j < n) {
      s += w[j];
      j++;
    }
  }
  return j;
}

long long solve() {
  long long left {0};
  long long right {MAX_NUM_PACKAGES * MAX_WEIGHT};
  long long mid {0};
  while (right - left > 1) {
    mid = (right + left) / 2;
    int v = check(mid);
    if (v >= n) {
      right = mid;
    } else {
      left = mid;
    }
  }
  return right;
}

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> w[i];
  long long ans = solve();
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3488
/*input
bus
*/
/**
    Author: Kristopher Paul
    Date Created: 08-09-2020
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

//Uncomment for File I/O
//ifstream fin("input.in")

//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    string s;
    cin >> s;
    if(s[s.length()-1] != 's'){
        s += 's';
    }else{
        s += 'e';
        s += 's';
    }
    cout << s << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 3648
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	X := sc.nextInt()
	ans := 0
	if X <= 6 {
		ans = 1
	} else {
		ans += (X / 11) * 2
		rest := X % 11
		if 1 <= rest && rest <= 6 {
			ans += 1
		} else if 6 < rest {
			ans += 2
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int N,M,ans;
vint G[10];
bool vis[10];

bool dfs(int v,int c){
    vis[v]=1;
    if(c==N) ans++;
    for(int u:G[v]){ 
        if(!vis[u]) dfs(u,c+1);
    }
    vis[v]=0;
}

signed main()
{
    cin>>N>>M;
    REP(i,M){
        int a,b; cin>>a>>b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0,1);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
   ll a,b;
   cin>>a>>b;
   ll arr[b];
   ll sum=0;
   for(ll i=0;i<b;i++){
       cin>>arr[i];
       sum+=arr[i];
   }
   if(sum>=a){
       cout<<"Yes";
   }else{
       cout<<"No";
   }
    
    
}

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

static const int MAX = 200000;
#define dump(x) cerr << #x << " = " << (x) << endl;

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


    int n;
    cin >> n;

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

    int minv = v[0];
    int maxv = -2000000000;

    for(int i=1; i<n; i++){
        maxv = max(maxv, v[i]-minv);
        //dump(maxv)
        minv = min(minv, v[i]);
        //dump(minv)
    }

    cout << maxv << endl;

}



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

#define rep(i,a,b) for(long long i = (a); i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
using ll = long long;

ll lcm(ll a,ll b){

	return (a*b)/(__gcd(a,b));
}


void solve()
{
	string s;
	cin>>s;
	int n=s.size();
	int cnt=0;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='R'){
			cnt++;
		}
		else{
			ans=max(ans,cnt);
			cnt=0;
		}
	}
ans=max(ans,cnt);
	cout<<ans;
}



int  main(){
	solve();
	cout<<endl;


}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	string s;
	int k;
	cin>>s>>k;
	ll res=0;
	vector<pair<char,int> > v;
	for(int i=0;i<s.size();++i)
		if(v.empty() || v.back().first!=s[i])
			v.push_back({s[i],1});
		else
			v.back().second++;
	if(v.size()==1){
		res=(ll)k*s.size()/2;
	}else{
		if(v[0].first==v.back().first){
			int t=v[0].second+v.back().second;
			res+=(ll)t/2*(k-1);
			res+=v[0].second/2;
			res+=v.back().second/2;
			v.erase(v.begin());
			v.pop_back();
		}
		for(auto x:v)
			res+=x.second/2*(ll)k;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a,b = 0, n
print(a,flush=True)
s = str(input())
if s == 'Vacant':
        exit()
for i in range(19):
    check = (a+b) // 2
    print(check,flush=True)
    t = str(input())
    if t == 'Vacant':
        exit()
    if (check-a) % 2 == 0 and s == t:
        a = check
    elif (check-a) % 2 == 0 and s != t:
        b = check
    elif s == t:
        b = check
    else:
        a,s = check,t

Measured memory_bytes: 3660
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 105;
const ll mm = 1e+18;
void solve()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*b,c*d);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 3620
let get_int () = Scanf.scanf "%d " (fun v -> v)
let input_int_array n =
  Array.init n (fun _ -> Scanf.scanf "%d " (fun v -> v))

let () =
  let n = get_int ()
  in
  input_int_array n
  |> Array.to_list
  |> List.sort_uniq Pervasives.compare
  |> List.length
  |> Printf.printf "%d\n"




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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  priority_queue<int> que;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    que.push(a);
  }
  for (int i = 0; i < M; i++) {
    int a = que.top();
    que.pop();
    a /= 2;
    que.push(a);
  }
  int64_t res = 0;
  while (!que.empty()) {
    int a = que.top();
    que.pop();
    res += a;
  }
  cout << res << '\n';
  return 0;
}


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

int main() {
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int res = 0;
	for(int i=0; i<=a; i++) {
	for(int j=0; j<=b; j++) {
	for(int k=0; k<=c; k++) {
		if( 500*i + 100*j + 50*k == x ) {
			res++;
		}
	}}}
	cout << res << endl;
	return 0;
}

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

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

    int n;
    cin >> n;
    if (n%2) {
        printf("%.10f", (n/2+1.0)/n);
    } else {
        printf("%.10f", 0.5);
    }
}

Measured memory_bytes: 3772
package main

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

var N, M int

const MOD = 1000000007

func main() {
	fsc := NewFastScanner()
	N = fsc.NextInt()
	M = fsc.NextInt()

	res := 1
	for i := 1; i <= N; i++ {
		res *= i
		res %= MOD
	}
	for j := 1; j <= M; j++ {
		res *= j
		res %= MOD
	}
	diff := N - M
	if N-M < 0 {
		diff *= -1
	}
	if diff == 0 {
		res *= 2
		res %= MOD
	}
	if diff > 1 {
		res = 0
	}

	fmt.Println(res)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int in(){int x; scanf("%d",&x); return x;}
static const int MAX = 100000;


int main(){
  int N = in(), K = in(), Q = in(), a[MAX];;
  rep(i, N) a[i] = 0;

  int x;
  rep(i, Q){
    cin >> x;
    a[x-1]++;
  }
  rep(i, N){
    if(Q - a[i] >= K) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
}

Measured memory_bytes: 1024
#include <iostream>
#define MAX_LENGTH 200005
using namespace std;

char str1[MAX_LENGTH] = {0};
char str2[MAX_LENGTH] = {0};
int main(int argc, char const *argv[])
{
	cin >> str1 >> str2;
	int result = 0;
	for (int i = 0; i < MAX_LENGTH; ++i)
	{
		result += (str1[i] != str2[i]);
	}
	cout << result;
	return 0;
}

Measured memory_bytes: 4016
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

ll keta(ll n) {
	if (n < 10) { return n; }
	return keta(n / 10) + n % 10;
}

int main() {

	ll a, b, c, k;
	cin >> a >> b >> c >> k;

	if (k % 2 == 0) { cout << a - b; }
	else { cout << b - a; }
	system("PAUSE");

}





Measured memory_bytes: 504
my $s = <>;
chomp $s;
my $t = <>;
chomp $t;
my @s = split "", $s;
my @t = split "", $t;
@s = sort {$a cmp $b} @s;
@t = sort {$b cmp $a} @t;
$s = join "", @s;
$t = join "", @t;
my $result = $s lt $t ? 'Yes':'No';
print $result;


Measured memory_bytes: 384
import collections as cl
ans = []
n = int(input())
list1 = []
for x in range(n): 
  list1.append(input())

clist = cl.Counter(list1)
max = max(clist.values())
citem =list(clist.items())
for y in citem:
    if y[1] == max:
      ans.append(y[0])

ans = sorted(ans)

for l in ans:
  print(l)

Measured memory_bytes: 118608
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
  int variety;
  cin >> variety;
  int pick_up;
  cin >> pick_up;
  int prices[variety];
  for(int i =0;i<=variety;i++){
    cin >> prices[i];
  }
  std::sort(prices, prices + variety);
  int sum = 0;
  
  for(int j = 0;j< pick_up;j++){
    sum = sum + prices[j];

  }
    cout << sum << endl;
    
    
    return 0;
}

Measured memory_bytes: 3624
def resolve():
    MOD = 10 ** 9 + 7

    def COMinit(n, MOD):
        fact = [1, 1]
        fact_inv = [1, 1]
        inv = [0, 1]
        for i in range(2, n + 1):
            fact.append((fact[-1] * i) % MOD)
            inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
            fact_inv.append((fact_inv[-1] * inv[i]) % MOD)
        return fact, fact_inv

    # 二項係数計算
    def Combination(n, k, MOD=10 ** 9 + 7):
        # fac, finv = COMinit(n, MOD)
        if n < k: return 0
        if n < 0 or k < 0: return 0
        ret = fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
        return ret

    K = int(input())
    S = input()
    N = len(S)
    n25 = [1]
    n26 = [1]
    for _ in range(K+N-N):
        n25.append((n25[-1] * 25) % MOD)
        n26.append((n26[-1] * 26) % MOD)

    fac, finv = COMinit(N + K, MOD)
    v = 1
    ans = 0
    for i in range(K + 1):
        ans += pow(25, i, MOD) * Combination(N-1+i, N-1) * pow(26, K-i, MOD)
        ans %= MOD
    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 230268
#include<iostream>
#include<string>
using namespace std;
int main()
{
  // 入力
  int a, b;
  cin >> a >> b;
  
  int ans;
  
  if (a >= 13)
    ans = b;
  else if (a >= 6)
    ans = b/2;
  else
    ans  = 0;
    
  // 出力
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    P = list(map(float, input().split()))
    dp = [[0] * (N+1) for _ in range((N+1))]
    dp[0][0] = 1
    for i in range(1, N+1):
        for j in range(i+1):
            dp[i][j] = dp[i-1][j]*(1-P[i-1]) + dp[i-1][j-1]*P[i-1]
    print(sum(dp[N][N//2+1:]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 275464
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(x) for(auto it=(x).begin();it!=(x).end();it++) 
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
 
using namespace std;

vector<string> split(string s, char c){
    if(s[s.size()-1]!=c)s.push_back(c);
    
    vector<string> v;
    int pos=0;
    for(int i=0;i<s.size();i++){
        if(s[i]==c){
            v.push_back(s.substr(pos,i-pos));
            pos=i+1;
        }
    }
    return v;
}

int main(){
    string s,t;
    while(getline(cin,s)){
        if(s==".")break;
        getline(cin,t);
        if(s==t){
            cout<<"IDENTICAL"<<endl;
            continue;
        }
    
        vector<string> ss=split(s,'"'), tt=split(t,'"');
        if(ss.size()!=tt.size()){
            cout<<"DIFFERENT"<<endl;
            continue;
        }
        int count=0;
        rep(i,0,ss.size()){
            if(ss[i]!=tt[i]){
                if(i%2==0){
                    cout<<"DIFFERENT"<<endl;
                    goto AWAY;
                }else {
                    count++;
                }
            }
        }
        if(count>1)cout<<"DIFFERENT"<<endl;
        else cout<<"CLOSE"<<endl;
        AWAY:;
    
    }
    return 0;
}


Measured memory_bytes: 3184
n=int(input())
it=[int(i) for i in list(input())]
vis=[[0 for i in range(10)] for j in range(n+1)]
for i in range(n-1,-1,-1):
    vis[i]=vis[i+1][:]
    vis[i][it[i]]=1
vis2=[[0 for i in range(10)] for j in range(n+1)]
for i in range(n):
    vis2[i]=vis2[i-1][:]
    vis2[i][it[i]]=1
do=[0 for i in range(1000)]
for i in range(1,n-1):
    x=it[i]
    nu=x*10
    
    for ii in range(10):
        for j in range(10):
            if vis[i+1][ii] and vis2[i-1][j]:
                tot=nu+ii*100+j
                do[tot]=1
print(do.count(1))
                
    
    


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

int main(){
  char S[10],T[10];
  char U[10];
  int A = 0,B = 0;
  
  scanf("%s %s %d %d %s",S,T,&A,&B,U);
  
  if(strcmp(S,U) == 0) A--;
  else if(strcmp(T,U) == 0) B--;
  
  printf("%d %d\n",A,B);
  
  return 0;
}

Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		s := strings.Split(sc.Text(), " ")
		a, _ := strconv.Atoi(s[0])
		b, _ := strconv.Atoi(s[1])
		fmt.Println(len(fmt.Sprint(a + b)))
	}
}



Measured memory_bytes: 1076
#include<stdio.h>
#include<stdlib.h>
#define N 1000000
int cnt=0;
int n;
int l;
int A[N];
int *G;

void insertionSort(int A[], int n, int g){
int i,v,j;
  for(i=g;i<n;i++){
    v=A[i];
    j=i-g;
    while(j>=0&&A[j]>v){
      A[j+g]=A[j];
      j-=g;
      cnt++;
    }
    A[j+g]=v;
  }
}

void shellSort(int A[],int n){
  int i=0,h;

G=(int *)malloc(n * sizeof(int));
  
for(h=1; ; ){
if(h>n) break;
G[i]=h;
i++;
  h=3*h+1;
}
l=i;
  for(i=l-1;i>=0;i--){
    insertionSort(A,n,G[i]);
  }
}



int main(){
int i;
scanf("%d",&n);
for(i=0;i<n;i++) scanf("%d",&A[i]);
cnt=0;
  
shellSort(A,n);

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

for(i=l-1;i>=0;i--){
printf("%d",G[i]);
if(i) printf(" ");
}
printf("\n");
printf("%d\n",cnt);
for(i=0;i<n;i++)printf("%d\n",A[i]);

 free(G);
  return 0;
}



Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 10000000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P>> vec;
// vector<vector<int>> data(3, vector<int>(4));

int main() {
    ll N, M, X;
    cin >> N >> M >> X;
    vector<ll> C(N);
    vector<vector<ll>> A(N, vector<ll>(M));
    rep(i, N) {
        cin >> C[i];
        rep(j, M) cin >> A[i][j];
    }

    ll res = INF;
    rep(i, 1LL << N) {
        ll now = 0;
        vector<ll> cc(M);
        rep(j, N) {
            if (1LL << j & i) {
                rep(k, M) cc[k] += A[j][k];
                now += C[j];
            }
        }
        bool flg = true;
        rep(j, M) {
            if (cc[j] < X) flg = false;
        }
        if (flg) {
            res = min(res, now);
            // if (now == 0) cout << i << endl;
        }
    }

    if (res >= INF)
        cout << "-1" << endl;
    else
        cout << res << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int N, M; 		// グラフの頂点数、辺の数
vector<int> G[8]; 	// 隣接グラフ表現
bool visit[8];

int res;		// ハミルトンパスの数

void dfs(int u, int p, int depth){
	if (depth == N - 1){
		++res;
		return;
	} // end if

	visit[u] |= true;
	rep (i, (int)G[u].size()){
		int v = G[u][i];
		if (v != p && !visit[v]){
			dfs(v, u, depth + 1);
		} // end if
	} // end rep
	visit[u] = false;
}

int main()
{
	rep (i, 8){
		G[i].clear();
		visit[i] = false;
	} // end rep

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> N >> M;
	rep (i, M){
		int a, b; cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	} // end rep

	res = 0;
	dfs(0, -1, 0);

	cout << res << endl;

	return 0;
}

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

int main(){
  int N, A, B;
  cin >> N >> A >> B;

  if (N == 1){
    cout << "Hello World" << endl;
  }
  else
  {
    cout << A + B << endl;
  }
  
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, S, X):
    Xs = []
    for x in X:
        t = abs(x - S)
        Xs.append(t)

    if N == 1:
        return Xs[0]
    ans = gcd(Xs[0], Xs[1])
    for i in range(2, N):
        ans = gcd(ans, Xs[i])

    return ans


def gcd(a, b):
    if a < b:
        return gcd(b, a)
    if b == 0:
        return a
    return gcd(b, a % b)


def main():
    N, S = read_int_n()
    X = read_int_n()
    print(slv(N, S, X))

    # N = 10000
    # S = random.randint(1, 10**9)
    # # X = [random.randint(1, 10**9) for _ in range(N)]
    # S = 1
    # X = list(range(N))
    # print(slv(N, S, X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 16644
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int n;
vector<int> a[200010];
vector<int> b[200010];
int col[200010];
int h[200010];
bool vis[200010];
int siz[200010];

int dfs(int x)
{
    vis[x] = 1;
    int ans = 1;
    forn(i, a[x].size())
    {
        if(!vis[a[x][i]])
        {
            b[x].pb(a[x][i]);
            ans += dfs(a[x][i]);
        }
    }
    siz[x] = ans;
    return ans;
}
void cl(){Forn(i, n) vis[i] = 0;}

pii up[200010];
stack<pii> curup[200010];

void dfs2(int x)
{
    up[x] = curup[col[x]].top();
    forn(i, b[x].size())
    {
        curup[col[x]].push({x, i});
        dfs2(b[x][i]);
        curup[col[x]].pop();
    }
}

vector<int> subsiz[200010];
vector<int> pie[200010];
int sum[200010];

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin >> n;
    Forn(i, n) cin >> col[i];
    forn(i, n-1)
    {
        int x, y;
        cin >> x >> y;
        a[x].pb(y);
        a[y].pb(x);
    }
    dfs(1);
    Forn(i, n) curup[i].push({-1, -1});
    dfs2(1);
    Forn(x, n)
    {
        forn(i, b[x].size()) subsiz[x].pb(siz[b[x][i]]);
    }
    Forn(x, n)
    {
        if(up[x].F != -1) subsiz[up[x].F][up[x].S] -= siz[x];
    }
    Forn(x, n)
    {
        forn(i, subsiz[x].size())
        {
            pie[col[x]].pb(subsiz[x][i]);
            sum[col[x]] += (subsiz[x][i]);
        }
        sum[col[x]]++;
    }
    Forn(i, n) if(n > sum[i]) pie[i].pb(n - sum[i]);
    /*Forn(i, n)
    {
        cout << "col = " << i << endl;
        forn(j, pie[i].size()) cout << pie[i][j] << " ";
        cout << endl;
    }*/
    Forn(i, n)
    {
        ll ans = (ll)n * (ll)(n+1) / 2;
        forn(j, pie[i].size())
        {
            ll ko = (ll)(pie[i][j]) * (ll)(pie[i][j] + 1) / 2;
            ans -= ko;
        }
        cout << ans << '\n';
    }
}


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

#define vi vector<int>
#define vl vector<long long>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define vp vector<P>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define INF 1e18
#define INFTY 1e9
const int mod = 998244353;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

template<class T> bool chmax(T &a, const T & b) {
    if (a<b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> bool chmin(T &a, const T & b) {
    if (a>b) {
        a = b;
        return true;
    }
    return false;
}

//cout << fixed << setprecision(10) << y << endl;
struct edge {int to, cost;};
vector< vector<edge> > es;
const int MAX_N = 10010;

int main() {
    ll n;
    cin >> n;
    ll res = n*(n-1)/2;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
use std::io::prelude::*;

fn input<T>() -> T
    where T: std::str::FromStr {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let x: usize = input();
    let tmp_cnt = x / 11 * 2;
    let ret = x % 11;
    if ret > 6 {
        println!("{}", tmp_cnt + 2);
    } else if ret > 0 {
        println!("{}", tmp_cnt + 1);
    } else {
        println!("{}", tmp_cnt);
    }
}

Measured memory_bytes: 4352