akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

map<pii,bool> dp;
bool dfs(int pos, int less, const vector<int> &v,int sum, const int goal){
    if(abs(pos)>sum)return false;
    if(dp.count(pii(pos,less))){
        return dp[pii(pos,less)];
    }
    if(less==-1){
        if(pos==0)return true;
        else return false;
    }
    int a = pos+v[less];
    int b = pos-v[less];
    return dp[pii(pos,less)] = (dfs(a,less-1,v,sum-v[less],goal) || dfs(b,less-1,v,sum-v[less],goal));
}

bool solve(vector<int> v, int p){
    dp.clear();
    int sum = accumulate(all(v),0);
    return dfs(p,v.size()-1,v,sum,p);
}

int main(){
    string s;
    cin>>s;
    int x,y;
    cin>>x>>y;
    
    vector<int> v[2];
    int dir = 0;
    int tmp = 0;
    rep(i,s.size()){
        if(s[i]=='F')tmp++;
        else{
            v[dir].pb(tmp);
            tmp = 0;
            dir = !dir;
        }
    }
    if(tmp!=0)v[dir].pb(tmp);
    
    int t = 0;
    rep(i,s.size()){
        if(s[i]=='T')break;
        t++;
    }
    if(t!=0){
        x-=t;
        v[0].erase(v[0].begin());
    }
    
    if( solve(v[0],x) && solve(v[1],y) )cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}




Measured memory_bytes: 58240
s = input()
n = len(s)
ans = 0
for bit in range(1 << n-1):
    string = ""
    for i in range(n-1):
        if bit & (1 << i):
            string += "+"

        string += s[i+1]
    string = s[0] + string
    ans += sum(list(map(int, string.split("+"))))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;


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

    vector<int> X(N);
    int res = 0;
    REP(i, N){
        if (S[i] == 'W'){
            res++;
        }
        X[i] += res;
    }
    res = 0;
    REPD(i, N){
        if (S[i] == 'E'){
            res++;
        }
        X[i] += res;
    }

    int ans = MIN(X);

    cout << ans-1 << endl;
}

Measured memory_bytes: 4836
a, b = map(int, input().split())

def gcd(x, y):
  x, y = max(x, y), min(x, y) # x >= y
  r = x % y
  if r==0:
    return y
  while r!=0:
    r = x % y
    x, y = y, r #shift
  return x

g = gcd(a, b)
i = 2
c = 0
while i**2 <= g:
  if g % i == 0:
    c += 1
    while g % i == 0:
      g //= i
  i += 1
if g != 1:
  c += 1
print(c + 1)

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

int main() {
	char a;
	cin >> a;
	if(a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o'){
		cout << "vowel" << endl;
		return 0;
	}
	cout << "consonant" << endl;
	return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())

ab = [list(map(int, input().split())) for _ in range(n)]

import itertools
nums = [0,1]
ll = list(itertools.product(nums,repeat=3))

res = 0
for i in ll:
    temp =[]
    for j in range(n):
        if i[0]==0:
            x = ab[j][0]
        else:
            x = -ab[j][0]
        if i[1]==0:
            y = ab[j][1]
        else:
            y = -ab[j][1]
        if i[2] ==0:
            z = ab[j][2]
        else:
            z = -ab[j][2]
        temp.append(x+y+z)
    tempp =list(sorted(temp,reverse=True))
    res = max(res,sum(tempp[:m]))

print(res)


Measured memory_bytes: 9460
#include<iostream>

int main(){
	int n, mintime;
	int cost;
	int *array;

	std::cin >> n >> mintime;

	cost = 1001;
	array = new int[n * 2];

	for (int i = 0; i < n * 2; i++){
		std::cin >> array[i];
		if (i % 2 == 1){
			if (array[i - 1] <= cost && array[i] <= mintime){
				cost = array[i - 1];
			}
		}
	}

	if (cost <= 1000){
		std::cout << cost << std::endl;
	}
	else{
		std::cout << "TLE" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
 
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
 
        String[] inputArray = input.readLine().split(" ");
        ArrayList<Integer> inputList = new ArrayList<>();
        for (String each : inputArray) {
            inputList.add(Integer.parseInt(each));
        }
        Collections.sort(inputList);
        Collections.reverse(inputList);
        System.out.println(inputList.get(0) + " " + inputList.get(1) + " " + inputList.get(2) + " "
                + inputList.get(3) + " " + inputList.get(4));
    }
}
 

Measured memory_bytes: 24232
N = int(input())
s_list = list(input().split())
money = 1000
stock = 0

for i in range(N):
  #print("i:{}".format(i))

  # Last day
  if (i == N-1):
    money += stock * int(s_list[i])
    stock = 0
    break

  # Stock price tomorrow is higher than today
  if (int(s_list[i+1]) > int(s_list[i])):
    stock = stock + int(money / int(s_list[i]))
    money = money - (int(s_list[i]) * int(money / int(s_list[i])))
    continue

  # Stock price tomorrow is lower than or equal to today
  if (int(s_list[i+1]) <= int(s_list[i])):
    money = money + (int(s_list[i]) * stock)
    stock = 0
    continue

print(money)

Measured memory_bytes: 8832
import math

N, M = map(int, raw_input().split())

a, b, c, d = [], [], [], []

for i in xrange(N):
    s = map(int, raw_input().split())
    a.append(s[0])
    b.append(s[1])

for i in xrange(M):
    s = map(int, raw_input().split())
    c.append(s[0])
    d.append(s[1])


ans = 0
t = 0
for i in xrange(N):
    for j in xrange(M):
        if j == 0:
            t = abs(a[i]-c[j]) + abs(b[i]-d[j])
            ans = 1
        elif t > abs(a[i]-c[j]) + abs(b[i]-d[j]):
            t = abs(a[i]-c[j]) + abs(b[i]-d[j])
            ans = j+1
        #print "t = %d" % t
        #print "ans=%d" % ans
    print ans

Measured memory_bytes: 2696
K,N = map(int,input().split())
nums = list(map(int,input().split()))
last_to_first = nums[0] + (K - nums[-1])
diffs = [last_to_first]
for i in range(1,N):
    diffs.append(nums[i] - nums[i - 1])
print(sum(diffs) - max(diffs))

Measured memory_bytes: 86396
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string a;
    string b;
    string c;
    cin >> a >> b >> c;
    cout << "A" << b[0] << "C" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string debug_string(const string& s) {
	return '"' + s + '"';
}
string debug_string(bool b) {
	return (b ? "true" : "false");
}
string debug_string(const char* s) {
	return debug_string((string)s);
}
template<class T, class U>
string debug_string(const pair<T, U>& p);
template<class U>
struct can_be_string {
	template<typename...>
	static int f(...) {
		return 0;
	}
	template<typename T>
	static char f(decltype(to_string(T()), char())) { 
		return 'a';
	}
	static const bool value = sizeof(f<U>(char())) == sizeof(char);
};
template<class T> 
typename enable_if<can_be_string<T>::value, string>::type debug_string(const T& a) {
	string s = to_string(a);
	return s;
}
template<class T>
typename enable_if<!can_be_string<T>::value, string>::type debug_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += debug_string(x);
	}
	s += "}";
	return s;
}
template<class T, class U>
string debug_string(const pair<T, U>& p) {
	string s = "(";
	s += debug_string(p.first);
	s += ", ";
	s += debug_string(p.second);
	s += ")";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << debug_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int mod2 = 1e9 + 9;
const int inf = 1e9 + 100;
const ll inf64 = 1e18l + 100;
void max_self(int& a, int b) {
	a = max(a, b);
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<vector<pair<ll, ll>>> hash(n, vector<pair<ll, ll>>(n));
	srand(time(0));
	int b1 = (int)rand() % 150;
	int b2 = 7;
	while (b2 == b1) {	
		b2 = (int)rand() % 150;	
	}
	for (int i = 0;i < n;++i) {
		ll h1 = 0, h2 = 0;
		for (int j = i;j < n;++j) {
			h1 = (h1 * b1 + (s[j] - '0')) % mod;
			h2 = (h2 * b2 + (s[j] - '0')) % mod2;
			hash[i][j].first = h1;
			hash[i][j].second = h2;
		}
	}
	int answer = 0;
	for (int i = 0;i < n;++i) {
		for (int j = i + 1;j < n;++j) {
			int size = min(n - j, j - i);
			int l = 1, r = size;
			while (l <= r) {
				int mid = l + (r - l) / 2;
				bool ok = hash[i][mid + i - 1].first == hash[j][mid + j - 1].first;
				ok &= hash[i][mid + i - 1].second == hash[j][mid + j - 1].second;
				if (ok) {
					max_self(answer, mid);
					l = mid + 1;
				}
				else {
					r = mid - 1;
				}
			}
		}
	}
	cout << answer << '\n';
	return 0;
}


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

int main() {
    int Q; cin >> Q;
    int left = 100000, right = 1;
    vector<pair<int, int>> query;
    for (int i = 0; i < Q; i++) {
        int l, r; cin >> l >> r;
        query.push_back({l, r});
        left = min(l, left);
        right = max(r, right);
    }
    vector<bool> isPrime(right + 1, true);
    isPrime[0] = false;
    isPrime[1] = false;
    for (int i = 2; i <= right; i++) {
        if (!isPrime[i]) continue;
        for (int j = 2; i * j <= right; j++) {
            isPrime[j * i] = false;
        }
    }
    vector<int> cum2017(right + 1, 0);
    for (int i = left; i <= right; i++) {
        if (isPrime[i] && isPrime[(i + 1) / 2]) cum2017[i] = cum2017[i-1] + 1;
        else cum2017[i] = cum2017[i-1];
    }
    for (int i = 0; i < Q; i++) {
        int l = query[i].first;
        int r = query[i].second;
        cout << cum2017[r] - cum2017[l - 1] << endl;
    }
}

Measured memory_bytes: 4584
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
import bisect
ans = 0
for i in range(N):
    b = B[i]
    x = bisect.bisect_left(A,b)
    y = N - bisect.bisect_right(C,b)
    ans += x*y
print(ans)

Measured memory_bytes: 23248
#include<bits/stdc++.h>
#define ll long long
#define maxn 100005
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define pb push_back
#define pii pair<int,int>
using namespace std;

int n,k;
int a[5005];

bool Check(int mid){
    if(a[mid]>=k) return 1;
    bitset<maxn> bs;
    bs[0]=1;
    for(int i=1;i<=n;i++){
        if(i!=mid) bs|=bs<<a[i];
    }
    for(int i=k-1;i>=k-a[mid];i--){
        if(bs[i]) return 1;
    }
    return 0;
}

int main(){

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    int L=1,R=n,mid;
    while(L<=R){
        mid=L+R>>1;
        if(Check(mid)) R=mid-1;
        else L=mid+1;
    }
    cout<<R<<endl;


}




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

vector<string> blue(100);
vector<string> red(100);
int n,m;

int cal(string t){
	int mrk = 0;
	for(int i = 0;i<n;i++){
		if(blue[i]==t) mrk++;
	}
	for(int i = 0;i<m;i++){
		if(red[i]==t) mrk--;
	}

	return mrk;
}


int main(){

	cin>>n;

	for(int i = 0;i < n;i++){
		cin>>blue[i];
	}
	cin>>m;
	for(int i = 0;i < m; i++){
		cin>>red[i];
	}

	int res = 0;

	for(int i = 0;i < n;i++){
		res = max(res,cal(blue[i]));
	}
	cout<<res;
}


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

int main() {
    int H, N, i;
    bool can = false;
    cin >> H >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.rbegin(), A.rend());
    for (int i = 0; i < N; i++) {
        H -= A[i];
        if (H <= 0) {
            can = true;
            break;
        }
    }
    if (can == true) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
  ll N;
  cin >> N;
  ll a[5];
  rep(i, 5) cin >> a[i];
  ll ans = (N + a[0] -1)/a[0];
  ll m = a[0];
  rep(i, 4){
    if(a[i+1] < m){
       ans = i+1+(N + a[i+1] -1)/a[i+1];
       m = a[i+1];
     }
    else ans++;
  }
  cout << ans << endl;
  return 0;
}


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

public class Main {	
	private static void solve(){
		//Implement solution here.
		int N = ni();
		gen("a",N,'a');
	}
	
	private static void gen(String s, int N, int max) {
		if(s.length() >= N){
			System.out.println(s);
			return;
		}
		
		for(int i = (int)'a'; i <= (int)max + 1; i++) {
			gen(s + Character.valueOf((char)i),N,Math.max(i, (int)max));
		}
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 50280
#import numpy as np
N,M = map(int, input().split())
a = [list(input()) for _ in range(N)]
b = [list(input()) for _ in range(M)]

fl = False
for i in range(N-M+1):
    for j in range(N-M+1):
        #print(i,j)
        #print(a[i][j:j+M])
        #print(a[i+1][j:j+M])
        #print(np.array([a[k+i][j:j+M] for k in range(M)]))
        if b==[a[k+i][j:j+M] for k in range(M)]:
            fl = True
print('Yes') if fl else print('No')

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    int n,b[102],c[102],d[102];
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>b[i];
    }
    for(int i=1;i<=n;i++){
        if(b[i]>i){
            cout<<-1<<endl;
            return 0;
        }
        c[i]=b[i];
    }
    for(int i=1;i<=n;i++){
        bool f=true;
        for(int j=n-i+1;j>=1;j--){
            if(c[j]==j){
                d[n-i]=c[j];
                for(int k=j;k<n-i+1;k++){
                    c[k]=c[k+1];
                }
                f=false;
                break;
            }
        }
        if(f){
            cout<<-1<<endl;
            return 0;
        }
    }
    for(int i=0;i<n;i++){
        cout<<d[i]<<endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.equals("A")) {
            System.out.println("T");
        } else if (s.equals("T")) {
            System.out.println("A");
        } else if (s.equals("C")) {
            System.out.println("G");
        } else {
            System.out.println("C");
        }


        
    }

}


Measured memory_bytes: 21076
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

n = int(readline())
kx = np.array(read().split(),np.int32)
k = kx[::2]
x = kx[1::2]

from collections import Counter
c = Counter(k)
c.update({0:0})
d = Counter(x)
d.update({0:0})
if c.most_common()[0] != d.most_common()[0]:
  print(n-c.most_common()[0][1]-d.most_common()[0][1])
else:
  a = max(c.most_common()[0][1]+d.most_common()[1][1],c.most_common()[1][1]+d.most_common()[0][1])
  print(n-a)

Measured memory_bytes: 29952
#include<cstdio>
using namespace std;
int main(){
  int n,a;
  bool flag=true;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a);
    if((a&1)||a%3==0||a%5==0) continue;
    flag=false;
  }
  if(flag) printf("APPROVED");
  else printf("DENIED");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    lli n, k;
    cin >> n >> k;
    n %= k;
    lli temp = abs(n-k);
    cout << min(n, temp) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();

    while(true){
    String str1 = br.readLine();
    String[] str2 = str1.split(" ");
    int n = Integer.parseInt(str2[0]);
    int x = Integer.parseInt(str2[1]);
    int count = 0;
    if (n == 0 && x == 0) {break;}
    for (int i = 1; i <= n; i++){
      for (int j = i + 1; j <= n; j++){
        for (int k = j + 1; k <= n; k++){
          if (i == j || j == k || k == i){break;}
          else if (i + j + k == x){count++;}
        }
      }
    }
    System.out.println(count);
  }

  }
}

Measured memory_bytes: 25220
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(x) begin(x),end(x)
#define pii pair<int,int>
#include <bits/stdc++.h>
#define pll pair<ll,ll>
#define vi vector<int>
#define ld long double
#define ll long long
#define pb push_back
#define mid (l+r)/2
#define S second
#define F first
using namespace std;
const ll mod = 998244353;
ll n,s,ans;
ll a[3009];
ll dp[3009][3009];
ll bt(ll id,ll sum){
    if(sum > s) return 0;
    if(sum == s) return n-id+1;
    if(id == n) return 0;
    ll &ret = dp[id][sum];
    if(ret != -1) return ret;
    ret = bt(id+1,sum);
    ret = (ret+bt(id+1,sum+a[id]))%mod;
    return ret;
}
int main(){
    fast,cin>>n>>s; mem(dp,-1);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        ans = (ans+bt(i,0))%mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 71168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin>>n;
    vi a(n);
    rep(i,n) cin >> a[i];
    vi l(n+1),r(n+1);
    l[0] = a[0];
    for(int i=1;i<n;i++){
        l[i] = __gcd(l[i-1],a[i]);
    }
    r[n-1] = a[n-1];
    for(int i=n-2;i>=0;i--){
        r[i] = __gcd(r[i+1],a[i]);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        int t;
        if(i==0) t = r[1];
        else if(i==n-1) t = l[n-2];
        else t = __gcd(l[i-1],r[i+1]);
        ans = max(ans,t);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    map<string, int> s;
    int q, a, b, c;
    string key;
    cin >> q;
    rep(i, q) {
        cin >> a >> key;
        if(a == 0) {
            cin >> b;
            s[key] = b;
        } else if(a == 1) {
            cout << s[key] << "\n";
        } else if(a == 2) {
            s.erase(key);
        }
    }
}



Measured memory_bytes: 25900
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
#define P pair<int,int>
pair<int,int> judge(int a, int b){
	int x=0,y=0;
	int gcd = __gcd(a,b);
	int ans=0;
	
	while(gcd != ans){// a < b
		while(ans < gcd){
			ans += a;
			x++;
		}
		if(ans == gcd)break;
		while(ans < b){
			ans += a;
			x++;
		}
		while(ans > gcd){
			ans -= b;
			y--;
		}
		if(ans == gcd)break;
		while(ans > a){
			ans -= b;
			y--;
		}
	}
	return make_pair(x,y);
}

int main(){
	int a,b;
	cin >> a >> b;
	P ans1 = judge(a,b);
	P ans2 = judge(b,a);
	swap(ans2.first,ans2.second);
	int x,y;
	if(abs(ans1.first)+abs(ans1.second) > abs(ans2.first) + abs(ans2.second)){
		cout << ans2.first << " " << ans2.second << endl;
	}else{
		if(abs(ans1.first)+abs(ans1.second) == abs(ans2.first) + abs(ans2.second)){
			if(ans1.first<ans2.first){
				cout << ans1.first << " " << ans1.second << endl;
			}else{
				cout << ans2.first << " " << ans2.second << endl;
			}
		}else
		cout << ans1.first << " " << ans1.second << endl;
	
}
	return 0;

}

Measured memory_bytes: 3092
N=int(input())

nowodd = False
ans = 0
for i in range(N):
    a = int(input())
    if nowodd and a>0:
        a-=1
        ans+=1

    if a%2==1:
        nowodd=True
    else:
        nowodd=False
    ans+=a//2
print(ans)

Measured memory_bytes: 74808
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var w = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int min = int.MaxValue;
        for (int i = 1; i < w.Length; i++)
        {
            min = Min(min, Abs(w.Skip(i).Sum() - w.Take(i).Sum()));
        }
        Console.WriteLine(min);
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <list>
#include <stack>
#include <climits>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#define m7 1000000007
#define m9 1000000009
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second

using namespace std;
int dp[1 << 22 + 1][21], allmask, X[21][21];
int n;

int solve(int mask,int pre_man) {
	if (mask == allmask) 
		return 1;
	if (pre_man == n || mask > allmask)
		return 0;
	if (dp[mask][pre_man] != -1) return dp[mask][pre_man];
	
	dp[mask][pre_man] = 0;
	
	for (int i = 0; i < n; i++) {
		if (X[pre_man][i] && !(mask & (1<<i)) ) {
			dp[mask][pre_man] = (dp[mask][pre_man] + solve( mask | (1 << i) ,pre_man + 1) ) % m7;
		}
	}
	//cout << mask << ' ' << pre_man <<' '<< dp[mask][pre_man] << endl;
	return dp[mask][pre_man];
}
int main()
{
	memset(dp, -1, sizeof dp);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
			cin >> X[i][j];
	}
	allmask = (1 << n) - 1;
	cout<<solve(0, 0);

	

	return 0;
}

Measured memory_bytes: 688384
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

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

  for (int i = 0; i+1 < s.length(); ++i) {
    if (s[i] == s[i+1]) {
      cout << i+1 << ' ' << i+2 << endl;
      return 0;
    }
  }

  for (int i = 0; i+2 < s.length(); ++i) {
    if (s[i] == s[i+2]) {
      cout << i+1 << ' ' << i+3 << endl;
      return 0;
    }
  }

  cout << -1 << ' ' << -1 << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int n,a,t,r,w;
int main() {
	cin>>n;
	string s;
	for(int i=0;i<n;i++)
	{
		cin>> s;
		if(s=="AC")
		a++;
		if(s=="WA")
		w++;
		if(s=="TLE")
		t++;
		if(s=="RE")
		r++;
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<w<<endl;
	cout<<"TLE x "<<t<<endl;
	cout<<"RE x "<<r<<endl;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  int d[100] = {0};
  int a[100][100] = {0};
  set<int> S;
  for(int i = 0; i < k; i++){
    cin >> d[i];
    for(int j = 0; j < d[i]; j++){
      cin >> a[i][j];
    }
  }
  
  for(int i = 0; i < k; i++){
    for(int j = 0; j < d[i]; j++){
      S.insert(a[i][j]);
      }
    }
  

  cout << n - S.size() << endl;
}
 

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

#include <iostream>
#include <stdio.h>
using namespace std;

int main() {

	int a[100] = {};
	int n;

	cin >> n;

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

	for(int j = n - 1; j >= 0; j--){
		cout << a[j];
		if (!(j == 0)){
			cout << " ";
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3060
# n,m = map(int ,input().split())
N = int(input())
T = [int( input() ) for _ in range(N)]
T = set(T)
from functools import reduce
def gcd(x, y):
    while y != 0:
        (x, y) = (y, x % y)
    return x
    
# print(reduce(lambda a,b : a * b , T) // reduce(gcd, T))
def gcp (x,y):
    return x*y //gcd(x,y)
print(reduce(gcp, T))




Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    cout << 180 * (n - 2) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
#define ll long long 
#define pb push_back
#define mk make_pair
#define x first
#define y second
#define deb(x) cout<< #x <<" "<<x<<"\n";
#define deb1(x,y) cout<< #x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define sz(a) (int)a.size()
const ll MOD=1e9+7;
const int MAX=1e6+1;
const int MAX2=1025;
const ll inf=LLONG_MAX;
const double EPS=1e-6;
int dcmp(double x,double y)
{return (fabs(x-y)<=EPS)?0:(x<y)?1:-1;}
void init(){
	ios
	///cout << fixed << setprecision(15);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

int main()
{	init();
	ll n,k;
	cin>>n>>k;
	vector<ll>c(k,0);
	ll ans=0;
	for(int i=1;i<=n;i++)
		c[i%k]++;
	for(int i=0;i<k;i++)
	{
		if((i+i)%k==0)
		{
			ans+=c[i]+c[i]*(c[i]-1)*3+c[i]*(c[i]-1)*(c[i]-2);
			
		}
	}
	cout<<ans;

	


}











	

	

	
	




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

#define LL long long
#define RG register

using namespace std;
template<class T> T gi() {
	T x = 0; bool f = 0; char c = getchar();
	while (c != '-' && (c < '0' || c > '9')) c = getchar();
	if (c == '-') f = 1, c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f ? -x : x;
}
const int N = 3010, Mod = 1e9 + 7;
int a[N], f[N][N], g[N][N];
int fpow(int a, int b) {
	int res = 1;
	for (; b; b >>= 1, a = 1ll * a * a % Mod)
		if (b & 1) res = 1ll * res * a % Mod;
	return res;
}
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	int n = gi<int>(), q = gi<int>();
	for (int i = 1; i <= n; i++) a[i] = gi<int>();
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			f[i][j] = a[i] > a[j];
	int inv = fpow(2, Mod - 2), ans = 0;
	for (int i = 1; i <= q; i++) {
		int x = gi<int>(), y = gi<int>();
		f[x][y] = f[y][x] = 1ll * (f[x][y] + f[y][x]) * inv % Mod;
		for (int j = 1; j <= n; j++) {
			if (j == x || j == y) continue;
			f[y][j] = f[x][j] = 1ll * (f[x][j] + f[y][j]) * inv % Mod;
			f[j][x] = f[j][y] = 1ll * (f[j][x] + f[j][y]) * inv % Mod;
		}
		/*for (int j = 1; j <= n; j++) {
			f[x][j] = g[x][j]; f[j][x] = g[j][x];
			f[y][j] = g[y][j]; f[j][y] = f[j][y];
			}*/
	}
	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++) 
			(ans += f[i][j]) %= Mod;
	cout << 1ll * ans * fpow(2, q) % Mod << endl;
	return 0;
}


Measured memory_bytes: 36224
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define forn(f,n) for(int i=f;i<f+n;i++)
#define rforn(l,n) for(int i=l;i>l-n;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i];
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1005;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
//////////////////Sieve////////////////////



int main()
{
	string s;
	cin>>s;
	int sum=0;
	int n=s.length();
	vvi dp(n,vi(2));
	reverse(all(s));
	dp[0][0] = s[0]-'0';
	dp[0][1] = 1+10-(s[0]-'0');
	for(int i=1;i<n;i++)
	{
		int dig=s[i]-'0';
		dp[i][0] = min(dig+dp[i-1][0],dig+dp[i-1][1]);
		dp[i][1] = min(9-dig+dp[i-1][1],11-dig+dp[i-1][0]);
	}
	cout<<min(dp[n-1][0],dp[n-1][1])<<endl;
	
}		

Measured memory_bytes: 55940
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define yokuwaruprime (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int N;
  cin>>N;
  int a[N],b[N];
  rep(i,N){
    cin>>a[i];
  }
  rep(i,N){
    cin>>b[i];
  }
  int candy[N]={};
  rep(i,N){
    rep(j,i+1){
      candy[i]+=a[j];
    }
    for(int j=i;j<N;j++){
      candy[i]+=b[j];
    }
  }
  int max=candy[0];
  rep(i,N){
    if(max<candy[i]){
      max=candy[i];
    }
  }
  cout<<max<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm> // sort
#include <map>       // pair
#include <vector>
using namespace std;

#define REP(a,b) for(int i =(a);i < (b);i++)
#define FOR(n) for(int i = 0; i<(n); i++)
#define COUT(c)  cout<<(c)<<endl


const int INF = 100100100;
const int MOD = (int)1e9 +7;
const double EPS = 1e-9; 

typedef long long int ll;

//char in[120];
//ex. pair
//pair<pair<string,int>,int> p[110];

int main(){
    int n,k;cin>>n>>k;
    vector<int> hs(n);
    FOR(n){
        cin>>hs[i];
    }
    sort(hs.begin(),hs.end());

    int ans=hs[k-1] - hs[0];
    //cout<<hs[k-1]<<endl;
    for(int i=k-1; i<n;i++){
        ans = min(ans,hs[i] - hs[i-k+1]);
    }
    cout<<ans<<endl;
    return 0;    
}

Measured memory_bytes: 640
#include<stdio.h>
int pr[50847534];

int x=0;
int nextpr(int p){
  int nxp=p+2;
  int i=0;
  int ok=0;
  pr[x]=p;
  x++;
  if(p==2)return 3;
  while(1==1){
    for(i=0;pr[i]*pr[i]<=nxp;i++){
      ok = 0;
      if(nxp%pr[i]==0){
        ok = 1;
        break;
      }
    }
    if(ok==0){
      return nxp;
    }else{
      nxp+=2;
    }
  }

}

int main(){
  int n,n2;
  int p=2;
  int done=0;
  scanf("%d",&n);
  printf("%d:",n);
  n2 = n;
  while(n>1){
    if(n%2==0){
      printf(" 2");
      n /= 2;
      done = 1;
    }else if(n%p==0){
      printf(" %d",p);
      n /= p;
      done = 1;
    }else{
      /*printf("X%d\n",p);*/
      p = nextpr(p);
    }
    if(p*p>n2&&done==0){
      printf(" %d",n2);
      break;
    }
  }
  printf("\n");
}

Measured memory_bytes: 1036
#include <iostream>
#include <string>
#include <map>
#include <vector>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

// 最長共通部分列 ... len(s) == m, len(t) == n とすると, O(mn)
int lcs(std::string& s, std::string& t) {
  std::vector<std::vector<int> > dp(s.size() + 1, std::vector<int>(t.size() + 1, 0));

  for (int i = 1; i <= s.size(); ++i) {
    for (int j = 1; j <= t.size(); ++j) {
      if (s[i - 1] == t[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
      }
      else if (dp[i - 1][j] >= dp[i][j - 1]) {
        dp[i][j] = dp[i - 1][j];
      }
      else {
        dp[i][j] = dp[i][j - 1];
      }
    }
  }

  return dp[s.size()][t.size()];
}

int main() {
  int q;
  std::string s, t;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    cin >> s >> t;
    cout << lcs(s, t) << endl;
  }

  return 0;
}


Measured memory_bytes: 6764
n,m=map(int,input().split())
box=[1]*n
boxz=[1]+[0]*(n-1)
for i in range(m):
    x,y=map(int,input().split())
    box[y-1]+=1
    box[x-1]-=1
    if boxz[x-1]==1:
        boxz[y-1]=1
        if box[x-1]==0:
            boxz[x-1]=0
print(sum(boxz))

Measured memory_bytes: 5364
import numpy as np

n = 1000003
primes = set(range(2, n+1))

for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))

primes = np.array(list(primes))

x = int(input())

print(primes[np.where(primes>=x)][0])

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

int main(){
  int n; cin>>n;
  string s,t; cin>>s>>t;
  int ans=2*n;
  for(int i=0; i<n; i++){
    int s_index=n-1-i;
    int now_ans=2*n-(i+1);
    bool flag=1;
    for(int t_index=0; t_index<=i; t_index++){
      if(t[t_index]!=s[s_index])flag=0;
      s_index++;
    }
    if(flag){
      ans=now_ans;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int a=0,b=0;
	string s;
	cin >> s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='A'){
			a=i;
			break;
		}
	}
	
	for(int i=s.size()-1;i>=0;i--){
		if(s[i]=='Z'){
			b=i;
			break;
		}
	}
	
	cout << b-a+1 << endl;
	
	return 0;
}

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

#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <vector>
#include <string.h> // for memset in CF judge.
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int main() {
	int n; cin >> n;
	if(n >= 1200) cout << "ARC" << endl;
	else cout << "ABC" << endl;
return 0;
}


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

using namespace std;

#define FOR(i,s, t) for(int i = s; i < t; i++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(x) (int)x.size()

int main() {

	string s;
	cin >> s;
	int a=1e9,z=-1;
	FOR(i, 0, SZ(s)) {
		if (s[i] == 'A')a = min(a, i);
		if (s[i] == 'Z')z = max(z, i);
	}
	cout << z - a + 1 << endl;

	return 0;
}


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

int main(void){
	char str[200002];
	int i,l,s,ans;
	scanf("%s",str);
	l=strlen(str);
	ans=l;
	s=0;
	for(i=0;i<l;i++){
		if(str[i]=='S') s++;
		else if(str[i]=='T'){
			if(s>0){
				s--;
				ans-=2;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

int main(){
  ll n;
  cin>>n;
  ll mi=ll(1e18);
  for(int i=0;i<5;i++){
    ll a;
    cin>>a;
    mi=min(mi,a);
  }
  ll x=n/mi;
  if(n%mi==0) x--;
  cout<<5+x<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>


using namespace std;

int main()
{
	int x1,y1,x2,y2;

	cin >> x1 >> y1 >> x2 >> y2;

	int dx,dy;
	int x3, y3, x4, y4;
	//場合分け
	if (x2 >= x1 && y2 >= y1) {
		dx = y2 - y1;
		dy = x2 - x1;
		x3 = x2 - dx;
		y3 = y2 + dy;
		x4 = x1 - dx;
		y4 = y1 + dy;
	}
	else if (x2 <= x1 && y2 >= y1) {
		dx = x1 - x2;
		dy = y2 - y1;
		x3 = x2 - dy;
		y3 = y2 - dx;
		x4 = x1 - dy;
		y4 = y1 - dx;
	}
	else if (x2 <= x1 && y2 <= y1) {
		dx = x1 - x2;
		dy = y1 - y2;
		x3 = x2 + dy;
		y3 = y2 - dx;
		x4 = x1 + dy;
		y4 = y1 - dx;
	}
	else if (x2 >= x1 && y2 <= y1) {
		dx = x2 - x1;
		dy = y1 - y2;
		x3 = x2 + dy;
		y3 = y2 + dx;
		x4 = x1 + dy;
		y4 = y1 + dx;
	}

	printf("%d %d %d %d", x3, y3, x4, y4);

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e10;
const ll MOD = 1e9 + 7;
const ll MAX_N = 1e5;

int main(){
    ll N;
    cin>>N;
    ll i, j;
    ll n = 1;
    ll fn = n;
    while(1){
        if(N == fn){
            cout<<"Yes"<<endl;
            break;
        }
        if(N < fn){
            cout<<"No"<<endl;
            return 0;
        }
        n++;
        fn += n;
        if(fn > MAX_N){
            cout<<"No"<<endl;
            return 0;
        }
    }
    ll nset = n + 1;
    vector<vll> S(nset);
    ll ssize = n;
    ll th_s = 0;
    ll th_e = 0;
    while(ssize > 0){
        for(i=1;i<=ssize;i++){
            S[th_s].push_back(th_e + i);
            S[th_s + i].push_back(th_e + i);
        }
        th_s++;
        th_e += ssize;
        ssize--;
    }
    cout<<nset<<endl;
    for(i=0;i<nset;i++){
        cout<<S[i].size()<<" ";
        for(auto e: S[i]) cout<<e<<" ";
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3200
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int P[200002];
bool eranda[200002];

int Find(int A) {
	if (P[A] < 0) return A;
	return P[A] = Find(P[A]);
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint(), H = getint(), W = getint();

	int R[100000], C[100000], A[100000];
	rep(i, N) {
		R[i] = getint() - 1;
		C[i] = getint() + H - 1;
		A[i] = getint();
	}
	
	int SR[100000], SC[100000], SA[100000];
	int kazu[100001] = {};
	rep(i, N) kazu[A[i]]++;
	for (int i = 99999; i >= 0; i--) kazu[i] += kazu[i + 1];
	rep(i, N) {
		SA[--kazu[A[i]]] = A[i];
		SR[kazu[A[i]]] = R[i];
		SC[kazu[A[i]]] = C[i];
	}

	rep(i, H + W) P[i] = -1;
	ll kotae = 0;
	rep(i, N) {
		int r = Find(SR[i]);
		int c = Find(SC[i]);
		if (r != c) {
			if (!(eranda[r] && eranda[c])) {
				if (P[r] > P[c]) swap(r, c);
				P[r] += P[c];
				eranda[r] |= eranda[c];
				P[c] = r;
				kotae += SA[i];
			}
		}
		else {
			if (eranda[r] == 0) {
				eranda[r] = 1;
				kotae += SA[i];
			}
		}
	}

	printf("%lld", kotae);


	Would you please return 0;
}

Measured memory_bytes: 3968
#include <iostream>
using namespace std;
int main(){
  int a,b;
  int t=1,i;
  cin>>a>>b;
  
  while(1){
    i=t*b;
    
    if(i>=a){
      break;
    }
    t++;
  }
  
  cout<<t;
      
  
  return 0;
}

Measured memory_bytes: 3192
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define PI 	3.14159265358979323846

int main(){
    ll n;
    ld ans;
    cin >> n;
    ld x[100],d[100];
    REP(i,n){
        cin >> x[i];
    }
    REP(i,n){
        ld y;
        cin >> y;
        d[i] = abs(x[i]-y);
    }
    ld sum = 0;
    REP(i,n){
        sum += d[i];
    }
    printf("%.8llf\n",sum);

    sum = 0;
    REP(i,n){
        sum += (ld)pow(d[i],2);
        //cout << sum << endl;
    }
    ans = (ld)pow(sum,0.5);
    printf("%.8llf\n",ans);
    sum = 0;
    REP(i,n){
        sum += (ld)pow(d[i],3);
        //cout << sum << endl;
    }
    double num = 1.0/3.0;
    ans = (ld)pow(sum,num);
    printf("%.8llf\n",ans);
    
    ans = 0;
    REP(i,n){
        ans = max(ans,d[i]);
        //cout << ans << endl;
    }
    printf("%.8llf\n",ans);
}


Measured memory_bytes: 3484
import sys
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = sorted([[a[i], b[i]] for i in range(n)], key=lambda x: x[1])
a = [(x[0], i) for i, x in enumerate(c)]
b = [x[1] for x in c]
a.sort()
for i in range(n):
	if a[i][0] > b[i]:
		print("No")
		sys.exit()
cur, cnt = 0, 0
while a[cur][1] != 0:
	cnt += 1
	cur = a[cur][1]
if cnt < n-1:
	print("Yes")
else:
	for i in range(n-1):
		if a[i+1][0] <= b[i]:
			print("Yes")
			break
	else:
		print("No")

Measured memory_bytes: 32256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];
		long[] x = new long[N];
		for (int i = 0; i < N; i++) {
			A[i] = 2 * sc.nextLong();
			if (i % 2 == 0) {
				x[0] += A[i];
			} else {
				x[0] -= A[i];
			}
		}
		x[0] /= 2;
		for (int i = N - 1; i > 0; i--) {
			x[i] = (A[i] - x[(i+1) % N]);
		}
		for (int i = 0; i < N; i++) {
			System.out.print(x[i] + " ");
		}
		System.out.println();
	}
}

Measured memory_bytes: 67576
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=1
k=0
if a[-1]==0:
    print(0)
    exit()
else:
    while k<n:
        if len(str(ans))<19:
            ans*=a[k]
            k+=1
        else:
            print(-1)
            exit()
if len(str(ans))<19 or ans==10**18:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 21648
import fractions

a, b, c, d = map(int, input().split())
num = b - a + 1
div_c = b // c - (a - 1) // c 
div_d = b // d - (a - 1) // d 
lcm_cd = c * d // fractions.gcd(c, d)
div_lcm = b // lcm_cd - (a - 1) // lcm_cd
print(num - div_c -div_d + div_lcm)

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

using ll = long long;
using namespace std;

int main() {
    double l;
    cin >> l;
    double h = l/3;
    double w = (l - h)/2;
    double d = l - h - w;
    cout << setprecision(10) << h * w * d << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int A, B;
	int takagireni;
	if (scanf("%d%d", &A, &B) != 2) return 1;
	for (takagireni = 1; takagireni <= 1000000; takagireni++) {
		if (takagireni * 8 / 100 == A && takagireni * 10 / 100 == B) {
			printf("%d\n", takagireni);
			return 0;
		}
	}
	puts("-1");
	return 0;
}


Measured memory_bytes: 128