akhauriyash/Code-Regression huggingface dataset:
CMD=0
VAL=1

class Node
  attr_accessor :value,:left,:right
  def initialize (value)
    @value = value
    @left = nil
    @right = nil
  end

  def insert (value)
    if value < @value
      if @left.nil?
        @left = Node.new(value)
      else
        @left.insert(value)
      end
    else
      if @right.nil?
        @right = Node.new(value)
      else
        @right.insert(value)
      end
    end
  end

  def find(value)
    #p "@value:#{@value}"
    if value==@value
      print "yes\n"
    elsif value < @value
      #p "left:#{@left}"
      if @left.nil?
        print "no\n"
      else
        @left.find(value)
      end
    else
      #p "right:#{@right}"
      if @right.nil?
        print "no\n"
      else
        @right.find(value)
      end
    end
  end
  
  def print_inorder
    @left.print_inorder unless @left.nil?
    print " #{value}"
    @right.print_inorder unless @right.nil?
  end
  
  def print_preorder
    print " #{value}"
    @left.print_preorder unless @left.nil?
    @right.print_preorder unless @right.nil?
  end
end

num_of_cmd = STDIN.gets()
inputs = STDIN.read().split("\n").map{ |input| input.split(' ') }

root=nil
inputs.each do |input|
  if input[CMD] == 'insert'
    if root.nil?
      root = Node.new(input[VAL].to_i)
    else
      root.insert(input[VAL].to_i)
    end
  elsif input[CMD] == 'find'
    root.find(input[VAL].to_i)
  else
    root.print_inorder unless root.nil?
    print "\n"
    root.print_preorder unless root.nil?
    print "\n"
  end
end

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

int main() {
  string s;
  cin >> s;
  
  reverse(s.begin(), s.end());
  
  int i = 0;
  bool judge = true;
  while (i < s.size() && judge) {
    if (s.substr(i, 5) == "maerd" || s.substr(i, 5) == "esare")
      i += 5;
	else if (s.substr(i, 6) == "resare")
      i += 6;
	else if (s.substr(i, 7) == "remaerd")
	  i += 7;
	else
	  judge = false;
  }
  
  if (judge)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <map>

using i64 = long long;

const i64 MOD = 998244353;

std::map<std::string, i64> dic;

i64 dfs(std::string s) {
	if (dic[s]) return dic[s];
	if (s.size() == 0) return 1;
	i64 f = dfs(s.substr(0, s.size() - 1)) * (s.back() - 47);
	for (int i = 1; i <= s.size(); ++i) {
		std::string c = s.substr(s.size() - i, i);
		for (int j = 2; j <= s.size() / i; ++j) {
			for (int k = 0; k < i; ++k)
				c[k] = (c[k] ^ 48) & (s[s.size() - i * j + k] ^ 48) ^ 48;
			( f += dfs(c) * dfs(s.substr(0, s.size() - i * j)) ) %= MOD;
		}
	}
	return dic[s] = f;
}

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);

	std::string s;
	std::cin >> s;
	std::cout << dfs(s);

	return 0;
}


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

int main() {
    int n; cin >> n; long long arr[n]; for (int i = 0; i < n; i ++) cin >> arr[i];
    sort(arr, arr + n); long long ans = 0; 
    for (int i = 0; i < n-1; i ++) {
        if (i == 0) {ans += arr[n-1]; continue;}
        if (i % 2 == 1) {ans += arr[n-(i/2+2)];}
        else {ans += arr[n-(i/2+1)];}
    } cout << ans << endl;
}

Measured memory_bytes: 5156
<?php
while(1) {
$f = trim(fgets(STDIN));
if($f == 0) {
    break;
}
$c =1;
$vc = 0;
$v = 0;
$flag = false;
while($c <= 12) {
    list($a,$b) = explode(" ",fgets(STDIN));
    $vc = intval($a) - intval($b);
    $v += $vc;
    if($v >= $f && $flag == false) {
        print $c . PHP_EOL;
        $flag = true;
    }
    $c++;
    if($c == 13 && $flag == false) {
        print 'NA' . PHP_EOL;
    }
}
}



Measured memory_bytes: 9260
#include <cstdio>
#include <algorithm>

using std::min;

const int MAXN=100005;

int main()
{
    int N,K,diffs=0;
    char str[MAXN];

    scanf("%d%d%s",&N,&K,str);

    for (int i=1;i<N;++i)
        if (str[i]!=str[i-1]) diffs++;
    printf("%d",min(N-1-diffs+2*K,N-1));

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
 
#define ll long long int
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);
#define MOD 998244353
#define ll_MAX 19223372036859
#define endl "\n"
inline ll absdiff(ll a,ll b){ return (a>b)?a-b:b-a;}
ll fast_expo(ll x,ll p){if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
ll gcd(ll a,ll b){if(a==0||b==0) return a+b;  else return gcd(b%a,a); }

int main()
{
    fast
    ll q;q = 1;
    // cin>>q;
    for (ll t = 0; t < q; ++t)
    {
        ll n;cin>>n;
        string str1,str2,ans;cin>>str1>>str2;
        for(ll i=0;i<n;++i){
            ans.pb(str1[i]);
            ans.pb(str2[i]);
        }

        cout<<ans;
    }
    return 0;
}   

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
const int Mod = 1e9 + 7;
int Ad(int x, int y) { return ((x + y) > Mod) ? (x + y - Mod) : (x + y); }
int Dc(int x, int y) { return ((x - y) < 0) ? (x - y + Mod) : (x - y); }
int Ml(int x, int y) { return (long long)x * y % Mod; }
int ksm(int x, long long y) {
	int ret = 1;
	for (; y; y >>= 1, x = Ml(x, x))
		if (y & 1ll)
			ret = Ml(ret, x);
	return ret;
}
struct Matrix {
	int r, c, A[2][2];
	Matrix() : r(0), c(0) {}
	Matrix(int _r, int _c, int a00, int a01, int a10, int a11) : r(_r), c(_c) {
		A[0][0] = a00;
		A[0][1] = a01;
		A[1][0] = a10;
		A[1][1] = a11;
	}
	void Print() {
		printf("r : %d c : %d\n", r, c);
		for (int i = 0; i < r; ++i) {
			for (int j = 0; j < c; ++j)
				printf("%d ", A[i][j]);
			printf("\n");
		}
	}
};
Matrix operator*(const Matrix &a, const Matrix &b) {
	Matrix ret;
	ret.r = a.r;
	ret.c = b.c;
	for (int i = 0; i < ret.r; ++i)
		for (int j = 0; j < ret.c; ++j) {
			ret.A[i][j] = 0;
			for (int k = 0; k < a.c; ++k)
				ret.A[i][j] = Ad(ret.A[i][j], Ml(a.A[i][k], b.A[k][j]));
		}
	return ret;
}
void ksm(Matrix &ans, Matrix x, long long y) {
	for (; y; y >>= 1, x = x * x)
		if (y & 1) ans = ans * x;
}
int eup, edown, H, W, ud, lr;
const int NH = 1e3 + 5;
char base[NH][NH];
long long K;
int main() {
	scanf("%d%d%lld", &H, &W, &K);
	for (int i = 1; i <= H; ++i) scanf("%s", base[i] + 1);
	for (int i = 1; i <= W; ++i) if (base[1][i] == '#') ud += (base[1][i] == base[H][i]);
	for (int i = 1; i <= H; ++i) if (base[i][1] == '#') lr += (base[i][1] == base[i][W]);
	if (ud && lr)
		printf("1\n");
	else if (ud || lr) {
		Matrix ans(1, 2, 1, 1, 0, 0);
		int cnt = 0;
		for (int i = 1; i <= H; ++i)
			for (int j = 1; j <= W; ++j)
				cnt += (base[i][j] == '#');
		int con = 0;
		if (ud) {
			for (int i = 2; i <= H; ++i)
				for (int j = 1; j <= W; ++j)
					if (base[i][j] == '#')
						con += (base[i][j] == base[i-1][j]);
		} else {
			for (int i = 1; i <= H; ++i)
				for (int j = 2; j <= W; ++j)
					if (base[i][j] == '#')
						con += (base[i][j] == base[i][j-1]);
		}
		Matrix b(2, 2, cnt, 0, Dc(0, con), ud | lr);
		ksm(ans, b, K-1);
		printf("%d\n", ans.A[0][0]);
	} else {
		int cnt = 0;
		for (int i = 1; i <= H; ++i)
			for (int j = 1; j <= W; ++j)
				cnt += (base[i][j] == '#');
		printf("%d\n", ksm(cnt, K - 1));
	}
	return 0;
}

Measured memory_bytes: 4220
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int H,W,A,B;
    cin >> H >> W >> A >> B;
    int ans[H][W];
    rep(i,0,H)rep(j,0,W)ans[i][j] = 0;

    rep(i,0,B)rep(j,0,A)ans[i][j] = 1;
    rep(i,B,H)rep(j,A,W)ans[i][j] = 1;

    rep(i,0,H){
        rep(j,0,W){
            cout << ans[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 5120
#include <cstdio>
#include <algorithm>
#include <vector>
 
using namespace std;
typedef long long ll;
 
const ll MOD = 1000000007;
 
int n;
ll fact[100005];
int pos1, pos2;
 
void extgcd(ll a, ll b, ll *x, ll *y) {
    ll xx, yy;
    if (b == 0) {
        *x = 1;
        *y = 0;
    } else {
        ll q = a / b;
        ll r = a % b;
        extgcd(b, r, &xx, &yy);
        *x = yy;
        *y = xx - q * yy;
    }
}
 
ll inv(ll a) {
    ll x, y;
    extgcd(a, MOD, &x, &y);
    return (x + MOD) % MOD;
}
 
ll combination(int n, int r) {
    return fact[n] * inv(fact[r]) % MOD * inv(fact[n - r]) % MOD;
}
 
int main() {
    scanf("%d", &n);
    ll f = 1;
    fact[0] = 1;
    for (int i = 1; i <= 100004; i ++) {
        f = (f * i) % MOD;
        fact[i] = f;
    }
    vector<int> seen(n + 1, -1);
    for (int i = 0; i < n + 1; i ++) {
        int a;
        scanf("%d", &a);
        if (seen[a] >= 0) {
            pos1 = seen[a];
            pos2 = i;
        }
        seen[a] = i;
    }
    int N = n + 1;
    int len_I = pos1;
    int len_III = N - pos2 - 1;
    for (int k = 1; k <= N; k ++) {
        ll sum;
        int l_min = max(k - 1 - len_III, 0);
        int l_max = min(len_I, k - 1);
        if (l_min <= l_max) {
            sum = combination(len_I + len_III, k - 1);
        } else {
            sum = 0;
        }
        sum = (combination(N, k) - sum + MOD) % MOD;
        printf("%lld\n", sum);
    }
}

Measured memory_bytes: 2432
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n,m;cin>>n>>m;
    vector<ll>ab[200001];
    for(ll i=0;i<m;i++){
        ll a,b;cin>>a>>b;
        a--;b--;
        ab[a].pb(b);
        ab[b].pb(a);
    }
    for(ll i=0;i<siz(ab[0]);i++){
        for(ll j=0;j<siz(ab[ab[0][i]]);j++){
            if(ab[ab[0][i]][j]==n-1){
                cout<<"POSSIBLE"<<endl;
                return 0;
            }
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------




Measured memory_bytes: 12776
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt int Q[100005]={0}
#define mp make_pair
#define test() int t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<int>()) 
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(int i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(int i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
bool check(string s)
{
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        if(s[i]!=s[n-1-i])
            return false;
    }
    return true;
}
int main()
{
    fastio();
    int n;
    cin>>n;
    ll a[n];
    int f[n+1]={0};
    map <ll,ll> m;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        m[a[i]]++;
    }
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        if(f[a[i]]==0)
        {
            ll d = m[a[i]];
            d = (d*(d-1))/2;
            ans+=d;
            f[a[i]]=1;
        }
    }
    for(int i=0;i<n;i++)
    {
        ll sum = ans;
        ll d = m[a[i]];
        sum = sum - (d*(d-1))/2;
        d--;
        sum = sum + (d*(d-1))/2;
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 13312
#include <stdio.h>
int main(void){
  int i,j,k;
  int dice1[7];
  int dice2[7];
 
  for(i=1;i<=6;i++) scanf("%d",&dice1[i]);                                                          
  for(i=1;i<=6;i++) scanf("%d",&dice2[i]);
  
  for(i=1;i<=6;i++){
      if(dice2[1]==dice1[1]) {
         for(j=1;j<=4;j++){
            for(k=1;k<=7;k++){
              if(k==7){
                  printf("Yes\n");
                  return 0;
              }
              if(dice2[k]!=dice1[k]) break;
            }
              
             dice2[0]=dice2[2];
             dice2[2]=dice2[3];
             dice2[3]=dice2[5];
             dice2[5]=dice2[4];
             dice2[4]=dice2[0];
          }
      }
      
      dice2[0]=dice2[1];
      switch(i){
          
          case 3:
          dice2[1]=dice2[3];
          dice2[3]=dice2[6];
          dice2[6]=dice2[4];
          dice2[4]=dice2[0];
          break;
          
          default:
          dice2[1]=dice2[2];
          dice2[2]=dice2[6];
          dice2[6]=dice2[5];
          dice2[5]=dice2[0];
          break;
      }
  }
  
  printf("No\n");
  
  return 0;
}
          


Measured memory_bytes: 2104
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

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

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

struct edge {
    llong cost;
    llong to;
};

vvecllong WarshallFloyd(vector<vector<edge>> edges) {
    llong N = edges.size();

    // 初期化処理
    vvecllong minDist(N, vecllong(N, INF));
    FOR(i, N) {
        for_each(edges[i].begin(), edges[i].end(), [&](edge e){
            minDist[i][e.to] = e.cost;
        });
    }

    FOR(k, N) {
        FOR(i, N) {
            FOR(j, N) {
                chmin(minDist[i][j], minDist[i][k] + minDist[k][j]);
            }
        }
    }

    return minDist;
};

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

    llong N, M, R;
    cin >> N >> M >> R;

    vecllong visit(R);
    FOR(i, R) {
        llong r;
        cin >> r;
        r--;
        visit[i] = r;
    }

    vector<vector<edge>> edges(N);
    edges.resize(N);
    FOR(i, M) {
        llong from, to, cost;
        cin >> from >> to >> cost;
        from--;
        to--;

        edges[from].push_back({cost, to});
        edges[to].push_back({cost, from});
    }

    vvecllong minDist = WarshallFloyd(edges);

    llong ans = INF;
    sort(visit.begin(), visit.end());

    do {
        llong cost = 0;
        FOR(i, R - 1) {
            cost += minDist[visit[i]][visit[i + 1]];
        }
        ans = min(ans, cost);
    } while(next_permutation(visit.begin(), visit.end()));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Affine Cipher
 */
public class Main {

	static final char[][] hints = {{'t', 'h', 'i', 's'}, {'t', 'h', 'a', 't'}};

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = parseInt(br.readLine());

		for (int i = 0; i < n; i++) {
			String s = br.readLine();
			int[] c = cipher(s);
			char[] d = new char['z' + 1];
			for (int j = 0; j < 26; j++) {
				d[(char) (((c[0] * j + c[1]) % 26) + 'a')] = (char) (j + 'a');
			}
			StringBuilder sb = new StringBuilder();
			for (int j = 0; j < s.length(); j++) {
				if (s.charAt(j) == ' ') {
					sb.append(' ');
				} else {
					sb.append(d[s.charAt(j)]);
				}
			}
			System.out.println(sb.toString());
		}
	}

	static int[] cipher(String s) {

		int[] ret = new int[2];

		StringTokenizer st = new StringTokenizer(s);

		while (st.hasMoreTokens()) {

			String w = st.nextToken();

			if (w.length() == 4) {

				char[] hint;

				if (w.charAt(0) != w.charAt(w.length() - 1)) {
					hint = hints[0];
				} else {
					hint = hints[1];
				}

				for (int a = 0; a < 26; a++) {
					if (a % 2 != 0 && a % 13 != 0) {
						for (int b = 0; b < 26; b++) {
							String h = "";
							for (int i = 0; i < hint.length; i++) {
								h += (char) (((a * (hint[i] - 'a') + b) % 26) + 'a');
							}
							if (w.equals(h)) {
								ret[0] = a;
								ret[1] = b;
								return ret;
							}
						}
					}
				}
			}
		}

		return ret;
	}
}

Measured memory_bytes: 33344
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
using namespace std;

double dp[301][301][301];
double a[300];

int main(){
    int N;
    cin >> N;
    int counts[4] = {0, 0, 0, 0};
    for(int i = 0; i < N; i++){
        cin >> a[i];
        if(a[i] == 1){
            counts[1] += 1;
        }else if(a[i] == 2){
            counts[2] += 1; 
        } else if(a[i] == 3){
            counts[3] += 1;
        }
    }
    
    dp[0][0][0] = 0;
    for(int i = 1; i < N + 1; i++){
        for(int j = 0; j < N + 1; j++){
            for(int k = 0; k < N + 1; k++){
                dp[i][j][k] = 0;
            }
        }
    }

    for(int i = 0; i < N + 1; i++){
        for(int j = 0; j < N + 1; j++){
            for(int k = 0; k < N + 1; k++){
                if(i + j + k <= 0 || i + j + k > N){
                    continue;
                }
                dp[i][j][k] = 1.0 * N / (i + j + k);
                if(k >= 1){
                    dp[i][j][k] += 1.0 * k / (i + j + k) * dp[i][j][k-1];
                }
                if(j >= 1){ 
                    dp[i][j][k] += 1.0 * j / (i + j + k) * dp[i][j - 1][k + 1];
                } 
                if(i >= 1){
                    dp[i][j][k] += 1.0 * i / (i + j + k) * dp[i - 1][j + 1][k];
                }
            }
        }
    }
    
    printf("%.10f\n", dp[counts[3]][counts[2]][counts[1]]);

/*
    for(int i = 0; i < N + 1; i++){
        for(int j = 0; j < N + 1; j++){
            printf("[");
            for(int k = 0; k < N + 1; k++){
                printf("%.10f ", dp[i][j][k]);
            }
            printf("] ");
        }
        printf("\n");
    }
*/
    return 0;

}

Measured memory_bytes: 213248
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define X first
#define Y second
#define sz(v) (int)v.size()
using ord = tree<int, null_type, greater<int>, rb_tree_tag, tree_order_statistics_node_update>;
 
void solve();
 
main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
#ifdef ONPC
	freopen("in.txt", "r", stdin);
#endif
	int t = 1;
	//cin >> t;
	while (t--) solve();
	return 0;
}

set<int> Q;

void solve() {
	Q.insert(1);
	Q.insert(2);
	Q.insert(3);
	int a, b;
	cin >> a >> b;
	Q.erase(a);
	Q.erase(b);
	cout << (*Q.begin());
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	ll arr[n];
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	ll ans = 0;
	sort(arr, arr + n);
	ans += arr[n - 1];
	if (n == 2)
	{cout << ans; return 0;}
	int c = 1;
	for (int i = n - 2; i >= 0; i--)
	{
		ans += arr[i];
		c++;
		if (c == n - 1)
			break;
		ans += arr[i];
		c++;
		if (c == n - 1)
			break;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 5180
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}
 
ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
int a,b;
cin >> a >> b;
int A,B;
rep(i,100000) {
    double aa =i*0.08;
    double bb =i*0.1;
    int resa = aa/1;
    int resb = bb/1;
    if (resa==a && resb==b) {
        cout << i << "\n";
        return 0;
    }
}
cout << -1 << "\n";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef  long long int ll;
typedef long double ld;
#define pb  push_back
#define vll vector<ll>
#define mll map<ll,ll>
const double PI = 2*acos(0.0);
#define gcd(a,b)   __gcd((a),(b))
#define lcm(a,b)   ((a)/(__gcd((a),(b)))*(b))
#define INF         LLONG_MAX
#define ln  INT_MAX
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
int main() {
string s;
cin>>s;
if(s[s.size()-1]=='s'){cout<<s<<"es";}
else{cout<<s<<"s";}
return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  cin >> N;
  set<int> prime;
  for (int i = 2; i <= 55555; i++)
  {
    int val = i;
    for (int j = 2; j * j <= val; j++)
    {
      while (val % j == 0)
      {
        prime.insert(j);
        val /= j;
      }
    }
    if (val != 1)
      prime.insert(val);
  }
  // 5で割ったときに1余る素数を5つ選んだ場合，
  // それらの和は必ず5で割り切れる．
  // つまり合成数になる．
  int count = 0;
  for (auto a : prime)
  {
    if (a % 5 == 1)
    {
      if (0 < count)
        cout << " ";
      cout << a;
      count++;
    }
    if (count == N)
      break;
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 512
#include<cctype>
#include<string>
#include<algorithm>
#include<iostream>
#include<set>
#include<regex>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<map>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin >> s;

    for(int i = 0; i < s.size(); ++i) {

        if(s.at(i) == '?')
            cout << 'D';
        else
            cout << s.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 3784
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
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<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}

uintmax_t comb(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}

unsigned GetDigit(unsigned num){
    return log10(num)+1;
}

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

string o,e;
cin >> o >> e;
int olen = o.length();
int elen = e.length();
vector<char> v(olen + elen);
rep(i,olen+elen){
    if(i % 2 == 0) v[i] = o[i/2];
    else v[i] = e[i/2];
}
rep(i,olen + elen) cout << v[i];



//////////////////////////////////////////////////////
return 0;}


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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)


typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////
#define all(c) c.begin(),c.end()

bool comp(l_l a,l_l b){
    return a.fi>b.fi;
}

int main(){fastio
    ll x,y,a,b,c;cin>>x>>y>>a>>b>>c;
    vector<l_l>v;
    rep(i,1,a){
        ll t;cin>>t;
        v.pb({t,1});
    }
    rep(i,1,b){
        ll t;cin>>t;
        v.pb({t,2});
    }
    rep(i,1,c){
        ll t;cin>>t;
        v.pb({t,3});
    }
    sort(all(v),comp);
    ll ans=0;
    ll cnt=0;
    ll X=x+y;
    for(auto obj:v){
        if(obj.se==1){
            if(x>0){
                x--;
                ans+=obj.fi;
                cnt++;
            }
        }else if(obj.se==2){
            if(y>0){
                y--;
                ans+=obj.fi;
                cnt++;
            }
        }else{
            ans+=obj.fi;
            cnt++;
        }
        if(cnt==X)break;
    }
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 10476
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define pii pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<ii>
#define li long int
#define ll long long
#define lli long long int
#define vlli vector<lli>
#define vll vector<ll>
#define vl vector<long>
#define ld long double
#define ulli unsigned long long int
 
using namespace std;

void solve() {
    double s, d, t;
    cin>>d>>t>>s;
    if((d / s) <= t)
        cout<<"Yes";
    else cout<<"No";
}
// s = d / t; t = d / s
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
        solve();
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
int dy[] = {-1,0,1,0};
int dx[] = {0,1,0,-1};

int main(void){
    int n;
    cin >> n;
    vector<vector<int>> d(n);
    vector<vector<bool>> space(n);
    rep(y,n) {
        d[y] = vector<int>(n);
        space[y] = vector<bool>(n);
    }
    rep(y,n) rep(x,n) {
        d[y][x] = min({y, n-y-1, x, n-x-1});
    }
    int sum = 0;
    rep(i,n*n) {
        int p;
        cin >> p;
        p--;
        int y = p/n;
        int x = p%n;
        sum += d[y][x];
        space[y][x] = true;
        using P = pair<int,int>;
        queue<P> qu;
        qu.push({y,x});
        while(qu.size()) {
            int cy = qu.front().first;
            int cx = qu.front().second;
            qu.pop();
            int cost = space[cy][cx] ? 0 : 1;
            rep(dir,4){
                int ny = cy + dy[dir];
                int nx = cx + dx[dir];
                if (ny >= n || nx >= n || ny < 0 || nx < 0) continue;
                if (d[ny][nx] > d[cy][cx] + cost) {
                    d[ny][nx] = d[cy][cx] + cost;
                    qu.push({ny, nx});
                }
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 4628
using System;
using System.Linq;

namespace ABC154D
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var N = NK[0];
            var K = NK[1];
            var ps = Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray();
            var exs = ps.Distinct().ToDictionary(x => x, x => ((x * (1 + x)) / 2) / x);

            var tmpex = 0.0;
            var ans = 0.0;
            for (var i = 0; i <= N - K; i++)
            {
                if (i == 0)
                {
                    for (var j = i; j < i + K; j++)
                        tmpex += exs[ps[j]];
                }
                else
                {
                    tmpex -= exs[ps[i - 1]];
                    tmpex += exs[ps[i + K - 1]];
                }

                ans = Math.Max(ans, tmpex);
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 31964
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int n, m,a,b,high=9999999,low=0;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		if (a > low)low = a;
		if (b < high)high = b;
	}

	if (low > high)cout << 0 << endl;
	else cout << (high - low + 1) << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
const int inf = 1000000000; //10^9
int main()
{
  int N;
  cin >> N;
  vector<int> X(N);
  rep(i, N) cin >> X.at(i);
  sort(X.begin(), X.end());
  int L = X.at(0); int R = X.at(N - 1);
  int ans = inf;
  for (int i = L; i <= R; i++) { //開催地i
    int cost = 0; //体力
    for (int j = 0; j < N; j++) { //人がいる地点j
      cost += (X.at(j) - i) * (X.at(j) - i); //体力の総和
    }
    ans = min(ans, cost); //開催地をずらしていき、それぞれの体力の総和を比較する
  }
  cout << ans << endl;
  return 0;
}

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

#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;

const ll oo=1e18;
const int MOD=1000000007;
const int INF=1000000000;
const ld EPS=0.000000001;

int dp[100005][3],n,a,b,c;

signed main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    cin>>a>>b>>c;
    dp[1][0]=a;
    dp[1][1]=b;
    dp[1][2]=c;
    for(int i=2;i<=n;++i) {
        cin>>a>>b>>c;
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
    return 0;
}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
#define guard(x) if( not ( x ) ) continue;
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename T>
struct Maybe {
   T x;
   bool valid;
   Maybe() : valid(false) {}
   Maybe(T x_) : x(x_), valid(true) {}
   operator T() const {
      assert( valid );
      return x;
   }
};

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   std::vector<Int> edges[64];
   std::vector<Int> ids;
   std::vector<Int> ts;
   std::vector<Int> us;
   Int n, m;
   Int id;
   Int dfs(Int i, Int prev) {
      ids[i] = id;
      id += 1;
      Int res = 0;
      for(Int next : edges[i]) {
         if( next == prev ) continue;
         if( ids[next] != -1 ) {
            ts[next] -= 1;
            ts[i]    += 1;
         }
      }
      for(Int next : edges[i]) {
         if( next == prev ) continue;
         if( ids[next] == -1 ) {
            res += dfs(next, i);
            us[i] += us[next];
         }
      }
      us[i] += ts[i];
      dumpll(i, us[i]);
      if( us[i] == 0 and prev != -1 ) {
         res += 1;
      }
      return res;
   }
   void solve() {
      scan(n, m);
      ids.resize(n+1, -1);
      ts.resize(n+1, 0);
      us.resize(n+1, 0);
      id = 0;
      for(Int i = 0; i < m; ++i) {
         Int a, b; scan(a, b);
         edges[a].push_back(b);
         edges[b].push_back(a);
      }
      Int res = dfs(1, -1);
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

char str[128];
long long k;

int main()
{
  char ans;
  long long length;
  
  scanf("%s %lld", str, &k);
  
  length = strlen(str);
  for (long long i = 0; i < length; i++) {
    if (i == k - 1) {
      ans = str[i];
      break;
    } else if (str[i] != '1') {
      ans = str[i];
      break;
    }
  }
  
  printf("%c\n", ans);
  
  return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int) (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9+7

using namespace std;

vector<int> board[7][7];
int n, m, p;
int dx[17] = {1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 0};
int dy[17] = {0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1, 0};
int dz[17] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1};

int judge(){
  REP(i, 7) REP(j, 7) REP(k, 7) {
    if(k >= board[i][j].size()) break;
    int tmp = board[i][j][k];
    if(tmp == 0) break;
    REP(l, 17){
      int nx = i; int ny = j; int nz = k;
      int count = 1;
      nx += dx[l]; ny += dy[l]; nz += dz[l];
      while(0 <= nx and nx < 7 and 0 <= ny and ny < 7 and 0 <= nz and nz < board[nx][ny].size()){
        if(board[nx][ny][nz] == tmp) count++;
        else break;
        nx += dx[l]; ny += dy[l]; nz += dz[l];
      }
      if(count >= m) return board[i][j][k];
    }
  }
  return 0;
}

int main(){
  while(cin >> n >> m >> p and n + m + p){
    memset(board, 0, sizeof(board));
    int win = 0;
    int turn = 0;
    REP(i, p){
      int x, y; cin >> x >> y; x--; y--;
      board[x][y].push_back(i%2 ? -1 : 1);
      if(win == 0) {
        win = judge();
        if(win) { turn = i+1; }
      }
    }
    if(win) cout << (win == 1 ? "Black" : "White") << " " << turn << endl;
    else cout << "Draw" << endl;
  }
  return 0;
}

Measured memory_bytes: 3228
#include <iostream>
#include <string>
#include <functional>
#include <algorithm>
using namespace std;
int main(void){

	while(1){
		int a, b;
		cin >> a >> b;
		if( a == 0 && b == 0 ){
			return 0;
		}
		if( a > b ){
			int temp;
			temp = a;
			a = b;
			b = temp;
		}
		cout << a << " " << b << endl;

	}
	return 0;
}


Measured memory_bytes: 3016
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
using namespace std;

void no()
{
    cout << -1;
    exit(0);
}

int main()
{

#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#endif


    string s;
    cin >> s;
    int n = (int)s.size();

    if (s[n - 1] == '1' || s[0] == '0')
        no();

    for (int i = 0; i < n - 1; ++i)
        if (s[i] != s[n - 2 - i])
            no();

    int v = 2, cur = 3;
    vector< pair<int,int> > out;

    out.push_back({1, 2});

    for (int i = 1; i <= (n - 1) / 2; ++i)
    {
        out.push_back({v, cur});
        ++cur;
        if (s[i] == '1')
            v = cur - 1;
    }

    for (; cur <= n; ++cur)
        out.push_back({v, cur});


    for (auto p : out)
        cout << p.first << ' ' << p.second << '\n';

}


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



int main(void){
    int n;
    cin >> n;
    vector<int>a;
    rep(i,n){
        int x;
        cin >> x;
        a.push_back(x);
    }
    sort(a.begin(),a.end());
    int num = a[0];
    int place = 0;
    int mn = 1000000001;
    int pre = 1000000001;
    int mplace = 0;
    while(pre>num){
        pre = num;
        for(int i=n-1;i>=0;i--){
            if(i != place){
                a[i] = a[i]%num;
                if(mn>a[i] &&a[i] >0){
                    mn = a[i];
                    mplace = i;
                }
            }
        }
        num = min(mn,a[place]);
        place = mplace;
    }
    
    cout << num <<endl;
  
    return 0;
}










































Measured memory_bytes: 892
#include<bits/stdc++.h>
#include <unordered_map>
#define int long long
//#define double long double
#define endl "\n"
#define PI 3.1415926535897932384626433
#define sp(x)   setprecision(x)
#define ceil(a,b)   (a+(b-1))/b
#define LCM(a,b)    (a*b)/__gcd(a,b)
#define all(v)  v.begin(),v.end()
#define alls(s,v)  s.begin(),s.end(),v
#define gena(arr,n,nxt)  generate(arr,arr+n, nxt)
#define genv(v,nxt)  generate(v.begin(),v.end(), nxt)
#define base ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define exit return 0;
#define is(x) cout << #x << " = " << x << endl;
using namespace std;
const int N=500000;
int nxt(){int x;cin >> x;return x;}
int32_t main()
{
    base
    int a=nxt(),b=nxt();
    cout<<a*b<<endl;
    exit
}


Measured memory_bytes: 3644
s = list(input())
l = list("keyence")
ans = "NO"
for i in range(len(s)):
    for j in range(len(s)-i):
        #del_s = s[i:i+j]
        part = s[:i] + s[i+j:]
        if part == l:
            ans = "YES"
            break
print(ans)


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

int main(){
	int n,k,x,y;
	std::cin >> n>>k>>x>>y;
	int ans=0;
	for (int i = 1; i <=n; i++) {
		/* code */
		if(i<=k)ans+=x;
		else ans+=y;
	}
	std::cout << ans << std::endl;
}
	

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;

typedef pair <int, int> pii;

int main()
{

	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	string s, t;
	ll x[4][4] = { {} };
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> x[i][j];
		}
	}
	if (x[0][0] - x[0][1] == x[1][0] - x[1][1] && x[1][0] - x[1][1] == x[2][0] - x[2][1] &&
		x[0][1] - x[0][2] == x[1][1] - x[1][2] && x[1][1] - x[1][2] == x[2][1] - x[2][2] &&
		x[0][0] - x[1][0] == x[0][1] - x[1][1] && x[0][0] - x[1][0] == x[0][2] - x[1][2] &&
		x[1][0] - x[2][0] == x[1][1] - x[2][1] && x[1][0] - x[2][0] == x[1][2] - x[2][2] )
	{
		cout << "Yes" << endl;

	}
	else
	{
		cout << "No" << endl;

	}




	//cout << ans << endl;
	//cout <<  << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

ll m;
vector<lvector> V;

void gen_increase_series(ll pos,lvector v) {
  if(v.back()>0) V.emplace_back(v);
  else {
    for(ll d=0;d+v[pos]<=m;++d) {
      v[pos+1]=v[pos]+d;
      gen_increase_series(pos+1,v);
    }
  }
  return;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,q,a,b,c,d,ans=-1,ans_;cin>>n>>m>>q;
  lvector e(n,0);e[0]++;
  vector<lvector> v(q);
  rep(i,q) {cin>>a>>b>>c>>d;a--,b--;v[i]=lvector{a,b,c,d};}
  gen_increase_series(0,e);
  for(lvector i:V) {
    ans_=0;
    for(lvector r:v) if(i[r[1]]-i[r[0]]==r[2]) ans_+=r[3];
    ans=max(ans_,ans);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 9020
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
		string S;
		cin >> S;
		int r = 0, b = 0;
		for ( int i = 0;  i < S.size(); i++ ) {
				if (S[i] == '0') r++;
				else if (S[i] == '1') b++;
		}

		cout << min(r,b) * 2 << endl;

		return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k,n=0;
  cin>>k>>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  vector<int> sa(n);
  int kyori=0;
  
  for(int i=0;i<n-1;i++){
    sa.at(i)=vec.at(i+1)-vec.at(i);
  }
  sa.at(n-1)=vec.at(n-1)-vec.at(0);
  if(sa.at(n-1)>k/2){
    sa.at(n-1)=k-sa.at(n-1);
  }
  
  sort(sa.begin(),sa.end());
  for(int i=0;i<n-1;i++){
    kyori+=sa.at(i);
  }
  cout<<kyori;
}

Measured memory_bytes: 1792