akhauriyash/Code-Regression huggingface dataset:
m = gets.chomp.to_i
commands = []
m.times do 
    cmd, v = gets.chomp.split(' ')
    v = v.to_i unless v.nil?
    commands.push([cmd, v])
end

def insert(tree, z)
    y = nil
    x = tree[:root]
    # p x, y, z
    until x.nil? do
        y = x
        # puts "x[:key] = #{x[:key]}"
        # puts "z[:key] = #{z[:key]}"
        if z[:key] < x[:key] then
            x = tree[x[:l]]
        else
            x = tree[x[:r]]
        end
    end
    z[:p] = y[:key] unless y.nil?
    if y.nil? then
        tree[:root] = z
        tree[z[:key]] = z
    elsif z[:key] < y[:key]
        y[:l] = z[:key]
        tree[z[:key]] = z
    else
        y[:r] = z[:key]
        tree[z[:key]] = z
    end
end

def preParse(tree, key)
    return if key == nil
    print " #{key}"
    preParse(tree, tree[key][:l])
    preParse(tree, tree[key][:r])    
end

def inParse(tree, key)
    return if key == nil
    inParse(tree, tree[key][:l])
    print " #{key}"
    inParse(tree, tree[key][:r])
end

tree = { root: nil }
commands.each do |cmd|
    if cmd[0] == "insert" then
        node = { key: cmd[1], p: nil, l: nil, r: nil }
        insert(tree, node)
    elsif cmd[0] == "find" then
        puts tree.has_key?(cmd[1]) ? "yes" : "no"
    else
        # p tree
        inParse(tree, tree[:root][:key])
        puts "\n"
        preParse(tree, tree[:root][:key])
        puts "\n"
    end
end



Measured memory_bytes: 173392
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
d = [-1, 0, 1, 0]
for i in range(H):
  for j in range(W):
    if S[i][j] == ".":
      continue
    f = 1
    for k in range(4):
      if 0 <= i + d[k] < H and 0 <= j + d[-1 - k] < W:
        if S[i + d[k]][j + d[-1 - k]] == "#":
          f = 0
          break
    if f:
      print("No")
      exit(0)
print("Yes")

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

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

  std::vector<int> a;
  for(int i = 0; i < n; ++i) {
    int x;
    std::cin >> x;
    a.push_back(x);
  }

  int alice { 0 };
  int bob { 0 };

  std::sort(std::begin(a), std::end(a), std::greater<int>());
  for(int i = 0; i < a.size(); ++i) {
    if(i % 2 == 0) {
      alice += a[i];
    } else {
      bob += a[i];
    }
  }

  std::cout << alice - bob << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;i++) {
            a[i] = sc.nextInt();
        }
        for(int i=0;i<n-1;i++)
            for(int j=0;j<n-i-1;j++)
                if(a[j]<a[j+1]) {
                    int tmp = a[j];
                    a[j] = a[j+1];
                    a[j+1] = tmp;
                }
        int sum1 = 0;
        int sum2 = 0;
        int flag = 1;
        for(int i=0;i<n;i++,flag*=-1) {
            if(flag==1) {
                sum1+=a[i];
            }
            else sum2+=a[i];
        }
        System.out.println(sum1-sum2);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;

int main() {
  ll N,A,B;
  cin >> N >> A >> B;
  vll X(N);
  repeat(i,N){
    cin >> X[i];
  }
  ll ans = 0;
  repeat(i,N-1){
    ll a = A*(X[i+1]-X[i]);
    ans += (a<B)? a:B;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,ans=0;
  cin>>n>>k;
  int aa[n];
  for(int i=0;i<n;i++){
    cin>>aa[i];
  }
  sort(aa,aa+n);
  for(int i=n-1;i>n-1-k;i--){
    ans+=aa[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
N,K = [ int(it) for it in input().split() ]
li = [ int(it) for it in input().split() ]

res_li = []
ma = max(max(li),K)
t = 1
K_li = []
k = K
K_haji = -1
for i in range(1000000):
  
  K_li.append(k%2)
  if (k%2==1):
    K_haji = i
  k//=2
  
  res_0 = 0
  res_1 = 0
  for v in li:
    res_0 += (v&t)
    res_1 += (v&t)^t
  res_li.append( (res_0,res_1)  )
  t*=2
  if (ma<t):
    break

smax = sum([ a for a,b in res_li ]) #only xor zero
wlen = len(K_li)
smax = max(smax, sum([ res_li[it][K_li[it]] for it in range(wlen) ]) )
for i in range( wlen ):
  if ( K_li[i]==1 ):
    _sum = 0
    for j in range(wlen):
      if (i==j):
        _sum += res_li[j][0]
      elif (i<j):
        _sum += res_li[j][K_li[j]]
      elif (j<i):
        _sum += max(res_li[j])
    smax = max(smax, _sum)
print ( smax )  


Measured memory_bytes: 69080
'use strict';

function main(stdin) {
  const input = stdin.split(' ').map(v => parseInt(v, 10));
  const r = input[0];
  const D = input[1];
  let x = input[2];
  
  for (let i = 0; i < 10; ++i) {
    x = x * r - D;
    console.log(x);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21320
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())

for _ in range(N):
  b = int(input())
  for i in range(3):
    for j in range(3):
      if A[i][j] == b:
        A[i][j] = 0

for i in range(3):
  if A[i][0] + A[i][1] + A[i][2] == 0:
    print('Yes')
    exit()

for j in range(3):
  if A[0][j] + A[1][j] + A[2][j] == 0:
    print('Yes')
    exit()

if A[0][0] + A[1][1] + A[2][2] == 0 or A[0][2] + A[1][1] + A[2][0] == 0:
  print('Yes')
  exit()

print('No')


Measured memory_bytes: 3064
#include <cctype>
#include <cassert>
#include <string>
#include <iostream>
using namespace std;


string S;
size_t cur = 0;
int parse();
int expression();


int digit(){
  // assert(isdigit(S[cur]));
  int n = S[cur]-'0';
  cur =cur+1;
  // cout << n <<endl;
  return n;
}

int number (){
  int n = digit();
  // cout << n << endl;
  while(cur<S.size() && isdigit(S[cur])) n=n*10 + digit();
  // cout << n<<endl;
  return n;
}

int factor(){
  if(S[cur] != '('){
    return number();
  }
  cur += 1;
  int n = expression();
  assert(S[cur]==')');
  cur+=1;
  return n;
}

int term(){
  int a=factor();
  while(cur<S.size() && (S[cur]=='*' || S[cur]=='/')){
    char op = S[cur++];
    int b = factor();
    if(op=='*') a*=b; else a/=b;
  }
  return a;
}

int expression(){
  int a= term();
  while(cur<S.size()&&(S[cur]=='+'||S[cur]=='-')){
    char op = S[cur++];
    int b = term();
    if(op == '+') a += b;else a -=b;
  }
  return a;
  // int sum = number();
  // while(S[cur] == '+'|| S[cur] == '-'||S[cur]=='*'||S[sur]=='/'){
  //   char op = S[cur];
  //   cur += 1;
  //   int b = number();
  //   if(op=='+'){

  //   }

  // }


  // int a = number();
  // char op = S[cur];
  // cur += 1;
  // int b = number();
  // assert(op == '+');
  // return a + b;
}



int main(){
  int N;
  cin >> N;
  for (int i=0;i<N;++i){
    cur=0;
    cin>>S;
    S.resize(S.size()-1);
    cout << expression()<<endl;
  }
}
// int parse(){return expression();}
// int main(){
//   int a = parse();
//   // assert(a==15);
//   cout << a << endl;
//   assert(cur == S.size());
// }

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<=(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second

int main()	{
  int n;
  cin>>n;
  vector<ll>l(n+1);
  l[0]=2,l[1]=1;
  rep(i,n-2){
    l[i+2]=l[i]+l[i+1];
  }
  cout<<l[n]<<endl;
}

Measured memory_bytes: 3612
N = int(input())
Nminus1 = N - 1
# lines = []

CSF = [0 for _ in range(Nminus1)]
# S = [0 for _ in range(Nminus1)]
# F = [0 for _ in range(Nminus1)]

for i in range(Nminus1):
    c, s, f = input().split()
    CSF[i] = (int(c), int(s), int(f))
    # C[i] = int(c)
    # S[i] = int(s)
    # F[i] = int(f)

# for line in lines:
#     c, s, f = line.split()
#     C.append(int(c))
#     S.append(int(s))
#     F.append(int(f))

for i in range(Nminus1):
    a = 0
    for j in range(i, Nminus1):
        C, S, F = CSF[j]
        if a <= S:
            n = S - a
        else:
            mod = a % F 
            n = F - mod if mod != 0 else 0
        a = a + C + n
    print(a)

print(0)

Measured memory_bytes: 3188
import math
N, K = map(int, input().split())
A = list(map(int,input().split()))

def num(x,K):
    return(math.ceil(x/(K-1)))
    
left = A.index(1)
right = N-1-A.index(1)

left_noba = left % (K-1)
left_num = left // (K-1) + 1

right_noba = K - 1 - left_noba

if right >= right_noba:
    right_num = num(right - right_noba,K)
else:
    right_num = 0
    
print(left_num + right_num)

Measured memory_bytes: 13812
class Factorials(object):
    def __init__(self, n, mod):
        inv = [1] * (n + 1)
        self.__mod = mod
        self.__fac = [1] * (n + 1)
        self.__fac_inv = [1] * (n + 1)
        for i in range(2, n+1):
            self.__fac[i] = (self.__fac[i-1] * i) % mod
            inv[i] = mod - inv[mod % i] * (mod // i) % mod
            self.__fac_inv[i] = self.__fac_inv[i - 1] * inv[i] % mod
        
    def comb(self, n, k):
        if n < k or n < 0 or k < 0:
            return 0
        return self.__fac[n] * (self.__fac_inv[k] * self.__fac_inv[n - k] % self.__mod) % self.__mod
    
    def fac(self, k):
        return self.__fac[k]
    
    def fac_inv(self, k):
        return self.__fac_inv[k]

MOD = 1000000007
x, y = map(int, input().split())
if (x + y) % 3 != 0:
  print(0)
  exit()
n = (x + y) // 3
f = Factorials(n, MOD)
print(f.comb(n, x-n))

Measured memory_bytes: 82072
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int n;
    string s;
    cin>>n>>s;
    
    for(int i=0;i<s.size();i++){
        for(int k=0;k<n;k++){
            s.at(i)++;
            if(s.at(i)=='[') s.at(i)='A';
        }
    }
    
    cout<<s<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
string s;
set<string> a;


int main() {
    cin >> n;
    while (n--) {
        cin >> s;
        a.insert(s);
    }

    cout << a.size() << endl;

    return 0;
}


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

char draw[51][51];
int main(){
    int h,w;
    cin >> h >> w;
    rep(i,h){
        rep(j,w){
            cin >> draw[i][j];
        }
    }

    rep(i,h){
        rep(j,w){
            int ny = i,nx = j;
            if(draw[ny][nx]=='#'){   
                int cnt = 0;
                rep(k,4){
                    int cx = nx+dx[k],cy = ny+dy[k];
                    if(0<=cx&&cx<w&&0<=cy&&cy<h){
                        if(draw[cy][cx] == '.') cnt++;
                    }
                }
                if(cnt==4){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict

read = sys.stdin.read
readline = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    if N==1:
        print(1)
        sys.exit()
    XY = list(list(map(int, readline().split())) for _ in range(N))
    d = defaultdict(int)
    for i in range(N-1):
        x1, y1 = XY[i]
        for j in range(i+1,N):
            x2, y2 = XY[j]
            x = x2-x1
            y = y2-y1
            d[x,y] += 1
            d[-x,-y] += 1
    print(N-max(d.values()))



if __name__ == '__main__':
    main()


Measured memory_bytes: 9864
#include <iostream>
#include <math.h>

using namespace std;

int main(){
  int m1, m2,d1,d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if(m1 == m2){
    cout << 0;
  }else{
    cout << 1;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(all(a));
    cout << a[0] * a[1] / 2 << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>
#include <ctype.h>
 
int main(void)
{
  int a, b;
  char s[11];
  bool flag = true;
  int i;
  
  scanf("%d %d %s", &a, &b, s);
  
  i = 0;
  while (i < a + b + 1) {
    if (s[a] != '-' || i != a && isdigit(s[i]) == 0) {
      flag = false;
      break;
    }
    i++;
  }
  
  if (flag)
    printf("Yes\n");
  else
    printf("No\n");
  
  return 0;
}

Measured memory_bytes: 128
n , k = map(int,input().split())
a = list(map(int,input().split()))
bi = [0 for i in range(41)]
if n % 2 == 0:
    kahan = n//2-1
elif n % 2 == 1:
    kahan = n//2
for i in range(n):
    for j in range(41):
        bi[j] += (a[i] >> j) & 1

for i in reversed(range(41)):
    if k < pow(2,i):
        continue
    elif k >= pow(2,i):
        if bi[i] <= kahan:
            bi[i] = n - bi[i]
            k -= pow(2,i)
ans = 0
for i in range(41):
    ans += bi[i]*pow(2,i)

print(ans)

Measured memory_bytes: 87076
#include <bits/stdc++.h>
//#define DEBUG
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}
int cal_cost(vi & a, int x){
    int cost = 0;
    for( int i = 0 ; i < a.size() ; i++){
        cost += ( a[i] - x) * (a[i] - x);
    }
    return cost;
}
void solve(){
    int n;
    cin >> n;
    vi a(n);
    for ( int i  = 0 ; i < n ; i++){
        cin >> a[i];
    }
    int min_cost = 100 * 200 * 200; 
    for(int i = - 100; i <= 100; i++){
        int cost = cal_cost(a, i);
        if( cost < min_cost){
            min_cost = cost;
        }
    }
    cout << min_cost << "\n";
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}



Measured memory_bytes: 3600
import sys

def main():
    N = int(input())
    X = sorted(list(map(int, input().split())))
    ans = sys.float_info.max
    for p in range(X[0], X[-1]+1):
        hp = sum([(p - x) ** 2 for x in X])
        if hp < ans:
            ans = hp
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 64444
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
typedef long long llong;

llong burg_length[51];
llong burg_score[51];

void burg_init() {
	burg_length[0] = 1;
	burg_score[0] = 1;
	for (int i = 1; i <= 50; i++) {
		burg_length[i] = 2 * burg_length[i - 1] + 3;
		burg_score[i] = 2 * burg_score[i - 1] + 1;
	}
}


int main() {
	llong N, X;
	llong score = 0;
	burg_init();
	cin >> N >> X;

	for (int i = N; i >= 0; i--) {
		if (X == burg_length[i]) {
			score += burg_score[i];
			break;
		}
		else if (X == burg_length[i - 1] + 2) {
			score += burg_score[i - 1] + 1;
			break;
		}
		else if (X > burg_length[i - 1] + 2) {
			score += burg_score[i - 1] + 1;
			X -= burg_length[i - 1] + 2;
			continue;
		}
		else {
			X -= 1;
			continue;

		}
	}
	cout << score << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define MOD 1000000007

long long bipow(long long K, int p){
    if(p == 0) return 1;
    if(p % 2 == 0){
        long long tmp = (K * K) % MOD;
        return bipow(tmp, p / 2) % MOD;
    }else
        return (K * bipow(K, p-1)) % MOD;
}

vector<long long> divs(int n){
    vector<long long> ret;
    for(int i=1; i*i<=n; i++){
        if(n % i == 0){
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N, K;
    cin >> N >> K;

    vector<long long> dv = divs(N);
    sort(dv.begin(), dv.end());

    vector<long long> num(dv.size(), 0);

    num[0] = K;
    for(int i=1; i<dv.size(); i++){
        long long d = dv[i];
        long long tmp1 = bipow(K, (d+1)/2);
        long long tmp2 = 0;
        for(int j=0; j<i; j++){
            int d2 = dv[j];
            if(d % d2 == 0) tmp2 = (tmp2 + num[j]) % MOD;
        }
        num[i] = (tmp1 - tmp2 + MOD) % MOD;
    }
    long long ans = 0;
    for(int i=0; i<dv.size(); i++){
        long long d = dv[i];
        if(d % 2 == 0)
            ans += (num[i] * d / 2) % MOD;
        else
            ans += (num[i] * d) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

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

    int ans;
    if (B < C || D < A) {
        ans = 0;
    } else if (A <= C && D <= B) {
        ans = D - C;
    } else if (C <= A && B <= D) {
        ans = B - A;
    } else {
        ans = min(B - C, D - A);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int K,X;
int main(){
	scanf("%d%d",&K,&X);
	for(int i=X-K+1;i<X;i++)
		printf("%d ",i);
	printf("%d",X);
	for(int i=X+1;i<=X+K-1;i++)
		printf(" %d",i);
	puts("");
}

Measured memory_bytes: 128
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  vll a(n);
  ll S = 0;
  rep(i, n){
    cin >> a[i];
    S ^= a[i];
  }
  vll ans(n);
  rep(i, n){
    ans[i] = S ^ a[i];
  }
  print(ans);
}


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

int main() {
    int x, y;
    while (cin >> x >> y, x | y) {
        if (x < y) {
            cout << x << " " << y << endl;
        } else {
            cout << y << " " << x << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int long long
#define endl "\n"
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr(a,b,c) for(int a=b; a<c; a++)
#define frr(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define pii pair<int,int>
#define R(a) ll a; cin >> a;
#define RS(a) string  a; cin >> a;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

#define RA(a, n) ll a[(n) + 1] = {}; fr(i, 1, (n)+1) {cin >> a[i];}
#define RM(a, n, m) int a[n + 1][m + 1] = {}; fr(i, 1, n+1) {fr(j, 1, m+1) cin >> a[i][j];}
#define reset(X) memset(X, 0, sizeof(X))
using vi=vector<int>;
const int inf = 1e18;
const int mod=1e9+7;
unsigned int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool isPrime(int n)
{   if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
int modInverse(int n, int p)
{
    return power(n, p-2, p);
}
signed main()
{
    fastio;
    R(n);
    int mxp=-inf,mnp=inf,mxn=-inf,mnn=inf;
    fr(i,1,n+1)
    {
        R(x);R(y);
        mxp=max(mxp,x+y);
        mnp=min(mnp,x+y);
        mxn=max(mxn,x-y);
        mnn=min(mnn,x-y);
    }
    cout<<max(mxp-mnp,mxn-mnn);
    return 0;


}


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

int main(){
    string s,t;
    cin>>s>>t;
    int c=0;
    for(int i=0; s[i]; i++){
        if(s[i]==t[i])c++;
    }
    if(c==s.length() ) cout<<"Yes";
    else cout<<"No";

}


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

int main() {
    int a, b, c, k; cin >> a >> b >> c >> k;
    int maxv = max(max(a, b), c);
    cout << maxv * (pow(2, k) - 1) + a + b + c << endl;
    
    return 0;
}

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

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

  vector<int> vec(N);
  rep(i, N){
    cin >> vec.at(i);
  }

  int j = 0;
  bool ans = true;

  rep(i, N){
    for(; vec.at(i) % 2 == 0; j++){
      vec.at(i) /= 2;
    }
  }
  
  cout << j << endl;
}

Measured memory_bytes: 256
from sys import stdin


def get_result(data):
    S, T = data[0]
    A, B = data[1]
    U = data[2][0]
    if S == U:
        A = A - 1
    elif T == U:
        B = B - 1
    return ' '.join([str(A), str(B)])

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(str, val.split(' '))) for val in raw_data]
    data[1] = [int(val) for val in data[1]]
    result = get_result(data)
    print(result)


Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


int main(void){
  int x;
  scanf("%d",&x);
  if(x==0){
    printf("1\n");
  }else{
    printf("0\n");
  }
  return 0;
}

Measured memory_bytes: 1664
w, h, n = map(int, raw_input().split())
nums = []
for i in range(n):
  nums.append(map(int, raw_input().split()))

res = 0
x_1, x_2, y_1, y_2 = 0, w, 0, h
for a in nums:
  if a[2] == 1:
    if a[0] > x_1:
      x_1 = a[0]
  elif a[2] == 2:
    if a[0] < x_2:
      x_2 = a[0]
  elif a[2] == 3:
    if a[1] > y_1:
      y_1 = a[1]
  elif a[2] == 4:
    if a[1] < y_2:
      y_2 = a[1]
if x_2 <= x_1 or y_2 <= y_1:
  print(0)
else:
  print((y_2-y_1)*(x_2-x_1))

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

using namespace std;

int main(){
	int N, M;
	cin >> N >> M;
	int a[N], b[N], c[M], d[M];
	for(int i = 0; i < N; i++){
		cin >> a[i] >> b[i];
	}
	for(int j = 0; j < M; j++){
		cin >> c[j] >> d[j];
	}


	for(int i = 0; i < N; i++){
		int min_length = pow(10, 8) * 2 * pow(2, 0.5);
		int min_index;
		for(int j = 0; j < M; j++){
			int length = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if(length < min_length){
				min_length = length;
				min_index = j;
			}
		}
		cout << min_index + 1 << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<int, int> P;


//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int 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;
	}
}

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

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}


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

int main() {

ll n,d;
cin>>n>>d;
ll z[n+1][d+1];
rep(i,n){
	rep(j,d){
		cin>>z[i][j];
	}
}

ll ans=0;
for(int i=1;i<=n-1;i++){
	for(int j=i+1;j<=n;j++){

ll v=0;
for(int k=1;k<=d;k++){
v+=abs(z[i][k]-z[j][k])*abs(z[i][k]-z[j][k]);

}

for(int l=1;l<=10000;l++){
	if(l*l==v){ans++;
	break;}
}


	}
}




cout<<ans<<endl;
return 0;

}




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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define mod 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()

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

  int n = S;
  map<int, int> m;
  m[n] = 1;

  for (int i = 2; i <= 1000000 ; i++) {
   if (n % 2 == 0) {
     n = n / 2;
   } else {
     n = 3 * n + 1;
   }

  auto f = m.find(n);
   if (f != m.end()) {
     cout << i << endl;
     return 0;
   } else {

   }
   m[n] = 1;
  }

  return 0;
}

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

class Main{
	public static void main(String arg[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.nextLine();
		Integer[]a = new Integer[N];
		int ans = 0;
		int Alice = 0;
		int Bob = 0;
		
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();
		
		Arrays.sort(a, Comparator.reverseOrder());
		
		for(int i = 0; i < N; i++) {
			if( i % 2 == 0 ) {
				Alice += a[i];
			}else {
				Bob += a[i];
			}
		}
		System.out.println(Alice - Bob);
	}
}

Measured memory_bytes: 21844
using System;
class Pg
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int[] balls = {int.Parse(input[0]), int.Parse(input[1])};
    int a, b;
    if(balls[0] == 0){a=0;}else{a = (balls[0] * (balls[0] - 1) / 2);}
    if(balls[1] == 0){b=0;}else{b = (balls[1] * (balls[1] - 1) / 2);}
    int ans = a + b;
    Console.WriteLine(ans);
  
    
  }
}

Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

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

  int n = a.size();
  int m = b.size();

  if(n == m) {
  	for(int i = 0; i < n; ++i) {
  		bool can = true;
  		for(int j = 0; can && j < n; ++j) {
  			can &= (a[j] == b[(j+i)%n]);
  		}
  		if(can)
  				return cout << "Yes", 0;
  	}
  }

  cout << "No" << flush;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;
using ll = long long;

int main() {
    ll x;
    cin >> x;

    ll money = 100;
    ll count = 0;

    while (money < x) {
        count++;
        money += money / 100;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a,b,c;
    cin >> a >> b >> c ;
    int m = max(a,max(b,c));
    if(3*m % 2 != (a+b+c)% 2 ){
        m = m + 1;
    }
        cout << (3*m - (a+b+c)) / 2 << endl;
}

Measured memory_bytes: 256
import java.awt.print.Printable;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		
		Scanner scan =new Scanner(System.in);
		int n=scan.nextInt();
		int[] arr=new int[n];
		for(int i=0;i<n;i++){
			arr[i]=scan.nextInt();
		}
		//insertsort(arr,n);
		bubblesort(arr,n);
	}

	public  static void insertsort(int[] arr,int n){
		arrPrint(arr);
		for(int i=1;i<n;i++){
			int tmp=arr[i];
			int j=i-1;
			while(j>=0&&arr[j]>tmp){
				arr[j+1]=arr[j];
				j--;
			}
			arr[j+1]=tmp;
			arrPrint(arr);
		}
	}
	
	public static void bubblesort(int[] arr,int n){
		int res=0;
		for(int i=0;i<n;i++){
			boolean flag=false;
			for(int j=n-1;j>i;j--){
				if(arr[j]<arr[j-1]){
					int tmp=arr[j];
					arr[j]=arr[j-1];
					arr[j-1]=tmp;
					flag=true;
					res++;
				}
				
			}
			if(flag==false)
				break;
		}
		arrPrint(arr);
		System.out.println(res);
	}
	
	
	public static void arrPrint(int[] arr){
		int i=0;
		for(i=0;i<arr.length-1;i++)
			System.out.print(arr[i]+" ");
		System.out.println(arr[i]);
	}
}



Measured memory_bytes: 26384
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int N,M;
vi g[1010],r[1010];
int used[1010];
int List[1010],l;
int cycle[1010],c;
int inCycle[1010];
ll dp[1010];

void dfs(int cur){
	if(used[cur]){
		int from = 0;
		while(List[from] != cur) from++;
		rep2(i,from,l){
			cycle[c++] = List[i];
		}
		return;
	}
	used[cur] = 1;
	List[l++] = cur;
	if(sz(g[cur]) == 0){
		cycle[c++] = cur;
		return;
	}
	rep(i,sz(g[cur])){
		dfs(g[cur][i]);
	}
}

ll solve(int v){
	ll& res=dp[v];
	if(res != -1)return res;
	used[v] = 1;
	res = 1;
	rep(i,sz(r[v])){
		res = res * solve(r[v][i]) % MOD;
	}
	res = (res+1) % MOD;
	return res;
}

ll f(int start){
	l=0;
	c=0;
	dfs(start);
	ll res = 1;
	rep(i,c)inCycle[cycle[i]] = 1;
	rep(i,c)rep(j,sz(r[cycle[i]])){
		if(inCycle[r[cycle[i]][j]])continue;
		res = res * solve(r[cycle[i]][j]) % MOD;
	}
	res = (res+1) % MOD;
	return res;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>N>>M;
	rep(i,M){
		int s,d;
		cin>>s>>d;
		s--;d--;
		g[s].pb(d);
		r[d].pb(s);
	}

	memset(dp,-1,sizeof(dp));
	ll ans = 1;
	rep(i,N)if(!used[i]){
		ans = ans * f(i) % MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1344
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
template <typename T> T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;

struct edge {
    int to, cost;
};

using edges = vector<edge>;
using graph = vector<edges>;

int main() {
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    for(int i = 0; i < R; ++i) {
        cin >> r[i];
        r[i]--;
    }
    graph g(N);
    for(int i = 0; i < M; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        g[a - 1].push_back(edge{b - 1, c});
        g[b - 1].push_back(edge{a - 1, c});
    }

    int res = inf<int>;
    for(int s = 0; s < R; ++s) {
        vector<vector<int>> d(1 << R, vector<int>(N, inf<int>));
        d[0][r[s]] = 0;
        using state = tuple<int, int, int>;
        priority_queue<state, vector<state>, greater<state>> que;
        que.emplace(0, 1 << s, r[s]);
        while(!que.empty()) {
            int cur_d, S, v;
            tie(cur_d, S, v) = que.top();
            que.pop();
            if(d[S][v] < cur_d) {
                continue;
            }
            for(auto& e : g[v]) {
                int j = find(r.begin(), r.end(), e.to) - r.begin();
                int nS = (j != R ? S | (1 << j) : S);
                int nd = cur_d + e.cost;
                if(d[nS][e.to] > nd) {
                    d[nS][e.to] = nd;
                    que.emplace(nd, nS, e.to);
                }
            }
        }
        for(int i = 0; i < N; ++i) {
            res = min(res, d[(1 << R) - 1][i]);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3364
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  int n, m, p, w, s, x;
  
  while(cin >> n >> m >> p && (n|m|p)) {
    s = 0;
    for(int i=0; i<n; i++) {
      cin >> x;
      s += x;
      if(i == m-1) w = x;
    }
    if(w == 0) cout << 0 << endl;
    else cout << s*100*(100-p)/100/w << endl;
  }
  
  return 0;
}

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

using namespace std;

const int inf = 1e9;

int f[100010];

int main() {
  int n;
  scanf("%d", &n);
  fill(f + 1, f + n + 1, inf);
  for (int rot = 0; rot < 2; rot++) {
    int b = rot ? 6 : 9;
    for (int i = 1; i <= n; i++) {
      for (int p = 1; p <= i; p *= b) {
        f[i] = min(f[i], f[i - p] + 1);
      }
    }
  }
  printf("%d\n", f[n]);
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, n) for (ll i = a; i < n; i++)

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    double w,h;
    int n;
    double ow=0,oh=0;
    cin >>w>> h>> n;
    REP(i,n){
        double x,y;
        int a;
        cin >> x >> y >> a;
        if(a==1 && ow<x) ow= x;
        if(a==2 && x<w) w= x;
        if(a==3 && oh<y) oh= y;
        if(a==4 && y<h) h= y;
        // cout << (w-ow)*(h-oh) << endl;
    }
    cout << ((w>ow&&h>oh)?(w-ow)*(h-oh):0) << endl;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> l(m), r(m);
    rep(i, m) {
        cin >> l[i] >> r[i];
    }
    vector<int> left(m), right(m);
    int ans;
    bool flag = true;
    rep(i, m) {
        if (i == 0) {
            left[i] = l[i];
            right[i] = r[i];
        } else {
            if (l[i] > right[i-1] || r[i] < left[i-1]) {
                flag = false;
                break;
            } else {
                if (l[i] > left[i-1]) left[i] = l[i];
                else left[i] = left[i-1];
                if (r[i] < right[i-1]) right[i] = r[i];
                else right[i] = right[i-1];
            }
        }
        if (right[i] > n) right[i] = n;
    }
    if (flag) {
        // if (right[m-1] <= n) {
            ans = right[m-1] - left[m-1] + 1;
        // } else if (left[m-1] >= n) {
        //     ans = n - left[m-1] + 1;
        // } else {
        //     ans = 0;
        // }
    } else {
        ans = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4836
#include<stdio.h>
int main(void)
{int a[7],b[7],i;
  for(i=0; i<7; i++){
    scanf("%d %d",&a[i],&b[i]);

  }

  for(i=0; i<7; i++){
    printf("%d\n",a[i] - b[i]);}

  return(0);

}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        int a;
        scanf("%d",&a);
        if(a%2!=0)
        {
            printf("first");
            return 0;
        }
    }
    printf("second");
    return 0;
}


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

void solve(long long N, long long L)
{
    long long sum = 0;
    long long min = 9999999;
    for (int i = 0; i < N; i++) {
        long long tmp = i + L;
        if (abs(tmp) < abs(min)) {
            min = tmp;
        }
        sum += tmp;
    }
    printf("%lld\n", sum - min);
}

int main()
{
    long long N;
    scanf("%lld",&N);
    long long L;
    scanf("%lld",&L);
    solve(N, L);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
int main(){
  int N; cin >> N;
  vector<int>A(N);
  rep(i,N) cin >> A[i];
  set<int>s;
  rep(i,N) s.insert(A[i]);
  if (s.size() == N) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1e9+7;
using namespace std;
typedef pair<int,int> pii;
vector<long> primes_(long n){
    bool judge[n+1];
    for(int i = 0;i<=n;i++){
        judge[i] = true;
    }
    vector<long> prime;
    for(int i = 2;i<=n;i++){
        if(judge[i]){
            for(int j = 2*i;j<=n;j+=i){
                judge[j] = false;
            }
            prime.push_back(i);//ここでprimeに入れられる素数の条件を指定できる
        }
    } 
    return prime;
}
//aのMODbでの逆元
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
//x^n(MOD)
long long power(int x,long long n,long long MOD){
    long long a = 1;
    long long b = x;
    while(n>0){
        if(n%2==1){
            a*=b;
            a%=MOD;
        }
        n/=2;
        b = b*b;
        b%=MOD;
    }
    return a;
}
int main(){
    int n;
    cin >> n;
    long long a[n];
    rep(i,n) cin >> a[i];
    vector<long> primes = primes_(long(1e3+5));
    set<long long> big;
    int pnum[primes.size()];
    fill_n(pnum,primes.size(),0);
    rep(i,n){
        long long tmp = a[i];
        rep(j,primes.size()){
            int cnt = 0;
            while(tmp%primes[j]==0){
                tmp/=primes[j];
                cnt++;
            }
            pnum[j] = max(pnum[j],cnt);
        }
        if(tmp!=1) big.insert(tmp);
    }
    long long lcm = 1;
    //cout << pnum[0] << " " << pnum[1] << " " << pnum[2] << endl;
    rep(i,primes.size()){
        lcm*=power(primes[i],pnum[i],MOD);
        lcm%=MOD;
        //cout << lcm << endl;
    }
    for(auto itr = big.begin();itr!=big.end();itr++){
        lcm*=*itr;
        lcm%=MOD;
        //cout << lcm << endl;
    }
    long long ans = 0;
    rep(i,n){
        long long k = lcm*modinv(a[i],MOD);
        k%=MOD;
        ans+=k;
        ans%=MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	int N,M;
	cin>>N>>M;
	vpint V[SIZE];
	for(int i=0;i<M;i++){
		int p,y;
		cin>>p>>y;
		V[p-1].eb(y,i);
	}
	for(int i=0;i<SIZE;i++)
		sort(V[i].begin(),V[i].end());
	char ans[SIZE][100];
	for(int i=0;i<N;i++){
		for(int j=0;j<V[i].size();j++){
			char S[100];
			sprintf(S,"%06d%06d",i+1,j+1);
			strcpy(ans[V[i][j].second],S);
		}
	}
	for(int i=0;i<M;i++)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 16768
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	long long  x, y;
	scanf("%lld%lld", &x, &y);
	if (x == 0 || y == 0) {
		if (x <= y) {
			printf("%d", y - x);
		}
		else {
			printf("%d", x - y + 1);
		}
	}
	else  if (x * y > 0) {
		if (x <= y) {
			printf("%lld", y - x);
		}
		else {
			printf("%lld", x - y + 2);
		}
	}
	else {
		if (x >= y) {
			printf("%lld", abs(abs(y) - x) + 1);
		}
		else {
			printf("%lld", abs(y - abs(x)) + 1);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll inf = 1LL<<60;
const ll mod = 1000000007;

int dp[105][4][4][4];

int main(){
    int N; cin >> N;
    dp[0][3][3][3] = 1;
    
    for(int len=0; len<N; len++){
        for(int i=0; i<4; i++){
            for(int j=0; j<4; j++){
                for(int k=0; k<4; k++){
                    
                    for(int a=0; a<4; a++){
                        if(j==0 && k==2 && a==1) continue;
                        if(j==0 && k==1 && a==2) continue;
                        if(j==1 && k==0 && a==2) continue;
                        if(i==0 && j==1 && a==2) continue;
                        if(i==0 && k==1 && a==2) continue;

                        dp[len+1][j][k][a] += dp[len][i][j][k];
                        dp[len+1][j][k][a] %= mod;

                    }
                }
            }
        }
    }

    ll ans = 0;
    for(int i=0; i<4; i++){
        for(int j=0; j<4; j++){
            for(int k=0; k<4; k++){
                ans += dp[N][i][j][k];
                ans %= mod;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256