akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


int main(){
    string s;
    IN s;
    int n = 0;
    rep(i,0,sz(s)){
        if(s[i] == '+')n++;
        else n--;
    }
    P(n);
    
	return  0;
}

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

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector< vector<int> > d(n, vector<int>(n, 0));
	int a, b;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		d[a-1][b-1] = d[b-1][a-1] = 1;
	}
	vector<int> c;
	for (int i = 1; i < n; i++) {
		c.push_back(i);
	}
	long long int cc = 0;
	do {
		bool h = true;
		if (d[0][c[0]] == 1) {
			for (int i = 0; i < n-2; i++) {
				if (d[c[i]][c[i+1]] == 1) {
				} else {
					h = false;
				}
			}
		} else {
			h = false;
		}
		if (h) {
			cc++;
		}
	} while(next_permutation(c.begin(), c.end()));
	cout << cc << 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 koukansize = 0;
		int N = sc.nextInt();
		int [] a = new int [N];
		for(int i=0; i<N; i++){
			a[i] = sc.nextInt();
		}
		
		for(int i=0; i<N; i++){
			int minj = i;
			for(int j=i; j<N; j++){
				if(a[j] < a[minj]){
					minj = j;
				}
			}
			if(i!=minj){
				int ste = a[i];
				a[i] = a[minj];
				a[minj] = ste;
				koukansize++;
			}
		
		}
		for(int i=0; i<N-1; i++){
			System.out.print(a[i]+" ");
		}
		System.out.println(a[N-1]);
		System.out.println(koukansize);
		sc.close();
	}
		
}

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    vector<int> l(N+1,0);
    int a;
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        ++l[a];
    }
    sort(l.begin(),l.end());
    int ans = 0;
    for (int i = 1; i <= N-K; i++)
    {
        ans += l[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	string ans = "";
	ll tmp;
	//int n; cin >> n;
	string s; cin>>s;
	REP(i, s.size()){
		if(s[i] == '0') ans += "0";
		else if(s[i] == '1') ans += "1";
		else ans = ans.substr(0, ans.size()-1);
	}
	cout << ans << endl;
}

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

int main()
{
	int k,n;
	cin>>k>>n;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	int m=0;
	for (int i = 0; i < n-1; ++i)
	{
		m=max(m,a[i+1]-a[i]);
	}
	cout<<min(k-m,(a[n-1]-a[0]));
}

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

int main(){

int s1,s2,s3,s4,s5;

cin >> s1;

s2 = s1/3600;

s3 = s1%3600;

s4 = s3/60;

s5 = s3%60;

cout << s2 << ":" << s4 << ":" << s5 << '\n';

return 0;

}


Measured memory_bytes: 3116
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a,b)<<' '<<max(0,a+b-n)<<endl;
}


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

int main() {
  int x;
  cin >> x;
  int ans = 1;
  for (int i = 2;i<=int(sqrt(x));i++){
    int tmp = pow(i, 2);
    while (true){
      if (tmp*i>x){
        break;
      }
      tmp*=i;
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
s=list(input())
#i番目の人がリーダーとして
l=[0] #リーダーより左で向きを変える必要がある人数
for i in range(1,n):
  w=l[-1]
  if s[i-1]=='W':
    w+=1
  l.append(w)
r=[0] #リーダーより右で向きを変える必要がある人数
for i in reversed(range(n-1)):
  e=r[-1]
  if s[i+1]=='E':
    e+=1
  r.append(e)
r.reverse()
# print(l)
# print(r)
ans=n
for i in range(n):
  ans=min(r[i]+l[i],ans)
print(ans)

Measured memory_bytes: 20216
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  int n;cin>>n;
  ll l,a[n];
  cin>>l;
  for(int i=1;i<=n;i++)
    cin>>a[i];
  int f=0,tem;
  for(int i=1;i<=n-1;i++)
  {
    if((a[i]+a[i+1])>=l)
    { f=1;tem=i;break;}
  }
  if(f==0)
    cout<<"Impossible\n";
  else
  {
      cout<<"Possible\n";
      for(int i=1;i<tem;i++)
        cout<<i<<endl;
      for(int i=n-1;i>tem;i--)
        cout<<i<<endl;
      cout<<tem<<endl;
  }
}


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

int main() {
	bool cards[4][14];
	int n, rank;
	char suit;

	for (int s = 0; s < 4; s++)
		for (int r = 1; r <= 13; r++)
			cards[s][r] = 0;

	cin>>n;
	for (int i = 0; i < n; i++) {
		cin >> suit >> rank;
		if (suit == 'S')cards[0][rank] = 1;
		if (suit == 'H')cards[1][rank] = 1;
		if (suit == 'C')cards[2][rank] = 1;
		if (suit == 'D')cards[3][rank] = 1;

	}
	for (int s = 0; s < 4; s++) {
		for (int r = 1; r <= 13; r++) {
			if (cards[s][r])continue;
			if (s == 0)suit = 'S';
			if (s == 1)suit = 'H';
			if (s == 2)suit = 'C';
			if (s == 3)suit = 'D';
			cout << suit << " " << r << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3096
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}

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

int main(){
	
	int n,m;
	int t[100005] = {},p[105] = {},x[105] = {};
	cin >> n;
    ull ans = 0;
	rep(i,0,n){
        cin >> t[i];
        ans += t[i];
	}
	cin >> m;
	int ma = -inf;
	rep(i,0,m){
        cin >> p[i] >> x[i];

        cout << ans - t[p[i]-1] + x[i] << endl;
        //ma = max(ma, t[p[i]-1] - x[i]);
	}

	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
#include<cctype>
#include<vector>
#include<ctime>
#include<cmath>
#include<set>
#include<map>
#define LL long long
#define pii pair<int,int>
#define mk make_pair
#define fi first
#define se second
using namespace std;
LL n;
int main(){
	cin >> n;LL ans = n + 1321;
	for(LL i = 1;i * i <= n;++i){
		if(n % i == 0) ans = min(ans,i + n / i - 2);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  string S;
  cin >> S;

  bool ok = true;
  for(int i = 0; i < S.length(); i++) {
    if(i % 2 == 0) {
      if(S[i] == 'L') {
        ok = false;
      }
    } else {
      if (S[i] == 'R') {
        ok = false;
      }
    }
  }

  if(ok) {
    cout << "Yes";
  } else {
    cout << "No";
  }

  return 0;
}


Measured memory_bytes: 256
N=int(input())
A=[]
for i in range(N):
    E=list(input().split())
    D=[E[0],int(E[1])]
    D.append(i+1)
    A.append(D)
B=sorted(A, key=lambda x: x[1])
B.reverse()
C=sorted(B, key=lambda x: x[0])
for i in range(N):
    print(C[i][2])

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

#define llong long long 
#define len(x) ((int)x.size())
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#define rand __rand
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());  // or mt19937_64
template<class T = int> T rand(T range = numeric_limits<T>::max()) { return (T)(rng() % range); }

#define CONCAT_(x, y) x##y/*{{{*/
#define CONCAT(x, y) CONCAT_(x, y)
#ifdef LOCAL_DEBUG   
int __db_level = 0;
bool __db_same_line = false;
#define clog cerr << string(!__db_same_line ? __db_level * 2 : 0, ' ')
struct debug_block {
    function<void()> fn;
    void print_name() { __db_same_line = true; fn(); clog << endl; __db_same_line = false;  }
    debug_block(function<void()> fn_): fn(fn_) { clog << "{ "; print_name(); ++__db_level; }
    ~debug_block() { --__db_level; clog << "} "; print_name(); }
};
#define DB(args...) debug_block CONCAT(dbbl, __LINE__)([=]{ clog << args; })
#define deb(...)  if (1) { (clog << "[" #__VA_ARGS__ "] = [" << __VA_ARGS__) << "]"; if (!__db_same_line) clog << endl; }
#else
#define clog if (0) cerr
#define DB(...)
#define deb(...)
#endif
template<class T>
ostream& operator,(ostream& out, const T& thing) { return out << ", " << thing; }
template<class U, class V>
ostream& operator<<(ostream& out, const pair<U, V>& p) { return (out << "(" << p.first, p.second) << ")"; }
template<class A, class B>
ostream& operator<<(ostream& out, const tuple<A, B>& t) { return (out << "(" << get<0>(t), get<1>(t)) << ")"; }
template<class A, class B, class C>
ostream& operator<<(ostream& out, const tuple<A, B, C>& t) { return (out << "(" << get<0>(t), get<1>(t), get<2>(t)) << ")"; }
template<class T> ostream& operator<<(ostream& out, const vector<T>& container) { 
    out << "{";
    if (len(container)) out << container[0];
    rep1(i, len(container) - 1) out, container[i];
    return out << "}";
}
template<class x> vector<typename x::value_type> $v(const x& a) { return vector<typename x::value_type>(a.begin(), a.end()); }
#define ptrtype(x) typename iterator_traits<x>::value_type
template<class u> vector<ptrtype(u)> $v(u a, u b) { return vector<ptrtype(u)>(a, b); }/*}}}*/
// ACTUAL SOLUTION BELOW ////////////////////////////////////////////////////////////

const int maxn = 111;
int n;
llong a[maxn];
int main(void) {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    cin >> n;
    rep(i, n) cin >> a[i];
    llong ans = LLONG_MAX;
        
    for (llong m = -100; m <= 100; ++m) {
        llong cur_ans = 0;
        rep(i, n) cur_ans += (a[i] - m) * (a[i] - m);
        ans = min(ans, cur_ans);
    }
    cout << ans;


    return 0;
}

// Remember:
// - Multitest? REFRESHING the data!!!
// - Constrains for each set of data may differs. Should NOT USE the same max constant (maxn)
//   for all of them.
// vim: foldmethod=marker


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    int x;
    cin >> x;

    vector<int> p;
    p.push_back(1);
    for(int i = 2; i < 40; i++){
        int a = i*i;
        while(a<1500){
            p.push_back(a);
            a *= i;
        }
    }
    sort(p.begin(),p.end());
    for(int i = 0; i < p.size()-1; i++){
        if(p[i+1]>x){
            cout << p[i] << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math
sys.setrecursionlimit(10**8)
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(A: int, B: int, C: int, D: int):

    if math.ceil(C/B) <= math.ceil(A/D):
        yes()
    else:
        no()
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9208
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

int N;
int A_bottle[10];

stack<int> B_bottle,C_bottle;

bool dfs(int i){
	//A????????????i???????????°?????????????????????
	if (i==10){
		//?????????????????????????????????????????????
		return true;
	}
	bool flg=false;

	if (B_bottle.empty() || B_bottle.top()<A_bottle[i]){
		//B????????????????????????
		B_bottle.push(A_bottle[i]);
		flg=dfs(i+1);
		B_bottle.pop();
		if (flg) return true;
	}
	if (C_bottle.empty() || C_bottle.top()<A_bottle[i]){
		//C????????????????????????
		C_bottle.push(A_bottle[i]);
		flg=dfs(i+1);
		C_bottle.pop();
		if (flg) return true;
	}
	return false;
}

int main(){
	vector<bool> out;
	cin>>N;
	for (int i=0;i<N;i++){
		for (int j=0;j<10;j++){
			cin>>A_bottle[j];
		}
		out.push_back(dfs(0));
	}
	for (vector<bool>::iterator ite=out.begin();ite!=out.end();ite++){
		cout<<(*ite ? "YES" : "NO")<<endl;
	}
	return 0;
}

Measured memory_bytes: 1192
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define umap unordered_map

const int MOD = 1000000007;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int rows, cols; cin >> rows >> cols;
	vvi G = vvi(rows, vi(cols, 0));
	rep(r, rows){
		rep(c, cols){
			char block; cin >> block;
			if (block == '.')
				G[r][c] = 1;
		}
	}
	vvll dp = vvll(rows, vll(cols, 0));
	dp[0][0] = 1;
	rep(r, rows){
		rep(c, cols){
			if (G[r][c]){
				if (r > 0){
					dp[r][c] += dp[r-1][c];
					dp[r][c] %= MOD;
				}
				if (c > 0){
					dp[r][c] += dp[r][c-1];
					dp[r][c] %= MOD;
				}
			}
		}
	}
	cout << dp[rows-1][cols-1];
}

Measured memory_bytes: 15032
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    let handle = std::io::stdin();
    let n: isize = {
        handle.read_line(&mut buf).unwrap();
        let tmp = buf.trim().parse().unwrap();
        buf.clear();
        tmp
    };
    let hs: Vec<isize> = {
        handle.read_line(&mut buf).unwrap();
        let tmp = buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
        buf.clear();
        tmp
    };
    let mut memo: Vec<isize> = vec![-1; (n+1) as usize];
    dp(n, n, &hs, &mut memo);
    println!("{}", memo[n as usize])
}

fn dp(i: isize, n: isize, hs: &Vec<isize>, memo: &mut Vec<isize>) -> isize {
    if i <= 1 { 
        memo[i as usize] = 0;
        return 0;
    }
    if i == 2 {
        let h_1 = dp(i-1, n, hs, memo) + (hs[(i-1) as usize] - hs[(i-2) as usize]).abs();
        memo[i as usize] = h_1;
        return h_1;
    }
    if memo[i as usize] == -1 {
        let h_2 = dp(i-2, n, hs, memo) + (hs[(i-1) as usize] - hs[(i-3) as usize]).abs(); 
        let h_1 = dp(i-1, n, hs, memo) + (hs[(i-1) as usize] - hs[(i-2) as usize]).abs();
        memo[i as usize] = min(h_1, h_2);
    }
    memo[i as usize]
}


Measured memory_bytes: 9468
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; long x; readV(n, x);

  auto h = new long[](n), p = new long[](n);
  h[0] = 1; p[0] = 1;
  foreach (i; 0..n) {
    h[i+1] = h[i]*2+3;
    p[i+1] = p[i]*2+1;
  }

  long pat(int i, long x)
  {
    if (i == 0) return 1;

    if (x == 1) return 0;
    else if (x <= h[i-1]+1) return pat(i-1, x-1);
    else if (x == h[i-1]+2) return p[i-1]+1;
    else if (x <= h[i-1]*2+2) return p[i-1]+1+pat(i-1, x-h[i-1]-2);
    else return p[i-1]*2+1;
  }

  writeln(pat(n, x));
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a[3];
    int c5=0,c7=0;
    cin >> a[0]>>a[1]>>a[2];
    for(int i = 0; i < 3; i++){
        if(a[i] == 5)   c5+=1;
        if(a[i] == 7)   c7+=1;
    }
    if(c5==2 && c7 == 1){
        cout << "YES\n";
    }else{
        cout << "NO\n";
    }

   return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class MODnCk {
    private static final int mod = 1000000007;

    private static int[] factorialCache = new int[16000];
    private static int factorialCacheIdx = 0;

    static{
        factorialCache[0] = 1;
    }
    
    static int nCk(int n, int k){
        return div((div(factorial(n), factorial(k))), factorial(n-k));
    }

    private static int factorial(int n){
        if(factorialCacheIdx < n){
            setFactorialCache(factorialCacheIdx+1, n);
        }

        return factorialCache[n];
    }

    private static void setFactorialCache(int s, int e){
        for(int i=s; i<=e; i++){
            factorialCache[i] = mul(factorialCache[i-1], i);
        }
        factorialCacheIdx = e;
    }

    private static int div(int a, int b){
        return mul(a, modinv(b));
    }

    static int mul(int a, int b){
        long x = (long)a * (long)b;
        return (int)(x % mod);
    }

    private static int modinv(int a) {
        int b = mod;
        int u = 1;
        int v = 0;
        while (b != 0) {
            int t = a / b;
            a -= t * b;
            int temp = a; a = b; b = temp; // swap(a, b)
            u -= t * v;
            temp = u; u = v; v = temp; // swap(u, v)
        }
        u %= mod;
        if (u < 0) u += mod;
        return u;
    }
}

public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
		int n = stdIn.nextInt();
		int k = stdIn.nextInt();

		for(int i=1; i<=k; i++){
			if(n-k+1 < i){
				System.out.println(0);
			}else{
				System.out.println(MODnCk.mul(MODnCk.nCk(k-1, i-1), MODnCk.nCk(n-k+1, i)));
			}
		}
	}
}


Measured memory_bytes: 36432
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define ull unsigned long long
#define ff first
#define ss second
#define Mod 1000000007
//#define Mod 998244353
#define nl "\n" 
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define f(i, a, b) for (ll i = a; i < b; ++i)
#define rf(i, a, b) for (ll i = a; i >= b; --i)
#define vll vector<ll>
#define pll pair<ll, ll>
#define mem(a, b) memset(a, b, sizeof(a))
#define printv(v) for(int i=0;i<v.size();i++) { cout<<v[i]<<" "; } cout<<nl;
using namespace std;
inline bool kthbit(ll n, int k) { return (n >> k) & 1; }
ll pw(ll a, ll b){ll c = 1, m = a;while (b){if (b & 1) c = (c * m);m = (m * m);b /= 2;}return c;}
//------------------------------------------------------------------------------------------------

int main()
{
    fast;
    ll T=1;
    //cin>>T; //comment for single test

    while(T--)
    {
        //code...
        ll N,K;
        cin>>N>>K;
        vll A;
        ll mx=-10e17;
        f(i,0,N)
        {
            ll x;
            cin>>x;
            A.pb(x);
            mx=max(mx,x);
        }
        ll low=1,high=mx,ans=mx;
        while(low<=high)
        {
            ll mid=low+(high-low)/2;
            ll cnt=0;
            f(i,0,N)
            {
                if(A[i]>mid)
                {
                    if(A[i]%mid==0)
                        cnt+=A[i]/mid-1;
                    else
                        cnt+=A[i]/mid;
                }
            }
            if(cnt<=K)
            {
                ans=min(ans,mid);
                high=mid-1;
            }
            else
            {
                low=mid+1;
            }
        }
        cout<<ans<<nl;
    }
    return 0;  
}

Measured memory_bytes: 5328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<string>s(N);
  vector<int>t(N);
  string X;
  int M;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> s.at(i) >> t.at(i);
  }
  cin >> X;
  
  for (int i = 0; i < N; i++) {
    if (s.at(i) == X){
      M = i;
    }
  }
  
  for (int i = 0; i < N; i++) {
    if (i > M){
      sum += t.at(i);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vi2 = vector<vector<ll>>;
const int INF = 1e9+4;
#define REP(i,n) for(int i = 0; i < (n); i++)
#define REPS(i,n) for(int i = 1; i <= (n); i++)
template<typename T> bool chmin(T& a,const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> bool chmax(T& a,const T& b){if(a<b){a=b;return true;}return false;}

int main(){
    int n,m;
    cin >> n >> m;
    vi v(n);
    vi w(n);
    vi2 dp(n+1,vi(m+1,0));
    REP(i,n){
        cin >> w[i] >> v[i];
    }
    REPS(i,n){
        REPS(j,m){
            if (w[i-1]<=j)
            {
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
            }else
            {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout << dp[n][m] << endl;
}

Measured memory_bytes: 83196
import java.util.Scanner

object Main {
  val sc = new Scanner(System.in)
  def main(args: Array[String]): Unit = {
    val n  = sc.nextInt
    val l  = sc.nextInt
    val sl = List.fill(n)(sc.next)

    val res = sl.sorted.foldLeft("")(_ + _)

    println(res)
  }
}


Measured memory_bytes: 29944
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
vector<int> adj[200005];
int visited[200005]={0};
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    queue<int>q;
    for(int i=0;i<adj[1].size();i++)
    {
        q.push(adj[1][i]);
    }
    while(!q.empty())
    {
        int d=q.front();
        q.pop();
        for(int i=0;i<adj[d].size();i++)
            visited[adj[d][i]]=1;
    }
    if(visited[n]==1)
    {
        cout<<"POSSIBLE";
    }
    else
        cout<<"IMPOSSIBLE";
    return 0;
}


Measured memory_bytes: 12400
import java.util.Arrays;

public class Main {

  private static void solve() {
    int n = ni();
    int[] l = na(n);
    Arrays.sort(l);


    int ret = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        for (int k = j + 1; k < n; k++) {
          if (l[i] + l[j] > l[k])
            ret++;
          else
            break;
        }
      }
    }
    System.out.println(ret);

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



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

long long n,d,t,ans,answ=0,tmp;
char str1[15],ch=0;

int main(void) {
	long long a;
	cin>>str1;
	n = strlen(str1);
	t = pow(10,n);
	sscanf(str1,"%lld",&d);
	char str[] = "0123456789";
	do {
		swap(str[n],ch);
		sscanf(str,"%lld",&a);
		if((tmp=min(abs(a-d),t-abs(a-d)) ) > answ)
			answ = tmp,ans=a;
		swap(str[n],ch);
		//cout<<a<<' '<<ch<<endl;
		//cout<<str<<endl<<endl;
	} while(next_permutation(str,str+10));
	if(a == 0) 
		for(int i=1;i<=n;i++)
			putchar('0');
	else {
		a = log(ans)/log(10);
		a++;
		for(int i=a;i<n;i++)
			putchar('0');
		cout<<ans;
	}
	cout<<endl;
	return 0;
}

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

int main() {
    long long N,K;
    cin >> N >> K;

    long long A[N+1];

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

    long long past=0;
    long long current=0;

    for (int i=1 ; i<=K ; i++) {
        past += A[i];
    }

    for (int i=K+1 ; i<=N; i++) {
        current = past - A[i-K] + A[i];
        if (current > past) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        past = current;
    }

    return 0;
}


Measured memory_bytes: 5180
n,k=[int(i) for i in raw_input().split()]
p=[int(i)-1 for i in raw_input().split()]
c=[int(i) for i in raw_input().split()]
maxx=-10**18
for i in range(n):
  ct=0;j=0;pos=i
  v=[0]*n
  arr=[]
  while j<k:
    if(v[pos]==1):
  	    break
    v[pos]=1
    ct+=c[pos]
    pos=p[pos]
    arr.append(ct)
    j+=1
  val=0
  if(ct>0):
  	val=ct*((k-j)/j)
  else:
  	val=0
  k1=k
  k1%=j
  k1+=j
  for i1 in range(len(arr)):
  	if(k1-i1>j):
  	    maxx=max(maxx,val+arr[i1],val+ct+arr[i1])
  	else:
  	    maxx=max(maxx,val+arr[i1])
print maxx


Measured memory_bytes: 110136
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  cout << (d <= t * s ? "Yes" : "No") << endl;
}

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

using namespace std;

const int MAXN = 1e5 + 5;

int n, m, a, b, sol;
vector<int> veza[MAXN];
int DP[MAXN];
bool bio[MAXN];

void rek(int cvor)
{
	bio[cvor] = true;
	int ret = 0;
	for(int i = 0; i < veza[cvor].size(); i++)
	{
		if(!bio[veza[cvor][i]])
			rek(veza[cvor][i]);
		ret = max(ret, DP[veza[cvor][i]]);
	}
	DP[cvor] = ret + 1;
}

int main()
{
	memset(bio, false, sizeof(bio));
	cin >> n >> m;
	for(int i = 0; i < m; i++)
	{
		cin >> a >> b;
		veza[a].push_back(b);
	}
	for(int i = 1; i <= n; i++)
	{
		if(!bio[i])
			rek(i);
		sol = max(sol, DP[i]);
		//cout << DP[i] << " ";
	}
	cout << sol - 1;
	return 0;
}


Measured memory_bytes: 8192
#include <cstdio>
#include <cstring>

char s[200000 + 10];

int main()
{
    scanf("%s", s);
    int st, ed, n = strlen(s);
    for(st = 0; ; st++) if(s[st] == 'A') break;
    for(ed = n - 1; ; ed--) if(s[ed] == 'Z') break;
    printf("%d\n", ed - st + 1);
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            string s = ReadString();
            bool ans = s.GroupBy(c => c).Count() == 3;
            Console.WriteLine(ans ? "Yes" : "No");
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

Measured memory_bytes: 13396
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = lc()
for i in range(8):
    cur = int(n[0])
    ans = n[0]
    for j in range(2,-1,-1):

        if (i>>j)&1 == 1:
            cur += int(n[3-j])
            ans = ans + "+" + n[3-j]
        else:
            cur -= int(n[3-j])
            ans = ans + "-" + n[3-j]
        
        
    if cur == 7:
        ans = ans + "=" + "7"
        break

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;

struct G{
	string st;
	int n;
};
int main(){
	int n,m;
	struct G K[1001];
	string str;

	
	
	
	while(1){
cin>>n>>m;if(n==0&&m==0)break;
	for(int i=0;i<n;i++)
	{		cin>>K[i].st;cin>>K[i].n;
	
	}
	string y;int s=0;
	for(int i=0;i<m;i++)
	{	cin>>y;
	for(int ii=0;ii<n;ii++){bool f=true;//cout<<"&";
	for(int j=0;j<8;j++){//cout<<K[ii].st[j]<<"!"<<y[j]<<endl;
		if(K[ii].st[j]!='*'&&K[ii].st[j]!=y[j]){//cout<<"##"<<endl;
				f=false;break;}
	}
		if(f==true){s+=K[ii].n;break;}
	}
}
	cout<<s<<endl;
}
	return 0;
}

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

int main(){
  int a, b, c, x;
  scanf("%d %d %d", &a, &b, &c);
  bool flag = false;

  for(x = 1; x <= 100; x++){
    if(a*x%b == c){
      flag = true;
      break;
    }
  }

  if(flag){
    printf("%s\n", "YES");
  } else {
    printf("%s\n", "NO");
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


using Graph = vector<vector<Pll>>;

int main() {
  ll N; cin >> N;

  Graph G(N);
  for (int i = 0; i < N-1; i++) {
    ll u, v, w;
    cin >> u >> v >> w;
    u--; v--;
    G[u].push_back(Pll(v, w));
    G[v].push_back(Pll(u, w));
  }

  Vll dist(N, INFll);
  queue<ll> que;

  dist[0] = 0;
  que.push(0);
  while (!que.empty()) {
    ll u = que.front(); que.pop();
    for (auto e : G[u]) {
      ll v, w;
      tie(v, w) = e;
      if (chmin(dist[v], dist[u] + w)) {
        que.push(v);
      }
    }
  }
  rep(i, N) {
    cout << (dist[i]%2) << endl;
  }
  return 0;
}


Measured memory_bytes: 8704
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int R = Integer.parseInt(sc.next());
		int G = Integer.parseInt(sc.next());
		sc.close();

		int ans = G * 2 - R;
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N, K; std::cin >> N >> K;
  --N; --K;
  std::cout << (N + K - 1) / K << std::endl;
}


Measured memory_bytes: 256
//
// Created by sanyinchen on 17/4/25.
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_A
//
#include <iostream>
#include <cstdio>

using namespace std;

void bubbleSort(int *a, int n) {
    int step = 0;
    for (int i = 0; i < n; i++) {
        for (int j = n - 1; j >= i + 1; j--) {
            if (a[j] < a[j - 1]) {
                swap(a[j], a[j - 1]);
                step++;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if (i != 0)cout << " ";
        cout << a[i];
    }
    cout << endl;
    cout << step << endl;
}


int main() {
    //freopen("../files/in.txt", "r", stdin);
    int a[101], n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    bubbleSort(a, n);
    return 0;
}

Measured memory_bytes: 3084
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    int dp[n];
    dp[0] = 0;
    for(int i=1;i<n;i++)
    {        
        dp[i] = INT_MAX;
        for (int j=max(0,i-k) ; j<i;j++)
        {
            dp[i] = min(dp[i] , dp[j]+abs(arr[i]-arr[j]));
        }
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1024
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

//# include <ext/pb_ds/assoc_container.hpp>
//# include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red
 
string s[5];
int p[5];

bool can (char a, char b) {
	if (a == '?') return 1;
	if (b == '?') return 1;
	return (a == b);
}

bool St[4][4][4004];

inline int calc () {
	for (int i = 0; i < 2; ++i) {
		for (int j = i+1; j < 3; ++j) {
			for (int k = 0; k <= 2100; ++k)
				St[i][j][k] = 0;
		}
	}
	
	for (int i = 0; i < 3; i ++) {
		for (int j = i + 1; j < 3; ++j) {
			for (int st = 0; st < sz(s[p[i]]); ++st) {
				bool bad = 0;
				for (int k = 0; k < sz(s[p[i]]) - st && k < sz(s[p[j]]); ++k) if (!can(s[p[i]][st + k], s[p[j]][k])) {
					bad = 1;
					break;
				}

				St[i][j][st] = bad;
			}
		}
	}
	int ans = 6699;


	for (int s1 = 0; s1 <= sz(s[p[0]]); ++s1) if (!St[0][1][s1]) {
		for (int s2 = 0; s2 <= sz(s[p[1]]) || s2 <= sz(s[p[0]]); ++s2) if (!St[1][2][s2] && !St[0][2][s1 + s2]) {
			
			int cur = sz(s[p[0]]);
			cur = max(cur, s1 + sz(s[p[1]]));
			cur = max(cur, s1 + s2 + sz(s[p[2]]));

			ans = min(ans, cur);
		}
	}

	return ans;
}

int main () {
	SpeedForce;
	int res = 0;
	int len = 0;
	for (int i = 0; i < 3; ++i) {
		cin >> s[i];
		p[i] = i;
		len = max(len, sz(s[i]));
		res += sz(s[i]);
	}

	do {
		int x = calc();
		res = min(res, x);
	} while(next_permutation(p, p + 3));
	
	cout << max(len, res) << '\n';
	return Accepted;
}

// B...a


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int x, n; cin >> x >> n;
    set<int> S;
    for (int x = -200; x <= 200; x++) {
        S.insert(x);
    }
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        S.erase(x);
    }
    int mn = 10010, res = 10010;
    for (auto y : S) {
        if (abs(x - y) == mn && y < res) {
            res = y;
        }
        if (abs(x - y) < mn) {
            mn = abs(x - y);
            res = y;
        }
    }
    cout << res;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
    using namespace std;
    void fast()
    {
        ios::sync_with_stdio(0);
        cin.tie(0);
    }
    long long n,a,b;
    int main() 
    {   
        fast();
        cin>>n>>a>>b;
        cout<<a*(n/(a+b))+min(n%(a+b),a);
        return 0;
    }

Measured memory_bytes: 256
sx,sy,tx,ty = map(int,input().split())
ans = ""
y = ty-sy
x = tx-sx
ans += "U"*y+"R"*x+"D"*y+"L"*(x+1)+"U"*(y+1)+"R"*(x+1)+"DR"+"D"*(y+1)+"L"*(x+1)+"U"
print(ans)

Measured memory_bytes: 9188
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INI(n) scanf("%d",&n)
#define INL(n) scanf("%lld",&n)
#define INF 10000000000
#define mod 1000000007
#define X 100000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void nCrReady(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (ll i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(ll n,ll k){return fac[n]*(finv[k]*finv[n-k]%mod)%mod;}

int main(void){
  char s[100001],s1[200001],s2[100001],c[2];
  scanf("%s",s);
  int n,flg=0,cnt1=0,cnt2=0;
  INI(n);
  FOR(n){
    int q;
    INI(q);
    if(q==1){
      flg++;
      flg%=2;
    }else{
      int f;
      INI(f);
      f--;
      scanf("%s",c);
      if(f==flg){
        s1[cnt1++]=c[0];
      }else{
        s2[cnt2++]=c[0];
      }
    }
  }
  char t[2];
  if(flg){
    int l=strlen(s2);
    FOR(l/2){
      t[0]=s2[i];
      s2[i]=s2[l-i-1];
      s2[l-i-1]=t[0];
    }
    l=strlen(s);
    FOR(l/2){
      t[0]=s[i];
      s[i]=s[l-i-1];
      s[l-i-1]=t[0];
    }
    printf("%s%s%s\n",s2,s,s1);
  }else{
    int l=strlen(s1);
    FOR(l/2){
      t[0]=s1[i];
      s1[i]=s1[l-i-1];
      s1[l-i-1]=t[0];
    }
    printf("%s%s%s\n",s1,s,s2);
  }
  return 0;
}


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

int a, b, x;
string res;

int main(){
  cin >> a >> b >> x;
  if(x < a){
    res = "NO";
  }else if(x >= a && x <= a + b){
    res = "YES";
  }else{
    res = "NO";
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;

	int ret = 0;
	ret += min(N, K) * X;
	if(N > K)
		ret += (N-K) * Y;

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#define maxn 100
#define INF 1<<30
using namespace std;
int n,m;
int a[maxn],b[maxn],c[maxn],d[maxn];
int abs(int x) {
	if (x<0)
		return -x;
	return x;
}
int dis(int x1,int y1,int x2,int y2) {
	return abs(x1-x2)+abs(y1-y2);
}
int main() {
	
	scanf("%d %d",&n,&m);
	for (int i=1;i<=n;i++)
		scanf("%d %d",&a[i],&b[i]);
	for (int i=1;i<=m;i++)
		scanf("%d %d",&c[i],&d[i]);
	for (int i=1;i<=n;i++) {
		int mindis=INF,k;
		for (int j=1;j<=m;j++) {
			int t=dis(a[i],b[i],c[j],d[j]);
			if (mindis>t) {
				mindis=t;
				k=j;
			}
		}
		printf("%d\n",k);
	}
	return 0;
}

Measured memory_bytes: 128