akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	string S;
	cin >> N >> S;
	S.insert(begin(S), '1');
	S +='1';
	int inner1 =0, inner0 =0;
	for(int i =1; i <= 2*N; i++) if(S[i-1] == S[i]) {
		if(S[i-1] == '1') inner1++;
		else inner0++;
	}
	if(inner1%2 != 0 || inner0%2 != 0) {
		cout << "No\n";
		return 0;
	}

	vector< vector<int> > T; // topology
	for(int i =0; i <= 2*N; i++) if(i == 0 || (S[i-1] == '0' && S[i] == '1')) {
		vector<int> v(1, i);
		i++;
		while(i <= 2*N && S[i] == '1') {
			v.push_back(i);
			i++;
		}
		v.push_back(i);
		T.push_back(v);
	}
	vector<int> ans(2*N, -1);
	int col =1;

	if(inner1%4 != 0) {
		int seg =1;
		while(seg+1 < (int)T.size() && (int)T[seg].size() <= 2) seg++;
		if(seg+1 >= (int)T.size()) {
			cout << "No\n";
			return 0;
		}
		int s2 =-1;
		for(int i =0; i < (int)T.size(); i++) if((int)T[i].size() > 2 && i != seg) {
			s2 =i;
			break;
		}
		if(s2 == -1) {
			cout << "No\n";
			return 0;
		}
		ans[T[seg][0]-1] =ans[T[seg].back()-1] =col;
		col++;
		ans[T[s2][T[s2].size()-2]-1] =ans[T[seg][1]-1] =col;
		col++;
		int l =T[s2].back();
		T[s2].pop_back();
		T[s2].pop_back();
		for(int i =2; i < (int)T[seg].size()-1; i++) T[s2].push_back(T[seg][i]);
		T[s2].push_back(l);
		T.erase(begin(T)+seg);
	}

	// topology merge
	vector<int> Tfin;
	for(int i =0; i < (int)T.size(); i++) {
		if(i > 0) {
			ans[T[i-1].back()-1] =ans[T[i][0]-1] =col;
			col++;
		}
		for(int j =1; j < (int)T[i].size()-1; j++) Tfin.push_back(T[i][j]);
	}

	// 00 pairs
	int x0, p0sz =0;
	for(int i =1; i <= 2*N; i++) if(S[i] == '0' && S[i-1] == '0') {
		if(p0sz == 0) {
			x0 =i;
			p0sz++;
		}
		else {
			ans[x0-1] =ans[i-1] =col;
			p0sz =0;
			col++;
		}
	}

	// 11 pairs
	int x1[3];
	int p1sz =0;
	for(int i =0; i < (int)Tfin.size(); i++) {
		if(p1sz < 3) {
			x1[p1sz] =Tfin[i];
			p1sz++;
		}
		else {
			ans[x1[0]-1] =ans[x1[2]-1] =col;
			col++;
			ans[x1[1]-1] =ans[Tfin[i]-1] =col;
			col++;
			p1sz =0;
		}
	}

	cout << "Yes\n";
	for(int i =0; i < 2*N; i++) cout << ans[i] << ((i == 2*N-1)?"\n":" ");
	return 0;}

// look at my code
// my code is amazing


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int xs[4];

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

    for(int i=0;i<4;++i){
        std::cin >> xs[i];
    }

    std::sort(xs, xs+4);

    if(xs[0] == 1 && xs[1] == 4 && xs[2] == 7 && xs[3] == 9){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
const int N=100005;
int n,e,t,x[N],i,j,k;
ll f[N],w=1ll<<60;
multiset<ll> st;
int main()
{
	scanf("%d%d%d",&n,&e,&t);
	for(i=1;i<=n;++i)
		scanf("%d",x+i);
	for(i=1,k=0;i<=n;++i)
	{
		st.insert(f[i-1]-x[i-1]+t);
		while(k<i&&2*(x[i]-x[k+1])>=t)
		{
			w=min(w,f[k]-x[k]-2*x[k+1]);
			st.erase(st.find(f[k]-x[k]+t));
			++k;
		}
		f[i]=1ll<<60;
		if(w<(1ll<<60))
			f[i]=min(f[i],w+2*x[i]);
		if(!st.empty())
			f[i]=min(f[i],*(st.begin()));
		//for(j=i-1;j>=0;--j)
			//f[i]=min(f[i],f[j]-x[j]+max(t,2*(x[i]-x[j+1])));
		f[i]+=x[i];
	}
	printf("%lld",f[n]+e-x[n]);
	return 0;
}


Measured memory_bytes: 3328
n, m = gets.chomp.split.map(&:to_i)
ab = []
n.times do
  ab << gets.chomp.split.map(&:to_i)
end
ab.sort! do |x, y|
  x[0] <=> y[0]
end
sum = 0
rest = m
1.upto(n) do |i|
  x = [rest, ab[i-1][1]].min
  sum += x * ab[i-1][0]
  rest -= x
  if rest <= 0 then
    break
  end
end
puts sum


Measured memory_bytes: 10600
A, B, C, X, Y = map(int, input().split())

maxV = max(X, Y)
min_prise = pow(10, 10)

# ABピザの枚数をiとする
for AB_cnt in range(maxV * 2 + 1):
  # Aの金額を計算する
  if X - AB_cnt // 2 > 0:
    A_prise = (X - AB_cnt // 2) * A
  else:
    A_prise = 0

  # Bの金額を計算する
  if Y - AB_cnt // 2 > 0:
    B_prise = (Y - AB_cnt // 2) * B
  else:
    B_prise = 0

  # ABの金額を計算する
  AB_prise = AB_cnt * C

  # A, B, ABの金額を合計する
  sum_prise = A_prise + B_prise + AB_prise

  # sum_priseが最小値よりも小さければ格納する
  if sum_prise < min_prise:
    min_prise = sum_prise

print(min_prise)

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

int main(){
	int a, b, tot = 0;
	string str;

	cin >> a >> b;

	for( int i = a; i <= b; ++i ){
		stringstream convert;
		convert << i;
		convert >> str;

		if( str[0] == str[4] && str[1] == str[3] ) tot++;
	}
	cout << tot << endl;
	return 0;
}

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

int main()
{
    string s; cin>>s;
    stack<char> a;
    for(auto& c: s)
        c=='T' && a.size() && a.top()=='S' ?  a.pop() : a.push(c);
    cout<<a.size()<<endl;
}

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

int main(){
	int n,num;
	cin >>n;
	vector<int> order,gain;
	int ans = 0;
	for (int i = 0;i <n; i++)
		{
			cin >> num;
			order.push_back(num);
		}
		
	for (int i = 0;i <n; i++)
		{
			cin >> num;
			ans += num;
		}		
	for (int i = 0; i <n-1; i ++)
	{
		cin >> num;
		gain.push_back(num); 
	}
	for(int i = 1; i <n; i++){
		if (order[i] == order[i-1]+1)
		{
			ans += gain[order[i-1]-1];
		}
	}
	cout <<ans;
} 

Measured memory_bytes: 256
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N,C = inpl()
xv = [inpl() for i in range(N)]

#right[i] = [C,d]
#右にi貫食べた時，C:差し引きカロリー,d:移動距離
rc = rd = lc = ld = 0
ans = 0
R1 = [0]
L1 = [0]
R2 = [0]
L2 = [0]
MAX_R1 = MAX_R2 = MAX_L1 = MAX_L2 = -INF
for i in range(0,N):
	x,v = xv[i]
	rd = x
	rc += v
	MAX_R1 = max(MAX_R1,rc-rd)
	MAX_R2 = max(MAX_R2,rc-2*rd)
	R1.append(MAX_R1)
	R2.append(MAX_R2)

	x,v = xv[N-1-i]
	ld = C-x
	lc += v
	MAX_L1 = max(MAX_L1,lc-ld)
	MAX_L2 = max(MAX_L2,lc-2*ld)
	L1.append(MAX_L1)
	L2.append(MAX_L2)

ans = 0
for i in range(0,N+1):
	r1 = R1[i]
	r2 = R2[i]
	l1 = L1[N-i]
	l2 = L2[N-i]
	ans1 = r2 + l1
	ans2 = r1 + l2
	ans = max(r1,l1,ans1,ans2,ans)

print(ans)

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n,m;cin >>n>>m;
    ll ans=1900*m+100*(n-m);
    ans*=pow(2,m);
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func readLine(sc *bufio.Scanner) string {
	sc.Scan()
	return strings.TrimSpace(sc.Text())
}

func readLineToInt(sc *bufio.Scanner) int {
	intValue, err := strconv.Atoi(readLine(sc))
	if err != nil {
		panic(err)
	}

	return intValue
}

func explodeString(delimiter string, inputValue string) []string {
	splittedValue := strings.Split(inputValue, delimiter)

	var trimmedValues []string

	for _, value := range splittedValue {
		if value != "" {
			trimmedValues = append(trimmedValues, value)
		}
	}

	return trimmedValues
}

func explodeInt(delimiter string, inputValue string) []int {
	inputStrings := explodeString(" ", inputValue)

	var splittedInts []int

	for _, inputString := range inputStrings {
		var (
			intValue int
			err      error
		)
		intValue, err = strconv.Atoi(inputString)

		if err != nil {
			panic(err)
		}
		splittedInts = append(splittedInts, intValue)
	}

	return splittedInts
}

func main() {
	sc := bufio.NewScanner(os.Stdin)

	var cookingTimes []int

	lastCookingTimeIndex := 0
	lastCookingTimeMod := 10

	for i := 0; i < 5; i++ {
		inputInt := readLineToInt(sc)
		cookingTimes = append(cookingTimes, inputInt)

		modInt := inputInt % 10
		if modInt != 0 && modInt < lastCookingTimeMod {
			lastCookingTimeMod = modInt
			lastCookingTimeIndex = i
		}
	}

	outputValue := 0
	for i, cookingTime := range cookingTimes {
		if i == lastCookingTimeIndex {
			continue
		}

		if cookingTime%10 == 0 {
			outputValue += cookingTime
		} else {
			outputValue += cookingTime + 10 - cookingTime%10
		}
	}

	outputValue += cookingTimes[lastCookingTimeIndex]

	fmt.Println(outputValue)
}


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

int main(){
  int n;

  cin >> n;

  int x = n;
  int sum = 0;
  while (x > 0) {
    sum += x % 10;
    x /= 10;
  }

  if (n % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n;
  cin >> n;

  bool one = 0;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    char c;
    cin >> c;
    a[i] = c - '1';
    if (a[i] == 1) one = 1;
  }

  auto solve = [&]() {
    bool ret = 0;
    for (int i = 0; i < n; ++i) {
      bool cur = (((n - 1 - i) & i) == 0);
      cur &= (a[i] & 1);
      ret ^= cur;
    }
    return ret;
  };

  int ans = solve();
  if (ans == 1) {
    cout << 1 << '\n';
  } else if (one) {
    cout << 0 << '\n';
  }else {
    for (int i = 0; i < n; ++i) {
      a[i] /= 2;
    }
    ans = solve();
    if (ans == 1) cout << 2 << '\n';
    else cout << 0 << '\n';
  }
}

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

S = [[]for i in range(M)]

for i in range(M):
    L=list(map(int,input().split()))
    for j in range(L[0]):
        S[i].append(L[j+1])

P=list(map(int,input().split()))

D=[0]*M

#print(S)
#print(P)

count=0

even=0
odd=0
#Nをビットで羅列
for i in range(2 **N):
    D=[0]*M
    ON_SW=[0]*M
    #ビットシフト
    for j in range(N):
        if ((i >> j) & 1):
            #print(i,j)
            for k in range(M):
                for l in range(len(S[k])):
                    if j+1==S[k][l]:
                        ON_SW[k]+=1
                        #print(ON_SW)
    
    #print("ONSW="+str(ON_SW)+"PK="+str(P[k]))
            
    flag=True
    for j in range(M):
        
        if ON_SW[j]%2==P[j]:
            pass
        else:
            flag=False
        
    if flag==True:
        #print(i)
        count+=1
    #print(ON_SW)
    #print(ON_SW,ON_SW[0]%2,ON_SW[1]%2,P)
print(count)

            

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

// using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

/***** MAIN *****/
signed main() {
  int n, x, y;
  cin >> n >> x >> y;
  --x; --y;
  map<int,int> mp;
  for(int i = 0; i < n; ++i) {
    for(int j = i+1; j < n; ++j) {
      int distance = min(j-i, abs(x-i)+1+abs(j-y));
      ++mp[distance];
    }
  }
  for(int i = 1; i < n; ++i) {
    cout << mp[i] << endl;
  }
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 384
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
        
def lcm(a,b):
    return a//gcd(a,b)*b
    
n = int(input())
ans=1
for i in range(n):
    t = int(input())
    ans = lcm(ans,t)
    
print(ans)

Measured memory_bytes: 3060
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

    static long N;
    static int M;
    static int A;
    static long B;
    static long C;
    //    static int[][] map;
    static int min = 9999999;


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        N = scanner.nextInt();

        int ret = 0;
        for (int i = 0; i <= N; i++) {
            int ans = 0;
            for (int j = 1; j <= i; j++) {
                if(i % j == 0)ans++;
            }
            if(ans == 8 && i % 2 == 1)ret++;
        }


        System.out.println(ret);

    }
}



Measured memory_bytes: 23892
def dfs(A: list):
    if len(A) > len(str(n))+1:
        return
    if len(A) and (x := int("".join(A))) >= n and ans[0] > x:
        ans[0] = x
        return

    for v in d:
        if v == "0" and len(A) == 0:
            next
        A.append(v)
        dfs(A)
        A.pop()


n, k = map(int, input().split())
d = sorted(list(set([str(i) for i in range(10)]) - set(input().split())))
ans = [10**10]
dfs([])
print(ans[0])


Measured memory_bytes: 9076
#include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <sstream>
#include <stdio.h>
#include<cstdio>

#include<string>
#include<cmath>
#include<map>
//#include<cstdlib>
#include<deque>
//#include<queue>
//#include<climits>
#include<cstring>
using namespace std;

const int N_MAX = 1000000;

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

  // table
  int** table = new int*[N];
  for(int i=0; i<N; i++){
    table[i] = new int[N];
    memset(&table[i][0], 0, N*sizeof(table[i][0]));
    // &table[i][0] can be table[i] because it only needs head address.
    
    //[..., [int, int,int], ...]
    // memset(start_addr, 0, delta_arr) fills
    // start_addr to (start_addr + delta_arr) by 0.
    // table[i] refers to the first addr of table[i],
    // for each integer to be filled by 0, size of the element
    // (not table[i]) should be given.
  }
  
  for(int i=0; i<N; i++){
    int row_num, k;
    cin >> row_num >> k;

    row_num--;
    
    for(int j=0; j<k; j++){
      int col_num;
      cin >> col_num;
      col_num--;
      table[row_num][col_num] = 1;
    }
  }

  //print table
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      cout << table[i][j];
      if(j!=N-1) cout << " ";
      else cout << endl;
    }
  }
  
  for(int i=0; i<N; i++){
    delete[] table[i];
  }
  delete[] table;
  
  return 0;
}



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


int main(void)
{
    int N;
    cin >> N;
    vector<double> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    double res = 0;
    for (int i = 0; i < N; i++)
    {
        res+= 1/(double)A[i];
    }
    res= 1/res;
    cout << res;
    
    }


Measured memory_bytes: 3824
S = input()

if S == 'SSS':
    print(0)
elif S == 'RSS' or S == 'SRS' or S == 'SSR' or S == 'RSR':
    print(1)
elif S == 'RRS' or S == 'SRR':
    print(2)
elif S == 'RRR':
    print(3)


Measured memory_bytes: 8964
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0;i < n;i++)cin >> a[i];
  sort(a.begin(),a.end());
  int N,K;
  N = a[n-1];
  int min = N;
  for(int i = 0;i < n;i++){
    int d = abs(N - 2*a[i]);
    if(min > d){
      min = d;
      K = a[i];
    }
  }
  cout << N << " " << K;
}
    
  

Measured memory_bytes: 640
#include <iostream>

int main() {
	int a,b,c,d;
  
  	std::cin >> a >> b >> c >> d;
  
  	if (a*b <= c*d) {
    	std::cout << c*d << std::endl;
    } else {
    	std::cout << a*b << std::endl;
    }
}

Measured memory_bytes: 3576
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    if(s.back() == '1' || s.front() == '0') {
        cout << "-1" << endl;
        return 0;
    }
    int n = s.length() - 1;
    rep(i, n / 2) {
        if (s[i] != s[n - i - 1]) {
            cout << "-1" << endl;
            return 0;
        }
    }
    int l = 1, r = 2;
    rep(i, n) {
        if(s[i] == '1') {
            cout << l << " " << r << endl;
            l = r;
            r++;
        } else {
            cout << l << " " << r << endl;
            r++;
        }
    }


    return 0;
}


Measured memory_bytes: 1616
n = int(input())
A = list(map(int, input().split()))

S = sum(A)

from itertools import accumulate
C = [0]+A
C = list(accumulate(C))
ans = 10**18
for i in range(1, n):
    s = C[i]
    a = S-s
    ans = min(ans, abs(s-a))
print(ans)


Measured memory_bytes: 103272
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    i32 N; cin >> N;
    Vec<i32> A(N);
    for (i32 i = 0; i < N; i++) {
        cin >> A[i];
    }
    i64 m = 1000;
    for (i32 i = 0; i < N - 1; i++) {
        i64 k = 0;
        if (A[i] < A[i + 1]) k = m / A[i];
        m += (A[i + 1] - A[i]) * k;

    }
    cout << m << endl;
}


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

#define ll long long
#define fr first
#define se second
#define pb push_back

using namespace std;

const long long N = 1e5 + 7;

ll res, n, m, cnt, ans , a , b , sum , mx = -1e9 , mn, c , d;
string s;
int main()
{
    cin >> s;
    if( s[1] == 'B' )
    cout << "ARC";
    else
        cout << "ABC";
}


Measured memory_bytes: 3612
import java.util.*;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();

        System.out.println((r*100 + g*10 + b) % 4 == 0 ? "YES" : "NO");
    }
}

Measured memory_bytes: 21844
use proconio::input;

fn solve(x: i32, a: i32) {
    if x < a {
        println!("0");
    }
    else {
        println!("10");
    }
}

fn main() {
    input! {
        x: i32,
        a: i32,
    }

    solve(x, a);
}


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

int main(){
  int n;
  cin >> n;
  while(n--){
    string str; cin >> str;
    map<int,char> data;
    map<int,char>::iterator itr;
    int cnt = 0;
    for(int i=0;i<str.size();i++){
      if(isalpha(str[i])) data[cnt] = str[i];
      else if(str[i] == '<') cnt--;
      else if(str[i] == '>') cnt++;
    }
    for(itr = data.begin();itr!=data.end();itr++){
      cout << (*itr).second;
    }
    cout << endl;
    data.clear();
  }
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
 
bool vector_finder(std::vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) {
    return true;
  }
  else {
    return false;
  }
}

std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}
 
 
int main() {
  ll N, D;

  cin >> N >> D;

  vector<ll> X(N);
  vector<ll> Y(N);
  ll ans = 0;

  for (ll i = 0; i < N; i++) {
    cin >> X.at(i) >> Y.at(i);

    long double e = sqrt((long double)(X.at(i)*X.at(i) + Y.at(i)*Y.at(i)));

    if (D >= e) ans++;

  }


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

Measured memory_bytes: 6420
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <queue>

#include <cmath>
#include <cstdio>

using namespace std;


int main(int argc,char **argv){
	
	long N;
	cin >> N;
	vector<long> Pinv(N);
	for(long i=0;i<N;++i){ 
		long tmp=0;
		cin >> tmp;
		Pinv[tmp-1]=i;
	}

	long now=1,max=1;
	for(long i=1;i<N;++i){
		if(Pinv[i-1]>Pinv[i]){ now=1; }
		else{ 
			now+=1;
			max=std::max(now,max);
		}
	}

	cout << (N-max) << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define vii vector<int>
#define vcc vector<char>
#define pll pair<long long, long long>
#define mem memset
#define sof sizeof
#define co1 __builtin_popcountll
#define PB push_back
#define UB upper_bound
#define LB lower_bound
#define MP make_pair
#define TS to_string
#define F first
#define S second
#define endl '\n'
using namespace std;

long long __lcm(long long a, long long b){
    ll gd = __gcd(a,b);
    ll xx = (a*b)/gd;
    return xx;
}

long long bigmod(long long a, long long b, long long M){
    if(b==0) return 1%M;
    ll x = bigmod(a,b/2,M);
    x=(x*x)%M;
    if(b%2==1) x=(x*a)%M;
    return x;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long a=0,b=0,c=0,d=0,e,f,i,j,k,m,n,o,x,y;
    cin>>n;
    while(n--){
        string s;
        cin>>s;
        if(s=="AC") a++;
        else if(s=="WA") b++;
        else if(s=="TLE") c++;
        else d++;
    }
    cout<<"AC x "<<a<<"\n"<<"WA x "<<b<<"\n"<<"TLE x "<<c<<"\n"<<"RE x "<<d<<"\n";
}

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

int main(){
    long long a,b,c,ans;
    cin>>a>>b>>c;
    long long t=max({a,b,c});
    if(a==t) ans=b*c*abs(a/2-(a-a/2));
    else if(b==t) ans=c*a*abs(b/2-(b-b/2));
    else ans=a*b*abs(c/2-(c-c/2));
    
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b,ans=0;;
    cin >> a >> b;
    for(int i=0; i<2; i++){
        if(a>b){
            ans+=a;
            a--;
        }else{
            ans+=b;
            b--;
        }
    }
    cout << ans << endl;
}

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

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

  int cnt = 0;

  for (int i = 0; i < N; i++) {
    int p;
    cin >> p;
    if (p != i + 1) cnt++;
  }

  cout << ((cnt == 0 || cnt == 2) ? "YES" : "NO") << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			int ans=i*m+j*n-2*i*j;
			if(ans==k){printf("Yes");return 0;}
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define tsort int
#define smaxn 1000000 //最大要素数
#define smxbit 30 //要素のうち最大の数値のビット数
#define snobit 17 //1-smxbitの間で調整、増やせば速いがメモリを消費する
#define rev 0     //0で昇順、1で降順
#define snosc (1<<(snobit+1))

int sort(tsort *vlist,int *plist,int n){
  int h,i,j,k,l,m,s,p,qlist[smaxn],c[snosc][3],ss;
#if rev
  ss=snosc-1;
#else
  ss=0;
#endif
  tsort vj,vk,mx[snosc];
  for(i=0;i<snosc;i++){
    c[i][0]=-1;
    c[i][1]=-1;
  }
  for(i=0;i<n;i++){
    l=(int)(vlist[i]>>(smxbit-snobit))&(snosc-1)^(1<<snobit);
    if(c[l][0]==-1){
      c[l][0]=i;
      c[l][2]=i;
      mx[l]=vlist[i];
    }else{
      qlist[c[l][1]]=i;
#if rev
      if(vlist[i]<mx[l]){
#else
      if(vlist[i]>mx[l]){
#endif
        c[l][2]=i;
        mx[l]=vlist[i];
      }
    }
    c[l][1]=i;
    plist[i]=-1;
  }
#if rev
  for(h=snosc-1;h>=0;h--){
#else
  for(h=0;h<snosc;h++){
#endif
    s=c[h][0];
    if(s==-1){
#if rev
      if(h==ss) ss--;
      if(h!=snosc-1) c[h][1]=c[h+1][1];
#else
      if(h==ss) ss++;
      if(h!=0) c[h][1]=c[h-1][1];
#endif
      continue;
    }
    qlist[c[h][1]]=-1;
    while(qlist[s]!=-1){
      i=s;
      p=-1;
      while(i!=-1){
        j=i;
        k=qlist[j];
        if(k==-1) break;
        i=qlist[k];
#if rev
        if(vlist[j]<vlist[k])
#else
        if(vlist[j]>vlist[k])
#endif
        {
          if(p==-1){
            s=k;
          }else{
            qlist[p]=k;
          }
          l=j;
          j=k;
          k=l;
        }
        qlist[j]=i;
        p=j;
        vj=vlist[j];
        vk=vlist[k];
        while(k!=-1){
#if rev
          if((j==-1)|(vj<vk))
#else
          if((j==-1)|(vj>vk))
#endif
          {
            l=plist[k];
            plist[k]=plist[m];
            plist[m]=k;
            m=k;
            k=l;
            vk=vlist[k];
          }else{
            m=j;
            j=plist[j];
            vj=vlist[j];
          }
        }
      }
    }
    if(h==ss){
      c[h][0]=s;
    }else{
#if rev
      plist[c[h+1][1]]=s;
#else
      plist[c[h-1][1]]=s;
#endif
    }
    for(i=c[h][2];i!=-1;i=plist[i]) j=i;
    c[h][1]=j;
  }
  return(c[ss][0]);
}
    
int main(){
  int n,i,j,k,a[2][200006],b[2],c[200005],d[2],m;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<2;j++){
      scanf("%d",&a[j][i]);
    }
  }
  for(i=0;i<2;i++){
    j=sort(&a[i],&c,n);
    for(k=0;k<((n-1)>>1);k++){
      j=c[j];
    }
    b[i]=a[i][j];
    d[i]=a[i][j]+a[i][c[j]];
  }
  if(n&1){
    m=b[1]-b[0]+1;
  }else{
    m=d[1]-d[0]+1;
  }
  printf("%d",m);
  return(0);
}

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


void solve(long long N, long long D, std::vector<long long> X, std::vector<long long> Y){
    long long D2 = D * D;

    long long counter = 0;
    for(long long i = 0; i < N; i++) {
        if(X[i] * X[i] + Y[i] * Y[i] <= D2) {
            ++counter;
        }
    }
    cout << counter << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    std::vector<long long> X(N);
    std::vector<long long> Y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&Y[i]);
    }
    solve(N, D, std::move(X), std::move(Y));
    return 0;
}


Measured memory_bytes: 6408
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

template<lint MOD> struct Mint {
    lint v;
    Mint() { v = 0; }
    Mint(lint x) { v = x % MOD; if(v < 0)  v += MOD; }

    Mint operator-() { return Mint{-v}; };
    Mint operator+(Mint x) { return Mint(v + x.v); };
    Mint operator-(Mint x) { return Mint(v - x.v); };
    Mint operator*(Mint x) { return Mint(v * x.v); };
    Mint operator/(Mint x) { return Mint(v * pow(x.v, MOD-2).v); };

    Mint& operator+=(Mint x) { return *this = (*this + x); };
    Mint& operator-=(Mint x) { return *this = (*this - x); };
    Mint& operator*=(Mint x) { return *this = (*this * x); };
    Mint& operator/=(Mint x) { return *this = (*this / x); };

    static Mint pow(Mint base, lint exp) {
        if(exp == 0)  return Mint(1);
        return pow(base*base, exp/2) * (exp&1 ? base : Mint(1));
    }

    friend ostream& operator<<(ostream& os, Mint x) { return os << x.v; }
};
using mint = Mint<1000000007>;

mint gcd(mint a, mint b) {
    return b.v == 0 ? a : gcd(b, a-(a/b)*b);
}

// O(√n)
map<lint, lint> prime_factor(lint n) {
    map<lint, lint> res;
    for(lint i=2; i*i<=n; i++) {
        while(n%i == 0)  res[i]++, n/=i;
    }
    if(n != 1)  res[n] = 1;
    return res;
}

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

    vector<lint> a(n);
    for(auto& elem : a)  cin >> elem;

    // 普通にやるとオーバーフローしそうなので、素因数分解した数を保持することにする
    vector<map<lint, lint>> pf(n);

    for(lint i=0; i<n; i++) {
        pf[i] = prime_factor(a[i]);
    }

    map<lint, lint> lcmp;

    for(lint i=0; i<n; i++) {
        for(auto& e : pf[i]) {
            lcmp[e.first] = max(lcmp[e.first], e.second);
        }
    }

    mint lcm = 1;
    for(auto& e : lcmp) {
        lcm *= mint::pow(mint{e.first}, e.second);
    }

    mint ans = 0;
    for(lint i=0; i<n; i++) {
        ans += lcm / mint(a[i]);
    }

    cout << ans << endl;
}

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

using namespace std;
int N , a , K;
vector <int> v , rez;


int main(){
	cin>>N>>K;
	rez.insert(rez.begin(),N,1000000005);
	for (int i=0;i<N;i++)
	{
		cin>>a;
		v.push_back(a);
	}
	int br;
	rez[0]=0;
	for (int i=1;i<N;i++)
	{
		br=i;
		for (int j=i-1;j>=0 && j>=i-K;j--)
		{
			rez[i]=min(rez[i],abs(v[j]-v[i])+rez[j]);
		}
	}
	
	cout<<rez[N-1];
	
	return 0;
}


Measured memory_bytes: 1276
fn main() {
    let nk = read_vec::<usize>();
    let mut v: Vec<char> = {
        let s = read::<String>();
        s.chars().into_iter().collect()
    };
    for i in 0..nk[0] {
        if i == nk[1] - 1 {
            let c = v[i];
            v[i] = ((c as u8) + 32) as char;
        }
    }
    let ret: String = v.into_iter().collect();
    println!("{}", ret);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include<stdio.h>
 
struct dice
{
    int n[6] ; //number
};
struct dice dice1 ;
 
 
int east()
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[3] ;
    dice1.n[3] = dice1.n[5] ;
    dice1.n[5] = dice1.n[2] ;
    dice1.n[2] = mem ;
}
 
int west()
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[2] ;
    dice1.n[2] = dice1.n[5] ;
    dice1.n[5] = dice1.n[3] ;
    dice1.n[3] = mem ;
}
 
int south()
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[4] ;
    dice1.n[4] = dice1.n[5] ;
    dice1.n[5] = dice1.n[1] ;
    dice1.n[1] = mem ;
}
 
int north()
{
    int mem = 0 ;
    mem = dice1.n[0] ;
    dice1.n[0] = dice1.n[1] ;
    dice1.n[1] = dice1.n[5] ;
    dice1.n[5] = dice1.n[4] ;
    dice1.n[4] = mem ;
}
 
int main()
{
    int i=0 ;
    int cmp=0 ;
 
    char a[101] = {0} ;
 
    for (i=0 ;i < 6 ;i++)
    {
        scanf("%d" ,&cmp) ;
 
        dice1.n[i] = cmp ;
 
    }
    scanf("%s" ,a) ;
 
    for (i=0 ;i < 101 ;i++)
    {
        if (a[i] == '\0') break ;
 
        if (a[i] == 'E') east() ;
        if (a[i] == 'W') west() ;
        if (a[i] == 'S') south() ;
        if (a[i] == 'N') north() ;
 
    }
 
    printf ("%d\n" ,dice1.n[0]) ;
    return 0 ;
}


Measured memory_bytes: 2120
#include<stdio.h>
int main(void){
    int max = -1000001, min = 1000001, input, N;
    long int sum = 0;
    scanf("%d", &N);
    while(N > 0){
        scanf("%d", &input);
        if(max < input) max = input;
        if(min > input) min = input;
        sum += input;
        N--;
    }
    printf("%d %d %ld\n", min, max, sum);
    return 0;
}


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


int main(){
  int n;
  cin >> n;
  for(int i=1;i<=n;i++){
    int x=i;
    if (x%3 == 0)
      cout << " " << i;
    else
      if (x%10 == 3)
        cout << " " << i;
      else{
        while(x /= 10){
          if (x%10 == 3){
            cout << " " << i;
            break;
          }
        }
      }
  }
  cout << endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define _ ios::sync_with_stdio(false);cin.tie(0);
#define __ cout<<fixed;cout<<setprecision(10);
#define int long long

void solve() {
	int n;
	cin >> n;
	if (n >= 30) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

int32_t main() {
	_ __
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}

#ifndef ONLINE_JUDGE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif

	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        long n = fs.nextLong();
        System.out.println(n*(n-1)/2);
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
 
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22356
#include<bits/stdc++.h>
#define LL long long
#define rep(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
using namespace std;
static const LL INF = 1LL<<60LL;
typedef pair<LL,LL> PLL;

LL N,M;
LL ans=INF;
LL V[160][15];
LL K[160][15];
LL mem[160][15][80][3];


LL cal(int y,int x,int m,int f){
    LL res=INF;
    if(mem[y][x][m][f]!=-1){
        return mem[y][x][m][f];
    }
    if(y==N-1&&f==2)return 0;
    else if(y==N&&f==1)return 0;
    rep(i,10){
        LL d1,d2;
        if(m>0&&K[y+1][i]&&K[y+2][i]&&y+2<=N){
            d1=(K[y][x]+K[y+1][i])*abs(V[y][x]-V[y+1][i]);
            d2=(K[y][x]+K[y+2][i])*abs(V[y][x]-V[y+2][i]);
            res=min(cal(y+1,i,m,f)+d1,min(cal(y+2,i,m-1,f)+d2,res));
        }
        else if(K[y+1][i]){
            d1=(K[y][x]+K[y+1][i])*abs(V[y][x]-V[y+1][i]);
            res=min(cal(y+1,i,m,f)+d1,res);
        }
        else if(K[y+2][i]&&m>0&&y+2<=N){
            d2=(K[y][x]+K[y+2][i])*abs(V[y][x]-V[y+2][i]);
            res=min(cal(y+2,i,m-1,f)+d2,res);
        }
    }
    return mem[y][x][m][f]=res;
}


int main(){
    while(1){
        cin>>N>>M;
        if(N==0&&M==0)break;
        memset(mem,-1,sizeof(mem));
        memset(V,0,sizeof(V));
        memset(K,0,sizeof(K));
        FOR(i,1,N){
            LL t;
            cin>>t;
            rep(j,t){
                LL x,k;
                cin>>x>>k;
                V[i][j]=x;
                K[i][j]=k;
            }
        }
        rep(j,10){
            if(K[1][j]&&K[2][j]&&M>0){
                ans=min(cal(1,j,M,1),min(cal(2,j,M-1,2),ans));
            }
            else if(K[1][j]){
                ans=min(cal(1,j,M,1),ans);
            }
            else if(M>0)ans=min(cal(2,j,M-1,2),ans);
        }
        cout<<ans<<endl;
        ans=INF;
    }
    return 0;
}

Measured memory_bytes: 5724
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1};
const vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0};
const vi d4y = {0, 1, 0, -1};

//---------------from here-----------------

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

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
#define lint long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807

void solve()
{
  double a,b,h,x;
  cin>>a>>b>>x;

  if(x < a*a*b/2)
  {
  h = 2*x/a/b;
  double t;
  t = atan(h/b);
  cout<<fixed;
  cout<<setprecision(8);
  cout<<90 - t* 180 /M_PI<<endl;
  }
  else
  {
   double y;
  y = a*a*b -x;
  h = 2*y/a/a;
  double t;
  t = atan(a/h);
  cout<<fixed;
  cout<<setprecision(8);
  cout<< 90 - t* 180 /M_PI<<endl;   
  }
  



  return;
}

int main(int argc, const char *argv[])
{

  solve();

  return 0;
}


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

signed main(){
    int n;
    cin >> n;
    int a[n];
    vector<int> x[n], y[n]; 
    REP(i,n){
        cin >> a[i];
        REP(j,a[i]){
            int X,Y;
            cin >> X >> Y;
            X--;
            x[i].emplace_back(X);
            y[i].emplace_back(Y);
        }
    }
    int ans = 0;
    for(int bit = 0; bit < 1 << n; bit++){
        int cnt = 0;
        REP(i,n){
            if(!(bit & 1 << i)) continue;
            REP(j,a[i]){
                if(y[i][j] == 1 && !(bit & 1 << x[i][j])){
                    goto no;
                }else if(y[i][j] == 0 && (bit & 1 << x[i][j])){
                    goto no;
                }
            }
        }
        REP(i,n){
            if(bit & 1 << i) cnt++;
        }
        ans = max(ans, cnt);
        no:;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	cin>>a;
	cin>>s;
	
	if(a%2==1) cout<<"No"<<endl;
	else {
		int f=1;
		for(int i=0;i<s.size()/2;i++)
			if(s[i]!=s[s.size()/2+i]){
				f=0;
				break;
			}
		if(f==1) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

int main(){

  string S; cin >> S;
  
  int N = S.length();

  long long DP[N][13];

  for (int i = 0; i < N; i++){
    for (int j = 0; j < 13; j++){
      DP[i][j] = 0;
    }
  }
  

  if (S[0] == '?'){
    for (int i = 0; i < 10; i++){
      DP[0][i] = 1;
    }
    for (int i = 10; i < 13; i++){
      DP[0][i] = 0;
    }
  }else{
    int a = S[0] - '0';
    for (int i = 0; i < 13; i++){
      if (i == a) DP[0][i] = 1;
      else DP[0][i] = 0;
    }
  }

  const int nmax = 1e9 + 7;
  for (int i = 1; i < N; i++){
    if (S[i] == '?'){
      for (int j = 0; j < 13; j++){
        for (int k = 0; k < 10; k++){
          DP[i][(j * 10 + k) % 13] += DP[i - 1][j];
        }
      }
    }else{
      int A = S[i] - '0';
      for (int j = 0; j < 13; j++){
        DP[i][(j * 10 + A) % 13] += DP[i - 1][j];
      }
    }

    for (int j = 0; j < 13; j++){
      DP[i][j] = DP[i][j] % nmax;
    }
  }
  
  cout << DP[N - 1][5] << endl;
  
  
  return 0;
}


Measured memory_bytes: 10624
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    // 10:33-
    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            String s = sc.next();
            out.println(Math.min(c(s, 0), c(s, 1)));
        }
    }

    private static int c(String s, int x) {
        int cost = 0;
        for (int i = 0; i < s.length(); i++) {
            if ((s.charAt(i) - '0') != x) cost++;
            x = 1 - x;
        }
        return cost;
    }
}


Measured memory_bytes: 24040
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#include <cstring>
using namespace std;
typedef long long ll;
ll INF=1<<29;

int main(){
	ios::sync_with_stdio(false);
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=c && c<=b){
		cout<<"Yes";
	}else if(a>=c && c>=b){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 764
import java.util.*;
public class Main { 
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		while(true) {
			int n = stdIn.nextInt();
			int k = stdIn.nextInt();
			int m = stdIn.nextInt();
			if(n == 0 && k == 0 && m == 0) break;
			list = new ArrayList<Integer>();
			for(int i = 0; i < n; i++) {
				list.add(i+1);
			}
			int nowp = m-1;
			list.remove(nowp);
			n-=1;
			while(n != 1) {
				nowp += k-1;
				nowp %= n;
				list.remove(nowp);
				n--;
			}
			
			System.out.println(list.get(0));
		}
	}
}

Measured memory_bytes: 38064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int V[] = {1, 5, 10, 50, 100, 500};
		Scanner sr = new Scanner(System.in);


		while(true) {

			int count = sr.nextInt();

			if(count == 0) break;


			int change = 1000 - count;
			int sum = 0;
			for(int i=5; i >= 0; i--) {
				int k = change / V[i];
				change -= k * V[i];
				sum += k;
			}

			System.out.println(sum);
		}

		sr.close();

	}

}


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

int main() {
  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;

  vector<string> ans(n);
  int cnt_a = 0, cnt_b = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'a' &&  cnt_a + cnt_b < a + b) {
      ans[i] = "Yes";
      cnt_a++;
    }
    else if (s[i] == 'b' &&  cnt_a + cnt_b < a + b &&  cnt_b < b) {
      ans[i] = "Yes";
      cnt_b++;
    }
    else {
      ans[i] = "No";
    }
  }


  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
}

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

int main() {
	int k;
	string s;
	cin >> k >> s;
	int n = s.size();
	if (s.size() <= k) {
		cout << s << endl;
		return 0;
	}
	s = s.substr(0, k);
	s += "...";
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int dice[] = new int[6];
		int pip[] = new int[6];
		int order_length = 0;
		int count = 0;
		String order;
		
		//サイコロの目の入力
		dice =  make_dice(scanner);
		
		pip = dice;
		
		//命令数取得
		order = scanner.next();
		order_length = order.length();
		String[] order_box = new String[order_length];	
		
		for( int i = 0; i < order_length ; i ++ ) {
			order_box[i] = order.substring(i, i+1);
		}

		//命令数実行
		while(true ){
			//命令ごとに処理
			switch( order_box[count] ) {
			case "N":
				pip = diceroll_n(pip);
				break;
			case "E":
				pip = diceroll_e(pip);
				break;
			case "S":
				pip = diceroll_s(pip);
				break;
			case "W":
				pip = diceroll_w(pip);
				break;
				
			default :
				break;
			}
			
			count ++;
			if( count >= order_length){
				break;
			}
		}
		//1番上出力
		System.out.println(pip[0]);
		
		scanner.close();
	}
	
	public static int[] make_dice ( Scanner scanner){
		int dice[] = new int[6];
		
		for(int i = 0; i < 6; i ++){
			dice[i] = scanner.nextInt();
		}
		
		return dice;
	}

	public static int[] diceroll_n(int[] pip){
		int dice[] = new int[6];
		for(int i = 0; i < 6; i ++){
			dice[i] = pip[i];
		}
		pip[0] = dice[1];
		pip[1] = dice[5];
		pip[2] = dice[2];
		pip[3] = dice[3];
		pip[4] = dice[0];
		pip[5] = dice[4];
		
		return pip;
	}

	public static int[] diceroll_e (int[] pip){
		int dice[] = new int[6];
		for(int i = 0; i < 6; i ++){
			dice[i] = pip[i];
		}
		pip[0] = dice[3];
		pip[1] = dice[1];
		pip[2] = dice[0];
		pip[3] = dice[5];
		pip[4] = dice[4];
		pip[5] = dice[2];
		
		return pip;
	}

	public static int[] diceroll_w (int[] pip){
		int dice[] = new int[6];
		for(int i = 0; i < 6; i ++){
			dice[i] = pip[i];
		}
		pip[0] = dice[2];
		pip[1] = dice[1];
		pip[2] = dice[5];
		pip[3] = dice[0];
		pip[4] = dice[4];
		pip[5] = dice[3];
		
		return pip;
	}

	public static int[] diceroll_s (int[] pip){
		int dice[] = new int[6];
		for(int i = 0; i < 6; i ++){
			dice[i] = pip[i];
		}
		pip[0] = dice[4];
		pip[1] = dice[0];
		pip[2] = dice[2];
		pip[3] = dice[3];
		pip[4] = dice[5];
		pip[5] = dice[1];
		
		return pip;
	}
	
}



Measured memory_bytes: 26308