akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct Node{
  int key;
  struct Node *right,*left,*parent;
};
struct Node *root, *NIL,*t;

struct Node * find(struct Node *u,int k){
  while (u!=NIL && k!=u->key){
    if(k<u->key){
      u=u->left;
    }
    else{
      u=u->right;
    }
  }
  return u;
}

void insert(int k){
  struct Node *y = NIL;
  struct Node *x =root;
  struct Node *z;

  z=(struct Node *)malloc(sizeof(struct Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key < y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }
}

void inorder(struct Node *u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int i,n,x;
  char com[10];
  char s0[10]="find";
  char s1[10]="insert";
  char s2[10]="print";
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(strcmp(com,s0)==0){
      scanf("%d",&x);
      struct Node *t=find(root,x);
      if(t!=NIL){
	printf("yes\n");
      }
      else{
	printf("no\n");
      }
    }
    else if(strcmp(com,s1)==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(com,s2)==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  
  return 0;
}



Measured memory_bytes: 20448
x, y = map(int, input().split())
if x >= 0 and y >= 0:
    if x <= y:
        ans = abs(x-y)
    elif y == 0:
        ans = abs(x-y)+1
    else:
        ans = abs(x-y)+2
elif x < 0 and y <= 0:
    if x <= y:
        ans = abs(x-y)
    else:
        ans = abs(x-y)+2
else:
    ans = abs(abs(x)-abs(y))+1
print(ans)


Measured memory_bytes: 3060
class Dice(object):
    def __init__(self, s1, s2, s3, s4, s5, s6):
        self.s1 = s1
        self.s2 = s2
        self.s3 = s3
        self.s4 = s4
        self.s5 = s5
        self.s6 = s6
    def east(self):
        prev_s6 = self.s6
        self.s6 = self.s3
        self.s3 = self.s1
        self.s1 = self.s4
        self.s4 = prev_s6
    def west(self):
        prev_s6 = self.s6
        self.s6 = self.s4
        self.s4 = self.s1
        self.s1 = self.s3
        self.s3 = prev_s6
    def north(self):
        prev_s6 = self.s6
        self.s6 = self.s5
        self.s5 = self.s1
        self.s1 = self.s2
        self.s2 = prev_s6
    def south(self):
        prev_s6 = self.s6
        self.s6 = self.s2
        self.s2 = self.s1
        self.s1 = self.s5
        self.s5 = prev_s6
    def top(self):
        return self.s1
 
s1, s2, s3, s4, s5, s6 = map(int, input().split())
dice = Dice(s1, s2, s3, s4, s5, s6)
order = input()
for c in order:
    if c == 'N':
        dice.north()
    elif c == 'W':
        dice.west()
    elif c == 'E':
        dice.east()
    elif c == 'S':
        dice.south()
print(dice.top())


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

class Test
{
    static void Main()
    {
        string ss;
        while ((ss = Console.ReadLine()) != "0 0")
        {
            var temp = ss.Split().Select(int.Parse).ToArray();
            int n = temp[0];
            int x = temp[1];

            int count = 0;
            for (int i = 1; i <= n - 2; i++)
            {
                for (int j = i + 1; j <= n - 1; j++)
                {
                    for (int k = j + 1; k <= n; k++)
                    {
                        if (i + j + k == x) count++;
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 18400
#include <stdio.h>
int main(){
    int a,b,k;
    scanf("%d",&k);
    scanf("%d %d",&a,&b);
    int s,t,u,v;
    s=a/k;
    t=b/k;
    u=a%k;
    v=b%k;
    
    if(s!=t){
        printf("OK");
    }else if(u==0 ||v==0){
        printf("OK");
    }else{
        printf("NG");
    }
    
    return 0;
}


Measured memory_bytes: 1684
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cctype>
#include<string>
using namespace std;
template<typename T>inline T read(){
	register char c=getchar();register T x=0,b=1;
	for(;!isdigit(c);)b=(c=='-'?-1:1),c=getchar();
	for(;isdigit(c);)x=x*10+c-48,c=getchar();
	return x*b;
}
template<typename T>void put(T x){ //no negative
	if(x>9)put(x/10);
	putchar(x%10+48);
}
string s;
int main(){
	register int a=read<int>();
	cin>>s;
	if(a<3200){
		puts("red");
		return 0;
	}
	cout<<s;
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
#define MOD 1000000000

int main(){
  ll n,k,s; cin >> n >> k >> s;
  rep(i,n){
    if(i<k) cout << s;
    else cout << (s+1)%MOD;
    cout << " ";
  }
}


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

int n, k;
vector<int> a;
bool check(int l){
    int times = 0;
    for(int i = 0; i < n; ++i){
        times += a[i] / l;
        if(a[i] % l == 0) --times;
    }

    return times <= k;
}

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

    cin >> n >> k;

    a.resize(n);
    int ok = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        ok = max(ok, a[i]);
    }
    int ng = 0;

    while(ok - ng > 1){
        int mid = (ok + ng) / 2;

        if(check(mid)) ok = mid;
        else ng = mid;
    }

    cout << ok << endl;

    return 0;
}

Measured memory_bytes: 3888
n = int(input())
time = []

for i in range(n):
    time.append(int(input()))

def gcd(a,b):
    if a == 0:
        return b
    return gcd(b % a, a)

def lcm(a,b):
    return (a*b) // gcd(a,b)

ans = time[0]
for i in range(0, n):
    ans = lcm(ans, time[i])

print(ans)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;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--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_146_b() {
	ll N;
	string S;

	cin >> N >> S;

	string ans = S;
	char tmp;
	rep(i, S.size()) {
		tmp = S[i];
		if (tmp + N > 'Z') {
			tmp = (tmp - 'Z') + ('A' + N - 1);
		}
		else {
			tmp = tmp + N;
		}
		ans[i] = tmp;
	}

	cout << ans << "\n";
}

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

	solve_abc_146_b();

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_&Alang=jp>
 */

func init() {
}

func main() {
	for {
		var n, x int
		fmt.Scanf("%d %d", &n, &x)
		if n|x == 0 {
			break
		}
		cnt := 0
		for i:= 1; i <= n;i++{
			for j:=i+1;j<=n;j++{
				for k:=j+1;k<=n;k++{
					if i + j + k == x{
						cnt++;
					}
				}
			}
		}
		fmt.Println(cnt)
	}
}

Measured memory_bytes: 1128
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    string s,t; cin>>s>>t;
    map<char, vector<int>> mp;
    int n = s.length();

    rep(i,n) {
        mp[s[i]].push_back(i+1);
    }
    for (char c = 'a'; c <= 'z'; c++) {
        if (!mp[c].empty()) mp[c].push_back(INF);
    }

    int m = t.length();
    ll ans = 0;
    ll cur = 0;

    rep(i,m) {
        if (mp[t[i]].empty()) {
            cout << -1 << '\n';
            return 0;
        }
        auto itr = upper_bound(mp[t[i]].begin(), mp[t[i]].end(), cur);
        if (*itr == INF) {
            ans += n;
            cur = 0;
            auto itr2 = upper_bound(mp[t[i]].begin(), mp[t[i]].end(), cur);
            cur = *itr2;
        }
        else {
            cur = *itr;
        }
    }

    ans += cur;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1216
from sys import stdin
import numpy as np

N, K = [int(x) for x in stdin.readline().rstrip().split()]
A = np.sort(np.array([int(x) for x in stdin.readline().rstrip().split()]))
MINUS = A[A < 0]
ZERO = A[A == 0]
PLUS = A[A > 0]


def solve(x):
    count_tpl = 0
    if x >= 0:
        count_tpl += len(ZERO) * N
    count_tpl += np.searchsorted(A, x // PLUS, side='right').sum()
    count_tpl += (N - np.searchsorted(A, (-x - 1) // (-MINUS), side='right')).sum()
    count_tpl -= np.count_nonzero(A * A <= x)
    assert count_tpl % 2 == 0
    return count_tpl // 2






left = -10**18
right = 10**18
while left + 1 < right:
    x = (left + right) // 2
    if solve(x) >= K:
        right = x
    else:
        left = x
print(right)

Measured memory_bytes: 32320
N, X = map(int, input().split())
num_p = [2**(i+1)-1 for i in range(N+1)]
num_layer = [2**(i+2)-3 for i in range(N+1)]
def f(N, X):
    if N == 0:
        if X == 0:
            return 0
        else:
            return 1
    elif X == 1:
        return 0
    elif X <= 1 + num_layer[N-1]:
        return f(N-1, X-1)
    elif X == 2 + num_layer[N-1]:
        return 1 + num_p[N-1]
    elif X < 2 + 2 * num_layer[N-1]:
        return num_p[N-1] + 1 + f(N-1, X - 2 - num_layer[N-1])
    else:
        return 2 * num_p[N-1] + 1
print(f(N, X))

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

using namespace std;


typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;

#define rep(i,b) for(i=0;i<b;++i)
#define repp(i,a,b) for(i=a;i<b;++i)

int main() {
    ll n, m = -1001001001, pos = -1;
    cin >> n;
    std::vector<ll> v(n + 1);
    for(int i = 1; i <= n; i++){
        cin >> v[i];
        if(v[i] > m) pos = i;
    }
    bool flag = false;
    ll sum = 1, tot = 10010010001;
    for(int j = 1; j <= 100; j++){
        sum = 0;
        for(int i = 1; i <= n; i++){
            ll ans = pow((v[i] - j), 2);
            sum += ans;
        }
        tot = min (sum, tot);
        if(sum > tot) break;
        //cout << "ans for j = " << j << " = "<< sum << endl;
    }

    cout << tot;
    return 0;
}
/*
         ,--"""",--.__,---[],-------._
       ,"   __,'            \         \--""""""==;-
     ," _,-"  "/---.___     \       ___\   ,-'',"
    /,-'      / ;. ,.--'-.__\  _,-"" ,| `,'   /
   /``""""-._/,-|:\       []\,' ```-/:;-. `. /
             `  ;:::      ||       /:,;  `-.\
                =.,'__,---||-.____',.=
                =(:\_     ||__    ):)=
               ,"::::`----||::`--':::"._
             ,':::::::::::||::::::::::::'.
    .__     ;:::.-.:::::__||___:::::.-.:::\     __,
       """-;:::( O )::::>_|| _<::::( O )::::-"""
   =======;:::::`-`:::::::||':::::::`-`:::::\=======
    ,--"";:::_____________||______________::::""----.          , ,
         ; ::`._(    |    |||     |   )_,'::::\_,,,,,,,,,,____/,'_,
       ,;    :::`--._|____[]|_____|_.-'::::::::::::::::::::::::);_
      ;/ /      :::::::::,||,:::::::::::::::::::::::::::::::::::/
     /; ``''''----------/,'/,__,,,,,____:::::::::::::::::::::,"
     ;/                :);/|_;| ,--.. . ```-.:::::::::::::_,"
    /;                :::):__,'//""\\. ,--.. \:::,:::::_,"
   ;/              :::::/ . . . . . . //""\\. \::":__,"
   ;/          :::::::,' . . . . . . . . . . .:`::\
   ';      :::::::__,'. ,--.. . .,--. . . . . .:`::`
   ';   __,..--'''-. . //""\\. .//""\\ . ,--.. :`:::`
   ;    /  \\ .//""\\ . . . . . . . . . //""\\. :`::`
   ;   /       . . . . . . . . . . . . . . . . .:`::`
   ;   (          . . . . . . . . . . . . . . . ;:::`
   ,:  ;,            . . . . . . . . . . . . . ;':::`
   ,:  ;,             . . . . . . . . . . . . .;`:::
   ,:   ;,             . . . . . . . . . . . . ;`::;`
    ,:  ;             . . . . . . . . . . . . ;':::;`
     :   ;             . . . . . . . . . . . ,':::;
      :   '.          . . . . . . . .. . . .,':::;`
       :    `.       . . . . . . . . . . . ;::::;`
        '.    `-.   . . . . . . . . . . ,-'::::;
          `:_    ``--..___________..--'':::::;'`
             `._::,.:,.:,:_ctr_:,:,.::,.:_;'`
________________`"\/"\/\/'""""`\/"\/""\/"____________________________

*/


Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.*;
import java.io.*;

public class Main{
	int [] vx = {0,1,0,-1};
	int [] vy = {-1,0,1,0};
	
	int [] diax = {1, -1, -1, 1};
	int [] diay = {1, 1, -1, -1};
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			int d = sc.nextInt();
			if((w|h|d) == 0) break;
			
			int wh = w * h;
			int [][] a = new int[wh][wh + 1];
			for(int i = 0; i < wh; i++){
				a[i][wh] = sc.nextInt();
			}
			
			for(int i = 0; i < wh; i++){
				a[i][i] = 1;
				for(int j = 0; j < 4; j++){
					int x = (i % w) + vx[j] * d;
					int y = (i / w) + vy[j] * d;
					if(isOK(x, y, w, h)){
						a[i][y * w + x] = 1;
					}
					
					for(int  k = 0; k < d-1; k++){
						x = x + diax[j];
						y = y + diay[j];
						if(isOK(x, y, w, h)){
							a[i][y * w + x] = 1;
						}
					}
				}
			}
			
			System.out.println(solve(a, wh) ? 1 : 0);
		}
	}
	
	private boolean solve(int[][] a, int elementSize) {
		int n = a.length;
		for(int i = 0; i < n; i++){
			int pivot = i;
			for(int j = i; j < n; j++){
				if(Math.abs(a[j][i]) > Math.abs(a[pivot][i])) pivot = j;
			}
			
			if(Math.abs(a[pivot][i]) == 0) continue;
			
			for(int j = 0; j <= n; j++){
				int temp = a[i][j];
				a[i][j] = a[pivot][j];
				a[pivot][j] = temp;
			}
			
			for(int j = 0; j < n; j++){
				if(i != j && a[j][i] != 0){
					for(int k = i; k <= n; k++){
						a[j][k] ^= a[i][k];
					}
				}
			}
		}
		
		
		for(int i = 0; i < n; i++){
			if(a[i][i] == 0 && a[i][n] != 0){
				return false;
			}
		}
		
		return true;
	}

	private boolean isOK(int x, int y, int w, int h) {
		return (0 <= x && x < w && 0 <= y && y < h);
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 65004
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int x, y;
	cin >> x >> y;
	cout << x + y / 2 << endl;
}

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

	solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())

int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;

    vector<double> vec(n);
    int a;
    REP(i,n){
        cin >> a;
        vec[i] = (double)(1+a)/2.0;
    }
    vector<double> rui(n+1);
    rui[0] = 0;
    for(int i=1; i <=n; i++){
        rui[i] = rui[i-1] + vec[i-1];
    }
    double m= 0;
    for(int i = k;i <=n;i++){
        m = max(m,(rui[i]-rui[i-k]));
    }
    printf("%.6f\n",m);
}





Measured memory_bytes: 3328
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
 
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cassert>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <numeric>
#include <time.h>
#include <stack>
#include <bitset>

#define prev asasddlsa
#define rank aljds

#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i++)
 
using namespace std;
 
typedef long long ll;
typedef double dbl;
 
template<typename T>
void print(const vector<T>& s){
    for (auto x : s)
        cout << x << " ";
    cout << endl;
}
 
template<class T>   
void print(const T* s, int n){
    for (int i = 0; i < n; i++)
        cout << s[i] << ' ';
    cout << endl;
}

template<class T>
void print(vector<vector<T>> s){
    for (int i = 0; i < s.size(); i++)
        print(s[i]);
}

int solve(){
    int n;
    cin >> n;
    vector<int> s(2 * n);
    for (int& x : s)
        cin >> x;
    sort(s.begin(), s.end());
    int res = 0;
    for (int i = 0; i < 2 * n; i += 2){
        res += s[i];
    }
    cout << res << endl;
    return 0;
}

int main(){
    srand(time(NULL));
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(10);
    cout << fixed; 
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}


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

double a, b, x;

int main() {
    cout << fixed << setprecision(10);

    cin >> a >> b >> x;

    double theta = 0.0;
    
    if (x >= a*a*b/2) {
        double y = 2*(a*a*b-x)/(a*a);
        theta = atan(y/a);
    }
    else {
        double y = 2*x/(a*b);
        theta = atan(b/y);
    }


    cout << 180/M_PI * theta << endl;

    return 0;
}


Measured memory_bytes: 256
s = input()
t = input()

dic_s = {}
dic_t = {}

for i, j in zip(s, t):
    if i not in dic_s.keys():
        dic_s[i] = 1
    else:
        dic_s[i] += 1
    if j not in dic_t.keys():
        dic_t[j] = 1
    else:
        dic_t[j] += 1

dic_s = sorted(dic_s.items(), key=lambda x: x[1])
dic_t = sorted(dic_t.items(), key=lambda x: x[1])

for i in range(min(len(dic_s), len(dic_t))):
    if dic_s[i][1] != dic_t[i][1]:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 3632
h,w = gets.split.map(&:to_i)
c = []
10.times {c << gets.split.map(&:to_i)}

10.times do |k|
    10.times do |s|
        10.times do |f|
            if c[s][f] > c[s][k] + c[k][f]
                c[s][f] = c[s][k] + c[k][f]
            end
        end
    end
end

num = Array.new(11,0)
h.times do
    gets.split.map{|e| num[e.to_i] += 1}
end

ans = 0
10.times do |i|
    ans += c[i][1] * num[i]
end

puts ans

Measured memory_bytes: 2300
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  ll n;
  cin>>n;
  ll best = 1*n;
  for(int i=1;i<=2000000;i++){
  	if(n%i==0){
  		best=min(best,(i-1)+(n/i)-1);
  	}
  }
  cout<<best<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char str[10];
int mem[200],num;
int main(){
	scanf("%s",str);
	mem[str[0]]++,mem[str[1]]++,mem[str[2]]++,mem[str[3]]++;
	for(int i=1;i<=150;i++)if(mem[i])num++;
	if(num==2)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
from itertools import product, accumulate
import sys
sys.stdin.readline

def main():
    N, W = map(int, input().split())
    V = [[] for _ in range(4)]
    w1 = 0
    for i in range(N):
        w, v = map(int, input().split())
        if i == 0: w1 = w
        V[w-w1].append(v)
    U = []
    for i in range(4):
        U.append([0] + list(accumulate(sorted(V[i], reverse=True))))

    ans = 0
    for prod in product(*[range(len(U[i])) for i in range(4)]):
        if sum((i+w1)*p for i, p in enumerate(prod)) <= W:
            ans = max(ans, sum(U[i][p] for i, p in enumerate(prod)))
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
using namespace std;
 
int main(){
  int l,r; cin>>l>>r;
  for(int i=l;i<=r;i++) {
    if (i%2019 == 0) return puts("0") * 0;
  }
  int an=2018;
  for(int i=l;i<r;i++) {
    for(int j=i+1;j<=r;j++) {
      //cout<<i<<" "<<j<<" "<<(i%2019)*(j%2019)%2019<<endl;
      an=min(an,(i%2019)*(j%2019)%2019);
    }
  }
  cout<<an<<endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))#n+1
b = list(map(int,input().split()))
cnt = 0
for i in range(n):
    if b[i] > a[i]:
        cnt += a[i]
        b[i] -= a[i]
        a[i] = 0
    elif b[i] == a[i]:
        cnt += b[i]
        b[i] = 0
        a[i] = 0
    else:
        cnt += b[i]
        a[i] -= b[i]
        b[i] = 0
    if b[i] <= 0:
        pass
    elif a[i+1] > b[i]:
        cnt += b[i]
        a[i+1] -= b[i]
        b[i] = 0
    elif a[i+1] < b[i]:
        cnt += a[i+1]
        b[i] -= a[i+1]
        a[i+1] = 0
    elif a[i+1] == b[i]:
        cnt += b[i]
        b[i] = 0
        a[i+1] = 0
print(cnt)





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

dp = [float('inf')] * (1 << N)
dp[0] = 0

u = 1 << N
for i in range(M):
    a, b = map(int, input().split())
    c = sum(1 << (x - 1) for x in map(int, input().split()))

    for j in range(u):
        dp[c | j] = min(dp[c | j], dp[j] + a)


if dp[-1] != float('inf'):
    print(dp[-1])
else:
    print(-1)


Measured memory_bytes: 50012
#include<stdio.h>

int main(void) {

	int n;

	scanf("%d", &n);

	if (n % 10 == 7 || (n / 10) % 10 == 7 || (n / 100) % 10 == 7) printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int fbit(vector<int>& v){
  int out = 0;
  for(int l =0; l< v.size(); ++l){
    out += v[l]*(int)pow(2,l);
  }
  return out;
}

int main() {
  int n;cin >> n;
  vector<vector<int>> f, p;
  for(int i=0;i<n;++i){
    vector<int> fi;
    for(int j=0;j<10;++j){
      int fij;cin>> fij;
      fi.push_back(fij);
    }
    f.push_back(fi);
  }
  for(int i=0;i<n;++i){
    vector<int> pi;
    for(int j=0;j<11;++j){
      int pij;cin>> pij;
      pi.push_back(pij);
    }
    p.push_back(pi);
  }
  int max_c = -1000000007;
  for (int bit=1;bit < (1<<10); ++bit) {
    int c = 0;
    for (int k=0; k<n; ++k) {
      int f_bit = fbit(f[k]);
      int flag = (bit&f_bit);
      int cnt_f =0;
      for(int l=0; l< 10; ++l){
        if (flag & (1<<l)) ++cnt_f;
      }
      c += p[k][cnt_f];
    }
    max_c = max(max_c, c);
  }
  cout << max_c << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD ((int)1e9 + 7)
#define atoi(x) ((x)-'0')
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

string s;

int main() {
	cin >> s;
	if (s == "RRR") cout << 3;
	else if (s == "RRS" || s == "SRR") cout << 2;
	else if (s == "SSS") cout << 0;
	else cout << 1;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <iostream>

using namespace std;
typedef long long ll;
ll a,b,c,i,j,k,n,m,t,r,s,p;
ll arr[100005];
int main(){
	scanf("%lld%lld%lld%lld%lld",&n,&k,&r,&s,&p);
	string ss;
	cin>>ss;
	n=0;
	for(i=0;i<ss.length();i++){
		if(i-k<0||ss[i]!=ss[i-k]){
			if(ss[i]=='s')
				n+=r;
			else if(ss[i]=='r')
				n+=p;
			else
				n+=s;
		}
		else
            ss[i]=' ';
	}
	printf("%lld",n);
	return 0;
}


Measured memory_bytes: 512
from heapq import heapify, heappush, heappop
def solve():
    n, m = map(int, input().split())
    A = [-int(i) for i in input().split()]
    heapify(A)
    for _ in range(m):
        heappush(A, -(-heappop(A) // 2))
    print(-sum(A))
solve()


Measured memory_bytes: 14180
#include <stdio.h>
int main(void){
    int m,d,dt,nm,nd,nd1,nd2,ans;
    ans = 0;
    scanf("%d", &m);
    scanf("%d", &d);
    for(nm = 1;nm <= m;nm ++){
        for(nd = 1;nd <= d;nd ++){
            dt = nd;
            nd1 = 0;
            nd2 = 0;
            while(dt >= 10){
               nd2 = nd2 + 1;
               dt = dt - 10;
            }
            while(dt > 0){
            nd1 = nd1 + 1;
            dt = dt - 1;
            }
            if(nd1 >= 2 && nd2 >= 2) 
            if(nd1 * nd2 == nm){
                ans = ans + 1;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

int func(int x){
  if(x%100 != 0)
    return 0;
  return func(x/100) + 1;
}

int main(){
  int d, n;
  cin >> d >> n;
  int count = 0;
  for(int x =1; ; x++){
    if(func(x) == d){
      count++;
      if(count == n){
        cout << x << endl;
        return 0;
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<sstream>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define loop(i,a,b) for(i=(int)a;i<(int)b;i++)
#define revloop(i,a,b) for(i=(int)a;i>=(int)b;i--)
#define stloop(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<int,int>
#define MP make_pair
#define pb push_back
#define f first
#define s second
#define ll long long int
#define PI acos(-1.0)
#define rs resize
ll check(ll a)
{
 ll sum=0;
 while(a)
 {
  a/=10;
  sum++;
 }
 return sum;
}
int main()
{  std::ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   ll a,i,x,y,ans;
   ans=mod*100;
   cin>>a;
   loop(i,1,sqrt(a)+5)
    if(a%i==0)
    {
     x=check(i);
     y=check(a/i);
     x=max(x,y);
     if(ans>x)
      ans=x;
    }
   cout<<ans;
   return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1


class UnionFind:
    __slots__ = ['id','sz']

    def __init__(self, n):
        self.id = [-1] * n
        self.sz = n

    def root(self, x):
        if self.id[x] < 0:
            return x
        else:
            self.id[x] = self.root(self.id[x])
            return self.id[x]

    def find(self, x, y):
        return self.root(x) == self.root(y)

    def union(self, x, y):
        s1, s2 = self.root(x), self.root(y)
        if s1 != s2:
            if self.id[s1] <= self.id[s2]:
                self.id[s1] += self.id[s2]
                self.id[s2] = s1
            else:
                self.id[s2] += self.id[s1]
                self.id[s1] = s2
            self.sz-=1
            return True
        return False


n,m,k = map(int,input().split())
uf=UnionFind(n)
S = [[] for i in range(n)]
for i in range(m):
  a,b = map(int,input().split())
  a-=1;b-=1
  uf.union(a,b)
  S[a].append(b)
  S[b].append(a)
for i in range(k):
  a,b = map(int,input().split())
  a-=1;b-=1
  S[a].append(b)
  S[b].append(a)
ans = [0] * n
for i in range(n):
  tmp = (-uf.id[uf.root(i)])-1
  for vi in S[i]:
    if uf.find(i,vi):
      tmp -= 1
  ans[i] = tmp
print(*ans)

  

Measured memory_bytes: 102176
#include <stdio.h>

int main(){
	int num[4];
  	for(int i=0;i<4;i++){
		scanf("%d",&num[i]);
    }
  
  int sum = 0;
  if(num[0] > num[1]){
    sum += num[1];
  }else{
    sum += num[0];
  }
  
  if(num[2] > num[3]){
    sum += num[3];
  }else{
    sum += num[2];
  }
  printf("%d",sum);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using testimony = vector<pair<int, int>>;

int main() {
    int n; cin >> n;
    vector<testimony> ts(n);
    for (int i=0; i<n; ++i) {
        int a; cin >> a;
        for (int j=0; j<a; ++j) {
            int x, y;
            cin >> x >> y;
            x--;
            ts[i].push_back(make_pair(x, y));
        }
    }
    int ans = 0;
    for (int bit = 1; bit < (1 << n); ++bit) {
        bool can = true;
        int cnt = 0;
        vector<int> people(n, -1); // honest = 1, unkind = 0
        for (int i=0; i<n; ++i) {
            if (bit & (1 << i)) {
                cnt++;
                people[i] = 1;
            }
            else people[i] = 0;
        }
        for (int i=0; i<n; ++i) {
            if (!(bit & (1 << i))) continue;
            people[i] = 1;
            for (auto p: ts[i]) {
                if (p.second) {
                    if (people[p.first] == 0) {
                        can = false;
                        break;
                    }
                    else people[p.first] = 1;
                }
                else {
                    if (people[p.first] == 1) {
                        can = false;
                        break;
                    }
                    else people[p.first] = 0;
                }
            }
            if (!can) break;
        }
        if (can) ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import math
A, B = map(int, input().split())

low_A = A / 0.08
low_B = B / 0.10
high_A = (A + 1) / 0.08
high_B = (B + 1) / 0.10

result = 0
if (low_A >= high_B) or (low_B >= high_A):
  result = -1
else:
  low_end = low_B if (low_A < low_B) else low_A
  result = math.ceil(low_end)

print(result)


Measured memory_bytes: 3060
#include<cstdio>
#include<cmath>

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

using namespace std;
const double INF=1e12,EPS=1e-9;

int p,m;
double a,b,c;

double f(double x)
{
	return x*x*x+a*x*x+b*x+c;
}
double solve(double lo,double hi,bool dec)
{
	if(hi-lo<EPS)return lo;
	double mid=(lo+hi)/2;
	return (f(mid)<0)^dec?solve(mid,hi,dec):solve(lo,mid,dec);
}

int main()
{
	int n,w,x,y,z; scanf("%d",&n);
	rep(i,n)
	{
		scanf("%d%d%d%d",&w,&x,&y,&z);
		a=1.0*x/w; b=1.0*y/w; c=1.0*z/w;
		p=m=0;
		
		double d=a*a-3*b;
		if(d<0)
		{
			double x=solve(-INF,INF,0);
			if(x<-EPS)m++; else if(x>EPS)p++;
		}
		else
		{
			double p1=(-a-sqrt(d))/3,p2=(-a+sqrt(d))/3;
			double x1=solve(-INF,p1,0),x2=solve(p1,p2,1),x3=solve(p2,INF,0);
			
			if(f(-INF)*f(p1)<=0)
			{
				if(x1<-EPS)m++; else if(x1>EPS)p++;
			}
			if(f(p1)*f(p2)<=0)
			{
				if(x2<-EPS)m++; else if(x2>EPS)p++;
			}
			if(f(p2)*f(INF)<=0)
			{
				if(x3<-EPS)m++; else if(x3>EPS)p++;
			}
		}
		printf("%d %d\n",p,m);
	}
	return 0;
}

Measured memory_bytes: 0
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
r = [ord('z') - ord(t) + 1 if t != 'a' else 0 for t in s]
res = [None] * n
k = inp()
for i,x in enumerate(r):
    if x <= k:
        res[i] = 'a'
        k -= x
if k > 0:
    tmp = 'a' if res[-1] != None else s[-1]
    res[-1] = chr((ord(tmp) - ord('a') + k)%26 + ord('a'))
for i,t in enumerate(res):
    if t == None:
        res[i] = s[i]
print(''.join(res))

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

#define i64 long long int
#define ran 555

void upd(i64 &a, i64 b) {
	if (a<0 || a>b) a = b;
}

int n;
int a[ran];
i64 s[ran];
i64 f[ran][ran];

int main() {
	scanf("%d", &n);
	for(int i=1;i<=n;i++) {
		scanf("%d", &a[i]);
		s[i] = s[i-1] + a[i];
	}
	for(int i=2;i<=n;i++)
	for(int j=1;j+i-1<=n;j++) {
		f[j][j+i-1] = -1;
		for(int k=j;k<j+i-1;k++)
			upd(f[j][j+i-1], f[j][k] + f[k+1][j+i-1] + (s[j+i-1] - s[j-1]));
	}
	cout<<f[1][n]<<endl;
	
	return 0;
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int r;
  cin >> r;
  cout << 3 * r * r << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();

		String ans = "";

		if (A % 3 == 0) {
			ans = "Possible";
		} else if (B % 3 == 0) {
			ans = "Possible";
		} else if ((A + B) % 3 == 0) {
			ans = "Possible";
		} else {
			ans = "Impossible";
		}

		System.out.println(ans);

	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


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

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < n; i++) cout << s[i] << t[i];

    return 0;
}

Measured memory_bytes: 256
/*
 * 0296.cc: A Fat Wallet
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int N = 6;
const int L = 1000;

const int CPS[N] = {1, 5, 10, 50, 100, 500};

/* typedef */

/* global variables */

int cs[N];

/* subroutines */

/* main */

int main() {
  for (int i = 0; i < N; i++) cin >> cs[i];

  int sum = 0;
  for (int i = 0; i < N; i++) sum += cs[i] * CPS[i];

  printf("%d\n", (sum >= L) ? 1 : 0);
  return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            if (i + j == x && 2 * i + 4 * j == y) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)
#define Ans(s) cout << s << endl;

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

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

	vector<int> a(n + 2);
	for (int i = 1; i < n + 1; i++) cin >> a[i];

	int ans = 0;

	vector<int> cost(n + 3);
	for (int i = 1; i < n + 2; i++) cost[i] = abs(a[i] - a[i - 1]) + cost[i - 1];

	//for (int i = 0; i < n + 2; i++) cout << cost[i] << " ";

	for (int i = 1; i < n + 1; i++)
	{
		int ans = cost[n + 1] - cost[i + 1];
		ans += cost[i - 1];
		ans += abs(a[i - 1] - a[i + 1]);

		cout << ans << endl;
	}
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve(){
    ll n;
    cin >> n;
    set<ll> s;
    rep(i, n)
    {
        ll x; cin >> x;
        if(s.find(x) != s.end())
        {
            s.erase(s.find(x));
        }
        else s.insert(x);
    }
    cout << s.size();
}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



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

vector<int> v;

bool solve(int i, int m) {
    if (m == 0) {
        return true;
    }
    if (i >= v.size()) {
        return false;
    }

    return solve(i + 1, m) || solve(i + 1, m - v[i]);
}

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

    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        v.push_back(x);
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int m;
        cin >> m;
        if (solve(0, m)) {
            cout << "yes";
        } else {
            cout << "no";
        }
        cout << endl;
    }
}



Measured memory_bytes: 3132
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int H, W, h, w;

    cin >> H >> W >> h >> w;

    cout << H * W - h * W - H * w + h * w << endl;
}

Measured memory_bytes: 384
module Main where

import Data.Functor
import Data.List

main :: IO ()
main = do
  { xs <- getInts
  ; putInts (sort xs)
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int X, Y; cin >> X >> Y;
    for (int i = 0; i <= X; i++) {
        if (i*2 + (X-i)*4 == Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

#define V vector<int>
#define VV(v, n, m) vector<V> v(n, V(m));
#define _4(i, n) for(int i = 0; i < n; i++)
#define g_arr(arr, n) _4(i, n) cin >> arr[i];
#define p_vec(vec) _4(i, (int)vec.size()) cout << vec[i] << ' '; cout << endl;

typedef long long ll;

using namespace std;

#define int long long
int knapsack(int n, int w, V wt, V val);

#undef int
int main(int argc, char * argv[]) {
#define int long long
    ios::sync_with_stdio(0);
    cin.tie(NULL);

    int n, w;
    cin >> n >> w;

    V wt(n), val(n);

    _4(i, n)
        cin >> wt[i] >> val[i];

    cout << knapsack(n, w, wt, val);

    return 0;
}

int knapsack(int n, int w, V wt, V val) {

    VV(dp, n + 1, w + 1);

    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= w; j++) {
            if(i == 0 || j == 0)
                dp[i][j] = 0;
            else if(wt[i - 1] <= j)
                dp[i][j] = max(val[i - 1] + dp[i - 1][j - wt[i - 1]], dp[i - 1][j]);
            else
                dp[i][j] = dp[i - 1][j];
        }
    }

    return dp[n][w];

}


Measured memory_bytes: 80256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1e9 + 100;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 330;
char s[maxn][maxn];
int h, w;

bool read() {
  if (scanf("%d%d", &h, &w) < 2) {
    return false;
  }
  for (int i = 0; i < h; i++) {
    scanf("%s", s[i]);
  }
  return true;
}

void solve() {
  int res = 0;
  for (int j = 0; j + 1 < w; j++) {
    vector<vector<int> > dp(h + 1, vector<int> (h + 1));
    vector<vector<int> > eq(h + 1, vector<int> (h + 1));
    for (int a = h; a >= 0; a--) {
      for (int b = h; b >= 0; b--) {
        int & cur = eq[a][b];
        if (a == h || b == h) {
          cur = 0;
          continue;
        }
        cur = eq[a + 1][b + 1] + (s[h - 1 - a][j] == s[h - 1 - b][j + 1]);
      }
    }
    for (int a = 0; a <= h; a++) {
      for (int b = 0; b <= h; b++) {
        if (!a && !b) {
          continue;
        }
        int & cur = dp[a][b];
        cur = inf;
        if (a) {
          cur = min(cur, dp[a - 1][b] + eq[a - 1][b]);
        }
        if (b) {
          cur = min(cur, dp[a][b - 1] + eq[a][b - 1]);
        }
      }
    }
    res += dp[h][h];
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time: %.18f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

Measured memory_bytes: 1240
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
INF = 10**10
MOD = 10**9 + 7
X = int(input())
MAX_X = 10**9
n = 0
while(1):
    n+=1
    if n**5 - (n-1)**5 > MAX_X:
        break
for i in range(n):
    #for j in range(-n+1,n-1):
    for j in range(-64,n-1):
        if i**5 - j**5 == X:
            print (i,j)
            exit()
   

Measured memory_bytes: 9196
#include<cstdio>

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

using namespace std;

int main(){
	for(int t;scanf("%d",&t),t;){
		int n; scanf("%d",&n);
		rep(_,n){
			int s,g; scanf("%d%d",&s,&g);
			t-=g-s;
		}
		if(t<=0) puts("OK"); else printf("%d\n",t);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define P pair<int, int>
#define PP pair<P, P>
#define mk make_pair
#define fi first
#define se second
#define V vector<int>
#define VV vector<V>
#define pb push_back
using namespace std;
typedef long long ll;

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

    int ev = K/2;
    int od;
    if(K%2) od = ev+1;
    else od = ev;

    cout << ev * od << endl;

    return 0;
}

Measured memory_bytes: 256
///mAAria...
#include<bits/stdc++.h>
using namespace std;
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

signed main(){
    IOS;
    string s;
    cin >> s;
    for(int i = 1;i<s.size();i++){
        if(s[i]==s[i-1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;

return 0;}


Measured memory_bytes: 256
// Last Change: 03/25/2019 22:56:26.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  ll A, B, ans;
  ans = INT64_MIN;
  cin >> A >> B;
  ans = max(ans, A + B);
  ans = max(ans, A - B);
  ans = max(ans, A * B);

  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}


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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if (b - a <= k && c - a <= k && d - a <= k && e - a <= k && c - b <= k &&
      d - b <= k && e - b <= k && d - c <= k && e - c <= k && e - d <= k) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }
  return 0;
}

Measured memory_bytes: 888