akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};

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

	int n;
	cin >> n;

	int a,odd=0;
	for(int i=0;i<n;i++){
		cin >> a;
		if(a%2 == 1) odd++;
	}
	if(odd%2==1) cout << "NO\n";
	else		cout << "YES\n";

	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val (H, W) = readInts()
  val S = (1..H).map { readString() }

  val INF = Int.MAX_VALUE / 2
  val N = H * W
  val dp = Array(N) { Array(N) { INF } }
  for (i in 0 until H) {
    for (j in 0 until W) {
      val c = S[i][j]
      if (c == '.') {
        dp[i * W + j][i * W + j] = 0
        val d = listOf(-1 to 0, 0 to 1, 1 to 0, 0 to -1)
        d.forEach {
          val ii = i + it.first
          val jj = j + it.second
          val cc = S.getOrNull(ii)?.getOrNull(jj)
          if (cc == '.') {
            dp[i * W + j][ii * W + jj] = 1
            dp[ii * W + jj][i * W + j] = 1
          }
        }
      }
    }
  }

//  for (i in 0 until N) {
//    for (j in 0 until N) {
//      val n = dp[i][j]
//      print(if (n == INF) '-' else n.toString())
//      print(" ")
//    }
//    println()
//  }

  for (k in 0 until N) {
    for (i in 0 until N) {
      for (j in 0 until N) {
        dp[i][j] = Math.min(dp[i][j], dp[i][k] + dp[k][j])
      }
    }
  }

  var result = 0
  for (i in 0 until N) {
    for (j in 0 until N) {
      val n = dp[i][j]
      if (n == INF) continue
      result = Math.max(result, n)
    }
  }
  println(result)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int N = 26, D;
vi last (N, -1);
vi CS (N);
vector<vi> SAT;

ld heuristic(int day, int choice) {
	ld res = SAT[day][choice];
	F0R(i, N) if (i != choice) {
		res -= CS[i] * (day - last[i]);
	} 
	return res;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> D;
	F0R(i, N) cin >> CS[i];
	SAT = vector<vi> (D, vi (N));
	F0R(i, D) F0R(j, N) cin >> SAT[i][j];

	F0R(i, D) {
		ld best = -INF; 
		int ind = -1;
		F0R(j, N) {
			ld score = heuristic(i, j);
			if (score > best) {
				best = score;
				ind = j;
			}
		}
		last[ind] = i;
		print(ind+1);
	}
}

Measured memory_bytes: 3708
sx,sy,tx,ty = map(int,input().split())
a = tx-sx
b = ty-sy
ans = ''
ans += 'U'*b+'R'*a
ans += 'D'*b+'L'*a
ans += 'L'+'U'*(b+1)+'R'*(a+1)+'D'
ans += 'R'+'D'*(b+1)+'L'*(a+1)+'U'
print(ans)

Measured memory_bytes: 3064
N = int(input())
C1 = input().split()
C2 = C1[:]

def bubbleSort(C, N):
    for i in range(N):
        for j in range(N-1, i, -1):
            if int(C[j][1]) < int(C[j-1][1]):
                tmp = C[j]
                C[j] = C[j-1]
                C[j-1] = tmp
        i += 1
    return C

def selectionSort(C, N):
    for i in range(N):
        minj = i
        for j in range(i, N):
            if int(C[j][1]) < int(C[minj][1]):
                minj = j
        if minj != i:
            tmp = C[minj]
            C[minj] = C[i]
            C[i] = tmp
        i += 1
    return C

bubbleSort_result = ' '.join(bubbleSort(C1, N))
selectionSort_result = ' '.join(selectionSort(C2, N))

print(bubbleSort_result)
print('Stable')
print(selectionSort_result)
if bubbleSort_result == selectionSort_result:
    print('Stable')
else:
    print('Not stable')

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    ll n,k;
    cin >> n >> k;

    n = n % k;

    n = min(n, abs(n - k));

    cout << n << endl;

    return 0;
}


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

#define MAX(A, B) (((A) > (B)) ? (A) : (B))

int checknum (long* list) {
  int a = *(list) * 100 + *(list + 1) * 10 + *(list + 2);
  if ((a == 132) || (a == 123) || (a == 312)) {
    return 0;
  }
  else {return 1;}
  
  return 0;
}

int checknumb(long* list) {
  
  int f = 0;
  f = checknum(list + 1);
  int a = *(list) * 100 + *(list + 1) * 10 + *(list + 3);
  int b = *(list) * 100 + *(list + 2) * 10 + *(list + 3);
  a -= 132;
  b -= 132;
  f *= a * b;
  return f;
}

int main() {
  long INF = 1000000000 + 7;
  int N;
  scanf("%d", &N);
  
  long** list = malloc(64 * sizeof(long*));
  
  for (int i=0; i<64; i++) {
    
    *(list + i) = malloc(6 * sizeof(long));
    
    *(*(list + i)) = i/16 + 1;
    *(*(list + i) + 1) = i%16/4 + 1;
    *(*(list + i) + 2) = i%4 + 1;
    
    if (checknum(*(list + i))) {
      *(*(list + i) + 4) = 1;
    }
    else {
      *(*(list + i) + 4) = 0;
    }
  }
  
  int digit = 3;
  long* p;
  int q;
  while (digit < N) {
    for (int i=0; i<64; i++) {
      p = *(list + i);
      for (int j=1; j<5; j++) {
        *(p + 3) = j;
      	q = *(p + 1) * 16 + *(p + 2) * 4 + *(p + 3) - 21;
        
        if (checknumb(p)) {
          *(*(list + q) + 5) += *(p + 4);
        }
      }
    }
    for (int i=0; i<64; i++) {
      p = *(list + i);
      *(p + 4) = *(p + 5) % INF;
      *(p + 5) =0;
    }
    digit++;
  }
  
  long ans = 0;
  for (int i=0; i<64; i++) {
    ans += *(*(list + i) + 4);
    ans %= INF;
  }
  ans %= INF;
  printf("%ld", ans);
  return 0;
}

Measured memory_bytes: 128
#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 gcd(int x, int y) {
    if (x % y == 0) return y;
    return gcd(y, x % y);
}

int main() {
    int x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
    return 0;
}



Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

using ll = long long int;

struct shop{
	 ll a,b;
};

int main(){
	int n,m;
	cin >> n >> m;
	vector<shop> slist(n);
	
	for(auto &i : slist){
		cin >> i.a >> i.b;
	}
	
	sort(slist.begin(),slist.end(),[](shop &s1,shop &s2){return s1.a < s2.a;});

	ll i = 0,money = 0;

	while(m > 0){
		m -= slist[i].b;
		money += slist[i].a * slist[i].b;
		++i;
	}
	
	if(m < 0){
		money -= abs(m) * slist[i-1].a;
	}
	cout << money << endl;
	
}

Measured memory_bytes: 1920
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ios>//左右揃え
#include<iomanip>//setwで幅指定

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007LL

int main(void) {
    int s, w;
    cin >> s >> w;
    s <= w ? cout << "unsafe" << endl : cout << "safe" << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    for (int i = 0; i < N - 1; i++) cin >> C[i];

    int ans = B[A[0] - 1];
    for (int i = 1; i < N; i++) {
        ans += B[A[i] - 1];
        if (A[i - 1] + 1 == A[i]) ans += C[A[i - 1] - 1];
    }

    cout << ans << endl;
}

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

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main(void)
{
    int N;
    cin >> N;
    auto H = vc(int, N);
    fa(i, H) cin >> i;
    int ans = 0, cnt = 0;
    for (int i = 1; i < N; i++)
    {
        if (H[i-1] < H[i])
        {
            ans = max(ans, cnt);
            cnt = 0;
        }
        else cnt++;
    }
    cout << max(ans, cnt) << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<climits>
using namespace std;

int main() {
  int N;
  int x=-1;
  int y=-1;
  int z=-1;
  long Y;
  int tmp1=0;
  int tmp2=0;
  int ans=0;
  int cnt=0;

  cin >> N >> Y;

  if(Y%1000 != 0){
    cout << x << " " << y << " " << z << endl;
    return 0;
  }
  
  for(int i = 0; i <=N; i++){
    x=i;
    if(i*10000 <= Y){
      tmp1 = Y-i*10000;

      for(int j = 0; j <= N-i; j++){
        y=j;
        if(j*5000 <= tmp1){
          tmp2 = tmp1 - j*5000;

          int k=N-i-j;
            z=k;
            if(tmp2/1000 == k && tmp2%1000==0){
              cout << x << " " << y << " " << z << endl;
              return 0;
            }
        }
      }
    }
  }

  x=-1;
  y=-1;
  z=-1;
  cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
     
#define ll long long
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
#define pld(x) printf("%lld\n",x)
#define pd(x) printf("%d\n",x)
#define forn(i,a,n) for(int i = a; i < n ; i++)
const int MOD = 1e9+7, N = 1e7 + 10;



int main() {
    ll n1,n2,gcd,lcm,i;
    cin >> n1 >> n2;
    for (i = 1; i <= n1 && i <= n2; ++i) {
        
        // check if i is a factor of both integers
        if (n1 % i == 0 && n2 % i == 0)
            gcd = i;
    }
    lcm = (n1 * n2) / gcd;
    cout << lcm << endl;
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;

const int mod = 1e9 + 7;

const int N = 3005;

int n, dp[N][N], pref[N][N];

string s;

int add(int x, int y) {
    return (1ll * x + 1ll * y) % mod;
}

int mul(int x, int y) {
    return (1ll * x * 1ll * y) % mod;
}

int del(int x, int y) {
    return ((1ll * x - 1ll * y) % mod + mod) % mod;
}

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    cin >> s;
    s = "++" + s;
    dp[1][1] = 1;
    pref[1][1] = 1;
    for(int j = 2; j <= n; j++)
        pref[1][j] = add(pref[1][j], pref[1][j - 1]);
    for(int i = 2; i <= n; i++) {
        for(int j = 1; j <= i; j++) {
            if(s[i] == '<')
                dp[i][j] = add(dp[i][j], pref[i - 1][j - 1]);
            else
                dp[i][j] = add(dp[i][j], del(pref[i - 1][n], pref[i - 1][j - 1]));
        }
        for(int j = 1; j <= n; j++) {
            pref[i][j] = dp[i][j];
            pref[i][j] = add(pref[i][j], pref[i][j - 1]);
        }
    }
    int sum = 0;
    for(int i = 1; i <= n; i++)
        sum = add(sum, dp[n][i]);
    cout << sum;
}


Measured memory_bytes: 70784
import math
N,D = map(int,input().split())
X = [list(map(int,input().split())) for _ in range(N)]
cnt = 0
for i in range(N):
    for j in range(i+1,N):
        num = 0
        for k in range(D):
            num += (X[i][k]-X[j][k])**2
        if math.sqrt(num) == int(math.sqrt(num)):
            cnt += 1
print(cnt)

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

using namespace std;

typedef long long ll;
typedef long long unsigned int llui;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef set<int> si;
typedef map<string, int> msi;

#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-9
#define DEBUG(x) cout<< '>' << #x << ':' << x << "\n";
#define all(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define sz(a) int((a).size())
#define UNIQUE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define clr(a) memset(a,0,sizeof(a))
#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;

inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }

#define LSOne(S) (S&(-S))

const double pi = acos(-1);

template<class T> inline T gcd(T a,T b) //NOTES:__gcd(0,0) gives exception
  {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}

int cmp(double x, double y = 0, double tol = EPS) {
    return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

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

/*bool sortby(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
    return (a.second < b.second);
}*/

const int MAX_N = 123456;

//int arr[MAX_N];

int main() {
    int N,A,B;
    scanf("%d%d%d",&N,&A,&B);
    int TC=12345;
    while(TC--){
        if(A<N && A+1!=B)
            A++;
        else if(A>1)
            A--;
        else{
            printf("Borys\n");
            return 0;
        }
        if(B>1 && A+1!=B)
            B--;
        else if(B<N)
            B++;
        else{
            printf("Alice\n");
            return 0;
        }
    }
    printf("Draw\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;

const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int c[50][26];
char s[50][50];
int cnt[26];

int main(){
	int n;
	
	cin >> n;
	
	REP(i,n){
		scanf("%s", s[i]);
		
		int len = strlen(s[i]);
		
		REP(j,len){
			c[i][s[i][j] - 'a']++;
		}
	}
	
	REP(i,26){
		cnt[i] = 5000;
		
		REP(j,n){
			cnt[i] = min(cnt[i],c[j][i]);
		}
	}
	
	REP(i,26){
		REP(j,cnt[i]) printf("%c", 'a'+i);
	}
	
	puts("");
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	int start = 0;
	int end = 0;

	if (A >= C) {
		start = A;
	}
	else if (A < C) {
		start = C;
	}

	if (B <= D) {
		end = B;
	}
	else if (B > D) {
		end = D;
	}

	if (end - start > 0) {
		cout << end - start << endl;
	}
	else {
		cout << 0 << endl;
	}
}
	


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<=0 && b>=0){ puts("Zero");return 0; }
	if(a>0){ puts("Positive");return 0; }
	if((b-a+1)&1) puts("Negative");
	else puts("Positive");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef long double db;
#define pb push_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)-v.begin()
#define lb(v,val) lower_bound(v.begin(),v.end(),val)-v.begin()
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define PI 3.1415926535
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for( i=n-1;i>=0;i--)
#define rep(i,n) for( i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int M = 1e9 + 7;
int INF = 1e6;

ll n, m;



int main() {
	// your code goes here
	IOS;

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll i, j, t, k, x, y, z,  N;
	cin >> n;
	ll a[n];
	ll cnt = 0;
	ll sum = 1000;
	ll itm = 0;
	rep(i, n) {
		cin >> a[i];
	}
	for (i = 0; i < n - 1 ; i++) {
		if (cnt == 0) {
			if (a[i + 1] <= a[i])
				continue;
			else {
				itm = sum / a[i];
				sum -= itm * a[i];
				cnt ^= 1;
			}
		}
		else {
			if (a[i + 1] >= a[i])
				continue;
			else {
				sum += itm * a[i];
				itm = 0;
				cnt ^= 1;
			}
		}
	}
	if (cnt == 1) {
		sum += itm * a[n - 1];
		itm = 0;
		cnt ^= 1;
	}
	cout << sum;


	return 0;
}

Measured memory_bytes: 3652
from collections import deque
import sys
input = sys.stdin.readline
n, x, y = map(int, input().split())
g = dict()
for i in range(n):
    if i == 0:
        g[i] = [i+1]
    elif i == n-1:
        g[i] = [i-1]
    else:
        g[i] = [i-1, i+1]
g[x-1].append(y-1)
g[y-1].append(x-1)
# print(g)
distance = [0]*(n-1)
# 1番ノードから各ノードへの最短距離を求めていく.
for i in range(n):
    queue = deque()
    visited = [0]*n
    # まず処理される予定のノードが格納されているqueueに最初のノードを格納する
    queue.append(i)
    while queue:
        target = queue.popleft()
        for j in g[target]:
                if visited[j] == 0 or visited[j] > visited[target] + 1:
                    visited[j] = visited[target] + 1
                    queue.append(j)
    for k in range(len(visited)):
        if k > i:
            if visited[k] >= 1:
                distance[visited[k]-1] += 1
    # print(f"{i}番ノードからの各ノードへの最短距離は{visited}である")
for l in distance:
    print(l)

Measured memory_bytes: 48092
#include <cstdio>
#include <iostream>

using namespace std;



int main() {
    string s;
    cin >> s;
    int sum[2] = {0,0};
    for (int j = 0;j<=1;j++) {
        int start = j;
        for (int i = 0;i<s.size();i++) {
            if (s[i]=='0') {
                if (start == 1) sum[j]++;
            }
            if (s[i]=='1') {
                if (start == 0) sum[j]++;
            }
            start = (start == 0)?1:0;
        }
    }
    if (sum[0]<=sum[1])cout<< sum[0]<<endl;
    if (sum[0]>sum[1])cout<< sum[1]<<endl;

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
 
using namespace std;
static const int MAX = 1000;

void trace(int A[], int N)
{
	int i;
	for(i=0; i<N; i++){
		if(i>0)cout << " ";
		cout << A[i];
	}
	cout << endl;
}

void insertionSort(int A[], int N)
{
	int i, j, v;
	
	for(i=1; i<N; i++){
		v = A[i];
		j = i-1;
		while(j>=0 && A[j]>v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		
		trace(A, N);
	}
}
 
int main()
{
    int N, i, j;
    int A[MAX];
     
    cin >> N;
    for (i=0; i<N; i++)cin >> A[i];
    
    trace(A, N);
    insertionSort(A, N);

    return 0;
}

Measured memory_bytes: 3020
Imports System

Public Class Program
    Public Shared Sub Main(args As String())

        'Input(0)=a,Input(1)=b
        Dim Input() As String = Console.ReadLine().Split(" ")
        If ((Integer.Parse(Input(0)) * Integer.Parse(Input(1))) Mod 2) = 0 Then
            Console.WriteLine("Even")
        Else
            Console.WriteLine("Odd")

        End If

    End Sub
End Class

Measured memory_bytes: 13140
while 1:
    n,w = map(int,raw_input().split())
    if n == 0: break
    v = [0.]*11
    m = 0
    for i in range(n):
        p = int(raw_input())/w
        v[p] += 1.
        m = max(m,p)
    vm = max(v)
    ans = 0.01+sum((v[i]/vm)*(1-i*1.0/m) for i in range(m))
    print ans

Measured memory_bytes: 4252
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N;
    vec d(N);
    rep(i,N) cin>>d[i];
    vec ott(12,0);
    rep(i,N){
        if(d[i] == 0){
            cout<<0<<endl;
            return 0;
        }else if(d[i] == 12 && N== 1){ 
          cout<<12<<endl; 
          return 0; 
        }else {
            --d[i];
            ++ott[d[i]];
            if(ott[d[i]] + (d[i] / 11) == 3){
                cout<<0<<endl;
                return 0;
            }
        }
    }
    ll ans = 0;
    rep(s, (1<<12)){
        ll temp = 12, last = -1;
        rep(i, 12){
            if(((ott[i] == 1) && (s>>i)&1) || (ott[i] + (i/11) == 2)){
                temp = min(temp, i - last);
                last = i;
            }
        }
        Rrep(i,11){
            if(((ott[i] == 1) && ((s>>i)^1)&1) || (ott[i] == 2)){
                temp = min(temp, 22 - i - last);
                last = 22 - i;
            }
        }
      temp = min(temp, 23 - last);
        ans = max(ans, temp);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N = Scanner.int()
    A = Scanner.map_int()
    if 0 in A:
        print(0)
        return
    ans = 1
    for a in A:
        ans *= a
        if ans > 10 ** 18:
            print(-1)
            return
    print(ans)


def main():
    # sys.stdin = open("sample.txt")
    # print('YNEOS'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 23840
n, t = map(int, input().split())
ct = []

for i in range(n):
    ct.append(list(map(int, input().split())))

#ct.sort()
minV = 10000
ans = 0

for i in range(n):
    if ct[i][1] > t:
        continue
    elif ct[i][0] < minV:
        minV = ct[i][0]
        ans = i + 1

if minV == 10000:
    print('TLE')
else:
    print(minV)


Measured memory_bytes: 3060
#include <iostream>

int main()
{
	int n, k;
	std::cin >> n >> k;

	int a = 1;
	for( int i = 0; i < n; i++ ) {
		if( a < k ) {
			a = a * 2;
		}
		else {
			a = a + k;
		}
	}

	std::cout << a << std::endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		System.out.println(a == 7 || a == 5 || a == 3 ? "YES" : "NO");
		sc.close();
	}

}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
main(){
    ll A,B;
    cin >> A >> B;
    if(A*B <= 0){
        cout << "Zero" << endl;
        return 0;
    }
    if(A < 0 && (B-A)%2 == 0)cout << "Negative" << endl;
    else cout << "Positive" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#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;
using lint = int64_t;

constexpr lint INF = 1000000000000000000;
struct Edge {int from; int to; lint cost;};
using Graph = vector<vector<Edge>>;

int main() {
    int N, M;
    cin >> N >> M;
    Graph G(N);
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        G[b].push_back(Edge{b, a, -c});
    }
    vector<int> d(N, 0);
    queue<int> q;
    d[N - 1] = 1;
    q.push(N - 1);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (auto e : G[v]) {
            if (d[e.to] == 0) {
                d[e.to] = 1;
                q.push(e.to);
            }
        }
    }
    vector<Edge> Edges;
    rep(i, N) {
        for (auto e : G[i]) {
            if (d[i] && d[e.to]) {
                Edges.push_back(Edge{e.to, e.from, e.cost});
            }
        }
    }
    vector<lint> dist(N, INF);
    dist[0] = 0;
    rep(i, N) {
        for (auto e : Edges) {
            if (dist[e.from] + e.cost < dist[e.to]) {
                dist[e.to] = dist[e.from] + e.cost;
                if (i == N - 1) {
                    cout << "inf\n";
                    return 0;
                }
            }
        }
    }
    cout << -dist[N - 1] << "\n";
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using i64 = long long;

i64 dp[100010][13];

int main() {
    constexpr i64 mod = 1000000007;
    std::string s;
    std::cin >> s;
    int n = s.size();
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        if (s[i - 1] == '?') {
            for (int j = 0; j < 10; j++) for (int k = 0; k < 13; k++) {
                dp[i][(k * 10 % 13 + j) % 13] = (dp[i][(k * 10 % 13 + j) % 13] + dp[i - 1][k]) % mod;
            }
        } else {
            int d = s[i - 1] - '0';
            for (int j = 0; j < 13; j++) {
                dp[i][(j * 10 % 13 + d) % 13] = (dp[i][(j * 10 % 13 + d) % 13] + dp[i - 1][j]) % mod;
            }
        }
    }

    std::cout << dp[n][5] << std::endl;

    return 0;
}


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

typedef int64_t i64;
typedef uint64_t ui64;

const int inf=1073741823;
const i64 llinf=4611686018427387903LL;

int main(void){
    int a,b;
    scanf("%i%i",&a,&b);
    printf("%i %i\n",a*b,(a+b)*2);
    return 0;
}



Measured memory_bytes: 3144
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define P pair<int,int>
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;

signed main(){
    int n,k;
    cin >> n >> k;
    vec(a,n);
    vec(b,n-k+1);
    REP(i,n){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    REP(i,n-k+1){
        int t = a[i+k-1] - a[i];
        b[i] = t;
    }
    sort(b.begin(),b.end());

    cout << b[0];

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using ll = long long;
using namespace std;

int n, k, q, arr[100001], d;
int main()
{
    IOS
    cin >>n >> k >> q;
    while (q--) {
        cin >> d;
        arr[0]--;
        arr[d]++;
        arr[d+1]--;
    }
    for (int i = 1; i <= n; ++i) {
        arr[i] += arr[i-1];
        if (arr[i] + k <= 0) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> x >> y;
	ll ans=1;
	n=x;
	for(i=2;i*i<=x;i++)
	{
		if(n%i==0 && y%i==0)
			ans++;
		while(n%i==0)
			n/=i;
	}
	if(n>1 && y%n==0)
		ans++;

	cout<<ans<<endl;
}

Measured memory_bytes: 3672
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=251000;
vector<PII> rel[N];
multiset<PII> hs;
int day[N],n,x[N];
void add(int l,int r,int num) {
	if (l>r) {
		puts("No");
		exit(0);
	}
	rel[l].pb(mp(r,num));
}
int main() {
	scanf("%d",&n);
	rep(i,0,n) {
		scanf("%d",x+i);
		rep(j,0,i) add(1,x[i]-1,i);
		rep(j,i+1,n) add(x[i]+1,n*n,i);
		add(x[i],x[i],i);
	}
	rep(i,1,n*n+1) {
		for (auto task:rel[i]) hs.insert(task);
		if (hs.empty()||hs.begin()->fi<i) {
			puts("No");
			exit(0);
		}
		day[i]=hs.begin()->se;
		hs.erase(hs.begin());
	}
	puts("Yes");
	rep(i,1,n*n+1) printf("%d ",day[i]+1);
	puts("");
}


Measured memory_bytes: 19060
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 
 
const ll large_P = 1e9 + 7;
 
 
int main(){
  ll L;
  cin >> L; 
  
  ld l = (ld)L;
  
  ld V;
  if(L%3 == 0){
    V = (L/3)*(L/3)*(L/3);
  }else{
    V = l*l*l/27.0;
  }
  
  printf("%.12Lf\n",(ld)V);
  //cout << V;
  
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
using ll = long long;

int main() {

	int X, Y, A, B, C;

	cin >> X >> Y >> A >> B >> C;

	vector<int> p(A), q(B), r(C);

	rep(i, A) cin >> p[i];
	rep(i, B) cin >> q[i];
	rep(i, C) cin >> r[i];

	sort(p.rbegin(), p.rend());
	sort(q.rbegin(), q.rend());
	sort(r.rbegin(), r.rend());

	vector<int> s;

	rep(i, X) s.push_back(p[i]);
	rep(i, Y) s.push_back(q[i]);
	rep(i, C) s.push_back(r[i]);

	sort(s.rbegin(), s.rend());

	ll ans = 0;

	rep(i, X + Y) ans += s[i];

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3572
#include<stdio.h>
#define FOR(n) for(int i=0;i<n;i++)
#define PRN(n) printf("%d\n",n)
#define PRS(s) printf("%s\n",s)

int main(void){
  int n,d,c=0;
  scanf("%d %d",&n,&d);
  if(n%(2*d+1))c++;
  PRN(n/(2*d+1)+c);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define watch(x) cout << #x << " is " << x << endl;
#define print(a, l, r) \
    for (int i = l; i < r; i++) cout << a[i] << (i == (r - 1) ? endl : " ");
const long long M = 1000000007;

bool isPalindrome(string s) {
    int n = (int)s.length();

    int i = 0, j = n - 1;

    bool palindrome = true;

    while (i < j) {
        if (s[i] != s[j]) {
            palindrome = false;
            break;
        }
        i++;
        j--;
    }
    return palindrome;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string s;
    cin >> s;
    int n = (int)s.length();
    if (isPalindrome(s) && isPalindrome(s.substr(0, n / 2)) && isPalindrome(s.substr(n / 2 + 1))) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;++i)a[i]=scan.nextInt();
        Arrays.sort(a);
        int max = a[n-1];
        int r = 0;
        for(int i=0;i<n;++i){
            int aa = Math.min(a[i], max-a[i]);
            if(r<aa)r=a[i];
        }
        System.out.println(max+" "+r);
    }
}

Measured memory_bytes: 50964
#include<bits/stdc++.h>
#define N 100100
using namespace std;
int msk[N];
vector<int> g[N];
void DFS(int u,int p){
	for(int i=0;i<g[u].size();i++){
		int v=g[u][i];
		if(v!=p) DFS(v,u);
	}
	int d=1<<20;
	while(d){
		int c=0;
		for(int i=0;i<g[u].size();i++){
			int v=g[u][i];
			if(v!=p&&(msk[v]&d)) c++;
		}
		if(c>1){
			msk[u]+=d<<1;
			break;
		}
		else if(c==1) msk[u]|=d;
		d>>=1;
	}
	if(d==0) msk[u]++;
}
int main(){
	int n,a,b;
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d%d",&a,&b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	DFS(1,0);
	int ans=0;
	while((1<<ans+1)<=msk[1]) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 10624
N = int(input())

def calculate2(n):
    arr = []
    for i in range(40):

        if n % (2**(i+1)) != 0:
            arr.append(1)
            n = n - ((-2) ** i)
        else:
            arr.append(0)
        if n == 0:
            break

    arr.reverse()
    return arr

result = calculate2(N)
result = "".join([str(s) for s in result])
print(result)



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

using namespace std;

#define FOR(i,a,b) for(int i=a;i<=b;i++)

const int maxn=2e5+10;

int main() {
	// your code goes here
	int n,m,a[maxn];
	cin >> n;
	FOR(i,1,n) cin >> a[i];
	int lmin=a[1],dem=1;
	FOR(i,2,n) {
		if (a[i]<=lmin) dem++;
		lmin=min(lmin,a[i]);
	}
	cout << dem;
	return 0;
}

Measured memory_bytes: 1024
n, m, l = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split()))for i in range(m)]

for i in range(n):
    for j in range(l):
        sum = 0
        for k in range(m):
            sum += a[i][k] * b[k][j]
        if j == l - 1:
            print(f"{sum}", end="")
        else:
            print(f"{sum} ", end="")
    print()


Measured memory_bytes: 6588
ans = [0]*(10**4 + 1)

for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            memo = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if memo <= 10**4:
                ans[memo] += 1


N = int(input())

for i in range(1,N+1):
    print(ans[i])

Measured memory_bytes: 9260
/* 
 * File:   main.c
 * Author: s1252007
 *
 * Created on June 26, 2018, 12:02 PM
 */

#include <stdio.h>
#include <stdlib.h>
#define M 5000000/* your task*/
#define L 14

/*
 * 
 */

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M;/* your task */ }
int h2(int key){ return (1 + key % (M - 1));/* your task */ }

int find(char str[])
{
    int i = 0, k, n = 0,sum;
    sum = getKey(str);
    while(i < M)
    {
        k = (h1(sum) + i * h2(sum)) % M;
        if(H[k][0]=='\0') break;
        if(strcmp(H[k],str)==0)
        {
            n=1;
            break;
        }
        i++;
    }
    return n;
}

int insert(char str[])
{
    int sum, i = 0, k; 
    sum = getKey(str);
    while(i < M)
    {
        k = (h1(sum) + i * h2(sum)) % M;
        if(H[k][0]=='\0')
        {
            strcpy(H[k],str);
            break;
        }
        i++;
    }
    /* your task */

}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}




Measured memory_bytes: 70092
import java.util.*;

class Main {

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);

        sc.nextLine();

        while(sc.hasNext()) {
            String line = sc.nextLine();
            line = line.replace("Hoshino", "Hoshina");
            System.out.println(line);
        }

    }
}

Measured memory_bytes: 12000
{-# LANGUAGE BangPatterns         #-}
{-# LANGUAGE DerivingStrategies   #-}
{-# LANGUAGE FlexibleContexts     #-}
{-# LANGUAGE MultiWayIf           #-}
{-# LANGUAGE RankNTypes           #-}
{-# LANGUAGE ScopedTypeVariables  #-}
{-# LANGUAGE UndecidableInstances #-}
import           Control.Monad.State
import qualified Data.ByteString.Char8 as BS
import           Data.List

main :: IO ()
main = do
  s <- readLnAsListWith unconsChar

  putStrLn $ if solve s then "YES" else "NO"

-- "dreamd re am"
-- "dreamd re amer"
--
-- "dreame ra se"
-- "dreame ra ser"

-- "dreame rd ream"
-- "dreame rd reamer"
-- "dreame re rase"
-- "dreame re raser"
--
-- "erased re am"
-- "erased re amer"
-- "erasee ra se"
-- "erasee ra ser"
--
-- "eraser dr eam"
-- "eraser dr eamer"
-- "eraser er ase"
-- "eraser er aser"


solve :: String -> Bool
solve ss
  | null ss || ss == "dream" || ss == "dreamer" || ss == "erase" || ss == "eraser" = True
  | otherwise = let v = take 6 ss
                    u = take 2 $ drop 6 ss
                in if | v == "dreamd" -> solve $ drop 5 ss
                      | v == "dreame" && u == "ra" -> solve $ drop 5 ss
                      | v == "dreame" && (u == "rd" || u == "re") -> solve $ drop 7 ss
                      | v == "erased" || v == "erasee" -> solve $ drop 5 ss
                      | v == "eraser" -> solve $ drop 6 ss
                      | otherwise -> False


-- converter
unconsChar :: StateT BS.ByteString Maybe Char
unconsChar = StateT BS.uncons

-- 1D Data
-- for list
readLnAsListWith :: StateT BS.ByteString Maybe a -> IO [a]
readLnAsListWith !st = unfoldr (runStateT st) <$> BS.getLine


Measured memory_bytes: 4940
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

const int MOD = 1000000007;

struct edge{
  int to;
  int id;
};

int n; 
vector<vector<edge>> G;
vector<int> C;
int max_c;

void dfs(int v,int c = -1,int p = -1){
  int k = 1;
  for(auto e:G[v]){
    if(p == e.to) continue;
    if(k == c) k++;
    C[e.id] = k; k++;
    dfs(e.to,C[e.id],v);
  }
}

int main(){
  cin >> n;
  G.resize(n);
  C.resize(n-1,-1);
  
  rep(i,n-1){
    int a,b; cin >> a >> b;
    a--,b--;
    edge e1; e1.to = a; e1.id = i;
    edge e2; e2.to = b; e2.id = i;
    G[b].push_back(e1);
    G[a].push_back(e2);
  }
  
  for(auto node:G){
    int s = node.size();
    chmax(max_c,s);
  }
  
  //cout << max_c << endl;
  
  dfs(0);
  cout << max_c << endl;
  rep(i,n-1) cout << C[i] << endl;
  return 0;
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  sort(b.begin(),b.end());
  int u=b[n/2],d=b[(n-1)/2];
  for(int i=0;i<n;i++){
    if(a[i]<=d){
      cout<<u<<endl;
    }else{
      cout<<d<<endl;
    }
  }
}

Measured memory_bytes: 3712
#include <stdio.h>

int search(int , int);
int array[20],num1;
int main(){
  int i,num2,key;

  scanf("%d",&num1);
  for(i=0;i<num1;i++){
    scanf("%d",&array[i]);
  }
  scanf("%d",&num2);
  for(i=0;i<num2;i++){
    scanf("%d",&key);
    if(search(0,key)==1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}
      
int search(int i, int key){
  int num;
  if(key==0) return 1;  /*found*/
  if(i>=num1) return 0;  /*not found*/
  
  num=search(i+1,key-array[i]) || search(i+1,key);/*choice element i or not*/
  return num;
}
				
				



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
const int N=15;
char s[N][10000];
int cnt[N];
int h,w,K,ans=0x3f3f3f3f;
int main()
{
	scanf("%d %d %d",&h,&w,&K);
	for(int i=0;i<h;i++) cin>>s[i];
	for(int i=0;i<1<<h-1;i++)
	{
		memset(cnt,0,sizeof cnt);
		bool f=0;
		int now=__builtin_popcount(i);
		for(int j=0;j<w;j++)
		{
			int id=0;
			bool flag=0;
			for(int k=0;k<h;k++)
			{
				cnt[id]+=(s[k][j]=='1');
				if(cnt[id]>K)  flag=1;
				if(i>>k&1) id++;
			}
			if(flag==1)
			{
				now++;
		
				for(int k=0;k<=id;k++) cnt[k]=0;
				id=0;
				for(int k=0;k<h;k++)
				{
					cnt[id]+=(s[k][j]=='1');
					if(cnt[id]>K)  f=1;
					if(i>>k&1) id++;
				}
			}
		}
		if(!f&&now<ans)
		{
			ans=now;
		}
	}
	cout<<ans<<endl;
}

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

ll N;
vector<ll> D;

int main(){
    cin >> N;
    map<int,int> m;
    D.assign(N,0);
    rep(i,0,N){
        cin >> D[i];
        m[D[i]]++;
    }

    if(D[0]!=0 || m[0]>1){
        cout << 0 << endl;
        return 0;
    }
    int cnt = 0;
    ll ans = 1;
    ll pre = 1;
    ll pre_d = -1;
    for(auto &e : m){
        cnt++;
        if(pre_d+1 != e.first){
            cout << 0 << endl;
            return 0;
        }
        if(cnt<=2){
            pre_d = e.first;
            pre = e.second;
            continue;
        }

        rep(i,0,e.second){
            ans *= pre;
            ans %= mod;
        }
        pre_d = e.first;
        pre = e.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8692
//div 3 c
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
int main()
{
	ll k,n;
	cin>>k>>n;
	ll a[n+1];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
	}
	a[n]=a[0];
	ll val=0;
	for(ll i=1;i<n;i++)
	{
		if((a[i]-a[i-1])>(k/2))
		{
			val=max(val,k-(a[i]-a[i-1]));
		}
		else
		val=max(val,a[i]-a[i-1]);
	}
	if(a[n-1]-a[0]>(k/2))
	val=max(val,k-(a[n-1]-a[0]));
	else
	val=max(val,a[n-1]-a[0]);
	//cout<<val<<endl;
	//val=max(val,a[n-1]-a[0]);
	cout<<(k-val)<<endl;
}

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

long num(long *A, long m, int N){
    long ans = 0;
    REP(i, N)
        ans += (long)N - (long)(lower_bound(A, A + N, m - A[i]) - A);
    return ans;
}

int main()
{
    int N;
    long M;
    long A[100005];
    cin >> N >> M;
    REP(i, N)
        cin >> A[i];
    sort(A, A + N);
    long sum[100005];
    sum[0] = 0;
    REP(i, N)
        sum[i+1] = sum[i] + A[i];
    long mi = 0;
    for(int i=20;i>=0;i--)
        if(num(A, mi + (1LL<<i), N) >= M)
            mi += (1LL<<i);
    //cout << mi << endl;
    long happy = 0;
    long rest = 0;
    REP(i, N){
        int temp = (int)(lower_bound(A, A + N, mi - A[i]) - A);
        happy += sum[N] - sum[temp] + ((long)N - (long)temp) * A[i];
        rest += (long)N - temp;
    }
    if(rest >= (long)M)
        happy -= (rest-(long)M)*mi;
    cout << happy << endl;

    return 0;
}



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


int main() {
    int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<a[k-1]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <complex>
#include <functional>
#include <bitset>
#include <map>
#include <random>
#include <memory>
#include <map>
#include <valarray>
#include <iomanip>
#include <queue>

#include <cassert>
#include <ctime>
#include <cmath>
#include <cstdlib>

using namespace std;

const int inf = (int)1e9 + 7;

int main ()
{
    //freopen ("input.txt", "r", stdin);

    ios_base::sync_with_stdio (false);
    cin.tie (nullptr);

    string s;

    cin >> s;

    cout << s.substr (0, s.size () - string ("FESTIVAL").size ()) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    if (k <= a)
    {
        ans = k;
        cout << k << endl;
        return 0;
    }
    ans += a;
    k -= a;
    if (k <= b)
    {
        cout << ans << endl;
        return 0;
    }
    k -= b;
    ans -= k;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628