akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[300000];
int b[300000];
int c[300000];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int m = 0;
	for (int i = 0; i < n;) {
		int j = i;
		while (j < n&&a[i] == a[j]) {
			j++;
		}
		b[m++] = a[i];
		i = j;
	}
	int ans = 1;
	for (int i = 0; i < m; i++) {
		ans += c[b[i]];
		ans %= Mod;
		c[b[i]] = ans;
		c[b[i]] %= Mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
string s;
bool a[26];
inline void goout()
{
	cout <<s<<endl;
	exit(0);
}
inline int small(int smallest)
{
	for(int i=0;i<26;i++)
	if(!a[i]&&i>smallest)
	{
	//	puts("go");
		return i;
	}
	return -1;
}
int main()
{
	cin >>s;
	for(int i=0;i<s.size();i++)
	a[s[i]-'a']=true;
	int smm=small(-1);
    if(smm>-1)
    {
		char d='a'+smm;
	//	cout <<d;
    //	cout <<s+d;
    	s+=d;
    	goout();
	}
	for(int i=0;i<s.size();i++)
	{
		int c=s.size()-1-i;
		int sm=small(s[c]-'a');
		if(sm<0)
		{
			a[s[c]-'a']=false;
			s[c]=' ';
			continue;
		}
		else
		{
			s[c]=sm+'a';
			goout();
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define vii vector<int,int>

using namespace std;

int digit(long long x){
    int ct =0;
    while(x>0){
        x/=10;
        ct++;
    }
    return ct;
}

int main(){
    long long N;
    cin >> N;
    
    int res = 10;
    for(long long i = 1;i*i <= N ;i++){
        if((N%i) == 0){
            int a = digit(i);
            int b = digit(N/i);
            
            res = min(res,max(a,b));
        }
    }
    
    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    vector<int> c(n - 1), s(n - 1), f(n - 1);
    rep(i, n - 1) cin >> c[i] >> s[i] >> f[i];

    vector<int> ans(n, 0);
    rep(k, n - 1) {
        int tot = 0;
        forr(i, k, n - 1) {
            if(tot < s[i]) tot = s[i];
            else if((tot - s[i]) % f[i] != 0) {
                tot = tot + f[i] - tot % f[i];
            }
            tot += c[i];
        }
        ans[k] = tot;
    }

    for(auto x : ans) cout << x << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A; int B; int C; int D;
  cin >> A; cin >> B; cin >> C; cin >> D;
  if (A+B == C+D){
    cout << "Balanced" << endl;
  }
  if (A+B > C+D){
    cout << "Left" << endl;
  }
  if (A+B < C+D){
    cout << "Right" <<endl;
  }
}

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

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
char capitalize(char c) { return static_cast<char>(std::toupper(static_cast<unsigned char>(c))); }
// template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
// template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "Yes"
#define NO  "No"

#define forit(v) for(auto it = v.begin(); it != v.end(); ++it)

using namespace std;

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

  int num = 0;
  // num = numeric_limits<int>::max();
  // num = numeric_limits<int>::min();
  bool flag = false;
  flag = true;

  int n; cin >> n;
  vector<int> t(n); forit(t) cin >> *it;
  int m; cin >> m;
  num = accumulate(t.begin(), t.end(), 0);

  for (int i = 0; i < m; ++i) {
    int p, x; cin >> p >> x;
    cout << num - t[p - 1] + x << endl;
  }
  
  // cout << num << endl;
  // cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
from itertools import groupby
N =int(input())
d = [input() for i in range(N)]

d.sort()
#print(d)
p=-1
b=[]
for key, value in groupby(d):
  a = len(list(value))
  if p<a:
    #print(p,len(list(value)))
    b=[]
    b.append(key)
    p=a
  elif p==a:
    #print(222)
    b.append(key)
for i in b:
  print(i)

Measured memory_bytes: 21460
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#define ull int
using namespace std;

const int nmax = 200100;
ull N,n;
ull a[nmax], b[nmax], c[nmax];
ull curmod = 0;

void read(){
    cin >> N;
    n = N;
    for(int i=0;i < N; ++i)cin >> a[i];
    for(int i=0;i < N; ++i)cin >> b[i];
}
ull bs(ull a, ull C, ull B, ull A, ull x)
{
    int AA = 1 << x + 1;
	int BB = 3 * (1 << x);
	int CC = 1 << x;
    if(AA!=A || BB != B || CC!=C)
    {
        cout << "YOEOEOEOEOELOEL\n";
        exit(0);
    }
    ull res = 0;
    int ind = lower_bound(c, c+N, C - a%AA) - c;
    res = (res + ind) % 2;
    ind = lower_bound(c, c+N , A - a%AA) - c;
    res = (res - ind % 2 + 2) % 2;
    ind = lower_bound(c, c+N, B - a%AA) - c;
    res = (res + N - ind) % 2; 
    return res;
}


int Solve(int x)
{
	int A = 1 << x + 1;
	int B = 3 * (1 << x);
	int C = 1 << x;
	for (int i = 0; i < n; i++)
		c[i] = b[i] % A;
	sort(c, c + n);
	int res = 0;
	for (int i = 0; i < n; i++) {
		int ind = lower_bound(c, c + n, C - a[i] % A) - c;
		res = (res + ind) % 2;
		ind = lower_bound(c, c + n, A - a[i] % A) - c;
		res = (res - ind % 2 + 2) % 2;
		ind = lower_bound(c, c + n, B - a[i] % A) - c;
		res = (res + n - ind) % 2; 
	}
	return res;
}

void solve(){
    ull ans = 0;
    curmod = 1;
    for(int i = 0; i <= 28; ++i)
    {
        //ans += Solve(i) ? (1 << i) : 0;
        //continue;
        
        vector <ull> bmod;
        for(int j=0; j < N; ++j){
            c[j] = (b[j] % (curmod<<1));
        }
  
//sort(bmod.begin(), bmod.end());
        sort(c, c+N);
        ull cnt = 0;
        for(int j=0;j<N; ++j)
        {
            cnt += bs(a[j] % (curmod << 1), curmod, 3 * curmod , curmod << 1,i );
            //cout << cnt << ' ' << a[j] << endl;
        }
        ans += (cnt & 1) * (curmod);
        //if(curmod==4)break;
        curmod <<=1;
        //cout << "---\n";
    }
    cout << ans << endl;
}

int main(){
    read();
    solve();
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i = 0; i<n; i++){
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    int half = n / 2;
    int ans = d[half] - d[half - 1];
    
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define ll long long
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))

using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> a (n);
    
    for(int i = 0;i < a.size();i++){
        cin >> a[i];
    }

    bool is_rise = false;
    vector<int> wave (0); //kabuka,is_kau
    for(int i = 1;i < n;i++){
        if(!is_rise){
            //fall
            if(a[i-1] < a[i]){
                //ifrise
                wave.push_back(a[i-1]);
                is_rise = true;
                /* cout << i << endl; */
            }
        } else {
            if(a[i-1] > a[i]){
                //ifrise
                wave.push_back(a[i-1]);
                is_rise = false;
                /* cout << i << endl; */
            }
        }
    }

    if(wave.empty()){
        cout << 1000;
        return 0;
    }

    if(wave.back() < a[n-1] || is_rise == true){
        wave.push_back(a[n-1]);
    }

    /* for(auto i : wave){
        cout << i.first << " " << i.second << endl;
    } */
    ll money = 1000;
    for(int i = 0;i <= wave.size()-2;i+=2){
        assign_max(money, (money % wave[i]) + ((money / wave[i]) * wave[i+1]));
    }

    cout << money << endl;
    
    return 0;
}

Measured memory_bytes: 3196
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val s = readLine()!!
    val k = readLong()

    val runLengthS = runLengthEncode(s)
    if (runLengthS.size == 1) {
        println(s.length * k / 2)
        return
    }

    var ansForS = 0
    for (run in runLengthS) {
        ansForS +=  run.length / 2
    }

    val runLengthSS = runLengthEncode(s + s)
    var ansForSS = 0
    for (run in runLengthSS) {
        ansForSS += run.length / 2
    }

    val diff = ansForSS - ansForS
    println(ansForS + diff * (k - 1))
}

data class RunLength<T>(val value: T, val length: Int)

/** O(s.length) */
//fun runLengthEncode(s: String): List<RunLength<Char>> {
//    if (s.isEmpty()) return emptyList()
//
//    val runLengthList = mutableListOf<RunLength<Char>>()
//    var currentChar = s.first()
//    var length = 1
//    for (c in s.substring(1)) {
//        if (c == currentChar) {
//            length++
//        } else {
//            runLengthList += RunLength(currentChar, length)
//            currentChar = c
//            length = 1
//        }
//    }
//    runLengthList += RunLength(currentChar, length)
//
//    return runLengthList
//}

//fun runLengthEncode(s: CharSequence): List<RunLength<Char>> = s.fold(mutableListOf<RunLength<Char>>()) { acc, value ->
//    if (acc.isNotEmpty() && acc.last().value == value) {
//        acc.last().length++
//    } else {
//        acc += RunLength(value, 1)
//    }
//    acc
//}

fun runLengthEncode(s: CharSequence) = s.fold(listOf<RunLength<Char>>()) { acc, value ->
    if (acc.isEmpty()) {
        acc + RunLength(value, 1)
    } else {
        val last = acc.last()
        if (last.value == value) {
            acc.dropLast(1) + last.copy(length = last.length + 1)
        } else {
            acc + RunLength(value, 1)
        }
    }
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 33788
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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;
}

ll M = 1000000007;
int n,m,q;
vector<int>a(51),b(51),c(51),d(51);
int ans=0;
void dfs(vector<int>num){
	int sz=size(num);
	if(sz==n){
		int sum=0;
		/*rep(i,n){
			cout<<num[i]<<" ";
		}
		cout<<endl;*/
		rep(i,q){
			int dis=num[b[i]]-num[a[i]];
			//cout<<dis<<endl;
			if(dis==c[i]){
				//cout<<"yay"<<endl;
				sum+=d[i];
			}
		}
		//cout<<sum<<endl;
		ans=max(ans,sum);
		//return ;
	}else{

		FOR(i,num[sz-1],m+1){
			vector<int>aa=num;
			//cout<<" "<<i<<endl;
			aa.push_back(i);
			dfs(aa);
		}	
	}
	
}
void solve()
{
	//int q;
	cin>>n>>m>>q;
	
	rep(i,q){
		cin>>a[i]>>b[i]>>c[i]>>d[i];
		a[i]--;b[i]--;
	}
	vector<int>t;
	t.push_back(1);
	dfs(t);
	cout<<ans<<endl;

}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 3592
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] d = new int[N];
		for( int i=0; i<N; i++ ){
			d[i]=sc.nextInt();
		}
		int a = 0;
		for( int i=0; i<N; i++ ){
			for( int j=i+1; j<N; j++ ){
				if( j==i ){
					continue;
				}
				a+=d[i]*d[j];
			}
		}
		System.out.println(a);
	}
}


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

int main(){
  string S; cin >> S;
  int zero,one;
  zero = 0; one = 0;
  for(int i=0; i<S.size(); i++){
    if('0'==S[i]){zero++;}
    else{one++;}
  }
  
  cout << min(zero, one)*2;
  
  return 0;
}

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

int main(){
	int i,n;
	double s[1000],ave,sum,answer;
	char input[4001],*p;
	
	while(1){
		sum=0.0;
		fgets(input,sizeof input,stdin);
		sscanf(input,"%d",&n);
		
		if(n==0){
			break;
		}
		
		fgets(input,sizeof input,stdin);
		
		p=strtok(input," ");
		s[0]=strtod(p,NULL);
		sum+=s[0];
		for(i=1;i<n;i++){
			p=strtok(NULL," ");
			s[i]=strtod(p,NULL);
			sum+=s[i];
		}
		//??????
		ave=sum/(double)n;
		//??????
		for(i=0;i<n;i++){
			s[i]-=ave;
		}
		sum=0.0;
		//?????£
		for(i=0;i<n;i++){
			sum+=s[i]*s[i];
		}
		ave=sum/(double)n;
		//?¨??????????
		answer=sqrt(ave);
		printf("%f\n",answer);
	}
	return 0;
}

Measured memory_bytes: 668
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	// your code goes here
	int t=1;
	//cin >> t;
	while(t--)
	{
        ll n, k, i=1;
        cin >> n >> k;
        double ans = 0.0;
        cout << fixed ;
        cout << setprecision(12);
        while(i<=n)
        {
            ll v = i, c=0;
            while(v<k)
            {
                v = v*2;
                c++;
            }
            ans = ans+ (double)(1.0/(n*pow(2,c)));
            c=0;
            i++;
        }
        cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>

 int main(){
     int W,H,x,y,r;
     scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
     if(0 <= x - r & x + r <= W & 0 <= y - r & y + r <= H ){
         printf("Yes");
     }
         else{
             printf("No");
         }
     printf("\n");
     return 0;
 }


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

int main(){
  int n;
  cin >> n;
  
  double d, result;
  
  for(int i = 0; i < n; i++){
    cin >> d;
    result += 1/d;
  }
  result = 1 / result;
  
  cout << result << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		String[] Ws = W.split(" ");

		System.out.println(Ws[1]+Ws[0]);

	}
}


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

#define M 4
int a[M], b[M];

double sub_in(int a[], int n)
{
	for (int i = 0; i < n; i++)
	{
		if (!(cin >> a[i]))
			return false;
	}
	return true;
}

bool in_ab(int a[], int b[], int n)
{
	if (!sub_in(a, n) || !sub_in(b, n))
		return false;
	return true;
}

int hit(int a[], int b[], int n)
{
	int c = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] == b[i])
			c++;
	}
	return c;
}

int blow(int a[], int b[], int n)
{
	int c = 0;
	for(int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
		{
			if (a[i] == b[j] && i != j)
				c++;
		}
	return c;
}

int main()
{
	while (in_ab(a,b,M))
	{
		cout << hit(a,b,M) << " " << blow(a,b,M) << endl;
	}
	return 0;
}

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

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

int main() {
	for (int T, D, L; cin >> T >> D >> L&&T;) {
		int t = 0;
		int ans = 0;
		rep(i, 0, T) {
			int x; cin >> x;
			if (i == T - 1)break;
			if (x >= L)t = D;
			if (t) {
				t--;
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3056
#define DEBUG 0

/**
 * File    : E2.cpp
 * Author  : Kazune Takahashi
 * Created : 5/25/2019, 12:46:38 AM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

const int MAX_SIZE = 1000010;
const long long MOD = 1000000007;

long long inv[MAX_SIZE];
long long fact[MAX_SIZE];
long long factinv[MAX_SIZE];

void init()
{
  inv[1] = 1;
  for (int i = 2; i < MAX_SIZE; i++)
  {
    inv[i] = ((MOD - inv[MOD % i]) * (MOD / i)) % MOD;
  }
  fact[0] = factinv[0] = 1;
  for (int i = 1; i < MAX_SIZE; i++)
  {
    fact[i] = (i * fact[i - 1]) % MOD;
    factinv[i] = (inv[i] * factinv[i - 1]) % MOD;
  }
}

long long C(int n, int k)
{
  if (n >= 0 && k >= 0 && n - k >= 0)
  {
    return ((fact[n] * factinv[k]) % MOD * factinv[n - k]) % MOD;
  }
  return 0;
}

long long power(long long x, long long n)
{
  if (n == 0)
  {
    return 1;
  }
  else if (n % 2 == 1)
  {
    return (x * power(x, n - 1)) % MOD;
  }
  else
  {
    long long half = power(x, n / 2);
    return (half * half) % MOD;
  }
}

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

ll B, W;
ll ans[200010];

int main()
{
  init();
  cin >> B >> W;
  ll N = B + W;
  ans[0] = inv[2];
  for (auto k = 1; k < N; k++)
  {
    ans[k] = ans[k - 1];
    ans[k] += MOD - (C(k - 1, B - 1) * power(inv[2], k + 1)) % MOD;
    ans[k] %= MOD;
    ans[k] += (C(k - 1, W - 1) * power(inv[2], k + 1)) % MOD;
    ans[k] %= MOD;
  }
  for (auto i = 0; i < N; i++)
  {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 27136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
struct UnionFind {
    vector<int> par;
    vector<long long> siz;
    long long psiz;

    UnionFind(int N) : par(N),siz(N,1LL),psiz(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }
    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if(siz[rx] < siz[ry]) swap(rx,ry);
        siz[rx] += siz[ry];
        psiz -= siz[ry];
        par[ry] = rx;
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    long long size(int x){
        return siz[root(x)];
    }
    long long psize() {
        return psiz;
    }
};

int main(){
    int n,q;
    cin >> n >> q;
    UnionFind tree(n);
    rep(i,q){
        int t,u,v;
        cin >> t >> u >> v;
        if (t){
            if(tree.same(u,v)) cout << 1 << "\n";
            else cout << 0 << "\n";
        }else{
            tree.unite(u,v);
        }
    }
}

Measured memory_bytes: 5604
// C++ code to find maximum possible product of 
// sub-sequence of size k from given array of n 
// integers 
#include <algorithm> // for sorting 
#include <iostream> 
#define M 1000000007
using namespace std; 

// Required function 
int maxProductSubarrayOfSizeK(int64_t A[], int n, int k) 
{ 
	// sorting given input array 
	sort(A, A + n); 

	// variable to store final product of all element 
	// of sub-sequence of size k 
	int product = 1; 

	// CASE I 
	// If max element is 0 and 
	// k is odd then max product will be 0 
	if (A[n - 1] == 0 && (k & 1)) 
		return 0; 

	// CASE II 
	// If all elements are negative and 
	// k is odd then max product will be 
	// product of rightmost-subarray of size k 
	if (A[n - 1] <= 0 && (k & 1)) { 
		for (int i = n - 1; i >= n - k; i--) 
			product = (product * A[i])%M; 
		return ((product%M)+M)%M; 
	} 

	// else 
	// i is current left pointer index 
	int i = 0; 

	// j is current right pointer index 
	int j = n - 1; 

	// CASE III 
	// if k is odd and rightmost element in 
	// sorted array is positive then it 
	// must come in subsequence 
	// Multiplying A[j] with product and 
	// correspondingly changing j 
	if (k & 1) { 
		product =( product * A[j] ) %M; 
		j--; 
		k--; 
	} 

	// CASE IV 
	// Now k is even 
	// Now we deal with pairs 
	// Each time a pair is multiplied to product 
	// ie.. two elements are added to subsequence each time 
	// Effectively k becomes half 
	// Hence, k >>= 1 means k /= 2 
	k >>= 1; 

	// Now finding k corresponding pairs 
	// to get maximum possible value of product 
	for (int itr = 0; itr < k; itr++) { 

		// product from left pointers 
		int64_t left_product = (A[i] * A[i + 1]); 

		// product from right pointers 
		int64_t right_product =(A[j] * A[j - 1]); 

		// Taking the max product from two choices 
		// Correspondingly changing the pointer's position 
		if (left_product > right_product) { 
			product =product * A[i] %M * A[i+1] %M; 
			i += 2; 
		} 
		else { 
			product =product * A[j] %M * A[j-1] %M;
			j -= 2; 
		} 
	} 

	// Finally return product 
	if(product<0)
	    return ((product%M)+M)%M; 
	return product%M;
} 

// Driver Code to test above function 
int main() 
{ 
	int n,k;
	cin>>n>>k;
	int64_t A[n];
	for(int i=0;i<n;i++)
	    cin>>A[i];
	cout << maxProductSubarrayOfSizeK(A, n, k)%M; 

	return 0; 
} 


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

int main() {
  int N;
  cin >> N;
 int64_t a = 0;
  for (int i = 1; i <= N; i++) {
    if((i%3) != 0 && (i%5) != 0){
      a = a + i;
    }
  }
cout << a << endl;
  
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

static const long long MOD = 1000000007;
static const long long INF = 1<<31;

ll n, a[200005], k;
ll x[200005];
ll c[200005];

int main(void) {
    cin >> n >> k;
    rep(i, 1, n+1) scanf("%lld", &a[i]);

    rep(i, 0, n+1) c[i] = 1000000000;

    x[0] = 1;
 
    rep(i, 0, n+1) {
        x[i+1] = a[x[i]];
    }

    ll s = -1, t = -1;
    rep(i, 0, n+1) {
        if (c[x[i]]!=1000000000) {
            s = c[x[i]];
            t = i;
            break;
        }
        c[x[i]] = i;
    }

    if (k<s) {
        printf("%lld\n", x[k]);
    } else {
        printf("%lld\n", x[s+(k-s)%(t-s)]);
    }



	return 0;
}


Measured memory_bytes: 8512
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    if (b>=a){
      System.out.println("unsafe");
    }
    else{
      System.out.println("safe");
    }
  }
}


Measured memory_bytes: 35420
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int r;
	cin>>r;
	if(r<1200)
	cout<<"ABC"<<endl;
	else if(r<2800)
	cout<<"ARC"<<endl;
	else
	cout<<"AGC"<<endl; 
	return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  ans = max(ans, 10 * a + b + c);
  ans = max(ans, a + 10 * b + c);
  ans = max(ans, 10 * c + a + b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = (int)(1<<30);
int dp[41][401][401];

int main() {
  int N, Ma, Mb; cin >> N >> Ma >> Mb;
  int a[40], b[40], c[40];
  for(int i = 0; i < N; ++i) {
    cin >> a[i] >> b[i] >> c[i];
  }
  for(int i = 0; i <= N; ++i) {
    for(int ca = 0; ca <= 400; ++ca) {
      for(int cb = 0; cb <= 400; ++cb) {
        dp[i][ca][cb] = inf;
      }
    }
  }
  dp[0][0][0] = 0;
  for(int i = 0; i < N; ++i) {
    for(int ca = 0; ca <= 400; ++ca) {
      for(int cb = 0; cb <= 400; ++cb) {
        if(dp[i][ca][cb] == inf) continue;
        dp[i+1][ca][cb] = min(dp[i+1][ca][cb] , dp[i][ca][cb]);
        dp[i+1][ca+a[i]][cb+b[i]] = min(dp[i+1][ca+a[i]][cb+b[i]], dp[i][ca][cb] + c[i]);
      }
    }
  }
  int ans = inf;
  for(int ca = 1; ca <= 400; ++ca) {
    for(int cb = 1; cb <= 400; ++cb) {
      if(ca*Mb == cb*Ma) ans = min(ans, dp[N][ca][cb]);
    }
  }
  if(ans == inf) ans = -1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 25984
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		double[] a=new double[n];
		double[] tmp=new double[n];
		long ans=0;
		for(int i=0; i<n; i++){
			a[i]=sc.nextInt()-k;
			if(i!=0){
				a[i]+=a[i-1];
			}
			tmp[i]=a[i];
			if(tmp[i]>=0){
				ans++;
			}
		}
		Arrays.sort(tmp);
		for(int i=0; i<n; i++){
			a[i]=-Arrays.binarySearch(tmp,a[i]+0.1);
		}
		BIT b=new BIT(n+1);
		for(int i=0; i<n; i++){
			ans+=b.get((int)a[i]);
			b.add((int)a[i]);
		}
		System.out.println(ans);
	}
	static class BIT{
		int n;
		int[] data;
		BIT(int n){
			this.n=n;
			data = new int[n+1];
		}
		void add(int i){
			for(;i<=n;i+=i&(-i))data[i]++;
		}
		int get(int i){
			int res = 0;
			for(;i>0;i-=i&(-i))res+=data[i];
			return res;
		}
	}
}


Measured memory_bytes: 93784
#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define dbV(arr) cout << #arr << "=[ "; \
for(auto i:arr) cout << i << " "; cout << "]\n";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repF(i,a,n) for(int i = (a); i <= (n); ++i)
#define repB(i,a,n) for(int i = (a); i >= (n); --i)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define umii unordered_map<int,int>
#define umll unordered_map<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define seti set<int>
#define setl set<ll>
#define pb push_back
#define F first
#define S second
#define MOD 1000000007
#define all(z) z.begin(),z.end()
using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n; cin >> n;
	vector<vector<int>> activity(n);
	rep(i, n) {
		activity[i].resize(3);
		int a, b, c; cin >> a >> b >> c;
		activity[i] = {a, b, c};
	}
	vector<vector<int>> dp(n);
	dp[0].resize(3); dp[0][0] = activity[0][0];
	dp[0][1] = activity[0][1]; dp[0][2] = activity[0][2];
	repF(i, 1, n - 1) {
		dp[i].resize(3);
		dp[i][0] = activity[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = activity[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = activity[i][2] + max(dp[i - 1][1], dp[i - 1][0]);
	}
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
	return 0;
}

Measured memory_bytes: 14252
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();
		int count=0;

		for (int i = a; i <= b; i++) {
			if(c%i==0){
				count++;
			}
		}
		//c????´???°?????????
		System.out.println(count);
	}
}

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

using namespace std;

int ctos, son;
int A[10005];
int D[50005];

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

    cin>>ctos>>son;
    for(int i=1; i<=son; i++){
        cin>>A[i];
    }

    for(int i=1;  i<=ctos; i++){
        D[i] = 50001;
        for(int k=1; k<=son; k++){
            if(A[k] > i)
                continue;
            D[i] = min(D[i], 1 + D[i - A[k]]);
        }
    }
    cout<<D[ctos]<<endl;
    return 0;
}

Measured memory_bytes: 3412
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(b<a)a=b
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
int high[10000], par[10000];
inline int findSet(int x) {
	if(x != par[x]) par[x] = findSet(par[x]);
	return par[x];
}
inline void link(int x, int y) {
	if(high[x] > high[y]) par[y] = x;
	else {
		par[x] = y;
		if(high[x] == high[y]) ++high[y];
	}
}
inline void unite(int x, int y) { link(findSet(x), findSet(y)); }
inline bool same(int x, int y) { return findSet(x) == findSet(y); }
int main() {
	int n, q; cin >> n >> q;
	rep(i, 0, 10000) { high[i] = 0; par[i] = i; }
	int t, a, b;
	rep(i, 0, q) {
		cin >> t >> a >> b;
		if(t == 0) unite(a, b);
		else if (t == 1) P(same(a, b) ? 1 : 0);
	}
	return 0;
}

Measured memory_bytes: 3284
#include <iostream>
#include <string.h>

int main(int argc, char** argv) {
	char str[20];
	int len, i;

	std::cin >> str;
	len = strlen(str);
	
	for(i = len - 1; i >= 0; i--) {
		std::cout << str[i];
	}
	std::cout << std::endl;
}


Measured memory_bytes: 3032
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int dan;
int dp[31];
int solve(int i);

int main(void){
	
	while(cin >> dan, dan){
		fill_n(dp,31,-1);
		int flag = 0;
		if(solve(0) % 3650 != 0){flag++;}
		int ans = solve(0)/3650 + flag;
		cout << ans << endl;
	}
}

int solve(int num){
	if(num == dan){return 1;}
	if(num > dan){return 0;}
	if(dp[num] != -1){return dp[num];}
	int sum = 0;
	for(int i = 0; i < 3; i++){
		sum += solve(num + i + 1);
	}
	return dp[num] = sum;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<algorithm>
int b[100000], a[100000];
int main() {
	int n, h, i;
	scanf("%d%d", &n, &h);
	for (i = 0; i < n; i++) {
		scanf("%d%d", &a[i], &b[i]);
	}
	std::sort(a, a + n, [](const int& a, const int& b) {return a > b; });
	std::sort(b, b + n, [](const int& a, const int& b) {return a > b; });
	i = 0;
	while (h>0 && a[0] < b[i]) {
		h -= b[i];
		i++;
	}
	if (h>0) {
		i += h / a[0];
		if (h % a[0] != 0) {
			i++;
		}
	}
	printf("%d", i);
	return 0;
}

Measured memory_bytes: 896
package main

import "fmt"

func main() {
	// Code for A - Something on It
	var S string
	fmt.Scanf("%s", &S)

	var count int = 0
	for i := 0; i < 3; i++ {
		if S[i] == 'o' {
			count++
		}
	}
	fmt.Println(700 + count*100)
}


Measured memory_bytes: 1832
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)



int main() {
	long long int n, i = 0;
	long long int a, b, c = 0, k = 0;
	cin >> n >> k;
	if (k == 1 || k == n) {
		cout << 0 << endl;
		return 0;
	}
	if (n / k > 10000000000) {
		if (k / 10 > 1) {
			while (n >= 1000000000) {
				n -= k * 10000000;
			}
		}
		else {
			n -= k * 100000000000000000;
			while (n >= 100000000) {
				n -= k * 10000000;
		}
	
		}
		while (1) {
			i++;
			a = n - k;
			//cout << "a"<<a << endl;
			if (a < 0) {
				a = a * -2 + a;
				//cout <<"a2"<<a<< endl;
			}
			b = a - k;
			//cout <<"b"<< b << endl;
			if (b < 0) {
				b = b * -2 + b;
				//cout <<"b2"<< b << endl;
			}

			if (b < a && n != b) {
				n = b;
			}
			else {
				if (i == 1 && a < n) n = a;
				cout << k - n << endl;
				return 0;
			}
		}

	}
	//cout << n << endl;
	while (1) {
		i++;
		a = n - k;
		//cout << "a"<<a << endl;
		if (a < 0) {
			a = a * -2 + a;
			//cout <<"a2"<<a<< endl;
		}
		b = a - k;
		//cout <<"b"<< b << endl;
		if (b < 0) {
			b = b * -2 + b;
			//cout <<"b2"<< b << endl;
		}

		if (b < a && n != b) {
			n = b;
		}
		else {
			if (i == 1 && a < n) n = a;
			if (n - k)
				cout << n << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 3652
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

a,b,c = iim()
if (a*b*c)%2 == 0:
    print(0)
else:
    print(a*b*c//max(a,b,c))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

long long int res;

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

    long long int A, B, C;
    cin >> A >> B >> C;
    long long int cnt = 0;
    long long int tmpA, tmpB, tmpC;
    tmpA = A;
    tmpB = B;
    tmpC = C;
    if (A == 1 && B == 1 && C == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    if (A == B && B == C)
    {
        cout << -1 << endl;
        return 0;
    }
    while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0)
    {
        A = tmpB / 2 + tmpC / 2;
        B = tmpA / 2 + tmpC / 2;
        C = tmpA / 2 + tmpB / 2;
        cnt++;
        tmpA = A;
        tmpB = B;
        tmpC = C;
    }

    res = cnt;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int fa[100001],x,y;
int n,m;
int find(int s)
{
    if(fa[s]!=s) fa[s]=find(fa[s]);
     return fa[s];
}
void unionq(int x,int y)
{
	 fa[find(y)]=find(x);
}
int count_sets(int n)
{
	int cnt = 0;
	for (int i = 1; i <= n; i++)
		if (find(i) == i)
			cnt++;
 
	return cnt;
}
int main()
{
	int bi;
    cin>>n>>m;
    for(int i=1;i<=n;i++) fa[i]=i;
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
     unionq(x,y);
    }
  int kk=count_sets(n);
  cout<<kk-1;
    return 0;
}

Measured memory_bytes: 4012
//AtCoder ABC065 B - Trained?
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll N;
    cin>>N;
    vector<ll> atbl(N+1,0);
    vector<bool> flags(N+1,false);
    for(ll i=1;i<=N;++i){
        cin>>atbl[i];
    }
    ll cur=1;
    ll count=0;
    while(true){
        flags[cur]=true;
        cur=atbl[cur];
        ++count;
        if(cur==2){
            break;
        } else if(flags[cur]){
            count=-1;
            break;
        }
    }
    cout<<count<<endl;
    return 0;
}

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

bool can_do_with_conditions(const int nr_colors, const int nr_unique, const int nr_same){
    if(nr_colors == nr_unique && nr_same == 0) return true;
    if(nr_colors == nr_unique && nr_same != 0) return false;
    if(nr_colors < nr_unique) return false;
    return 2 * (nr_colors - nr_unique) <= nr_same; }

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    map<int, int> frec;
    for(auto&x  : v) cin >> x, ++frec[x];

    if(frec.size() > 2){
        cout << "No" << endl;
        return 0; }

    const int small = begin(frec)->first, big = (--end(frec))->first;
    bool rez = false;
    if(frec.size() == 1) rez = (n == big+1 || 2 * big <= n);
    else rez = (small == big-1 && can_do_with_conditions(big, frec[small], frec[big]));
    cout << (rez ? "Yes" : "No") << endl;
    return 0; }


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main()
{   
	int n,i;
	cin>>n;
	string a,b;
	cin>>a>>b;
	for(i=0;i<n;i++)
	{
		cout<<a[i]<<b[i];
	}
	cout<<endl;
	return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

char bo[] = {'a','i','u','e','o'};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  while(true){
    cin >> n;
    if(n == 0) break;
    vector<string> x(n);
    rep(i,n){
      string s;
      cin >> s;
      x[i].push_back( s[0] );
      rep(j,s.size()-1){
        rep(k,5){
          if(s[j] == bo[k]) x[i].push_back(s[j+1]);
        }
      }
    }
    bool flag = false;
    rep(i,51){
      set<string> st;
      rep(j,n){
        st.insert(x[j].substr( 0,min(i,(ll)x[j].size()) ));
      }
      if(st.size() == n){
        flag = true;
        cout << i << endl;
        break;
      }
    }
    if(flag == false) cout << -1 << endl;
  }
  return 0;
}



Measured memory_bytes: 3216
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=100005;

int dp[N];

void solve()
{
    //dp[1]=0;
    dp[1]=0;
    int n,k;
    cin>>n>>k;
    for(int i=2;i<=n;i++)
        dp[i]=INF;
    int h[n+1];
    for(int i=1;i<=n;i++)
        cin>>h[i];
    for(int j=2;j<=n;j++)
    {
        for(int i=j-1;i>=max((int)1,j-k);i--)
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
    }
    cout<<dp[n]<<endl;
    
    
    
    
}


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






Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 1000006;

int x[5];

void solv()
{
    for (int i = 0; i < 5; ++i)
    {
        scanf("%d", &x[i]);
    }
    for (int i = 0; i < 5; ++i)
    {
        if (x[i] == 0)
            printf("%d\n", (i + 1));
    }
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    //ios_base::sync_with_stdio(false), cin.tie(0);
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


Measured memory_bytes: 3828
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();

        var k = sc.nextInt();
        var s = sc.nextInt();

        long ans = 0;
        for (int x = 0; x <= k; x++)
        {
            for (int y = 0; y <= k; y++)
            {
                if (0 <= s - x - y && s - x - y <= k) ans++;
            }
        }
        Console.WriteLine(ans);
    }
}

// chokudai's Scanner
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 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: 13140
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
int h,w,k,x1,yy1,x2,y2;
int cx[]={0,0,1,-1};
int cy[]={1,-1,0,0};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>h>>w>>k>>x1>>yy1>>x2>>y2;
    char arr[h+1][w+1];
    int dist[h+1][w+1];
    for (int i=1;i<=h;i++){
        for (int j=1;j<=w;j++){
            cin>>arr[i][j];
        }
    }
    memset(dist,-1,sizeof(dist));
    dist[x1][yy1]=0;
    queue<pair<int,int> > q;
    q.push(mp(x1,yy1));
    while (!q.empty()){
        pair<int,int> cur=q.front();
        q.pop();
        for (int i=0;i<4;i++){
            int dx=cur.first;
            int dy=cur.second;
            for (int j=0;j<k;j++){
                dx+=cx[i];
                dy+=cy[i];
                if (dx<1 || dy<1 || dx>h || dy>w) break;
                if (arr[dx][dy]=='@') break;
                if (dist[dx][dy]!=-1 && dist[dx][dy]<dist[cur.first][cur.second]+1) break;
                if (dist[dx][dy]!=-1 && dist[dx][dy]<=dist[cur.first][cur.second]+1) continue;
                dist[dx][dy]=dist[cur.first][cur.second]+1;
                q.push(mp(dx,dy));
            }
        }
    }
    cout<<dist[x2][y2];
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 K, X;
  cin >> K >> X;
  if(X <= K * 500) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256