akhauriyash/Code-Regression huggingface dataset:
N = int(input())
for h in range(1,3500+1):
    for n in range(1,3500+1):
        if 4 * n * h - N * h - N * n == 0:
            continue
        w = N * h * n / (4 * n * h - N * n - N * h)
        if w > 0 and int(w) == w:
            print(h,n,int(w))
            exit()

Measured memory_bytes: 40684
#include <stdio.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <map>
#include <ctime>
#include <string.h>
#define inf 0x7fffffff
using namespace std;
//1232
int n,m,k,i,a,c,o[3000004],d,b,l[2000004],j[3333],dx[10]={0,1,-1,0,0,-1,-1,1,1},dy[10]={0,0,0,-1,1,1,-1,1,-1};
long long x,y,z;
stack<int> s;
struct P
{
    int x,y;
    long long z;
    bool operator<(const P &a)const
    {
        return y>a.y;
    }
};
 //map<int, int> p;
queue<P> q;
string r;
vector<P> v[1000100];
//vector<long long> ;
bool sdf(long long a,long long b){return a>b;}



int main()
{
    scanf("%d %d",&a,&b);
    for(int t=1;t<=b;t++)
    {
        scanf("%d %d",&c,&d);
        o[c]++;
        o[d]++;
    }
    for(int t=1;t<=a;t++)
        if(o[t]%2)
    {
        puts("NO");
        return 0;
    }
    puts("YES");
    return 0;
}

Measured memory_bytes: 26880
// Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;

		if(n==0&&m==0)
			break;

		int N[100], M[100];

		int N_sum = 0;
		int M_sum = 0;

		for(int i=0; i<n; i++){
			cin >> N[i];
			N_sum += N[i];
		}
		for(int i=0; i<m; i++){
			cin >> M[i];
			M_sum += M[i];
		}

		sort(N, N+n);
		sort(M, M+m);

		int i = 0;
		int j = 0;

		bool flg = false;
		while(i<n&&j<m){
			if(N_sum-N[i]+M[j]==M_sum-M[j]+N[i]){
				flg = true;
				break;
			}
			else if(N_sum-N[i]+M[j]>M_sum-M[j]+N[i]){
				i++;
			}
			else{
				j++;
			}
		}

		if(flg){
			cout << N[i] << ' ' << M[j] << endl;
		}
		else{
			cout << -1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n, k;
  cin >> n >> k;
  int h[n];
  for(int i = 0; i < n; i++) cin >> h[i];

  int count = 0;
  for(int i = 0; i < n; i++){
    if(h[i] >= k) ++count;
  }

  cout << count << endl;

  return 0;
}


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

int main(){

    int n;
    cin >> n;

    ll ans=0;
    rep(i,n){
        int t;
        cin >> t ;
        ans+=(t-1);
    }

    cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#define N (1<<17)
#define MODULO (1000000007)

#include <cstdio>
#include <iostream>
#include <fstream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <deque>
#include <vector>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
using namespace std;

int n;
int par[N];
vector<int> v[N];
int req[N];

bool cmp(const int &x, const int &y)
{
	return (req[x] > req[y]);
}

void dfs(int xx)
{
	for (int i = 0;i < v[xx].size();i++)
	{
		dfs(v[xx][i]);
	}
	sort(v[xx].begin(), v[xx].end(), cmp);
	req[xx] = v[xx].size();
	for (int i = 0;i < v[xx].size();i++)
	{
		req[xx] = max(req[v[xx][i]] + i + 1, req[xx]);
	}
}

int main()
{
	scanf("%d", &n);
	for (int i = 1;i < n;i++)
	{
		scanf("%d", &par[i]);
		par[i]--;
		v[par[i]].push_back(i);
	}
	dfs(0);
	/*
	for (int i = 0;i < n;i++)
	{
		printf("req[%d]=%d.\n", i, req[i]);
	}
	*/
	printf("%d\n", req[0]);
	//system("pause");
	return 0;
}



Measured memory_bytes: 13568
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
#define N 200010
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,a[N],dep[N],cnt0,cnt1,res1,res2;
vector<int> vec[N],G[N];
void dfs(int u,int fa){
	dep[u]=dep[fa]+1;
	vec[dep[u]].push_back(u);
	for(auto v:G[u]){
		if(v==fa)continue;
		dfs(v,u);
	}
}
int main(){
	n=read();
	for(int i=1;i<n;++i){
		int u=read(),v=read();
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1,0);
	for(int i=1;i<=n;++i){
		if(i&1)cnt1+=vec[i].size();
		else cnt0+=vec[i].size();
	}
	res1=n/3+(n%3>=1),res2=n/3+(n%3>=2);
	if(max(cnt1,cnt0)>=res1&&min(cnt0,cnt1)>=res2){
		for(int i=1;i<=n;++i){
			if((i&1)^(cnt1<=cnt0)){
				for(auto u:vec[i]){
					if(!res1)break;
					--res1;
					a[u]=res1*3+1;
				}
			}
			else{
				for(auto u:vec[i]){
					if(!res2)break;
					--res2;
					a[u]=res2*3+2;
				}
			}
		}
	}
	else{
		for(int i=1+(cnt1<cnt0);i<=n;i+=2){
			for(auto u:vec[i]){
				if(res1){
					--res1;
					a[u]=res1*3+1;
				}
				else if(res2){
					--res2;
					a[u]=res2*3+2;
				}
			}
		}
	}
	int now=1;
	for(int i=1;i<=n;++i){
		if(!a[i]){
			a[i]=now*3;
			++now;
		}
	}
	for(int i=1;i<=n;++i){
		printf("%d ",a[i]);
	}
	printf("\n");
	return 0;
}



Measured memory_bytes: 30936
#include <iostream>
using namespace std;
 
 
int main()
{
	int N;
	cin >> N;
 
	N = N % 10;
 
	if (N == 0 || N == 1 || N == 6 || N == 8) {
		cout << "pon";
	}
	else if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
		cout << "hon";
	}
	else {
		cout << "bon";
	}
 
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  string A, B; cin >> A >> B;
  if (A==B) {
    cout << "EQUAL" << endl;
    return 0;
  }

  if (A.size()>B.size()) cout << "GREATER" << endl;
  else if (A.size()<B.size()) cout << "LESS" << endl;
  else{
    rep(i,A.size()){
      if (A[i]>B[i]){
        cout << "GREATER" << endl;
        return 0;
      }
      else if (A[i]<B[i]){
        cout << "LESS" << endl;
        return 0;
      }
      else continue;      
    }
  }
  


  // cout << fixed << setprecision(6);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 10000

int par[MAX],rank[MAX];

void init(int n){
  int i;
  for(i = 0 ; i < n ; i++){
    par[i] = i;
    rank[i] = 0;
  }
}

int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);

  if(x == y) return;

  if(rank[x] < rank[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rank[x] == rank[y]){
      rank[x]++;
    }
  }
}

int same(int x,int y){
  return find(x) == find(y);
}

int main(){
  int n,q,i,com,x,y;

  scanf("%d%d" ,&n ,&q);
  init(n);
  for(i = 0 ; i < q ; i++){
    scanf("%d%d%d" ,&com ,&x ,&y);

    if(com == 0){
      unite(x,y);
    }else{
      if(same(x,y)){
	puts("1");
      }else{
	puts("0");
      }
    }
  }

  return 0;
}

Measured memory_bytes: 660
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
#define l(i,a,b) for(auto i=a;i<b;i++)
#define lr(i,a,b) for(auto i=a;i>=b;i--)
#define ll long long 
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<ll,ll>
#define vl vector<long long>
#define se set <long long int>
#define pi pair<long long,long long>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define all(v) v.begin(), v.end()
#define in(x) cin>>x
#define o(x) cout<<x
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll dp[200009];
vl v;
ll n;

ll solve(ll i)
{
    dp[i]=dp[i-1] + abs(v[i] - v[i-1]);
    if(i>1)
    dp[i]=min(dp[i], dp[i-2] + abs(v[i] - v[i-2]));
    
    if(i==n-1)
    return dp[i];
    else
    return solve(i+1);
}




int main()
{
    SYNC
    ll temp; in(n);
    v.clear();
    l(i,0,n)
    {
        in(temp);
        //o(temp)<<" ";
        v.pb(temp);
    }
    dp[0]=0;
    ll ans = solve(1);
    o(ans)<<endl;
    
    
    
    
    
    
    
}

Measured memory_bytes: 1908
a, b, c, d = map(int, input().split())
isT = True
while True:
    if isT:
        c -= b
        isT = False
        if c <= 0:
            print("Yes")
            quit()
    else:
        a -= d
        isT = True
        if a <= 0:
            print("No")
            quit()

Measured memory_bytes: 61752
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;
 
namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var n = ReadInt();
            Console.WriteLine($"{n * 800 - n / 15 * 200}");
        }
    }
 
    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 13268
n = gets.chomp.to_i
i = 0
n.times do
  d1, d2 = gets.chomp.split(' ').map(&:to_i)
  if d1 == d2
    i += 1
  else
    i = 0
  end
  return puts 'Yes' if i == 3
end
puts 'No'

Measured memory_bytes: 14352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int n;
    cin >> n;
    vector<int> h(n), cost(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    cost[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; i++){
        cost[i] = min(cost[i - 2] + abs(h[i] - h[i - 2]), cost[i - 1] + abs(h[i] - h[i - 1]));
    }
    cout << cost[n - 1];
}

Measured memory_bytes: 1024
h,w=map(int,input().split())
maze=[[None] for _ in range(h)]
for i in range(h):
  s=list(input())
  for j in range(w):
    if s[j]=="#":
      pass
    else:
      s[j]=0
  maze[i]=s

for i in range(h):
  for j in range(w):
    if maze[i][j]=="#":
      for ii in range(i-1,i+1+1):
        for jj in range(j-1,j+1+1):
          if 0<=ii<h and 0<=jj<w:
            if maze[ii][jj]!="#":
              maze[ii][jj]+=1
for i in range(h):
  for j in range(w):
    print(maze[i][j],end="")
  print()


Measured memory_bytes: 45292
#include<bits/stdc++.h>
 
 using namespace std;
 typedef long long ll;
 #define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
 
 int main() {
 
     int n,m; cin >> n >> m;
     vector<int> a(m);
     rep(i, m) {
         cin >> a[i];
     }
     // 入力例的にa[i]の順は大小が考慮されていないので、降順ソートしておく
     sort(a.begin(), a.end(), greater<int>() );
 
     // 数値ごとのマッチ利用本数
     vector<int> match_num{2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6};

     vector<int> dp(11000, -INT_MAX);
     for(int i=1; i <= n; i++) {
         int tmp = -INT_MAX;
         rep(j, m) {
             if(i-match_num[a[j]-1] < 0) continue;
             if(i-match_num[a[j]-1] == 0) {
                 tmp = 1;
             } else if(dp[i-match_num[a[j]-1]] > 0) {
                 tmp = max(tmp, dp[i-match_num[a[j]-1]]+1);
             }
         }
         dp[i] = tmp;
     }
     
 
     // 結果を求める
     string ans = "";
     int remain = dp[n]; // 期待される桁数
     int match = n; // 残りのマッチ本数
     dp[0] = 0; // 計算用の対策, dp[0]の時を0にしておく(最後の１桁を求める時の判定用)
 
     while(match > 0) {
         rep(i, m) {
             if(remain-1 == dp[match-match_num[a[i]-1]] && match-match_num[a[i]-1] >= 0) {
                 match -= match_num[a[i]-1];
                 remain -= 1;
                 ans += to_string(a[i]);
                 break;
             }
         }
     }
 
     cout << ans << endl;
     return 0;
 }

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<algorithm>
#include<utility>
#include<unordered_map>
#include<vector>
#include<math.h>
#include<set>
using namespace std;
// bool findPossibleOrNot(int** edges,int n,int* visited,int currentIndex,int count1,int count2,int count3,int n1,int n2,int n3,int currentColour)
// {
//     visited[currentIndex] = currentColour;
//     if(currentColour==1)
//     {
//         if(count2)
//     }
//     else if(currentColour==2)
//     {

//     }
//     else
//     {

//     }
// }
// int main()
// {
//     int n;
//     cin>>*edges = new int*[n];
//     for(int i=0;i<n;i++)
//     {
//         edges[i] = new int[n]{0};
//     }
//     int e;
//     cin>>e;
//     while(e--)
//     {
//         int x,y; 
//         cin>>x>>y;
//         edges[x][y] = 1;
//         edges[y][x] = 1;
//    }
//    int n1,n2,n3;
//    cin>>n1>>n2>>n3;
//    int *visited = new int[n]{0};
//    bool ans = findPossibleOrNot(edges,n,0,visited,0,0,0,n1,n2,n3,1)<<endl;
//    if(ans==true){
//     cout<<"YES"<<endl;
//     for(int i=0;i<n;i++)
//     {
//         cout<<visited[i]<<" ";
//     }
//    }
//    else
//    {
//     cout<<"NO"<<endl;
//    }
// }
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
    int n;
    cin>>n;
    int x = n%10;
    if(x==0 || x==1 ||x==6 || x==8)
    {
        cout<<"pon"<<endl;
    }
    else if(x==3)
    {
        cout<<"bon"<<endl;
    }
    else
    {
        cout<<"hon"<<endl;
    }
}

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

int main(){
	int c=0,maxv=0;
	
	for(int i=1;i<=3;i++)
	{
		char s;
		cin>>s;
		if(s=='R')
		{
			c++;
		}
		else
		{
			if(c>maxv)
			{
				maxv=c;
				c=0;
			}
		}
	}
	if(c>maxv)
	{
		maxv=c;
	}
	cout<<maxv;
	return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
int oo(int x){return (x + 9) / 10 * 10;}
int re(int x){return oo(x) - x;}

int main() {
    string s;
    cin >> s;
    int len = 0;
    int max_l = 0;
    for(char x : s){
        if(x == 'A' or x == 'C' or x == 'G' or x == 'T') len++;
        else len = 0;
        max_l = max(max_l, len);
    }
    cout << max_l << endl;
}

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

int gcd(int a, int b){
  if(b > a) return gcd(b, a);
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main() {
  int n; cin >> n;
  int a, b, c, d; cin >> a >> b >> c >> d;
  a--; b--; c--; d--;
  string s; cin >> s;
  
  bool ans = 1;
  int cnt = 0;
  int m = max(c, d);
  for(int i = a + 1; i < m; i++){
    if (s.at(i) == '#') {
      if(cnt ==1) {cout << "No" << endl; return 0;}
      else cnt = 1;
    }
    else cnt = 0;
  }
  
  if (c < d) {cout << "Yes" << endl; return 0;}
  
  cnt = 0;
  
  for(int i = b - 1; i <= d + 1 ; i++){
    if (s.at(i) == '.') {
      if (cnt == 2) {cout << "Yes" << endl; return 0;}
      else cnt++;
    } else cnt = 0;  
  }
  
  cout << "No" << endl; return 0;
  
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] values = line.split(" ");
        int a1,a2,a3,b1,b2,b3,c1,c2,c3;
        a1 = Integer.parseInt(values[0]);
        a2 = Integer.parseInt(values[1]);
        a3 = Integer.parseInt(values[2]);
        line = scanner.nextLine();
        values = line.split(" ");
        b1 = Integer.parseInt(values[0]);
        b2 = Integer.parseInt(values[1]);
        b3 = Integer.parseInt(values[2]);
        line = scanner.nextLine();
        values = line.split(" ");
        c1 = Integer.parseInt(values[0]);
        c2 = Integer.parseInt(values[1]);
        c3 = Integer.parseInt(values[2]);
        line = scanner.nextLine();
        values = line.split(" ");
        int n = Integer.parseInt(values[0]);
        boolean a = false,aa = false,aaa = false,b = false,bb = false,bbb = false,c = false,cc = false,ccc = false;
        for (int i = 0; i < n; i++) {
            line = scanner.nextLine();
            values = line.split(" ");
            int curr = Integer.parseInt(values[0]);
            if (curr == a1) {
                a = true;
            }
            if (curr == a2) {
                aa = true;
            }
            if (curr == a3) {
                aaa = true;
            }
            if (curr == b1) {
                b = true;
            }
            if (curr == b2) {
                bb = true;
            }
            if (curr == b3) {
                bbb = true;
            }
            if (curr == c1) {
                c = true;
            }
            if (curr == c2) {
                cc = true;
            }
            if (curr == c3) {
                ccc = true;
            }
        }
        boolean ret = false;
        if (a && aa & aaa) {
            ret = true;
        }
        if (b && bb && bbb) {
            ret = true;
        }
        if (c && cc && ccc) {
            ret = true;
        }
        if (a && b && c) {
            ret = true;
        }
        if (aa && bb && cc) {
            ret = true;
        }
        if (aaa && bbb && ccc) {
            ret = true;
        }
        if (a && bb && ccc) {
            ret = true;
        }
        if (aaa && bb && c) {
            ret = true;
        }
        System.out.println(ret ? "Yes" : "No");
    }
}

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

int	main() {
	int N;
	cin >>N;
	vector<int> p(N+2);
	for (int i=1; i<=N; i++)
		cin >>p.at(i);
	int S=0;
	for (int i=1; i<=N; i++) {
		if (i==p.at(i)) {
			S++;
			swap(p.at(i), p.at(i+1));
		}
	}
	cout <<S <<endl;
	return 0;
};


Measured memory_bytes: 640
#include <cstdio>
#include <utility>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n';)s+=c;return s;}
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;if((c=gcu())=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:ungetc(c,stdin),o=in,true;}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

int main() {
	for (int n, i {1}; (n = in); i++)
		outl("Case ", i, ": ", n);
}


Measured memory_bytes: 2452
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stack>
#include <set>
using namespace std;
const int N = 1234567;
int minCost[N];
int cost[N];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>cost[i];
		minCost[i] = 1e9;
	}
	minCost[0] = 0;
	for(int i=1;i<n;i++)
	{
		for(int j=i-1;i-j<=k && j>=0;j--)
		{
			minCost[i] = min(minCost[i], minCost[j]+abs(cost[i]-cost[j]));
		}
	}
	cout<<minCost[n-1]<<endl;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    
    char c = *min_element(s.begin(), s.end());
    string t = s;
    reverse(t.begin(), t.end());
    string u = s + t;
    int m = 1;
    while (k > 1 && m < n) {
        m = min(n, 2 * m);
        --k;
    }
    string ans;
    for (int i = 0; i <= n; ++i) {
        s = u.substr(i, n);
        if (s.back() != c)
            continue;
        int len = 0;
        while (len < n && s[n - len - 1] == c)
            ++len;
        int f = min(n, len * m);
        s = s.substr(f - len, n - f);
        while (s.length() < n)
            s += c;
        reverse(s.begin(), s.end());
        if (ans.empty() || ans > s)
            ans = s;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define SZ(x) ((int)((x).size()))

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

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

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

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

template<class TH>
void _dbg(const char* name, TH val){
    clog << name << ": " << val << endl;
}
template<class TH, class... TA>
void _dbg(const char* names, TH curr_val, TA... vals) {
    while(*names != ',') clog << *names++;
    clog << ": " << curr_val << ", ";
    _dbg(names+1, vals...);
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
    #define dbg_arr(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg(...)
    #define dbg_arr(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!

    int h1, m1, h2, m2;
    cin >> h1 >> m1 >> h2 >> m2;
    int l = (h2-h1)*60+(m2-m1);
    int k;
    cin >> k;
    cout << l - k  << "\n";
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key){
    return u;
  }
  if(k < u->key){
    return treeSearch(u->left,k);
  } else
    return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL)
    return treeMinimum(x->right);

  y=x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y;
  Node x;

  if(z->left == NIL || z->right == NIL){
    y = z;
  } else y = treeSuccessor(z);

  if(y->left != NIL){
    x = y->left;
  }else
    x = y->right;

  if(x != NIL)
    x->parent = y->parent;

  if(y->parent == NIL)
    root = x;
  else if(y == y->parent->left)
    y->parent->left = x;
  else
    y->parent->right = x;
  
  if(y != z)
    z->key = y->key; 
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;

  if(y == NIL){
    root = z;
  } else if(z->key < y-> key){
    y->left = z;
  } else{
    y->right = z;
  }
}

void inorder(Node u){
  if(u == NIL){
    return;
  }
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if (u == NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20444
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
int main() {
	string a, s, b;
	cin >> a;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] == 'B') {
			b = "";
			for (int j = 0; j < (int)(s.size()) - 1; j++) {
				b = b + s[j];
			}
			s = b;
		}
		else
			s = s + a[i];
	}
	cout << s << endl;
}

Measured memory_bytes: 256
class PriorityQueue
  attr_reader :data
  def initialize(array = [])
    @data = []
    array.each{|a| add(a)}
  end

  def add(element)
    @data.push(element)
    bottom_up
  end

  # @return Integer
  def peek
    @data[0]
  end

  # @return Integer
  def poll
    if size == 0
      return nil
    elsif size == 1
      return @data.pop
    else
      min = @data[0]
      @data[0] = @data.pop
      top_down
      return min
    end
  end

  # @return Integer
  def size
    @data.size
  end

  private

  def swap(i, j)
    @data[i], @data[j] = @data[j], @data[i]
  end


  def bottom_up
    idx = size - 1
    while(has_parent?(idx))
      parent_idx = parent_idx(idx)
      if @data[parent_idx] > @data[idx]
        swap(parent_idx, idx)
        idx = parent_idx
      else
        return
      end
    end
  end

  def top_down
    idx = 0
    while (has_child?(idx))
      a = left_child_idx(idx)
      b = right_child_idx(idx)
      if @data[b].nil?
        c = a
      else
        c = @data[a] <= @data[b] ? a : b
      end
      if @data[idx] > @data[c]
        swap(idx, c)
        idx = c
      else
        return
      end
    end
  end


  # @param Integer
  # @return Integer
  def parent_idx(idx)
    (idx - (idx.even? ? 2 : 1)) / 2
  end

  # @param Integer
  # @return Integer
  def left_child_idx(idx)
    (idx * 2) + 1
  end

  # @param Integer
  # @return Integer
  def right_child_idx(idx)
    (idx * 2) + 2
  end

  # @param Integer
  # @return Boolent
  def has_child?(idx)
    ((idx * 2) + 1) < @data.size
  end

  def has_parent?(idx)
    idx > 0
  end
end



n, m = gets.chomp.split.map(&:to_i)
alist = gets.chomp.split.map(&:to_i)

queue = PriorityQueue.new
alist.each do |a|
  queue.add(-a)
end

m.times do
  pop = queue.poll
  queue.add(-(-pop / 2).floor)
end

puts queue.data.inject(0){|sum, tmp| sum + (-tmp.to_i)}


Measured memory_bytes: 13076
#include<bits/stdc++.h>
using namespace std;
#define tezi ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
typedef long long ll;

vector<bool> prime(1000001, true);

void sieve(){
    prime[0] = prime[1] = false;
    for(int i = 2; i <= 1000000; ++i){
        if(!prime[i]) continue;
        int j = 2 * i;
        while(j <= 1000000){
            prime[j] = false;
            j += i;
        }
    }
}

ll binsearch(ll val){
    ll l = 0, r = 1000000, res = 0;
    while(l <= r){
        ll m = l + (r - l) / 2;
        if(m * (m + 1) <= val){
            res = m;
            l = m + 1;
        }
        else r = m - 1;
    }
    return res;
}

int main(){
    tezi;
    sieve();
    ll n, i = 2, ans = 0;
    cin >> n;
    vector<ll> v;
    while(n > 1 && i < 1000000){
        if(prime[i]){
            ll k = 0;
            while(n % i == 0){
                n /= i;
                k++;
            }
            v.push_back(k);
        }
        i++;
    }
    if(n > 1) v.push_back(1);
    for(const auto &it : v){
        ans += binsearch(2 * it);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4376
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	string ar[n];
	for(i=0;i<n;i++){
		cin>>ar[i];
	}

	ll c=0,c1=0,c2=0,c3=0;
	for(i=0;i<n;i++){
		ll v=ar[i].length();
		for(j=0;j<v-1;j++){
			if(ar[i][j]=='A'&&ar[i][j+1]=='B'){
				c++;
			}
		}
		if(ar[i][0]=='B'&&ar[i][v-1]=='A'){
			c1++;
		}
		if(ar[i][0]=='B'&&ar[i][v-1]!='A'){
			c2++;
		}
		if(ar[i][0]!='B'&&ar[i][v-1]=='A'){
			c3++;
		}
	}
	if(c1==0){
		c=c+min(c2,c3);
	}
	else {
		if(c2+c3==0){
			c+=(c1-1);
		}
		else {
			c+=(c1)+min(c2,c3);
		}
	}
	cout<<c;
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
using namespace std;

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	ul a[5];
   	ul n;
   	ul min;
   	int where = 0;
   	cin >> n;
   	REP(i, 5){
   		//int a;
   	    cin >> a[i];
   	    if(i == 0)min = a[0];
   	    if(a[i] < min){
   	    	min = a[i];
   	    	where = i;
   	    }
   	    
   	    //cout << i << a << "\n";
   	}
   	
   	cout <<(ul)((n + a[where] - 1)/a[where]) + 4 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

double e_value(int pi){
    return ((1.0+pi) * (pi/2.0)) / pi;
}

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

    int n, k;
    cin >> n >> k;

    vi a(n);
    int r_max = -1;
    int k_sum = 0;
    int cur_l = 0;
    int cur_r = 0;

    rep(i, n){
        cin >> a[i];
        if(i<k){
            k_sum += a[i];
            r_max += a[i];
            cur_r = i+1;
        }
        else{
            k_sum = k_sum - a[i-k] + a[i];
            if(k_sum > r_max){
                r_max = k_sum;
                cur_l = i-k+1;
                cur_r = i+1;
            }
        }
    }
    double ans = 0;
    for(int i=cur_l; i<cur_r; i++){
        ans += e_value(a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAX = 100100;
ll dp[MAX];
ll sum[MAX];
ll ten[15];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	ten[0] = 1;
	for (int i = 1; i < 15; i++)
		ten[i] = ten[i - 1] * 10;
	int A, B, P;
	while (cin >> A >> B >> P) {
		if (A == 0 && B == 0 && P == 0) break;
		memset(dp, 0, sizeof(dp));
		memset(sum, 0, sizeof(sum));
		for (int i = B; i >= A; i--) {
			dp[i - A] = 1;
			for (int j = 1; j < 6; j++) {
				ll mini = i*ten[j];
				if (mini > B) continue;
				ll maxi = 0;
				while (mini >= ten[maxi])
					maxi++;
				maxi = ten[maxi];
				maxi = min<ll>(maxi, B + 1);
				dp[i - A] += sum[mini-A] - sum[maxi-A];
			}
			for (int k = 9; k >= 0; k--) {
				if (i < ten[k] || (i / ten[k]) % 10 == 9) continue;
				ll mini = (i / ten[k] + 1) * ten[k];
				ll maxi = (i / ten[k + 1] + 1)*ten[k + 1];
				if (mini > B) continue;
				if (maxi > B) maxi = B + 1;
				//cout << i << " " << k << " " << mini << " " << maxi << endl;
				dp[i - A] += sum[mini-A] - sum[maxi-A];
			}
			dp[i - A] = (dp[i - A] % P + P) % P;
			sum[i - A] = (sum[i - A + 1] + dp[i-A]) % P;
			//cout << i << " " << dp[i - A] << endl;
		}
		cout << sum[0] << endl;
	}
    return 0;
}

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

using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;

constexpr lint mod = 1e9 + 7;

lint pw(lint a, lint n) {
  lint res = 1;
  while (n) {
    if (n & 1) (res *= a) %= mod;
    n >>= 1;
    (a *= a) %= mod;
  }
  return res;
}
lint inv(lint a) { return pw(a, mod - 2); }

int main() {
  constexpr int L = 1 << 20;
  V<lint> fact(L + 1, 1);
  for (int i = 2; i <= L; ++i) {
    fact[i] = i * fact[i - 1] % mod;
  }
  V<lint> finv(L + 1);
  finv[L] = inv(fact[L]);
  for (int i = L; i >= 1; --i) {
    finv[i - 1] = finv[i] * i % mod;
  }
  auto comb = [&](int n, int r) -> lint {
    if (r < 0 or r > n) return 0;
    return fact[n] * finv[r] % mod * finv[n - r] % mod;
  };

  int n, m, k;
  cin >> n >> m >> k;
  lint res = 0;
  for (int x = 0; x <= k; ++x) {
    int y = k - x;
    lint crr = comb(n + m + 2 * k, n + 2 * x);
    (crr *= (n + 1) * fact[2 * x + n] % mod * finv[x] % mod * finv[x + n + 1] % mod) %= mod;
    (crr *= (m + 1) * fact[2 * y + m] % mod * finv[y] % mod * finv[y + m + 1] % mod) %= mod;
    (res += crr) %= mod;
  }
  cout << res << '\n';
}


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

int main(){
	int n,po[101]={},ans=0;
	cin >> n;
	
	for(int i=2;i<=n;i++){
		int a = i;
		for(int j=2;j<=i;j++){
			while(a%j==0){
				a /= j;
				++po[j];
			}
		}
	}

	for(int i=2;i<=n;i++){
		if(po[i]>=74)ans++;
		for(int j=2;j<=n;j++){
			if(i==j)continue;
			if(po[i]>=4&&po[j]>=14)ans++;
			if(po[i]>=2&&po[j]>=24)ans++;
			for(int k=j+1;k<=n;k++){
				if(i==k)continue;
				if(po[i]>=2&&po[j]>=4&&po[k]>=4)
					ans++;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <numeric>
typedef long long int ll;
using namespace std;
int main(){
	int A,B,count=0;
	cin >> A>>B;
	string oss;
	
	for(int i=A;i<=B;i++){
		oss=to_string(i);
		if((oss[0]==oss[4])&&(oss[1]==oss[3])){
			count++;
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
def solve(N,A,X):  
  X.append(0)
  X.sort()
  ma=sum(X)

#[x]までのy個を使ってzを作る場合の数を数え上げるdp
#dp[x][y][z]=dp[x-1][y][z]+dp[x-1][y-1][z-X[x]](zが残っている場合）
#dp[x][y][z]=dp[x-1][y][z](zが残っていない場合)
  dp=[[[0] * (ma+1) for _ in range(N+1)] for _ in range(N+1)]
  
#[x]までの0個を使って0を作る方法は1つ（dp初期化）
  for i in range(N+1):
    dp[i][0][0]=1
  for i in range(1,N+1):
    cnt=X[i]
    for j in range(1,N+1):
      for k in range(ma+1):
        if k < cnt:
          dp[i][j][k]=dp[i-1][j][k]
        else:
          dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-cnt]

#ansはN枚中j枚使用かつj枚*平均Aを作れる個数。
  ans=0
  for x in range(1,N+1):
    if x*A<=ma:
      ans+=dp[N][x][x*A]
  return ans

N,A=map(int,input().split())
X=[int(a) for a in input().split()]
ans=solve(N,A,X)
print(ans)


Measured memory_bytes: 91868
let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let es = Array.make n max_int in
  for i = 0 to m - 1 do
    Scanf.scanf "%d %d\n" @@ fun a b ->
      es.(a - 1) <- min (b - 1) es.(a - 1)
  done;
  let acc = ref 0 in
  for i = 0 to n - 2 do
    if es.(i) = i + 1 then incr acc
    else es.(i + 1) <- min es.(i) es.(i + 1)
  done;
  Printf.printf "%d\n" !acc


Measured memory_bytes: 5376
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#define ll long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000//10^12


int main(void)
{
	//変数の宣言
	int n;
	char s[60][60];
	int strtemp[30];
	int strans[30];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;
	
	
	//データの読み込み
	scanf("%d",&n);
//	scanf_s("%d",&n);

	for(i=0;i<n;i++){
		scanf("%s",&s[i]);
//		scanf_s("\n%s",&s[i],60);	
//		printf("s[%d]=%s",i,s[i]);
	}

	for(i=0;i<30;i++){
		strtemp[i]=0;
		strans[i]=0;
	}

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理
	
	for(i=0;i<n;i++){
		len=strlen(s[i]);
		for(j=0;j<len;j++){
//			printf("s[i][j]=%d",s[i][j]);
			strtemp[s[i][j]-97]++;
		}
		for(j=0;j<26;j++){
//			printf("%c=%d",'a'+j,strtemp[j]);
			if(i==0) strans[j]=strtemp[j];
			strans[j]=min(strans[j],strtemp[j]);
			strtemp[j]=0;
		}
//		printf("\n");
	}
	


	//	printf("計算部分終了\n");
	
	//出力
	
	for(i=0;i<26;i++){
//		printf("%c=%d",'a'+i,strans[i]);
		for(j=0;j<strans[i];j++){
			printf("%c",i+97);
		}
	}


	//	printf("結果の出力終了\n");

	
	return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define inf(x) (ll)(1e##x)
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
int n,a[201000],h[201000];
bool check(int lim){
	for(int i=1;i<2*n;i++) h[i]=a[i]>=lim;
	if(h[n]==h[n-1]||h[n]==h[n+1]) return h[n];
	for(int i=1;i<n;i++){
		if(h[n-i]==h[n-i-1]) return h[n-i];
		if(h[n+i]==h[n+i+1]) return h[n+i];
	}
	if(n&1) return h[n];
	else return !h[n];
}
int main(){
	read(n);
	for(int i=1;i<2*n;i++) read(a[i]);
	int l=1,r=2*n;
	while(l+1<r){
		int mid=l+r>>1;
		if(check(mid)) l=mid;
		else r=mid;
	}
	cout<<l<<'\n';
	return 0;
}

Measured memory_bytes: 1920
y = [int(input()) for _ in range(5)]
k = int(input())
if y[4] - y[0] > k:
	print(":(")
	exit(0)
for i in range(4):
	if y[i + 1] - y[i] > k:
		print(":(")
		exit(0)
print("Yay!")

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

long long n, m;
char s[100010];
char t[100010];

long long g;
long long lcm;	//lcm


long long gcd(long long a, long long b)
{
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}

bool check(char *a, char *b, long long szA, long long szB, long long dA, long long dB)
{
	long long pa = 0;
	long long pb = 0;
	
	long long gcdD;
	if (dA > dB)
		gcdD = gcd(dA, dB);
	else
		gcdD = gcd(dB, dA);
		
	long long lcmD = dA * dB / gcdD;
	long long ddA = lcmD / dA;
	long long ddB = lcmD / dB;
	
	while (pa < szA || pb < szB)
	{
//		if (pa == pb)
//		{
			if (a[pa] != b[pb])
				return false;
//		}
		
		pa = pa + ddA;
		pb = pb + ddB;
		
//		if (pa > pb)
//		{
//			//+pb
//			if (pb < total)
//				pb = pb + dB;
//		}
//		else
//		{
//			//+pa
//			if (pa < total)
//				pa = pa + dA;
//		}
		
	}
	
	return true;
}


int main()
{
	scanf("%lld%lld\n", &n, &m);
	scanf("%s\n", s);
	scanf("%s", t);
	
	
	if (n > m)
		g = gcd(n, m);
	else
		g = gcd(m, n);
		
	lcm = n * m / g;
		
	if (false == check(s, t, n, m, lcm / n, lcm / m))
	{
		printf("-1\n");
		return 0;
	}
	
	printf("%lld\n", lcm);
	
	return 0;
}

Measured memory_bytes: 384
def f(c):
    if c == "a":
        return 0
    return ord("z") - ord(c) + 1

s = input()
K = int(input())
ans = list(s)
for i, c in enumerate(s):
    n = f(c) 
    # print(c, n, K)
    if n <= K:
        ans[i] = "a"
        K -= n
if K > 0:
    ans[-1] = chr((ord(ans[-1]) - ord("a") + K) % 26 + ord("a"))
print("".join(ans))


Measured memory_bytes: 4340
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    string s;
    cin >>s;
    int i;
    int flag[26];
    for(i=0;i<26;i++){
      flag[i]=0;
    }
    for(i=0;i<s.size();i++){
      flag[s[i]-97]=1;
    }
    for(i=0;i<26;i++){
      if(flag[i]==0){
        cout << (char)(i+97)<<endl;
        return 0;
      }
    }
    cout << "None";
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define MAX 1000000000 // 10^9

vector<vector<P>> V(100001); // first : 誕生した都市
				     // 入力順
P citynum[100001];

// 桁数を返す
int nsize(int n) {
	int res = 1;
	while (n / 10 != 0) {
		n /= 10;
		res++;
	}
	return res;
}

int main() {
	
	int N, M; cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		int p, year; cin >> p >> year;
		V[p].push_back(P(year, i));
	}

	//cout << "ok1" << endl;

	for (int i = 1; i <= N; i++) sort(V[i].begin(), V[i].end());
	//cout << "ok2" << endl;

	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < V[i].size(); j++) citynum[V[i][j].second] = P(i, j + 1);
	}
	//cout << "ok3" << endl;

	for (int i = 1; i <= M; i++) {
		int cnt1 = nsize(citynum[i].first);
		int cnt2 = nsize(citynum[i].second);
		for (int j = 0; j < 6-cnt1; j++) cout << "0";
		cout << citynum[i].first;
		for (int j = 0; j < 6-cnt2; j++) cout << "0";
		cout << citynum[i].second << endl;
	}

	return 0;
}

Measured memory_bytes: 7808
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(a, b, c) = in.readLine().split("\\s+").map(_.toInt)

    out.println(
      List(a, b, c).max * 10 + List(a, b, c).min + List(a, b, c).sorted.tail.head
    )

    out.flush()
  }
}


Measured memory_bytes: 27332
#include <bits/stdc++.h>
using namespace std;
int a[100005];
string out[]={"First","Second"};
int gcd(int a,int b)
{
	if (!a || !b)
	return (a^b);
	return __gcd(a,b);
}
int main()
{
	int n;
	cin >> n;
	for (int i=0;i<n;i++)
	cin >> a[i];
	for (int i=0;;i^=1)
	{
		int e=0;
		for (int j=0;j<n;j++)
		e+=(a[j]%2==0);
		if (e%2)
		{
			cout << out[i];
			return 0;
		}
		if (e!=n-1)
		{
			cout << out[!i];
			return 0;
		}
		int g=0;
		for (int j=0;j<n;j++)
		{
			if (a[j]==1)
			{
				cout << out[!i];
				return 0;
			}
			a[j]-=(a[j]%2);
			g=gcd(g,a[j]);
		}
		for (int j=0;j<n;j++)
		a[j]/=g;
	}
}

Measured memory_bytes: 640
#include <stdio.h>

int x[110],res[110];
int a;
void solve(int k, int value, int &sum){
	 x[k] = value;
	if(k==1){
		sum++;
		if(sum==a){
            for(int i=1;i<=10;i++)
                 res[i] = x[i];
		}
		return;
	}

	if(value>=1) solve(k-1,value-1,sum);

	solve(k-1,value,sum);

	if(value<=8) solve(k-1,value+1,sum);

}
int main(){
	scanf("%d",&a);

	int sum = 0;
	for(int i=1;i<=10;i++)
		for(int j=1;j<=9;j++)
			solve(i,j,sum);

	int p = 0;
	for(int i=10;i>=1;i--)
		if(res[i]!=0){
			p = i;
			break;
		}
	for(int i=p;i>=1;i--)
          printf("%d",res[i]);
}


Measured memory_bytes: 128
def ascan; gets.split.map(&:to_i); end

N,M = ascan
br = M.times.map{a,b=ascan;[b,a]}.sort

ans = 0
last = nil
br.each do |en,be|
    if !last
        last = en
        ans += 1
    else
        if last <= be
            ans += 1
            last = en
        end
    end
end

p ans

Measured memory_bytes: 11128
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	var n = toInt(input[0]);
	var as = toIntArr(input[1].split(' '));

	console.log(max.apply(this,as) - min.apply(this,as));
}

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#include<cstdio>
#include<string>
using namespace std;
 int q,p,w[1000001],u[1000001],o;
 string a;
 int main(){cin>>a;
     for (int i=0;i<a.size();i++){if (a[i]=='C'){p++;u[p]=i+1;}
         else if (a[i]=='F'){q++;w[q]=i+1;}}
     if (q>=1 && p>=1){
     for (int i=1;i<=p;i++){
         for (int j=1;j<=q;j++){
             if (u[i]<w[j]){
                 o=1;}}}
     if (o==1) cout<<"Yes"<<endl;
     else cout<<"No"<<endl; }
     else cout<<"No"<<endl;
     return 0;
}

Measured memory_bytes: 2304
#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++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int X,N;
    cin>>X>>N;
    vector<int> p(N);
    rep(i,N){
        cin>>p[i];
    }
    int ans=1000;
    bool notflag=false;
    rep2(i,0,1000){
        notflag=false;
        rep(j,N){
            if(i==p[j]){
                notflag=true;
            }
        }
        if(notflag){
            continue;
        }else{
            if(abs(X-i)<abs(X-ans)||(abs(X-i)==abs(X-ans)&&ans>i)){
                ans=i;
            }
        }
    }
    if(N==0){
        ans==X;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652