akhauriyash/Code-Regression huggingface dataset:
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE BangPatterns #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust, fromMaybe )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.IO as IOA
import qualified Data.Array.MArray as MA
import Control.Monad.ST
import System.IO (stdin)
import Control.Arrow
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Generic as GV



readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- readInts
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- readInts
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

main = do
    n <- readInt
    ss <- replicateM n BC.getLine
    print $ S.size $ S.fromList ss


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

int main() {
  int d;
  cin >> d;
  if(d == 25) cout << "Christmas" << endl;
  else if (d == 24) cout << "Christmas Eve" << endl;
  else if (d == 23) cout << "Christmas Eve Eve" << endl;
  else cout << "Christmas Eve Eve Eve" << endl;
}


Measured memory_bytes: 3580
import numpy as np
input()
A = np.array(input().split(), dtype=np.int64)
S = np.sign(A)
A = np.abs(A)
if 0 in S or not ((S == -1).sum() & 1):
    print(A.sum())
else:
    A.sort()
    print(A.sum() - A[0] * 2)


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

int main() {
  ll N;
  cin >> N; // <= 10^10

  int ans = 11;
  for (ll a = 1; a <= (sqrt(N) + 1); a++) {
    ll reminder = N % a;
    ll b = N / a;

    if (reminder != 0) {
      continue;
    }
    int len = max(to_string(a).size(), to_string(b).size());
    ans = min(ans, len);
  }

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

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define N 100010
int a[N],s[N],b[N],c[N];
void ssort(int *a,int x,int y)
{
    if(y-x<=1)
        return;
    int mid=(x+y)/2;
    ssort(a,x,mid);
    ssort(a,mid,y);
    int i,j,k;
    i=x;
    j=mid;
    k=x;
    while(i<mid||j<y)
    {
        if(j>=y||(i<mid&&a[i]<=a[j]))
            s[k++]=a[i++];
        else
            s[k++]=a[j++];
    }
    for(i=x;i<y;i++)
        a[i]=s[i];
}
int main()
{
    int i,j,k,n,l,r,mid,p1,p2;
    long long ans;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    scanf("%d",&a[i]);
    for(i=1;i<=n;i++)
    scanf("%d",&b[i]);
    for(i=1;i<=n;i++)
    scanf("%d",&c[i]);
    ssort(a,1,n+1);
    ssort(b,1,n+1);
    ssort(c,1,n+1);
    ans=0;
    for(i=1;i<=n;i++)
    {
        if(b[i]<=a[1])
        continue;
        if(b[i]>=c[n])
        continue;
        p1=1;
        l=1;
        r=n;
        while(l<=r)
        {
            mid=(l+r)/2;
            if(a[mid]<b[i])
            {
                p1=max(p1,mid);
                l=mid+1;
            }
            else
            r=mid-1;
        }
        p2=n;
        l=1;
        r=n;
        while(l<=r)
        {
            mid=(l+r)/2;
            if(c[mid]>b[i])
            {
                p2=min(p2,mid);
                r=mid-1;
            }
            else
            l=mid+1;
        }
        ans=ans+(long long)p1*(n-p2+1);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1664
a = input()
a1 = int(a[:2])
a2 = int(a[2:])
b1 = False
b2 = False
if 1 <= a1 <= 12:
    b1 = True
    
if 1 <= a2 <= 12:
    b2 = True

if b1 and b2:
    print('AMBIGUOUS')
    
elif b1:
    print('MMYY')

elif b2:
    print('YYMM')

else:
    print('NA')

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

class ORDER {
public:
	int N;
	char S;
	void ARARE() {
		cin >> N;
		int temp = 0;
		while (1) {
			temp++;
			cin >> S;
			if (S == 'Y') {
				cout << "Four" << endl;
				break;
			}
			if (temp == N) {
				cout << "Three" << endl;
				break;
			}
		}
	}
};

int main() {
	ORDER x;
	x.ARARE();
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <set>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(){
	int N;
	scanf("%d",&N);
	vector<int>a(N);
	set<int>h;
	int r=2;
	for(int i=0;i<N;i++)scanf("%d",&a[i]),h.insert(a[i]);
	sort(a.begin(),a.end());
	for(int i=0;i<N;i++)for(int j=i+1;j<N;j++){
		int d=a[j]-a[i];
		int k=2;
		for(;;k++)if(h.find(a[i]+d*k)==h.end())break;
		r=max(r,k);
	}
	printf("%d\n",r);
}


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


int main(){
	int k,n;
  	cin >> k >> n;
    int l, i=0, a[n];
    while(cin>>l){
        a[i] = l;
        i++;
    }
  	int ans;
  	int sub, sub_max;
  	sub_max = k-a[n-1] + a[0];
  //	cout << sub_max << endl; 
  	for(int k=0; k < n-1; k++ ){
      sub = a[k+1] - a[k];
      if(sub > sub_max){
      sub_max = sub;
      }
    }
  	ans = k-sub_max;
  	cout << ans << endl;
    

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<map<ll, ll>> dp(n + 1);

  dp[0][0] = 1000;

  for (int i = 0; i < n; i++) {
    for (auto v : dp[i]) {
      ll j = v.second / a[i];
      dp[i + 1][v.first] = max(dp[i][v.first], dp[i + 1][v.first]);
      dp[i + 1][0] = max(dp[i + 1][0], dp[i][v.first] + v.first * a[i]);
      dp[i + 1][j] = max(dp[i + 1][j], v.second - j * a[i]);
    }
  }
  cout << dp[n][0] << endl;
  return 0;
} 


Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

int digsum(int x){
	int sm = 0;
	while(x > 0){
		sm += x % 10;
		x /= 10;
	}

	return sm;
}

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

	int n, a, b;
	cin >> n >> a >> b;

	int ans = 0;
	for(int i = 1; i <= n; i++){
		int dsum = digsum(i);
		if(a <= dsum && dsum <= b) ans += i;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int a, b;
    string s;
    cin >> a >> b >> s;
    for (int i = 0; i < s.size(); i++) {
        if (i != a && s.at(i) == '-') {
            cout << "No" << endl;
            return 0;
        }
        if (i == a && s.at(i) != '-') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

int main(){
  int n,cnt=0,judge=0;
  cin >> n;
  rep(i,n){
    int a,b;
    cin >> a >> b;
    if(a==b) cnt++;
    if(a!=b) cnt=0;
    if(cnt==3) judge=1; 
    
  }
  if(judge==1){
    cout << "Yes" << endl;
    return 0;
  }
  if(judge==0){
    cout << "No" << endl;
    return 0;
}
}

Measured memory_bytes: 3536
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		boolean flag =true;
		int n=sc.nextInt();
		for(int i=0;i<n;i++) {
			int m=sc.nextInt();
			if(m%2==0&&(m%5!=0&&m%3!=0)) {
				flag=false;
				break;
			}
		}
		if (flag)System.out.println("APPROVED");
		else System.out.println("DENIED");
	}
	
} 

Measured memory_bytes: 22996
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL


struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;


Node root;

/*Node treeSearch(Node u, int k){
  if(x == NIL || k == x.key)  return x;
  if(k < x.key)  return treeSearch(u.left , k);
  else return treeSearch(u.right , k);
  }
  
  
  //Node treeMinimum(Node x){}
  //Node treeSuccessor(Node x){}
  
  void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  }*/


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y = x;
    if(z->key < x->key)
      x = x->left;
    else 
      x = x->right;
  }
  
  z->parent = y;
  if(y==NIL){
    root = z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else
    y->right = z;
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}

void preorder(Node u){ 
  if(u != NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
    else if ( com[0] == 'p' ){
      inorder(root);
      
      printf("\n");
      
      preorder(root);
      
      printf("\n");
    }
  }
  
  return 0;
}

Measured memory_bytes: 24036
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int PortA = sc.nextInt();
    int PortB = sc.nextInt();
    int PortC = sc.nextInt();
    int Time[]= new int[6];
    
    Time[0]=PortA+PortB;
    Time[1]=PortC+PortB;
    Time[2]=PortA+PortC;
    Time[3]=PortB+PortC;
    Time[4]=PortC+PortA;
    Time[5]=PortB+PortA;
   

	int max = Time[0];
	int min = Time[1];
for (int i = 1; i < Time.length; i++) {
    int v = Time[i];
    if (v > max) {
        max = v;
    }
    if (v < min) {
        min = v;
    }
}


System.out.println(min); 
  }
}



Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <stack>

using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r,int c){
	stack<int> S;
	S.push(r);
	color[r]=c;
	while(!S.empty()){
		int u=S.top();S.pop();
		for(int i=0;i<G[u].size();i++){
			int v=G[u][i];
			if(color[v]==NIL){
				color[v]=c;
				S.push(v);
			}
		}
	}
}

void assignColor(){
	int id = 1;
	for(int i=0;i<n;i++) color[i]=NIL;
	for(int u=0;u<n;u++){
		if(color[u]==NIL) dfs(u,id++);
	}
}


int main() {
	int s,t,m,q;
	
	cin>>n>>m;
	
	for(int i=0;i<m;i++){
		cin>>s>>t;
		G[s].push_back(t);
		G[t].push_back(s);
	}
	
	assignColor();
	
	cin>>q;
	
	for(int i=0;i<q;i++){
		cin>>s>>t;
		if(color[s]==color[t]){
			cout<<"yes"<<endl;
		}else{
			cout<<"no"<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 8944
from itertools import accumulate
from math import*
from collections import deque
from collections import defaultdict
from itertools import permutations
from heapq import*
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
from functools import reduce

n,k = map(int,input().split())
h = [inf]*(n+k)
high = list(map(int,input().split()))
for i in range(n):
    h[i] = high[i]
dp = [inf]*(n+k)
dp[0] = 0
for i in range(n):
    for j in range(1,k+1):
        dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]))
print(dp[n-1])


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

#define ll long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define MOD 1000000007
#define println(x) cout << "[" << #x << ":" << x << "]\n"; 
#define print(x) cout << "[" << #x << ":" << x << "] "; 

const int mxN = 2e5 + 1;
int n;
string s;
int a[mxN];

int main(){
    cin >> n >> s;
    for(int i=0; i<n; i++){
	a[i+1] = a[i] + (s[i] == 'R');
    }
    int ans = INT_MAX;
    for(int i=0; i<=n; i++){
	int wrongW = a[n] - a[i];
	int wrongR = i - a[i];
	ans = min(ans, max(wrongW, wrongR)); 
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4464
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
using namespace std;
bool isprime(int);
int main() {
	int n=0;

	cin >> n;
	int num=n;
	while(1){
		if (isprime(num))break;
		num++;
	}
	cout << num << endl;
	return 0;
}

bool isprime(int nm){
	if (nm < 2 ) return false;
	if (nm == 2 ) return true;
	if (nm % 2 == 0 ) return false;
	double t = sqrt(nm);
	for (int j=3; j<=t; j+=2 ){
		if (nm % j == 0){
			return false;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,a,b;
	long long t;
	cin>>n>>a>>b;
	if(n==1){
		if(a==b)
			cout<<"1"<<endl;
		else cout<<"0"<<endl;
	}else{
		if(a>b)
			cout<<"0"<<endl;
		else
			cout<<(long long)(b-a)*(n-2)+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2019/0106_educational_dp#%E8%A7%A3%E6%B3%953

n = int(input())
a = list(map(int, input().split()))

dp = [[0] * (n + 1) for i in range(n + 1)]

for w in range(1, n + 1):
    for l in range(n - w + 1):
        r = l + w
        dpl = a[l] - dp[l + 1][r]
        dpr = a[r - 1] - dp[l][r - 1]
        dp[l][r] = max(dpl, dpr)

print(dp[0][n])


Measured memory_bytes: 112732
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if((a<c&&c<b)||(b<c&&c<a))System.out.println("Yes");
    else System.out.println("No");
  }
}


Measured memory_bytes: 21204
#include <stdio.h>
int main(){
    int n, Y, x = 0, y, z;
    scanf("%d %d", &n, &Y);
    Y /= 1000;
    while(true){
        for(y = 0; y <= n - x; y++){
            z = n - x - y;
            if(10*x + 5*y + z == Y){
                printf("%d %d %d", x, y, z);
                return 0;
            }
        }
        if(x == n) break;
        else x++;
    }

    printf("-1 -1 -1");
    return 0;
}

Measured memory_bytes: 128
#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];
	long long f[n];
	f[0]=0;
	f[1]=abs(a[1]-a[0]);
	f[2]=abs(a[2]-a[0]);
	for(int i=3;i<n;i++){
		f[i]=min(f[i-1]+abs(a[i]-a[i-1]), f[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<f[n-1]<<"\n";
	return 0;
}

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

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define max_heap priority_queue <int> pq; // max heap 
#define min_heap priority_queue <int, vector<int>, greater<int> > pq;  //min heap
#define make_pairVector vector<pair<long long int,long long int> > pairVector // vector of pairs
#define hashmap unordered_map<long long int, long long int>hashmap;
#define pb push_back

//transform(s.begin(), s.end(), s.begin(), ::tolower); //to convert a string entirely to lower case

//toupper(s[i]) or tolower(s[i]) // converting a character to upper or lower case

//map<pair<ll,ll>, ll > hash;          // pair,value hashmap where key is a pair
//hash[make_pair(i,j)] = 0;
//if(hash.find(make_pair(i,j)) == hash.end())


//map<ll,ll>::iterator itr;           // iterating a map
//for (itr = hash.begin();itr != hash.end(); itr++)
//{
//   itr->first = key  
//   itr->second = value
//}


// vector<string> v; //to convert vector to a set
// set<string> s(v.begin(), v.end());


// set<string>s;     // to convert set to a vector
// vector<string> v(s.begin(),s.end());


// cin >> x >> y;
// pairVector.pb(mp(x,y));


// string size = str.size()


// stack <int> s; 


// queue <int> gquiz; 


// __gcd(m, n) 

// ll arr[10e5 + 5];


// char arr[10e5 + 5];


//vec.insert(v.begin(),value)   -> to insert a value in the vector at the begin

// printf ("%.9f\n",x);
// cout << fixed << setprecision(9);

//covert integer to string :  to_string(integer)

bool sortbysec(const pair<long long int,long long int> &a, const pair<long long int,long long int> &b) 
{ 
    return (a.second < b.second); 
}
bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
int check_key(map<long long int, long long int> m, long long int key) 
{ 
    // Key is not present 
    if (m.find(key) == m.end()) 
        return 0; 
  
    return 1; 
} 

void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}

int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n;
    cin >> n;
    if(n%1000 == 0)
        cout << 0 << endl;
    else
    {
           ll q = n/1000;
           q+=1;
           q*=1000;
           cout << q - n << endl;
    }
    return 0;
}   

Measured memory_bytes: 3652
import sys
from math import log2,floor,ceil,sqrt
# import bisect
# from collections import deque
sys.setrecursionlimit(7*10**4)

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
 
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD =  998244353

# for _ in range(int(ri())):
a,b,c,d   = Ri()
tt = ceil(c/b)
ot = ceil(a/d)

if ot < tt:
    No()
else:
    Yes()


Measured memory_bytes: 62344
/**
*    author:  souzai32
*    created: 02.08.2020 00:03:56
**/

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

int main() {

    long long int n;
    cin >> n;

    long long num=0;
    long long int p=1;
    int length=1;
    while(1){
        p*=26;
        num+=p;
        //cout << num << endl;
        if(num>=n) break;
        else length++;
    }

    //vector<int> name(length);
    vector<char> name(length,'a');
//    cout << n << endl;

    for(int i=0; i<length; i++){
        n--;
        name.at(length-i-1)+=n%26;
        n/=26;
    }
    //name.at(length-1)++;

    
    for(int i=0; i<length; i++){
        cout << name.at(i);
    }
    cout << endl;

    //cout << length << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int a, b;
    cin >> a >> b;

    int ans = -100000000;

    ans = max(ans, a + b);
    ans = max(ans, a - b);
    ans = max(ans, a * b);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
   long n,a,b,f,l;
   int i;

   scanf("%ld %ld",&n,&a);
   f=1;
   l=f+(n+a-1)/a-1;
   for (i=0;i<4;i++) {
      scanf("%ld",&b);
      f++;
      if (a>b) {
         l=f+(n+b-1)/b-1;
      } else {
         l++;
      }
      if (b<a) a=b;
   }
   printf("%ld\n",l);
   return 0;
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) ;
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

int dx[4]{0, 1, 0, -1};
int dy[4]{1, 0, -1, 0};



int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll N, K; cin >> N >> K;
	vector<ll> P(N); REP(i, N) cin >> P[i], --P[i];
	vector<ll> C(N); REP(i, N) cin >> C[i];

	ll res{-INF};
	REP(init, N)
	{
		ll now = init;
		vector<ll> his;
		ll t{0};

		while (true)
		{
			now = P[now];
			t += C[now];
			his.push_back(t);
			if (now == init) break;
		}

		ll S = his.size();

		if (S >= K)
		{
			REP(i, K)
				res = max(res, his[i]);
		}
		else
		{
			ll q = K / S;
			if (his.back() > 0)
			{
				if (q > 1)
				{
					REP(i, S)
						res = max(res, his[i] + (q-1)*his.back());
				}

				REP(i, K%S)
					res = max(res, his[i] + q * his.back());
			}
			else
			{
				REP(i, S)
					res = max(res, his[i]);
			}
		}
	}

	std::cout << res << std::endl;
	
	return 0;
}


Measured memory_bytes: 3788
n = int(input())
t, a = map(int, input().split())
h = list(map(int,input().split()))

min = abs(t-h[0]*0.006 - a)
ans = 1

for i in range(n):
    if abs(t-h[i]*0.006 - a) < min:
        min = abs(t-h[i]*0.006 - a)
        ans = i + 1
print(ans)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

  static Scanner sc = new Scanner(System.in);


  public static void main(String[] args) {
    String answer = "";
    for (int i = 0; i < 3; i++) {
      String a = sc.next();
      answer += a.substring(i, i + 1);
    }
    System.out.println(answer);
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(in) in.begin(), in.end()
#define FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main(){
    FIO;
    ll n;   cin >> n;
    vector<pair<ll, ll> > v;
    for(ll i = 0 ; i < n ; i++){
        ll x;   cin >> x;
        v.push_back({x, i});
    }
    sort(all(v));
    for(ll i = 0 ; i < n ; i++){
        cout << v[i].second + 1 << " ";
    }
    return 0;
}


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

int main() {
    string s;
    cin>>s;
    int l=-1,r=s.size();
    while(++l<s.size()) if(s[l]=='A') break;
    while(--r>=0) if(s[r]=='Z') break;
    cout<<r-l+1<<endl;
}


Measured memory_bytes: 640
#coding:UTF-8
def Check(P,k,w):
    i=0
    for j in range(k):
        s=0
        while s+w[i]<=P:
            s+=w[i]
            i+=1
            if i==n:
                return n
    return i

def Allocation(n,k,w):
    left=0
    right=100000000000000
    while right-left > 1:
        mid=int((left+right)/2)
        v=Check(mid,k,w)
        if v>=n:
            right=mid
        else:
            left=mid
    print(right)
  
if __name__=="__main__":
    a=input()
    n=int(a.split(" ")[0])
    k=int(a.split(" ")[1])
    w=[]
    for i in range(n):
        w.append(int(input()))
    Allocation(n,k,w)

Measured memory_bytes: 11536
#include <iostream>
int main(){
	int w[10], k[10];
	for (int i = 0; i < 10; i++) {
		std::cin >> w[i];
	}
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 9; j++) {
			if (w[j] < w[j + 1]) {
				int c = w[j];
				w[j] = w[j + 1];
				w[j + 1] = c;
			}
		}
	}
	for (int i = 0; i < 10; i++) {
		std::cin >> k[i];
	}
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 9; j++) {
			if (k[j] < k[j + 1]) {
				int c = k[j];
				k[j] = k[j + 1];
				k[j + 1] = c;
			}
		}
	}
	std::cout << w[0] + w[1] + w[2] << " " << k[0] + k[1] + k[2] << std::endl;
}

Measured memory_bytes: 2984
#!/bin/ruby

n = gets.chomp.to_i
otoshidamas = []
n.times do |i|
  otoshidamas[i] = gets.chomp.split(" ")
end
total = 0
otoshidamas.each do |otoshidama|
  value = otoshidama[0].to_f
  if otoshidama[1] == 'JPY'
    total += value
  else
    total += value * 380000.0
  end
end
puts total


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>

using namespace std;

bool comp( string s1, string s2 ) {
	
	for(int i = 0; i < s1.length() ; i++ ) {
		if( s1[i] > s2[i] ) return true;
		else if( s1[i] < s2[i] ) return false;
		else continue;
	}
	return false;
}

int isLarger( string s1, string s2 ) {
	
	string s3;
	string s4;
	if( s1.length() > s2.length() ) {
		s4.append( s1.length() - s2.length(), '0');
		s4 += s2;
		s3 = s1;
	} else if( s1.length() < s2.length() ) {
		s3.append(s2.length() - s1.length() , '0' );
		s3 += s1;
		s4 = s2;
	} else {
		s3 = s1;
		s4 = s2;
	}
	int flg = comp( s3, s4 );

	return flg;
}

void add( char c[70][70], string s, string dp[70][70], int w, int h, int x, int y) {
	if( x < 0 || x >= w || y < 0 || y >= h ) return;
	if( c[x][y] < '0' || c[x][y] > '9' ) return;
	string s1 = dp[x][y];
	string s2 = c[x][y] + s;
	if( isLarger( s1, s2 ) ) dp[x][y] = s1;
	else dp[x][y] = s2;
}

void output( string s ) {

	bool flg = false;
	for(int i = 0; i < s.length() ; i++) {
		if( s[i] != '0' ) flg = true;
		if( flg ) cout << s[i];
	}
	if( flg == false ) cout << 0;
	cout << endl;

}
int cnt = 0;
int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	while( 1 ) {
		string dp[70][70];
		char c[70][70];

		int w, h;
		cin >> w >> h;
		if( w == 0 && h == 0 ) break;

		for(int i = 0; i < h; i++ ) {
			string s;
			cin >> s;
			for(int j = 0; j < w; j++) {
				c[j][i] = s[j];
				dp[j][i] += s[j];
			}
		}

		//動的計画法　右下から順に調べてゆく
		for(int j = h - 1; j >= 0; j--) {
			for(int i = w - 1; i >= 0; i--) {
				if( c[i][j] < '0' || c[i][j] > '9' ) continue;
				add( c, dp[i][j], dp, w, h, i - 1, j);
				add( c, dp[i][j], dp, w, h, i, j - 1);
			}
		}

		string max;
		for(int i = 0; i < h; i++) 
			for(int j = 0; j < w; j++) {
				if( isLarger( dp[j][i], max ) && c[j][i] >= '0' && c[j][i] <= '9' ) 
					{
						
						max = dp[j][i];
				}
			}
			
		output(max);

	}
	//while(1){}

    return 0;
}

Measured memory_bytes: 1380
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")

MOD = 1000000007  # type: int


class Combination(object):

    def __init__(self, N, mod=MOD):
        fac, finv, inv = [0]*(N+1), [0]*(N+1), [0]*(N+1)
        fac[:2] = 1, 1
        finv[:2] = 1, 1
        inv[1] = 1
        for i in range(2, N+1):
            fac[i] = fac[i-1]*i % mod
            inv[i] = -inv[mod % i]*(mod//i) % mod
            finv[i] = finv[i-1]*inv[i] % mod
        self.N = N
        self.MOD = mod
        self.fac = fac
        self.finv = finv
        self.inv = inv

    def __call__(self, n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        fac = self.fac
        finv = self.finv
        mod = self.MOD
        return fac[n] * (finv[k]*finv[n-k] % mod) % mod


def solve(H: int, W: int, A: int, B: int):

    cmb = Combination(H+W+1, MOD)

    ans = 0
    for i in range(B, W):
        buf = cmb(H-A-1+i, i)
        buf *= cmb(A+W-i-2, W-i-1)
        buf %= MOD
        ans += buf
        ans %= MOD
    print(ans)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(H, W, A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26704
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,k; cin>>n>>k; 
    vi a(n);
    for (int &i: a) cin>>i;
    sort(a.begin(), a.end());
    int ans=0;
    for (int i=0;i<k;i++){
        ans += a[i];
    }cout << ans << endl;
    
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl

#define INF 1000000001
#define MOD 1000000007
#define INF64 1000000000000000001

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000
int N;
int M;
// vector<int> K;
//int KK[MAX_N*MAX_N];
int K[MAX_N];
int L;
int ans;
bool bool_ans;

int main (void)
{
  cin >> N;

  rep(i,0,N) {
    cin >> K[i];
  }

  sort(K,K+N);

  int bufl,bufr;

  bufl = N/2 - 1;
  bufr = bufl+1;

  ans = K[bufr] - K[bufl];

  put(ans);

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";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; }


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

    int N, K; cin >> N >> K;
    K--;
    string s; cin >> s;
    if(s[K] == 'A') s[K] = 'a';
    else if(s[K] == 'B') s[K] = 'b';
    else if(s[K] == 'C') s[K] = 'c';
    COUT(s);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int > pp;
typedef long long ll;
 
#define sz(x) (int)x.size() 
int const N=3e5+10,oo=1e9;
ll const OO=2e18;
double const eps=1e-8,PI=acos(-1);
int mod=oo+7;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,an=0;
  cin>>n;
  for(int i=0,mx=0;i<n;i++){
  	int a;
  	cin>>a;
  	if(a>=mx){
  		an++;
  	}
  	mx=max(mx,a);
  }
  cout<<an;
  return 0;
}






Measured memory_bytes: 256
#include<iostream>
#include<cmath>
int main()
{
	for (double v_min; std::cin >> v_min;)
	{
		double y_min = v_min * v_min / 19.6;
		int y_ceil = static_cast<int>(ceil(y_min));
		int y = y_ceil + (5 - y_ceil % 5) % 5;
		std::cout << (y + 5) / 5 << std::endl;
	}
	return 0;
}


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

string t;
int a[7];

void move(int i){
int b[7];
for(int n=1;n<7;n++){b[n]=a[n];}

if(t[i]=='W'){
a[6]=b[4];
a[4]=b[1];
a[1]=b[3];
a[3]=b[6];
}

if(t[i]=='N'){
a[6]=b[5];
a[5]=b[1];
a[1]=b[2];
a[2]=b[6];
}

if(t[i]=='E'){
a[6]=b[3];
a[3]=b[1];
a[1]=b[4];
a[4]=b[6];
}

if(t[i]=='S'){
a[6]=b[2];
a[2]=b[1];
a[1]=b[5];
a[5]=b[6];
}}



int main(){
for(int n=1;n<7;n++){cin>>a[n];}
cin>>t;
for(int g=0;g<(int)t.size();g++){move(g);}

cout<<a[1]<<endl;

return 0;
}


Measured memory_bytes: 3144
//my import
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
#define lll __int128
const int mod=1e9+7;
const int inf=1e9+7; 

//const int maxn=

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	int m1,d1,m2,d2;
	
	cin>>m1>>d1;
	
	cin>>m2>>d2;
	
	if(d2==1)
		return cout<<1<<endl,0;
	
	return cout<<0<<endl,0;
	
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextIntLine() []int {
	sc.Scan()
	splitStr := strings.Fields(sc.Text())
	ints := make([]int, len(splitStr))
	for i := 0; i < len(splitStr); i++ {
		n, _ := strconv.Atoi(splitStr[i])
		ints[i] = n
	}
	return ints
}

func min(n1, n2 int) int {
	if n1 < n2 {
		return n1
	} else {
		return n2
	}
}

func main() {
	n, _ := strconv.Atoi(nextLine())
	b := nextIntLine()
	var score int
	for i := 0; i < n; i++ {
		switch i {
		case 0:
			score += b[i]
		case n - 1:
			score += b[len(b)-1]
		default:
			score += min(b[i-1], b[i])
		}
	}
	fmt.Println(score)
}


Measured memory_bytes: 640
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char str[20];
int len;
int main()
{
	scanf("%s",str);
	len=strlen(str);
	if(str[0]!='A') {printf("WA\n");return 0;}
		bool F=false;
		for(int i=0;i<len;i++)
			if('A'<=str[i] && str[i]<='Z')
			{
				if(str[i]=='A' && i!=0) {printf("WA\n");return 0;}
				if(str[i]=='C')
					if(2<=i && i<=len-2)
					{
						if(F){printf("WA\n");return 0;}
						else F=true;
					}
				else {printf("WA\n");return 0;}
				if(str[i]!='A' && str[i]!='C') {printf("WA\n");return 0;}
			}
		if(!F){printf("WA\n");return 0;}
		printf("AC\n");
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String s = sc.next();
        
        String result = s;
        if (a < 3200) result = "red";
        System.out.println(result);
    }
}


Measured memory_bytes: 35588
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

int main() {
   double W, H, x, y;
   cin >> W >> H >> x >> y;
   double ans = (double)W * H;
   ans /= 2.;
   int flg = 0;
   
   double x0 = W / 2.;
   double y0 = H / 2.;
   if (x0 == x && y0 == y) flg = 1;

   cout << fixed << setprecision(10) << ans << " ";
   cout << flg << endl;
   return 0;
}


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

int main()
{
    string s,s1,s2;
    cin>>s>>s1>>s2;
    int l=s.length();
    int l1=s1.length();
    int l2=s2.length();

    if(s[l-1]==s1[0] && s1[l1-1]==s2[0])
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}


Measured memory_bytes: 768
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]# }}}

def local_input():
    from pcm.utils import set_stdin
    import sys
    if len(sys.argv) == 1:
        set_stdin(os.path.dirname(__file__) + '/test/' + 'sample-1.in')

def solve():
    N = int(input())
    res = float('inf')
    for n in range(1, N):
        a = n
        b = N - n
        res = min(res, calc(a) + calc(b))
    print(res)

def calc(a):
    res = 0
    for i in range(0, 6):
        b = dcopy(a)
        t = 10**i
        b = int(b/t)
        b %= 10
        res += b
    return res


if __name__ == "__main__":# {{{
    try:
        local_input()
    except:
        pass
    solve()
# vim: set foldmethod=marker:}}}


Measured memory_bytes: 122116
#include <bits/stdc++.h>
using namespace std;
int main(){
	char b;
	cin>>b;
	if(b=='A')
	cout<<'T';
	else if(b=='T')
	cout<<'A';
	else if(b=='C')
	cout<<'G';
	else if(b=='G')
	cout<<'C';
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <ctime>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int unt;
typedef double db;
typedef pair <int, int> pii;
typedef vector <int> vi;

#define Fi first
#define Se second
#define pb push_back
#define mp make_pair
#define rep(x, a, b) for(int x = (a); x <= (b); ++ x)
#define per(x, a, b) for(int x = (a); x >= (b); -- x)
#define rop(x, a, b) for(int x = (a); x < (b); ++ x)
#define por(x, a, b) for(int x = (a); x > (b); -- x)
#define forE(x, a) for(int x = head[a]; x; x = nxt[x])

#ifdef DEBUG
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define debug(x)
#endif

const db eps = 1e-8;
const int inf = 0x3f3f3f3f;
const int Minf = 0x7f7f7f7f;
const LL INF = 0x3f3f3f3f3f3f3f3fll;
const LL MINF = 0x7f7f7f7f7f7f7f7fll;

const int N = 2e5 + 50;

LL a[N], b[N];
LL n, m;

bool check(LL mid) {
	LL op = m;
	rep(i, 1, n) {
		LL now = a[i] * b[i];
		LL del = now - mid;
		if(del < 0) continue;
		op -= (del + b[i] - 1) / b[i];
		if(op < 0) return 0;
	}
	return 1;
}


int main() {
	scanf("%lld%lld", &n, &m);
	rep(i, 1, n) scanf("%lld", &a[i]);
	rep(i, 1, n) scanf("%lld", &b[i]);
	sort(a + 1, a + 1 + n);
	sort(b + 1, b + 1 + n);
	reverse(b + 1, b + 1 + n);
	LL l = 0, r = 1e18;
	while(l < r) {
		LL mid = (l + r) >> 1;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	cout << l << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;

int main()
{
	ll a,bi=0,small=0;
	string b;
	int flag=0;
	cin >> a >> b;
	ll l = b.size();
	rep(i,0,l) {
		if (b[i]!='.' && flag==0) {bi=bi*10+b[i]-'0';continue;}
		if (b[i]=='.') {flag=1; continue;}
		small = small*10+b[i]-'0';
	}
	ll tmp = small * a / 100;
	cout << a*bi+tmp << '\n'; 
	return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  int N;
  cin >> N;
  int A[N];
  rep(i,N) cin >> A[i];
  cout << *max_element(A,A+N)-*min_element(A,A+N) << endl;
}

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

int main ()
{
  int x[5];
  for (auto i = 0; i < 5; i++) {
    cin >> x[i];
    if (x[i] == 0) {
      cout << (i + 1);
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,K;
  cin >> N >> K;
  long int Case=0;
  for (long int i=K; i<N+2; i++){
    Case += (N-i+1)*i + 1;
  }
  cout << Case % 1000000007 <<endl;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
#define endl "\n"
//#define int long long
#define ALL(x) begin(x),end(x)
#define resort(v) sort((v).rbegin(), (v).rend())
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int fact(int i) {
    if (i == 0) return 1;
    return ((fact(i - 1)) * i) % MOD;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
int modpow(int a, int n, int mod) {
    int hi = 1;
    while (n > 0) {
        if (n & 1) hi = hi * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return hi;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
int n;
ll h[100050];
ll dp[100050];
/*signed*/int main(void) {
    cin >> n;
    rep(i, n) cin >> h[i];
    rep(i, 100050) dp[i] = INF;
    dp[0] = 0;
    for (int i = 1; i < n; ++i) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 5188
//
// Created by 李青坪 on 2018/10/1.
//

#include <cstdio>
#include <algorithm>

using namespace std;
#define MAXN 25
#define NIL -1

struct Node{
    int parent;
    int left;
    int right;
};

Node tree[MAXN];
int depth[MAXN];
int height[MAXN];

int getRoot(int n){
    for (int i = 0; i < n; ++i) {
        if (tree[i].parent == NIL) return i;
    }
}

void initTree(int n){
    for (int i = 0; i < n; ++i) {
        tree[i].parent = tree[i].left = tree[i].right = NIL;
    }
}

void preorder(int node){
    printf(" %d", node);
    if (tree[node].left != NIL) preorder(tree[node].left);
    if (tree[node].right != NIL) preorder(tree[node].right);
}

void inorder(int node){
    if (tree[node].left != NIL) inorder(tree[node].left);
    printf(" %d", node);
    if (tree[node].right != NIL) inorder(tree[node].right);
}

void postorder(int node){
    if (tree[node].left != NIL) postorder(tree[node].left);
    if (tree[node].right != NIL) postorder(tree[node].right);
    printf(" %d", node);
}

void printTree(int n){
    printf("Preorder\n");
    preorder(getRoot(n));
    printf("\nInorder\n");
    inorder(getRoot(n));
    printf("\nPostorder\n");
    postorder(getRoot(n));
    printf("\n");
}


int main(){
    int n;
    scanf("%d", &n);
    initTree(n);
    int node_id, left, right;
    for (int i = 0; i < n; ++i) {
        scanf("%d %d %d", &node_id, &left, &right);
        tree[node_id].left = left;
        tree[node_id].right = right;
        if (left != NIL) tree[left].parent = node_id;
        if (right != NIL) tree[right].parent = node_id;
    }
    printTree(n);
}
/*
9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1
 */


Measured memory_bytes: 2740
#include<stdio.h>
#include<string.h>

int main()
{
    int n;
    double sum = 0;
    scanf("%d", &n);
    double a[n];
    for (int i = 0; i < n; i++){
        scanf("%lf", &a[i]);
        sum += (1 / a[i]);
    }
    printf("%f\n", 1/sum);
    return 0;
}

Measured memory_bytes: 128
n, m = list(map(int,input().split()))
a = [0]*1000000
ac = 0
pen = 0
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == "AC":
        if a[p] == "AC":
            pass
        else:
            ac += 1
            pen += a[p]
            a[p] = "AC"
    else:
        if a[p] == "AC":
            pass
        else:
            a[p] += 1
print(ac,pen)
            


Measured memory_bytes: 10868
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	var wtr = bufio.NewWriter(os.Stdout)
	var N, x int
	fmt.Scan(&N, &x)
	a := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	var i int
	for {
		x -= a[i]
		if x < 0 {
			break
		}
		if i == N-1 {
			if x == 0 {
				i++
			}
			break
		}
		i++
	}
	fmt.Fprintln(wtr, i)
	_ = wtr.Flush()
}


Measured memory_bytes: 1848