akhauriyash/Code-Regression huggingface dataset:
use std::fmt::Write;

fn main(){
    let mut sc = Scanner::new();
    let n = sc.next();
    let mut x = vec![0i64; n];
    for i in 0..n {
        x[i] = sc.next();
    }
    let mut d = vec![0i64; n-1];
    for i in 0..n-1 {
        d[i] = x[i+1] - x[i];
    }
    let m = sc.next();
    let k = sc.next();
    let mut perm:Vec<_> = (0..n-1).collect();
    for _ in 0..m {
        let a = sc.next::<usize>() - 1;
        perm.swap(a-1, a);
    }
    let perm2 = pow(&perm, k);
    let mut res = vec![0i64; n-1];
    for i in 0..n-1 {
        res[i] = d[perm2[i]];
    }

    let mut ans = String::new();
    let mut cur = x[0];
    writeln!(&mut ans, "{}", cur).unwrap();
    for i in 0..n-1 {
        cur += res[i];
        writeln!(&mut ans, "{}", cur).unwrap();
    }

    print!("{}", ans);
}

fn pow(perm: &Vec<usize>, k: usize) -> Vec<usize> {
    if k == 0 {
        (0..perm.len()).collect()
    } else if k%2 == 1 {
        let x = pow(perm, k-1);
        prod(&x, &perm)
    } else {
        let x = pow(perm, k/2);
        prod(&x, &x)
    }
}

fn prod(a: &Vec<usize>, b: &Vec<usize>) -> Vec<usize> {
    let n = a.len();
    let mut res = vec![0; n];
    for i in 0..n {
        res[i] = a[b[i]];
    }
    res
}

#[allow(dead_code)]
struct Scanner {
    buf: std::collections::VecDeque<String>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner { buf: std::collections::VecDeque::new() }
    }

    fn next<T: std::str::FromStr>(&mut self) -> T {
        self.wrapped::<T>().unwrap()
    }

    fn wrapped<T: std::str::FromStr>(&mut self) -> Option<T> {
        self.read();
        self.buf.pop_front().and_then(|s| s.parse::<T>().ok())
    }

    fn ok(&mut self) -> bool {
        self.read() && !self.buf.is_empty()
    }

    fn eof(&mut self) -> bool {
        !self.ok()
    }

    fn read(&mut self) -> bool {
        while self.buf.is_empty() {
            let mut st = String::new();
            while st.trim() == "" {
                match std::io::stdin().read_line(&mut st) {
                    Ok(l) if l > 0 => continue,
                    _ => return false,
                }
            }
            self.buf = st.split_whitespace().map(|x| x.to_string()).collect();
        }
        true
    }
}


Measured memory_bytes: 10372
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
	FastIO
	lld n, i;
	cin >> n;
	lld A[n];
	map <lld, lld> count;
	set <lld> points;
	foi(i,n){
		lld r;
		cin >> r;
		A[i] = r;
		points.insert(r);
		count[r]++;
	}
	foi(i,n){
		count[A[i]]--;
		if (count[A[i]] == 0){
			points.erase(A[i]);
		}
		set <lld> :: iterator pos = points.end();
		pos--;
		cout << (*pos) << "\n";
		count[A[i]]++;
		points.insert(A[i]);
	}
	return 0;
}

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

int main() {
	int64_t n, k;
	cin >> n >> k;
	vector<int64_t> v(n);
	int64_t sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		sum += v[i];
	}
	int64_t val = 0;
	for (int bit = 40; bit >= 0; --bit) {
		int set = 0;
		for (int i = 0; i < n; ++i) {
			if ((v[i] >> bit) & 1) {
				set++;
			}
		}
		if ((n - set) > set && ((1LL << bit) + val) <= k) {
			val = (val | (1LL << bit));
		}
	}
	int64_t ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += (val ^ v[i]);
	}
	cout << ans;
}


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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int square = a*a;
		int cube = a*a*a;
		int res = a + square + cube;
		System.out.println(res);
	}

}


Measured memory_bytes: 35636
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;
typedef pair<int,int> p;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x);
    ll t=exp(x,y/2);
    return (t*t);
}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll big=998244353;

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(0);
    /*--------------------------------*/
    
    int h,w,a,b;cin >> h >> w >> a >> b;
    if(a>w/2||b>h/2){cout << "No" << endl;return 0;}
    rep(i,h)rep(j,w){
        if((i<b&&j<a)||(i>=b&&j>=a))cout << 0;
        else cout << 1;
        if(j==w-1)cout << '\n';
    }
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 int main(){
   int count=0,count1=0,count2=0;

   string S;
   cin>>S;
   int N=S.size();
   if(N==1){cout<<0<<endl;}
   else{
   for(int i=0;i<N;i++){
     if(S.at(i)=='1'){
      count1++;}
     else count2++;}
   count=min(count1,count2);
   
      cout<<count*2<<endl; 
   }
 }

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

int xy[14][14] = {};

int dai(int x, int y){
	xy[x-2][y]++;
	xy[x+2][y]++;
	xy[x][y-2]++;
	xy[x][y+2]++;
	return 0;
}

int chu(int x, int y, int z){
	if(z>2){
		dai(x, y);
	}
	xy[x-1][y+1]++;
	xy[x+1][y+1]++;
	xy[x-1][y-1]++;
	xy[x+1][y-1]++;
	return 0;
}

int sho(int x, int y, int z){
	if(z>1){
		chu(x, y, z);
	}
	xy[x][y]++;
	xy[x-1][y]++;
	xy[x][y-1]++;
	xy[x+1][y]++;
	xy[x][y+1]++;
	return 0;
}

int main(){
	string input, xx, yy, zz;
	int x, y, z;
	while (true){
		cin >> input;
		if (cin.eof()) { break; }
		xx = input[0];
		yy = input[2];
		zz = input[4];
		x = stoi(xx) + 2;
		y = stoi(yy) + 2;
		z = stoi(zz);
		sho(x, y, z);
	}
	int add = 0, max = 0;
	for(int i = 2;i<12;i++){
		for(int j = 2;j<12;j++){
			if (xy[i][j] == 0) { add++; }
			if (xy[i][j] > max) { max = xy[i][j]; }
		}
	}
	cout << add << endl
		<< max << endl;
	return 0;
}

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

using namespace std;
#define ll  long long
#define ld long double

struct graw {
ll m;
ll val;
};
int main()
{
 // freopen("input.txt","r",stdin);
 //  freopen("output.txt","w",stdout);
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    ll n,w;
    ll a[105][100005]={0};
    graw b[105]={0};
    cin>>n>>w;
   for(ll i =1;i<=n;i++) {
    cin>>b[i].m>>b[i].val;
   }
   for(ll j =1;j<=n;j++) {
   for(ll i =1;i<=w;i++) {
    if(i>=b[j].m) {
        a[j][i] = max(a[j-1][i],a[j-1][i-b[j].m]+b[j].val);
    } else a[j][i] = a[j-1][i];
   }
   }
   cout<<a[n][w];
}



Measured memory_bytes: 82304
#include <stdio.h>

int main () {
  long long int a,b,k;
  scanf("%lld %lld %lld", &a,&b,&k);

  if(k > a+b){
   printf("0 0\n");
   return 0;
 }

  if(k > a && k <= a+b){
   printf("0 %lld\n", b-(k-a));
   return 0;
 }

  if(k <= a){
   printf("%lld %lld\n", a-k, b);
   return 0;
}
  return 0;
}


Measured memory_bytes: 128
def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = 0
    for i in range(0, n-1):
        if a[i] > a[i+1]:
            step = a[i] - a[i+1]
            a[i+1] = a[i+1] + step
            cnt = cnt + step

    print(cnt)
main()

Measured memory_bytes: 32200
import java.util.*;

class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        final int N = Integer.parseInt(sc.next());
        final String S = sc.next();
        sc.close();

        int cnt = 0;
        for (int i=0; i<10; i++) {
            if (S.indexOf(Integer.toString(i))>-1) {
                String T = S.substring(S.indexOf(Integer.toString(i))+1);
                for (int j=0; j<10; j++) {
                    if (T.indexOf(Integer.toString(j))>-1) {
                        String U = T.substring(T.indexOf(Integer.toString(j))+1);
                        for (int k=0; k<10; k++) {
                            if (U.indexOf(Integer.toString(k))>-1) {
                                cnt++;
                            }
                        }
                    }
                }
    
            }
        }

        System.out.println(cnt);
    }
}

Measured memory_bytes: 28500
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))

j = A.index(min(A))

l = math.ceil((j + 1) / K)
n = l * (K - 1) + 1
r = math.ceil((N - n) / (K - 1))
ans = l + r
#print(l, r, n)
print(ans)

Measured memory_bytes: 13812
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

using namespace std;

int main()
{

    int N;
    char S[50];
    int ans;

    cin >> N;
    cin >> S;
    ans = 0;


    for (int i = 0; i < N-2; i++)
    {
        if (S[i] == 'A')
        {
            if (S[i + 1] == 'B')
            {
                if (S[i + 2] == 'C')
                {
                    ans += 1;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
module Main where

import           Control.Arrow              ((>>>))
import           Control.Monad              (join)
import           Data.ByteString.Lazy.Char8 as C
import           Data.Maybe                 (fromJust)
import           Text.Printf                (printf)

main = C.interact $ C.lines >>> Prelude.map C.words >>>
    Prelude.map (Prelude.map readInt) >>> join >>> solve >>> C.unlines
        where
            readInt = C.readInt >>> fromJust >>> fst

solve :: [Int] -> [C.ByteString]
solve [a,b,h,m] = let [af, bf, hf, mf] = Prelude.map (fromIntegral :: Int -> Double) [a,b,h,m]
                      rad = 2.0 * pi * ((hf / 12.0) + ((mf / 60.0) / 12.0) - (mf / 60.0))
                      c_2 = af*af + bf*bf - 2.0 * af * bf * cos rad in
                      [C.pack $ printf "%.10f" (sqrt c_2) :: C.ByteString]
solve _         = error "bad arg shape"



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

int n, k;
int a[200000];

int main() {
	int i;
	
	cin >> n >> k;
	for (i = 0; i < n; i++) cin >> a[i];
	
	for (i = 0; i < n - k; i++) {
		if (a[i] < a[i + k]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4392
n, k, q = gets.split(' ').map(&:to_i)

su_ary =
  [].tap do |ary|
    q.times do
      ary.push(gets.to_i)
    end
  end

k_ary = Array.new(n, k)

su_h = su_ary.group_by { |a| a }

su_h.each do |k, v|
  k_ary[k - 1] += v.length
end

k_ary.map! { |kk| kk - q }.each do |k|
  puts k > 0 ? 'Yes' : 'No'
end


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

int main()
{
    int n;
    cin >> n;
    int ar[n + 1], tmp;
    for(int i = 1; i <= n; i++){
        cin >> tmp;
        ar[tmp] = i;
    }

    for(int i = 1; i <= n; i++)
        cout << ar[i] << " ";

    return 0;
}

Measured memory_bytes: 1152
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    String O = sc.next();
    String E = sc.next();
    String ans = "";
    if(O.length()==E.length()){
      for(int i=0;i<O.length();i++){
        ans=ans+O.substring(i, i+1);
        ans=ans+E.substring(i, i+1);
      }
    }else{
      for(int i=0;i<E.length();i++){
        ans=ans+O.substring(i, i+1);
        ans=ans+E.substring(i, i+1);
      }
      ans=ans+O.substring(O.length()-1);
    }
    System.out.println(ans);
  }
  

  
}


Measured memory_bytes: 21588
#include<iostream>
#include<cmath>
#include<climits>
using namespace std;
int main()
{
    int n;
    double t, a, h, ans, tmin = INT_MAX;
    cin >> n >> t >> a;
    for(int i = 1; i <= n; i++){
        cin >> h;
        double htp = abs(a - (t - h * 0.006));
        if(tmin > htp){
            tmin = htp;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(250000)

def main():
    n = int(input())

    if n >= 64 :
        print(64)
    elif n >= 32:
        print(32)
    elif n >= 16:
        print(16)
    elif n >=8 :
        print(8)
    elif n >=4 :
        print(4)
    elif n>=2:
        print(2)
    else:
        print(n)
main()



#
# while True:
#     pair_str = input().split()
#     pair_int = [int(s) for s in pair_str]
#     if pair_int[0] == 0 and pair_int[1] == 0 :
#         break
#     else:
#         input_list.append(pair_int)


# if b > c * 2 :
    #     b_price = c
    #
    # input_array_list = []
    #
    # while True:
    #     input_array = input().split()
    #     if input_array[0] == "0" and input_array[1] == "0":
    #         break
    #     else:
    #         input_array_list.append(input_array)
    #
    # for item in input_array_list:
    #     n = int(item[0])
    #     k_sum = int(item[1])
    #
    #     count = 0
    #     for i in range(1,n + 1- 2):
    #         for j in range(i+1, n + 1 - 1):
    #             for k in range (j+1, n+ 1):
    #                 if i + j + k == k_sum :
    #                     count = count + 1
    #     print(count)

    #
    # for item in input_array_list:
    #     if item[1] == "+":
    #         print(str(int(item[0])+int(item[2])))
    #     elif item[1] =="-":
    #         print(str(int(item[0])-int(item[2])))
    #     elif item[1] == "/":
    #         print(str(int(item[0])//int(item[2])))
    #     elif item[1] == "*":
    #         print(str(int(item[0])*int(item[2])))
    #

# import sympy as sp

# input_list = []
# a,b,c = map(int, input().split())
# divisors = sp.divisors(c)
#
# count = 0
#
# for divisor in divisors:
#     if a <= divisor and divisor <= b:
#         count = count + 1
# print(count)
#
# while True:
#     pair_str = input().split()
#     pair_int = [int(s) for s in pair_str]
#     if pair_int[0] == 0 and pair_int[1] == 0 :
#         break
#     else:
#         input_list.append(pair_int)
#
# for pair_int in input_list:
#     if pair_int[0] <= pair_int[1]:
#         print("{} {}".format(pair_int[0], pair_int[1]))
#     else:
#         print("{} {}".format(pair_int[1], pair_int[0]))

#for i in range(10000):
#    print("Hello World")
#a = input().split()
#a_int = [int(s) for s in a]
#a_sorted = sorted(a_int)
#print(' '.join(map(str, a_sorted)))


Measured memory_bytes: 9136
#include<iostream>
using namespace std;
#define N 60000
int main()
{
    int a[N]={0},n,i,j,z;
    for(i=2;i<=N/2;i++){
	if(a[i]==0){
	    for(j=2;j*i<=N;j++){
		a[i*j]=1;	     
    	    }
	}
    }
    while((cin>>n)!=0){
    	for(i=n-1;i>1;i--){
	    if(a[i]==0){
		cout<<i<<' ';
		break;		
	    }
	}
	
    	for(i=n+1;i<=N;i++){
	    if(a[i]==0){
		cout<<i<<endl;
		break;		
	    }
	}
    }
    return 0;	
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <unordered_set>
#include <stack>
#include <iterator>
#include <random>
#include <fstream>
#include <chrono>
using namespace std;
#define int long long
int inv(int x){
    if(x==1)
        return 2;
    else
        return 1;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int X,Y,A,B,C;
    cin >> X >> Y >> A >> B >> C;
    vector<int>p(A);vector<int>q(B);vector<int>r(C);
    for(int i = 0; i < A; i++) cin >> p[i];
    for(int i = 0; i < B; i++) cin >> q[i];
    for(int i = 0; i < C; i++) cin >> r[i];
    sort(p.rbegin(),p.rend());
    sort(q.rbegin(),q.rend());
    vector<int>l;
    for(int i = 0; i < X; i++)
        r.push_back(p[i]);
    for(int i = 0; i < Y; i++)
        r.push_back(q[i]);
    sort(r.rbegin(),r.rend());
    int ans = 0;
    for(int i = 0; i < (X+Y); ++i){
        ans += r[i];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 6000
import math


N = int(input())

nn = int(math.sqrt(N))
# nn = int(N / 2)

ans = 1
for x in range(2,nn+1):

    if N % x == 1:
        ans += 1
        continue
    
    if N % x > 1:
        continue

    tmp = N
    while tmp > x:
        tmp = tmp / x
        if tmp % x == 1 :
            ans += 1
            break
        elif tmp % x > 1 :
            break
        elif tmp == x:
            ans += 1
            break

x = 1
tmp = N - 1
while tmp / x  > nn:
    if tmp % x == 0:
        ans += 1
    x += 1

print(ans)


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


#define P pair<ll, ll>
const int N_MAX = pow(10,5)+10;
struct edge { ll to; ll cost; };
vector<edge> adj[N_MAX], radj[N_MAX];

ll d[N_MAX];
ll N, M, T;

void dijkstra(ll s) {
  priority_queue<P, vector<P>, greater<P>> q;
  fill_n(d, N, LLINF); d[s] = 0; q.push(P(0, s));
  while (!q.empty()) {
    P p = q.top(); q.pop();
    ll v = p.second;
    if (d[v] < p.first) continue;
    for (auto e: adj[v]) {
      if (d[e.to] > d[v]+e.cost) {
        d[e.to] = d[v]+e.cost;
        q.push(P(d[e.to], e.to));
      }
    }
  }
}

int main() {
  cin >> N >> M;
  rep(i,M) {
    int L, R, C; cin >> L >> R >> C; L--; R--;
    edge tmp = {R, C};
    adj[L].push_back(tmp);
  }
  rep(i,N-1) adj[i+1].push_back((edge){i, 0});
  dijkstra(0);
  ll result = (d[N-1]!=LLINF) ? d[N-1] : -1;
  // rep(i,N) cout << d[i] << " "; cout << endl;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 11772
#include<stdio.h>

int main()
{
    int N, H, W, i, tmp1, tmp2;
    int count = 0;
    fscanf(stdin, "%d %d %d", &N, &H, &W);
    for(i = 0; i < N; i++){
        fscanf(stdin, "%d %d", &tmp1, &tmp2);
        if( (H <= tmp1) && (W <= tmp2))
            count++;
    }

    fprintf(stdout, "%d\n", count);

    return 0;
}

Measured memory_bytes: 128
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) >= 0 ? (a) : (-(a)))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) > *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static size_t countDivisors(const size_t n)
{
	size_t count = 1;

	for (size_t i = 2; i <= n; i++) {
		if (n%i == 0) {
			count++;
		}
	}

	return count;
}

static int32_t x[100000];

int main(void) {
	size_t N, K;

	scanf("%zu %zu\n", &N, &K);
	for (size_t idx = 0; idx < N; idx++) {
		scanf("%"PRId32, &x[idx]);
		if (idx < N - 1) {
			scanf(" ");
		}
	}

	size_t minTime = (size_t)UINT32_MAX;

	for (size_t beginIdx = 0; beginIdx <= N - K; beginIdx++) {
		const size_t endIdx = beginIdx + K - 1;
#if 0
		{
			const size_t timeCost = ABSS(x[beginIdx], x[endIdx]) + ABS(x[beginIdx]);
			if (timeCost < minTime) {
				minTime = timeCost;
			}
		}
		{
			const size_t timeCost = ABSS(x[beginIdx], x[endIdx]) + ABS(x[endIdx]);
			if (timeCost < minTime) {
				minTime = timeCost;
			}
		}
#endif
		if ((int64_t)(x[beginIdx]) * (int64_t)(x[endIdx]) < 0) {
			{
				const size_t timeCost = 2 * (size_t)ABS(x[beginIdx]) + (size_t)ABS(x[endIdx]);
				if (timeCost < minTime) {
					minTime = timeCost;
				}
			}
			{
				const size_t timeCost = (size_t)ABS(x[beginIdx]) + 2 * (size_t)ABS(x[endIdx]);
				if (timeCost < minTime) {
					minTime = timeCost;
				}
			}
		}
		else if (beginIdx == 0 && 0 <= x[beginIdx]) {
			const size_t timeCost = (size_t)ABS(x[endIdx]);
			if (timeCost < minTime) {
				minTime = timeCost;
			}
		}
		else if (endIdx == N - 1 && x[endIdx] <= 0) {
			const size_t timeCost = (size_t)ABS(x[beginIdx]);
			if (timeCost < minTime) {
				minTime = timeCost;
			}
		}
	}

	printf("%zu\n", minTime);

	return 0;
}

Measured memory_bytes: 512
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 2e9;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = a * c;
	ans = max(ans, a * d);
	ans = max(ans, b * d);
	ans = max(ans, b * c );
	cout << ans << '\n';
	
}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}


Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>
#include <fstream>
using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
const double pi = 3.14159265359;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> b(N-1),a(N);
    for (int i = 0; i < N-1; ++i) {
        cin >> b[i];
    }
    a[0] = b[0];
    int ans = b[0];
    a[N - 1] = b[N - 2];
    ans += b[N - 2];
    for (int i = 1; i < N-1; ++i) {
        a[i] = min(b[i - 1], b[i]);
        ans += min(b[i - 1], b[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> pi;
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair





main(){
  int n;
  while(cin>>n,n){
    set<int> tuukou;
    priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > intime,outtime;//time,hito
    int weight[n];
    rep(i,n){
      int m,a,b;
      cin>>m>>a>>b;
      weight[i]=m;
      intime.push(mp(a,i));
      outtime.push(mp(b,i));
    }
    int br=0;
    int time,hito;
    while(!outtime.empty()){
      if(intime.empty() || outtime.top().first<=intime.top().first){
        time=outtime.top().first,hito=outtime.top().second;
        outtime.pop();

        br-=weight[hito];
      }else{
        time=intime.top().first,hito=intime.top().second;
        intime.pop();
        br+=weight[hito];
      }
      //cout<<br<<" "<<time<<endl;
      if(br>150)break;
    }
    if(br>150)cout<<"NG"<<endl;
    else cout<<"OK"<<endl;
  }
}

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

int main()
{
	string s;
	cin>>s;
	int l=0;
	int r=0;
	string str;
	while(r<=s.length()){
		if(str.length()<2){
			str.push_back(s[r]);
			r++;
		}
		else if(str.length()>2){
			str.erase(0,1);
			l++;
		}
		else if(str.length()==2){
			if(str=="ST"){
				s.erase(l,2);
				str.erase(0);
				if(l>0) l--;
				r=l;
			}
			else{
				str.push_back(s[r]);
				r++;
			}
		}
	}
	cout<<s.length();
	return 0;
}

Measured memory_bytes: 1336
main = getLine >>= putStrLn . solve . map read . words

solve :: [Int] -> String
solve (w:h:x:y:r:[])
    | (x + r) <= w && (x - r) >=0 &&
      (y + r) <= h && (y - r) >=0 = "Yes"
    | otherwise = "No"


Measured memory_bytes: 3664
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = 1ll << 60;


vector<ll> dijkstra(const vector<vector<ll>>& d, int st, const ll LIM) {
    const int N = d.size();
    vector<ll> res(N, INF);
    priority_queue<pll, vector<pll>, greater<pll>> pq;
    res[st] = 0;
    pq.push({ 0,st });

    while (!pq.empty()) {
        ll pos, score;
        tie(score, pos) = pq.top(); pq.pop();
        rep(npos, N) {
            if (d[pos][npos] > LIM)continue;
            if (res[pos] + 1 >= res[npos])continue;
            res[npos] = res[pos] + 1;
            pq.push({ res[npos],npos });
        }
    }

    return res;
}

int main()
{
    ll N, M, L;
    cin >> N >> M >> L;
    vector<vector<ll>> d(N, vector<ll>(N, INF)), min_times(N);
    rep(i, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        d[a][b] = d[b][a] = c;
    }
    // warshall froid
    rep(k, N)rep(i, N)rep(j, N)d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

    rep(i, N)min_times[i] = dijkstra(d, i, L);

    ll Q;
    cin >> Q;
    while (Q--) {
        ll s, t;
        cin >> s >> t;
        s--; t--;
        ll res = min_times[s][t];
        cout << (res == INF ? -1 : res - 1) << endl;
    }
    return 0;
}


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

int main(){
  int a;
  int b=0;
  for(int i; i<5; i++){
    cin>>a;
    a=a/5;
      if(a<8){
	a=8;
	}
    b=b+a;
    
      }
  cout<<b<<endl;
}
  
  

Measured memory_bytes: 1164
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
vint adj[100001];
int p[100001];
bool visited[100001]={};
vint edgedepth[100001];
int depthmax=0;
map<pint,bool> usededge;
void dfs(int u,int depth){
	visited[u]=1;
	edgedepth[depth].push_back(u);
	depthmax=max(depthmax,depth);
	int flag=0;
	rep(i,adj[u].size()){
		int v=adj[u][i];
		if(visited[v]==0){
			flag=1;
			p[v]=u;
			usededge[{u,v}]=1;
			usededge[{v,u}]=1;
			dfs(v,depth+1);
		}
	}
}
int main(){
	int N;
	ll A[100001];
	scan(N);
	rep(i,N) scan(A[i]);
	rep(i,N-1){
		int a,b;
		scan(a>>b);
		a--; b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	if(N==2){
		if(A[0]==A[1]) prin("YES");
		else prin("NO");
		return 0;
	}
	int root;
	rep(i,N){
		if(adj[i].size()>1){
			root=i;
			break;
		}
	}
	dfs(root,0);
	ll kosum[100001],komax[100001]={};
	fill(kosum,kosum+N,-1);
	for(int d=depthmax;d>=1;d--){
		rep(i,edgedepth[d].size()){
			int u=edgedepth[d][i];
			int v=p[u];
			ll nextA;
			if(kosum[u]==-1){
				nextA=A[u];
			}
			else{
				if(kosum[u]<=2*A[u]&&A[u]<=kosum[u]){
					nextA=2*A[u]-kosum[u];
					if(komax[u]>A[u]){
						prin("NO");
						return 0;
					}
				}
				else{
					//printf("u:%d v:%d kosum[u]:%lld A[u]:%lld\n",u+1,v+1,kosum[u],A[u]);
					prin("NO");
					return 0;
				}
			}
			if(kosum[v]==-1) kosum[v]=nextA;
			else kosum[v]+=nextA;
			komax[v]=max(komax[v],nextA);
			//printf("u:%d v:%d kosum[v]-> %lld\n",u+1,v+1,kosum[v]);
		}
	}
	if(2*A[root]==kosum[root]&&komax[root]<=A[root]) prin("YES");
	else prin("NO");
	return 0;
}


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

const int N=100010;
int n,c[N];

int main() {
	scanf("%d%d",&n,&c[0]);
	for(int i=1;i<=n;i++) {
		scanf("%d",&c[i]);
	}
	sort(c,c+n+1);
	int ans=0;
	for(int i=0;i<n;i++) {
		ans=__gcd(ans,c[i+1]-c[i]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
import kotlin.math.min

fun main() {
    val builder = StringBuilder()

    val (n, m, x) = readInputLine().split(" ").map { it.toInt() }

    val books = Array(n) {
        val input = readInputLine().split(" ").map { it.toInt() }
        Pair(input[0], input.drop(1).toIntArray())
    }

    var ans = Int.MAX_VALUE

    for (i in 0 until (1 shl n)) {
        val tmp = IntArray(m)
        var cost = 0
        for (j in 0 until n) {
            if ((i shr j) and 1 == 1) {
                cost += books[j].first
                for ((index, a) in books[j].second.withIndex()) {
                    tmp[index] += a
                }
            }
        }

        if (tmp.all { it >= x }) {
            ans = min(ans, cost)
        }
    }


    builder.appendln(if (ans == Int.MAX_VALUE) -1 else ans)

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 38548
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

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

  if (D == 0) {
    if (N==100) cout << 101 << endl;
    else cout << N << endl;
  } else if (D == 1) {
    if (N==100) cout << 10100 << endl;
    else cout << N*100 << endl;
  } else {
    if (N==100) cout << 1010000 << endl;
    else cout << N*10000 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	ll n,sum =0,b,f;cin >> n;
	vector<ll> a(n + 1,0);
	rep(i, n + 1)cin >> a[i];
	rep(i, n) {
		cin >> b;
		sum  += min(a[i], b);
		b -= min(a[i], b);
		sum += min(a[i + 1], b);
		a[i + 1] -= min(a[i + 1], b);
	}
	cout << sum << endl;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	string s;
	cin >> s;

	int c = 0;
	int res = 0;

	for (int i = 0; i < s.length(); i++)
	{
		string x = s.substr(i, 1);
		if (x == "A" || x == "C" || x == "G" || x == "T")
		{
			c++;
		}
		else
		{
			res = max(res, c);
			c = 0;
		}
	}

	res = max(res, c);

	println(res);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;


int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	
	if(c <= b / a) {
		cout << c << endl;
	}
	else {
		cout << b / a << endl;
	}
	
    return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/22  Problem: ABC 055 C / Link: http://abc055.contest.atcoder.jp/tasks/abc055_c  ----- */


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

	LL S, C; cin >> S >> C;
	LL ans = 0LL;

	LL scc = min(S, C / 2);
	ans += scc;
	S -= scc;
	C -= 2 * scc;
	if (C) {
		ans += C / 4;
	}
	
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 380
import java.util.*
import kotlin.math.min

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    data class Line(var to: Int, val c: Int, val d: Int)

    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val M = sc.next().toInt()
        val S = sc.next().toInt()
        val edge = Array(N) { mutableListOf<Line>() }
        repeat(M) {
            val U = sc.next().toInt() - 1
            val V = sc.next().toInt() - 1
            val A = sc.next().toInt()
            val B = sc.next().toInt()
            edge[U].add(Line(V, A, B))
            edge[V].add(Line(U, A, B))
        }
        val edge2 = Array(N) { Array(2500) { mutableListOf<Line>() } }
        repeat(N) { i ->
            val C = sc.next().toInt()
            val D = sc.next().toInt()
            repeat(2500) { c ->
                edge2[i][c].add(Line(i, min(c + C, 2499), D))
                edge[i].forEach {
                    if (c >= it.c) {
                        edge2[i][c].add(Line(it.to, c - it.c, it.d))
                    }
                }
            }
        }

        val pq = PriorityQueue<Triple<Long, Int, Int>>(100) { x, y ->
            return@PriorityQueue if (y.first < x.first) 1 else -1
        }
        val dist = Array(N) { LongArray(2500) { Long.MAX_VALUE } }
        dist[0][min(S, 2499)] = 0L
        pq.add(Triple(0L, 0, min(S, 2499))) // dist, idx, coin
        while (pq.isNotEmpty()) {
            val tmp = pq.first(); pq.remove(tmp)
            val d = tmp.first
            val from = tmp.second
            val c = tmp.third
            if (dist[from][c] < d) continue
            for (line in edge2[from][c]) {
                if (dist[line.to][line.c] > dist[from][c] + line.d) {
                    dist[line.to][line.c] = dist[from][c] + line.d
                    pq.add(Triple(dist[line.to][line.c], line.to, line.c))
                }
            }
        }

        for (i in 1 until N) {
            pw.println(dist[i].min())
        }
    }
}


Measured memory_bytes: 92248
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
#include<cstring>
#define pa pair<int,int>
#define mp make_pair
using namespace std;
inline int read(){int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f;}
const int maxn=200005;
struct edge{
	int link,next;
}e[maxn];
int head[maxn],tot,m,n; 
inline void insert(int u,int v){
	e[++tot]=(edge){v,head[u]};
	head[u]=tot;
}
inline void init(){
	n=read(); m=read();
	for (int i=1;i<=m;i++){
		int u=read(),v=read();
		insert(u,v);
	}
}
int dis[maxn];
bool vis[maxn];
priority_queue<pa, vector<pa>, greater<pa> > heap; 
inline void solve(){
	memset(dis,127/3,sizeof(dis));
	dis[1]=0; heap.push(mp(0,1));
	while (!heap.empty()){
		int u=heap.top().second; heap.pop();
		if (vis[u]) continue;
		vis[u]=1;
		for (int i=head[u];i;i=e[i].next){
			int v=e[i].link;
			if (dis[v]>dis[u]+1){
				dis[v]=dis[u]+1;
				if (!vis[v]){
					heap.push(mp(dis[v],v));
				}
			}
		}
	}
	if (dis[n]==2) puts("POSSIBLE");
		else puts("IMPOSSIBLE");
}
int main(){
	init();
	solve();
	return 0;
} 

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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"
#define all(x) x.begin(),x.end()
#define sz(x) x.size()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int h,w;
vector<string> v;
int sx,sy,dx,dy;
int dis[1005][1005];
const int INF=1e9;

int using_dijkstra(){
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)dis[i][j]=INF;
    }
    dis[sx][sy]=0;
    priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>> pq;
    auto legal=[&](int r,int c)->bool{
        if(r<0 || c<0 || r>=h || c>=w || v[r][c]=='#')return 0;
        return 1;
    };
    pq.push({0,{sx,sy}});
    while(sz(pq)){
        int x=pq.top().second.first;
        int y=pq.top().second.second;
        pq.pop();
        for(pair<int,int> P:vector<pair<int,int>>({{x,y+1},{x,y-1},{x+1,y},{x-1,y}})){
            if(legal(P.first,P.second)){
                if(dis[x][y]<dis[P.first][P.second]){
                    dis[P.first][P.second]=dis[x][y];
                    pq.push({dis[P.first][P.second],{P.first,P.second}});
                }
            }
        }
        for(int i=x-2;i<=x+2;i++){
            for(int j=y-2;j<=y+2;j++){
                if(legal(i,j)){
                    if(dis[x][y]+1<dis[i][j]){
                        dis[i][j]=dis[x][y]+1;
                        pq.push({dis[i][j],{i,j}});
                    }
                }
            }
        }
    }
    return dis[dx][dy]==INF?-1:dis[dx][dy];
}

int using_01Bfs(){
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)dis[i][j]=INF;
    dis[sx][sy]=0;
    deque<pair<int,int>> dq;
    dq.push_front({sx,sy});
    auto legal=[&](int r,int c)->bool{
        if(r<0 || c<0 || r>=h || c>=w || v[r][c]=='#')return 0;
        return 1;
    };
    while(dq.size()){
        int x=dq.front().first;
        int y=dq.front().second;
        dq.pop_front();
        for(pair<int,int> P:vector<pair<int,int>>({{x,y+1},{x,y-1},{x+1,y},{x-1,y}})){
            if(legal(P.first,P.second)){
                if(dis[x][y]<dis[P.first][P.second]){
                    dis[P.first][P.second]=dis[x][y];
                    dq.push_front({P.first,P.second});
                }
            }
        }
        for(int i=x-2;i<=x+2;i++){
            for(int j=y-2;j<=y+2;j++){
                if(legal(i,j)){
                    if(dis[x][y]+1<dis[i][j]){
                        dis[i][j]=dis[x][y]+1;
                        dq.push_back({i,j});
                    }
                }
            }
        }
    }
    return dis[dx][dy]==INF?-1:dis[dx][dy];
}
void solve()
{
    cin>>h>>w;
    cin>>sx>>sy>>dx>>dy;
    --sx;--sy;--dx;--dy;
    v.resize(h);
    for(auto &x:v)cin>>x;
    // cout<<using_dijkstra()<<"\n";
    cout<<using_01Bfs()<<"\n";
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  if(N>=1 && N<=999){
    cout << "ABC";
  }
  else if(N>=1000 && N<=1998){
    cout << "ABD";
  }
  cout << endl;
  return 0;
}

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

int main() {
  int n;
  cin>>n;
  int ans=0;
  if(n%2==0) ans=n/2;
  if(n%2==1) ans=n/2+1;
  cout<<ans<<endl;


}


Measured memory_bytes: 256
# coding: utf-8
N, M, X = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(N)]
n = len(C)
m = -1
for i in range(2 ** n):
    A = [0 for i in range(M+1)]
    total = 0
    for j in range(n):
        if((i >> j) & 1):
            A = [a + b for a, b in zip(A, C[j])]
            B = [k for k in range(1, M+1) if A[k] < X]
            if len(B) == 0:
                if m == -1:
                    m = A[0]
                else:
                    m = min(m, A[0])
                break
print(m)



Measured memory_bytes: 9140
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    int a,b,sum;
    cin>>a>>b;
    sum=(a-b*2);
    if(sum<=0)
    {
        cout<<"0"<<endl;
    }
    else
    cout<<sum<<endl;

    return 0;

}


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

using namespace std;

int main()
{
  int n;
  cin >> n  ;
  int a[n];  
  for(int i=0;i<n;i++)cin >> a[i] ;
  
  sort(a,a+n,greater<int>()) ; //decreasing
  int count = 1;
  for(int i=1;i<n;++i){
    if(a[i]==a[i-1])
      continue;
    else
      ++count;
  }
   cout << count << "\n" ;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

template <class... Args>
struct tuple_input_impl;
template <std::size_t i, std::size_t... tail>
struct tuple_input_impl<std::index_sequence<i, tail...>>
{
    template <class... Args>
    static void f(std::tuple<Args...>& x)
    {
        std::cin >> std::get<i>(x);
        tuple_input_impl<std::index_sequence<tail...>>::f(x);
    }
};
template <>
struct tuple_input_impl<std::index_sequence<>>
{
    static void f(...) {}
};

template <class... Args>
std::istream& operator>>(std::istream& in, std::tuple<Args...>& x)
{
    tuple_input_impl<std::index_sequence_for<Args...>>::f(x);
    return in;
}
template <class T1, class T2>
std::istream& operator>>(std::istream& in, std::pair<T1, T2>& x) { return in >> x.first >> x.second; }

template <class T>
T read()
{
    T res;
    std::cin >> res;
    return res;
}
template <class T>
std::vector<T> read(std::size_t n)
{
    std::vector<T> res(n);
    for (std::size_t i = 0; i < n; ++i) std::cin >> res[i];
    return res;
}

template <class T>
void out_impl(T&& v) { std::cout << std::forward<T>(v); }
template <class T, class... Args>
void out_impl(T&& v, Args&&... args)
{
    std::cout << std::forward<T>(v) << ' ';
    out_impl(std::forward<Args>(args)...);
}
template <class... Args>
void out(Args&&... args)
{
    out_impl(std::forward<Args>(args)...);
    std::cout << '\n';
}
template <class... Args>
void out_noreturn(Args&&... args) { out_impl(std::forward<Args>(args)...); }

template <class T>
void print(const T& container)
{
    bool first = true;
    for (auto&& x : container) {
        if (!first) std::cout << ' ';
        std::cout << x;
        first = false;
    }
    std::cout << '\n';
}

void prog()
{
    int a, b;
    std::cin >> a >> b;
    if (a <= 5) {
        out(0);
    } else if (a <= 12) {
        out(b / 2);
    } else {
        out(b);
    }
}

int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    prog();
    return 0;
}


Measured memory_bytes: 256
INF = float("inf")

n, m, x = map(int, input().split())
c, a = [0] * n, [None] * n
for i in range(n):
    c[i], *a[i] = map(int, input().split())
ans = INF

for bit in range(2 ** n):
    s = [0] * m
    cost = 0
    for i in range(n):
        if bit >> i & 1:
            cost += c[i]
            for j in range(m):    
                s[j] += a[i][j]
    if min(s) >= x:
        ans = min(cost, ans)

print(-1 if ans == INF else ans)


Measured memory_bytes: 9168
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
using edge = struct{int to; ll cost;};
vector<edge> graph[110000];
ll depth[110000];

void dfs(int v, int p, ll d){
    depth[v] = d;
    for(auto &e : graph[v]){
        if(e.to == p) continue;
        dfs(e.to, v, d+e.cost);
    }
    
}

int main(){
    int N;
    cin >> N;
    for(int i=0; i<N-1; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        graph[a].push_back({b,c});
        graph[b].push_back({a,c});
    }
    int q, k;
    cin >> q >> k;
    k--;

    dfs(k, -1, 0);

    for(int i=0; i<q; i++){
        int x,y;
        cin >> x >> y;
        x--, y--;
        cout << depth[x] + depth[y] << endl;
    }
    
    return 0;
}

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

int main()
{
  int N,T ;
  cin>>N>>T ;
  vector<pair<int,int>>course ;
  for(int i=0;i<N;i++){
    int cost,time ;
    cin>>cost>>time ;
    course.push_back(make_pair(cost,time)) ;
  }
  
  sort(course.begin(),course.end()) ;
  for(int i=0;i<N;i++){
    if(course.at(i).second<=T){
      cout<<course.at(i).first<<endl ;
      return 0 ;
    }
  }
  cout<<"TLE"<<endl ;
  
  return 0 ;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char s[11];

  // スペース区切りの整数の入力
    scanf("%s",s);
    switch(s[0]){
      case 'A':
	  printf("T");
        break;
      case 'T':
	  printf("A");
        break;
      case 'C':
	  printf("G");
        break;
      case 'G':
	  printf("C");
        break;
        }
  
    return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int64_t n, h;
  cin >> n >> h;
  vector<int64_t> a(n), b(n);
  int64_t amax = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
    amax = max(amax, a[i]);
  }

  sort(b.rbegin(), b.rend());
  int bmin;
  for (bmin = 0; bmin < n; ++bmin) {
    if (b[bmin] <= amax) {
      break;
    }
  }

  int64_t ans = 0;
  int64_t hp = h;
  for (int i = 0; 0 < hp && i < bmin; ++i) {
    ++ans;
    hp -= b[i];
  }
  if (0 < hp) {
    ans += (hp + amax - 1) / amax;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<sstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int>PII;
typedef pair<ll,ll>PLL;
#define make_pair mkp;


const int maxn=2e5+10;
ll dist[maxn];
int a[maxn];

int main(){
	memset(dist,0,sizeof(dist));
	int k,n;
	cin>>k>>n;
	//ll ans=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	//ll res=0;
	dist[0]=min(a[n-1]-a[0],a[0]+k-a[1]);
	dist[n-1]=min(a[n-1]-a[0],a[n-2]+k-a[n-1]);
	for(int i=1;i<n-1;i++){
		dist[i]=min(a[i-1]+k-a[i],a[i]+k-a[i+1]);
	}
	ll ans=1e15;
	for(int i=0;i<n;i++){
		ans=min(ans,dist[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cstdlib>
using namespace std;
int main() {
	int a, b, c, d, e,time=0;
	cin >> a>>b >> c >> d >> e;
	if (a < 0) {
		time += (0 - a)*c;
		time += d;
		time += b*e;
	}
	else {
		time += (b-a)*e;
	}
	cout << time << endl;
	return 0;
}

Measured memory_bytes: 3072