akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

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

long N,K;
string s;
int main(void) {
  cin >> N >> K;
  cin >> s;
  s[K-1] += ('a' - 'A');

  cout << s << endl;
  return 0;
}

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

using namespace std;

int n, m;
vector<int> e[9];
int res = 0;

void dfs(int p, int sum, int v[]) { //p:現在訪問しているノード番号 sum:今までに訪れたノードの数 v:今までに訪れたノード番号を格納する配列
	int tempv[9];
	for (int i = 0; i < 9; i++)tempv[i] = v[i];

	/*for (int i = 1; i <= 8; i++)cout << v[i] << ' ';
	cout << endl;*/

	sum++;
	if (sum == n) {
		res++;
		//cout << "g =" << ' ' << p << endl;
		return;
	}

	//ノードpに隣接するノードを探索
	for (int i = 0; i < e[p].size(); i++) {	//もし隣接ノードが未訪問なら再帰する
		//cout << "check" << e[p][i] << endl;
		if (v[e[p][i]] == 0) {
			v[e[p][i]] = 1; //訪問するノードを記憶
			dfs(e[p][i], sum, v);
			for (int j = 0; j < 9; j++)v[j] = tempv[j];
		}
	}

	return; //隣接ノードがすべて訪問済みで条件に一致しない場合は戻る
}

int main() {

	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		e[a].push_back(b);
		e[b].push_back(a);
	}

	int v[9] = { 0,1,0,0,0,0,0,0,0 };
	dfs(1, 0, v);

	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<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;
	int h,w;cin>>h>>w;
	vector<string> a(h);
	vvint f;
	int inf = 100000;
	initvv(f, h, w, inf);
	queue<P> q;

	rep(i, h){
		cin>>a[i];
		rep(j, w){
			if(a[i][j] == '#'){
				q.push(P(i, j));
				f[i][j] = 0;
			}
		}
	}
	int ans = 0;
	while(!q.empty()){
		P top = q.front();q.pop();
		int x,y,cost;
		x = top.first;y = top.second;
		cost = f[x][y];
		chmax(ans, cost);
		rep(i, 4){
			int nx = x + dx[i];
			int ny = y + dy[i];
			in(nx, ny, h, w){
				if(f[nx][ny]==inf){
					q.push(P(nx, ny));
					f[nx][ny] = cost+1;
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 13456
import java.util.*;

class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    boolean result = false;
    for(int i = 1; i < 10; i++) {
	    for(int j = 1; j < 10; j++) {
          int x = i * j;
          if(a == x) {
            result = true;
            break;
          }
        }
      if(result) {
        break;
      }
    }
    
    if(result) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    } 
  }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long
map<int, int> ma;
  
signed main() {
  int n;
  cin >>n;
  vector<int> a(n);
  vector<int> b(n);
  rep(i,n) {
    cin >> a[i]>>b[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if(n%2==1) {
    cout <<b[n/2]-a[n/2]+1 << endl;
  }
  else {
    cout << b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1 << endl;
  }

  return 0;
}

Measured memory_bytes: 6380
#include<stdio.h>
int dp[50];
int fib(int n){
  if (n == 0 || n == 1) return dp[n]=1;
  if(dp[n]!=-1) return dp[n];
  return dp[n]=fib(n-1)+fib(n-2);
}
int main()
{
  int n,i;
  for(i=0;i<50;i++) dp[i]=-1;
  scanf("%d",&n);
  printf("%d\n",fib(n));
  return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <list>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <vector>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
// const ll MOD = 1000000009;


int main() {
    ll n;
    cin >> n;
    char alphabet[10] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};
    ll m = 1;
    for (ll i = 1; i <= n; ++i) {
        m *= i;
    }
    vector<ll> vals(n, 0);

    while (true) {
        bool ok = true; {
            ll valmax = 0;
            for (ll i = 0; i < n; ++i) {
                if (vals[i] > valmax + 1) {
                    ok = false;
                    break;
                }
                valmax = max(valmax, vals[i]);
            }
        }

        if (ok) {
            for (ll i = 0; i < n; ++i) {
                cout << alphabet[vals[i]];
            }
            cout << endl;
        }
        ll carry = 1;
        for (ll i = n - 1; i >=0; --i) {
            if (carry == 0) break;
            vals[i]++;
            carry = 0;
            if (vals[i] == i + 1) {
                carry = 1;
                vals[i] = 0;
            }
        }
        if (carry == 1) break;
    }
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m;
  cin >> n >> m;
  vector<int> sx(n);
  vector<int> sy(n);
  vector<int> cx(m);
  vector<int> cy(m);
  for (int i=0; i<n; i++) {
    cin >> sx.at(i) >> sy.at(i);
  }
  for (int i=0; i<m; i++) {
    cin >> cx.at(i) >> cy.at(i);
  }
  for (int i=0; i<n; i++) {
    int t=1000000009,s=0,ans=0;
    for (int j=0; j<m; j++) {
      s = abs(sx.at(i)-cx.at(j)) + abs(sy.at(i)-cy.at(j));
      if (t>s) {
        t = s;
        ans = j+1;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */
const ll MOD = 1e9+7;
int main() {
  ll n;
  string s;
  cin >> n >> s;
  vector<ll> cnt(26, 0);
  REP(i, n){
    cnt[s[i] - 'a']++;
  }
  ll ans = 1;
  REP(i, 26){
    (ans *= cnt[i]+1) %= MOD;
  }
  ans--;
  cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		Set<Integer> s = new HashSet<Integer>();
		int N = sc.nextInt(), i = 1, t = 0;
		while (N-->0) {
			int a = sc.nextInt();
			if (s.contains(a-1) && a==i) t--;
			if (a==i) { 
				if (!s.contains(a-1)) s.add(a); 
				t++; 
			}
			i++;
		}
		System.out.println(t);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 61912
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
	int N, K, sum = 1;
	scanf("%d %d", &N, &K);
	for(int i = 1; i <= N; i++) {
		if(sum * 2 < (sum + K)) sum = sum * 2;
		else sum = sum + K;
	}
	printf("%d\n", sum);
}

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

int main(){
  int t[4];
  int tt[4];
  int a,b,bb,c;
  while(true){
    cin>>a;
    c=0;
    if(a==0)break;
    for(int i=1111;i<10000;i+=1111){
      if(i==a){
	cout<<"NA"<<endl;
	c=-1;
      }
    }
    if(c==-1)continue;
    while(a!=6174){
      b=a;
      c++;
      for(int i=3;i>=0;i--){
	t[i]=b%10;
	b/=10;
      }
      sort(t,t+4);
      reverse(t,t+4);
      b=t[0]*1000+t[1]*100+t[2]*10+t[3];

      bb=a;
      for(int i=3;i>=0;i--){
	t[i]=bb%10;
	bb/=10;
      }
      sort(t,t+4);
      bb=t[0]*1000+t[1]*100+t[2]*10+t[3];
      
      a=b-bb;
      //cout<<a<<endl;
    } 
    cout<<c<<endl;
    
  }
  return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	int a, b, k;
	cin >> k >> a >> b;
	bool ans = false;
	for(int i=a; i<=b; ++i)
		if(i%k==0) ans = true;
	if(ans)
		cout << "OK\n";
	else
		cout << "NG\n";
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 2000010;
const LL MOD = 1e9 + 7;
int X[6] , Y[6];
LL fct[MC];
LL inv[MC];
LL ans;

void build(){
	fct[0] = fct[1] = 1;
	repp(i,2,MC){
		fct[i] = fct[i-1] * i % MOD;
	}
	LL x = fct[MC-1];
	inv[MC-1] = 1;
	for(int i = MOD - 2 ; i > 0 ; i >>= 1){
		if(i % 2 == 1) (inv[MC-1] *= x) %= MOD;
		(x *= x) %= MOD;
	}
	repm(i,MC-1,0){
		inv[i-1] = inv[i] * i % MOD;
	}
}

LL comb(int x , int y){
	if(x < 0 || y < 0) return 0;
	return fct[x+y] * inv[x] % MOD * inv[y] % MOD;
}

int main(){
	repp(i,0,6) scanf("%d" , X + i);
	repp(i,0,6) scanf("%d" , Y + i);
	int p[2] = {X[0]-1 , X[1]};
	int q[2] = {Y[0]-1 , Y[1]};
	int u[2] = {X[4] , X[5]+1};
	int v[2] = {Y[4] , Y[5]+1};
	build();
	repp(i,0,4){
		repp(j,0,4){
			LL z = abs(2*i-3) == abs(2*j-3) ? 1 : (MOD-1);
			repp(s,X[2],X[3]+1){
				(ans += comb(s-p[i/2] , Y[2]-1-q[i%2]) * comb(u[j/2]-s , v[j%2]-Y[2]) % MOD * (MOD-s-Y[2]) % MOD * z) %= MOD;
				(ans += comb(s-p[i/2] , Y[3]-q[i%2]) * comb(u[j/2]-s , v[j%2]-Y[3]-1) % MOD * (s+Y[3]+1) % MOD * z) %= MOD;
			}
			repp(t,Y[2],Y[3]+1){
				(ans += comb(X[2]-1-p[i/2] , t-q[i%2]) * comb(u[j/2]-X[2] , v[j%2]-t) % MOD * (MOD-X[2]-t) % MOD * z) %= MOD;
				(ans += comb(X[3]-p[i/2] , t-q[i%2]) * comb(u[j/2]-X[3]-1 , v[j%2]-t) % MOD * (X[3]+t+1) % MOD * z) %= MOD;
			}
		}
	}
	printf("%lld\n" , ans);
	return 0;
}


Measured memory_bytes: 31488
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        hoge();
        System.Console.ReadLine();
    }

    public static void hoge()
    {
        var vars = System.Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var n = vars[0];

        var a = System.Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        long kane = 1000;
        long kabu = 0;

        int updown = 0;
        var maxmin = a[0];
        long prevkane = 1000;
        for(int i = 1; i < a.Length; i++)
        {
            var current = 0;

            // 値下がり中なら最安値を保存
            if(updown == -1)
            {
                if(maxmin > a[i])
                {
                    maxmin = a[i];
                }
            }
            // 値上がり中なら最高値を保存
            if (updown == 1)
            {
                if (maxmin < a[i])
                {
                    maxmin = a[i];
                }
            }

            if (a[i-1] < a[i])
            {
                // 値上がり
                current = 1;
            }
            else if(a[i-1] > a[i])
            {
                // 値下がり
                current = -1;
            }
            // 下がり基調だったのが値上がりに転じた→今までの最安から買い
            if(current == 1 && updown == -1)
            {
                kabu = kane / maxmin;
                kane = kane % maxmin;
                prevkane = kane;
                maxmin = a[i];
                updown = 1;
            }
            // 上がり基調だったのが値下がりに転じた→今までの最高で売り
            else if (current == -1 && updown == 1)
            {
                kane += kabu * maxmin;
                kabu = 0;
                maxmin = a[i];
                updown = -1;
            }

            if(updown == 0)
            {
                // 最初である場合で値上がりの場合は株を買っておく
                if(current == 1)
                {
                    kabu = kane / maxmin;
                    kane = kane % maxmin;
                    prevkane = kane;
                    maxmin = a[i];
                }
                updown = current;
                if (updown == -1)
                {
                    if (maxmin > a[i])
                    {
                        maxmin = a[i];
                    }
                }
                if (updown == 1)
                {
                    if (maxmin < a[i])
                    {
                        maxmin = a[i];
                    }
                }
            }

        }

        // 上がり基調で終わったら清算
        if(updown == 1)
        {
            kane += kabu * maxmin;
        }

        Console.WriteLine(kane > prevkane ? kane : prevkane);
    }
}

Measured memory_bytes: 28160
#include <stdio.h>

int main(void)
{
	int i,j,k,w,h;
	
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0&&w==0) break;
		for(k=0;k<w;k++){
			printf("#");
		}
		printf("\n");
		for(i=1;i<h-1;i++){
			printf("#");
			for(j=1;j<w-1;j++){
				printf(".");
			}
			printf("#\n");
		}
		for(k=0;k<w;k++){
			printf("#");
		}
		printf("\n\n");
	}
	
	return 0;
}

Measured memory_bytes: 588
#include <stdio.h>
 
long long int gcd( long long int m, long long int n ){	
	while( n > 0 ){
		long long int r = m % n;
		m = n;
		n = r;
	}
	return m;	
}
 
int main(){
	
	int n, i;
	long long int T[100];
	scanf("%d", &n);
	for( i = 0; i < n; i++ ){
		scanf( "%lld", &(T[i]) );
	}
	
	long long int g;
	long long int result = T[0];
	for( i = 1; i < n; i++ ){
		g = gcd( result, T[i] );
		result *= T[i]/g;
	}
	
	printf("%lld", result);
	
	return 0;
	
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;
class Program{
    int N,v[], c[], arr[];
    ArrayList<Integer> sub_c = new ArrayList<Integer>();
    ArrayList<Integer> sub_v = new ArrayList<Integer>();
    ArrayList<Integer> p = new ArrayList<Integer>();
    Program(int v[], int c[], int N){
        this.v = v;
        this.c = c;
        this.N = N;
        this.arr = new int[N];
    }
    void solve(int i){
        if (i==N) p.add(price());
        else{
            sub_c.add(c[i]);
            sub_v.add(v[i]);
            solve(i+1);
            sub_c.remove(sub_c.size()-1);
            sub_v.remove(sub_v.size()-1);
            solve(i+1);
        }    
    }
    int ans(){
        return Math.max(0,Collections.max(p));
    }
    int price(){
        int sum = 0;
        for(int i=0;i<sub_c.size();i++) sum += sub_v.get(i) - sub_c.get(i);
        return sum;
    }
}
class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int v []= new int[N];
        int c []= new int[N];
        for(int i=0;i<N;i++) v[i] = in.nextInt();
        for(int i = 0;i<N;i++) c[i] = in.nextInt();
        Program obj = new Program(v,c,N);
        obj.solve(0); System.out.println(obj.ans());
    }
}

Measured memory_bytes: 65636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

void solve() 
{
    string s,t;cin>>s>>t;
    vector<vector<int>>dp(3030,vector<int>(3030,0));
    rep(i,1,s.size()+1)rep(j,1,t.size()+1){
        if(s[i-1]==t[j-1])dp[i][j]=dp[i-1][j-1]+1;
        else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
    }
    stack<char>ans;
    int ss=s.size(),ts=t.size();
    while(ss!=0&&ts!=0){
        if(s[ss-1]==t[ts-1]){
            ans.push(s[ss-1]);
            ss--;ts--;
        }else dp[ss-1][ts]>=dp[ss][ts-1]?ss--:ts--;
    }
    while(!ans.empty()){cout<<ans.top();ans.pop();}cout<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 36224
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
using namespace std;
#define sci(n) scanf(“%lld”, &(n))
#define scd(n) scanf(“%Ld”, &(n))
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> pll;
int main(void)
{
	int n, idx = -1;
	double avg = 1e9+7;
	cin >> n;
	vector<LL> v(n);
	double sum = 0;
	for (int i = 0; i < v.size();i++) {
		cin >> v[i]; sum += v[i];
	}
	sum /= n;

	for (int i = 0; i < v.size();i++) {
		if (avg > abs(sum-v[i])) {
			avg = abs(sum - v[i]);
			idx = i;
		}
	}
	cout << idx;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int A,B,C,D,P,all;
	scanf("%d %d %d %d %d",&A,&B,&C,&D,&P);
	if(P<=C){}
	else{
		B+=(P-C)*D;
	}
	all=min(A*P,B);
	printf("%d\n",all);
	return 0;
}
//9:53.939クリア


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define _for(i, begin, end) for (int i = begin; i < end; i++)
#define _rep(i, begin, end) for (int i = begin; i <= end; i++)
using namespace std;
typedef long long LL;

int nextInt() {
	LL res = 0;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar());
	for (; isdigit(ch); ch = getchar()) {
		(res *= 10) += ch - 48;
	}
	return res;
}

int main() {
	LL A = nextInt(), B = nextInt(), C = nextInt();
	LL X = nextInt(), Y = nextInt();
	LL ans1 = A*X + B*Y;
	LL ans2 = 2*X*C + min(max(0ll, Y-X)*B, max(0ll, Y-X)*2*C);
	LL ans3 = 2*Y*C + min(max(0ll, X-Y)*A, max(0ll, X-Y)*2*C);
	printf("%lld\n", min(ans1, min(ans2, ans3)));
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int m,fl,l,r,n; char S[100005];
int main(){
	scanf("%s",S+1); n=strlen(S+1);
	l=n+1>>1; r=n;
	while (l<r){
		m=l+r+1>>1; fl=1;
		for (int i=n-m+1;i<m;++i)
		if (S[i]!=S[m]) fl=0;
		if (fl) l=m; else r=m-1;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int a,b,c,d;
    d=n%10;
    c=(n/10)%10;
    b=(n/100)%10;
    a=n/1000;
    if(a+b+c+d==7)printf("%d+%d+%d+%d=7\n",a,b,c,d);
    else if(a-b+c+d==7)printf("%d-%d+%d+%d=7\n",a,b,c,d);
    else if(a+b-c+d==7)printf("%d+%d-%d+%d=7\n",a,b,c,d);
    else if(a+b+c-d==7)printf("%d+%d+%d-%d=7\n",a,b,c,d);
    else if(a-b-c+d==7)printf("%d-%d-%d+%d=7\n",a,b,c,d);
    else if(a-b+c-d==7)printf("%d-%d+%d-%d=7\n",a,b,c,d);
    else if(a+b-c-d==7)printf("%d+%d-%d-%d=7\n",a,b,c,d);
    else if(a-b-c-d==7)printf("%d-%d-%d-%d=7\n",a,b,c,d);

    return 0;
}


Measured memory_bytes: 128
N, K = map(int, input().split())

count_a = 0

for i in range(1, N + 1):
    if i % K == 0:
        count_a += 1

count_b = 0
count_list = []
if K % 2 == 0:
    for i in range(1, N+1):
        if i % K == K/2:
            count_list.append(i)
    count_b += len(count_list) ** 3

print(count_a**3 + count_b)

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

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

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int m, d ;
  cin >> m >> d ;
  int count = 0 ;
  
  
  for(int i= 22;i<=d;i++){
    if(i/10>=2 && i%10>=2 && (i/10)*(i%10)<=m){
      count++ ;
    }
  }
  cout << count <<endl ;
    return 0 ;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define init(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, a, b) for (int i = a; i < b; i++)
#define loopr(i, a, b) for (int i = a; i >= b; i--)
#define loops(i, a, b, step) for (int i = a; i < b; i += step)
#define looprs(i, a, b, step) for (int i = a; i >= b; i -= step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie();                        \
    cout.tie();
#define FILE_READ_IN freopen("input.txt", "r", stdin);
#define FILE_READ_OUT freopen("output.txt", "w", stdout);
#define all(a) a.begin(), a.end()
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

void solve()
{
    ll n, k;
    cin >> n >> k;
    ll arr[n], sum = 0;
    for(int i = 0; i < n; i++) cin >> arr[i];
    sort(arr, arr + n);
    for(int i = n - 1 - k; i >=0; i--)
    {
        sum += arr[i];
    }
    cout << sum << "\n";
}

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

Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int a;
    cin >> a;
    cout << 3*a*a << endl;
    


    return 0;
}

Measured memory_bytes: 256
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		long m = 0;
		long a=0;
		long r=0;
		long c=0;
		long h=0;



		long[] D=new long[5];

		int[] P={0,0,0,0,0,0,1,1,1,2};
		int[] Q={1,1,1,2,2,3,2,2,3,3};
		int[] R={2,3,4,3,4,4,3,4,4,4};

		for (int i = 0; i < N; i++) {

			String buf=sc.next();

			if(buf.substring(0, 1).equals("M"))m++;
			if(buf.substring(0, 1).equals("A"))a++;
			if(buf.substring(0, 1).equals("R"))r++;
			if(buf.substring(0, 1).equals("C"))c++;
			if(buf.substring(0, 1).equals("H"))h++;

		}

		D[0]=m;
		D[1]=a;
		D[2]=r;
		D[3]=c;
		D[4]=h;

		long res=0;

		for (int d = 0; d < 10; d++) {
			res+=D[P[d]]*D[Q[d]]*D[R[d]];
		}

		System.out.println(res);
	}

	//以下テンプレート

	public static int[] extgcd(int a, int b) {

		int x0 = 1;
		int x1 = 0;

		int y0 = 0;
		int y1 = 1;

		while (b != 0) {
			int q = a / b;
			int r = a % b;

			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;

			a = b;
			b = r;

			x0 = x1;
			x1 = x2;

			y0 = y1;
			y1 = y2;
		}

		return new int[] { a, x0, y0 };

	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;

		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		return gcd(b, a % b);

	}

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

	static void swap(int[] a) {
		int t;

		t = a[0];
		a[0] = a[1];
		a[1] = t;

		return;
	}

	static <T> void output(List<T> list) {

		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i));

			if (i != list.size() - 1) {
				System.out.print(" ");
			} else {
				nl();
			}
		}

	}

	static void output(String[][] str) {

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				print(str[i][j]);
			}

			nl();
		}

	}

	static void output(boolean flg, String Yes, String No) {

		if (flg) {
			pln(Yes);
		} else {
			pln(No);
		}

	}

	static void output(String[][] str, int digit) {

		String dig = "%" + String.valueOf(digit) + "s";

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				System.out.printf(dig, str[i][j]);
			}
			nl();
		}

	}

	static void pln(String str) {
		System.out.println(str);
	}

	static void pln(int x) {
		System.out.println(x);
	}

	static void print(String str) {
		System.out.print(str);
	}

	static void print(int x) {
		System.out.print(x);
	}

	static void print(String str, int times) {
		for (int i = 0; i < times; i++) {
			print(str);
		}
	}

	static void print(int x, int times) {
		for (int i = 0; i < times; i++) {
			print(x);
		}
	}

	static void nl() {
		System.out.println();
	}

}


Measured memory_bytes: 45664
from collections import deque

N, M = map(int, input().split())
E = {u: set() for u in range(1, N+1)}
for i in range(M):
    u, v = map(int, input().split())
    E[u].add(v)
S, T = map(int, input().split())

X = {}
for u in E:
    for i in range(3):
        X[(u, i)] = set([(v, (i + 1) % 3) for v in E[u]])

# bfs
queue = deque()
queue.append(((S, 0), 0))
visited = set()

while len(queue) > 0:
    u, n = queue.popleft()
    if u in visited:
        continue
    visited.add(u)
    if u == (T, 0):
        print(n // 3)
        exit()
    for v in X[u]:
        queue.append((v, n + 1))

print(-1)


Measured memory_bytes: 165136
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << endl; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n; cin >> n;
  
  vector<Pll> a(n);
  rep(i, n) {
    int x; cin >> x;
    a[i] = Pll(x, i);
  }
  sort(all(a));
  drep(i, n-1) chmin(a[i].second, a[i+1].second);

  Vll ans(n);
  ans[0] = a[0].first * n;
  rep(i, n-1) ans[a[i+1].second] += (a[i+1].first - a[i].first) * (n-i-1);

  cout << ans;
  return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
ll n,m,cnt,ans;
int cal(int a,int b)
{
	if(a<b)return 0;
	if(!(a%b))return a/b;
	int k=a-(ll)a*(b-1)/b,j;
	int l1,r1,m1;
	l1=1;r1=a/k;
	while(l1<r1)
	{
		m1=(l1+r1)/2+1;j=a-m1*k;
		if(j-(ll)j*(b-1)/b==k)l1=m1;
		else r1=m1-1;
	}
	return cal(a-l1*k,b);
}
int main()
{
	int i,s,a,b,j,k;
	scanf("%lld",&n);
	for(i=1;i<=n;i++)scanf("%d%d",&a,&b),ans^=cal(a,b);
	if(ans)printf("Takahashi");
	else printf("Aoki");
	return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio

using namespace std;

inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }

const int N = 200000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

vector<int> g[N];

int ans = 1;

int dfs(int u, int p) {
    int best = 1;
    for (int v : g[u]) {
        if (v != p) {
            int len = dfs(v, u);
            setmax(ans, best + len);
            setmax(best, len + 1);
        }
    }
    return best;
}

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    rep(i, 0, n - 1) {
        int u, v;
        cin >> u >> v; u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(0, -1);
    cout << (ans % 3 == 2 ? "Second\n" : "First\n");
    return 0;
}

Measured memory_bytes: 20224
#include<iostream>
using namespace std;
int main()
{
  int a[6];int pos;
  for(int i=1;i<6;i++)
  {
    cin>>a[i];
    if(a[i]==0)
    {
      pos=i;
      break;
    }
  }
  cout<<pos<<"\n";
  return 0;
}
 
  

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pll pair <long long,long long>
#define fi first
#define se second
#define ll long long
using namespace std;
int main () {
	ios;
	ll n;
	cin>>n;
	ll d[n+1],a[n+1];
	for (int k=1;k<=n;k++) cin>>a[k];
	d[1]=0;
	d[2]=abs(a[2]-a[1]);
	for (int k=3;k<=n;k++) {
		if (d[k-1]+abs(a[k]-a[k-1])<d[k-2]+abs(a[k]-a[k-2])) d[k]=d[k-1]+abs(a[k]-a[k-1]);
		else d[k]=d[k-2]+abs(a[k]-a[k-2]);
	}
	cout<<d[n];
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
using ll = unsigned long long;

ll gcd(ll m, ll n){
  if(n==0) return m;
  else return gcd(n, m%n);
}

int main(){
  ll n, m;
  cin >> n >> m;
  string s, t;
  cin >> s;
  cin >> t;
  ll g = gcd(n, m);
  ll L = n*m/g;

  for(ll i = 0; i < g; i++){
    if( s[i*n/g] != t[i*m/g] ){
      cout << "-1\n";
      return 0;
    }
  }
  cout << L << "\n";
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int x;
	if (n % 2 == 0) {
		x = (n / 2)*(n / 2);
	}
	else {
		x = (n / 2)*(n / 2 + 1);
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
int main(){
    int n,h,a[N],b[N],ma=0,ans=0;
    cin>>n>>h;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        ma=max(a[i],ma);
    }
    sort(b,b+n,greater<int>());
    for(int i=0;i<n;i++){
        if(h>0&&b[i]>ma){
            h-=b[i];
            ans++;
        }else{
            break;
        }
    }
    if(h>0){
        cout<<ans+h/ma+(h%ma>0)<<'\n';
    }else{
        cout<<ans<<'\n';
    }
}


Measured memory_bytes: 1024
_ = input()
As = map(int, input().strip().split())

total_steps_height = 0
current_height = 0

for Ai in As:
	if current_height > Ai:
		total_steps_height += (current_height - Ai)
	if current_height < Ai:
		current_height = Ai

print(total_steps_height)

Measured memory_bytes: 25196
let split str =
  let rec split_inner ct b=
    if String.length str = ct then [int_of_string b]
    else
      match str.[ct] with
        ' ' -> (int_of_string b)::split_inner (ct+1) ""
      | c -> split_inner (ct+1) (b^(Char.escaped c))
  in split_inner 0 "";;

let () =
  let f x y =
    let matrix_multi m2 m1 =
      List.fold_left (fun p q -> (List.fold_left2 (fun a b1 c1 -> a + b1 * c1) 0 q m2)::p) [] m1
      |> List.rev and
        read_list u = read_line u |> split in
    let rec read fin i =
      let line = fin () in
      if i <= 0 then [line] else line::read fin (i-1)in
    let result = matrix_multi (read read_int (y-1)) (read read_list (x-1))
    in List.iter (fun e-> string_of_int e |> print_endline) result
  in match read_line () |> split with
       [a;b] ->f a b
     | _ -> ();;

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

int main() {
    int x;
    cin >> x;
    int ans = 0;
    if ((400 <= x) && (x < 600)) ans = 8;
    else if ((600 <= x) && (x < 800)) ans = 7;
    else if ((800 <= x) && (x < 1000)) ans = 6;
    else if ((1000 <= x) && (x < 1200)) ans = 5;
    else if ((1200 <= x) && (x < 1400)) ans = 4;
    else if ((1400 <= x) && (x < 1600)) ans = 3;
    else if ((1600 <= x) && (x < 1800)) ans = 2;
    else if ((1800 <= x) && (x < 2000)) ans = 1;
    else ;

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


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

char check[5]={'M','A','R','C','H'};

int main(){
	long long n;
	cin>>n;
	long long num[5];
	fill(num,num+5,0);
	string tmp;
	rep(i,n){
		cin>>tmp;
		rep(j,5)if(tmp[0]==check[j])num[j]++;
	}
	long long sum=0;
	rep(i,(1<<5)){
		bool alt[5];
		long long hoge=0;
		rep(j,5)alt[j]=((i&(1<<j))!=0);
		rep(j,5)if(alt[j])hoge++;
		if(hoge!=3)continue;
		hoge=1; 
		rep(j,5)if(alt[j])hoge*=num[j];
		sum+=hoge;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}

module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust, fromMaybe )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.IO as IOA
import qualified Data.Array.MArray as MA
import Control.Monad.ST
import System.IO (stdin)
import Control.Arrow
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Generic as GV
import qualified Data.Vector.Mutable as MV
import Data.Ix
import Data.Ord (Down(Down))
import qualified Data.Sequence as Seq
import Data.Foldable (toList)
import Data.Fixed

debug = False

ts :: Show a => a -> a
ts a = if debug then traceShowId a else a


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- readInts
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- readInts
    return (a, b, c)


readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

readIntV :: Int -> IO (UV.Vector Int)
readIntV n = GV.unfoldrN n (fmap (fmap BC.tail) . BC.readInt) <$> BC.getLine

readIntegersV :: Int -> IO (V.Vector Integer)
readIntegersV n = GV.unfoldrN n (fmap (fmap BC.tail) . BC.readInteger) <$> BC.getLine

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BC.readInteger) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las


main :: IO ()
main = do
  [a, b, c, d, e] <- readInts
  putStrLn $ if a == 0 then "1"
    else if b == 0 then "2"
    else if c == 0 then "3"
    else if d == 0 then "4"
    else "5"


Measured memory_bytes: 4220
s = gets.chomp
a = s.size
all = 0
arr = ""
["", "+"].repeated_permutation(a) do |plus|
(a).times do |i|
      arr << plus[i]
     arr << s[i]
 end
 all += arr.split("+").map(&:to_i).inject(:+)
 #p arr
 arr = ""
end
p all /2


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
long long H;
int n,a[100100],b[100100],amax=-1,d[100100],ok=0,cnt,i,ans;
int main()
{
  //freopen("1.in","r",stdin);freopen("1.out","w",stdout)
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>n>>H;
  for(i=1;i<=n;i++)
  {
    cin>>a[i]>>b[i];
    amax=max(amax,a[i]);	
  } 
  sort(b+1,b+n+1);
  for(i=1;i<=n;i++)
  {
	if(b[n-i+1]>amax)
	{
	  d[++cnt]=d[i-1]+b[n-i+1];
      if(d[cnt]>=H) goto num1;
	}
    else 
      break;
  }
  
  if(d[cnt]<H)
  {
	if((H-d[cnt])%amax==0)
      cnt+=(H-d[cnt])/amax;
    else
      cnt+=((H-d[cnt])/amax)+1;
  } 
  num1:
    cout<<cnt<<endl;
  return 0; 
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; i64 k; scanf("%d%lld", &n, &k);
	std::vector<i64> a(n), f(n);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
	for(int i = 0; i < n; i++) scanf("%lld", &f[i]);

	sort(begin(a), end(a), std::greater<i64>());
	sort(begin(f), end(f));

	auto check = [&](i64 t) {
		i64 tmp = 0;
		for(int i = 0; i < n; i++) {
			if(a[i] * f[i] <= t) continue;

			tmp += (a[i] * f[i] - t + f[i] - 1) / f[i];
		}
		
		return tmp <= k;
	};
	
	i64 ok = 1LL << 60, ng = -1;
	while(std::abs(ok - ng) > 1) {
		i64 mid = (ok + ng) >> 1;

		if(check(mid)) ok = mid;
		else ng = mid;
	}
	printf("%lld\n", ok);
	return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>

int main(void){
	int a, b;
	int area, circum;
	
	scanf("%d %d", &a, &b);
	area = a * b;
	circum = (a + b) * 2;
	
	printf("%d %d\n", area, circum);
	
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s; cin>>s;
	for(int i = 0; i + 1 < s.size(); i++)
	if(s[i] == s[i+1]){
		cout<<"Bad";
		return 0;
	}
	cout<<"Good";
  return 0;
}


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

ll md=1e9+7;
ll c[2010][2010];


ll comb(int a,int b){
    if (a<b) return 0;
    else if (b==0) return 1;
    else if (b==1) return a;
    else {
        if (c[a-1][b]==md) c[a-1][b]=comb(a-1,b);
        if (c[a-1][b-1]==md) c[a-1][b-1]=comb(a-1,b-1);
        c[a][b]=(c[a-1][b]+c[a-1][b-1])%md;
        return c[a][b];
    }
}

int main() {
    int n,k;
    cin >> n >> k;
    for (int i=0;i<2010;i++) {
        for (int j=0;j<2010;j++) c[i][j]=md;
    }
    for (int i=1;i<=k;i++) {
        ll ans=comb(k-1,i-1);
        ans*=comb(n-k+1,i);
        cout << ans%md << endl;
    }
}

Measured memory_bytes: 31872
#include <iostream>

int main(void){

	int H, W;
	std::cin >> H >> W;

	char a[102][102];
	
	// 画像入力
	int i,j;
	for(i=1;i<H+1;i++){
		for(j=1;j<W+1;j++){
			std::cin>>a[i][j];
		}
	}
	
	//枠の＃作り
	for(i=0;i<102;i++){
		a[0][i]='#';
		a[i][0]='#';
		a[H+1][i]='#';
		a[i][W+1]='#';
	}
	
	//出力
	for(i=0;i<H+2;i++){
		for(j=0;j<W+2;j++){
			std::cout<<a[i][j];
		}
		std::cout<<std::endl;
	}

	return 0;

}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;

int main(){
	//cin.sync_with_stdio(false); cin.tie(0);
	//cin >> sth; cout << sth;	
	int N;
	int a[200005];
	int max= 0;
	int tag = INF;
	int max2 = 0;
	cin >> N;
	for(int i=0;i<N;++i){
		cin >> a[i];
		if(a[i] >= max){
			max2 = max;
			max = a[i];
			tag = i;
		}
		else if(a[i]>max2)
			max2=a[i];
	}
	for(int i=0; i<N;++i){
		if(i!=tag)
			cout << max <<'\n';
		else
			cout << max2<<'\n';
	}

}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int h,w;
pair<char,int> ans;
string s;

signed main() {
    cin >> h >> w;
    rep(i,h) rep(j,w) {
        cin >> s;
        if (s == "snuke") ans = mp((char)('A'+j), i+1);
    }
    cout << ans.fi << ans.se << endl;
}












Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
ll dmod(ll x){
    return ((x+mod)%mod);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h,w;
    cin>>h>>w;
    int arr[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            char ch;
            cin>>ch;
            if(ch=='.')arr[i][j]=1;
            else arr[i][j]=0;
        }
    }
    ll ans[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i==0&&j==0){
                ans[0][0]=1;
                continue;
            }
            if(arr[i][j]==0)ans[i][j]=0;
            else {
                ans[i][j]=0;
                if(i-1>=0)ans[i][j]=dmod(ans[i][j]+ans[i-1][j]);
                if(j-1>=0)ans[i][j]=dmod(ans[i][j]+ans[i][j-1]);
            }
        }
    }
    /*for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<ans[h-1][w-1];
    return 0;
}

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

int main(){
	int a, b;
	cin >> a >> b;
	if (a == 1) a = 14;
	if (b == 1) b = 14;
	if(a == b) cout << "Draw";
	else if (a > b) cout << "Alice";
	else cout << "Bob";
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] arg){
		Scanner sc = new Scanner(System.in);
		String line;
		line = sc.nextLine();
		int sum = 0;
		int i;

		while(line.compareTo("0") != 0){
			for(i = 0;i < line.length();i++){
				sum += Character.getNumericValue(line.charAt(i));
			}
			System.out.println(sum);
			line = sc.nextLine();
			sum = 0;
		}

	}
}


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

const ll INF = 1LL << 60;

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

    for (int i = 1; i <= 210; i++) {
        if (i % 2 == 1) {
            // 高橋
            C -= B;
        } else {
            // 青木
            A -= D;
        }

        if (A <= 0) {
            cout << "No" << endl;
            break;
        } 
        if (C <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define MOD 998244353
using ll=long long;
vector<ll> fact(200001);
void init_fact(int n){
	fact[0]=1;
	for (int i = 1; i < n+1; i++){
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
	}
}
ll mod_pow(ll x, ll p){
	ll res=1;
	ll n=x;
	while(p>0){
		if(p&1==1)res=(res*n)%MOD;
		n=(n*n)%MOD;
		p=(p>>1);
	}
	return res;
}
ll nCr(int n, int r){
	ll res=1;
	//if n is large
	// for (int i = n; i > n-r; i--){
	// 	res*=i;
	// 	res%=MOD;
	// }
	res*=fact[n];
	res*=mod_pow(fact[r],MOD-2);
	res%=MOD;
	res*=mod_pow(fact[n-r],MOD-2);
	res%=MOD;
	return res;
}


int main() {
    int N,M,K;
    cin>>N>>M>>K;
    init_fact(N);
    ll ans=0;
    for (int i = 0; i <= K; i++){
        ll tmp=M;
        tmp*=nCr(N-1,i);
        tmp%=MOD;
        tmp*=mod_pow(M-1,N-1-i);
        tmp%=MOD;
        ans+=tmp;
        ans%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4656
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n;
string s, t;
int main() {
    cin>>n>>s>>t;

    REP(i, 0, n-1){
        cout<<s[i]<<t[i];
    }
    cout<<s[n-1]<<t[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 2e5 + 10;
typedef long long int ll;
ll x[N];
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> x[i];
    ll ans = 0;
    for (int i = 2; i <= n; i++)
    {
        if (x[i] < x[i - 1])
        {
            ans += x[i - 1] - x[i];
            x[i] = x[i - 1];
        }
    }
    cout << ans << endl;
    return 0;
}
/*
3 4
1 0 0 0
0 0 0 0
0 0 0 2
*/

Measured memory_bytes: 4752
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int i = 0, j, x, y, z, r, H, W;
	while (1) {
		cin >> x;
		if (x == 0) {
			break;
		}
		i = i + 1;
		printf("Case %d: %d\n", i, x);
	}
}

Measured memory_bytes: 3184