akhauriyash/Code-Regression huggingface dataset:
use std::io;

/// 一行を読み込んで、空白で区切ったベクタにして返す
#[allow(dead_code)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect()
}

/// n行を読み込んで、数字を空白で区切って二次元のベクタにして返す
#[allow(dead_code)]
fn read_table<T>(n: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut ret: Vec<Vec<T>> = Vec::new();
    for _ in 0..n {
        ret.push(read::<T>());
    }
    ret
}

/// n行を読み込んで、1文字ずつを二次元のベクタにして返す
#[allow(dead_code)]
fn read_char_table(n: usize) -> Vec<Vec<char>> {
    let mut ret: Vec<Vec<char>> = Vec::new();
    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let chr = buf.trim().chars().collect();
        ret.push(chr);
    }
    ret
}

/// n行を読み込んで、一次元のベクタにして返す
#[allow(dead_code)]
fn read_array<T>(n: usize) -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut array = Vec::new();

    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        array.push(buf.trim().parse().unwrap());
    }
    array
}

fn main() {
    // 数値
    let n = {
        let i = read::<isize>();
        (i[0])
    };

    let ans = if n % 2 == 0 { n } else { n * 2 };

    println!("{}", ans);
}


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

using namespace std;

typedef long long int lli;

int main(int argc, char const *argv[]) {
  lli n;
  cin >> n;
  vector<lli> a(n), b;
  for (size_t i = 0; i < n; i++) cin >> a[i];
  if (n%2==0) {
    for (lli i = n-1; i > 0; i-=2) b.push_back(a[i]);
    for (lli i = 0; i < n; i+=2) b.push_back(a[i]);
  }
  else {
    for (lli i = n-1; i >= 0; i-=2) b.push_back(a[i]);
    for (lli i = 1; i < n; i+=2) b.push_back(a[i]);
  }
  for (lli i = 0; i < n; i++) cout << b[i] << ' ';
  cout << endl;
  return 0;
}


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

int main(){
  int n;
  string s;
  cin >> n >> s;
  
  //右端から見ていって、もし白石の塊が黒石の塊より小さければ貪欲に黒に変えていい。
  //白石のほうが多ければ、どんどん左に進んでいって、小さくなったタイミングで加算する。
  //左端までついて時点で白石のほうが多ければ黒石を白石に変えたほうがいいので黒石の数を加算する。
  //加算するたびに石のカウントは初期化する。(それより右には黒しかないことになる)
  int ans = 0;
  bool ok = true;//右側がもとから黒石であるうちは考えなくていい
  int cntb = 0, cntw = 0;
  for(int i = n-1; i >= 0; i--){ // 右端から見ていく
    if(s.at(i) == '.') ok = false;//白石が出てきたらカウント開始
    if(ok) continue;
    if(s.at(i) == '#') cntb++;//黒石の時は何も考えない
    else if(cntb == 0) cntw++;//一度白石が出てきた後黒が出てきてなければ加算するだけ
    else{//連続した白石と黒石が途切れたら加算するか考える
      if(cntw <= cntb){//白を黒にするのはいつでもやっていい
        ans += cntw;
        cntb = 0, cntw = 1;//加算したら初期化
        //今止まっている石は白で、白…白黒…黒白となっている状態なので、白は1になる
      }
      else cntw++;//白のほうが多ければカウントを続行する
    }
  }
  ans += min(cntb, cntw);
  
  cout << ans << endl;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/12  Problem: ABC 081 B / Link: http://abc081.contest.atcoder.jp/tasks/abc081_b  ----- */


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

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

	auto f = [](LL x) {
		LL ret = 0;
		while (x % 2 == 0) {
			x /= 2;
			ret++;
		}
		return ret;
	};
	LL ans = LINF;
	for (auto it : a) {
		ans = min(ans, f(it));
	}
	
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
N = int(input())
n = N
sumup = 0
while N != 0:
    #print(N % 10)
    sumup += (N % 10)
    N = N // 10
#print(n, sumup)
if n % sumup == 0:
    print('Yes')
else:
    print('No')

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    ll N;
    cin >> N;
    vector<ll> A(5);
    for (int i = 0; i < 5; i++) {
        cin >> A[i];
    }
    int mi = min_element(all(A)) - A.begin();
    cout << mi + (N + A[mi] - 1) / A[mi] + 5 - mi - 1 << endl;

}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cctype>
#include <climits>
#include <fstream>

using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;


int main(){
    int n;
    ll ans = 1;
    const ll MAX = 1000000007;
    cin>>n;
    vector<int> v(n);
    int x;
    rep(i,n){
        cin>>x;
        v[x]++;
    }
    if(n%2==0){
        for(int i=n-1;i>=0;i -= 2){
            if(v[i] != 2){
                cout<<0<<endl;
                return 0;
            }
        }
        rep(i,n/2){
            ans *=2;
            ans %= MAX;
        }
        cout<< ans << endl;
    }else{
        for(int i=n-1;i>0;i -= 2){
            if(v[i] != 2){
                cout<<0<<endl;
                return 0;
            }
        }
        if(v[0] != 1){
            cout<<0<<endl;
            return 0;
        }
        rep(i,n/2){
            ans *=2;
            ans %= MAX;
        }
        cout<< ans << endl;
    }


    return 0;
}


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

using namespace std;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}init;
typedef long long LL;
const LL MOD=10007;
int main(){

    string s;
    cin>>s;
    vector<int> num;
    for(auto &it:s)num.push_back(it-'0');
    int n=num.size();
    int m=1<<(n-1);
    LL res=0;
    for(int bit=0;bit<m;bit++){
        LL sum=0;
        LL now=num[0];
        for(int i=0;i<n-1;i++)
            if(bit&(1<<i)){
                now*=10;now+=num[i+1];
            }else{
                sum+=now;now=num[i+1];
            }
        res+=sum+now;
    }
    cout<<res<<endl;        
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int            int64_t
#define double         long double
#define nitro          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi             vector<int64_t>
#define pub            push_back
#define puf            push_front
#define pob            pop_back
#define pof            pop_front
#define PI             3.1415926535897932384626433832795
#define read(a)        for(auto& x : a) cin>> x
#define endl           '\n'
#define gap            ' '
#define min3(a,b,c)    min(a, min(b, c))
#define max3(a,b,c)    max(a, max(b, c))
#define MOD            1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
    nitro
    int n,m;cin>>n>>m;
    n+=2,m+=2;
    char c[n][m];
    for(int i=0;i<n;++i)
    for(int j=0;j<m;++j)
    c[i][j]='.';
    for(int i=1;i<=n-2;++i)
    for(int j=1;j<=m-2;++j)
    cin>>c[i][j];
    for(int i=1;i<=n-2;++i){
    for(int j=1;j<=m-2;++j)
    {
    	int a=0;
    	if(c[i][j]=='.')
    	{
    		if(c[i][j+1]=='#') a++;
    		if(c[i][j-1]=='#') a++;
    		if(c[i+1][j]=='#') a++;
    		if(c[i-1][j]=='#') a++;
    		if(c[i+1][j+1]=='#') a++;
    		if(c[i+1][j-1]=='#') a++;
    		if(c[i-1][j-1]=='#') a++;
    		if(c[i-1][j+1]=='#') a++;
    		cout<<a;
    	}
    	else cout<<"#";
    }
    cout<<endl;
    }
}

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

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

    vector<vector<int>> F(N, vector<int> (10));
    vector<vector<int>> P(N, vector<int> (11));
    for (auto& x : F) for (auto& y : x) cin >> y;
    for (auto& x : P) for (auto& y : x) cin >> y;

    int ans = -(1 << 30);
    for (int i = 1; i < 1 << 10; i++) {
        int t = 0;
        for (int j = 0; j < N; j++) {
            int cnt = 0;
            for (int k = 0; k < 10; k++) {
                cnt += ((i >> k) & 1 && F[j][k]);
            }
            t += P[j][cnt];
        }
        ans = max(ans, t);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N,M = map(int, input().split())

div = []
for i in range(1, int(M**0.5)+1):
  if M % i == 0:
    div.append(i)
    if M // i != i:
      div.append(M // i)
div.sort()

for i in range(len(div)):
  num = div[i]
  if num >= N:
    print(M // num)
    break

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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(max(max(a,b),c)*3+min(min(a,b),c)*3==(a+b+c)*2)
	cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;

    rep(i, w + 2) cout << '#';
    cout << endl;
    rep(i, h) {
        string s;
        cin >> s;
        cout << '#' << s << '#' << endl;
    }
    rep(i, w + 2) cout << '#';
    cout << endl;

    return 0;
}


Measured memory_bytes: 3512
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

#define  ROT(dr) dr=(dr+1)%4;

bool f[205][205];

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

int wdx[]={-1,-1, 0, 1, 1,  1,  0,-1};
int wdy[]={ 0, 1, 1, 1, 0, -1, -1,-1};

void setw(int x1, int y1, int x2, int y2)
{
	x1*=2; y1*=2; x2*=2; y2*=2;
	y1=H*2-y1; y2=H*2-y2; 
	if(x1>x2) swap(x1,x2);
	if(y1>y2) swap(y1,y2);
	
	for(int i=y1; i<=y2; i++)
	for(int j=x1; j<=x2; j++)
		f[j][i]=1;
}

int main()
{
	int N;
	while(cin >> W >> H >> N,(W||H||N))
	{
		memset(f,0,sizeof(f));
		
		setw(0,0,0,H);
		setw(0,0,W,0);
		setw(W,0,W,H);
		setw(0,H,W,H);
		
		while(N--)
		{
			int x1,y1,x2,y2;
			cin >> x1 >> y1 >> x2 >> y2;
			setw(x1,y1,x2,y2);
		}
		
		int ux,uy,vx,vy,gx,gy;
		cin >> ux >> uy >> vx >> vy >> gx >> gy;
		int sx = max(ux,vx)*2;
		int sy = max(uy,vy)*2;
		int dr = 0;
		gx*=2; gx++; gy*=2; gy++;
		gy=H*2-gy;
		
		
		if(sx!=min(ux,vx)*2) sx--;
		if(sy!=min(uy,vy)*2) sy--;
		
		sy=H*2-sy;
		
		f[sx][sy]=0;
		
		bool v[205][205][4]={0};
		
		for(int i=0; i<4; i++)
		{
			int tx=sx+dx[i], ty=sy+dy[i];
			if(tx<0||ty<0||tx>=2*W+1||ty>=2*H+1) continue;
			if(f[tx][ty]) continue;
			
			dr=i;
			break;
		}
		/*
		for(int i=0; i<=H*2; i++)
		{
			for(int j=0; j<=W*2; j++)
			{
				cout << f[j][i];
			}
			cout << endl;
		}
		*/
		
		int c=0;
		bool g=false;
		while(1)
		{
			if(v[sx][sy][dr]) break;
			v[sx][sy][dr]=1;
			
			if(sx==gx&&sy==gy)
			{
				g=true;
				cout << c << endl;
				break;
			}
			
			int tx=sx+dx[dr], ty=sy+dy[dr];

			if(f[tx][ty]) 
			{
				for(int i=0; i<4; i++)
				{
					int wx=sx+dx[(dr+3+i)%4], wy=sy+dy[(dr+3+i)%4];
					if(f[wx][wy]==0)
					{
						dr=(dr+3+i)%4;
						break;
					}
				}
			}
			else
			{
				int wx=sx+dx[(dr+3)%4], wy=sy+dy[(dr+3)%4];
				
				if(f[wx][wy]==0)
				{
					dr=(dr+3)%4;
				}
			}

			sx+=dx[dr]; sy+=dy[dr];
			if(c!=0)
			{
				sx+=dx[dr]; sy+=dy[dr];
			}
			if(sx<0||sy<0||sx>=2*W+1||sy>=2*H+1) break;
			c++;
			
		}
		
		if(!g) cout << "Impossible" << endl;
	}
}

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

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

  vector<vector<int>> to(N);
  vector<int> ans(N, -1);
  for (int i = 0; i < N-1; i++)
  {
    int x, y; cin >> x >> y;
    x--; y--;
    to[x].push_back(y);
    to[y].push_back(x);
  }

  vector<int> c(N);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> c[i];
    sum += c[i];
  }
  sort(c.rbegin(), c.rend());

  ans[0] = c[0];
  int num = 1;
  queue<int> q;
  q.push(0);

  while (!q.empty()) {
    int now = q.front(); q.pop();
    for (auto& next : to[now])
    {
      if (ans[next] != -1) continue;
      ans[next] = c[num];
      num++;
      q.push(next);
    }
  }

  cout << sum - c[0] << endl;
  for (int i = 0; i < N; i++) {
    cout << ans[i];
    if (i != N - 1)cout << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

int main() {
    long long int N, X;
    cin >> N >> X;
    
    long long int max_length=1;
    int n=0;
    vector<long long int> max_p_num(N+1, 0);
    max_p_num[0] = 1;
    while(n<N) {
        max_length *= 2;
        max_length += 3;
        
        max_p_num[n+1] = max_p_num[n]*2+1;
        // cout << max_p_num[n+1] << endl;
        n++;
    }
    // cout << max_length << endl;
    
    long long int s=1, e=max_length;
    long long int cur=(s+e)/2;
    long long int ans=0;
    long long int curN=N-1;
    if(cur==X) {
        ans = max_p_num[curN]+1;
    }
    while(cur!=X) {
        // cout << cur << endl;
        if(cur<X) {
            if(curN>=0) {
                ans += max_p_num[curN]+1;
            } else {
                ans += 1;
                break;
            }
            
            s = cur+1;
            if(e!=X) {
                e--;
            } else {
                ans += max_p_num[curN];
                break;
            }
            cur = (s+e)/2;

            if(cur==X) {
                if(curN>0) {
                    ans += max_p_num[curN-1]+1;
                } else if(curN==0) {
                    ans += 1;
                }
            }
        } else if(cur>X) {
            e = cur-1;
            if(s!=X) {
                s++;
            } else {
                break;
            }
            cur = (s+e)/2;
            
            if(cur==X) {
                if(curN>0) {
                    ans += max_p_num[curN-1]+1;
                } else if(curN==0) {
                    ans += 1;
                }
            }
        }
        
        curN--;
    }
    
    cout << ans << endl;


    return 0;
    
}

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

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define INF ((ll)1e9+7)
#define c(a) cout<<a<<"\n";
using namespace std;
const int N = 100005;

int main() {
	speed;
	int a;
	string s;
	cin >> a >> s;
	if (a < 3200) { c("red"); }
	else c(s);
	ed;
	return 0;
}


Measured memory_bytes: 256
/** AtCoder Beginner Contest 136, by Abreto<m@abreto.net> */
#include <bits/stdc++.h>

using namespace std;

namespace abreto {

const int maxn = 100100;

int N;
int H[maxn];

void main(void)
{
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> H[i];
    H[0]--;
    for (int i = 1; i < N; i++)
    {
        if (H[i] > H[i - 1])
            H[i]--;
    }
    int ok = 1;
    for (int i = 1; i < N; i++)
        if (H[i] < H[i - 1])
        {
            ok = 0;
            break;
        }
    cout << (ok ? "Yes" : "No") << '\n';
}

}

int main(void)
{
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    abreto::main();
    return 0;
}


Measured memory_bytes: 640
def main():
	S = input()

	border = len(S)

	while True:
		if S[border - 5: border] == "dream":
			border -= 5
		elif S[border - 7: border] == "dreamer":
			border -= 7
		elif S[border - 5: border] == "erase":
			border -= 5
		elif S[border - 6: border] == "eraser":
			border -= 6
		else:
			break

	if border == 0:
		print("YES")
	else:
		print("NO")
 
 
if __name__ == "__main__":
  	main()

Measured memory_bytes: 9244
import java.io.PrintWriter;
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int r = in.nextInt();
        out.println(2.0 * Math.PI * 1.0 * r);
        out.close();
    }
}

Measured memory_bytes: 27236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

void no(){
		printf("-1\n");
		exit(0);
}

#define N 112345
set<int> g[N];
priority_queue<pii, vpii, greater<pii>> que;
int a[N]={};
vpii ans;
void edg(int x, int y){
	ans.EB(x, y);
	g[x].erase(g[x].find(y));
	que.emplace(g[x].size(), x);
	g[y].erase(g[y].find(x));
	que.emplace(g[y].size(), y);
	a[x]++;
}

int main(){
	int n, m; scanf("%d%d", &n, &m);
	REP(i, m){
		int a, b; scanf("%d%d", &a, &b);
		g[a].emplace(b);
		g[b].emplace(a);
	}
	if(m%2){
		no();
	}
	FOR(i, 1, n+1) que.emplace(g[i].size(), i);
	while(que.size()){
		pii tp = que.top(); que.pop();
		int i = tp.second;
		if((int)g[i].size() != tp.first) continue;
		int s = tp.first;
		if(!s){
			if(a[i]%2) no();
		 	continue;
		}
		int j = *g[i].begin();
		if(a[i]%2){
			edg(i, j);
		} else {
			edg(j, i);
		}
	}
	for(auto &p : ans) printf("%d %d\n", p.first, p.second);
}



Measured memory_bytes: 18784
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef pair<int,int> P;
typedef pair<int,P>Q;
#define fi first
typedef long long ll;
#define sc second

int x[205][205][105];
vector<int>vec[10];

int main(){
	vec[1].pb(2); vec[1].pb(3);	vec[1].pb(5); vec[1].pb(4);
	vec[2].pb(1); vec[2].pb(4);	vec[2].pb(6); vec[2].pb(3);
	vec[3].pb(1); vec[3].pb(2);	vec[3].pb(6); vec[3].pb(5);
	vec[4].pb(1); vec[4].pb(5);	vec[4].pb(6); vec[4].pb(2);
	vec[5].pb(1); vec[5].pb(3);	vec[5].pb(6); vec[5].pb(4);
	vec[6].pb(5); vec[6].pb(3);	vec[6].pb(2); vec[6].pb(4);
	while(1){
		int n;
		cin >> n; if(n==0) return 0;
		rep(i,205)rep(j,205)rep(k,105)x[i][j][k] =0;
		rep(i,n){
			int a,b; cin >> a >> b;
			int c;
			for(int j=0;j<4;j++) if(vec[a][j] == b) { c = vec[a][(j+1)%4]; break;}
			int X=100,Y=100;
			while(1){
				//if(n == 8) cout << X << " " << Y << " " << a << b << c << endl;
				int len = 0;
				for(int i=0;i<105;i++) if(x[X][Y][i] > 0) len++; else break;
				//cout << len << endl;
				int nx[4]={1,0,-1,0};
				int ny[4]={0,1,0,-1};
				int mx = -1, dir = -1;
				int men[4]={c,b,7-c,7-b};
				for(int k=0;k<4;k++){
					int len2 = 0;
					rep(i,105) if(x[X+nx[k]][Y+ny[k]][i] > 0) len2++; else break;
					if(len2 >= len) continue;
					if(men[k] < 4) continue;
					if(mx < men[k]) {mx = max(mx,men[k]); dir = k;}
				}
				if(mx == -1){
					//cout << X << " " << Y << " " << len << " " << a << endl;
					x[X][Y][len] = a; break;
				}
				else{
					X += nx[dir];
					Y += ny[dir];
					if(dir == 0){
						int d = c; c = a; a = 7-d;
					}
					else if(dir == 1){
						int d = b; b = a; a = 7-d;
					}
					else if(dir == 2){
						int d = a; a = c; c = 7-d;
					}
					else{
						int d = a; a = b; b = 7-d;
					}
				}
			}
		}
		int c[6]={};
		for(int i=0;i<205;i++) for(int j=0;j<205;j++){
			for(int k=100;k>=0;k--){
				if(x[i][j][k] > 0) {c[x[i][j][k]-1]++;break;}
				
			}
		}
		rep(i,6) cout << c[i] << (i==5?(char)(10):' '); //cout << endl;
	}
}



Measured memory_bytes: 20408
#include<stdio.h>

int main(){
	int a,b,c,d;
	int N;
	int M;
	while(scanf("%d",&N)!=EOF){
		M=0;
		for(a=0;a<=9;a++)
			for(b=0;b<=9;b++)
				for(c=0;c<=9;c++)
					for(d=0;d<=9;d++)
						if(a+b+c+d==N)
							M++;
		printf("%d\n",M);
	}		
	return 0;
}

Measured memory_bytes: 596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


    class Program
    {
        static void Main(string[] args)
        {
          string[] Input = Console.ReadLine().Split(' ');
          int N = int.Parse(Input[0]);
          int L = int.Parse(Input[1]);
          var list = new List<string>{};
          for(int i = 0; i < N; i++)
          {
            string Input2 = Console.ReadLine();
            list.Add(Input2);
          }
          list.Sort();
          foreach(var l in list)
          {
           Console.Write(l); 
          }
          Console.WriteLine();
        }
    }



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

#define pb push_back

#define int ll
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;

template<typename T, typename U>
ostream& operator<<(ostream& o, const pair<T,U>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}

template<typename T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (const T& x : v)
    o << x << ",";
  return o << "]";
}

const int INF = 1e18;

void bfs(const vvi& g, vi& posts) {
  queue<int> q;
  q.push(0);
  vi seen(g.size());
  seen[0] = 1;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int w : g[v]) {
      if (!seen[w]) {
        seen[w] = 1;
        posts[w] = v;
        q.push(w);
      }
    }
  }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m;
  cin >> n >> m;
  vvi g(n);
  for (int i=0; i<m; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].pb(b);
    g[b].pb(a);
  }
  vi posts(n, -1);
  bfs(g, posts);
  cout << "Yes\n";
  for (int i=1; i<n; ++i) {
    assert(posts[i] >= 0);
    cout << posts[i]+1 << "\n";
  }
}


Measured memory_bytes: 13672
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-9;



int main() {


    int k,a,b;
    cin>>k>>a>>b;
    bool ch=0;
    for(int i=0;i<1000;i++){
        if(k*i>=a&&k*i<=b)ch=1;
    }
    if(ch)fin("OK");
    else fin("NG");
}



Measured memory_bytes: 3636
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main(){
    input!{
        s:String,
    }
    let mut v:Vec<char> = s.chars().collect();
    let zero = v.iter().filter(|&x| *x == '0').count();
    let one  = v.iter().filter(|&x| *x == '1').count();
    let ans = if zero < one {
        zero
    } else {
        one
    };
    println!("{}",ans*2);
}

Measured memory_bytes: 4352
N, A, B =map(int,input().split())
ans = 0
for i in range(N+1):
    keta5 = i//10000
    keta4 = i//1000 - 10*(i//10000)
    keta3 = i//100 - 10*(i//1000)
    keta2 = i//10 - 10*(i//100)
    keta1 = i%10
    if A<=keta1+keta2+keta3+keta4+keta5 <=B:
        ans += i
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long

int X;
LL a,b;

int main() {
	cin>>X;
	for(a=-1000ll;a<1000ll;a++)for(b=-1000ll;b<1000ll;b++){
		LL A=a*a*a*a*a,B=b*b*b*b*b;
		if(A-B==X){
			cout<<a<<" "<<b<<endl;
			return 0;
		}
	}

	return 0;
}



Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    ll d = c-b-a;
    if(4 * a * b < d * d && d > 0)    cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
  vector<int> deta(3),rest(3);
  cin>>deta.at(0)>>deta.at(1)>>deta.at(2);
  sort(deta.begin(), deta.end());
  int a,dif,sum;
  a=deta.at(2)*3;
  dif=a-(deta.at(0)+deta.at(1)+deta.at(2));
  rest.at(0)=deta.at(0)%2;
  rest.at(1)=deta.at(1)%2;
  rest.at(2)=deta.at(2)%2;
  sum= rest.at(0)+rest.at(1)+ rest.at(2);
  if(sum==0||sum==3)
  {
    cout<<dif/2<<endl;
  }
  else if(sum==1)
  {
    if(rest.at(2)==0)
    {
      cout<<(dif+3)/2<<endl;
    }
    else
    {
      cout<<(dif+1)/2<<endl;
    }
  }
  else if(sum==2)
  {
    if(rest.at(2)==0)
    {
      cout<<(dif+1)/2<<endl;
    }
    else
    {
      cout<<(dif+3)/2<<endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w; cin >> h >> w;
    vector<string> f(h); for(auto& e : f) cin >> e;

    bool res = true;
    rep(y, h){
        rep(x, w){
            if(f[y][x] != '#') continue;

            bool ok = false;
            rep(i, 4){
                int nx = x + dx[i];
                int ny = y + dy[i];
                if(nx < 0 or w <= nx or
                   ny < 0 or h <= ny) continue;
                ok |= (f[ny][nx] == '#');
            }

            res &= ok;
        }
    }

    cout << (res ? "Yes":"No") << endl;

    return 0;
}


Measured memory_bytes: 256
import bisect
N = int(input())
a = sorted(list(map(int, input().split())))
color = [400, 800, 1200, 1600, 2000, 2400, 2800, 3200]
border = []
for i in color:
    border.append(bisect.bisect_left(a, i))
border = [0] + border
num = []
for i in range(len(color)):
    num.append(border[i+1] - border[i])
num.append(N - sum(num))
colornum = sum(x>0 for x in num[:-1])
print(str(max(1, colornum)) + " " + str(colornum + num[-1]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;

int main(){
  string s;
  cin >> s;
  
  bool flag=true;
  char f,g;
  int fn=0,gn=0;
  
  f = s[0];
  rep(i,4){
    if(s[i] != f) g = s[i];
  }
  
  rep(i,4){
    if(s[i] == f) fn++;
    if(s[i] == g) gn++;
  }
  
  if(fn==2 && gn==2) cout << "Yes";
  else cout << "No";
  
  return 0;
}


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

int n,arr[10000];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>arr[i]; 
	} 
	int sum=0,min1,min2;
	for(int i=0;i<n-2;i++){
		min1=arr[i+1];
		int s[]={arr[i],arr[i+1],arr[i+2]};
		sort(s,s+3);
		min2=s[1];
		if(min1==min2){
			sum++; 
		}
	} 
	cout<<sum;
	return 0; 
} 

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    string s;
    cin >> s;
    
    int ans = 0;
    rep(i, s.size()) {
        if (i & 1) {
            if (s[i] == 'g') ++ans;
        } else {
            if (s[i] == 'p') --ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define se second
#define fi first
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;
const int N = 1e5 + 5;

int n,m,s;

struct edge{int to,cost;};
vector<edge>G[N];
ll d[N];

void dijkstra(const int& s,const int& V,ll *d){
	priority_queue<P,vector<P>,greater<P> >q;
	fill(d,d+V+1,INF);
	d[s]=0;
	q.push({0,s});
	while(!q.empty()){
		P t=q.top();q.pop();
		int v=t.se;
		if(d[v]<t.fi) continue;
		for(int i=0;i<G[v].size();i++){
			edge e=G[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				q.push({d[e.to],e.to});
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int u,v,w=1;
		cin>>u>>v;
		G[u].push_back({v,w});
		G[v].push_back({u,w});
	}
	s=1;
	dijkstra(s,n,d);
	for(int i=1;i<=n;i++){
		if(d[i]==INF){
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
	for(int i=2;i<=n;i++){
		for(auto c:G[i]){
			int k=c.to;
			if(d[k]+1==d[i]){
				cout<<k<<'\n';
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 13652
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
using ll = long long;
using namespace std;
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }

template <class Monoid>
struct sparse_table {
    typedef typename Monoid::underlying_type underlying_type;
    vector<vector<underlying_type> > table;
    Monoid mon;
    sparse_table() = default;
    sparse_table(vector<underlying_type> const & data, Monoid const & a_mon = Monoid())
            : mon(a_mon) {
        int n = data.size();
        int log_n = log2(n) + 1;
        table.resize(log_n, vector<underlying_type>(n, mon.unit()));
        table[0] = data;
        for (int k = 0; k < log_n-1; ++ k) {
            for (int i = 0; i < n; ++ i) {
                table[k+1][i] = mon.append(table[k][i], i + (1ll<<k) < n ? table[k][i + (1ll<<k)] : mon.unit());
            }
        }
    }
    underlying_type range_concat(int l, int r) const {
        if (l == r) return range_concat(0, table[0].size());
        if (l > r) return mon.append(
                l == table[0].size() ? mon.unit() : range_concat(l, table[0].size()),
                r == 0 ? mon.unit() : range_concat(0, r));
        assert (0 <= l and l <= r and r <= table[0].size());
        if (l == r) return mon.unit();
        int k = log2(r - l);
        return mon.append(table[k][l], table[k][r - (1ll<<k)]);
    }
};
struct min_t {
    typedef int underlying_type;
    int unit() const { return INT_MAX; }
    int append(int a, int b) const { return min(a, b); }
};

constexpr ll inf = ll(1e18)+9;
int main() {
    // input
    int n, x; scanf("%d%d", &n, &x);
    vector<int> a(n); repeat (i, n) scanf("%d", &a[i]);
    // solve
    sparse_table<min_t> rmq(a);
    ll result = inf;
    repeat (k, n) {
        ll acc = x *(ll) k;
        repeat (i, n) {
            acc += rmq.range_concat(i, (i + k + 1) % n);
        }
        setmin(result, acc);
    }
    // output
    printf("%lld\n", result);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max
#include <string>	//string
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt
#include <sstream>	//stringstream,getline
#include <cmath>	//ceil

using namespace std;

int main() {

	int N, X, T;
	cin >> N >> X >> T;

	int a = N / X;
	if (N % X != 0) {
		a++;
	}

	cout << a * T << endl;

	return 0;

}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
         
int main() {
  int N;
  cin >> N;
  
  vector<int> data(N);
  
  for(int i = 0 ; i < N ; i++){
    cin >> data.at(i);
  }
  
  int cnt = N;
  
  for(int i = 0 ; i < N - 1 ; i++){
    int temp = data.at(i);
    for(int j = i + 1; j < N; j++){
      if(temp == data.at(j)){
        cnt--;
        break;
      }
    }
  }
  
  cout << cnt;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))
cnt = 0
for _ in range(10**4):
    if any(H) is False:
        break
    cnt += 1
    f = False
    for i in range(len(H)):
        if H[i] > 0:
            H[i] -= 1
            f = True
        elif f and H[i] == 0:
            break
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


long long solve(long long K) {
    if (K % 2 == 0 || K % 5 == 0) return -1;
    long long val = 7 % K;
    for (int i = 0; i <= K*2; ++i) {
        if (val == 0) return i + 1;
        val = (val * 10 + 7) % K;
    }
}

int main() {
    long long K;
    while (cin >> K) {
        cout << solve(K) << endl;
    }
}

















Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


const int SZMAX = 100;
ll dp[SZMAX + 5][10][10];
int nxtj(int j,int l,char c) {
	if (j == 1)return 1;
	int num = c - '0';
	if (l < num)return 1;
	else if (l == num)return 0;
	else return 2;
}
int nxtk(int k,int l){
	if (l == 0)return k;
	else return min(k + 1,4);
}

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

	string N;
	int K;
	cin >> N >> K;
	int sz = N.size();
	reverse(all(N));
	dp[sz][0][0] = 1;
	for (int i = sz; i >= 1; i--){
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k <= 3; k++) {
				for (int l = 0; l <= 9; l++) {
					dp[i-1][nxtj(j,l,N[i-1])][nxtk(k,l)] += dp[i][j][k];
				}
			}
		}
	}
	puts(dp[0][0][K] + dp[0][1][K]);
	
	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

int main(){
    int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
    int a = C * max({X, Y}) * 2;
    
    int min_num = min({X, Y});
    int b = C * min_num * 2 + (X - min_num) * A + (Y - min_num) * B;
    int c = A * X + B * Y;

    int ans = min(a, min(b, c));
    cout << ans << endl;
    
}

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

#define fastIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL);
#define asc(s) sort(s.begin(), s.end())
#define des(s) sort(s.rbegin(), s.rend())
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define rev(v) reverse(v.begin(), v.end())
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define precision(x, p) fixed << setprecision(p) << x
#define set_bits(n) __builtin_popcount(n);
#define mod 1000000007
#define PI 3.14159265358979
typedef long long ll;

#ifndef ONLINE_JUDGE
#define debug(x) cout << x << endl;
#else
#define debug(x)
#endif

template <class T>
T gcd(T a, T b)
{
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) { return a * b / gcd(a, b); };

vector<string> split(string s)
{
    istringstream buf(s);
    istream_iterator<string> beg(buf), end;
    vector<string> list(beg, end);
    return list;
}

bool isvowel(char c)
{
    string s = "aeiou";
    if (find(s.begin(), s.end(), c) != s.end())
        return true;
    return false;
}

bool cmp(pair<int, int> &a, pair<int, int> &b)
{
    return a.second > b.second || (a.second == b.second && a.first > b.first);
}

bool isprime(ll n)
{
    for (int i = 2; i * i <= n; i++)
        if (n % i == 0)
            return false;

    return true && (n != 1);
}

void solve()
{
    int a, b;
    cin >> a >> b;

    cout << max(a + b, max(a - b, a * b));
}

int main()
{
    fastIO

        int t = 1;
    // cin>>t;

    for (int test_case = 1; test_case <= t; test_case++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
def check(a,b,c,k):
    sum1=0
    sum1+=min(a,k)
    k-=min(a,k)
    if(k==0):
        return sum1
    else:
        k-=min(b,k)
        if(k==0):
            return sum1
        else:
            val=min(k,c)
            sum1=sum1-val
            return sum1
l=list(map(int,input().strip().split()))[:4]
a,b,c,k=l[0],l[1],l[2],l[3]
sum1=0
ans=check(a,b,c,k)
print(ans)


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

int main() {
	string a, b;
	cin >> a >> b;
	int res = 0;
	for(int i = 0; i < a.length(); ++i) {
		res = res * 10 + (a[i] - '0');
	}
	for(int i = 0; i < b.length(); ++i) {
		res = res * 10 + (b[i] - '0');
	}
	for(int i = 1; i <= 1000; ++i) {
		if(i * i > res)
			break;
		if(i * i == res) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  string s;
  cin >> s;
  rep(i,s.size()){
     s[i] = 'x';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
	bool is_visited;
} edge;
int main( void ){
	int N; cin >> N;
	int ans = 1;
	while(ans <= N)
		ans *= 2;
	cout << ans/2 << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
/*Author: S7a2a7d */
    #include <bits/stdc++.h>
    #pragma GCC optimize("Ofast")
    using namespace std;
     
    #define pb push_back
    #define ll long long
    #define rep(i,n)  for(ll i=0;i<n;i++)
    #define repi(i,n)  for(ll i=1;i<=n;i++)
    #define mem(arr,x) memset(arr,x,sizeof(arr))
     
    #define mp make_pair
    #define f first
    #define s second
     
    const double PI = 3.1415926535897932;
    const int mod = 1e9 + 7;  
    const int inf = 1e9 + 5;
    ll lcm(ll a,ll b)
    {
        return (a*b)/__gcd(a,b);
    }
    int min(int a,int b)
    {
		if(a<b)
		return a;
		return b;
	}
    int main()
    {
        
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
     
   string s,t;
   cin>>s>>t;
   int res=inf;
  for(int i=0;i<=(int)s.length()-(int)t.length();i++)
  {  ll int ans=0;
	  for(int j=0;j<(int)t.length();j++)
	  {
		  if(s[i+j]==t[j])
		  {
			  continue;
		 }
		 else
		 ans++;
	 }
	 res=min(res,ans);
 }
 cout<<res<<'\n';
		  
    
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int32_t n, m, l;

    cin >> n >> m >> l;

    vector<vector<int64_t>> A(n, vector<int64_t>(m)), B(m, vector<int64_t>(l));

    for (int32_t i = 0; i < n; i++) {
        for (int32_t j = 0; j < m; j++) {
            cin >> A[i][j];
        }
    }

    for (int32_t i = 0; i < m; i++) {
        for (int32_t j = 0; j < l; j++) {
            cin >> B[i][j];
        }
    }

    for (int32_t i = 0; i < n; i++) {
        for (int32_t j = 0; j < l; j++) {
            int64_t c_ij = 0;

            for (int32_t k = 0; k < m; k++) {
                c_ij += A[i][k] * B[k][j];
            }

            cout << c_ij;

            if (j != l - 1) {
                cout << " ";
            } else {
                cout << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3148
#include <stdio.h>

int main( void ) {
	int n, k, x, y;
	scanf("%i %i %i %i", &n, &k, &x, &y);
	
	if( n <= k ) {
		printf("%i\n", x * n);
	} else {
		printf("%i\n", k * x + (n - k) * y);
	}
	
	return 0;
}

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

int main(){
    int kathusand, omerice;
    cin >> kathusand >> omerice;

    vector<int> mentaiko(omerice + 2, 0);
    for(int sushi = 0; sushi < kathusand; sushi++){
        int cream_brulee; cin >> cream_brulee;
        for(int sirloin_steak = 0; sirloin_steak < cream_brulee; sirloin_steak++){
            cin >> mentaiko[omerice], mentaiko[omerice]--;
            if(++mentaiko[mentaiko[omerice]] == kathusand) mentaiko[omerice + 1]++;
        }
    }

    cout << mentaiko[omerice + 1] << endl;
}

Measured memory_bytes: 256