akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

string N;
int main() {
  cin >> N;
  cout << (N[0] == N[2] ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] h = new int[N];
        ArrayList<Integer> list = new ArrayList<Integer>();

        for(int i=0; i<N; i++){
            h[i] = sc.nextInt();
            list.add(h[i]);
        }

        Collections.sort(list);
        int min = list.get(N-1);

        for(int i=0; i<N-K+1; i++){
            min = Math.min(min, list.get(i+K-1)-list.get(i));
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 63848
import numpy as np

a,b=map(int,input().split())
A=np.array(sorted(list(map(int,input().split()))))
F=np.array(sorted(list(map(int,input().split())),reverse=True))

s=A.sum()

x=-1
y=10**12
while x+1<y:
  mid=(x+y)//2
  if s-np.minimum(A,mid//F).sum()<=b:
    y=mid
  else:
    x=mid
print(y)



Measured memory_bytes: 37276
require "prime"

def _divisors(primes, k)
  Enumerator.new do |y|
    if primes.size == k
      y << 1
    else
      p, e = primes[k]
      _divisors(primes, k + 1).each {|d|
        (e + 1).times {|e1|
          y << p ** e1 * d
        }
      }
    end
  end
end

def divisors(n)
  _divisors(Prime.prime_division(n), 0).to_a.sort
end

n=gets.to_i
l=divisors(n)
z=l.size
if z.odd?
  puts l[z/2]*2-2
else
  puts l[z/2-1]+l[z/2]-2
end

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];

  sort(A.begin(), A.end());
  long long res = 0;
  res += abs(A[0] - A[N - 1]) + abs(A[0] - A[N - 2]);
  for (int i = 1; i < N / 2; i++) {
    res += abs(A[i] - A[N - i]);
    if ((N - 1) / 2 < N - i - 2) {
      res += abs(A[i] - A[N - i - 2]);
    }
  }
  if (N % 2 && 3 < N) {
    res += max(A[N / 2 + 1] - A[N / 2], A[N / 2] - A[N / 2 - 1]);
  }

  if(N == 3){
    res = max(res, A[N-1] - A[0] + A[N - 1] - A[1]);
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 1024
K, N = map(int, input().split())
lis_A = list(map(int, input().split()))
dif = [0]*len(lis_A)
dif[0] = K-lis_A[-1] + lis_A[0]
for i in range(1,len(lis_A)):
    dif[i] = lis_A[i]-lis_A[i-1]
ans = sum(dif)-max(dif)
print(ans)

Measured memory_bytes: 26444
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    ll H, W;
    cin >> H >> W;
    if ( H == 1 || W == 1) {
        cout << 1 << endl;
        return 0;
    }

    ll cells = H * W;
    ll result = cells / 2 + cells % 2;
    cout << result << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;

void Show(vector<vector<int>> Ns) {
	for (int i = 0; i < Ns.size(); i++) {
		for (int j = 0; j < Ns[i].size(); j++) {
			if (j == Ns[i].size() - 1) {
				cout << Ns[i][j] << endl;
			} else {
				cout << Ns[i][j] << ",";
			}			
		}
	}
}

void Show(vector<int> N) {
	for (int i = 0; i < N.size(); i++) {
		cout << N[i];
		if (i != N.size() - 1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
}

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


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    map <int, int> position;
    int sequence[n];
    for(int i = 0; i < n; i++)
    {
        cin >> sequence[i];
        position[sequence[i]] = i;
    }
    sort(sequence, sequence + n);
    int cantCambiosConsecutivos = 0;
    for(int i = 0; i < n; i++)
        if(i % 2 != position[sequence[i]] % 2)
            cantCambiosConsecutivos++;
    cout << cantCambiosConsecutivos/2 << endl;
    return 0;
}


Measured memory_bytes: 5376
def bit_mani(num, quant):
    ans = 0
    for i in range(quant):
        ans *= 10
        ans += num
    return ans

n, m = input().split(" ")
if int(n) < int(m):
    print(bit_mani(int(n), int(m)))
    
else:
    print(bit_mani(int(m), int(n)))

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

int main() {
	char c;
	map<char, int> m;
	while(cin >> c){
		m[c] ? m[c]++ : m[c] = 1;
		if(m[c] == 2){
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
import bisect
def main():
    _ = int(input())
    l = list(map(int,input().split()))
    d = defaultdict(int)
    for i in l:
        d[i] += 1
    dk = sorted(list(d.keys()))
    dk2 = [i*2 for i in dk]
    ans = 0
    while dk:
        x = dk[-1]
        _ = dk2.pop(-1)
        bs = bisect.bisect(dk2,x)
        tmp = dk[bs:]
        if not tmp:
            break
        for i in tmp:
            for j in dk:
                if i+j > x and i >= j:
                    if i == j and i == x:
                        ans += d[x]*(d[x]-1)*(d[x]-2)//6
                    elif i == j:
                        ans += d[x]*d[i]*(d[i]-1)//2
                    elif i == x:
                        ans += d[x]*(d[x]-1)*d[j]//2
                    else:
                        ans += d[x]*d[i]*d[j]
        del dk[-1]
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 45740
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,mm,K;
int lim[30],w[30],dp[1<<20],two[1<<19][12];
const int mo=1e9+7;
int main(){
	scanf("%d%d%d",&n,&mm,&K);
	for (int i=1;i<=K;i++){
		int k1,k2,k3; scanf("%d%d%d",&k1,&k2,&k3);
		lim[k1]|=(1<<k2-1); w[k1]|=(k3<<k2-1);
	}
	memset(two,0xff,sizeof two);
	memset(dp,0x00,sizeof dp); dp[0]=1;
	int N=n-1; int m=0;
	for (int i=0;i<(1<<N);i++){
		int len=0;
		for (int j=1;j<N;j++)
			if ((i&(1<<j))&&(i&(1<<j-1))==0) two[i][len++]=i-(1<<j)+(1<<j-1);
		m=max(m,len);
	}
	for (int now=1;now<=mm;now++){
		for (int i=0;i<m;i++)
			for (int j=(1<<N)-1;j>=0;j--)
				if (two[j][i]>=0) dp[two[j][i]]=(dp[two[j][i]]+dp[j])%mo;
		for (int i=0;i<(1<<N);i++)
			for (int j=N-1;j>=0&&(i&(1<<j))==0;j--)
				dp[i+(1<<j)]=(dp[i+(1<<j)]+dp[i])%mo;
		for (int i=0;i<(1<<N);i++)
			if ((i&lim[now])!=w[now]) dp[i]=0;
	//	cout<<lim[now]<<" "<<w[now]<<endl;
	//	for (int i=0;i<(1<<N);i++) cout<<dp[i]<<" "; cout<<endl;
	}
	int ans=0;
	for (int i=0;i<(1<<N);i++) ans=(ans+dp[i])%mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 28928
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;

void drop(int h, int w, vector<string>& grid) {
    rep(i, 0, w) {
        rrep(j, h - 1, 0) {
            if (grid[j][i] == '*') continue;
            int start = j;
            while (start + 1 < h && grid[start + 1][i] == '*') {
                swap(grid[start][i], grid[start + 1][i]);
                ++start;
            }
        }
    }
}

int erase(int h, int w, int k, vector<string>& grid) {
    vector<vector<int> > cumsum(h, vector<int>(w, 0));
    int res = 0;
    rep(i, 0, h) {
        char now = '*';
        int cnt = 0;
        rep(j, 0, w) {
            if (grid[i][j] == '*') {
                cnt = 0;
                continue;
            }
            if (grid[i][j] != now) {
                cnt = 1;
                now = grid[i][j];
            }
            else ++cnt;
            cumsum[i][j] = cnt;
        }
    }
    rep(i, 0, h) {
        rrep(j, w, 0) {
            if (cumsum[i][j] < k) continue;
            int erase_cnt = cumsum[i][j];
            rep(l, 0, erase_cnt) {
                res += (int)(grid[i][j - l] - '0');
                grid[i][j - l] = '*';
                cumsum[i][j - l] = 0;
            }
        }
    }
    return res;
}

int game(int h, int w, int k, int del_h, int del_w, vector<string> grid) {
    int res = 0;
    int pow = 1;
    grid[del_h][del_w] = '*';
    while (true) {
        drop(h, w, grid);
        int score = erase(h, w, k, grid);
        if (score == 0) break;
        res += pow * score;
        pow *= 2;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> grid(H);
    rep(i, 0, H) cin >> grid[i];
    int ans = 0;
    rep(i, 0, H) rep(j, 0, W) {
        int now_ans = game(H, W, K, i, j, grid);
        ans = max(ans, now_ans);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
const int mod = 1e9+7;
int add(int a, int b) {
	return a + b < mod ? a + b : a + b - mod;
}
int mul(int a, int b) {
	return int(1LL * a * b % mod);
}
int fexp(int b, int e = mod - 2) {
	int ans = 1;
	while(e) {
		if(e & 1) ans = mul(ans, b);
		b = mul(b, b);
		e /= 2;
	}
	return ans;
}

using ll = long long;
const ll oo = 1e18;

const int N = 200005;

struct Segtree {
	ll st[2 * N];
	int n;

	ll query(int l, int r){ // [l, r]
		ll ans = -oo;
		for(l += n, r += n+1; l < r; l >>= 1, r >>= 1){
			if(l & 1) ans = max(ans, st[l++]);
			if(r & 1) ans = max(ans, st[--r]);
		}
		return ans;
	}

	void build() {
		for(int i = 0; i < 2 * N; i++) st[i] = -oo;
	}

	void update(int p, ll val){
		p += n;
		st[p] = max(st[p], val);
		while(p >>= 1) st[p] = max(st[2*p], st[2*p+1]);
	}
} up, down;

int n;
ll x[N], y[N];
ll compr[N];

int gety(ll val) {
	return int(lower_bound(compr, compr + n, val) - compr);
}
int id[N];

int main() {
	scanf("%d", &n);
	up.n = down.n = n;
	up.build(), down.build();

	for(int i = 0; i < n; i++) {
		scanf("%lld %lld", x + i, y + i);
		compr[i] = y[i];
		id[i] = i;
	}
	sort(compr, compr + n);

	sort(id, id + n, [](int i, int j) {
		if(x[i] != x[j]) return x[i] < x[j];
		return y[i] < y[j];
	});
	
	ll ans = 0;

	for(int w = 0; w < n; w++) {
		int i = id[w];

		int me = gety(y[i]);

		ans = max(ans, up.query(me, n - 1) + x[i] - y[i]);
		ans = max(ans, down.query(0, me) + x[i] + y[i]);

		up.update(me, y[i] - x[i]);
		down.update(me, -y[i] - x[i]);
	}

	printf("%lld\n", ans);
	return 0;

	for(int i = 0; i < n; i++) for(int j = i + 1; j < n; j++) {
		ll tmp = abs(x[i] - x[j]) + abs(y[i] - y[j]);
		if(tmp > ans) {
			printf("%d(%lld %lld) %d(%lld %lld)\n", i, x[i], y[i], j, x[j], y[j]);
			assert(0);
		}
	}

}


Measured memory_bytes: 15512
import sys
sys.setrecursionlimit(10**7)

n, m = [int(i) for i in sys.stdin.readline().split()]
parent = [i for i in range(n)]

graph = {j:[] for j in range(n)}
for i in range(m):
    l, r, d = [int(i) for i in sys.stdin.readline().split()]
    l -= 1
    r -= 1
    graph[l].append((r, d))
    graph[r].append((l, -d))

already = set()
x_ls = [None for i in range(n)]
x_ls[0] = 0
stack = list(range(n))[::-1]
flg = True
while len(stack) > 0:
    cur = stack.pop(-1)
    if cur in already:
        continue
    if x_ls[cur] is None:
        cur_pos = 0
    else:
        cur_pos = x_ls[cur]
    already.add(cur)
    for _next, dis in graph[cur]:
        if x_ls[_next] is None:
            x_ls[_next] = cur_pos + dis
            stack.append(_next)
        else:
            if x_ls[_next] != cur_pos + dis:
                flg = False
                break
    if not flg:
        break
if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 91308
#include <cmath>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <iostream>

using namespace std;


//xまでの素数を列挙O(n^1.5)
vector<int> get_prime_numbers(int x) {
	vector<int> v;
	int sn = sqrt(x);

	for (int number = 2; number <= x; number++) {
		int i = 0;
		bool pn = false;
		while (true) {
			if (i >= v.size() || v[i] > sn) { //平方根までの全素数で割れればOK
				v.push_back(number);
				break;
			}
			if (number % v[i] == 0) break;
			i++;
		}
	}
	return v;
}


//全ての約数リスト
vector<int> get_all_divisors(int x) {
	int sx = sqrt(x);

	vector<int> v;
	for (int n = 1; n <= sx; n++) {
		if (x % n == 0) {
			int m = x / n;
			v.push_back(n);
			if(n!=m) v.push_back(m);
		}
	}
	sort(v.begin(),v.end());
	return v;
}

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

	vector<int> vd = get_all_divisors(m);
	for (int i = 0; i < vd.size(); i++) {
		if (vd[i] >= n) {
			int x = m / vd[i];
			cout << x;
			break;
		}
	}
	return 0;
}


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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define ford(i, n) for (int i = int(n)-1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define endl '\n'
#define de(x) cout<<#x<<" = "<<(x)<<endl
#define de2(x,y) cout<<#x<<" = "<<(x) <<' '<< #y<<" = "<<y<<endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	string st;
	cin>>st;
	forn(i,st.size()) cout<<'x';
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define int long long
#define double long double
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

const int inf = 100000000000000;
const int mx = 2525;
int N, M, P;

int dist[mx];
bool negative[mx];

struct edge{
    int from, to, cost;
    edge(int f = 0, int t = 0, int c = 0) : from(f), to(t), cost(c) {}
};
edge graph[mx * 2];

//ABC137
signed main(void){

    cin >> N >> M >> P;
    rep(i, M){
        int a, b, c; cin >> a >> b >> c; a--; b--; c -= P;
        graph[i] = edge(a, b, -c);
    }

    fill(dist, dist + N, inf);
    dist[0] = 0;
    rep(i, N - 1){
        rep(j, M){
            if(dist[graph[j].from] == inf)continue;
            chmin(dist[graph[j].to], dist[graph[j].from] + graph[j].cost);
        }
    }

    rep(i, N){
        rep(j, M){
            if(dist[graph[j].from] == inf)continue;
            if(chmin(dist[graph[j].to], dist[graph[j].from] + graph[j].cost)){
                negative[graph[j].to] = true;
            }
            if(negative[graph[j].from])negative[graph[j].from] = true;
        }
    }

    int ans = -dist[N - 1];
    if(negative[N - 1])cout << -1 << endl;
    else cout << max<int>(ans, 0) << endl;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define comp(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvli;
const int M = 1e9+7;
const int N = 2e5;
ll po(int,int);


void solve(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    FOR(i,0,k+1){
        int x = (int)pow(2,i);
        int y = (int)pow(2,k-i);
        if(x*b>a && y*c > x*b){
            cout<<"Yes\n";
            return;
        }
    }
    cout<<"No\n";
}





int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
    //cin>>t;
    FOR(i,1,t+1){
        //cout<<"Case #"<<i<<": "; 
        solve();
    }
    
	return 0;
	
	
}


ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}


Measured memory_bytes: 4040
from heapq import heappop, heappush, heapify

N, M = map(int, input().split())
A = list(map(int, input().split()))
List = [list(map(int, input().split())) for _ in range(M)]

List = sorted(List, reverse=True, key=lambda x: x[1])

heapify(A)

i = 0
while i<M:
    m = heappop(A)
    heappush(A, m)
    tmp = List[i][1]
    cnt = List[i][0]
    while (0<cnt) and (m<tmp):
            m = heappop(A)
            heappush(A, tmp)
            tmp = List[i][1]
            cnt-=1
    i+=1

print(sum(A))

Measured memory_bytes: 103064
#include <iostream>
#include <iomanip>

const int MINUTES = 60;
const int N_MAX = 100;
const int M_MAX = 100;

int main(void) {
  int schedule[N_MAX + M_MAX] = {0};

  int N = 0;
  int M = 0;

  std::cin >> N;

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

    std::cin >> hour >> minutes;

    int time = hour * MINUTES + minutes;

    schedule[i] = time;
  }

  std::cin >> M;

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

    std::cin >> hour >> minutes;

    int time = hour * MINUTES + minutes;

    schedule[i] = time;    
  }

  for (int i = 0; i < (N + M); i++) {
    for (int j = i + 1; j < (N + M); j++) {
      if (schedule[i] > schedule[j]) {
	int tmp = schedule[i];
	schedule[i] = schedule[j];
	schedule[j] = tmp;
      }
    }
  }
  
  int old = schedule[0];
  int i = 0;

  while (i < (N + M)) {
    int t = schedule[i];

    if ((i > 0) && (t == old)) {
      i++;

      continue;
    }

    if (i > 0) {
      std::cout << " ";
    }

    int hour = t / MINUTES;
    int minutes = (t % MINUTES);
    
    std::cout << hour << ":";
    std::cout << std::setfill('0') << std::setw(2) << minutes;

    old = t;
    
    i++;
  }

  std::cout << std::endl;

  return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mxn= 5e4+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
//#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    rishabh();
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=0;
    ans=(b-a+1)-(b/c-(a-1)/c)-(b/d-(a-1)/d)+(b/((c*d)/__gcd(c,d))-(a-1)/((c*d)/__gcd(c,d)));
    cout<<ans;
}


Measured memory_bytes: 3608
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main(){
    int k,n;
    cin >> n >> k;
    int p[n];
    rep(i,n) cin >> p[i];

    double expect[n];
    rep(i,n){
        expect[i] = double(1+p[i])/2.0;
    }

    double ruiseki[200005];
    ruiseki[0] = 0;
    rep(i,n){
        ruiseki[i+1] = ruiseki[i] + expect[i];
    }

    double sum[200002];
    for(int i=0;i<=n-k;i++){
        sum[i] = ruiseki[i+k]-ruiseki[i];
    }

    double max_sum;
    rep(i,n-k+1) max_sum = max(max_sum,sum[i]);

    printf("%.7f",max_sum);
}

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

typedef long long LL;
const int mod = 1000000007;
const int MAXN = 100005;
LL num[MAXN];
LL fact[MAXN];
LL my_pow(LL a, LL b)
{
    LL sum=1;
    while(b>0)
    {
        if(b&1)
            sum=sum*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return sum%mod;
}
void init()
{
    fact[0]=1;
    for(int i=1;i<MAXN;++i)
       fact[i]=fact[i-1]*i%mod;
}
LL comb(LL a, LL b)
{
    if(b>a)
        return 0;
    return fact[a] *  my_pow(fact[b] * fact[a-b] % mod, mod-2) % mod;
}
int main()
{
   int n, k;
   init();
   scanf("%d %d", &n, &k);
   for(int i=0;i<n;++i)
       scanf("%lld", &num[i]);
   LL ans=0;
   sort(num, num+n);
   for(int i=0;i<n-k+1;++i)
   {
       ans = (ans + (num[n-i-1]-num[i])%mod*comb(n-i-1,k-1)%mod)%mod;
       //printf("%d %d %lld\n", n-i-1, k-1, (num[n-i-1]-num[i])*comb(n-i-1,k-1)%mod);
   }
   printf("%lld\n" ,(ans % mod + mod)%mod);
   return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        200005
#define mod         1000000007
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,sum=0,x;
    cin>>n;
    n=n-1;
    ll a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=0;i<n-1;i++){
        x=min(a[i],a[i+1]);
        sum+=x;
    }
    sum+=a[0]+a[n-1];
    cout<<sum;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        long[] NAB = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
        long N = NAB[0];
        long A = NAB[1];
        long B = NAB[2];
        if (A == 0)
        {
            Console.WriteLine(0);
            return;
        }
        long quotient = N / (A + B);
        long surplus = N % (A + B);
        if (A < surplus)
        {
            Console.WriteLine(A * quotient + A);
            return;
        }
        Console.WriteLine(A * quotient + surplus);
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int n;
    cin>>n;
    vector<vector<long long int>> grid(3,vector<long long int>(n));
    REP(i,3){REP(j,n){
            scanf("%lld", &grid[i][j]);
        }
        sort(grid[i].begin(), grid[i].end());
    }

    long long int result = 0;

    REP(i,n){
        result += (distance(grid[0].begin(),lower_bound(grid[0].begin(), grid[0].end(), grid[1][i])) * (distance(upper_bound(grid[2].begin(),grid[2].end(),grid[1][i]),grid[2].end())));
    }
    cout << result << endl;
    return 0;

}


Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int N, W; cin >> N >> W;
    int v[110], w[110], m[110];
    rep(i,0,N) cin >> v[i] >> w[i] >> m[i];

    int dp[10010] = {};
    rep(i,0,N) {
        // take 2^k good(s) each
        for(int k=0; m[i]>0; k++) {
            int key = min(m[i], (int)(1<<k));
            m[i] -= key;
            for(int j=W; j>=key*w[i]; j--) {
                // do not take or take
                dp[j] = max(dp[j], dp[j-key*w[i]] + key*v[i]);
            }
        }
    }
    int ans = 0;
    repq(i,0,W) ans = max(ans, dp[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3176
import collections
K = int(input())

q = collections.deque([i for i in range(1, 10)])
count = 0
while(q):
    count += 1
    x = q.popleft()
    if count == K:
        print(x)
        break
    if x % 10 != 0:
        q.append(x*10 + (x % 10 - 1))
    q.append(x*10 + (x % 10))
    if x % 10 != 9:
        q.append(x*10 + (x % 10 + 1))


Measured memory_bytes: 12384
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
int main() {
    string s;
    ll k;
    cin >> s >> k;
    int n=s.size();
    vector<ll> a;
    ll h=0, t=0, l=0;
    for (int i=1;i<n;i++) {
        if (s[i-1] == s[i]) l++;
        else if (l>0){
            if (l-i+1==0) h=l+1;
            else a.push_back(l+1);
            l=0;
        }
    }
    t=l+1;
    ll ans=0;
    if (t==n) {
        ans=(n*k)/2; 
    } else {
        for (ll i=0;i<a.size();i++) ans+=a.at(i)/2;
        ans*=k;
        if (s[0] == s[n-1]) {
            ll b=(h+t)/2;
            ans+=b*(k-1)+h/2+t/2;
        } else {
            ll b=h/2+t/2;
            ans+=b*k;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N=int(input())

if N==0:
    print(0)
    exit()

high=[2**(2*i)  for i in range(16)]
low=[-2**(2*i+1) for i in range(16)]
hh=[]
ll=[]
sum_h=0
sum_l=0
for i in range(16):
    sum_h+=high[i]
    sum_l+=low[i]
    hh.append(sum_h)
    ll.append(sum_l)

    
flag=True
while N!=0:
    #print(N)
    if N>0:
        for index,item in enumerate(hh):
            if N-item<=0:
                if flag:
                    l=[0]*(2*index+1)
                    flag=False
                l[-2*index-1]=1
                N-=high[index]
                break
    else:
        for index,item in enumerate(ll):
            if N-item>=0:
                if flag:
                    l=[0]*(2*index+2)
                    flag=False
                    length=len(l)
                l[-2*index-2]=1
                N-=low[index]
                break

print("".join(list(map(str,l))))
"""
print(high)
print(low)
print(hh)
print(ll)
"""


Measured memory_bytes: 3064
////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
#include <chrono>
#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

void hora(int tc) {
	double x;
	cin>>x;
	double cur = 100;
	for(int i = 1; ;i++) {
		cur = cur * 1.01;
		cur = floor(cur);
		if(x <= cur) {
			cout<<i<<endl;
			return ;
		}
	}
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;

int main()
{
    int a, b, M, minA = 100000000, minB = 100000000;
    cin >> a >> b >> M;
    vector<int> A(a, 0), B(b, 0);
    for (int i = 0; i < a; i++)
    {
        cin >> A[i];
        minA = min(minA, A[i]);
    }
    for (int i = 0; i < b; i++)
    {
        cin >> B[i];
        minB = min(B[i], minB);
    }
    int ans = minA + minB;
    for (int i = 0; i < M; i++)
    {
        int x, y, c;
        cin >> x >> y >> c;
        ans = min(ans, A[x - 1] + B[y - 1] - c);
    }
    cout << ans << endl;

    return 0;
}

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


#define INF 1000000000000
  int n;
  int Cnoichi;
   bool cikko(string s){
     int k=0;
     for(int i=2;i<n-1;i++){
       if (s[i]=='C'){
         k++;
         Cnoichi=i;
       }
     }
     return k==1;
   }

bool komozi(string s){
  for(int i=1; i<n; i++){
    if(i!=Cnoichi){
      if(isupper(s[i])){return false;}
    }
  }
  return true;
}
signed main()
 {
   string s;
   cin>>s;
   n=s.size();
   if(s[0]=='A'&&cikko(s)&&komozi(s)){
     cout<<"AC";
   }
   else cout<<"WA";
 }


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val mod = 1000000007L
    val (n, k) = readLine()!!.split(' ').map(String::toLong)
    val aList = readLine()!!.split(' ').map(String::toLong)
    val internalReverse = (0 until n).map { i -> aList.takeLast(n.toInt() - i.toInt()).count { j -> j < aList[i.toInt()] }.toLong() }
    val allReverse = (0 until n).map { i -> aList.count { j -> j < aList[i.toInt()] }.toLong() }
    val internalReverseSum = internalReverse.sum()
    val allReverseSum = allReverse.sum()

    var ans = (internalReverseSum * k) % mod
    val x = (k * (k - 1) / 2) % mod
    ans += (allReverseSum * x) % mod
    ans %= mod

    println(ans)
}


Measured memory_bytes: 41700
#include <stdio.h>

using namespace std;

void outPut(int Array[],char mark){
	for(int i = 1; i <= 13; i++){
		if(Array[i] == 0) printf("%c %d\n",mark,i);
	}
}

int main(){
	char mark[2];
	int n,S[14],H[14],C[14],D[14],tmp;
	for(int i = 0; i < 14; i++) S[i] = H[i] = C[i] = D[i] = 0;
	scanf("%d",&n);

	for(int i = 0; i < n; i++){
		scanf("%s %d",mark,&tmp);
		switch(mark[0]){
		case 'S':
			S[tmp] = 1;
			break;
		case 'H':
			H[tmp] = 1;
			break;
		case 'C':
			C[tmp] = 1;
			break;
		case 'D':
			D[tmp] = 1;
			break;
		}
	}
	outPut(S,'S');
	outPut(H,'H');
	outPut(C,'C');
	outPut(D,'D');
}


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

using namespace std;
#define ll long long
#define ld long double

ll gcd(ll a, ll b) {
    return b ? gcd(b,a % b) : a;    
}

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

ll f(ll n) {
    return n ? (n / 5  + f(n / 5)) : 0;
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    ll n;
    cin >> n;
    if(n % 2 == 1) {
        cout << 0 << '\n';
    }
    else {
        cout << f(n / 2) << endl;
    }
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  int cnt=0;
  bool flag=true;

  for (char c='a'; c<='z'; c++){
    cnt=0;
    for (int i=0; i<S.size(); i++){
      if (S.at(i)==c){
        cnt++;
      }
    }
    if (cnt>1){
      flag=false;
    }
  }
  cout << (flag? "yes":"no") << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
s = list(input())

if s[k-1]=='A':
    s[k-1] = 'a'
if s[k-1]=='B':
    s[k-1] = 'b'
if s[k-1]=='C':
    s[k-1] = 'c'
print(''.join(s))

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

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 A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;


int main(){
	int K, ans=0;
	string s;

	cin >> s >> K;
	int l = s.length();
	rep(i,l){
		if( s[i] + min(25,K) > 'z' ){
			K -= ('z'-s[i]) + 1;
			s[i] = 'a';
		}
	}
	rep(i,K) s[l-1] = (s[l-1]<'z') ? s[l-1]+1 : 'a';

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 640
n = int(input())
lst = [int(i) for i in input().split()]

flag = True
ans = 1
if 0 in lst:
  print(0)
else:
  for i in range(n):
    ans *= lst[i]
    if ans > 10 ** 18:
      flag = False
      break
  if flag:
    print(ans)
  else:
    print(-1)

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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	string S;
	cin >> S;
	string Sr=S;
	reverse(Sr.begin(),Sr.end());
	if(S!=Sr){
		cout << "No" << endl;
		return 0;
	}
	int N=S.size();
	string Sf=S.substr(0,(N-1)/2);
	string Sl=S.substr((N+3)/2-1,N);
	string Sfr=Sf;
	reverse(Sf.begin(),Sf.end());
	string Slr=Sl;
	reverse(Sl.begin(),Sl.end());
	if(Sf!=Sfr){
		cout << "No" << endl;
		return 0;
	}
	if(Sl!=Slr){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	
	int n,m,nm,a[26]={0},x1=0,y1=0,xy1=0;
	string s[100];
	cin>>n>>m;
	for(int i=0;i<n;i++) cin>>s[i];
	for(int i=0;i<n;i++) for(int j=0;j<m;j++) a[s[i][j]-'a']++;
	//for(int i=0;i<26;i++) cout<<'a'+i<<":"<<al[i]<<endl;
	x1=m/2;
	y1=n/2;
	if(n%2&&m%2) xy1=1;
		
	//cout<<x1<<y1<<xy1<<endl;
	int cnt=0;
	for(int i=0;i<x1*y1&&cnt!=26;i++){
		while(a[cnt]<4){
			cnt++;
			if(cnt==26) break;
		}
		if(cnt!=26) a[cnt]-=4;
	}
	//for(int i=0;i<26;i++) cout<<'a'+i<<":"<<a[i]<<endl;
	cnt=0;
	for(int i=0;i<(n%2)*x1+(m%2)*y1&&cnt!=26;i++){
		while(a[cnt]<2){
			cnt++;
			if(cnt==26) break;
		}
		if(cnt!=26) a[cnt]-=2;
	}
	if(xy1){
		for(int i=0;i<26;i++){
			if(a[i]==1){
				a[i]=0;
				break;
			}
		}
	}
	//for(int i=0;i<26;i++) cout<<'a'+i<<":"<<a[i]<<endl;
	int check=0;
	for(int i=0;i<26;i++) check+=a[i];
	if(check) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(void){

  char c[3][3];
  cin>>c[0]>>c[1]>>c[2];
  cout<<c[0][0]<<c[1][1]<<c[2][2];
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t A, B, C, K;
	std::cin >> A >> B >> C >> K;

	int64_t ans;
	if (K <= A) ans = K;
	else if (K <= A + B) ans = A;
	else ans = 2 * A + B - K;

	std::cout << ans << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 3624
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const string YES = "Yes";
const string NO = "No";

void solve(long long N){
  
}

int main(){
  string s;
  cin>>s;
  if(s[0]=='7' or s[1]=='7' or s[2]=='7')
    std::cout << YES << std::endl;
  else
    std::cout << NO << std::endl;
  return 0;
}



Measured memory_bytes: 3132
def resolve():
    K = int(input())
    from collections import deque
    cnt = 0
    q = deque()
    for i in range(1, 10):
        q.append(i)
    while q:
        num = q.popleft()
        cnt += 1
        if cnt == K:
            ans = num
            break
        mod10 = num % 10
        if mod10 != 0:
            q.append(10*num + mod10 - 1)
        q.append(10*num+mod10)
        if mod10 != 9:
            q.append(10*num + mod10 + 1)
    print(ans)

resolve()

Measured memory_bytes: 40560
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i + 100*j + 50*k == x:
        ans += 1
        
print(ans)

Measured memory_bytes: 9104
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}


char check[60][60];

int main(void){
    char s[60];
    char t[60];
    char min[60];
    int checki = 0;
    int slen;
    int tlen;
    int flag;
    int i, j;

    scanf("%s %s", s, t);
    slen = strlen(s);
    tlen = strlen(t);

    for (i = 0; i < 60; i++){
        strcpy(check[i], s);
    }

    strcpy(min, "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz");


    for (i = 0; i < slen; i++){
        if ((s[i] == '?' || s[i] == t[0]) && slen - i >= tlen){
            flag = 1;
            for (j = i; j < i + tlen; j++){
                if (s[j] != t[j-i] && s[j] != '?'){
                    flag = 0;
                }
            }
            if (flag == 1){
                strcpy(check[checki], s);
                for (j = i; j < i + tlen; j++){
                    check[checki][j] = t[j-i];
                }
                for (j = 0; j < slen; j++){
                    if (check[checki][j] == '?'){
                        check[checki][j] = 'a';
                    }
                }
                checki++;
            }
        }
    }

    if (checki == 0){
        printf("UNRESTORABLE\n");
        return 0;
    }

    for (i = 0; i < checki; i++){
        if (strcmp(min, check[i])){
            strcpy(min, check[i]);
        }
    }

    printf("%s\n", min);


    return 0;
}


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

int r, D, x, ans, c=0;

void def(int x) {
  while(c < 10) {
    ans = r * x - D;
    cout << ans << endl;
    c++;
    def(ans);
  }
}
int main() {
  cin >> r >> D >> x;
  def(x);
}

Measured memory_bytes: 256
n = gets.chomp.to_i
a_arr, b_arr = [], []
c = 0

n.times do
  input = gets.chomp.split.map(&:to_f)
  a_arr.unshift input[0]
  b_arr.unshift input[1]
end

tmp = a_arr

n.times do |i|
  tmp[i] += c
  next if b_arr[i] == 1 || tmp[i] % b_arr[i] == 0
  t = b_arr[i] * (tmp[i] / b_arr[i]).ceil
  diff = t - tmp[i]
  c += diff.to_i
end

puts c

Measured memory_bytes: 3692
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [Usize1; n],
    }

    let mut visited = vec![false; n];
    let mut now = 0;
    while !visited[now] {
        visited[now] = true;
        now = a[now];
    }
    let loop_start = now;

    let mut now = 0;
    let mut loop_started = false;
    let mut count = 0usize;
    loop {
        now = a[now];

        if loop_started {
            count += 1;
            if now == loop_start {
                break;
            }
        } else {
            if now == loop_start {
                loop_started = true;
            }
        }
    }
    let loop_length = count;

    let mut k = k;
    let mut now = 0;
    while k > 0 {
        now = a[now];
        k -= 1;
        if now == loop_start {
            k = k % loop_length;
        }
    }

    println!("{}", now + 1);
}


Measured memory_bytes: 5224
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N;
int cntw[200009], cntb[200009];
int rw[200009], rb[200009];
string stn;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>stn;
    rep(i,N){
        if(stn[i]=='.'){
            cntw[i]++;
        }else{
            cntb[i]++;
        }
        if(i){
            cntw[i]+=cntw[i-1];
            cntb[i]+=cntb[i-1];
        }
    }
    rrep(i,N-1){
        if(stn[i]=='.'){
            rw[i]++;
        }else{
            rb[i]++;
        }
        if(i<N-1){
            rw[i]+=rw[i+1];
            rb[i]+=rb[i+1];
        }
    }
    int ans=min(cntb[N-1],cntw[N-1]);
    rep(i,N){
        int n = cntb[i] + rw[i+1];
        chmin(ans,n)
    }
    cout1(ans)
}

Measured memory_bytes: 3732
N = int(input())
tes = [[] for _ in range(N+1)]
ans = 0

for i in range(1, N+1):
    for _ in range(int(input())):
        x, y = map(int, input().split())
        tes[x].append([i, y])

for x in range(1, 2**N):
    HorU = [0] + [(x >> n) & 1 for n in range(N)]
    cand = True
    for i in range(1, N+1):
        for j, y in tes[i]:
            if HorU[j] == 1 and y != HorU[i]:
                cand = False
    if cand:
        temp = (N+1) - sorted(HorU).index(1)
        if ans < temp:
            ans = temp
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int D,G;
    int p[11],c[11];
    cin>>D>>G;
    for(int i=0;i<D;i++){
        cin>>p[i]>>c[i];
    }
    int ans = 1e9;
    for(int i=0;i<(1<<D);i++){
        int a = 0; int num=0;int rest_max=-1;
        for(int j=0;j<D;j++){
            if(i>>j&1){
                a += 100*(j+1)*p[j]+c[j];
                num += p[j];
            }else{
                rest_max=j;
            }
        }
            if(a < G){
            int s1 = 100 * (rest_max + 1);
            int need = (G - a + s1 - 1) / s1;
            if(need >= p[rest_max]){
                continue;
            }
            num += need;
        }
        ans = min(ans, num);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))+[0]
ans=c=0
for i in range(N+1):
    a=A[i]
    b=B[i]
    ans+=min(a,c)
    a=max(a-c,0)
    ans+=min(a,b)
    c=max(b-a,0)
print(ans)


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

int main(){
   
    long long N,ans=1,t=1e9+7;
    map<long long,long long>m;
    cin >> N;
    long long A[N];
    for(int i = 0; i < N; i++){
         cin >> A[i];
         m[A[i]]++;
    }
    if(N%2){
       if(m[0] != 1){
          cout << 0 << endl;
          return 0;
       }
       for(long long i = 2; i <= N-1; i += 2) {
            if(m[i] != 2){
              cout << 0 << endl;
              return 0;
            }
       }
    }else {
       for(long long i = 1; i <= N-1; i += 2){
            if(m[i] != 2){
              cout << 0 << endl;
              return 0;
            }
       }
    }
    for(long long i = 0; i < N/2; i++){
         ans %= t;
         ans *= 2;
    }
    cout << ans % t << endl;
	return 0;
}

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace AtCoder
{
  class Program
  {
    static int Main(string[] args)
    {
      double input = double.Parse(Console.ReadLine());

      int count = 0;
      double yen = 100;
      while(yen < input)
      {
        yen += Math.Floor(yen/100);
        count++;
      }
      
      Console.WriteLine(count.ToString());
      
      return 0;
    }
  }
}

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


using namespace std;
using vc=vector<char>;
using vvc=vector<vc>;


int main(void)
{
	int n;

	while(scanf("%d\n", &n)==1)
	{
		int ans=1;
		vvc w(n);

		for(int i=0;i<n;i++)
		{
			w[i].resize(10+2);
			scanf("%10[a-z]\n", &w[i][0]);
			if(i>0)
			{
				if(w[i-1][strlen(&w[i-1][0])-1]!=w[i][0]) ans=0;
			}
			for(int j=0;j<i;j++)
			{
				if(strcmp(&w[i][0], &w[j][0])==0) ans=0;
			}
		}
		printf("%s\n", ans?"Yes":"No");
	}

	return 0;
}


Measured memory_bytes: 256
open System


[<EntryPoint>]
let main argv =
    let N = stdin.ReadLine()|>int
    [1..9]
    |>Seq.sumBy(fun c -> if(N%c=0)&&(N/c<=9) then 1 else 0)
    |>fun c -> if c>=1 then "Yes" else "No"
    |>stdout.WriteLine
    0

Measured memory_bytes: 13268