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

typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

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

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int n;
int main(){
    int k;
    cin>>n>>k;
    vector<int>height(n);
    rep(i,n)cin>>height.at(i);
    sort(height.begin(),height.end());
    ll sa=1e9;
    for(int i=0;i<=(n-k);i++){
        int temp=(height.at(i+k-1)-height.at(i));
        if(temp<sa)sa=temp;
    }
    cout<<sa<<endl;
    return 0;
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(void) {
    int n; cin >> n;
    vector<int> p(n+1);
    int cnt = 0;
    rep(i,n) {
        cin >> p[i+1];
        if(i+1 != p[i+1]) cnt++;
    }
    if(cnt<=2) cout <<"YES";
    else cout <<"NO";
}



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

ll dp[55][55][2550];

int main(){
    int N,A;
    cin >> N >> A;
    vector<int> x(N);
    rep(i,N)cin >> x[i];

    dp[0][0][0] = dp[0][1][x[0]] = 1;

    rep(i,N-1){
        rep(j,N+1){
            rep(k,2501){
                if(dp[i][j][k] == 0)continue;
                //i+1番目を選ぶ
                dp[i+1][j+1][k+x[i+1]] += dp[i][j][k];
                //選ばない
                dp[i+1][j][k] += dp[i][j][k];
            }
        }
    }

    ll res = 0;
    for(int i = 1; i <= N; i++){
        int a = i * A;
        if(a <= 2500 && dp[N-1][a] != 0){
            res += dp[N-1][i][a];
        }
    }
    cout << res << endl;
    return 0;
}

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

int main(){
  int k;
  vector<int> a(5);

  for(int i=0; i<5; i++) cin >> a[i];
  cin >> k;

  
  if(a[4] - a[0] > k){
    cout << ":(" << endl;
    return 0;
  }

  cout << "Yay!" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll MOD = 1e9+7;

map<ll, int> PrimeFact(ll N){
    map<ll, int> mp;

    while(N != 1){
        bool found = false;
        for(ll i = 2; i * i <= N; i++){
            if(N % i == 0){
                mp[i]++;
                N /= i;
                found = true;
                break;
            }
        }

        if(!found){
            mp[N]++;
            break;
        }
    }

    return mp;
}

ll powmod(ll a, int cnt){
    if(cnt == 0) return 1;
    else if(cnt % 2 == 0){
        ll tmp = powmod(a, cnt / 2);
        return tmp * tmp % MOD;
    }
    else {
        return a * powmod(a, cnt - 1) % MOD;
    }
}

ll revmod(ll a){
    //a^(MOD - 2)

    return powmod(a, MOD - 2);
}


int main(){
    int N;
    cin >> N;
    ll a[N];
    for(int i = 0; i < N; i++) cin >> a[i];

    map<ll, int> lcm;
    for(int i = 0; i < N; i++){
        //cout << "hoge" << endl;
        map<ll, int> mp = PrimeFact(a[i]);
        for(auto it = mp.begin(); it != mp.end(); it++){
            ll num = it -> first;
            int cnt = it -> second;
            lcm[num] = max(lcm[num], cnt);
        }
    }



    ll lcmmod = 1;
    for(auto it = lcm.begin(); it != lcm.end(); it++){
        //cout << it -> first << " " << it -> second << endl;
        lcmmod *= powmod(it -> first, it -> second);
        lcmmod %= MOD;
    }

    //cout << lcmmod << endl;

    ll ans = 0;
    for(int i = 0; i < N; i++){
        ans += revmod(a[i]);
        ans %= MOD;
    }

    ans *= lcmmod;
    ans %= MOD;

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

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

int main(){
  int A, B;
  cin >> A >> B;
  if (A >= B)
  {
    for (int i = 0; i < A; i++)
    {
      cout << B;
    }
  }else
  {
    for (int i = 0; i < B; i++)
    {
      cout << A;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
namespace IO{
    const int SIZE = (1 << 20) + 1;
    char ibuf[SIZE], *iS, *iT, obuf[SIZE],*oS = obuf, *oT = obuf + SIZE - 1;
    char _st[55];
    int _qr = 0;
    inline char gc(){
        return (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS++) : *iS++);
    }
    inline void qread(){}
    template<class T1, class ...T2>
    inline void qread(T1 &IEE, T2&... ls){
        register T1 __ = 0, ___ = 1;
        register char ch;
        while(!isdigit(ch = gc())) ___ = (ch == '-') ? -___ : ___;
        do{
            __ = (__ << 1) + (__ << 3) + (ch ^ 48);
        }while(isdigit(ch = gc()));
        __ *= ___;
        IEE = __;
        qread(ls...);
        return ;
    }
    inline void flush(){
        fwrite(obuf, 1, oS - obuf, stdout);
        oS = obuf;
        return ;
    }
    inline void putc_(char _x){
        *oS++ = _x;
        if(oS == oT) flush();
    }
    inline void qwrite(){}
    template<class T1, class ...T2>
    inline void qwrite(T1 IEE, T2... ls){
        if(!IEE) putc_('0');
        if(IEE < 0) putc_('-'), IEE = -IEE;
        while(IEE) _st[++_qr] = IEE % 10 + '0', IEE /= 10;
        while(_qr) putc_(_st[_qr--]);
        qwrite(ls...);
        return ;
    }
    struct Flusher_{~Flusher_(){flush();}}io_flusher;
}
using namespace IO;
int main(){
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
    return 0;
}

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

int main()
{
	int n, ai;
	cin >>n;
  
  	vector<int> a(n,0);
  
  	for (int i=0; i<n-1; i++)
    {
      cin >> ai;
      a[ai-1]++;
    }
    for (int i=0; i<n; i++)
    {
    	cout << a[i] << endl;
    }
	return 0;
 } 


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

using namespace std;

main(){
  int T, dp[100][100], n, d[100], s, t;
  cin >> T;
  while(T--){
    cin >> n;
    for(int i=0;i<n;i++) cin >> d[i];
    fill(dp[0], dp[n], 0);
    for(int k=1;k<n;k++){
      for(int i=0;i<n;i++){
        for(int j=0;j<k;j++){
          s = (i+k)%n;
          t = (i+j+1)%n;
          dp[i][s] = max(dp[i][s], dp[i][(i+j)%n] + dp[t][s] + abs(d[i] - d[t]));
        }
      }
    }
    int ans = 0;
    for(int i=0;i<n;i++) ans = max(ans, dp[i][(i+n-1)%n]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  int ans = 0;
  rep(i,n) {
    if (h[i] >= k) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3660
import sys
from fractions import gcd
from collections import deque

N=input()
A=map(int, sys.stdin.readline().split())

L=deque()

for i in range(N):
	if i==0:
		L.append(A[i])
	else:
		L.append( gcd(A[i],L[i-1]) )

R=deque()

for i in range(N-1,-1,-1):
	if i==N-1:
		R.appendleft(A[i])
	else:
		R.appendleft( gcd(A[i],R[0]) )

ans=float("-inf")
for i in range(N):
	if i==0:
		t=R[i+1]
	elif i==N-1:
		t=L[i-1]
	else:
		t=gcd(L[i-1], R[i+1])
	ans=max(ans, t)

print ans


Measured memory_bytes: 44696
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    vector<int> t;
    rep(i,3){
        int x;
        cin>>x;
        t.push_back(x);
    }
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    int ans=t[0]*10+t[1]+t[2];
    cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int t,n,i,j,k,l,l1;
  cin>>n;
  string s1,s2;
  cin>>s1>>s2;
  for(i=0;i<n;i++)
  {
    cout<<s1[i]<<s2[i];
  }
}

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

#define ll long long
#define pb push_back
#define MOD 1000000007
#define MAX 200005

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int t,val;
    cin >> t;
    set<int>st;
    while(t--)
    {
        int cc;
        cin >> cc;
        if(cc==0)
        {
            cin >> val;
            st.insert(val);
            printf("%d\n",st.size());
        }
        else if(cc==1)
        {
            cin >> val;
            if(st.find(val)!=st.end()) puts("1");
            else puts("0");
        }
        else
        {
            cin >> val;
            st.erase(val);
        }
    }
    return 0;
}



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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    for (int i = 0; i < k; i++) {
        if (a >= b && a >= c) a *= 2;
        else if (b >= a && b >= c) b *= 2;
        else if (c >= a && c >= b) c *= 2;
    }
    cout << a + b + c << endl;
}

Measured memory_bytes: 256
N = int(input())
m = 0
a = 0
r = 0
c = 0
h = 0
for _ in range(N):
    p = input()
    if p[0] == "M":
        m += 1
    elif p[0] == "A":
        a += 1
    elif p[0] == "R":
        r += 1
    elif p[0] == "C":
        c += 1
    elif p[0] == "H":
        h += 1
ans = 0
ans += (m*a*r) + (m*a*c) + (m*a*h) + (m*r*c) + (m*r*h) + (m*c*h) +(a*r*c) + (a*r*h) +(a*c*h) + (r*c*h)
print(ans)

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

int main(){
  	string s, t;
  	cin >> s >> t;
  	
  	sort(s.begin(), s.end());
  	sort(t.begin(), t.end());
  	reverse(t.begin(), t.end());
  	if(s < t) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N, K;
  cin >> N >> K;
  vector<double> a(N);

  double tmp;
  rep(i, N){
    cin >> tmp;
    a[i] = 1.0 + 0.5 * (tmp - 1);
  }

  vector<double> suma(N+1);
  suma[0] = 0.0;
  rep(i, N){
    suma[i+1] = suma[i] + a[i];
  }

  double ans = 0.0;
  for(int i = 0; i + K <= N; i++){
    chmax(ans, suma[i+K] - suma[i]);
  }

  cout << setprecision(10) << ans << endl;

  return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>

using namespace std;

int N,a[200001],b[200001]={0};

int main()
{
  cin >> N;
  for(int i=1;i<N+1;i++)
  {
    cin >> a[i];
  }
  int m=0;
  for(int i=N;i>0;i--)
  {
      b[i]=a[i];
      for(int j=2;j*i<N+1;j++)
      {
        b[i]+=b[j*i];
      }
      b[i]=b[i]%2;

    
  }
  
  for(int i=1;i<N+1;i++)
  {
    m+=b[i];
  }
  cout << m << endl;
  for(int i=1;i<N+1;i++)
  {
    if(b[i]==1)    cout << i <<" ";
    
  }
    
  
}

Measured memory_bytes: 2432
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>

int main() {
  long long k, a, b;
  std::cin >> k >> a >> b;
  if (a >= b or k <= a) {
    std::cout << 1 + k << std::endl;
    return 0;
  }
  long long ans1 = 1 + k;
  long long k2 = std::max(0LL, k - a + 1);
  long long ans2 = (k2 / 2) * (b - a) + a + k2 % 2;
  std::cout << std::max(ans1, ans2) << std::endl;
  return 0;
}

Measured memory_bytes: 888
n=int(input())
st=dict()
for i in range(n):
    si=list(input())
    si.sort()
    si="".join(si)
    if si in st:
        st[si]+=1
    else:
        st[si]=1
        
icnt=0
for i in st.values():
    if i>1:
        icnt+=i*(i-1)//2
        
print(icnt)
    

Measured memory_bytes: 17928
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int k;
vector<long long> ans, vec;

bool fun(long long a, long long b)
{
	long long da = 0, db = 0;
	long long tmp = a;
	while (tmp) {
		da += tmp % 10;
		tmp = tmp / 10;
	}
	tmp = b;
	while (tmp) {
		db += tmp % 10;
		tmp = tmp / 10;
	}
	if (a/da > b/db) return false;
	else if (a/da < b/db) return true;
	else {
		long long ta = a % da;
		long long tb = b % db;
		if (ta * db <= tb * da) return true;
		else return false;
	}
}

long long gun(long long x)
{
	vec.clear();
	long long cur = 1;
	while (1) {
		if (x/cur == 0) break;
		long long tmp = (x / cur)*cur + cur - 1;
		vec.pb(tmp);
		cur = cur * 10;
	}
	long long mi = vec[0];
	for (int i = 1; i < (int)vec.size(); i++) {
		if (fun(vec[i], mi)) {
			mi = vec[i];
		}
	}
	return mi;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> k;
	long long tmp = 1;
	while (1) {
		ans.pb(tmp);
		if (ans.size() == k) break;
		tmp = gun(tmp + 1);
	}
	for (int i = 0; i < k; i++)
		cout << ans[i] << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws Exception
	{
		int n=nextInt();

		int fact[]=new int[n+1];
		fact[0]=1;
		for(int i=1;i<=n;i++)
			fact[i]=fact[i-1]*i;
		
		int p[]=new int[n+1];
		for(int i=1;i<=n;i++)
			p[i]=nextInt();

		int q[]=new int[n+1];
		for(int i=1;i<=n;i++)
			q[i]=nextInt();

		int posp=1,posq=1;
		boolean visited[]=new boolean[n+1];
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<p[i];j++)
			{
				if(visited[j])
					continue;
				posp+=fact[n-i];
			}
			visited[p[i]]=true;
		}

		visited=new boolean[n+1];
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<q[i];j++)
			{
				if(visited[j])
					continue;
				posq+=fact[n-i];
			}
			visited[q[i]]=true;
		}

		out.println(Math.abs(posp-posq));
	}

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

	public void run()throws Exception
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws Exception{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws Exception{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws Exception{
		return br.readLine();
	}
	int nextInt()throws Exception{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception{
		return Double.parseDouble(nextToken());
	}
}

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

int main(void)
{
	double w;

	while (cin >> w)
	{
		if (w > 91) cout << "heavy" << endl;
		else if (81 < w && w <= 91) cout << "light heavy" << endl;
		else if (75 < w && w <= 81) cout << "middle" << endl;
		else if (69 < w && w <= 81) cout << "light middle" << endl;
		else if (64 < w && w <= 69) cout << "welter" << endl;
		else if (60 < w && w <= 64) cout << "light welter" << endl;
		else if (57 < w && w <= 60) cout << "light" << endl;
		else if (54 < w && w <= 57) cout << "feather" << endl;
		else if (51 < w && w <= 54) cout << "bantam" << endl;
		else if (48 < w && w <= 51) cout << "fly" << endl;
		else cout << "light fly" << endl;
	}
	return 0;
}


Measured memory_bytes: 3076
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int a[][] = new int[N][2];
		for (int j = 0; j < 2; j++) {
			for (int i = 0; i < N; i++) {
				a[i][j] = in.nextInt();
			}
		}
		
		int max=0;
		int sum=0;
		
		for(int i=0;i<N;i++) {
			for(int j=0;j<=i;j++) {
				sum=a[j][0]+sum;
			}
			for(int j=i;j<N;j++) {
				sum=a[j][1]+sum;
			}
			max=Math.max(max, sum);
			sum=0;
		}
		
		System.out.println(max);
		
	}
}



Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb   push_back
#define T int time;        scanf("%d", &time); while(time--)
int main(){
   // T{
   ll n,x,t;
   cin>>n>>x>>t;
   ll ans=(n/x);
   if(n%x)ans++;
   ans=(ans*t);
cout<<ans<<endl;

 
}



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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

bool U[1000005];

int main() {
    ll M, K;
    cin >> M >> K;
    if (M == 0) {
        if (K == 0)
            cout << "0 0" << endl;
        else
            cout << -1 << endl;
        return 0;
    }
    ll p = pow(2LL, M);
    if (p <= K) {
        cout << -1 << endl;
        return 0;
    }

    if (M == 1 && K == 0) {
        cout << "0 0 1 1" << endl;
        return 0;
    }
    if (M == 1 && K == 1) {
        cout << -1 << endl;
        return 0;
    }

    if (K == 0) {
        REP(i, p) {
            cout << i << " ";
        }
        REP(i, p) {
            cout << p - 1 - i << " ";
        }
        cout << endl;
        return 0;
    }

    memset(U, 0, sizeof(U));
    vector<vector<ll>> v;
    REP(i, p) {
        if (U[i])
            continue;
        ll k = (K ^ i);
        U[i] = U[k] = true;
        vector<ll> t;
        t.push_back(i);
        t.push_back(k);
        v.push_back(t);
    }

    vector<ll> ans;
    for (ll i = 0; i < v.size(); i += 2) {
        auto a = v[i];
        auto b = v[i + 1];
        ans.push_back(a[0]);
        ans.push_back(a[1]);
        ans.push_back(b[0]);
        ans.push_back(b[1]);
        ans.push_back(a[1]);
        ans.push_back(a[0]);
        ans.push_back(b[1]);
        ans.push_back(b[0]);
    }

    REP(i, ans.size()) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 9520
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <cassert>
#include <numeric>
#include <random>


using namespace std;
typedef long long ll;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll p, q, r;
  cin >> p >> q >> r;
  ll res = min(p+q, q +r);
  res = min(res, r+p);
  cout << res << endl;

  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> r(n+1);
  for(int i=0;i<n;i++){
    cin >> r.at(i);
  }
  int N;
  N = n;
  sort(r.begin(), r.end());
  for(int i=0; i<n; i++){
    if(r.at(i) == r.at(i+1)){
      N--;
    }
  }
  cout << N << endl;
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,n){cout<<arr[i][j]<<" ";}cout<<endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

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

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x1,y1,x2,y2,x3,y3,s;
    cin>>s;
    x1=0;
    y1=0;
    x2=1e9;
    y2=1;
    x3=(x2-s%x2)%x2;
    y3=(s+x3)/x2;
    cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;
    return  0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define MN 200
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int A,B,d[35][35],b[35][35],m;
struct edge{int x,y,w;}e[MN*MN+5];
int main()
{
    A=read();B=read();
    for(int i=1;i<=A;++i) for(int j=1;j<=B;++j) d[i][j]=read();
    for(int i=0;i<=100;++i) for(int j=0;j<=100;++j)
    {
        int mn=0;
        for(int k=1;k<=A;++k) for(int l=1;l<=B;++l) mn=max(mn,d[k][l]-k*i-l*j);
        e[++m]=(edge){i+1,202-j,mn};
        for(int k=1;k<=A;++k) for(int l=1;l<=B;++l) if(k*i+j*l+mn==d[k][l]) b[k][l]=1;
    }
    for(int i=1;i<=A;++i) for(int j=1;j<=B;++j) if(!b[i][j]) return 0*puts("Impossible");
    printf("Possible\n%d %d\n",202,m+200);
    for(int i=1;i<=100;++i) printf("%d %d X\n",i,i+1),printf("%d %d Y\n",i+101,i+102);
    for(int i=1;i<=m;++i) printf("%d %d %d\n",e[i].x,e[i].y,e[i].w);
    puts("1 202");
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(aa) (aa).begin(), (aa).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<pill,int> PA;
//ll MOD;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	ll weight;
};
int N,K,X;

int main(){
	cin>>N>>K>>X;
	int a=max(N,K);
	cout<<(X+a-1)/a<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8
#define MAX_N 100000

using namespace std;
typedef pair<llong, llong> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int N, K, A[MAX_N], res;
int main(int argc, char **argv) {
    cin >> N >> K;
    for(int i = 0; i < N; ++i)
        cin >> A[i];
    
    res = 0;
    for(int i = 0; i < N; ++i)
        if(A[i] >= K)
            res++;

    cout << res << endl;
}

Measured memory_bytes: 640
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int res = N/500;
         res *= 1000;
         int lol = N%500-N%5;
         System.out.println(res+lol);
      }
   }

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll p=998244353ll;
const int N=200005;
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
int a[N];
int main(){
	int n,i,b,t;ll s=0ll;
	scanf("%d",&n);
	for(i=1;i<=n+1;++i)scanf("%d",&a[i]);
	for(i=1;i<=n  ;++i){
		scanf("%d",&b);
		t=min(b,a[i  ]);b-=t;a[i  ]-=t;s+=t;
		t=min(b,a[i+1]);b-=t;a[i+1]-=t;s+=t;
	}
	printf("%lld",s);
	return 0;
}

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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 200010, M = 1010;

int n;
int a[N], b[N];
LL m;

bool check(LL x)
{
	LL sum = 0;
	for (int i = 0; i < n; i ++ )
		if ((LL)a[i] * b[i] > x)
			sum += (LL)a[i] - x / (LL)b[i];
	return sum <= m;
}

int main()
{
	scanf("%d%lld", &n, &m);
	for (int i = 0; i < n; i ++ ) scanf("%d", &a[i]);
	for (int i = 0; i < n; i ++ ) scanf("%d", &b[i]);
	sort(a, a + n);
	sort(b, b + n, greater<int>());
	
	LL l = 0, r = 1e12 + 10;
	while (l < r)
	{
		LL mid = l + r >> 1;
		if(check(mid)) r = mid;
		else l = mid + 1LL;
	}
	
	printf("%lld\n", r);
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        System.out.println((a/b)+" "+(a%b)+" "+(String.format("%.5f", 1.0*a/b)));
    }
}


Measured memory_bytes: 26524
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    int t[100010];
    int m;
    int sum = 0;
    cin >> n;
    imfor(i, n) {
        cin >> t[i];
        sum += t[i];
    }
    cin >> m;
    imfor(i, m) {
        int p, x;
        cin >> p >> x;
        cout << sum - t[p - 1] + x << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){
  long long X;
  cin >> X;
  long long maxNum;
  maxNum = 1;
  for(int i = 2; i < 100; i++){
    for(int j = 2;;j++){
      long long n = pow(i,j);
      if(n <= X) maxNum = max(n,maxNum);
      else break;
    }
  }
  cout << maxNum << endl;
  return 0;
}


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

int main() {
  int a[5];
  for (int i = 0; i < 5; ++i) cin >> a[i];

  int k;
  cin >> k;

  int cnt = 1;

  for (int i = 0; i < 5; ++i) {
    for (int j = i + 1; j < 5; ++j) {
      if (a[j] - a[i] > k) cnt = 0;
    }
  }
  if (cnt) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}


Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const int MOD = 1000000007;
typedef pair<long long,long long> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
 
    int N,M;cin >> N >> M;
    vector<pair<long long,long long>> retu(N);
    vector<pair<long long,long long>> check(M);
    for(int i = 0;i<N;i++) cin >> retu.at(i).first >> retu.at(i).second;
    for(int i = 0;i<M;i++) cin >> check.at(i).first >> check.at(i).second;

    for(int i = 0;i<N;i++){
        int ans = 0;long long mini = INF;
        for(int j = 0;j<M;j++){
            long long dist = abs(check.at(j).first-retu.at(i).first)+abs(check.at(j).second-retu.at(i).second);
            if(dist < mini){
                mini = dist;
                ans = j+1;
            }
        }
        cout << ans << endl;
    }

}

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

int main(){
  
  int n, ans;
  
  cin >> n;
  ans = n + n * n + n * n * n;
  cout << ans << endl;
  
  return 0;
  
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e8;
typedef long long ll;
ll mod = 1e9+7;
long long fast_exp(long long a, long long b)
{
    if(b == 0)
	   return 1;
    else
    {
	   long long res = 1;
	   res = fast_exp(a,b/2);
	   res = (res*res)%mod;
	   if(b%2 == 1)
		  res = (res*a)%mod;
	   return res;
 
    }
}
const ll N = 1e6;


int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	ll n;
	cin>>n;
	ll ones[64]={} , zero[64]={};
	ll a[n];
	for(ll i = 0; i<n ; i++)
	{
		cin>>a[i];
		ll pos = 0;
		int cur = 64;
		while(cur--)
		{
			if(a[i]%2)
				ones[pos]++;
			else
				zero[pos]++;
			a[i]=a[i]/2;
			pos++;
		}
	}
	// for(int pos = 0; pos<5 ; pos++)
	// {
	// 	cout<<"z : "<<zero[pos]<<"    on : "<<ones[pos]<<endl;
	// }
	ll ans = 0;
	ll p[64]={};
	p[0]=1;
	for(ll i = 1; i<64 ; i++)
		p[i] = 2*p[i-1];
	for(ll i = 0; i<64 ; i++)
		ans = (ans + (((ones[i]*zero[i])%mod)*((p[i])%mod))%mod)%mod;

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

Measured memory_bytes: 2560
NKQ = list(map(int, input().split()))
A = [int(input()) for i in range(NKQ[2])]

# print(NKQ)
# print(A)

apps = [0] * NKQ[0]

senzai = len(A)

for s in range(len(A)):
    apps[A[s]-1] += 1

for b in range(len(apps)):
    point = NKQ[1] - senzai + apps[b]
    if point <= 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 8628
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first 
#define ss second  
typedef pair<ll,ll> pp;
bool com(pp x,pp y){
    return x.ff<y.ff;
} 

void solve(){
    int n;
    cin>>n;
    vector<ll> frq(1e5+7,0),a(n);
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        frq[a[i]]++;
        sum+=a[i];
    }
    ll q,b,c;
    cin>>q;
    while(q--){
        cin>>b>>c;
        sum+=(c-b)*frq[b];
        frq[c]+=frq[b];
        frq[b]=0;
        cout<<sum<<"\n";
    }
}
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	return 0; 
	
}


Measured memory_bytes: 4760
import math

N = int(input())
t,a = [],[]
for _ in range(N):
	t_tmp, a_tmp = map(int, input().split())
	t.append(t_tmp)
	a.append(a_tmp)

T,A=1,1

for i in range(N):
	n = max(-(-A//a[i]), -(-T//t[i]))
	A = a[i] * n
	T = t[i] * n

print(A+T)

Measured memory_bytes: 3064
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

struct Data
{
    string key;
    int value;

    bool operator<(const Data &rhs) const
    {
        if (value == rhs.value)
        {
            return key < rhs.key;
        }

        return value > rhs.value;
    }
};

void solve()
{
    ll N;
    cin >> N;
    vector<string> S(N);
    map<string, ll> mp;
    vector<Data> uniq;

    for (ll i = 0; i < N; i++)
    {
        cin >> S.at(i);
        if (mp[S.at(i)] == (ll)NULL)
        {
            mp[S.at(i)] = 0;
            uniq.push_back({S.at(i), 0});
        }
        mp[S.at(i)] += 1;
    }

    ll uSize = uniq.size();
    for (ll i = 0; i < uSize; i++)
    {
        uniq.at(i).value = mp[uniq.at(i).key];
    }

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

    cout << uniq.at(0).key << endl;
    for (ll i = 1; i < uSize; i++)
    {
        if (uniq.at(i - 1).value != uniq.at(i).value)
        {
            break;
        }
        cout << uniq.at(i).key << endl;
    }

    return;
}

int main()
{
    solve();
    return 0;
}


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

int main() {
  int n, flag=1;//ことなるのが1
  cin >> n;
  vector<int> vec(n);
  for(int i=0; i<n; i++)
    cin>>vec.at(i);
  
  sort(vec.begin(), vec.end());
  
  for(int i=0; i<n-1;i++){
    if(vec.at(i) == vec.at(i+1)){
      flag=0;
      break;
    }
  }
  if(flag)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>

std::string nBaseEncode(int a,int n,std::string table="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"){
  /* aをn進法でansに変換する*/
  std::string ans="";
  int temp=a;
  while (temp!=0){
    ans=table[temp%n]+ans;
    temp/=n;
  }
  return ans;
}
int nBaseDecode(std::string a,int n,std::string table="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"){
  int ans=0,i;
  for (i=0;i<a.length();i++){
    ans*=n;
    ans+=table.find(a[i]);
  }
  return ans;
}
int main() {
  int n,ans=0,i;
  std::cin >> n;
  std::string a;
  for (i=0;i<std::pow(4,9);i++){
    a=nBaseEncode(i,4,"0357");
    if (nBaseDecode(a,10,"0123456789")<=n){
      if(a.find('0')==-1&&a.find('3')!=-1&&a.find('5')!=-1&&a.find('7')!=-1)ans++;
    }else break;
  }
  std::cout << ans << '\n';
}


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

int main(int argc, char const* argv[]) {
  using namespace std;

  int n;
  int a[1000];

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

  double sum = 0.0f;

  for (int i = 0; i < n; i++) {
    sum += (1.0f / a[i]);
  }

  printf("%.10f\n", (1 / sum));

  return 0;
}


Measured memory_bytes: 256
import math

N = int(input())
S = int(input())
L = N-S

def search(b, n=N):
    ans = 0
    while n >= b:
        ans += n%b
        n //= b
    ans += n
    return ans


def main():

    if L < 0:
        print(-1)
    elif L == 0:
        print(N+1)
    else:
        P = []
        for l in range(1, int(math.sqrt(L))+2):
            if L%l == 0:
                P.append(l+1)
                P.append(L//l+1)
        P.sort()

        ans = -1
        for p in P:
            if p == 1: continue
            S0 = search(p)
            if S == S0:
                ans = p
                break

        print(ans)

if __name__ == "__main__":
    main()

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>>s(h,vector<char>(w));
    rep(i,h){
        rep(j,w){
            cin >> s[i][j];
        }
    }
    
    bool ans = true;
    rep(i,h){
        rep(j,w){
            bool ok = false;
            if(s[i][j]=='.')continue;
            if(i>0&&s[i-1][j]=='#')ok = true;
            if(i<h-1 && s[i+1][j]=='#')ok = true;
            if(j>0 &&s[i][j-1]=='#')ok = true;
            if(j<w-1 &&s[i][j+1]=='#')ok = true;
            if(ok == false){
                ans = false;
                //cout << i << " " << j << endl;
            }

        }
    }
    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26028
#include<iostream>
#include<unordered_map>
#include<stack>
#include<algorithm>
#include<set>
#include<cstring>
#include<vector>
#include<numeric>
#include<map>
#include<climits>
#define int long long int
using namespace std;


int32_t main() 
{
	#ifndef ONLINE_JUDGE
	freopen("input/input.txt", "r", stdin);
	freopen("input/output.txt", "w", stdout);
	#endif
	int n;
	cin >> n;
	if(n == 0) cout << 1 << '\n';
	else cout << 0 << '\n';
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int ans=0,sum;
  for(int j=1;j<=N;j+=2) {
    sum=0;
    for(int a=1;a<=j;a++) {
      if(j%a==0) sum++;
    }
    if(sum==8) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
//author:happylkx
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <string.h>
#include <set>
#include <string>
using namespace std;
typedef long long LL;

char a[51], b[51];
int main()
{
	cin.getline(a, 51);
	cin.getline(b, 51);
	int lena = strlen(a);
	int lenb = strlen(b);

	if (lena < lenb) {
		cout << "UNRESTORABLE";
		return 0;
	}

	set<string> list;
	bool found = false;
	int i;
	for (i = lena - 1;i >= lenb - 1;i--) {
		bool valid = true;
		for (int j = 0;j < lenb;j++) {
			if ((a[i - j] == b[lenb - 1 - j]) || (a[i - j] == '?')) {
				continue;
			}
			else {
				valid = false;
				break;
			}
		}

		if (valid) {
			found = true;
			char tmp[51];
			strcpy(tmp, a);
			for (int j = 0;j < lenb;j++) {
				tmp[i - j] = b[lenb - 1 - j];
			}
			for (int j = 0;j < lena;j++) {
				if (tmp[j] == '?')tmp[j] = 'a';
			}
			string temp(tmp);
			list.insert(temp);
		}
	}

	if (found) {
		cout << *list.begin();
	}
	else {
		cout << "UNRESTORABLE";
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

int main() {
	int n, m;
	while(cin >> n >> m) {
		if(n == 0 && m == 0) break;

		vector<int> v(n + 1000);
		rep(i, n) {
			cin >> v[i];
		}

		vector<int> s(m);
		rep(i, m) {
			cin >> s[i];
		}

		int cur = 0, ans = 0;
		rep(i, m) {
			cur += s[i];
			cur += v[cur];

			ans++;
			if(cur >= n-1) {
				break;
			}
		}

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

Measured memory_bytes: 1204
N = int(input())
B = list(map(int,input().split()))
A = [0]*N
A[N-1] = B[N-2]
A[0] = B[0]
for i in range(1,N-1):
  if B[i-1] <= B[i]:
    A[i] = B[i-1]
  else:
    A[i] = B[i]
print(sum(A))

Measured memory_bytes: 8848
#include<stdio.h>
int main()
{
	int a, b, c, x;
	scanf("%d%d%d%d", &a, &b, &c, &x);
	int i, j, k;
	int ans = 0;
	for (i = 0; i <= a; i++)
		for (j = 0; j <= b; j++)
			for (k = 0; k <= c; k++)
				if (500 * i + 100 * j + 50 * k == x)
					ans++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1728
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;


class Solve
{
  public Solve() { }
  public static int Main()
  {
    new Solve().calc();
    return 0;
  }


  Scanner cin;

  void calc()
  {
    cin = new Scanner();
    double L = cin.nextDouble();
    double result = Math.Pow(L / 3, 3);
    
    Console.WriteLine(result.ToString());
  }
}
class Modulo
{
  private const int M = 1000000007;
  private readonly int[] m_facs;
  public int Mul(int a, int b)
  {
    return (int)(Math.BigMul(a, b) % M);
  }
  public Modulo(int n)
  {
    m_facs = new int[n + 1];
    m_facs[0] = 1;
    for (int i = 1; i <= n; ++i)
    {
      m_facs[i] = Mul(m_facs[i - 1], i);
    }
  }
  public int Fac(int n)
  {
    return m_facs[n];
  }
  public int Pow(int a, int m)
  {
    switch (m)
    {
      case 0:
        return 1;
      case 1:
        return a;
      default:
        int p1 = Pow(a, m / 2);
        int p2 = Mul(p1, p1);
        return ((m % 2) == 0) ? p2 : Mul(p2, a);
    }
  }
  public int Div(int a, int b)
  {
    return Mul(a, Pow(b, M - 2));
  }
  public int Ncr(int n, int r)
  {
    if (n < r) { return 0; }
    if (n == r) { return 1; }
    int res = Fac(n);
    res = Div(res, Fac(r));
    res = Div(res, Fac(n - r));
    return res;
  }
}

class Scanner
{
  string[] s;
  int i;

  char[] cs = new char[] { ' ' };

  public Scanner()
  {
    s = new string[0];
    i = 0;
  }

  public string next()
  {
    if (i < s.Length) return s[i++];
    string st = Console.ReadLine();
    while (st == "") st = Console.ReadLine();
    s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
    if (s.Length == 0) return next();
    i = 0;
    return s[i++];
  }

  public int nextInt()
  {
    return int.Parse(next());
  }
  public int[] ArrayInt(int N, int add = 0)
  {
    int[] Array = new int[N];
    for (int i = 0; i < N; i++)
    {
      Array[i] = nextInt() + add;
    }
    return Array;
  }

  public long nextLong()
  {
    return long.Parse(next());
  }

  public ulong nextULong()
  {
    return ulong.Parse(next());
  }

  public long[] ArrayLong(int N, long add = 0)
  {
    long[] Array = new long[N];
    for (int i = 0; i < N; i++)
    {
      Array[i] = nextLong() + add;
    }
    return Array;
  }

  public double nextDouble()
  {
    return double.Parse(next());
  }


  public double[] ArrayDouble(int N, double add = 0)
  {
    double[] Array = new double[N];
    for (int i = 0; i < N; i++)
    {
      Array[i] = nextDouble() + add;
    }
    return Array;
  }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main(){
int A,B,C,D;
int result;
int temp=0;
cin>>A>>B>>C>>D;
result =min(B,D)-max(A,C);
if(result>0){
	cout<<result;
}
else 
cout<<"0";

return 0;
	}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;



void Main()
{
	LL n; cin>>n;

	LL result = INF_LL;

	for(LL i=1;i*i<=n;i++){
		if(n%i == 0){
			result = min(result, i + n/i -2);
		}
	}

	cout << result << endl;

	return;
}

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, k;
    cin >> n >> k;
    if (k % 2 == 0) {
        cout << (ll)pow(n/k, 3) + (ll)pow(n/k + (n%k)/(k/2), 3) << endl;
    } else {
        cout << (ll)pow(n/k, 3) << endl;
    }
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    cout << n + pow(n, 2) + pow(n, 3) << endl;

    return 0;
}

Measured memory_bytes: 4288
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e7
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

int main(){
    int r,d;cin>>r>>d;
    int x;cin>>x;
    REP(i,1,10){
        x = r*x-d;
        cout<<x<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if (x-r < 0 || x+r > W || y-r < 0 || y + r > H)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

}

Measured memory_bytes: 3108
s = input()
a = ""
cnt, cnt_ = 0, 0
while len(a) <= len(s):
    a += "10"

for i in range(len(s)):
    if s[i] != a[i]:
        cnt += 1
    if s[i] != a[i + 1]:
        cnt_ += 1
print(min(cnt, cnt_))

Measured memory_bytes: 3188