akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int n,h;
    cin >> n >> h;
    vector<pair<int,int>> sword,pitch;
    for (int i=0; i<n; i++){
        int x,y;
        cin >> x >> y;
        sword.push_back(make_pair(x,y));
        pitch.push_back(make_pair(y,x));

    }
    sort(sword.begin(),sword.end());
    sort(pitch.begin(),pitch.end());
    reverse(sword.begin(),sword.end());
    reverse(pitch.begin(),pitch.end());
    int attack=0;
    for (int itr=0; itr<n; itr++){
        if (pitch[itr].first>=sword[0].first){
            h-=pitch[itr].first;
            attack++;
            if (h<=0){
                cout << attack<<endl;
                exit(0);
            }
        }
    }
    attack+=(h+sword[0].first-1)/(sword[0].first);
    cout << attack<<endl;
}

Measured memory_bytes: 2036
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
class BIT{
	public:
	//[1,i]
	int n;
	vi bit;
//	int bit[MAZ_N+1];
	BIT(int size){
		n=size;
		bit=vi(n+1);
	}
	int query(int i){//sum
		int s=0;
		while(i>0){
			s+=bit[i];
			i-=i&-i;
		}
		return s;
	}
	void add(int i,int x){
		while(i<=n){
			bit[i]+=x;
			i+=i&-i;
		}
	}
};
int main(){
	int n,m;
	cin>>n>>m;
	BIT bit(n);
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		if(a)cout<<bit.query(c)-bit.query(b-1)<<endl;
		else bit.add(b,c);
	}
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,brk;
  cin>>N;
  vector<int> b(N),ans(N);
  for(auto&& c:b)cin>>c;
  for(int i=N-1;i>=0;--i){
    brk=0;
    for(int j=i;j>=0;--j){
      if(b[j]==j+1){
        ans[i]=j+1;
        b.erase(b.begin()+j);
        brk=1;
        break;
      }
    }
    if(brk)continue;
    cout<<-1;
    return 0;
  }
  for(auto&& c:ans)cout<<c<<"\n";
  return 0;
}

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

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

int main() {
	ll N;
	cin >> N;
	ll A, high = 0, ans = 0;

	REP (i, N) {
		cin >> A;
		high = max(A, high);
		ans += high - A;
	}

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

Measured memory_bytes: 3568
import java.util.Scanner;
 
public class Main {
    long n;
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }
 
    void solve(Scanner sc) {
        n = sc.nextLong();
        System.out.println(count(0));
    }
 
    long count(long a) {
        if (a > n) {
            return 0;
        }
 
        String as = String.valueOf(a);
        if (as.contains("7") && as.contains("5") && as.contains("3")) {
            return 1 + count(a * 10 + 7) + count(a * 10 + 5) + count(a * 10 + 3);
        }
 
        return count(a * 10 + 7) + count(a * 10 + 5) + count(a * 10 + 3);
    }
}

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

#define range 524289
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<ll, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;



int main(int argc, char const *argv[])
{
	// #ifndef ONLINE_JUDGE
 //    	freopen("input.txt", "r", stdin);
 //    	freopen("output.txt", "w", stdout);
 //    	freopen("error.txt", "w", stderr);
	// #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin>>n>>m;
    int a =  n-m;
    int b =  n+m;
    int c =  n*m;
    cout<<max(a, max(b,c))<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define whatis(x) cout << #x << " is " << x << endl;
#define MOD 1000000007
#define endl "\n"
#define ll long long
#define ii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MAX 100001
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int i, t = 1;
    //cin>>t;
    while (t--)
    {
        int n, i, j, k;
        cin >> n >> k;
        int *arr = new int[n];
        int *dp = new int[n];
        for (i = 0; i < n; i++)
        {
            cin >> arr[i];
        }
        fill(dp, dp + n, 0);
        dp[n - 1] = 0;
        for (i = n - 2; i >= 0; i--)
        {
            int minval = INT_MAX;
            for (j = i + 1; j < n && j <= i + k; j++)
            {
                minval = min(abs(arr[i] - arr[j]) + dp[j], minval);
            }
            dp[i] = minval;
        }
        cout << dp[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;
    
    auto arr = readln.chomp.split.map!(to!int).array;
    
    auto inv = arr.map!(x => 1 / x.to!double);
    
    auto s = inv.sum;
    
    auto ans = 1 / s;
    
    writefln("%.12f", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a[] = {1,3,5,7,8,10,12};
    int b[] = {4,6,9,11};
    int c[] = {2};

    int x, y;
    cin >> x >> y;
    for(int z : a){
        if(z == x) x = 1;
        if(z == y) y = 1;
    }
    for(int z : b){
        if(z == x) x = 4;
        if(z == y) y = 4;
    }
    for(int z : c){
        if(z == x) x = 2;
        if(z == y) y = 2;
    }
    if(x == y) cout << "Yes" << endl;
    else cout<< "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
long long INF = (1LL<<62);
typedef long long LL;
char alphabet[] = "abcdefghijklmnopqrstuvwxyz";

int maxd(string s, char c){
	int ret = 0, d = 0, found = 0;
	for(int i=0; i<s.size(); i++){
		if(s[i] != c) d++;
		else{
			found = 1;
			if(ret < d) ret = d;
			d = 0;
		}
	}
	if(found == 0) return -1;
	if(ret < d) ret = d;
	return ret;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string s; cin >> s;
	int ans = 101;
	for(int i=0; i<26; i++){
		char c = alphabet[i];
		int d = maxd(s, c);
		if(d >= 0 && ans > d){
			ans = d;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int k, a, b;
    string s;
    cin >> k >> a >> b;
    
    for(int i = 0; i < 1000; ++i)
    {
        if( k * i >= a && k * i <= b)
        {
            s = "OK";
            break;
        }
        else
        {
            s ="NG";
        }
    }
    
    cout << s << endl;
}


Measured memory_bytes: 3604
import fractions
import functools

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return functools.reduce(lcm_base, numbers, 1)


n, m = map(int, input().split())
aset = set(map(int, input().split()))
aset = list(x // 2 for x in aset)

llcm = lcm(*aset)

for a in aset:
    if (llcm // a) % 2 == 0:
        ans = 0
        break
else:
    ans = (m // llcm + 1) // 2

print(ans)

Measured memory_bytes: 13352
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

void getDivisor(ll n, vector<ll>& result)
{
	for (auto i = 1ll; i * i <= n; ++i)
	{
		if (n % i == 0)
		{
			result.push_back(i);
			if (i != n / i)
			{
				result.push_back(n / i);
			}
		}
	}
}

int main()
{
	ll N, M;
	cin >> N >> M;
	vector<ll> div;
	getDivisor(M, div);
	auto ans = 1ll;
	for (auto i = 0; i < (int)div.size(); ++i)
	{
		if (M / div[i] >= N)
		{
			ans = max(ans, div[i]);
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	int ans=0;
	for (int i = 0; i < 3; ++i)
	{
		if (s[i]=='1')
		{
			++ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
const int MAXN    = 2e5+9;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	int k;
	cin >> k;
	ll ans = 0;
	for(int i = 1; i <= k; i++) {
		for(int j = 1; j <= k; j++) {
			int w = __gcd(i, j);
			if(w==1)
				ans+=k;
			else
				for(int z = 1; z <= k; z++)
					ans+=__gcd(w, z);

		}
	}
	cout << ans;

	return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    vector<int> data(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> data[i];
        sum += data[i];
    }

    int m = INF, ss = 0;

    rep(i, n) {
        m = min(m, abs((sum - ss) - ss));
        ss += data[i];
    }

    cout << m << endl;
    

    return 0;
}







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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

void solve() {
  int x; cin >> x;

  int b;
  for(int i=1; i<1e9; ++i) {
    b=i*(i+1)/2;
    if(x<=b) {
      drop(i);
    }
  }

  return;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
int fibonacci(int);
int F[45];
int memo[45];
int main(void){
    int n,i;
    for(i = 0; i < 45; i++){
        memo[i] = 0;
    }
    
    scanf("%d",&n);
    printf("%d\n",fibonacci(n));
    return 0;
}
int fibonacci(int n){
    if(n == 0 || n == 1){
        F[n] = 1;
        memo[n] = 1;
        return F[n];
    }
    if(memo[n] == 1){
        return F[n];
    }
    memo[n] = 1;
    return F[n] = fibonacci(n - 2) + fibonacci(n - 1);
}

Measured memory_bytes: 596
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::cin >> N;
  std::vector< ll > va(N+2, 0LL);
  va[0]   = 0;
  va[N+1] = 0;
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i+1];
  }

  std::vector< ll > vsum(N+2, 0LL);
  vsum[0] = 0;
  for (ll i = 1; i <= N+1; i++) {
    vsum[i] = std::abs(va[i] - va[i-1]) + vsum[i-1];
  }

  for (ll i = 1; i <= N; i++) {
    ll ans = vsum[N+1] - std::abs(va[i] - va[i-1]) - std::abs(va[i+1] - va[i]) + std::abs(va[i+1] - va[i-1]);
    print(ans);
  }
  return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define MAX 2002

ll power(ll a,ll b){
	if(b==0) return 1;
	ll temp = power(a,b/2)%Mod;
	if(b%2==0){
		return (temp*temp)%Mod;
	}else{
		return (a*((temp*temp)%Mod))%Mod;
	}
}


ll fact[MAX];

ll nck(ll n,ll k){
	if(k>n) return 0;
	ll num = fact[n];
	ll den = (fact[k]*fact[n-k])%Mod;
	den = power(den,Mod-2);
	return (num*den)%Mod;
}

ll f(ll n,ll m){

	// cout<<m-1<<" % "<<n-1<<endl;
	// cout<<nck(m-1,n-1)<<endl;

	return nck(m-1,n-1);
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	fact[0]=1;
	For(i,1,MAX) fact[i]=(i*fact[i-1])%Mod;
	
	ll n,k;cin>>n>>k;
	ll B = k;
	ll R = n-k;
	Foe(i,1,k){
		ll ways1 = f(i,B);
		ll ways2 = f((i-1)+2,R+2);

		cout<<(ways1*ways2)%Mod<<endl;
	}











	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <functional>
#include <queue>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
class Edge
{
	public:
	int cost;
	int from;
	int to;

	Edge(int n,int c)
	{
		to=n;
		cost=c;
	}

	Edge(int f,int t,int c)
	{
		from=f;
		to=t;
		cost=c;
	}
};

vector<Edge> g[100000];
ll dp[100000][2];//ノードiが0...白 1...黒のときのiを親とする木の塗り分け方

//ノードnow、親がparのときにdp[now]を埋める
//now=0のときはpar=-1
void dfs(int now,int par)
{
	//子の探索
	bool f=false;
	for(int i=0;i<g[now].size();i++)
	{
		Edge e=g[now][i];
		if(e.to!=par)
		{
			f=true;
			dfs(e.to,now);
		}
	}
	//子がなければ初期値設定
	if(!f)
	{
		dp[now][0]=1;
		dp[now][1]=1;
	}else{
		//子が入れば子をもとに自分の通り数を求める
		dp[now][0]=1;
		dp[now][1]=1;
		for(int i=0;i<g[now].size();i++)
		{
			Edge e=g[now][i];
			if(e.to==par)
				continue;
			dp[now][1]*=dp[e.to][0];
			dp[now][1]%=MOD;//黒のときは子に白しか来ない
			dp[now][0]*=(dp[e.to][0]+dp[e.to][1]);
			dp[now][0]%=MOD;//白のときは子に白も黒も来る
		}
	}
	return;
}

int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		x--;y--;
		g[x].push_back(Edge(y,1));
		g[y].push_back(Edge(x,1));
	}
	fill(dp[0],dp[100000],0);
	dfs(0,-1);//0を根としてdfs
	ll ans=dp[0][0]+dp[0][1];
	ans%=MOD;
	if(ans<0)
		ans+=MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15616
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <iomanip>
using namespace std;
long long n,a,b,c,d,i,j;
int main()
{
	cin>>n>>a>>b>>c>>d;
	long long target=b-a;
	d-=c;
	n-=1;
	for (i=0;i<=n;i++){
		j=n-i;
		long long cur=target;
		cur-=i*c;
		cur+=j*c;
		long long low=-d*j,high=d*i;
		if(cur>=low&&cur<=high){
			cout<<"YES";
			return 0;
		}
	} 
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
  
using namespace std;
  
int w, h;
int mindepth = 0;
int d[4][2] = { { 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 } }; 
 
bool isValid( int x, int y ) {
    return !( x < 0 || y < 0 || x >= w || y >= h ); 
}
 
void dfs_search( vector< vector< int > > map, int x, int y, int depth ) {
    if( depth >= 10 || depth >= mindepth ) return;
    for( int i = 0; i < 4; i++ ) {
        vector< vector< int > > currentmap = map;
        int cx = x, cy = y;
        if( !isValid( cx + d[i][1], cy + d[i][0] ) || currentmap[cy + d[i][0]][cx + d[i][1]] == 1 ) continue;
        for( ;isValid( cx, cy ); cx += d[i][1], cy += d[i][0] ) {
            if( currentmap[cy][cx] == 1 ) {
                currentmap[cy][cx] = 0;
                dfs_search( currentmap, cx - d[i][1], cy -  d[i][0], depth + 1 );
                break;
            }
            if( currentmap[cy][cx] == 3 ) {
                mindepth = depth + 1;
                break;
            }
        }
    }
}
 
int main(void){
  
    while( true ) {
        cin >> w >> h;
        if( !( w | h ) ) break;
        mindepth = 1 << 30;
        vector< vector< int > > startmap( h, vector< int >( w, 0 ) );
        int sx, sy;
        for( int i = 0; i < h; i++ ) {
            for( int j = 0; j < w; j++ ) {
                cin >> startmap[i][j];
                if( startmap[i][j] == 2 ){
                    sx = j; sy = i;
                }
            }
        }
        dfs_search( startmap, sx, sy, 0 );
        if( mindepth == ( 1 << 30 ) ) mindepth = -1;
        cout << mindepth << endl;
    }
    return 0;
}

Measured memory_bytes: 1336
#include<iostream>
#include<queue>
#include<stack>
using namespace std;

int main(){
    long long int in;
    int n, m;
    priority_queue<long long int, vector<long long int>, greater<long long int>> Q;
    cin>>n>>m;
    for(int i=0; i<n; i++){
        cin>>in;
        Q.push(in);
    }

    int b,c;
    stack<pair<long long int, long long int > > pros;
    for(int i=0; i<m; i++){
        cin>>b>>c;
        pros.emplace(b,c);
    }
    while(!pros.empty()){
        auto elem=pros.top();pros.pop();
        long long int qt=elem.first;
        long long int num=elem.second;
        for(int j=0; j<qt; j++){
                auto e=Q.top();
                if(e<num){
                    Q.pop();
                    Q.push(num);
                }
                else{
                    break;
                }
        }
    }
    long long int ans=0;
    while(!Q.empty()){
        //cout<<Q.top()<<endl;
        ans+=Q.top();
        Q.pop();
    }

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



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

int mini(int a, int b) {

	return ((b==0)?a:(a < b)? a : b);
}
int main() {
	int a[5],tsuika=0;
	int min = 1145141919;
	int ans = 0;
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	for (int i = 0; i < 5; i++)
	{
		min =mini(min, a[i]%10);
		if (a[i] % 10 != 0)tsuika += 10;
	}
	if (min == 1145141919)min = 10;
	ans = tsuika+a[0] / 10 * 10 + a[1] / 10 * 10 + a[2] / 10 * 10 + a[3] / 10 * 10 + a[4] / 10 * 10 -10+min;
	cout << ans;



	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

void solve9b(string s, int a) {
    int n = s.size();
    string ans = s;
    REP(i,a) {
        int h;
        cin >> h;
        string p, q;
        p = ans.substr(0, h);
        q = ans.substr(h, n-h);
        ans = q + p;
        
    }
    cout << ans << endl;
}

int main() {
    string s;
    int a;
    while(cin >> s >> a, s != "-") {
        solve9b(s, a);
    }
    return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <ctype.h>

int main(){
    char a[11],b[11],c[11];
    scanf("%s%s%s", a, b, c);

    printf("%c%c%c\n", toupper(a[0]),toupper(b[0]), toupper(c[0]));

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>

struct node{
  int key;
  struct node *p;
  struct node *l;
  struct node *r;
};

typedef struct node *Node;

Node r,NIL;

int find(int k,Node node){
  if(node == NIL){
    return 0;
  }

  if(node->key == k){
    return 1;
  }else if(node->key < k){
    return find(k , node->r);
  }else{
    return find(k , node->l);
  }
}
void insert(int k){
  Node y = NIL;
  Node x = r;

  Node z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->l;
    }else{
      x = x->r;
    }
  }
  z->p = y;
  if(y == NIL){
    r = z;
  }else if(z->key < y->key){
    y->l = z;
  }else{
    y->r = z;
  }
}

void inorder(Node u){
  if(u == NIL){
    return;
  }
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(Node u){
  if(u == NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}

void print(){
  inorder(r);
  printf("\n");
  preorder(r);
  printf("\n");
}

int main(){
  int n,i,j,z,k;
  char s[10];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",s);
    if(s[0] == 'i'){
      scanf("%d",&z);
      insert(z);
	}else if(s[0]=='f'){
    	scanf("%d" ,&k);
    	if(find(k,r)==1){
			printf("yes\n");
    	}else{
			printf("no\n");
    	}
    }else{
      print();
    }
  }
  return 0;
}


Measured memory_bytes: 20452
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
h = list(map(int, input().split()))
a = list(map(int, input().split()))

# h = [(item, i) for i,item in enumerate(h)]
# h.sort()

class SegmentTree:
    def __init__(self, n, a=None):
        """初期化
        num : nより大きい最小の2のべき乗
        """
        if 2**(n.bit_length()-1)==n:
            self.num = n
        else:
            self.num = 2**n.bit_length()
        self.seg = [0] * (2*self.num-1)
        if a is not None:
            for i,item in enumerate(a):
                self.update(i,item)
        
    def update(self,i,x):
        """update(i,x):Aiをxに更新する
        """
        k = i + self.num - 1
        while k >= 0:
            if x>self.seg[k]:
                self.seg[k] = x
                k = (k-1)//2
            else:
                break
                
    def query(self,a,b,k=0,l=0,r=None,index=False):
        """query(a,b,0,0,num):[a,b)の最大値
        index==Trueのときインデックスも返す
        """
        if r is None:
            r = self.num

        if r <= a or b <= l:
            return (-float("inf"), None) if index else -float("inf")
        elif a <= l and r <= b:
            return (self.seg[k], self._index(k)) if index else self.seg[k]
        else:
            return max(self.query(a,b,2*k+1,l,(l+r)//2, index=index),self.query(a,b,2*k+2,(l+r)//2,r, index=index))
    
    def _index(self, k):
        if k>=self.num:
            return k - (self.num-1)
        else:
            if self.seg[2*k+1]>=self.seg[2*k+2]:
                return self._index(2*k+1)
            else:
                return self._index(2*k+2)

st = SegmentTree(n+1)
for item, aa in zip(h,a):
    val = st.query(0,item)
    st.update(item, val+aa)
print(max(st.seg))

Measured memory_bytes: 118688
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a=int(input())
b=factorization(a)
#print(b)
sum=0

for i in b:
    counter=0
    for j in range(1,100):
        #print(1+(j+2)*(j-1)//2)
        if i[1]>=1+(j+2)*(j-1)//2:
            counter=j
        else:
            break
    sum+=counter
if a==1:
  print(0)
else:
  print(sum)

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

int func(int n){
    if(n%2){
        return 3*n+1;
    }else{
        return n/2;
    }
}

int main() {
    //input
    int s;
    cin >> s;
    vector<int> a(0);
    a.push_back(s);
    bool f = true;
    while(f){
        int x = func(a.at(a.size()-1));
        for(int i=0;i<a.size();i++){
            if(a.at(i) == x){
                cout << a.size()+1 << endl;
                f = false;
                break;
            }
        }
        a.push_back(x);
    }

    return 0;
}

Measured memory_bytes: 256
use proconio::input;

#[allow(unused_macros)]
macro_rules! chmax {
    ($a:expr, $b:expr) => {$a = std::cmp::max($a, $b)}
}

#[allow(unused_macros)]
macro_rules! chmin {
    ($a:expr, $b:expr) => {$a = std::cmp::min($a, $b)}
}

fn main() {
    input! {
        n: usize,
        p: [(i64, i64); n],
    }

    let (x, y) = p[0];
    let mut mx1 = x + y;
    let mut mn1 = x + y;
    let mut mx2 = x - y;
    let mut mn2 = x - y;

    for (x, y) in p {
        chmax!(mx1, x + y);
        chmin!(mn1, x + y);
        chmax!(mx2, x - y);
        chmin!(mn2, x - y);
    }
    let ans = std::cmp::max(mx1 - mn1, mx2 - mn2);
    println!("{}", ans);
}


Measured memory_bytes: 8964
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <queue>
using namespace std;
#define SZ(v) ((int)(v).size())
const int maxint = -1u>>1;
const int maxn = 100 + 30;
typedef long long ll;

int n, m;
ll adj[maxn][maxn];
int f[maxn], bestf[maxn];
int find(int v) {
    if (v != bestf[v]) {
        return bestf[v] = find(bestf[v]);
    }
    return v;
}
int bestff;
int v[maxn];
ll w[maxn];
bool a[maxn];
vector<pair<int, int> > res;
ll mincut() {
    ll ans = (-1ull) >> 1;
    //for (int i = 0; i < n; ++i) {
        //for (int j = 0; j < n; ++j) {
            //adj[i][j] = -adj[i][j];
        //}
    //}
    for (int i = 0; i < n; ++i) {
        f[i] = v[i] = i;
    }
    for (int t = n; t > 1; --t) {
        a[0] = true;
        for (int i = 1; i < t; ++i) {
            a[i] =false;
            w[i] = adj[v[0]][v[i]];
        }
        int prev = v[0];
        for (int i = 1; i < t; ++i) {
            int zj = -1;
            for (int j = 1; j < t; ++j) {
                if (a[j] == false && (zj == -1 || w[j] > w[zj])) {
                    zj = j;
                }
            }
            a[zj] = true;
            if (i == t - 1) {
                if (w[zj] < ans) {
                    ans = w[zj];
                    copy(f, f + n, bestf);
                    bestff = v[zj];
                }
                for (int k = 0; k < t; ++k) {
                    adj[v[k]][prev] = adj[prev][v[k]] += adj[v[zj]][v[k]];
                }
                f[v[zj]] = prev;
                v[zj] = v[t - 1];
                break;
            }
            prev = v[zj];
            for (int j = 1; j < t; ++j) {
                if (a[j] == false) {
                    w[j] += adj[v[zj]][v[j]];
                }
            }
        }
    }
    //bool flag[maxn] = {};
    //for (int i = 0; i < n; ++i) {
        //if (find(i) == bestff) {
            //flag[i] = true;
        //}
    //}
    //res.clear();
    //for (int i = 0; i < n; ++i) {
        //for (int j = i + 1; j < n; ++j) {
            //if (flag[i] == flag[j] && save[i][j]) {
                //res.push_back(make_pair(i, j));
            //}
        //}
    //}
    return ans;
}

void gao() {
    ll ans = 0;
    memset(adj, 0, sizeof(adj));
    for (int i = 0, a, b; i < m; ++i) {
        ll c;
        scanf ("%d%d%lld", &a, &b, &c);
        if (c < 0) {
            ans += c;
        } else {
            adj[a][b] = adj[b][a] = adj[a][b] + c;
        }
    }
    printf("%lld\n", ans + mincut());
}

int main() {
    while (scanf("%d%d", &n, &m) == 2 && (n || m)) {
        gao();
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int n,k,a[233333];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n-k;i++)cout<<(a[i]<a[i+k]?"Yes\n":"No\n");
}

Measured memory_bytes: 4432
#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;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll ar[M],cr[M],br[M];

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

	ll a,b,x,y,z,i,j,k,cost = 0;

	cin >> a >> b >> x >> y >> z;
	for(i=1;i<=x;++i)
		cin >> ar[i];
	for(i=1;i<=y;++i)
		cin >> br[i];
	for(i=1;i<=z;++i)
		cin >> cr[i];

	sort(ar+1,ar+1+x);
	sort(br+1,br+1+y);
	sort(cr+1,cr+1+z);

	for(i=x;i>=x-a+1;i--)
		cost += ar[i];
	for(i=y;i>=y-b+1;i--)
		cost += br[i];

	i = x-a+1;
	j = y-b+1;
	k = z;
	while(i<=x && j<=y && k>=0)
	{
		if(min(ar[i],br[j])>cr[k])
			break;
		if(ar[i]<br[j])
		{
			cost += cr[k]-ar[i];
			i++;
			k--;
		}
		else
		{
			cost += cr[k]-br[j];
			j++;
			k--;
		}
	}

	while(i<=x && k>=0)
	{
		if(ar[i]<cr[k])
		{
			cost += cr[k]-ar[i];
			i++;
			k--;
		}
		else
			break;
	}

	while(j<=y && k>=0)
	{
		if(br[j]<cr[k])
		{
			cost += cr[k]-br[j];
			j++;
			k--;
		}
		else
			break;
	}

	cout << cost << "\n";
	return 0;
}

	

Measured memory_bytes: 5120
import Foundation

let NK = readLine()!.components(separatedBy: " ").map{Int($0)!}
let N = NK[0]
let K = NK[1]
var result = 0
var P = readLine()!.components(separatedBy: " ").map { Int($0)! }

P.sort()


for tmp in 0 ..< K {
    result += P[tmp]
}

print(result)

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

int main()
{
    int n;
    cin >> n;
    vector<int> times(n);
    for (auto& time : times)
    {
        cin >> time;
    }

    int m;
    cin >> m;
    vector<int> problems(m);
    vector<int> boostedTimes(m);
    for (int i=0; i < m; i++)
    {
        cin >> problems[i] >> boostedTimes[i];
    }

    for (int i=0; i < m; i++)
    {
        int problem = (problems[i]-1);
        int totalTime = 0;
        for (int j=0; j < n; ++j)
        {
            totalTime += j == problem ? boostedTimes[i] : times[j];
        }
        cout << totalTime << endl;
    }

    return 0;
}

Measured memory_bytes: 764
(let* ((n (read))
       (m (read))
       x y
       (a (make-array (1+ n) :element-type 'integer
                             :initial-element 0
                             :adjustable t))
       (ans 0))
  (loop repeat m do
        (setf x (read))
        (setf y (read))
        (setf (aref a y) (max x (aref a y))))
  (loop for i from 1 upto n do
        (if (not (= 0 (aref a i))) (if (= (aref a (aref a i)) ans) (incf ans)))
        (setf (aref a i) ans))
  (format t "~A~%" ans))


Measured memory_bytes: 59752
#include <iostream>

using namespace std;

int main()
{
	char num[1000];
	int sum = 0;
	int n = 0;
	
	cin >> num;
	
	for (int i = 0; num[i] != '\0'; i++) {
		sum += num[i] - '0';
	}
	
	for (int i = 0; num[i] != '\0'; i++) {
		n = n * 10 + (num[i] - '0');
	}
	
	if (n % sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return (0);
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <vector>
#define MAXN 1000000

using namespace std;

int N, T;
int a[MAXN];

int main() {
    scanf("%d%d", &N, &T);
    for (int i = 0; i < N; i++)
        scanf("%d", &a[i]);

    int best_val = 0;
    int min_val = a[0];
    for (int i = 1; i < N; i++) {
        best_val = max(best_val, a[i] - min_val);
        min_val = min(min_val, a[i]);
    }

    min_val = a[0];
    int max_cnt = 0;
    for (int i = 1; i < N; i++) {
        int cur_val = a[i] - min_val;
        if (cur_val == best_val)
            max_cnt++;
        min_val = min(min_val, a[i]);
    }

    printf("%d\n", max_cnt);
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){
//int A[20001];
    int K,N;
    int i;
    int distance;
    int max;

    max = 0;

    scanf("%d %d",&K,&N);
    int A[N];

    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    for(i=0;i<N-1;i++){
        distance = A[i+1] - A[i];
        if(distance>=max){
            max = distance;
        }
    }
    distance = K - A[N-1] + A[0];
        if(distance>=max){
            max = distance;
        }

    printf("%d",K-max);
    return 0;
}




Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }
  return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }
  return 0; }
ll MOD = 1000000007;

int main(){
  int n; cin >> n;
  vector<P> ba;
  rep(i,n){
    int a,b;
    cin >> a >> b;
    ba.push_back(make_pair(b,a));
  }
  sort(ba.begin(),ba.end());
  int count = 0;
  for(int i = 0; i < n; i++){
    count += ba.at(i).second;
    if(count > ba.at(i).first){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 5380
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
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 (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

ll n; 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    string s = "";
    if (n == 0) s = "0";
    while (n != 0) {
      int r = abs(n % 2);
      s += to_string(r);
      n -= r;
      n /= -2;
    }
    reverse(ALL(s));
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}
vector<vector<int>> jtof(string S) {
    S.push_back('/');
    vector<vector<int>> ret;
    vector<int> tmp;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'b') {
            tmp.push_back(0);
        } else if (S[i] == '/') {
            ret.push_back(tmp);
            tmp.clear();
        } else {
            int num = (int)(S[i] - '0');
            for (int j = 0; j < num; j++) {
                tmp.push_back(1);
            }
        }
    }
    return ret;
}

string ftoj(vector<vector<int>> field) {
    string ret;
    for (int i = 0; i < field.size(); i++) {
        int cnt = 0;
        for (int j = 0; j < field[i].size(); j++) {
            if (field[i][j] == 1) {
                cnt++;
            } else if (field[i][j] == 0){
                if (cnt) ret.push_back('0' + cnt);
                cnt = 0;
                ret.push_back('b');
            }
            if (field[i].size() - 1 == j) {
                if (cnt) ret.push_back('0' + cnt);
                ret.push_back('/');
            }
        }
    }
    return ret;
}


string solve(string S) {
    vector<vector<int>> field = jtof(S);
    int a, b, c, d; cin >> a >> b >> c >> d;
    a--, b--, c--, d--;
    field[a][b] = 1;
    field[c][d] = 0;
    string ret = ftoj(field);
    return ret;
}

int main(void) {
    string S;
    vector<string> ans;
    while (1) {
        cin >> S;
        if (S[0] == '#') break;
        ans.push_back(solve(S));
    }
    for (auto &i : ans) {
        for (int j = 0; j < i.length() - 1; j++) {
            if (j != i.length() - 2) cout << i[j];
            else cout << i[j] << endl;
        }
    }
}   



Measured memory_bytes: 3196
#include <stdio.h>

int e;
long long f;

int check (long long a,int b)
{
	int c;
	if(a<=f){
		if(b==7){
			e++;
		}
	}
/*	if(a<=f){
		printf("%d\n",a);
	}*/
	if(a<=f){
		check(a*10+3,b|1);
		check(a*10+5,b|2);
		check(a*10+7,b|4);
	}
	return e;
}
	
int main(void)
{
	int d;
	scanf("%lld",&f);
	d=check(0,0);
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main() {

	string a, b;
	cin >> a >> b;


	REP(i, b.size()) {
		cout << a[i] << b[i];
	}

	if (a.size() > b.size()) {
		cout << a[a.size() - 1];
	}
	cout << endl;

	return 0;
}



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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    vector<ll> A(N);
    FOR(i, N-K, N){
        A[i] = 1;
    }

    do{
        ull mask = 0;
        FOR(i, 0, N){
            if(A[i]==1){
                ll bit = N-1-i;
                mask |= (1LL<<bit);
            }
        }
        cout << mask << ':';
        FOR(j, 0, 28){
            if(mask>>j&1){
                cout << ' ' << j;
            }
        }
        cout << endl;
        
    }while(next_permutation(ALL(A)));
    
    
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r, g, b;
    cin >> r >> g >> b;
    int aa = 100 * r + 10 * g + b;
    if(aa % 4 == 0){
        cout << "YES" << endl;
        return 0;
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	string S;
	cin >> S;

	bool n = false, w = false, s = false, e = false;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'N') n = true;
		else if (S[i] == 'W') w = true;
		else if (S[i] == 'S') s = true;
		else if (S[i] == 'E') e = true;
	}

	if (n == s && w == e) cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

void init()
{
	int a = GET<int>();
	int r = 1;
	set<int> s;
	while (s.count(a) == 0) {
		s.insert(a);
		if (a % 2) a = a * 3 + 1;
		else a /= 2;
		r++;
	}
	cout << r << endl;
}

void solve()
{
}


Measured memory_bytes: 256
n = int(input())
p = list(map(float, input().split()))
dp = [[0]*(n+1) for _ in range(n+1)]
dp[0][0] = 1
for i in range(1, n+1):
    for j in range(n+1):
        dp[i][j] = dp[i-1][j-1]*p[i-1]+dp[i-1][j]*(1-p[i-1])
print(sum(dp[-1][-(-n//2):]))


Measured memory_bytes: 259720
# 1: top, 2: front, 3: right,
# 4: left, 5: back, 6: bottom

class Dice:
    def __init__(self, nums):
        self.top, self.front, self.right, self.left, self.back, self.bottom = nums

    def roll(self, direction):
        if direction == 'E':
            self.top, self.right, self.left, self.bottom = self.left, self.top, self.bottom, self.right
            return

        if direction == 'N':
            self.top, self.front, self.back, self.bottom = self.front, self.bottom, self.top, self.back
            return

        if direction == 'S':
            self.top, self.front, self.back, self.bottom = self.back, self.top, self.bottom, self.front
            return

        if direction == 'W':
            self.top, self.right, self.left, self.bottom = self.right, self.bottom, self.top, self.left
            return

    def get_top(self):
        return self.top

if __name__ == '__main__':
    nums = [int(i) for i in input().split()]
    directions = input()

    d = Dice(nums)
    for i in range(len(directions)):
        d.roll(directions[i])

    print(d.get_top())

Measured memory_bytes: 6736
//
// Created on 2020/08/02.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;



int main() {

    int k;
    cin>>k;
    ll x = 7;
    x %= k;
    for (int i = 1; i <= k; ++i) {
        if(x == 0){
            cout<<i<<endl;
            return 0;
        }
        x %= k;
        x *= 10;
        x += 7;
        x %= k;
    }

    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3592