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

class Program
{
	static void Main(string[] args)
	{
		int n = 1;
		int N = int.Parse(Console.ReadLine());
		int K = int.Parse(Console.ReadLine());
		for (int i = 0; i < N; i++)
		{
			n = Math.Min(n * 2, n + K);
		}
		Console.WriteLine(n);
	}
}

Measured memory_bytes: 11092
n = gets.strip.to_i

result = []

if n.zero?
  p 0
  exit
end

if n.odd?
  result.unshift 1
  n -= 1
else
  result.unshift 0
end


until n==1 || n==-1
  n = -1 * (n / 2)
  if (n%2).zero?
    result.unshift(0)
  else
    result.unshift(1)
  end
#  p [n, result]
end

result.unshift(1) if n==-1

puts result.join('')



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

int main() {
  int n;
  cin >> n;
  vector<int> primes;
  {
    vector<bool> is_prime(n + 1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++) {
      if (is_prime[i]) {
        primes.push_back(i);
        for (int j = 2 * i; j <= n; j += i) {
          is_prime[j] = false;
        }
      }
    }
  }
  for (auto e : primes) cerr << e << " ";
  cerr << endl;

  vector<int> f(n + 1);
  for (int i = 1; i <= n; i++) {
    int t = i;
    for (auto e : primes) {
      for (; t % e == 0; t /= e) {
        f[e]++;
      }
    }
  }
  vector<int> s(accumulate(begin(f), end(f), 74, [](int a, int b) { return max(a, b); }) + 1);
  for (auto e : f) {
    s[e]++;
  }
  for (int i = s.size() - 1; i > 0; i--) {
    s[i - 1] += s[i];
  }

  int r = s[74];
  if (s[24] >= 1) r += s[24] * (s[2] - 1);
  if (s[14] >= 1) r += s[14] * (s[4] - 1);
  if (s[4] >= 2) r += s[4] * (s[4] - 1) / 2 * (s[2] - 2);
  cout << r << endl;
}


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

int main() {
  string S;
  cin>>S;
  
  bool accept1=false;
  bool accept2=false;
  bool accept3=false;
  
  if(S[0]=='A')
    accept1=true;
  
  int count=0;
  for(int i=2;i<S.size()-1;++i){
    if(S[i]=='C')
      ++count;
  }
  
  if(count==1)
    accept2=true;
  
  int cnt=0;
  for(int i=0;i<S.size();++i){
    if(S[i]>='A' && S[i]<='Z')
      ++cnt;
  }
  
  if(cnt==2)
    accept3=true;
  
  if(accept1 && accept2 && accept3)
    cout<<"AC"<<endl;
  else
    cout<<"WA"<<endl;
}


Measured memory_bytes: 256
class DisjointSet:
    def __init__(self):
        self.rank = {}
        self.p = {}

    def makeSet(self, x):
        self.p[x] = x
        self.rank[x] = 0

    def same(self, x, y):
        return self.findSet(x) == self.findSet(y)

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if(self.rank[x] > self.rank[y]):
            self.p[y] = x
        else:
            self.p[x] = y
            if(self.rank[x] == self.rank[y]):
                self.rank[y] += 1

    def findSet(self, x):
        if(x != self.p[x]):
            self.p[x] = self.findSet(self.p[x])
        return self.p[x]

H, W = map(int, input().split())
S = [list(input()) for i in range(H)]

ds = DisjointSet()
for i in range(H):
    for j in range(W):
        ds.makeSet((i,j))

for i in range(H):
    for j in range(W):
        if i + 1 < H and S[i][j] != S[i+1][j]:
            ds.unite((i,j), (i+1, j))
        if 0 <= i - 1 and S[i][j] != S[i-1][j]:
            ds.unite((i,j), (i-1, j))
        if j + 1 < W and S[i][j] != S[i][j+1]:
            ds.unite((i,j), (i, j+1))
        if 0 <= j - 1 and S[i][j] != S[i][j-1]:
            ds.unite((i,j), (i, j-1))

from collections import defaultdict

c1 = defaultdict(int)
c2 = defaultdict(int)

for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            c1[ds.findSet((i,j))] += 1
        else:
            c2[ds.findSet((i,j))] += 1
ans = 0
for i in c1.keys():
    ans += c1[i] * c2[i]
print(ans)

Measured memory_bytes: 126932
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ll long long
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
#define BIT_FLAG_1 (1<<1) // 0000 0000 0000 0010
#define BIT_FLAG_2 (1<<2) // 0000 0000 0000 0100
#define BIT_FLAG_3 (1<<3) // 0000 0000 0000 1000
#define BIT_FLAG_4 (1<<4) // 0000 0000 0001 0000
#define BIT_FLAG_5 (1<<5) // 0000 0000 0010 0000
#define BIT_FLAG_6 (1<<6) // 0000 0000 0100 0000
#define BIT_FLAG_7 (1<<7) // 0000 0000 1000 0000

int main(){
    double a,b,c,d;
    cin >> a >> b >> c >> d;
    string ans;
    while(1){
        c-=b;
        if(c<=0){
            ans="Yes";
            break;
        }
        a-=d;
        if(a<=0){
            ans="No";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long ll;
using namespace std;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


//ここからが回答　二次元配列を用意して片方に「ワンチャンLを超えるa,bの組み合わせ」,
//もう片方に「条件内でどうあがいてもLを超えることはないa,bの組み合わせ」を入れていく
//桁dpで考える

int main(void){
    string l;cin>>l;
    mint dp[2][l.size()+1];
    rep(i,2)rep(j,l.size()+1) dp[i][j]=(mint)0;
    dp[0][0]=1;
    dp[1][0]=0;
    rep(i,l.size()){
        char now=l[i];
        if(now=='1'){
            dp[0][i+1]+=dp[0][i]*2;//{a,b}={1,0},{0,1}
            dp[1][i+1]+=dp[0][i];//{a,b}={0,0}
        }else{
            dp[0][i+1]+=dp[0][i];//{a,b}={0,0}
        }
        dp[1][i+1]+=dp[1][i]*3;//{a,b}={0,0},{1,0},{0,1}
    }
    mint res=dp[0][l.size()]+dp[1][l.size()];
    
    cout<<res.x<<endl;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
typedef long long ll;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> fak;
  fak.push_back(1);
  for (ll i = 2; i * i <= m; i++) {
    if (m % i == 0) {
      fak.push_back(i);
      if (i * i != m) {
        fak.push_back(m / i);
      }
    }
  }
  fak.push_back(m);
  sort(fak.begin(), fak.end());
  int lo = 0, hi = fak.size()-1, mid, best = -1;
  while (lo <= hi) {
    mid = (lo + hi) / 2;
    if (fak[mid] < n ) lo = mid + 1;
    else {
      best = mid;
      hi = mid - 1;
    }
  }
  cout << m / fak[best] << el;
  return 0;
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).ok();
    let mut iter = line.split_whitespace().map(|d| d.parse::<usize>().unwrap());
    let n = iter.next().unwrap();
    let m = iter.next().unwrap();

    let mut mat_a = Vec::new();
    for _ in 0..n {
        let mut line = String::new();
        io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace().map(|d| d.parse::<i32>().unwrap());
        for _ in 0..m {
            let a = iter.next().unwrap();
            mat_a.push(a);
        }
    }

    let mut vec_b = Vec::new();
    for _ in 0..m {
        let mut line = String::new();
        io::stdin().read_line(&mut line).unwrap();
        let b = line.trim().parse::<i32>().unwrap();
        vec_b.push(b);
    }

    let vec_c = mat_a.chunks(m).map(|v| v.iter().zip(&vec_b).map(|(a, b)| a * b).sum::<i32>());

    for c in vec_c {
        println!("{}", c);
    }
}



Measured memory_bytes: 5036
a,b,k = map(int, input().split())
cnt=0
while True:
  if a%2==1:
    a-=1
  half=a//2
  a-=half
  b+=half
  cnt+=1
  if cnt==k:
    break
  if b%2==1:
    b-=1
  half=b//2
  b-=half
  a+=half
  cnt+=1
  if cnt==k:
    break  
print(a,b)


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

int main(){
    int w, a, b;
    cin >> w >> a >> b;
    if(b <= a+w && a <= b+w) cout << 0 << endl;
    else{
        cout << max(b-a-w, a-b-w) << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int n;
  string s;
  cin>>n>>s;
  int sum=0;
  string head="";
  string end="";
  for(int i=0;i<n;i++){
    if(s[i]=='('){
      sum+=1;
    }
    if(s[i]==')'){
      sum-=1;
    }
    if(sum<0){
      head+='(';
      sum+=1;
    }
  }
  while(sum>0){
    end+=')';
    sum-=1;
  }
  cout<<head<<s<<end<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String arg[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.nextLine();
		String str = sc.nextLine();
		sc.close();
		String[]S = str.split(" "); 
		int[] n = new int[N];
		int count = 0;
		
		for(int i = 0; i < N; i++) {
			n[i] = Integer.valueOf(S[i]);
		}
		while(true) {
			for ( int j = 0; j< n.length; j++) {
				if(n[j] % 2 == 0) {
					n[j]= n[j]/2;
				}else {
					System.out.println(count);
					System.exit(0);
				}
			}
			count++;
		}
	}
}

Measured memory_bytes: 21972
from math import *

N = int(input())
X = list(map(int, input().split()))

sum = 0
for i in range(len(X)):
    sum += X[i]

ave = int(round(sum / len(X), 0))

ans = 0
for i in range(len(X)):
    ans += int(pow(X[i] - ave, 2))

print(ans)

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

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

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

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

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

int main(int argc, char const *argv[]) {
    ll n,k,q; cin>>n>>k>>q;
    vector<ll> a(q);
    vector<ll> p(n);
    rep(i,q) {
        cin>>a[i];
        --a[i];
        p[a[i]]++;
    }

    vector<ll> ans(n,k);
    rep(i,n) {
        ans[i] -= q;
        ans[i] += p[i];
    }

    int ret = 0;
    rep(i,n) {
        if (ans[i]>0) cout << "Yes" << '\n';
        else cout << "No" << '\n';
    }

    return 0;
}

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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;

int main() {
	int a[5], i, j, k;

	rep(i,5) {
		cin >> a[i];
	}
	k = 0;
	j = a[0] % 10;
	repj(i,1, 5) {
		if (a[i] % 10 != 0 && a[i] % 10 < j) {
			k = i;
			j = a[i] % 10;
		}
	}

	j = 0;
	rep(i, 5) {
		if (i == k) {
			j += a[i];
		}
		else {
			if (a[i] % 10 == 0)j += a[i];
			else {
				j += (a[i] / 10 + 1) * 10;
			}
		}
	}

	cout << j;

	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
p = gets.chomp.split(" ").map(&:to_i)

ans = 0
for i in 0..n-3
  if (p[i] < p[i+1] && p[i+1] < p[i+2] ) || (p[i] > p[i+1] && p[i+1] > p[i+2])
     ans += 1
   end
 end
 puts ans

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

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

    int mat[10][10] = {0};
    for(int i = 1; i <= n; i++){
        string s = to_string(i);
        mat[s[0]-'0'][s.back()-'0']++;
    }

    int ans = 0;
    for(int i = 0; i <= 9; i++){
        for(int j = 0; j <= 9; j++){
            ans += mat[i][j] * mat[j][i];
        }
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
//============================================================================
// Name        : abc141_c.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

// K から自分以外が正解した回数を引いて 0 以下なら No
// <=> K - (解答できなかった回数) <= 0 なら No
// <=> K - (Q - 解答できた回数) <= 0 なら No
// <=> K - Q + (解答できた回数) <= 0 なら No
int main() {
	int N, K, Q;
	cin >> N >> K >> Q;
	int count[N + 1] = {0}; // count[0] は使わない, count[1]~count[N] を使う
	int A[Q + 1] = {0}; // A[0] は使わない, A[1]~A[i]~A[Q] を使う
	// 解答者の入力 -> 解答者ごとの解答数の集計
	for (int i = 1; i <= Q; ++i) { // i 番目に正解したのは参加者 A[i]
		cin >> A[i];
		++(count[A[i]]);
	}
	// 出力
	for (int j = 1; j <= N; ++j) {
		cout << ((K - Q + count[j] <= 0) ? "No" : "Yes") << endl;
	}
	return 0;
}


Measured memory_bytes: 1408
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n\r\t', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)

    sum_list(Xs, Sum)

    orは!忘れに注意(末尾再帰なら直前)
*/

f([], [], Z, Z).
f([X|Xs], [Y|Ys], S, Z) :- X \= Y, !, S2 is S + 1, f(Xs, Ys, S2, Z).
f([_|Xs], [_|Ys], S, Z) :- f(Xs, Ys, S, Z).

main :-
    get_chars(S),
    reverse(S, T),
    f(S, T, 0, Z),
    X is Z div 2,
    writeln(X).

    % statistics(inferences, IC), writeln(IC).


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




void solve(){
	int b[105] = {0};
	
	int x ,n ;
	cin >> x >> n;
	int a[n];
	int min = INT_MAX;
	int max = INT_MIN;
	if(n == 0 )
	{
		cout << x ;
		return;
	}
	
	
	for(int i =0 ;i < n ;i++)
	{
		cin >> a[i];
		b[a[i]]++;
		if(min > a[i])min = a[i];
		if(max < a[i])max = a[i];
	}
		
		int mini = INT_MAX;
		int ans = INT_MAX;
	
	for(int i = min ; i <=max ; i++ )
	{
		if(b[i] == 0 && abs(i-x) < mini)
		mini = abs(x-i),ans =i;
	}
	if(mini != INT_MAX)
    {
     cout << ans;
      return ;
    }
    if(abs(min -1 - x) <= abs(max+1 - x))
      cout <<min-1;
      else cout << max+1;
	
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  //f();
  //int t;cin>>t;while(t--)
  solve();
  return 0;
}


Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>

using namespace std;
typedef long long ll;

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

int main() {

    ll n;
    cin >> n;
    ll A[n];
    ll a;
    ll start = n/2;
    rep(i,n){
        ll I = (i+1)/2;
        cin >> a;
        if(n%2!=0){
            if(i%2==0) A[start-I] = a;
            else A[start+I] = a;
        }else{
            if(i%2==0) A[start+I] = a;
            else A[start-I] = a;
        }
    }
    rep(i,n){
        cout << A[i];
        if(i!=n-1) cout << " ";
        else cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3840
#include<stdio.h>

int main()
{
    int H, W, h, w;
    H>0, W>0;
    H>=h, W>=w;
    scanf("%d %d", &H ,&W);
    scanf("%d %d", &h ,&w);
    printf("%d\n", (H-h)*(W-w));

    return 0;

}


Measured memory_bytes: 1704
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    n,a,b = mi()

    amari = n%(a+b)
    cnt = n//(a+b)
    print(cnt*a+min(amari,a))






main()



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

typedef long long int ll;

const int N = 1e5+7;
const ll inf = 1e18;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  
  int n, W;
  cin >> n >> W;
  
  vector<ll> w(n), v(n);
  for(int i=0;i<n;++i)
    cin >> w[i] >> v[i];
    
  int M = n * 1000;
  vector<ll> dp(M+1, inf);
  dp[0] = 0;
  
  for(int i = 0; i < n; ++i)
  {
    for(int j = M; j >= v[i]; --j)
      if(dp[j - v[i]] < inf)
        dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
  }
  
  for(int i=M; ~i; --i)
    if(dp[i] <= W) return !(cout << i << endl);
  
  
  return 0;
}


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

int main()
{
  ll N,K;cin>>N>>K;
  int p[N];
  rep(i,N) {
    cin>>p[i];
  }
  sort(p, p+N);

  int ans = 0;
  rep(i,K) {
    ans += p[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"

#define rep(i,n) for(int i = 0;i<n;i++)
#define cint(a) int a; cin >> a;
#define cstr(str) string str; cin >> str;
#define vv(Type, n,m,d)vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {

	double a, b,c;
	cin >> a >> b;
	
	ll ib = b * 100+ 0.5;

	ll ia = a;
	ll ans = ia * ib;
	 ans /= 100;

	 printf("%ld\n", ans);


	return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

constexpr lint mod0 = 1919191991;
constexpr lint mod1 = 1919191993;

bool is_prime(lint n) {
    for (int p = 2; p * p <= n; ++p) if (n % p == 0) {
        return false;
    }
    return true;
}

lint tmod(lint a, lint p) { return (a %= p) < 0 ? a + p : a; }
lint mod_inv(lint a, lint p) {
    a = tmod(a, p);
    lint b = p, x = 1, u = 0;
    while (b) {
        lint q = a / b;
        swap(a -= q * b, b);
        swap(x -= q * u, u);
    }
    return a == 1 ? tmod(x, p) : -1;
}

struct WeightedUnionFind {
    using T = pair<lint, lint>;
    static T op(T x, T y) { return {x.first * y.first % mod0, x.second * y.second % mod1}; }
    static constexpr T e() { return {1, 1}; }
    static T inv(T x) { return {mod_inv(x.first, mod0), mod_inv(x.second, mod1)}; }
    static T sub(T x, T y) { return op(x, inv(y)); }

    const int n;
    V<> t;
    V<T> pot;
    WeightedUnionFind(int n) : n(n), t(n, -1), pot(n, e()) {}
    int find(int v) {
        if (t[v] < 0) return v;
        int r = find(t[v]);
        pot[v] = op(pot[v], pot[t[v]]);
        return t[v] = r;
    }
    void unite(int u, int v, T d) {
        bool _same = same(u, v);
        assert(!_same);
        d = sub(d, sub(pot[v], pot[u]));
        if (t[u] >= 0) u = t[u];
        if (t[v] >= 0) v = t[v];
        if (-t[u] < -t[v]) {
            t[v] += t[u];
            t[u] = v;
            pot[u] = inv(d);
        } else {
            t[u] += t[v];
            t[v] = u;
            pot[v] = d;
        }
    }
    T diff(int u, int v) {
        bool _same = same(u, v);
        assert(_same);
        return sub(pot[v], pot[u]);
    }
    bool same(int u, int v) { return find(u) == find(v); }
    int size(int v) { return -t[find(v)]; }
};

int main() {
    // int t = 3;
    // for (lint p = 1919191919; ; ++p) if (is_prime(p)) {
    //     cerr << p << endl;
    //     if (t == 0)break;
    //     --t;
    // }
    // return 0;

    int n, m; cin >> n >> m;
    WeightedUnionFind uf(n);
    while (m--) {
        int a, b, v;
        cin >> a >> b >> v, --a, --b;
        pair<lint, lint> x = {v, v};
        if (uf.same(a, b)) {
            if (uf.diff(a, b) != x) {
                return cout << "No\n", 0;
            }
        } else {
            uf.unite(a, b, x);
        }
    }
    cout << "Yes\n";
}


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

#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define ALL(v) begin(v), end(v)

/* REPmacro */
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (s); i >= (n); i--)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define rrep(i, n) RFOR(i, n - 1, 0)
#define rrepi(i, n) RFOR(i, n, 1)

/* debug */
#define pp(v) cerr << #v "=" << (v) << endl;

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using vs = vector<string>;
using Graph = vvi;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* iostream */
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define TIME system("date +%M:%S.%N")
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }
template<class T> T div_ceil(const T &a, const T &b) { return (a + b - 1) / b; }

int solve(int x) {
  int cs = 0;
  repi(i,1e5) {
    cs += i;
    if (cs >= x) return i;
  }
} 

signed main() {
  int x;cin>>x;
  int ans = solve(x);
  cout << ans << endl;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;cin>>n;
  ll tmp=0,i=1,diff;
  while(tmp<n) {tmp+=i;i+=1;}
  diff=tmp-n;
  for(ll j=1;j<i;++j) if(j!=diff) print(j);
  return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int a[100005];
int k;
long long check(long long now)
{
    int i;
    for (i=0;i<k;i++)
    {
        now-=now%a[i];
    }
    return now;
}
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    long long l,r;
    l=2;
    r=1000000000000000000ll;
    int i;
    scanf("%d",&k);
    for (i=0;i<k;i++)
    {
        scanf("%d",&a[i]);
    }
    for (;l<=r;)
    {
        long long mid=(l+r)/2;
        if (check(mid)<2) l=mid+1; else r=mid-1;
    }
    long long ans1=l;
    l=2;
    r=1000000000000000000ll;
    for (;l<=r;)
    {
        long long mid=(l+r)/2;
        if (check(mid)<=2) l=mid+1; else r=mid-1;
    }
    long long ans2=l;
    if (ans2==ans1)
    {
        puts("-1");
        //cout<<ans1<<" "<<ans2<<endl;
    }
    else
    {
        cout<<ans1<<" "<<ans2-1<<endl;
    }
    return 0;
} 


Measured memory_bytes: 768
n, d = gets.strip.split(" ").map(&:to_i)

xs = Array.new(n) do
  gets.strip.split(" ").map(&:to_i)
end

ans = 0

0.upto(n - 2) do |i|
  (i + 1).upto(n - 1) do |j|
    s = 0
    d.times do |k|
      s += (xs[i][k] - xs[j][k])**2
    end

    if Math.sqrt(s).to_s.split(".").last == "0"
      ans += 1
    end
  end
end

puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define MAXN 100010
using namespace std;

int n;
long long a[MAXN], dis[MAXN], sum, pre[MAXN], suf[MAXN];

int main() {
	scanf("%d", &n);
	for (register int i = 1; i <= n; ++i)
		scanf("%lld", &a[i]);
	for (register int i = 1; i <= n; ++i) {
		dis[i] = abs(a[i] - a[i - 1]);
		sum += dis[i];
	}
	dis[n + 1] = abs(a[n]);
	sum += dis[n + 1];
	for (register int i = 1; i <= n; ++i) {
		pre[i] = pre[i - 1] + dis[i];
		suf[n - i + 1] = suf[n - i + 2] + dis[n - i + 2];
	}
	for (register int i = 1; i <= n; ++i)
		printf("%lld\n", pre[i - 1] + abs(a[i - 1] - a[i + 1]) + suf[i + 1]);
	return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

template <class T>
inline void read(T &x) {
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

char s;
bool flag;

int main() {
    while (std::cin >> s) {
        if (s == '7')   flag = true;
    }
    puts(flag ? "Yes" : "No");
    return 0;
}

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

int bi_search(int S[], int s, int e, int T);

int bi_search(int S[], int s, int e, int T)
{
    int idx;

    //printf("%d : %d -> %d ( [%d] )\n", s, e, S[(s+e)/2], (s+e)/2);

    if(s > e) {
        return 0;
    }

#if 0
    0 1 2 3 4 5 6 7
    0 1 2
            4 5 6 7

    0 1 2 3 4 5 6
    0 1 2
    0
        2

            4 5 6
#endif

    idx = (s + e) / 2;
    if(S[idx] == T) {
        return 1;
    } else if(S[idx] > T) {
        return bi_search(S, s, (s+e)/2-1, T);
    } else {
        return bi_search(S, (s+e)/2+1, e, T);
    }
}

int main()
{
    int n;
    int *S;
    int q;
    int T;
    int C;
    int i;

    scanf("%d", &n);
    S = (int *)malloc(sizeof(int) * n);
    for(i = 0; i < n; i++) {
        scanf("%d", &S[i]);
    }
    scanf("%d", &q);
    C = 0;
    for(i = 0; i < q; i++) {
        scanf("%d", &T);
        //printf("%d\n", T);
        if(bi_search(S, 0, n-1, T) == 1) {
            //printf("found\n");
            C += 1;
        }
    }
    printf("%d\n", C);
    return 0;
}


Measured memory_bytes: 2084
#coding:utf-8


X = int(raw_input())


lists = []

for i in range(11, 32):
    lists.append(i ** 2)

for i in range(6, 11):
    lists.append(i ** 2)
    lists.append(i ** 3)

for i in range(4, 6):
    lists.append(i ** 2)
    lists.append(i ** 3)
    lists.append(i ** 4)

for i in range(3, 4):
    lists.append(i ** 2)
    lists.append(i ** 3)
    lists.append(i ** 4)
    lists.append(i ** 5)

for i in range(1, 10):
    lists.append(2 ** i)

lists.append(1)

max_num = 0
for i in lists:
    if (max_num < i) and (i <= X):
        max_num = i

print max_num


Measured memory_bytes: 2692
#include <iostream>
#include <vector>
#include <queue>
#include <map>

using namespace std;

vector<int> A;
map<int,bool> memo;

void search_subset(int ind, int sn) {
	if (ind < A.size()) {
		memo[sn] = true;
		search_subset(ind+1,sn);
		memo[sn+A[ind]] = true;
		search_subset(ind+1,sn+A[ind]);
	}
	return;
}

int main(void) {
	int n;
	cin >> n;
	A = vector<int>(n);
	for (int i = 0; i < n; ++i) {
		cin >> A[i];
	}
	search_subset(0,0);
	int q,temp;
	cin >> q;
	for (int i = 0; i < q; ++i) {
		cin >> temp;
		if (memo[temp]) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a =10000,b=5000,c=1000;
    int n,y;
    bool flag=false;
    cin>>n>>y;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j+i<=n;j++)
        {
            int rem=y-(i*10000+j*5000);
            if(rem>=0 && rem/1000+i+j ==n )
            {
                flag=true;
                cout<<i<<" "<<j<<" "<<rem/1000<<endl;
                break; 
            }
        }
        if(flag)
        break;
    }
    if(!flag)
    cout<<"-1 -1 -1"<<endl;
     return 0;
}

Measured memory_bytes: 256
#グローバル変数
ab = []
def solve0(n):
    ok = 0
    for a in range(1,n+1):
        for b in range(1,n+1):
            if str(a)[0] == str(b)[-1] and str(a)[-1] == str(b)[0]:
                ok += 1
                ab.append([a,b])
    return ok

def solve2(n,ab):
    ok = 0
    ok_a = 0
    ok_b = 0
    for a,b in ab:
        ok_a = count(n,a)
        ok_b = count(n,b)
        ok = ok + ok_a * ok_b
    return ok

def count(n,z):
    strN = str(n)
    strZ = str(z)
    if z > n:       # z の方が大きい場合は 0
        return 0
    if len(strN) == 1: #　n　の桁が１桁の場合
        return 1
    if len(strZ) == 1: #　z　の桁が１桁の場合
        return 1

    #　n と z　の桁が2桁以上の場合
    ok = 0
    mlen = 0
    while mlen+2 < len(strN): # z の桁が n より小さい
        ok = ok + 10**mlen
        mlen = mlen + 1
    # n と z　の桁が同じ
    if int(strZ[0]+"9"*mlen+strZ[-1]) <= n:
        ok = ok + 10**mlen
    elif int(strZ[0]+strN[1:len(strN)-1]+strZ[-1]) <= n:
        ok = ok + int(strN[1:len(strN)-1])+1
    else:
        nMid = str(strN[1:len(strN)-1])
        if int(nMid) > 0:
            nMid = str(int(nMid)-1).zfill(len(strN)-2)
            if int(strZ[0]+nMid+strZ[-1]) <= n:
                ok = ok + (int(nMid))+1
    return ok

# 配列 ab の準備
solve0(99)

# 整数の入力
n = int(input())
print(solve2(n,ab))


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

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define RREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define RFOR(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    for (auto a : v) os << a << ", ";
    os << "]";
    return os;
}

int main() {
    ll N, M;
    cin >> N >> M;
    priority_queue<ll> que;
    REP(i, N) {
        ll a;
        cin >> a;
        que.push(a);
    }

    REP(i, M) {
        ll price = que.top() / 2;
        que.pop();
        que.push(price);
    }

    ll ans = 0;
    while (!que.empty()) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
    return 0;
}

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

int main() {

	int n, ans;

	cin >> n;

	if (n % 2 == 0) {
		ans = n / 2;
	}
	else {
		ans = n / 2 + 1;
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 256
from collections import deque

k = int(input())

q = deque([i for i in range(1, 10)])

cnt = 0
while True:
    cnt += 1
    v = q.popleft()
    if cnt == k:
        print(v)
        exit()
    m = v % 10
    if m != 0:
        q.append(10*v + m - 1)
    q.append(10*v + m)
    if m != 9:
        q.append(10*v + m + 1)

Measured memory_bytes: 40816
#include <bits/stdc++.h>
using namespace std;
#define int long long
char arr[405][405];
bool vis[405][405];
int h, w;
int cb;
int cw;

bool f(int i, int j, int l, int m) {
	if (l < 0 || l >= h || m < 0 || m >= w) {
		return 0;
	}
	if (vis[l][m] == 1) {
		return 0;
	}
	if (arr[i][j] == arr[l][m]) {
		return 0;
	}
	return 1;
}

void dfs(int i, int j) {
	vis[i][j] = 1;
	// cout << i << " " << j << endl;
	if (arr[i][j] == '#') {
		cb++;
	}
	else {
		cw++;
	}
	if (f(i, j, i + 1, j)) {
		dfs(i + 1, j);
	}
	if (f(i, j, i, j + 1)) {
		dfs(i, j + 1);
	}
	if (f(i, j, i - 1, j)) {
		dfs(i - 1, j);
	}
	if (f(i, j, i, j - 1)) {
		dfs(i, j - 1);
	}
}


int32_t main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> arr[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (vis[i][j] == 0) {
				dfs(i, j);
				// cout << "cb=" << cb << " " << "cw=" << cw << endl;
				ans += (cb * cw);
				cb = 0;
				cw = 0;
			}
		}
	}
	cout << ans;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,pair<int,int>> iii;
typedef vector<pair<int,int>> vii;
typedef vector<vector<int>> vvi;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LSOne(i) ((i) & -(i))

const int INF = 1e9;
int d,g,ans = INF;
int p[11], c[11];

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

    cin >> d >> g;
    g /= 100;
    for (int i = 1; i <= d; i++) {
        cin >> p[i] >> c[i];
        c[i] /= 100;
    }

    int lim = 1<<d;
    for (int i = 0; i <= lim; i++) {
        int goal = g;
        int pm = i;
        int used = 0;
        for (int idx = d; idx > 0; idx--) {
            if (pm&1) {
                used += p[idx];
                goal -= idx*p[idx] + c[idx];
            }
            pm >>= 1;
        }

        pm = i;
        for (int idx = d; goal > 0 && idx > 0; idx--) {
            if (!(pm&1)) {
                int toUse = min(p[idx]-1, (goal+idx-1)/idx);
                used += toUse;
                goal -= idx*toUse;
            }
            pm >>= 1;
        }

        if (goal <= 0)
            ans = min(ans, used);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <algorithm>
#include <complex>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PI 3.14159265358979311600
#define loop(i, n) for(int i = 0; i < n; i++)
#define loop1(i, a, n) for(int i = a; i < n; i++)
using namespace  std;

using ll = long long;
const ll mod = 1e9 + 7;
typedef pair<ll, ll> pairs;
typedef complex<ll> G;
const int q=2e5+5;
#define x first
#define y second
const int INF = 1e9;

void done() {
    int n, k;
    cin >> n >> k;
    vector<int>a(n+1);
    for(int i =1;i <= n;i++) {
        cin >> a[i];
    }
    vector<int>pos;
    int ok = 0;
    for(int i =2;i < n;i++) {
        if(a[i] > a[i-1] && a[i] > a[i+1])pos.push_back(i);
    }
    int cnt = 0, d = 1, ans = 1;
    for(int i=0, j=0;i < pos.size();i++) {

        int q = pos[i];
        while((pos[j]-q)+2 <= k && j < pos.size()) {
            j++;
        }
        if(j-i > d) {
            ans = pos[i]-1;
            cnt = j-i+1;
            d = j-i;
            ok = 1;
        }
    }
    cout << cnt << " " << ans << '\n';

}
void solve() {
    int n;cin >> n;
    int ans = n % 1000;
    cout << (ans ? 1000-ans : 0);

}
void another() {



}
void test_case() {
    int t;
    cin >> t;
    while(t--)done();
}
int main() {

     fast;
    solve();

}



Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main() 
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if(b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if(b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else if(c <= b && b <= a)
        cout << c << " " << b << " " << a << endl;
    else if(c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
}

    





Measured memory_bytes: 3100
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#else
#define VS_ENDPAUSE()
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
	func();
	VS_ENDPAUSE();
	return 0;
}


void func(void)
{
	uint32 n;
	cin >> n;
	vector< uint32 > a(n);
	vector< uint32 > b(n);
	for(uint32 i=0; i<n; i++){
		cin >> a[i];
	}

	uint32 j=n-1;
	for(uint32 i=0; i<n/2; i++){
		b[i] = a[j];
		j -= 2;
	}
	b[n/2] = a[0];
	j = (n%2 == 1) ? 1 : 2;
	for(uint32 i=(n/2 + 1); i<n; i++){
		b[i] = a[j];
		j += 2;
	}
	
	for(uint32 i=0; i<n-1; i++){
		cout << b[i] << " ";
	}
	cout << b[n-1] << endl;

	return;
}




Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define int long long

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}

bool is_in_board(int x, int y, int h, int w){
    return x >= 0 && x <= w+1 && y >= 0 && y <= h+1;
}

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int h, w;
    cin >> h >> w;
    int black = 0;
    vector<vector<char>> board(h+2, vector<char>(w+2, '#'));
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cin >> board[i][j];
            if(board[i][j] == '#'){
                black++;
            }
        }
    }

    int d = -1;
    vector<vector<int>> dis(h+2, vector<int>(w+2, -1));
    dis[1][1] = 1;
    queue<int> qx;
    queue<int> qy;
    qx.push(1);
    qy.push(1);
    while(!qx.empty()){
        int x = qx.front();
        int y = qy.front();
        qx.pop();
        qy.pop();
        int dx[4] = {1, -1, 0, 0};
        int dy[4] = {0, 0, 1, -1};
        for(int i=0; i<4; i++){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(is_in_board(nx, ny, h, w) && board[ny][nx] == '.' && dis[ny][nx] == -1){
                dis[ny][nx] = dis[y][x] + 1;
                qx.push(nx);
                qy.push(ny);
            }
        }

        if(dis[h][w] != -1){
            d = dis[h][w];
            break;
        }
    }

    if(d == -1){
        cout << -1 << endl;
    }
    else{
        cout << h*w - black - d << endl;
    }

    return 0;
}

Measured memory_bytes: 3740
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<math.h>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    long double a,b,c;
    cin >> a >> b >> c;
    long double d = c-a-b;

    if(d > 0 && d*d > 4*a*b){
        cout << "Yes" << endl;
    } 
    else{
        cout << "No" << endl;
    }
    
    return 0;
}

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

int main(){
    ll n,ans=0,s=0;
    cin >> n;
    for(int i = 0;i < n;i ++){
        ll x;
        cin >> x;
        s += x;
        if(!x) {ans += s/2;s = 0;}
    }
    ans += s/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC         optimize("O3")
#include            <bits/stdc++.h>
#include            <ext/pb_ds/assoc_container.hpp>
#include            <ext/pb_ds/tree_policy.hpp>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define mp          make_pair
#define mem(x,i)    memset(x,i,sizeof(x))
#define ff          first
#define ss          second
#define popcount(x) __builtin_popcount(x)
#define all(x)      x.begin(),x.end()
#define Case(t)     for(int ks=1;ks<=t;ks++)
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define D(x)        cerr<< __LINE__ <<": "<< #x << " = "<<(x) <<'\n';
#define endl        '\n'

using namespace std;
using namespace __gnu_pbds;

using ll  = long long;
using ld  = long double;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;

const int INF    = 0x3f3f3f3f;
const ll LL_INF  = 0x3f3f3f3f3f3f3f3f;
const double PI  = acos(-1);
const double eps = 1e-4;
const int mod    = 998244353;
const int mx     = 100005;
template <typename T>  using orderedSet =
    tree<T, null_type, less_equal<T>,
    rb_tree_tag, tree_order_statistics_node_update>;//find_by_order,order_of_key*/

/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

//ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(; b; b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
/*----------------------BitMask-----------------------------------------*/
//inline int setBit(int N,int pos){return N=N | (1<<pos);}
//inline int resetBit(int N,int pos){return N= N & ~(1<<pos);}
//inline bool checkBit(int N,int pos){return (bool) (N& (1<<pos));}

int main()
{
    int n;
    cin>>n;
    int a[n+1],b[n+1],c[n+1];
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    for(int i=1;i<n;i++) cin>>c[i];
    int ans=0;
    int pre=-1;
    for(int i=1;i<=n;i++)
    {
        int u=a[i];
        ans+=b[u];
        if(pre+1==u) ans+=c[pre];
        pre=u;
       // D(ans);
    }
    cout<<ans<<endl;
}


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

static const int N = 100;

int main(){
  int n,p[N+1],m[N+1][N+1];
  cin >> n;
  for (int i=1;i<=n;i++){
    cin >> p[i-1] >> p[i];
  }

  for( int i=1;i<=n;i++)m[i][i]=0;
  for( int l=2;l<=n;l++){
    for( int i=1;i<=n-l+1;i++){
      int j=i+l-1;
      m[i][j]=(1<<21);
      for( int k=i;k<=j-1;k++){
        m[i][j]=min(m[i][j], m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
        }
      }
    }

  cout << m[1][n] << endl;
  
  return 0;
}

Measured memory_bytes: 3088