akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
    public static void main(String args[]){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            String order;
            while((order=br.readLine())!=null){
                double d = Double.parseDouble(order);
                int story=0;
                for(int i=1; i<10000; i++){
                    int y = (i-1)*5;
                    double t = Math.sqrt(y/4.9);
                    double v = 9.8*t;
                    if(v>=d) {story=i;break;}
                }
                System.out.println(story);
            }
            
        }catch(Exception e){e.printStackTrace();}
    }
}

Measured memory_bytes: 16896
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
t = readl()

s = 0
for i in t:
    s += 1 / i

print(1 / s)


Measured memory_bytes: 6864
#include<bits/stdc++.h>
#include<string.h>
#define ll long long int
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX_LIMIT 100000
#define mp make_pair
#define pb push_back
#define endl "\n"
#define fin(x) for(int i=x;i<n;i++)
using namespace std;
int main(){
    fio;
    ll T;
    cin>>T;
    ll n=T%10;
    if(n==3)
    cout<<"bon";
    else if(n==0||n==1||n==6||n==8)
    cout<<"pon";
    else
    cout<<"hon";
    cout<<endl;
	return 0;
}


Measured memory_bytes: 3664
/* ALDS1_11_A: Graph */

#include <iostream>

int main() {
    std::ios::sync_with_stdio(false);

    int n;
    std::cin >> n;

    int adjm[n + 1][n + 1];
    for (int row = 1; row <= n; row++)
        std::fill_n(adjm[row], n + 1, 0);

    int u, v, n_degrees;
    for (int i = 0; i < n; i++) {
        std::cin >> u >> n_degrees;
        for (int j = 0; j < n_degrees; j++) {
            std::cin >> v;
            adjm[u][v] = 1;
        }
    }

    for (int row = 1; row <= n; row++) {
        std::cout << adjm[row][1];
        for (int col = 2; col <= n; col++) {
            std::cout << " " << adjm[row][col];
        }
        std::cout << "\n";
    }


    return 0;
}

Measured memory_bytes: 1240
#include <stdio.h>

int h,i,j,k,l,m,n,count,score;
int site[5][11],flag;

void yoko(int x,int y) {

  //   printf("count = %d\n",count);  
  //  printf("x = %d\n",x);
  

  if(site[x][y] == site[x+1][y] && site[x][y] != 0 && site[x+1][y] !=0){
    //printf("%d  = %d\n",site[x][y] ,site[x+1][y]);
    count++;
    if(x != 3) yoko(x+1,y);
  }
  else if(count >=3) {
    //  printf("1count = %d\n",count);
    score += site[x-1][y] * count;
    ///printf("x - count +1 = %d\n",x - count + 1);
    for(j=x-count+1;j<=x;j++) site[j][y] = 0;
    count = 1;
    flag  = 1;
    if(x != 3) yoko(x+1,y);

  } if(x != 3) {
    count  = 1;
    yoko(x+1,y);
  } 
  
  if(count >=3 && x == 3) {
    // printf("2count = %d\n",count);
    score += site[x-1][y] * count;
    for(j=x-count+2;j<5;j++) site[j][y] = 0;
    count = 1;
    flag = 1;
  }


  
}

int main() {


  while(1) {

    scanf("%d",&n);
    //    printf("n = %d\n",n);

    if(n == 0) break;

    score = 0;

    for(j=0;j<n;j++){
      for(i=0;i<5;i++) {
	scanf("%d",&site[i][j]);
	//	printf("site[%d][%d] = %d\n",i,j,site[i][j]);

      }
    }
    
    flag = 1;
    while(flag != 0) {
      k=0;
      flag= 0;

      // printf("while flag = %d\n",flag);
      for(i=0;i<n;i++){
	count = 1;
	//	printf("before yoko\n");
	yoko(k,i);
      
      }
      
      /* //check cord
      for(j=0;j<n;j++){
	for(i=0;i<5;i++) {
	  printf("%d ",site[i][j]);
	    
      }
	printf("\n");
	} */  


      for(j=1;j<n;j++) {
	for(i=0;i<5;i++) {
	  if(site[i][j] == 0) {
	    for(k=j;k>0;k--) {
	      site[i][k] = site[i][k-1];
	    }
	    site[i][0] = 0;
	  }
	}
      }
      /* //check cord
      printf("\n");
      for(j=0;j<n;j++){
	for(i=0;i<5;i++) {
	  printf("%d ",site[i][j]);
	    
	}
	printf("\n");
      }  
      printf("\n");
      */

      // printf("flag = %d\n",flag);

    }


    
    printf("%d\n",score);
    
  }

  return 0;
  
}
  

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

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

const int MAX = 2e5 + 5;
int color[MAX];
int n, m;
vector<int> adj[MAX];
bool visited[MAX];

int bfs(int source) {
	queue<int> q;
	q.push(source);
	visited[source] = true;
	int total = 0;
	bool bip = true;
	while(!q.empty()) {
		int cur = q.front(); q.pop();
		total++;
		for(auto &each : adj[cur]) {
			if(!visited[each]) {
				visited[each] = true;
				color[each] = !color[cur];
				q.push(each);
			}
			else if(color[cur] == color[each]) {
				bip = false;
			}
		}
	}
	return total == 1 ? 0 : (bip ? 1 : 2);
}

int main() {
	scanf("%d %d", &n, &m);
	fori(i, 0, m) {
		int a, b;
		scanf("%d %d", &a, &b);
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	int isolated = 0, nbp = 0, bp = 0;
	fori(i, 1, n + 1) {
		if(!visited[i]) {
			int r = bfs(i);
			if(r == 0) {
				isolated++;
			}
			else if(r == 1) {
				bp++;
			}
			else {
				nbp++;
			}
		}
	}

	ll ans = 1LL * nbp * nbp + 2LL * nbp * bp + 2LL * bp * bp;
	int to_remove = 1;
	fori(i, 0, isolated) {
		ans += 2 * n - to_remove;
		to_remove += 2;
	}
	printf("%lld\n", ans);

	return 0;
}



Measured memory_bytes: 9728
import copy
n = int(input())
# = map(int, input().split())
s = input()
# = list(map(int, input().split()))

rgb = [0, 0, 0]
for i in range(n):
    if s[i] == 'R':
        rgb[0] += 1
    elif s[i] == 'G':
        rgb[1] += 1
    else:
        rgb[2] += 1

le = []
ri = []
past = [0, 0, 0]
unt = copy.copy(rgb)

for i in range(n):
    p = copy.copy(past)
    u = copy.copy(unt)
    if s[i] == 'R':
        unt[0] -= 1
        u[0] -= 1
        le.append(p)
        ri.append(u)
        past[0] += 1
    elif s[i] == 'G':
        unt[1] -= 1
        u[1] -= 1
        le.append(p)
        ri.append(u)
        past[1] += 1
    else:
        unt[2] -= 1
        u[2] -= 1
        le.append(p)
        ri.append(u)
        past[2] += 1
ans = 0
for i in range(n):
    if s[i] == 'R':
        ans += le[i][1]*ri[i][2] + le[i][2]*ri[i][1]
    elif s[i] == 'G':
        ans += le[i][0]*ri[i][2] + le[i][2]*ri[i][0]
    else:
        ans += le[i][0]*ri[i][1] + le[i][1]*ri[i][0]

for i in range(n-2):
    for j in range(i+1, i+(n-i+1)//2):
        if s[i] != s[j] and s[i] != s[j+j-i] and s[j] != s[j+j-i]:
            ans -= 1

print(ans)


Measured memory_bytes: 10212
n = gets.to_i
as = gets.chomp.split.map(&:to_i)
cnt_4 = 0
cnt_2 = 0
cnt_odd = 0
as.each do |a|
  if a % 4 == 0
    cnt_4 += 1
  elsif a.odd?
    cnt_odd += 1
  else
    cnt_2 += 1
  end
end

if cnt_2.even?
  if cnt_odd <= cnt_4 + 1
    ans = "Yes"
  else
    ans = "No"
  end
else
  if cnt_odd <= cnt_4
    ans = "Yes"
  else
    ans = "No"
  end
end

puts ans

Measured memory_bytes: 9476
import random

dice_a = list(map(int, input().split()))
dice_b = list(map(int, input().split()))


class Dice():
    def __init__(self, dice, directions):
        self.dice = dice
        self.directions = directions

    def roll(self):
        for direction in self.directions:
            NS = [0, 1, 5, 4]
            WE = [0, 2, 5, 3]
            copy_dice = self.dice[:]

            if direction == 'N':
                for j in range(4):
                    self.dice[NS[j]] = copy_dice[NS[j-3]]
            elif direction == 'S':
                for j in range(4):
                    self.dice[NS[j]] = copy_dice[NS[j-1]]
            elif direction == 'W':
                for j in range(4):
                    self.dice[WE[j]] = copy_dice[WE[j-3]]
            else:
                for j in range(4):
                    self.dice[WE[j]] = copy_dice[WE[j-1]]

        return self.dice


def check_equal(dice_1, dice_2):
    for i in range(777):
        dice_A = Dice(dice_1, random.choice(['N', 'S', 'W', 'E']))

        if dice_A.roll() == dice_2:
            print('Yes')
            break

    else:
        print('No')

check_equal(dice_a, dice_b)


Measured memory_bytes: 8188
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    sort(rall(a));
    sort(rall(b));

    int ans = 0;
    rep(i, n){
        if(b[i] < a[0] || h <= 0) break;
        h -= b[i];
        ans++;
    }

    if(h > 0) ans += (h / a[0] + (h % a[0] != 0));

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>    
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
const int N = 200005, mo = 1000000007;
using namespace std;
char A[N], B[N]; int a[N], b[N], n;
int get(int x, int y) {
    int z = min(x, y);
    x -= z, y -= z;
    if (!(x + y)) return 0;
    if (x) {
        if (!(x % 3)) return 0;
        if (x % 3 == 1) return 1; else return 2;
    } else {
        if (!(y % 3)) return 0;
        if (y % 3 == 1) return 2; else return 1;
    }
}
int main() {
    scanf("%s%s", A + 1, B + 1); int x, y, l, r;
    rep(i, 1, strlen(A + 1)) a[i] = a[i - 1] + (A[i] == 'A');
    rep(i, 1, strlen(B + 1)) b[i] = b[i - 1] + (B[i] == 'A');
    scanf("%d", &n);
    for ( ; n -- ; ) {
        scanf("%d%d%d%d", &x, &y, &l, &r);
        printf(get(a[y] - a[x - 1], y - x + 1 - (a[y] - a[x - 1])) == get(b[r] - b[l - 1], r - l + 1 - (b[r] - b[l - 1])) ? "YES\n" : "NO\n");
    }
    return 0;
}

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

int main(){
  int dp[5][1<<16];
  int grid[5][5];
  int bit[5];
  int casenum;
  int score[] = {0,0,60,70,80};

  cin >> casenum;
  while(casenum--){
    for(int i=0;i<5;i++)
      for(int j=0;j<5;j++)cin >> grid[i][j];

    for(int i=0;i<5;i++){
      bit[i] = 0;
      for(int j=0;j<5;j++){
	bit[i] |= (grid[i][j] << (3*j));
      }
    }

    for(int i=0;i<5;i++)
      for(int j=0;j<(1<<15);j++)dp[i][j] = -1;

    dp[0][bit[0]] = 0;

    for(int i=0;i<4;i++){
      int tmp[5];
      for(int j=0;j<5;j++){
	tmp[j] = ( bit[i+1]%( 1<<(3*(j+1)) ) ) >> (3*j);
      }

      for(int j=0;j<(1<<8);j++){
	int change[4];
	for(int k=0;k<4;k++){
	  change[k] = ( j%( 1<<(2*(k+1)) ) ) >> (2*k);
	}

	for(int k = 0;k<(1<<15);k++){
	  if(dp[i][k]>=0){
	    int pre[5];     
	    for(int l=0;l<5;l++){
	      pre[l] = ( k%( 1<<(3*(l+1)) ) ) >> (3*l);
	    }
	    int next[5];
	    int sum = 0;
	    for(int l=0;l<5;l++){
	      if(pre[l]){
		if(l!=4)pre[l] += change[l];
		if(pre[l]>4)pre[l] -= 4;
		if(l)pre[l] += change[l-1];
		if(pre[l]>4)pre[l] -= 4;
		sum += score[pre[l]];
	      }

	      next[l] = tmp[l];
	      if(next[l]){
		if(l!=4)next[l] += change[l];
		if(next[l]>4)next[l] -= 4;
		if(l)next[l] += change[l-1];
		if(next[l]>4)next[l] -= 4;
		next[l] %= 5;
	      }
	    }
	    int bitnext = 0;
	    for(int l=0;l<5;l++){
	      bitnext |= (next[l] << (3*l) );
	    }
	    /*
	    if(dp[i+1][bitnext]<dp[i][k] + sum){
	      cout << sum << endl;
	      for(int l=0;l<5;l++)cout << next[l] << " ";
	      cout << endl;
	      for(int l=0;l<4;l++)cout << change[l] << " ";
	      cout << endl;
	    }
	    */
	    dp[i+1][bitnext] = max(dp[i+1][bitnext],dp[i][k] + sum);
	  }
	}
      }
    }

    int ans = 0;
    for(int i=0;i<(1<<15);i++){
      if(dp[4][i]>=0){
	int hoge = 0;
	//cout << "[";
	for(int j=0;j<5;j++){
	  int tmp =  ( i%( 1<<(3*(j+1))) ) >> (3*j);
	  //cout << tmp << " ";
	  hoge += score[tmp];
	}	
	//cout<< "]" << endl;
	ans = max(ans,dp[4][i] + hoge);
      }
    }
    cout << ans << endl;
  }
}
    

Measured memory_bytes: 0
#include <cstdio>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <tuple>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int ll;
using namespace std;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

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

    ll high[n][2];
    ll low[n][2];

    ll highest = 0;
    for(ll i=0;i<n;i++)
    {
        ll tmp;
        cin >> tmp;
        if(i==0)
        {
            high[i][0] = tmp;
            low[i][0] = tmp;
            highest = tmp;
        }
        else
        {
            if(tmp > highest)
            {
                high[i][0] = tmp;
                low[i][0] = tmp;
                highest = tmp;
            }
            else
            {
                high[i][0] = highest;
                low[i][0] = 1;
            }
        }
    }


    highest = 0;
    for(ll i=0;i<n;i++)
    {
        ll tmp;
        cin >> tmp;
        if(i == 0){
            high[i][1] = tmp;
            low[i][1] = 1;
            highest = tmp;
        }
        else
        {
            if(tmp == highest)
            {
                high[i][1] = tmp;
                low[i][1] = 1;
            }
            else
            {
                low[i-1][1] = high[i-1][1];
                high[i][1] = tmp;
                low[i][1] = 1;
                highest = tmp;
            }
        }

       if(i == n-1)
       {
            low[i][1] = high[i][1];
        }
    }

    ll ans = 1;
    for(ll i=0;i<n;i++)
    {
        ll pat;
        ll def = min(high[i][0],high[i][1]) - max(low[i][0],low[i][1]) +1;
        if(def>0)
        {
            ans = ans * def % 1000000007;
        }
        else
        {
            ans *= 0;
            break;
        }
    }

     cout << ans <<endl;
    return 0 ;

}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)

int main()
{
    ll N;
    cin >> N;
    string n;
    n = to_string(N);
    repi(i,n.length()-2,0){
        if(n.at(i) == n.at(i+1) && n.at(i) == n.at(i+2)){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

ll N, D;
vector<vector<ll>> X;

bool sqn(ll x) {
  ll y = sqrt(x);
  return y*y == x;
}

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  cin >> N >> D;
  X.resize(N);
  for (ll j = 0; j < N; j++) {
    X.at(j).resize(D);
    for (ll i = 0; i < D; i++) {
      cin >> X.at(j).at(i);
    }
  }
  ll ans = 0;
  for (ll j = 0; j < N; j++) {
    for (ll k = j+1; k < N; k++) {
      ll s = 0;
      for (ll i = 0; i < D; i++) {
	ll t = X.at(j).at(i) - X.at(k).at(i);
	s += t*t;
      }
      if (sqn(s)) ans++;
    }
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int N, M, G;
char A[101010];
char B[101010];

int main(){
    scanf("%d %d", &N, &M);
    scanf("%s", A+1);
    scanf("%s", B+1);
    G = __gcd(N, M);
    for (int i=0; i<G; i++) if (A[N/G*i + 1] != B[M/G*i + 1]){
        puts("-1");
        return 0;
    }
    printf("%lld\n", (LL)N*M/G);
    return 0;
}


Measured memory_bytes: 384
N = int(input())
A = [int(_) for _ in input().split()]

ans_lis = [0] * N
to_print_lis = []

for n in range(N - 1, -1, -1):
    sum_lis = sum(A[n: : n + 1])
    tmp_lis = ans_lis[n: : n + 1]
    if sum(tmp_lis) % 2 != A[n]:
        ans_lis[n] = 1
        to_print_lis.append(n + 1)
    #print(ans_lis)
print(len(to_print_lis))
print(*to_print_lis)

Measured memory_bytes: 16052
def reconstruction(l, r, p):
    if l >= r:
        return
    c = next(pre)
    m = ino.index(c)
    reconstruction(l, m, p)
    reconstruction(m + 1, r, p)
    p += [c]
n = int(input())
pre = iter(list(map(int, input().split())))
ino = list(map(int, input().split()))
postorder = []
reconstruction(0, n, postorder)
print(' '.join(map(str, postorder)))


Measured memory_bytes: 5596
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#include <bitset>
#include <complex>
#include <cassert>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

class UnionFind
{
    vector<int> data;
    vector<int> scale;
    public:
    UnionFind(int n)
    {
        for(int i=0;i<n;i++)
        {
            data.push_back(i);
            scale.push_back(1);
        }
    }
    int root(int n)
    {
        if(data[n]==n)
            return n;
        else
            return data[n]=root(data[n]);
    }
    void set(int x,int y)
    {
        if(root(x)==root(y))
            return;
        scale[root(y)]+=scale[root(x)];
        scale[root(x)]=0;
        data[root(x)]=data[root(y)];
    }
    int size(int n)
    {
        return scale[root(n)];
    }
};

int N,M,P[100000],G[100000];

int main(void){
    GI(N);GI(M);
    UnionFind U(N);
    REP(i,N){
        GI(P[i]);
        P[i]--;
    }
    REP(i,M){
        int x,y;
        GI(x);GI(y);
        x--;y--;
        U.set(x,y);
    }
    vector<set<int> > vs1(N);
    vector<set<int> > vs2(N);
    REP(i,N){
        vs1[U.root(i)].insert(i);
        vs2[U.root(i)].insert(P[i]);
    }
    int ans = 0;
    REP(i,N){
        for(int j:vs1[i])
            if(vs2[i].find(j)!=vs2[i].end())
                ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 20212
import collections
n = int(input())
lst1 = list(input())
c = collections.Counter(lst1) #dict
right = c["E"]
left = 0
ans = 10**9

for i in range(n):
    if lst1[i] == "E":
        right -=1
    if i >= 1 and lst1[i-1] == "W":
        left += 1
    ans = min(ans,left+right)
    

print(ans)

Measured memory_bytes: 64240
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
lli mod=1000000007;

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
	cout.tie(NULL);
	lli n,a,b;
	cin>>n>>a>>b;
	lli sum=a+b;
	lli ans=(n/sum)*a;
	ans+=min(n%sum,a);
	cout<<ans<<endl;
 }

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

int main(){
    char a, b;
    std::cin >> a >> b;

    if(a == 'H' && b == 'H') std::cout << "H\n";
    else if(a == 'D' && b == 'D') std::cout << "H\n";
    else std::cout << "D\n";
    return 0;
}


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

int main()
{
    int a[3];
    for(int i = 0; i < 3; ++i)
    {
        cin >> a[i];
    }
    sort(a, a+3);
    
    if(a[0] + a[1] == a[2])
    {
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n,m=[int(i) for i in input().split(' ')]
class P:
  def __init__(self, a, b):
    self.a = a
    self.b = b

p = []
for i in range(n):
  a,b=[int(i) for i in input().split(' ')]
  p.append(P(a, b))

  
mon = 0
p.sort(key=lambda x: x.a)
for e in p:
  if m <= e.b:
    mon += e.a * m
    m = 0
  else:
    m -= e.b
    mon += e.a * e.b

print(mon)

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

using namespace std;

int main(){
    int n;
    cin>>n;
    for (int i=1; i<=9; i++) {
        for(int j=1;j<=9;j++){
            if (n==i*j) {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int N = sc.nextInt();
    int A[] = new int[N];
    int B[] = new int[N];
    int sum = 0;
    
    for(int i=0; i<N; i++) {
      A[i] = sc.nextInt();
    }
    B[0] = A[0] + K - A[N-1];
    for(int j=1; j<N; j++) {
      B[j] = A[j] - A[j-1];
    }
    Arrays.sort(B);
    for(int k=0; k<N-1; k++) {
      sum += B[k];
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 87672
F=->z,c{G[c].map{|e|e==z ?[0,c]:(x,y=F[c,e];[x+4[G[c].size],y])}.max};G=(0..gets.to_i).map{[]};$<.map{|e|a,b=e.split.map &:to_i;G[a]<<b;G[b]<<a};p~-G.count{|x,y|!y}+F[0,F[0,1][1]][0]

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

using ll = long long;

int main() {
    ll N, ans = 1e18;
    cin >> N;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ans = min(ans, i + N / i - 2);
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;

// #define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

ll INF = 1000000000000L;

struct node {
  ll modarr[3] = {INF, INF, INF};
  int number;
  void view() { cout << modarr[0] << " " << modarr[1] << " " << modarr[2] << endl; }
};


struct edge { long long to, cost;};	
typedef pair<long long, long long> P_dij;	
void dijkstra(const long long s, const long long n,	
  vector< vector<edge> > const &G, vector<long long> & d){	
  d.resize(n);	
  for(int i=0; i<n; i++) d[i] = INF; 	
  priority_queue<P_dij, vector<P_dij>, greater<P_dij>> que;	
  d[s] = 0;	
  que.push(P_dij(0, s));	
  while (!que.empty()) {	
    P_dij p = que.top();	
    que.pop();	
    long long v = p.second;	
    if(d[v] < p.first)continue;	
    for(int i=0;i<G[v].size(); i++){	
      edge e = G[v][i];	
      if(d[e.to] > d[v] + e.cost){	
        d[e.to] = d[v] + e.cost;	
        que.push(P_dij(d[e.to], e.to));	
      }	
    }	
  }	
}	

/*

vector<node> nodes(100001);

void dfs(const vector<vector<int>>& v, ll now, ll cost) {
  // cout << nodes[now].modarr[cost % 3] << " "  << cost << " " << now << endl;
  if (nodes[now].modarr[cost % 3] < cost) {
    // cout << now << endl;
    return;
  } else {
    cost += 1;
    nodes[now].modarr[cost % 3] = cost;
    for (auto itr : v[now]) {
      dfs(v, itr, cost);
    }
  }
  
}*/

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<edge>> uv((n+10) * 3);
  
  rep(i, m) {
    int u,v;
    cin >> u >> v;
    uv[u].push_back({v + n, 1});
    uv[u + n].push_back({v + 2 * n, 1});
    uv[u + 2 * n].push_back({v, 1});
  }

  int s, t;
  cin >> s >> t;

  vector<ll> d;
  dijkstra(s, (n+10) * 3, uv, d);
  // for (auto itr : d) cout << itr << endl;
  if (d[t] == INF) cout << -1 << endl;
  else cout << d[t] / 3 << endl;
}


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

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

	rep(i, N) {
		int x;
		cin >> x;

		if (x % 2 == 0) {
			if (x % 3 != 0 && x % 5 != 0) {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}

	cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

h,w,a,b = inm()
for i in range(b):
    print('0'*a+'1'*(w-a))
for i in range(h-b):
    print('1'*a+'0'*(w-a))


Measured memory_bytes: 39792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> a(n), b(m);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	for(int i = 0; i < m; ++i){ cin >> b[i]; }
	int answer = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
	for(int i = 0; i < k; ++i){
		int x, y, c;
		cin >> x >> y >> c;
		--x; --y;
		answer = min(answer, a[x] + b[y] - c);
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define rep(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

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; }
template<typename T>
vector<T> enum_div(T n){
    vector<T> ret;
    for(T i=1;i*i<=n;i++){
        if(n%i==0){
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n/i);
        }
    }
    //sort(ret.begin(), ret.end());
    return ret;
}
template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}
template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

ll N;
int main(void){
    cin >> N;
    cout << N*(N-1) / 2 << endl;

    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
int main() {
    int N,K;
    cin >> N >>K;
    vector<int>A(N);
    rep(i, 0, N){
        cin >> A[i];
    }
    N--;
    K--;
    if(N%K == 0){
      cout<<(N/K)<<endl;
    }else{
      cout<<(1+N/K)<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
int main() {
	int a, b;
	string s[110];
	cin >> a >> b;
	for (int i = 0; i < a; i++)cin >> s[i];
	for (int i = 0; i < b + 2; i++)cout << '#';
	cout << endl;
	for (int i = 0; i < a; i++)cout << '#' << s[i] << '#' << endl;
	for (int i = 0; i < b + 2; i++)cout << '#';
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
A_sum = sum(A)
deltas = [A_sum]
res = []
for i in range(N-1):
    deltas.append(deltas[-1] - 2*A[i])
    res.append(abs(deltas[-1]))
print(min(res))

Measured memory_bytes: 27212
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
const int MOD = 998244353;

int main()
{
	string S;
	cin >> S;
	while (true) {
		S.pop_back();
		if (S.size() % 2 == 0) {
			string s, t;
			for (int j = 0; j < S.size() / 2; j++) s.push_back(S[j]);
			for (int j = S.size() / 2; j < S.size(); j++) t.push_back(S[j]);
			if (s == t) {
				cout << S.size() << endl;
				return 0;
			}
		}
	}
}


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

int R;

int main () {
	cin >> R;
	if (R<1200) {
		cout << "ABC" << endl;
	} else if (R>=1200 && R<2800) {
		cout << "ARC" << endl;
	} else {
		cout << "AGC" << endl;
	}
}

Measured memory_bytes: 256
li = [
"AKIHABARA",
"AKIHABAR",
"AKIHABRA",
"AKIHABR",
"AKIHBARA",
"AKIHBAR",
"AKIHBRA",
"AKIHBR",
"KIHABARA",
"KIHABAR",
"KIHABRA",
"KIHABR",
"KIHBARA",
"KIHBAR",
"KIHBRA",
"KIHBR"
]

s = input()

if s in li:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 2940
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
void solve()
{
	int n;
	cin>>n;
	int a[n+1]={0};
	int b[n+1]={0};
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[i]=i+a[i];
	}	
	mii mp;
	mp[b[1]]++;
	int sum=0;
	for(int j=2;j<=n;j++)
	{
		if(mp[j-a[j]])
			sum+=mp[j-a[j]];
		mp[b[j]]++;
	}
	cout<<sum<<endl;
}
signed main()
{
	fastio;
		solve();
}












Measured memory_bytes: 29436
#include<iostream>
#include<cstdio>
#include<cstring>
namespace wohaocaia
{
	inline void check_max(int a,int &b){if(a>b)b=a;}
	const int N=105;
	int s[N][N],f[N][N][N][N];
	int n,m,sx,sy;
	int tl,tr,tu,td;
	int got(){for(char c=getchar();;c=getchar())if(c=='o' || c=='.' || c=='E')return c;}
	int min(int a,int b){return a<b?a:b;}
	int max(int a,int b){return a>b?a:b;}
	void initialize()
	{
		scanf("%d%d",&n,&m);
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
			{
				int x=got();
				if(x=='o')s[i][j]=1;
				else if(x=='.')s[i][j]=0;
				else sx=i,sy=j;
				s[i][j]+=s[i-1][j]+s[i][j-1]-s[i-1][j-1];
			}
	}
	int bdy(int a,int b,int c,int d)
	{
		if(a>c || b>d)return 0;
//		printf("(%d,%d) -- (%d,%d) : %d\n",a,b,c,d,s[c][d]-s[c][b-1]-s[a-1][d]+s[a-1][b-1]);
		return s[c][d]-s[c][b-1]-s[a-1][d]+s[a-1][b-1];
	}
	void dp()
	{
		tl=sy-1,tr=m-sy,tu=sx-1,td=n-sx;

//		printf("L:%d , R:%d , U:%d , D:%d \n",tl,tr,tu,td);
//		printf("%d , %d \n",sx,sy);
		
		f[0][0][0][0]=0;
		for(int l=0;l<=tl;l++)
			for(int r=0;r<=tr;r++)
				for(int u=0;u<=tu;u++)
					for(int d=0;d<=td;d++)
					{
						int v=f[l][r][u][d];
						check_max(v+bdy(max(sx-u,d+1),sy-l-1,min(sx+d,n-u),sy-l-1)*(sy-l-1>r),f[l+1][r][u][d]);
						check_max(v+bdy(max(sx-u,d+1),sy+r+1,min(sx+d,n-u),sy+r+1)*(sy+r+1<=m-l),f[l][r+1][u][d]);

						check_max(v+bdy(sx-u-1,max(sy-l,r+1),sx-u-1,min(sy+r,m-l))*(sx-u-1>d),f[l][r][u+1][d]);
						check_max(v+bdy(sx+d+1,max(sy-l,r+1),sx+d+1,min(sy+r,m-l))*(sx+d+1<=n-u),f[l][r][u][d+1]);

//						printf("f[%d][%d][%d][%d] = %d\n",l,r,u,d,v);
					}
	}
	void orz()
	{
		initialize();
		dp();
		printf("%d\n",f[tl][tr][tu][td]);
	}
}
int main()
{
//	freopen("in","r",stdin);
//	freopen("out","w",stdout);
	wohaocaia::orz();
	return 0;
}


Measured memory_bytes: 242944
import java.util.*;
 
public class Main {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] b = new int[n-1];
        for (int i = 0; i < n-1; i++) {
            b[i] = sc.nextInt();
        }
        
        int count = b[0] + b[n-2];
        for (int i = 0; i < n - 2; i++) {
            count += Math.min(b[i], b[i+1]);
        }
        System.out.println(count);
        
    }
}

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

#define LL long long
using namespace std;

int main(void){

    vector<int> v,c;
    vector<int> h;
    int n;
    int result = 0;

    cin >> n;

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

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

    for (int i = 0; i < n; i++){
        if(v[i] - c[i] > 0){
            result += v[i] - c[i];
        }
    }

    cout << result << endl;

    return 0;
}


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

int main() {
	long long N;
	double A, ANS = 0.0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A;
		ANS += 1.0 / A;
	}
	printf("%.9lf\n", 1.0 / ANS);
}

Measured memory_bytes: 256
# 解説放送
# https://atcoder.jp/contests/abc158/submissions/10643692
# dfsの代わりに親の頂点番号を配列で管理する方法

def main():
    from collections import deque, namedtuple
    from operator import attrgetter
    import sys
    sys.setrecursionlimit(10 ** 7)
    input = sys.stdin.readline

    MOD = 998244353

    Robot = namedtuple('Robot', 'x d reach ind')

    N = int(input())

    robots = []
    for ind in range(N):
        X, D = map(int, input().split())
        robots.append(Robot(X, D, X + D, ind))
    robots.sort(key=attrgetter('x'), reverse=True)

    parents = [-1] * N
    to_candidates = deque()
    for robot_from in robots:  # x降順
        """
        右端に位置するロボットから順に「起点」と見なしていく
        既出のロボットで有向辺の行き先として一度も設定されていないものが
        to_candidatesにx昇順で溜められている
        to_candidatesに含まれるロボットで「起点」から接触範囲内のものがある限り、
        「起点」から有向辺を張り続ける
        to_candidatesの先頭候補(最も左側に位置する)に対して辺を張れない場合、
        それ以降の候補のxはより遠い座標で辺を張れないので
        「起点」から張れる辺がないとわかる
        すべてのロボットは「起点」から辺を張られてto_candidatesから外れるか
        to_candidatesに残り、グラフ(森)の各木のrootとなる
        """
        while to_candidates:
            robot_to = to_candidates[0]
            if robot_to.x < robot_from.reach:
                parents[robot_to.ind] = robot_from.ind
                to_candidates.popleft()
            else:
                break

        to_candidates.appendleft(robot_from)

    ret = 1
    count = [1] * N
    for robot in robots:  # x降順
        par = parents[robot.ind]
        count[robot.ind] += 1
        if ~par:
            count[par] = (count[par] * count[robot.ind]) % MOD
        else:
            ret = (ret * count[robot.ind]) % MOD
            # x降順で見ているのでpar==-1のrootのrobotを見る頃には
            # rootの子は全て見ているので安心してretにかけられる
    print(ret)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 97884
import math
from sys import stdin
input = stdin.readline

while True:
    n = int(input())
    if n == 0:
        break
    slist = list(map(int, input().split()))
    n = len(slist)
    m = sum(slist) / n
    asquare = 0
    for num in slist:
        asquare += (num - m)**2 / n
    print(math.sqrt(asquare))


Measured memory_bytes: 5688
#include <stdio.h>

int main(void)
{
	int N = 0;
	int t = 0;
	long long int s = 1;
	scanf("%d",&N);
	for(long long int i = 0;i < 8;i++){
		t += N / s % 10;
		s *= 10;
	}
	
	if(N % t == 0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;cin >> N;
    set<int> vec;
    for(int a = 0;a < N;a++){
        int b;cin >> b;
        vec.insert(b);
    }
    if(vec.size()%2==0){
        cout<<vec.size()-1<<endl;
    }else{
        cout<<vec.size()<<endl;
    }
    return 0;
}


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

#define ll     long long
#define fr     first
#define sec    second
#define rep(i,n)  for(i=0;i<n;i++)
#define vi     vector <int>
#define vc     vector <char>
#define vl     vector <ll>
#define vb     vector <bool>
#define pb     push_back
#define M      1000000007
#define ios    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define open   freopen("input.txt","r",stdin);
#define close  freopen("output.txt","w",stdout);
#define M_PI   3.14159265358979323846
#define pp     pair<int,int>
#define nn 100003
#define MM 1000000000
#define MN 1000000000000000000
int main()
{
    ios;
    ll n;
    cin>>n;
    n=n%10;
    if(n==2 || n==4 || n==5 || n==7 || n==9)
        cout<<"hon";
    else if(n==0 || n==1 || n==6 || n==8)
        cout<<"pon";
    else
        cout<<"bon";
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <numeric>
#include <vector>

struct Node
{
  std::vector<Node*> peers;
  int value;

  Node() : value{-1}
  {}
};

using Tree = std::vector<Node>;

const long mod = 1000000007;

long f(Node& n, int k, long current)
{
  auto colored_count = std::accumulate(
      n.peers.begin(),
      n.peers.end(),
      0,
      [](int sum, const Node* p) { return sum + p->value >= 0; });

  for (auto* p : n.peers) {
    if (p->value < 0) {
      p->value = k - colored_count - 1;
      if (p->value <= 0) return 0;

      current *= p->value;
      current %= mod;
      ++colored_count;

      current = f(*p, k, current);
    }
  }

  return current % mod;
}

long solve(int n, int k, Tree& tree)
{
  tree[0].value = k;
  return f(tree[0], k, k);
}

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

  Tree tree(n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    std::cin >> a >> b;
    tree[a - 1].peers.push_back(&tree[b - 1]);
    tree[b - 1].peers.push_back(&tree[a - 1]);
  }

  std::cout << solve(n, k, tree) << std::endl;
}


Measured memory_bytes: 9984
let main = (standardInput) => {
    let lengthList = standardInput.split(' ');
    let varticalLength = Number.parseInt(lengthList[0]);
    let horizonLength = Number.parseInt(lengthList[1]);

    console.log(varticalLength * horizonLength + ' ' + 2 * (varticalLength + horizonLength));
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


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

namespace _074B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var K = int.Parse(Console.ReadLine());
            var x = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            int[] result = new int[N];
            for(int i = 0; i < N ; i++){
                if(Math.Abs(0-x[i]) > Math.Abs(K-x[i])){
                    result[i] = 2 * Math.Abs(K-x[i]);
                }else{
                    result[i] = 2 * Math.Abs(0-x[i]);
                }
            }
            Console.WriteLine(Enumerable.Sum(result));
        }
    }
}

Measured memory_bytes: 13268
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	inp(n)
	inpa(a,n)
	int mi=INF,ans=0;
	fo(i,n)
	{
		mi=min(mi,a[i]);
		if(a[i]<=mi)
		{
			ans++;
		}
	}
	cout<<ans<<'\n';
	printclock;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int N, K, i, temp, ans=1000000000;
    vector<int> h;
    scanf("%d %d", &N, &K);
    for(i=0; i<N; i++){
        scanf("%d", &temp);
        h.push_back(temp);
    }
    sort(h.begin(), h.end());
    for(i=0; i+K-1<N; i++){
        ans=min(ans, h[i+K-1]-h[i]);
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 892
n=int(input())
v=list(map(int,input().strip().split()))
a=[0]*n
for i in range(n-1,-1,-1):
  c=0
  for j in range(i,n,i+1):
    c ^= a[j]
  if c != v[i]:
    a[i] = 1
ans = []
for i in range(n):
  if a[i]: ans.append(i+1)
print(len(ans))
print(*ans)

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

using ll = long long;
#define REP(i, n) for(int (i)=0; (i)< (n); ++i)
#define REPR(i, n) for(int (i)=(n); (i)>=0; --i)
#define FOR(i, n, m) for(int (i)=(n); (i)<(m); ++i)

struct UnionFind{
  vector<int> par;
  vector<int> sizes;
  UnionFind(int n): par(n), sizes(n, 1){
    REP(i, n) par[i]=i;
  }
  int find(int x){
    if (x==par[x]) return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y){
    x = find(x);
    y = find(y);
    if (x==y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }
  bool same(int x, int y){
    return find(x) == find(y);
  }
  int size(int x){
    return sizes[find(x)];
  }
};

struct Edge{
  int a, b, cost;
  Edge(int a=0, int b=0, int cost=0){
   this->a = a;
   this->b = b;
   this->cost = cost;
  }
  bool operator<(const Edge &o) const{
    return cost < o.cost;
  }
};

vector<Edge> kruskal(vector<Edge> & E, int N){
  vector<Edge> ans;
  sort(E.begin(), E.end());
  UnionFind uf(N);
  for(auto e : E){
    if(!uf.same(e.a, e.b)){
      ans.push_back(e);
      uf.unite(e.a, e.b);
    }
  }
  return ans;
}
int main(){
  int V, E;
  cin >> V >> E;
  vector<Edge> edge(E);
  REP(i, E){
    int s, t, w;
    cin >> s >> t >> w;
    edge[i] = Edge(s, t, w);
  }
  vector<Edge> kr = kruskal(edge, V);
  ll ans = 0;
  REP(i, kr.size()){
    ans += kr[i].cost;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4444
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << "NO\n"; return;}
#define yes {cout << "YES\n"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

const int N = 2e5 + 7;

int a[N];

void solve() {
    int n; cin >> n;
    loop(i, n)
        cin >> a[i];
    sort(a, a + n);
    loop1(i, n - 1)
        if (a[i] == a[i - 1])
            no;
    yes;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(3e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a % 2 == 0 && a == b && b == c) {
        cout << -1 << endl;
        return 0;
    }
    int cnt = 0;
    while (a%2 + b%2 + c%2 == 0) {
        int a_,b_,c_;
        a_ = b/2+c/2;
        b_ = c/2+a/2;
        c_ = a/2+b/2;
        a = a_; b = b_; c = c_;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl;
using ll=long long;
const ll INF=1LL<<60;



int main(){
  ll n,k;
  cin >> n >> k;
  n=n%k;
  cout << min(k-n,n);
}


Measured memory_bytes: 256