akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int M = int.Parse(s[1]);
            int[] n = new int[N];
            for(int i = 0; i < M; i++)
            {
                s = Console.ReadLine().Split(' ');
                n[int.Parse(s[0])-1]++;
                n[int.Parse(s[1])-1]++;
            }
            for(int i=0;i<N;i++) Console.WriteLine(n[i]);
        }
    }
}


Measured memory_bytes: 11092
#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>;
using vv = vector<vector<ll>>;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

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

int dx[4] = {1,0,-1,0};int dy[4] = {0,-1,0,1};
using Graph = vector<vector<int> >;

int main() {
    int h,w;cin >> h >> w;
    vector<string> S(h);
    for(int i=0;i<h;i++){
	string s; cin >> s;
	S[i] = s;
    }
    int ans;
    queue<P> que;
    vector<vector<int> >dist(h,vector<int>(w,-1));
    que.push(make_pair(0,0));
    dist[0][0] = 1;
    while(!que.empty()){
	P v = que.front();que.pop();
	for(int k=0;k<4;k++){
	    int di = v.first + dx[k];
	    int dj = v.second + dy[k];
	    if(di < 0 || dj < 0 || h<= di || w <= dj) continue;
	    if(S[di][dj] == '#') continue;
	    if(dist[di][dj]==-1){
		dist[di][dj] = dist[v.first][v.second] + 1;
		que.push(make_pair(di,dj));
	    }
	}
    }
    ans = h*w-dist[h-1][w-1];
    rep(i,h)rep(j,w) if(S[i][j]=='#')ans--;
    if(dist[h-1][w-1]==-1) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <set>
#include <vector>

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	static int a[1<<18];
	rep(i,1<<n) scanf("%d",a+i);

	multiset<int> S(a,a+(1<<n)),T;
	{
		auto it=--S.end();
		T.emplace(*it);
		S.erase(it);
	}
	rep(i,n){
		vector<int> tmp;
		for(int v:T){
			auto it=S.lower_bound(v);
			if(it==S.begin()){
				puts("No");
				return 0;
			}
			--it;
			tmp.emplace_back(*it);
			S.erase(it);
		}
		T.insert(tmp.begin(),tmp.end());
	}
	puts("Yes");

	return 0;
}


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

int main(){
  string S;
  cin >> S;
  sort(S.begin(),S.end());
  if(S[0] == S[1] && S[1] != S[2] && S[2] == S[3]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
N,T = map(int,input().split(' '))

clist = []
tlist = []

for _ in range(N):
  L = list(map(int,input().split(' ')))
  clist.append(L[0])
  tlist.append(L[1])
  
List = [c for c,t in zip(clist,tlist) if t<=T]

if len(List):
  print(min(List))
else:
  print('TLE')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int k,x;
    cin>>k>>x;
    int st=x-(k-1),en=x+(k);
    for(int i=st; i<en; i++)
        cout<<i<<" ";
    cout<<'\n';
    return 0;
}


Measured memory_bytes: 256
import copy
import random
import time


memo = {}
def down(d, last, c):
    result = 0
    if d in memo:
        return memo[d]
    for i in range(26):
        result += c[i] * (d - last[i])
    memo[d] = result
    return result


def calc_score_of_the_day(S, d, t, last, C):
    return S[d][t] - down(d+1, last, C) + C[t] * (d+1 - last[t])


def main():
    start = time.time()
    D = int(input())
    C = [int(c) for c in input().split()]

    S = [0] * D

    for d in range(D):
        S[d] = [int(s) for s in input().split()]

    last = [0] * 26
    scores = [float('-inf')] * D

    result = 0
    T = [0] * D
    for d in range(D):
        next_t = 0
        score = float('-inf')
        for t in range(26):
            s = calc_score_of_the_day(S, d, t, last, C)
            if s > score:
                score = s
                next_t = t
        last[next_t] = d + 1
        result += score
        scores[d] = result
        T[d] = next_t + 1


    while time.time() - start < 1.9:
        result = scores[D-1]
        change_date = random.randint(0, D-1)
        change_from = T[change_date]
        change_to = random.randint(1, 26)
        delta = result - scores[change_date-1] if change_date > 0 else result

        if change_from == change_to:
            continue
        copied_T = copy.copy(T)
        copied_T[change_date] = change_to

        delta_to = 0
        last_of_the_day = [t if t <=change_date else 0 for t in last]
        copied_scores = copy.copy(scores)
        for d in range(change_date, D):
            t = copied_T[d] - 1
            score = calc_score_of_the_day(S, d, t, last_of_the_day, C)
            last_of_the_day[t] = d + 1
            delta_to += score
            copied_scores[d] = copied_scores[d-1] + delta_to
            copied_T[d] = t + 1
        if delta_to >= delta:
            scores = copied_scores
            T = copied_T


    for t in T:
        print(t)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10012
//Author : Prakhar Asaiya
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(ll i=a;i<b;++i)
#define REPN(i,a,b) for(ll i=a;i<=b;++i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define ll long long
#define ld long double
const int M=1e9+7;



int main()
{/*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#*/
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  
  	string s;
  	cin>>s;
  	REP(i,0,s.size())
  	{
  		if(s[i] == '?')
  		s[i] = 'D';
	}
     cout<<s<<"\n";

   return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    // Your code here!
    int N,ans=0;
    scanf("%d",&N);
    int a[N];
    for (int j=0;j<N;j++){
        scanf("%d",&a[j]);
    }
    for (int i=1;i<N;i++){
        if(a[i-1]==a[i]){
            ans+=1;
            a[i]=0;
        }
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  i64 H, N, i, j;
  cin >> H >> N;
  vi A(N), B(N);
  REP(0, N, i) {
    cin >> A[i] >> B[i];
  }

  vi ans(H+1, 2 * 10000 * 10000);
  ans[0] = 0;
  REP(0, H+1, i) {
    REP(0, N, j) {
      i64 k = min(H, i + A[j]);
      ans[k] = min(ans[k], ans[i] + B[j]);
    }
  }

  cout << ans[H] << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
  int n;
  int m;
  int p,x;
  cin>>n;
  int arr[n]={0};
  int sum=0;
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
    sum+=arr[i];
  }
 
  cin>>m;
  for(int i=0;i<m;i++)
  {
    cin>>p>>x;
    cout<<sum-arr[p-1]+x<<endl;
  }
  return 0;
}

  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 29;
constexpr lint   INFL = 1LL << 61;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

template <typename T>
T gcd(T a, T b) {
  while (a && b) {
    if (a >= b) a %= b;
    else b %= a;
  }
  return a + b;
}

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  rep (i, n) cin >> a[i];
  int ret = a[0];
  rep (i, 1, n) ret = gcd(ret, a[i]);
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 640
alias :math, as: Math
defmodule Main do
  def main do
    [a, b, x] =
      IO.read(:line)
      |> String.trim
      |> String.split(" ")
    a = String.to_integer(a)
    b = String.to_integer(b)
    x = String.to_integer(x)
    y = x / a;
    if y > a * b / 2 do
    	IO.puts(Math.atan2((a*b-y)*2, a*a) * 180 / Math.pi())
    else
    	IO.puts(Math.atan2(b*b, y*2) * 180 / Math.pi())
    end
  end
end


Measured memory_bytes: 31172
#include <stdlib.h>
#include <stdio.h>
int isOK(int vec[],long int index,long int key){
	if (vec[index] >= key) return -1; //trueのつもり
	else return 0; //falseのつもり
}

int binary_search(int vec[],long int key,long int length){ //key以上で最小の要素番号を返す
	long int ng = -1;
	long int ok = length;
	while (abs(ok - ng) > 1){
		long int mid = (ok + ng) / 2;
		
		if (isOK(vec, mid, key)) ok = mid;
		else ng = mid;
	}
	
	return ok;
}

#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

#define rep(i, n) for (int i = 0; i < (int) n; i++)
int main(){
  long int n;
  scanf("%d", &n);
  int a[n], b[n], c[n];
  rep(i, n) {
    scanf("%d", &a[i]);
  }
  rep(i, n) {
    scanf("%d", &b[i]);
  }
  rep(i, n) {
    scanf("%d", &c[i]);
  }
  qsort(a, n, sizeof(int), compare_int);
  qsort(c, n, sizeof(int), compare_int);
  long int low, up;
  long int ans = 0;
  rep(i, n) {
    low = binary_search(a, b[i], n);
  	up = n - binary_search(c, b[i] + 1, n);
    ans += low * up;
  }
  printf("%ld", ans);
  return 0;
}

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
 ll n, k, ans=0;
 cin >> n >> k;
 ll h[n];
 for(int i=0;i<n;i++) cin >> h[i];
 sort(h,h+n,greater<int>());
 if(k>=n) cout << "0";
 else{
   for(int i=0;i<n;i++){
     if(i<k) continue;
     else ans+=h[i];
   }
   cout << ans;
 }
 return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
const ll mod = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    deque<ll> a;
    rep(i, n)
    {
        int x;
        cin >> x;
        if (i % 2 == 0)
            a.push_back(x);
        else
            a.push_front(x);
    }
    if (n % 2 == 0)
    {
        rep(i, n)
        {
            int s = a.front();
            a.pop_front();
            cout << s << " ";
        }
        cout << endl;
    }
    else
    {
        rep(i, n)
        {
            int s = a.back();
            a.pop_back();
            cout << s << " ";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3840
import math
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(map(int, input().split()))
def i_row(N): return [int(input()) for _ in range(N)]
def i_row_list(N): return [list(map(int, input().split())) for _ in range(N)]

mnum,snum=i_map()
snholder=set()
for i in range(snum):
    d=i_input()
    ls=i_list()
    snholder=snholder | set(ls)
print(mnum-len(snholder))



Measured memory_bytes: 9100
let n, x = Scanf.scanf " %d %d" @@ fun a b -> a, b
let ms = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let m, s = Array.fold_left min ms.(0) ms, Array.fold_left (+) 0 ms
let _ = n + (x - s) / m |> Printf.printf "%d\n"

Measured memory_bytes: 384
N,M = map(int,input().split())
L = []
R = []
for i in range(1,M+1):
  L_val,R_val = map(int,input().split())
  L.append(L_val)
  R.append(R_val)
ans = max(min(R) - max(L) + 1,0)
print(ans)

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

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

void empty(int *,int *);
int dfs(int,int,int,int,const int);
int cal();
void swap(int *,int *);

int main() {
    int i,j,a,x,y,l;
    for(i=0; i<3; i++) {
        for(j=0; j<3; j++) scanf("%d",&puzzle[i][j]);
    }

    empty(&x,&y);
    for(l=0; l<100; l++) {
        for(i=0; i<3; i++) {
            for(j=0; j<3; j++) tmp[i][j] = puzzle[i][j];
        }

        a = dfs(x,y,-1,0,l);
        if(a!=-1) {
            printf("%d\n",a);
            break;
        }

        for(i=0 ; i<3 ; i++) {
            for(j=0 ; j<3 ; j++) puzzle[i][j] = tmp[i][j];
        }
        a = -1;
        if(l==99) printf("%d\n",a);
    } 
    return 0;
}

void empty(int *x,int *y) {
    int i,j;
    for(i=0; i<3; i++) {
        for(j=0; j<3; j++) {
            if(!puzzle[i][j]) {
                *x = j;
                *y = i;
                return;
            }
        }
    }
}

void swap(int *a,int *b) {
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int cal() {
    int i,a,sum=0;
    for(i=0; i<9; i++) {
        a = puzzle[i/3][i%3];
        if(a) {
            a--;
            sum += abs(i/3 - a/3) + abs(i%3 - a%3);
        }
    }
    return sum;
}

int dfs(int x,int y,int p,int dep,const int lim) {
    int i,h,nx,ny,res;

    h = cal();
    if(h==0) return dep;
    if(dep+h>lim) return -1;

    for(i=0; i<4; i++) {
        nx = x+dx[i];
        ny = y+dy[i];
 
        if(~p && i==(p+2)%4) continue;
        if(!(0<=nx && nx<3 && 0<=ny && ny<3)) continue;
 
        swap(&puzzle[y][x],&puzzle[ny][nx]);
        res = dfs(nx,ny,i,dep+1,lim);
        if(~res) return res;
 
        swap(&puzzle[y][x],&puzzle[ny][nx]);
    }

    return -1;
}

Measured memory_bytes: 600
/*      Welcome to my Code      */

#include <bits/stdc++.h>
#define ll                      long long int
#define i(a,n)                  int a=n;
#define l(a,n)                  ll a=n;
#define d(a,n)                  double a=n;
#define s(a)                    string a;
#define c(a)                    ll a; cin>>a;a
#define cd(a)                   double a; cin>>a;
#define cs(a)                   string a; cin>>a;
#define ci(a)                   cin>>a;
#define co(a)                   cout<<a;
#define cos(a)                  cout<<a<<" ";
#define con(a)                  cout<<a<<endl;
#define yes                     cout<<"YES"<<endl
#define no                      cout<<"NO"<<endl
#define nl                      cout<<endl;
#define ca(arr,n)               for(ll i=0;i<n;i++) cin>>arr[i];
#define f0(i,a,n)               for(ll i=a;i>=n;i--)
#define f(i,n)                  for(ll i=0;i<n;i++)
#define f1(i,a,n)               for(ll i=a;i<n;i++)
#define lcm(a,b)                (a*b)/__gcd(a,b)
#define T                       ll t=1; cin>>t; while(t--)
#define fast                    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ret(x)                  return cout<<x,0;

using namespace std;

int main()
{
    fast;
    cs(s);
    cout<<(s=="RRR"?3:s=="SSS"?0:s=="RRS"||s=="SRR"?2:1)<<endl;
    return 0;
}

/*It's not who I am underneath, but what I do that defines me

MMMMMMMMMMMMMMMMMMMMM.                             MMMMMMMMMMMMMMMMMMMMM
 `MMMMMMMMMMMMMMMMMMMM           M\  /M           MMMMMMMMMMMMMMMMMMMM'
   `MMMMMMMMMMMMMMMMMMM          MMMMMM          MMMMMMMMMMMMMMMMMMM'
     MMMMMMMMMMMMMMMMMMM-_______MMMMMMMM_______-MMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
     .MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM.
    MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
                   `MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM'
                          `MMMMMMMMMMMMMMMMMM'
                              `MMMMMMMMMM'
                                 MMMMMM
                                  MMMM
                                   MM
*/


Measured memory_bytes: 3612
/*
ID: barish21
LANG: C++14
TASK: test
*/

/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();

const intt max1 = 11;
const intt max2 = 102;
const intt max3 = 1003;
const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;
const intt lg2 = 7;
const intt lg3 = 10;
const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;
const intt lg7 = 24;
const intt lg8 = 27;
const intt lg9 = 30;
const intt lg18 = 60;
const intt INF = 2LL * 1000000000;
/***************/

/***Additional Functions***/
intt powmod(intt a,intt b,intt mod){intt res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
intt gcd(intt a, intt b) { while(b) b ^= a ^= b ^= a %= b; return a;}
intt lcm(intt a,intt b){return a*b/gcd(a,b);}
intt is_prime(intt n){if(n==1)return 0;if(n==2)return 1;if(n%2==0)return 0;for(intt i=3;i<=sqrt(n);i+=2)if(n%i==0)return 0;return 1;}
intt is_integer(double n){if(floor(n)==ceil(n))return 1;return 0;}

intt sto_int(string s){stringstream ss(s);intt n;ss>>n;return n;}
string to_string(intt n){stringstream ss;ss<<n;string s=ss.str();return s;}
/**************************/

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    IO;
    intt n;
    cin >> n;
    if (n / 100 == n % 10)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 384
import fractions

A, B, C, D = map(int, input().split())
A -= 1
tmp = fractions.gcd(C, D)
lcd = (C * D) // tmp
acnt1 = A // C
acnt2 = A // D
acnt3 = B // C
acnt4 = B // D
acnt5 = A // lcd
acnt6 = B // lcd
ans = B - A
atmp = acnt3 + acnt4 - acnt1 - acnt2 + acnt5 - acnt6
ans -= atmp
print(ans)


Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
#define re return
#define ll long long
int main(){
	ios::sync_with_stdio(false),cin.tie(0);
	long long n;
	cin>>n;
	ll ans=0;
	for(int i=1;i<n+1;i++){
		ll use;
		use=n/i;
		ans+=(use*(use+1)/2)*i;
	}
	cout<<ans<<endl;
	re 0;
}

Measured memory_bytes: 3584
console.log(function(args){
  const _tmp = args.trim().split('\n');
  const [N,M,X] = _tmp.shift().split(' ').map(v=>0|v);
  const book = [];
  for ( let i = 0; i < N; i++ ) {
    const [price,...A] = _tmp[i].split(' ').map(v=>0|v);
    book.push({price,A});
  }
  let skill = Array(M).fill(0), cheepest = Infinity;
  TEST: for ( let mask = 1; mask < 1 << N; mask++ ) {
    let price = 0;
    skill.fill(0);
    for ( let i = 0; i < N; i++ ) {
      if ( !(mask & 1<<i) ) continue;
      price += book[i].price;
      if ( price >= cheepest ) continue TEST;
      for ( let j = 0; j < M; j++ ) {
        skill[j] += book[i].A[j];
      }
    }
    if ( skill.some(x=>x<X) ) continue;
    cheepest = price;
  }
  return isFinite(cheepest) ? cheepest.toString() : '-1';
}(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 32568
#include <vector>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <iostream>
#define PB push_back
using namespace std;
vector<int> book[10],kak[10];
int dp[2001];
int main(){
    int N,K;
    scanf("%d%d",&N,&K);
    for(int i=0;i<10;i++){
        book[i]=vector<int>();
    }
    for(int i=0;i<N;i++){
        int c,g;
        scanf("%d%d",&c,&g);
        g--;
        book[g].PB(c);
    }
    for(int i=0;i<10;i++){
        sort(book[i].begin(),book[i].end(),greater<int>());
    }
    for(int i=0;i<=K;i++){
        dp[i]=0;
    }
    for(int i=0;i<10;i++){
        kak[i]=vector<int>(book[i].size());
        if(book[i].size()>0){
            kak[i][0]=book[i][0];
            for(int j=1;j<kak[i].size();j++){
                kak[i][j]=kak[i][j-1]-(j-1)*j+book[i][j]+j*(j+1);
            }
            for(int j=K;j>=0;j--){
                for(int k=0;k<min(j,(int)kak[i].size());k++){
                    dp[j]=max(dp[j],dp[j-k-1]+kak[i][k]);
                }
            }
        }
    }
    printf("%d\n",dp[K]);
}

Measured memory_bytes: 0
// input macro
// ref: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::min;

#[allow(unused_mut)]
fn main() {
    input! {
        n: usize,
        h: [i32; n],
    }

    let mut dp = vec![0; n+1];

    for i in 0..n {
        if i == 0 {
            dp[1] = 0;
        } else if i == 1 {
            dp[2] = (h[1] - h[0]).abs();
        } else {
            dp[i+1] = min(dp[i-1] + (h[i]-h[i-2]).abs(),
                          dp[i] + (h[i] - h[i-1]).abs());
        }
    }

    println!("{}", dp[n]);
}

Measured memory_bytes: 4352
n = gets.chomp("\n").to_i
mochis = []
n.times do
  mochis << gets.chomp("\n").to_i
end

count = 0
if mochis.uniq.length == 1
  # 全て同じ直径なら1
  count = 1
else
  # 前処理
  new_mochis = mochis.uniq.compact.reject { |m| m.zero? }
  # 鏡餅枚数
  count = new_mochis.length unless new_mochis.length.zero?
end
puts count


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

int main() {
    vector<int> num(3);

    for ( int i = 0; i < 3; i++ ) {
        cin >> num[i];
    }

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

    cout << num[0] + num[1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define rev1(i,n) for(ll i=n;i>0;i--)
#define pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int> >
#define vb vector<bool>
#define pii pair<int,int>
#define F first
#define S second
#define INF 1e9+7
typedef long long int ll;

const int N=2e3+7;
int arr[N];

void solve(){
    int n,X,Y;
    cin>>n>>X>>Y;
    rep1(i,n) rep1(j,n) if(j>i) arr[min(abs(j-i),min(abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(X-j)))]++;
    rep1(i,n-1) cout<<arr[i]<<"\n";
    
    //rep1(i,n) { rep1(j,n) cout<<sd[i][j]<<" "; cout<<"\n";}
}
signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve(); 
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

struct edge{ int to, cap, rev;};

static const int MAX_V = 110;
static const int INF = (1<<30);

vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];
int V, E;

void add_edge(int from, int to, int cap){
	G[from].push_back((edge){to, cap, (int)G[to].size()});
	G[to].push_back((edge){from, 0, (int)G[from].size()-1});
}

void bfs(int s){
	fill(level, level+MAX_V, -1);
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while (!que.empty()){
		int v = que.front(); que.pop();
		for (int i = 0; i < G[v].size(); ++i)
		{
			edge &e = G[v][i];
			if (e.cap > 0 && level[e.to] < 0)
			{
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}


int dfs(int v, int t, int f){
	if (v == t) return f;
	for (int &i = iter[v]; i < G[v].size(); ++i)
	{
		edge &e = G[v][i];
		if (e.cap > 0 && level[v] < level[e.to])
		{
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0)
			{
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t){
	int flow = 0;
	for (; ;)
	{
		bfs(s);
		if (level[t] < 0) return flow;
		fill(iter, iter+MAX_V, 0);
		int f;
		while((f = dfs(s, t, INF)) > 0){
			flow += f;
		}
	}
}

int main(int argc, char const *argv[])
{
	cin >> V >> E;
	for (int i = 0; i < E; ++i)
	{
		int s, t, c;
		cin >> s >> t >> c;
		add_edge(s, t, c);
	}
	cout << max_flow(0, V-1) << endl;
	return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int K,X,st,en;
  cin>>K>>X;
  st=X-K+1;
  en=X+K-1;
 
    if(st<-1000000){
      while(1) st++;
    }
    if(en>1000000){
      while(1) en--;
    }
  	for(;st<=en;st++) cout<<st<<" ";
  cout<<endl;
}	


Measured memory_bytes: 256
import bisect
A,B,Q=map(int,input().split())
s=[-10**15]
t=[-10**15]
ans=[]
for _ in range(A):
    s.append(int(input()))
for _ in range(B):
    t.append(int(input()))
s.append(10**15)
t.append(10**15)
def search(a,b,q):
    dis=10**15
    S=[s[a-1],s[a]]
    T=[t[b-1],t[b]]
    for i in range(2):
        for j in range(2):
            A=min(abs(S[i]-q),abs(T[j]-q))+abs(S[i]-T[j])
            dis=min(dis,A)
    return dis
for _ in range(Q):
    q=int(input())
    r=bisect.bisect_left(s,q)
    l=bisect.bisect_left(t,q)
    ans.append(search(r,l,q))
for i in ans:
    print(i)

Measured memory_bytes: 16924
#include <stdio.h>
int main(void)
{
  int h,w,i,j;
  while(1){
     scanf("%d %d",&h,&w);
     if(h == 0 && w == 0) break;
     for(i = 0; i < h; i++){
        for(j = 0; j < w; j++){
            printf("#");
        }
        printf("\n");
     }
     printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define maxn 100005
#define ll long long
#define ld double
#define mod 1000000007
using namespace std;	
int q[maxn], f, e;
vector<int> nx[maxn];
int d[maxn];
int r[maxn];
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 0; i < n + m - 1; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		d[u]++, nx[v].push_back(u);
	}
	for(int i = 1; i <= n; i++)
		if(!d[i]) q[e++] = i;
	while(f < e)
	{
		int nid = q[f];
		r[nid] = f;
		f++;
		for(int j = 0; j < nx[nid].size(); j++)
		{
			int v = nx[nid][j];
			d[v]--;
			if(!d[v]) q[e++] = v;
		}
	}
	r[0] = maxn;
	for(int i = 1; i <= n; i++)
	{
		int mns = 0;
		for(int j = 0; j < nx[i].size(); j++)
		{
			int v = nx[i][j];
			if(r[v] < r[mns]) mns = v;
		}
		printf("%d\n", mns);
	}
	return 0;
} 
/*
bbbbbb
bababa

*/

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

typedef long long ll;
typedef vector <ll> vr;
typedef pair <ll, ll> pr;
typedef vector <ll> :: iterator ir;

#define pub push_back
#define pob pop_back
#define mp make_pair
#define pc __builtin_popcount
#define lb lower_bound

ll dig(ll n) {
	string s = to_string(n);
	return s.size();
}

ll totSum(ll arr[], ll n) {
	ll sum = 0;
	for (ll i = 0; i < n; i++) {
		sum += arr[i];
	}
	return sum;
}


int main() {

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






// write your code here

	string s, t;
	cin >> s >> t;
	ll ans = INT_MAX;
	for (int i = 0; i < s.length() - t.length() + 1 ; i++) {
		ll tmp = i;
		ll count = 0;
		for (int j = 0; j < t.length(); j++) {
			if (s[tmp] != t[j])count++;
			tmp++;
		}
		ans = min(count, ans);
	}
	cout << ans;

// this is the end of your code

}


Measured memory_bytes: 3664
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int a, b, c; cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " "<< b << " " <<  c << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 10;
const long long mod = 1e9 + 7;
typedef long long ll;

#define A first
#define B second

int n;
pair<ll,ll> p[maxN];
map<pair<ll, ll>, int> cnt;
ll Pow[maxN];

void func(pair<ll,ll> &x) {
  if (!(x.A == 0 && x.B == 0) ) {
    ll gcd = __gcd(abs(x.A), abs(x.B));
    x.A = x.A / gcd;
    x.B = x.B / gcd;
  }
  if (x.A == 0) x.B = abs(x.B);
  if (x.A < 0) {
    x.A = -x.A;
    x.B = -x.B;
  }
}

int m;
vector<pair<ll,ll> > bi;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//  freopen("abc.inp", "r", stdin); freopen("abc.out", "w", stdout);
  cin >> n;
  ll spe = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i].A >> p[i].B;
    if (p[i].A == 0 && p[i].B == 0) ++spe;
    pair<ll, ll> op;
    op = {-p[i].B, p[i].A};
    func(p[i]); func(op);
    cnt[op]++;
  }

  Pow[0] = 1;
  for (int i = 1; i <= n; ++i) Pow[i] = (Pow[i-1] * 2) % mod;
  ll ans = 1;
  sort(p + 1, p + n + 1);
  for (int i = 1; i <= n; ++i) {
    if (p[i].A == 0 && p[i].B == 0) continue;
    int j = i, d = 0;
    while (j <= n && p[j] == p[i]) {
      ++j; ++d;
    }
    --j;
    ll lk = d, rk = cnt[p[i]];
    if (lk > rk) swap(lk, rk);
    bi.push_back({lk, rk});
    i = j;
  }
  sort(bi.begin(), bi.end());
  int md = 0;
  for (auto g : bi) {
    if (g.A) md = (md + 1) % 2;
    if (md % 2) continue;
    ll ret = Pow[g.A] + Pow[g.B];
    ret = (ret - 1 + mod) % mod;
    ans = (ans * ret) % mod;
  }
  cout << (ans - 1 + mod + spe) % mod;
  return 0;
}


Measured memory_bytes: 35980
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int n,x=0,c=0;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='I')x++;
		else x--;
		if(c<x)c=x;
	}
	cout<<c<<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 N = sc.nextInt();
        long K = sc.nextLong();
        int[] a = new int[N];
        int[] b = new int[N];

        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        long[] num = new long[100001];
        for(int i=0; i<=100000; i++){
            num[i] = 0;
        }

        for(int i=0; i<N; i++){
            num[a[i]] += b[i];
        }
        long sum = 0;
        for(int i=0; i<100001; i++){
            sum += num[i];
            if(sum>=K){
                System.out.println(i);
                break;
            }
        }
    }
}

Measured memory_bytes: 65268
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
using namespace std;
int main()
{
    int k,l,m,i,j,len,n,cnt=0,cnt2=0,r=0;
    string s,t;
    cin>>s;
    len = s.size();
    t=s;
    k = (len-1)/2;
    m = (len+3)/2;
    n = ((m-1)+(len-1))/2;
    for(i=0,j=len-1;i<len/2;i++,j--)
    {
        if(s[i]!=s[j])
        {
            r=1;
            break;
        }
        else
            r=0;
    }

    if(r==0){
    for(i=0,j=k-1;i<k/2; i++,j--)
    {
        if(s[i]!=s[j])
        {
             cnt=1;
             break;
        }
        else
            cnt=0;
    }
    if(cnt==1)
    {
        cout<<"No"<<"\n";
        return 0;
    }
    for(i=m-1,j=len-1;i<n+1; i++,j--)
    {
        if(s[i]!=s[j])
        {
             cnt2=1;
             break;
        }
        else
            cnt2=0;
    }


        if(cnt2==1)
            cout<<"No"<<"\n";
        else
            cout<<"Yes"<<"\n";


    }
        else
        cout<<"No"<<"\n";
            return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,z=1,i,sum=0;
    scanf("%d",&a);
    int c[a];
    for(i=0;i<a;i++){
        scanf("%d",&c[i]);
    }
    for(i=0;i<a;i++,z++)
    {
       if(c[i]!=z) sum++;
    }
    if(sum<=2)printf("YES\n");
    else printf("NO\n");
    return 0;
}



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

int main(){
    int n;
    cin >> n;
    vector<int> mons(n+1);
    vector<int> cap(n);
    rep(i,n+1) cin >> mons[i];
    rep(i,n) cin >> cap[i];
    ll ans=0;
    for(int i=0;i<n;i++){
        if(mons[i]>=cap[i]){
            ans+=cap[i];
        }else{
            ans+=mons[i];
            if(mons[i+1]>=cap[i]-mons[i]){
                mons[i+1]-=cap[i]-mons[i];
                ans+=cap[i]-mons[i];
            }else{
                ans+=mons[i+1];
                mons[i+1]=0;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] input1 = br.readLine().split(" ");
        int h = Integer.parseInt(input1[0]);
        int n = Integer.parseInt(input1[1]);
        
        String[] input2 = br.readLine().split(" ");
        int[] numbers = new int[n];
        int sum = 0;
        
        for(int i = 0; i < n; i++){
            numbers[i] = Integer.parseInt(input2[i]);
            sum += numbers[i];
        }
        
        out.println(sum >= h ? "Yes" : "No");
        out.close();
        
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  ll N;
  cin >> N;
  vector<ll> l(40), r(40);
  l[0] = 0, r[0] = 1;
  for (int i = 1; i < 40; i++) {
    if (i % 2 == 0) {
      l[i] = l[i - 1];
      r[i] = r[i - 1] + (1ll << i);
    } else {
      l[i] = l[i - 1] - (1ll << i);
      r[i] = r[i - 1];
    }
  }
  int idx = 0;
  while (N < l[idx] || r[idx] < N) idx++;
  ll rem = N;
  for (int i = idx; i >= 0; i--) {
    ll sgn = (i % 2 == 0) ? 1ll : -1ll;
    if (i == 0) {
      assert(rem == 0 || rem == 1);
      cout << rem;
    } else {
      if (l[i - 1] <= rem && rem <= r[i - 1])
        cout << 0;
      else {
        cout << 1;
        rem -= sgn * (1ll << i);
      }
    }
  }
  cout << endl;

  return;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();
  return 0;
}


Measured memory_bytes: 256
# いろいろやりかたありそうだけど尺取っぽくやってみた

n = int(input())
s = input()
ans = 0
l, r = 0, 0
while l < n:
    while r < n and s[l] == s[r]:
        r += 1
    if r <= l:
        r = l + 1
    ans += 1
    l = r

print(ans)



Measured memory_bytes: 39664
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll d, t, s;
    cin >> d >> t >> s;
    cout << (s * t < d ? "No" : "Yes") << '\n';
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
using namespace std;
long long arr[1000005];

void solve(long long n, long long c, long long k){
	sort(arr , arr + n);
	long long busPopulation = 1 , count = 1 , start = arr[0];

	for(long long i = 1; i < n; i++){
		if(arr[i] <= (start + k) && busPopulation < c){
			busPopulation++; 
		}
		else{
			count++;
			busPopulation = 1; // Create new bus
			start = arr[i];
		}
	}
	cout << count << endl; 
}

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(); cout.tie();
	long long n, c, k;
	cin >> n >> c >> k; 
	// C - Bus capacity, K - Min Time
	for(long long i = 0; i < n; i++){
		cin >> arr[i];
	}
	solve(n , c, k);
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ll long long
#define ld long double
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)

#define xx first
#define yy second
#define mp make_pair
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define pdd pair<double,double>
#define ALL(v) (v).begin(), (v).end()

const ll MOD=1e9+7;
const ll inf=1e10;

#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define put(x) cout<<#x<<" = "<<x<<endl;

ll power(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a);
        n>>=1;
        a=(a*a);
    }
    return ans;
}


ll powerMod(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%MOD;
        n/=2;
        a=(a*a)%MOD;
    }
    return ans;
}

ll powerMod1(ll a,ll n,ll mod){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%mod;
        n>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

ll lcm(ll a,ll b){
    return a*(b/__gcd(a,b));
}

ll sumdigit(ll n){
    ll sum=0;
    while(n){
        sum+=n%10;
        n=n/10;
    }
    return sum;
}

ll countSetBit(ll a){
    return __builtin_popcount(a);
}
ll countBit(ll a){
    ll sum=0;
    while(a){
        sum++;
        a>>=1;
    }
    return sum;
}

ll length(ll a){
    ll ans=0;
    while(a){
        ans++;
        a=a/10;
    }
    return ans;
}
//~ ll arr[]={3,8,15,24,35,48,63,80};
//~ vector(
int main()
{
    fast;
    ll t;
    //~ cin>>t;
    t=1;
	while(t--){
			ll n;
			cin>>n;
			cout<<(n+1)/2-1;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
    IOS();
    string s;
    cin >> s;
    ll cnt = 0;
    for (int i=0;i<SZ(s);++i) {
        cnt += (s[i] - '0');
    }
    if (cnt % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

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

        scanf("%d%d%d",&a,&b,&c);

        if(a>=b&&a>=c)
        {
            printf("%d",b+c);

        }
        if(b>a&&b>c)
        {
            printf("%d",a+c);
        }
        if(c>a&&c>b)
        {
            printf("%d",a+b);
        }


    return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
h,n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

inf = 10**9
dp = [inf]*(h+1)
dp[0] = 0
for i in range(n):
    for j in range(h+1):
        d = min(j+ab[i][0], h)
        dp[d] = min(dp[d], dp[j]+ab[i][1])

res = dp[h]
print(res)


Measured memory_bytes: 44084
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    int c = 0;
    int p = 0;
    for (int i = __gcd(A,B); i > 0; i--) {
        if (A % i == 0 && B % i == 0) {
            c++;
            p = i;
            if (c == K) break;
        }
    }
    cout << p << endl;
}


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

int main() {
	double temp,max=0,min=9999;
	while(cin>>temp){
		if(temp>max) max=temp;
		if(min>temp) min=temp;
	} printf("%.1f",max-min);
	return 0;
}

Measured memory_bytes: 1232
import java.util.Scanner;

public class Main {
    // AtCoder Beginner Contest 154
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.nextLine();
        for(int x = 0; x<S.length(); x++){
            System.out.print("x");
        }

    }




}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;

int main() {
    ll n; cin >> n;
    vl v(3,0);
    rep(i,n){
        ll a; cin >> a;
        if(a%4==0) v[2]++;
        else if(a%2==0) v[1]++;
        else v[0]++;
    }
    if(v[1]>=1) {
        if(v[0]==0){
            puts("Yes");
            return 0;
        }
        v[0]++;
    }
    if(v[2]==0){
        if(v[0]==0) puts("Yes");
        else puts("No");
    }
    else if(v[0]-v[2]<=1) puts("Yes");
    else puts("No");
}

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

struct node{
    struct node *Left;
    struct node *Right;
    struct node *Parent;
    int ndkey;
};

typedef struct node * NodePointer;

NodePointer root = NULL;
NodePointer NIL = NULL;

NodePointer makeNode(){
    NodePointer node = malloc(sizeof(struct node));
    node->Left = NULL;
    node->Right = NULL;
    node->Parent = NULL;
    node->ndkey = 0;
    return node;
}

void insert(int ndkey){
    NodePointer z = makeNode();
    NodePointer x = root;
    NodePointer y = NIL;
    z -> ndkey = ndkey;

    while(x!=NIL){
        y = x;
        if(z->ndkey < y->ndkey) x = x -> Left;
        else x = x -> Right;
    }

    z -> Parent = y;
    if(y == NIL) root = z;
    else if(z -> ndkey < y -> ndkey) y -> Left = z;
    else y -> Right = z;
}

void preO(NodePointer p){
    printf(" %d", p->ndkey);
    if(p->Left != NULL) preO(p->Left);
    if(p->Right != NULL) preO(p->Right);
}

void i_order(NodePointer p){
        if(p->Left != NULL) i_order(p->Left);
        printf(" %d", p->ndkey);
        if(p->Right != NULL) i_order(p->Right);
}

int main(){

   int i,m,n;
   char O[10];

   scanf("%d",&m);

   for(i=0;i<m;i++){
       scanf("%s",O);

       if(O[0]=='i'){
           scanf("%d",&n);
           insert(n);
       }

       else if(O[0]=='p'){
           i_order(root);
           printf("\n");
           preO(root);
           printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 24040
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    string s;
    cin >> s;
    int ans1=0,ans2=0;

    rep(i,s.length()){
        if(i % 2 == 0){
            if(s[i] == '1') ans1++;
            if(s[i] == '0') ans2++;
        }else if(i % 2 == 1){
            if(s[i] == '0') ans1++;
            if(s[i] == '1') ans2++;
        }
    }
    cout << min(ans1,ans2) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){
  int A, B;
  cin >> A >> B;
  int ans = 0;

  for (int i = A; i <= B; i++){
    int s = i % 10, t = i / 10000 % 10; // 5桁目と1桁目
    int u = i / 10 % 10, v = i/1000 % 10; // 4桁目と2桁目

    if ( s == t && u == v ) ans++;

  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256