akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define invrep(i, n) for(int i = (n)-1; i >= 0; i--)        // n-1, n-2, ..., 0
#define invREP(i, x, n) for(int i = (n)-1; i >= (x; i--)    // n-1, n-2, ..., x
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define PB push_back

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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; }


int main(){
    int N, Q; cin >> N >> Q;
    vi rui(N + 1, 0);
    string S; cin >> S;
    for(int i = 1; i < S.size(); i++){
        int f = 0;
        if(S[i - 1] == 'A' && S[i] == 'C') f = 1;
        rui[i] = rui[i - 1] + f;
    }
    rep(i, Q){
        int l, r; cin >> l >> r;
        l--; r--;
        COUT(rui[r] - rui[l]);
    }
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;

int main() {
    int n, T, m = 10000;
    cin >> n >> T;
    vector<int> c(n);
    vector<int> t(n);

    for (int i = 0; i < n; i++) {
        cin >> c[i] >> t[i];
        if (t[i] <= T) {
            m = min(c[i], m);
        }
    }

    if (m == 10000) {
        cout << "TLE" << endl;
    }
    else {
        cout << m << endl;
    }


    return 0;
}


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


void solve(long long N, std::vector<long long> A){
    long long m = 0;
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        long long a = A[i];
        m = max(m, a);
        ans += m - a;
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4840
import java.util.*;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = (int) Math.pow(10, 10000);
			String s = sc.nextLine();
			char[] arr = s.toCharArray();

			Deque<Character> deque = new ArrayDeque<Character>();
			for (int i = 0; i < arr.length; i++) {
				char c = arr[i];

				if (deque.isEmpty()) {
					deque.addFirst(c);
				} else if (c == 'T' && deque.peekFirst() == 'S' && n > 0) {
					deque.removeFirst();
					n--;
				} else {
					deque.addFirst(c);
				}
			}
			System.out.println(deque.size());
		}
	}
}

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

typedef pair<int,int>P;
#define F first
#define S second

int n,T,s,t;
vector<P>v[100009];
int E_aru[100009];


void END(){
  cout<<"No"<<endl;
  exit(0);
}

void YEAY(){
  cout<<"Yes"<<endl;
  exit(0);
}



int dfs0(int x,int par);

int dfs(int x,int par){

  //cout<<x<<' '<<E_aru[x]<<endl;

  int ofset = -T;
  int p_cost=-1;
  if(x==s)ofset=0;

  vector<P>vec;
  //cout<<v[x].size()<<endl;
  r(i,v[x].size()){
    //v[x][i].S -= T;
    //cout<<v[x][i].F<<' '<<E_aru[x]<<endl;
    if(E_aru[x] == v[x][i].F)continue;
    if(v[x][i].F == par){
      p_cost = i;
      v[x][p_cost].S -= T;
      continue;
    }
    vec.push_back( P(v[x][i].S,i) );
  }

  sort(vec.begin(),vec.end());

  r(i,vec.size()){

    if(v[x][vec[i].S].S + ofset <=0 )END();

    //cout<<"AAA"<<v[x][vec[i].S].F<<' '<<ofset<<endl;
    dfs( v[x][vec[i].S].F , x );

    if(p_cost != -1)v[x][p_cost].S -= T;
    //v[x][vec[i].S].S -= ofset;
    ofset -= T;
  }

  //cout<<x<<' '<<E_aru[x]<<endl;

  if(E_aru[x] != -1){
    r(i,v[x].size()){
      //cout<<v[x][vec[i].S].F<<endl;
      if(E_aru[x] != v[x][i].F)continue;
      //cout<<"BBB"<<v[x][i].F<<' '<<' '<<v[x][i].S<<' '<<ofset<<endl;
      if(v[x][i].S +  ofset <=0 )END();
      dfs( E_aru[x] , x );
    }
  }

  if(x==t)YEAY();

  if(p_cost != -1 &&  v[x][p_cost].S <= 0)END();
}


signed main(){
  memset(E_aru,-1,sizeof(E_aru));
  cin>>n;
  cin>>T>>s>>t; s--; t--;

  r(i,n-1){
    int a,b,c;
    cin>>a>>b>>c; a--; b--;
    v[a].push_back(P(b,c));
    v[b].push_back(P(a,c));
  }

  dfs0(s,-1);
  dfs(s,-1);

  cout<<"DAME"<<endl;
  exit(1);
}





int dfs0(int x,int par){
  if(x==t)return 1;
  int res=0;
  r(i,v[x].size()){
    if(v[x][i].F==par)continue;
    int X=dfs0(v[x][i].F,x);
    if(X==1)E_aru[x] = v[x][i].F , res=1;
  }
  return res;
}


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

int main() {
	int a, b;
	cin >> a >> b;
	if (a + b == 15) {
		cout << '+' << endl;
	}
	else if (a*b == 15) {
		cout << '*' << endl;
	}
	else {
		cout << 'x' << endl;
	}
}

Measured memory_bytes: 256
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

S = input()

ans = 0
for i in range(3):
  if S[i] == '1':
    ans += 1
    
print(ans)

Measured memory_bytes: 61804
H,W=map(int,input().split())
A= [ list( input() ) for _ in range(H)]

B=[["." for _ in range(W+2)] for _ in range(H+2)]

for i in range(1,H+1):
  for j in range(1,W+1):
    B[i][j]= A[i-1][j-1]

flag=True
for i in range(1,H+1):
  if flag:
    for j in range(1,W+1):
      if B[i][j]=="#":
        if B[i-1][j]!="#" and B[i+1][j]!="#" and B[i][j-1]!="#" and B[i][j+1]!="#":
          flag=False
          break
          
if flag:
  print("Yes")
else:
  print("No")

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


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


divs = sorted(make_divisors(M), reverse=True)

ans = 1
for div in divs:
    res = div if div*N <= M else 1
    ans = max(ans, res)

print(ans)

Measured memory_bytes: 3064
N = int(input())
A = []
for _ in range(N):
    ai = int(input())
    A.append(ai)

shined_button = A[0]
btn_attempt = 1
while True:
    if shined_button == 2:
        print(btn_attempt)
        break
    shined_button = A[shined_button-1]
    btn_attempt +=1

    if btn_attempt > N+1:
        print(-1)
        break


Measured memory_bytes: 7084
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		int C = stdIn.nextInt();
		int X = stdIn.nextInt();
		int Y = stdIn.nextInt();
		int AB = 2*C;
		
		int sum = 0;
		sum += Math.min(A+B, AB)*Math.min(X, Y);
		if(X >= Y) {
			sum += Math.min(A, AB)*(X-Y);
		}
		else {
			sum += Math.min(B, AB)*(Y-X);
		}
		
		System.out.println(sum);

	}

}

Measured memory_bytes: 21844
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  ll ans = 0;
  FOR(i, 1, N + 1) { ans += ((1 + i) * i) / 2; }
  REP(i, N - 1) {
    ll u, v;
    cin >> u >> v;
    if (u > v)
      swap(u, v);
    ans -= u * (N + 1 - v);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3540
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import sys, math, random
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"

inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    N=I()
    A=LI()
    out=1
    tmp=[-1,-1,-1]
    for a in A:
        out*=tmp.count(a-1)
        if tmp[0]==a-1:
            tmp[0]+=1
        elif tmp[1]==a-1:
            tmp[1]+=1
        else:
            tmp[2]+=1
    print(out%mod)


if __name__ == "__main__":
    main()

Measured memory_bytes: 24160
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
  std.range, std.container, std.bigint, std.ascii, std.typecons, std.format, std.bitmanip;

// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType)) {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {
  }

  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType)) {
    str ~= s.to!(char[]).strip.split;
  }
}
// }}}



void main() {
  auto cin = new Scanner;
  long k;

  cin.scan(k);

  long[] lunlun;
  DList!string q;
  foreach (i; 1 .. 10) {
    q ~= i.to!string;
  }

  bool[string] hash;
  while (!q.empty && hash.length < 100000) {
    auto s = q.front;
    q.removeFront;
    hash[s] = true;

    char[] ar;
    if (s[$ - 1] == '0') {
      ar = ['0', '1'];
    } else if (s[$ - 1] == '9') {
      ar = ['8', '9'];
    } else {
      ar = [cast(char)(s[$ - 1] - 1), s[$ - 1], cast(char)(s[$ - 1] + 1)];
    }

    foreach (c; ar) {
      q ~= s ~ c;
    }
  }
  foreach (e; hash.byKey) {
    lunlun ~= e.to!long;
  }
  lunlun.sort;
  //writeln(lunlun);

  writeln(lunlun[k - 1]);
}


Measured memory_bytes: 23288
#include<bits/stdc++.h>
#include<math.h>
#define ll long long
#define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
using namespace std;

//const double pi = boost::math::constants::pi<double>();
ll mod=1000000007;

ll expo(ll base, ll exponent, ll mod) { //return base^exponent modulo modulus
    ll ans = 1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            ans = ans*base ;
            ans = ans%mod;
        }
        base = base*base;
        base %= mod;
        exponent>>= 1;
    }
    return ans%mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll tests=1;
   // cin>>tests;
    while(tests--)
    {
       string s;
       cin>>s;
       if(s=="SUN") cout<<7;
       else if(s=="MON") cout<<6;
       else if(s=="TUE") cout<<5;
       else if(s=="WED") cout<<4;
       else if(s=="THU") cout<<3;
       else if(s=="FRI") cout<<2;
       else cout<<1;
        
    }
    
    return 0;
}


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

const ll MAX = 510000;
const ll mod = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}


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

    ll n,k;
    cin>>n>>k;
    COMinit();
    if(n==k){
        cout<<1<<endl;
        for(int i=2;i<=k;i++){
            cout<<0<<endl;
            
        }
        return 0;
    }

    for(ll i=1;i<=k;i++){
        ll ans=1;
        if(i-1 > n-k){
            cout<<0<<endl;
            continue;
        }
        ans = COM(k-1,i-1);
        ll cnt=0;
        
       
        cnt+=COM(n-k-1,i-2);
        cnt%=mod;

        cnt+=2*COM(n-k-1,i-1);
        cnt%=mod;

        cnt+=COM(n-k-1,i);
        cnt%=mod;
        
        //cnt--;
        ans = ans*cnt;
        ans%=mod;
        cout<<ans<<endl;

    }
    

}


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

int main(){
    int w, h;
    char c;
    cin >> w >> h >> c;
    for(int i=0;i<w;++i){
        cout << (i==0||i==w-1 ? '+' : '-');
    }
    for(int i=1;i<h-1;++i){
        cout << endl;
        for(int j=0;j<w;++j){
            cout << (j==0||j==w-1 ? '|' : (j==w/2&&i==h/2 ? c : '.'));
        }
    }
    cout << endl;
    for(int i=0;i<w;++i){
        cout << (i==0||i==w-1 ? '+' : '-');
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 3076
import heapq

n, m = map(int, input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))

heapq.heapify(A)
for i in range(m):
    tmp = heapq.heappop(A)*(-1)
    heapq.heappush(A, (-1)*(tmp//2))
print(sum(A)*(-1))


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct edge {
  ll to, cost;
};

int main() {
int n;
  cin >> n;
long long ans=0;
  for(int i=1;i<n;i++){
  if(n%i==0)ans+=n/i-1;
  else ans+=n/i;  
  
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3620
from collections import deque
import sys
input = sys.stdin.readline
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    return g1[n] * g2[n-r]  % mod

mod = 10**9+7 #出力の制限
N = 10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N,K=map(int,input().split())
ki=[[] for f in range(N)]
for i in range(N-1):
 a,b = map(int,input().split())
 ki[a-1].append(b-1)
 ki[b-1].append(a-1)
stack = deque([0])
check = [0]*N #チェック済みリスト
c=0
t=0
ans=1
while stack != deque([]) :
 a=stack.popleft()
 check[a]=1
 if len(ki[a])+1>K:
  t=1
  break
 else:
  for i in ki[a]:
   if check[i]==0:
    stack.append(i)
  ans*=cmb(K-c,len(ki[a])+1-c,mod)
  ans%=(10**9+7)
  c=2
if t==1:
 print(0)
else:
 print(ans)

Measured memory_bytes: 64244
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node{
    int c,a[20];
}p[20];
int ans[15],v[20];
ll ANS=1e10,sum;
int n,m,u,x;
void dfs(int cnt,int pre){
    if(cnt==u){
        sum=0;
        fill(v,v+20,0);
        for(int j=0;j<cnt;j++){
            for(int k=0;k<m;k++)
                v[k]+=p[ans[j]].a[k];
            sum+=p[ans[j]].c;
        }
        int flag=1;
        for(int j=0;j<m;j++) if(v[j]<x) {flag=0;break;}
        if(flag) ANS=min(ANS,sum);
        return;
    }
    for(int j=0;j<=n;j++){
        if(j>pre){
            pre=j;
            ans[cnt]=pre;
            dfs(cnt+1,pre);
        }
    }
}

int main()
{
    cin>>n>>m>>x;
    for(int i=1;i<=n;i++){
        cin>>p[i].c;
        for(int j=0;j<m;j++)
            cin>>p[i].a[j];
    }
    for(u=1;u<=n;u++){
        dfs(0,0);
    }
    if(ANS==1e10) puts("-1");
    else cout<<ANS;
    return 0;
}


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


int main()
{
	long long n, minn(1000000000000010ll), t;
	long long tt[5];
	
	scanf("%lld", &n);
	for (int i = 0; i < 5; ++i)
		scanf("%lld", tt + i);
	for (int i = 0; i < 5; ++i)
		if (minn > tt[i])
			minn = tt[i];
	if ((t = n % minn))
		n += minn - t;
	printf("%lld\n", n / minn + 4);
	return 0;
}



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

int main() {
	
	int W,H;
	int i,j,k;
	
	for(;;){
		
		cin>>H>>W;
		
		if(W==0&&H==0){
			break;
		}
		
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				
				if(i==0||i==H-1||j==0||j==W-1){
					cout<<'#';
				}else{
					cout<<'.';
				}
			}
				cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using P=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

int a, b, ans;
int main(){
    cin >> a >> b;
    rep(n, a, b+1){
        int t = n, rev = 0;
        rep(e, 0, 5){
            int tmp = t%10;
            rev += tmp * pow(10, 4-e);
            t /= 10;
        }
        if(n == rev) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(){
  char s[200000];
  cin >> s;

  int a = strlen(s);
  char c = 'A';
  char d = 'Z';
  
  int i = 0;
  while(s[i] != c){
    i++;
  }

  int k = 0;
  for(int j = 0 ; j < a ; j++){
    if(s[j] == d)
      k = j;
  }

  cout << k-i+1 << endl;
}


  

Measured memory_bytes: 384
// -*- coding:utf-8-unix -*-

use proconio::{input, marker::Chars, fastout};

#[fastout]
fn main() {
    input! {
       s: Chars,
       t: Chars,
    }

    let mut min = t.len();

    for i in 0..=(s.len() - t.len()) {
        let mut count = 0;
        for j in 0..t.len() {
            if s[i+j] != t[j]{
                count += 1;
            };
        }
        if min > count {
            min = count
        }
    } 

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


Measured memory_bytes: 2148
#include "bits/stdc++.h"
using namespace std;
#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30
#define MAX_P 1000000

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;


int p[MAX_P], n, sum[MAX_P];

int main(){
  p[0] = p[1] = 1;
  REP(i, 2, MAX_P){
    sum[i] = sum[i-1];
    if(!p[i]){
      sum[i]++;
      for(int j = i+i; j < MAX_P; j += i) p[j] = 1;
    }
  }
  //  rep(i, 100) printf("%d ", sum[i]); puts("");

  while(scanf("%d", &n) && n){
    int ip, m, res = 0;
    rep(i, n){
      scanf("%d%d", &ip, &m);
      //      int c = 0;
      //      REP(j, (ip-m)>0?(ip-m):0, (ip+m+1)>MAX_P?MAX_P:(ip+m+1)) if(!p[j]) c++;
      int top = (ip+m)>MAX_P-1?MAX_P-1:(ip+m);
      int under = (ip-m-1)>0?(ip-m-1):0;
      int c = sum[top] - sum[under];
      if(c) res += c-1;
      else res--;
    }
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 10932
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;

int main() {
	int N; cin >> N;
	vector<ll> A(N);
	rep(i, N) cin >> A[i];
	ll K = 0;
	rep(i, N) {
		K ^= A[i];
	}
	rep(i, N) {
		ll ans = A[i] ^ K;
		cout << ans << " ";
	}
	cout << endl;
}

Measured memory_bytes: 4776
#include <iostream>
#include <cmath>
using namespace std;
 
int main(void){
    long long n;
    cin >> n;
    
    long long s[450];
    long long i;
    for(i = 0; i < 450; i++){
        s[i] = i + 1;
    }
    
    i = (long long)sqrt(n);
    while(i * (i - 1) / 2 <= n){
        if(i * (i - 1) / 2 == n){
            cout << "Yes" << endl;
            cout << i << endl;
            i--;
            long long j;
            cout << i;
            long long k;
            for(k = 0; k < i; k++){
                cout << " " << s[k];
            }
            cout << endl;
            for(j = 0; j <= i; j++){
                if(j <= i - 2){
                    cout << i;
                    for(k = 0; k < i; k++){
                        if(k <= j){
                            s[k]++;
                        }else if(k > j + 1){
                            s[k] = s[k - 1] + 1;
                        }else{
                            s[k] = s[i - 1] + 1;
                        }
                        cout << " " << s[k];
                    }
                    cout << endl;
                }else{
                    s[0] = 1;
                    cout << i << " " << s[0];
                    long long cpi = i;
                    for(k = 1; k < i; k++){
                        s[k] = s[k - 1] + cpi;
                        cout << " " << s[k];
                        cpi--;
                    }
                    break;
                }
            }
            
            return 0;
        }
        i++;
    }
    
    cout << "No" << endl;
    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int x,y,z,k;
	cin >> x >> y >> z >> k;
	VL a(x), b(y), c(z);
	for (int i = 0; i < x; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < y; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < z; i++) {
		cin >> c[i];
	}

	VL ab(x*y,0);
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			ab[i*y + j] = a[i] + b[j];
		}
	}

	sort(RALL(ab));

	int num = min(3000, (int)ab.size());
	VL abc(num*z,0);

	for (int i = 0; i < num; i++) {
		for (int j = 0; j < z; j++) {
			abc[i*z+j] = ab[i] + c[j];
		}
	}

	sort(RALL(abc));
	for (int i = 0; i < k; i++) {
		cout << abc[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N; cin >> N;
    string a[N+1];
    for (int i =1; i<=N;i++)
    {
        cin >> a[i];
    }
    int h=0, k=0, g=0, b=0;
    for(int i =1; i<= N;i++)
    {
       if (a[i]=="AC") h++;
       if(a[i]=="WA") k++;
       if(a[i]=="TLE") g++;
       if (a[i]=="RE") b++;
    }
    cout << "AC x " << h << endl;
    cout << "WA x " << k << endl;
    cout << "TLE x " << g << endl;
     cout << "RE x " << b << endl;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    string S;
    cin >> S;
    ll N, K;
    cin >> K;
    N = S.size();
    vector<vector<vector<ll>>> dp(N + 1, vector<vector<ll>>(2, vector<ll>(K + 2, 0)));
    dp[0][0][0] = 1;
    rep(i, N) rep(j, 2){
        ll d = j==1?9:S[i] - '0';
        rep(k, K + 1) {
            rep(m, d + 1) {
                dp[i + 1][j == 1 || m < d][k + (m != 0)] += dp[i][j][k];
            }
        }
    }
    ll ans = dp[N][0][K] + dp[N][1][K];
    for(int i=0;i<=N;i++){
       // cout<<dp[i][0][K]<<' '<<dp[i][1][K]<<endl;
    }
    

    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}
/* 
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
typedef long long LL;

int n, K, dp[5][105][3];
char str[105];

int dfs(int m, int use, int limit) {
    if(use > K) return 0;
    if(m > n) return use == K;
    if(dp[use][m][limit] != -1) return dp[use][m][limit];
    int up = limit == 1? str[m]-'0':9, ans = 0;
    for(int i = 0; i <= up; ++i)
        ans += dfs(m+1, use+(i!=0), limit&&i==up); 
    return dp[use][m][limit] = ans;
}

void run_case() {
    cin >> (str+1) >> K;
    n = strlen(str+1);
    memset(dp, -1, sizeof(dp));
    cout << dfs(1, 0, 1);
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    //cout.setf(ios_base::showpoint);cout.precision(8);
    run_case();
    cout.flush();
    return 0;
}
 */


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100

string s;
string t = "";

int main() {
  cin >> s;

  for (int i = s.size() - 1; i >= 0; --i) {
    t += s[i];
    if (t.size() >= 5 && t.size() <=7) {
      string temp = t;
      for (int j = 0; j < t.size() / 2; ++j) {
        swap(temp[j], temp[t.size() - 1 - j]);
      }
      if (temp == "dream") {
        t = "";
      } else if (temp == "dreamer") {
        t = "";
      } else if (temp == "erase") {
        t = "";
      } else if (temp == "eraser") {
        t = "";
      }
    }
  }

  if (t.empty()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 512
#import string,itertools,fractions,heapq,re,array,bisect
#from math import *
#from collections import Counter
def rl(s): return xrange(len(s))

INF = 2147483647


import sys
stdin = sys.stdin

x, y = map(int, stdin.readline().strip().split())


rr = INF
if x < y:
    rr = y - x
if x == -y:
    rr = 1
if -x < y:
    rr = min(rr, y - -x + 1)
if x < -y:
    rr = min(rr, -y - x + 1)
if -x < -y:
    rr = min(rr, -y - -x + 2)

print rr


Measured memory_bytes: 2568
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <iomanip> //cout << fixed << setprecision(12) << ans << endl;
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define loop(i, l, r) for(int i = l; i < r; i++)
#define rloop(i, l, r) for(int i = l; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vec_i;
typedef pair<int,int> pair_ii;
typedef pair<ull,ull> pair_ull;
 
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int INF = 1e9;
const int MOD = 1e9+7;
 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;

	vec_i a(m);
	vec_i c(m, 0);

	rep(i, m){
		int b;
		cin >> a[i] >> b;
		rep(j, b){
			int d;
			cin >> d;
			c[i] += (1 << (d-1));
		}
	}

	vector<ull> ans(1<<n+1, INF);
	bool used[1<<n+1];
	rep(i,1<<n+1) used[i]=false;
	used[0] = true;
	ans[0] = 0;
	rep(i, m){
		rep(j, 1<<n){
			if(used[j]){
				int k = (j | c[i]);
				used[k] = true;
				ans[k] = min(ans[k], ans[j]+a[i]);
			}
		}
	}

	if(ans[(1<<n) - 1] == INF)
		cout << -1 << endl; 
	else
		cout << ans[(1<<n) - 1] << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
int main(){
    string w; cin >> w;
    int cnt[26] = {};
    for(int i = 0; i < w.size(); i++) cnt[w[i]-'a']++;
    for(int i = 0; i < 26; i++) {
        if(cnt[i]%2 == 1) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	std::vector<int> num(3); for (auto& a : num) std::cin >> a;
	if (std::accumulate(num.begin(), num.end(), 0) >= 22) {
		std::cout << "bust" << std::endl;
	}
	else {
		std::cout << "win" << std::endl;
	}
}

Measured memory_bytes: 888
// AOJ 2295: Power of Power
// 2017.10.7 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

int a[105]; int st, sz;

int cmp(int *a, int *b) { return *a - *b; }

int main()
{
	int n, sz, i, t, zero, one;

	scanf("%d", &n);
	zero = one = sz = 0;
	while (n-- > 0) {
		scanf("%d", &t);
		if (t == 0) zero++;
		else if (t == 1) one++;
		else a[sz++] = t;
	}
	qsort(a, sz, sizeof(int), cmp);
	st = 0;
	if (sz > 0 && one == 0 && zero & 1) {
		if (sz >= 3 && a[sz-1] == 3 && a[sz-2] == 2) a[sz-2] = 3, a[sz-1] = 2;
		while (zero-- > 1) a[sz++] = 0;
		a[sz++] = a[0], st = 1, a[sz++] = 0;
	} else {
		if (sz >= 2 && a[sz-1] == 3 && a[sz-2] == 2) a[sz-2] = 3, a[sz-1] = 2;
		if (zero & 1) {
			while (zero-- > 1) a[sz++] = 0;
			if (one > 0) a[sz++] = 1, one--;
			a[sz++] = 0;
		} else while (zero-- > 0) a[sz++] = 0;
		while (one-- > 0) a[sz++] = 1;
	}
	for (i = st; i < sz; i++) printf("%d\n", a[i]);
}

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

#define int long long
const int MOD = 1e9 + 7;
const int INF = 1e18;

void solve(){
  int n, a, b;
  cin >> n >> a >> b;
  int mx = min(a, b);
  int mn = max(0ll, a + b - n);
  cout << mx << " " << mn << endl;
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}

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

int main(){
    long long int a, b, c, d;
    long long int ac, ad, bc, bd;
    cin >> a >> b >> c >> d;
    
    ac = a * c;
    ad = a * d;
    bc = b * c;
    bd = b * d;

    cout << max({ac, ad, bc, bd}) << '\n';


    return 0;
}

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

typedef long long ll;

int main(){
  int n;
  cin >> n;
  ll a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  ll sum=0;
  for(int i=0;i<n;i++){
    sum+=a[i];
  }
  ll ans=1e18;
  ll k=0;
  for(int i=0;i<n-1;i++){
    k+=a[i];
    ans=min(ans,abs(k*2-sum));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
import math
import numpy as np

a,b,h,m = map(int, input().split())

h_direct = 30*h+m/2
m_direct = 6*m


ax = a*math.sin(math.radians(h_direct))
ay = a*math.cos(math.radians(h_direct))
bx = b*math.sin(math.radians(m_direct))
by = b*math.cos(math.radians(m_direct))

#
print(math.sqrt((ax-bx)**2+(ay-by)**2))

Measured memory_bytes: 27200
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int N = sc.nextInt();
    int M = sc.nextInt();
    
    int[] count = new int[N];
    for (int i = 0; i < M; i ++) {
      int a = sc.nextInt() - 1;
      int b = sc.nextInt() - 1;
      count[a] ++;
      count[b] ++;
    }
    
    boolean flg = true;
    for (int v : count) {
      if (v % 2 == 1) {
        flg = false;
        break;
      }
    }
    System.out.println(flg ? "YES" : "NO");
    
  }

}


class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 22852
a, b = [int(x) for x in input().split()]


def xor(x):
    tmp = (x + 1) % 4
    if tmp == 0:
        return 0
    elif tmp == 1:
        return x
    elif tmp == 2:
        return 1
    else:
        return 1 ^ x


print(xor(a - 1) ^ xor(b))


Measured memory_bytes: 2940
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <algorithm>
#define MOD 200003
#define forn(a, n) for(int a = 0; a<(int) (n); ++a)
#define dforn(a, n) for(int a = (n)-1; a>=0; --a)
#define forall(a, all) for(__typeof(all.begin()) a = all.begin(); a != all.end(); ++a)
#define EPS 0.000000000001
using namespace std;
typedef long long tint;
typedef pair<tint, tint> pii;
typedef vector<tint> vi;
typedef vector<vi> vvi;

typedef tint tipo;

tipo* ini(int l){
	tipo *r = new tipo[l];
	fill(r, r+l, 0);
	return r;
}
#define add(l,s,d,k)forn(i, l)(d)[i]+=(s)[i]*k
void mulFast(int l, tipo *n1, tipo *n2, tipo *nr){
	if(l<=0)return;
	if(l<35){
		forn(i, l)forn(j, l)nr[i+j]+=n1[i]*n2[j];
	}else{
		int lac = l/2, lbd = l - (l/2);
		tipo *a = n1, *b=n1+lac, *c=n2, *d=n2+lac;
		tipo *ab = ini(lbd+1), *cd = ini(lbd+1);
		tipo *ac = ini(lac+lac), *bd = ini(lbd+lbd);
		add(lac, a, ab, 1);
		add(lbd, b, ab, 1);
		add(lac, c, cd, 1);
		add(lbd, d, cd, 1);
		mulFast(lac, a, c, ac);
		mulFast(lbd, b, d, bd);
		add(lac+lac, ac, nr+lac,-1);
		add(lbd+lbd, bd, nr+lac,-1);
		add(lac+lac, ac, nr,1);
		add(lbd+lbd, bd, nr+lac+lac,1);
		mulFast(lbd+1, ab, cd, nr+lac);
		free(ab); free(cd); free(ac); free(bd);
	}
}
void mulFast(int l1, tipo *n1, int l2, tipo *n2, int &lr, tipo *nr){
	while(l1<l2) n1[l1++]=0;
	while(l2<l1) n2[l2++]=0;
	lr=l1+l2+3;
	fill(nr, nr+lr, 0);
	mulFast(l1, n1, n2, nr);

	while(lr>1 && nr[lr-1]==0)lr--;
}

tint cant[MOD+5];
tint res[2*MOD+10];
int main()
{
	vi perm(MOD+5), inv(MOD+5);
	tint r  = 1;
	forn(i, MOD-1) {
		perm[i] = r;
		inv[r] = i;
		r *= 2;
		r %= MOD;
	}
	
	forn(i, MOD) cant[i] = 0;
	
	int n;
	cin >> n;
	forn(i, n) {
		tint r;
		cin >> r;
		if(r > 0) {
			cant[inv[r]]++;
		}
	}
	
	ini(MOD+5);
	forn(i, 2*MOD+10) res[i] = 0;
	mulFast(MOD+5, cant, cant, res);
	
	tint ans = 0;
	forn(i, 2*MOD+5) {
		tint g = i % (MOD-1);
		ans += perm[g] * res[i];
	}
	
	forn(i, MOD+5) {
		ans -= (perm[i] *perm[i]) % MOD * cant[i];
	}
	cout << ans/2 << endl;
	
}


Measured memory_bytes: 22188
/* #                          */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <deque>
#include <map>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;

constexpr int               inf = 0x3f3f3f3f;
constexpr long long 		INF = 9123456789123456789;
constexpr long long         MOD = 1000000007LL;
/*************************************************/
ll H;

ll sol(ll H) {
    int exp(0);
    while (H > 1) {
        H /= 2;
        exp++;
    }
    ll sum(0); ll e(1);
    for (int i = 0; i <= exp; i++) {
        sum += e;
        e *= 2;
    }
    return sum;
}

int main() {
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cin.tie(nullptr);
    cin >> H;
    cout << sol(H) << endl;

    return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        string s;
        cin >> s;
        int ans = 0;
        for (int i = 0; i < s.size(); i ++) {
                if (s[i] == '0') continue;
                string t = s;
                t[i] --;
                for (int j = i + 1; j < t.size(); j ++) {
                        t[j] = '9';
                }
                int res = 0;
                for (int j = 0; j < t.size(); j ++) {
                        res += t[j] - '0';
                }
                ans = max(ans, res);
        }
        int res = 0;
        for (int i = 0; i < s.size(); i ++) {
                res += s[i] - '0';
        }
        ans = max(ans, res);
        printf("%d\n", ans);
        return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		new Main().execute();
	}

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		int[] arr = new int[N];
		sc.nextLine();
		String[] input = sc.nextLine().split(" ");
		for (int i = 0; i < N; i++) {
			arr[i] = Integer.parseInt(input[i]);
		}
		int[] sortedArr = arr.clone();
		Arrays.sort(sortedArr);
		int m1 = sortedArr[N / 2 - 1];
		int m2 = sortedArr[N / 2];
		for (int i = 0; i < N; i++) {
			int x = arr[i];
			if (x <= m1) {
				System.out.println(m2);
			} else {
				System.out.println(m1);
			}
		}
		sc.close();

	}

}


Measured memory_bytes: 94552
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

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

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ull fun(ull n) {
	if (n < 2) {
		return 1;
	} else {
		return n * fun(n - 2);
	}
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int flag = 0;
	int max = a;
	if (max < b) {
		max = b;
		flag = 1;
	}
	if (max < c) {
		max = c;
		flag = 2;
	}
	switch(flag) {
		case 0:
			if ((b + c) == a) {
				cout << "Yes" << endl;
			} else {
				cout << "No" << endl;
			}
			break;
		case 1:
			if ((a + c) == b) {
				cout << "Yes" << endl;
			} else {
				cout << "No" << endl;
			}
			break;
		case 2:
			if ((b + a) == c) {
				cout << "Yes" << endl;
			} else {
				cout << "No" << endl;
			}
			break;
	}
	return 0;
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    sort(ALL(a));
    cout << a[n-1] - a[0] << endl;
}

Measured memory_bytes: 256