akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}

int solve() {
	int k, a, b; cin >> k >> a >> b;
	if (b / k - (a - 1) / k > 0)
		cout << "OK" << endl;
	else
		cout << "NG" << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << "Case #" << i << ": ", solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    int N;
    cin >> N;
    vint A(N);
    cin >> A;
    sort(A.begin(),A.end());
    ll ans = 1LL << 60;
    for(int i=A[0]; i<=A[N-1]; i++){
        ll cnt = 0;
        for(auto a:A){
            cnt += abs(a-i)*abs(a-i);
        }
        chmin(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
N,M = map(int, input().split())
food = [0]*(M+1)
for _ in range(N):
    k,*a = map(int, input().split())
    for ai in a:
        food[ai] += 1
        
ans = 0
for f in food:
    if f==N:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
const int MAXN=1001;
int n,m;
ll x[MAXN],y[MAXN],z[MAXN],sum[MAXN];
ll ans=0,temp;
int res[3];
inline bool CMP(ll a,ll b){
	return a>b;
}
template<typename T>
inline T read(){
	T x=0,f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<3)+(x<<1)+c-'0';
	return x*f;
}
int main(){
	n=read<int>();m=read<int>();
	for(int i=1;i<=n;++i){
		x[i]=read<ll>();y[i]=read<ll>();z[i]=read<ll>();
	}
	for(int i=0;i<8;++i){
		for(int j=0;j<3;++j)
			res[j]=(i&(1<<j))?1:-1;
		for(int j=1;j<=n;++j)
			sum[j]=x[j]*res[0]+y[j]*res[1]+z[j]*res[2];
		sort(sum+1,sum+n+1,CMP);
		temp=0;
		for(int j=1;j<=m;++j) temp+=sum[j];
		ans=max(ans,temp);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#define INF 0x3f3f3f3f
int read()
{
    int x=0,f=1;	char c=getchar();
    while(c<'0'||c>'9')	{if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9')	{x=x*10+c-'0';c=getchar();}
    return x*f;
}
priority_queue<int,vector<int>,greater<int> >q1;
priority_queue<int,vector<int>,less<int> >q2;
const int maxn = 1e4 + 7;
const int mod = 1e9 + 7;
/** keep hungry and keep calm! **/

string a,b;
ll n,ans;
ll ch(int k)//判断有几位相同 
{
	int x = 0;
	for(int i=k;i<n;i++)
	{
		if(a[i] != b[x])
			break;
		x++;
	}
	return x;
}

int main()
{
	cin >> n >> a >> b;
	ans = 2*n;//最大长度
	for(int i=0;i<n;i++)
	{
		int t = ch(i);
		ans = min(ans,2*n-t);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int a, b, n;
int ans = 0;

int get(int x)
{
	int val = a * x / b;
	val -= a * (x / b);
	return val;
}

int32_t main()
{
	IOS;
	cin >> a >> b >> n;
	int ans = get(min(b - 1, n));
	cout << ans;
	return 0;
}

Measured memory_bytes: 3656
open System

[<EntryPoint>]
let main argv = 
  let s = Console.ReadLine()
  
  let f t c = 
    match c with
    | '0' | '1' -> t + string c
    | 'B' -> 
      if t = "" then ""
      else t.Substring(0, t.Length - 1)
    | _ -> failwithf ""
  List.fold f "" [ for c in s -> c ]
  |> printfn "%s"
  0 // 整数の終了コードを返します


Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (ll i = (ll)(start); i < (ll)(n); ++i)
static const ll INFTY = 1L << 62L;
ll solver(ll h, ll w, ll m, set<pair<ll, ll>> &st)
{
    ll sh[h] = {}, sw[w] = {};
    for (auto x : st)
    {
        ++sh[x.first], ++sw[x.second];
    }
    ll maxh = 0, maxw = 0;
    rep(i, 0, h)
    {
        if (sh[i] > maxh)
            maxh = sh[i];
    }
    rep(i, 0, w)
    {
        if (sw[i] > maxw)
            maxw = sw[i];
    }
    vector<ll> ih, iw;
    rep(i, 0, h)
    {
        if (sh[i] == maxh)
        {
            ih.push_back(i);
        }
    }
    rep(i, 0, w)
    {
        if (sw[i] == maxw)
        {
            iw.push_back(i);
        }
    }
    ll ans = maxh + maxw;
    rep(i, 0, ih.size())
    {
        rep(j, 0, iw.size())
        {
            if (st.count(make_pair(ih[i], iw[j])) == 0)
            {
                return ans;
            }
        }
    }
    return ans - 1;
}

int main()
{
    ll h, w, m;
    cin >> h >> w >> m;
    set<pair<ll, ll>> st;
    ll tmph, tmpw;
    rep(i, 0, m)
    {
        cin >> tmph >> tmpw;
        --tmph, --tmpw;
        st.insert(make_pair(tmph, tmpw));
    }
    cout << solver(h, w, m, st) << endl;
}

Measured memory_bytes: 34920
#include <stdio.h>

int main(void)
{
	int a, b, c;
	int rectangle = 0;
	int diamond = 0;

	while (scanf("%d, %d, %d", &a, &b, &c) != EOF){
		if (a * a + b * b == c * c){
			rectangle++;
		}
		else if (a == b){
			diamond++;
		}
	}
	printf("%d\n%d\n", rectangle, diamond);

	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)

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

    int n;
    cin >> n;

    vector<int> vec(n);
    REP(i, n) {
        cin >> vec[i];
    }

    sort(vec.begin(), vec.end());
    long long sum = accumulate(vec.begin(), vec.end(), 0LL);

    cout << vec[0] << ' ' << vec[n - 1] << ' ' << sum << '\n';
    return 0;
}


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

int A[100100];

int main(){
	int n;
	vector<long long> v;
	
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> A[i];
	}
	sort(A,A+n);
	reverse(A,A+n);
	
	for(int i=1;i<n;i++){
		if(A[i-1]==A[i]){
			v.push_back(A[i]);
			i++;
		}
		if(v.size()==2){
			cout << v[0]*v[1] << endl;
			return 0;
		}
	}
	
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 640
# https://atcoder.jp/contests/abc146/tasks/abc146_a

import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    s = input()
    ans = 0
    if s == 'SUN':
        ans = 7
    if s == 'MON':
        ans = 6
    if s == 'TUE':
        ans = 5
    if s == 'WED':
        ans = 4
    if s == 'THU':
        ans = 3
    if s == 'FRI':
        ans = 2
    if s == 'SAT':
        ans = 1
    print(ans)
    
if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
    int n , k ;
    cin>>n>>k ;
    int arr[n+1] ;
    for(int i = 1 ; i  <= n ; ++i)
        cin>>arr[i] ;
    int x = 0 , ans = 0, cnt = 0;
    for(int i = 1 ; i <= n ; ++i)
    {
        cnt++;
        if(cnt == k)
           i -= (i != n) , ans++ ,cnt = 0;
    }
    if(cnt == 0)
        cout<<ans;
    else
        cout<<ans+1;
    return 0 ;
}


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

int main()
{
    string s,t;
    cin>>s>>t;
    int n=s.size(),m=t.size(),mn=1000;
   
    for(int i=0;i<=n-m;i++)
  {
      int cnt=0;
      for(int j=i;j<=m+i-1;j++)
      {
         if(s[j]!=t[j-i])
         cnt++;
      }
    
      mn=min(mn,cnt);
  }
  cout<<mn<<endl;
	return 0;
}


Measured memory_bytes: 3620
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String s=br.readLine();
        int N=0;
        int S=0;
        int E=0;
        int W=0;
        for(char c:s.toCharArray()){
            if(c=='N'){
                N=1;
            }else if(c=='S'){
                S=1;
            }else if(c=='E'){
                E=1;
            }else if(c=='W'){
                W=1;
            }
        }System.out.println(((N+S)%2==0&&(E+W)%2==0) ? "Yes":"No");
    }
}

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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int n;
vector<int> e[400];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n;
  char c;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      cin >> c;
      if (c == '1')
        e[i].push_back(j);
    }
  int k = -1;
  for (int i = 0; i < n; i++) {
    queue<int> q;
    vector<int> num(n, -1);
    num[i] = 0;
    q.push(i);
    int h = 0;
    bool ok = true;
    while (!q.empty() && ok) {
      int j = q.front();
      q.pop();
      for (int l : e[j]) {
        if (num[l] >= 0)
          ok = ok && abs(num[j] - num[l]) == 1;
        else {
          num[l] = num[j] + 1;
          h = num[l];
          q.push(l);
        }
      }
    }
    if (ok)
      k = max(k, h + 1);
  }
  cout << k << "\n";
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(2e5 + 5);

int n;
ll a[MAX_N];

ll add_a[MAX_N];
ll xor_a[MAX_N];

ll ans;

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &(a[i]));
  }

  for (int i = 1; i <= n; ++i) {
    add_a[i] = add_a[i - 1] + a[i];
    xor_a[i] = xor_a[i - 1] ^ a[i];
  }

  ans = 0LL;

  for (int i = 1; i <= n; ++i) {
    int ok = i;
    int ng = n + 1;

    while (abs(ok - ng) > 1) {
      int mid = (ok + ng) / 2;

      ll add_value = add_a[mid] - add_a[i - 1];
      ll xor_value = xor_a[mid] ^ xor_a[i - 1];

      if (add_value == xor_value) {
        ok = mid;
      } else {
        ng = mid;
      }
    }

    ans += (ll)(ok - i + 1);
  }

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

  return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        TreeSet<Element> a = new TreeSet<>();
        for (int i = 0; i < n; i++) {
            a.add(new Element(i, sc.nextInt()));
        }
        for (int i = 0; i < m; i++) {
            Element max = a.last();
            a.remove(max);
            Element newE = new Element(max.seq, max.num / 2);
            a.add(newE);
        }
        long sum = a.stream().mapToLong(x -> x.num).sum();
        System.out.println(sum);

        sc.close();
    }

    static class Element implements Comparable<Element> {
        int seq;
        int num;

        public Element(int seq, int num) {
            this.seq = seq;
            this.num = num;
        }

        @Override
        public int compareTo(Element o) {
            if (num != o.num) {
                return num - o.num;
            } else {
                return seq - o.seq;
            }
        }
    }

}


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

int main(){
   long long n,x;
   cin >> n >> x;
   long long a[n];
   for(int i=0;i<n;i++){
       cin >> a[i];
   }
   sort(a,a+n);
   long long b=abs(a[0]-x);
   for(int i=1;i<n;i++){
       b=__gcd(b,abs(a[i]-x));
   }
   cout << b << endl;
   return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    int n, m;
    cin >> n >> m;
    int a[n];
    for (int& e: a) cin >> e;

    vector<vector<int>> g(n);
    for (int i=0; i<m; i++) {
        int x, y;
        cin >> x >> y;
        g[x-1].push_back(y-1);
        g[y-1].push_back(x-1);
    }

    int cnt = 0;
    for (int i=0; i<n; i++) {
        bool flag = true;
        for (int e : g[i])
            if (a[e] >= a[i])
                flag = false;

        cnt += flag;
    }
    cout << cnt << "\n";
}


Measured memory_bytes: 8708
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var open = new int[num][];
        for (var i = 0; i < num; i++)
            open[i] = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var be = new int[num][];
        for (var i = 0; i < num; i++)
            be[i] = Array.ConvertAll(ReadLine().Split(' '), int.Parse);

        var res = long.MinValue;
        for(var i = 1; i < Pow(2,10); i++)
        {
            var r = 0L;
            var wo = new int[10];
            for(var j = 0; j < 10; j++)
            {
                if (((i >> j) & 1) == 1)
                {
                    wo[j] = 1;
                }
            }

            var count = new int[num];
            for(var j = 0; j < num; j++)
            {
                for(var h = 0; h < 10; h++)
                {
                    if (open[j][h] == 1 && wo[h] == 1)
                        count[j]++;
                }
            }
            for (var j = 0; j < num; j++)
                r += be[j][count[j]];
            res = Max(r, res);
        }
        WriteLine(res);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 13396
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

int get_int3(int *a1, int *a2, int *a3) {
  scanf("%d %d %d", a1, a2, a3);
  return 0;
}

#define NUM_MAX 200000
#define DIVISOR 1000000007

static int64_t factorial[NUM_MAX+1];
static int64_t inv_factorial[NUM_MAX+1];

struct pair {
    int x;
    int y;
};

struct pair gcdext(int a, int b) {
    if(a==0) { return (struct pair){0, 1}; }
    struct pair p = gcdext(b%a, a);
    return (struct pair){p.y - (b/a)*p.x, p.x};
}

void init_combi(int size) {
    factorial[0] = factorial[1] = 1;
    inv_factorial[0] = inv_factorial[1] = 1;
    int i;
    for(i = 2; i <= size; i++) {
        factorial[i] = (factorial[i-1] * i)%DIVISOR;
        struct pair p = gcdext(i, DIVISOR);
        int inv = (p.x + DIVISOR)%DIVISOR;
        inv_factorial[i] = (inv_factorial[i-1] * inv)%DIVISOR;
    }
    return;
}

int64_t calc_combi(int n, int k) {
    int64_t ans = 1;
    ans = (ans * factorial[n])%DIVISOR;
    ans = (ans * inv_factorial[n-k])%DIVISOR;
    ans = (ans * inv_factorial[k])%DIVISOR;
    return ans;
}

int64_t calc_sum(int size) {
    int64_t ans = 0;
    int i;
    for(i = 1; i < size; i++) {
        int64_t res = 1;
        res = (res * i)%DIVISOR;
        res = (res * (size-i))%DIVISOR;
        ans = (ans + res)%DIVISOR;
    }
    return ans;
}

int main(void) {
    int row, col, k;
    get_int3(&row, &col, &k);
    init_combi(row*col);

    int64_t combi = calc_combi(row*col-2, k-2);
    int64_t xcnt = calc_sum(row);
    int64_t ycnt = calc_sum(col);
#ifdef DEBUG
    printf("%lld %lld: combi: %lld\n", xcnt, ycnt, combi);;
#endif
    xcnt = (xcnt * combi)%DIVISOR;
    xcnt = (xcnt * col * col)%DIVISOR;

    ycnt = (ycnt * combi)%DIVISOR;
    ycnt = (ycnt * row * row)%DIVISOR;

    int64_t ans = (xcnt + ycnt)%DIVISOR;
    printf("%d\n", (int)ans);
    return 0;
}

Measured memory_bytes: 3328
use proconio::input;

fn solve(mut n: i64) -> String {
    n -= 1;
    let mut ans = Vec::new();
    let mut k = 1;
    loop {
        let mut x = 1;
        for _ in 0..k {
            x = x * 26;
        }
        if n < x {
            break;
        }
        n -= x;
        k += 1;
    }
    for _ in 0..k {
        ans.push(std::char::from_u32((n % 26) as u32 + 97).unwrap());
        n = n / 26;
    }
    ans.iter().rev().collect()
}

fn main() {
    input! {
        n: i64,
    }
    let r = solve(n);
    println!("{}", r);
}


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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;


void dfs(const vector<vector<ll> >& g, vector<ll>& dist, ll k, ll sum){
        if(dist[k]!=-1){return;}
	dist[k]=sum;
	for(auto i : g[k]){
		dfs(g, dist, i , sum+1);
    }
}


int main(){
	int n; cin >> n;
	vector<vector<ll> >g(n);
	for(int i = 0; i < n-1; ++i){
		ll a,b; cin >>a >>b;
--a, --b;
                g[a].push_back(b);
		g[b].push_back(a);
    }
    
    vector<ll> dist1(n, -1), distn(n, -1);
    dfs(g, dist1, 0, 0);
    dfs(g, distn, n-1, 0);
   ll sum=0;
    for(int i = 0; i <n; ++i){
    	if(dist1[i] > distn[i]){++sum;}
    }
    if(sum>=n-sum){
    	cout << "Snuke" << endl;
}
else{
	cout << "Fennec" << endl;
}
    return 0;
}


Measured memory_bytes: 12032
package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
	bw = bufio.NewWriter(os.Stdout)
)

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	defer bw.Flush()
	sc.Split(bufio.ScanWords)
	n := ri()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = ri()
	}
	for i := n - 1; i >= 0; i -= 2 {
		fmt.Fprint(bw, a[i], " ")
	}
	for i := n & 1; i < n-2; i += 2 {
		fmt.Fprint(bw, a[i], " ")
	}
	if n > 1 {
		fmt.Fprint(bw, a[n-2])
	}
	fmt.Fprint(bw, "\n")
}


Measured memory_bytes: 6912
N, M, X = list(map(int, input().split()))

C = []
A = []

for i in range(N):
    s = list(map(int, input().split()))
    C.append(s[0])
    A.append(s[1:])

C2 = []
A2 = []

for i in range(2**N):
    su = [0]*M
    sai = 0
    for j in range(N):
        if ((i >> j) & 1):
            for k in range(M):
                su[k] += A[j][k]
            sai += C[j]
    C2.append(sai)
    A2.append(su)

ans = 10000000000

for i in range(len(A2)):
    flag = True
    for j in A2[i]:
        if j < X:
            flag = False
    if flag:
        if ans > C2[i]:
            ans = C2[i]

if ans == 10000000000:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define ld long double
#define MOD 1000000007
#define N 1000006
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define INF 1000000000000000000
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define randright srand(chrono::steady_clock::now().time_since_epoch().count());

using namespace std;
// int my_rand(){ int a=rand(); int b=rand(); return a*(RAND_MAX+1)+b; }

#define int long long int

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}

void solve(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            int c = __gcd(i,j);
            for(int k=1; k<=n; k++){
                ans += __gcd(c,k);
            }
        }
    }
    cout<<ans<<"\n";
}

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

Measured memory_bytes: 3652
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n; cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) cin >> h[i];

    int max = h[0];
    int cnt = 1;
    for (int i = 1; i < n; ++i){
        if (max <= h[i]) {
            ++cnt;
            max = h[i];
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
d = {}
for ai in a:
  if ai in d:
    d[ai] += 1
  else:
    d[ai] = 1
ans = 0
for ai in d:
  if d[ai] - ai >= 0:
    ans += d[ai] - ai
  else:
    ans += d[ai]
print(ans)


Measured memory_bytes: 67112
import sys
input = sys.stdin.readline
N = int(input())
a =[int(i) for i in input().split()]
x = 0
y = 0
z = 0
for i in range(N) :
    if a[i] % 2 != 0 :
        x+=1
    elif a[i] % 2 == 0 and a[i] % 4 != 0 :
        y += 1
    else :
        z +=1
ans = "No"
if y >= 1 :
    y = 1
    if x <= z :
        ans = "Yes"
else :
    if x <= z + 1 :
        ans = "Yes"
print(ans)

Measured memory_bytes: 14252
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        Console.WriteLine((int)Pow(n, 3));
    }
}


Measured memory_bytes: 13140
#include <iostream>

using namespace std;

long long e(long long a, long long b, long long c)
{
  long long mi = a, ma = a;
  if (b < mi)
    mi = b;
  if (b > ma)
    ma = b;
  if (c < mi)
    mi = c;
  if (c > ma)
    ma = c;
  return ma-mi;
}

long long f(long long a, long long b)
{
  long long amari = a%3;
  if (amari == 0)
    return 0;
  return b;
}

long long g(long long a, long long b)
{
  long long minvar = 1000000000;
  long long dy = b/2;
  long long dz = b-dy;
  long long x = 0, y = a*dy, z = a*dz;
  for(int i = 1; i < a; ++i){
    x += b;
    y -= dy;
    z -= dz;
    long long tmp = e(x, y, z);
    if (tmp < minvar)
      minvar = tmp;
  }
  return minvar;
}

int main()
{
  long long h, w;
  cin >> h >> w;
  long long minvar = 10000000000;
  long long tmp = f(h, w);
  if (minvar > tmp)
    minvar = tmp;
  tmp = f(w, h);
  if (minvar > tmp)
    minvar = tmp;
  tmp = g(h, w);
  if (minvar > tmp)
    minvar = tmp;
  tmp = g(w, h);
  if (minvar > tmp)
    minvar = tmp;
  cout << minvar << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
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 main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N;
	cin >> N;

	int X[100], Y[100];
	rep(i, N) cin >> X[i] >> Y[i];

	double pi = atan2(0, -1);

	rep(i, N) {
		double shita1 = -pi;
		double shita2 = 0;
		double ue1 = 0;
		double ue2 = pi;
		rep(j, N) {
			if (i != j) {
				double kakudo = atan2(Y[j] - Y[i], X[j] - X[i]);
				if (abs(kakudo) <= pi / 2) {
					shita1 = max(shita1, kakudo - pi / 2);
					ue2 = min(ue2, kakudo + pi / 2);
				}
				else if(kakudo > pi / 2) {
					shita2 = min(shita2, kakudo + pi / 2 - 2 * pi);
					ue1 = max(ue1, kakudo - pi / 2);
				}
				else {
					shita2 = min(shita2, kakudo + pi / 2);
					ue1 = max(ue1, kakudo - pi / 2 + 2 * pi);
				}
			}
		}
		double kotae = 0;
		if (ue2 > ue1) kotae += ue2 - ue1;
		if (shita2 > shita1) kotae += shita2 - shita1;
		kotae /= 2 * pi;
		cout << setprecision(12) << kotae << endl;
	}

	Would you please return 0;
}

Measured memory_bytes: 512
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = [input() for i in range(n)]
    sp,sm = [],[]
    for i in range(n):
        p = 0
        m = 0
        for j in a[i]:
            if j == "(":
                p += 1
            else:
                p -= 1
            if p < m:
                m = p
        if p > 0:
            sp.append((m,p))
        else:
            sm.append((m,p))
    sp.sort(reverse = True)
    sm.sort(key = lambda x:x[0]-x[1])
    k = 0
    for m,p in sp:
        if k+m < 0:
            print("No")
            return
        k += p
    for m,p in sm:
        if k+m < 0:
            print("No")
            return
        k += p
    if k != 0:
        print("No")
    else:
        print("Yes")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 197028
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir [] = {
	{ 1,0 },{ 0,1 }
};


signed main() {
	int n, k;
	scanf("%d %d", &n, &k);

	vector<vector<int>> g(n);
	vector<pii> ed(n-1);
	REP(i, n-1) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		ed[i] = { a,b };
		g[a].push_back(b);
		g[b].push_back(a);
	}

	vector<int> wei(n);
	vector<vector<int>> dp(n);
	
	function<int(int, int)> dfs = [&](int cur, int from) {
		for (auto itr : g[cur]) {
			if(itr != from)
				wei[cur] += dfs(itr, cur);
		}
		return ++wei[cur];
	};

	dfs(0,0);

	function<int(int, int, int)> ansdfs = [&](int cur, int from, int depth) {
		if (depth == 0) {
			return 1;
		}
		int res = 1;
		for (auto itr : g[cur]) {
			if (itr != from)
				res += ansdfs(itr, cur, depth-1);
		}
		return res;
	};
	function<int(int, int, int, int)> ansdfs_tyu = [&](int cur1, int cur2, int from, int depth) {
		if (depth == 0) {
			return 1;
		}
		int res = 0;
		res += ansdfs(cur1, cur2, depth/2);
		res += ansdfs(cur2, cur1, depth / 2);
		return res;
	};
	int ans = 0;
	if (k % 2) {
		REP(i, n-1) {
			ans = max(ans, ansdfs_tyu(ed[i].first, ed[i].second, -1, k));
		}
	}
	else {
		REP(i, n) {
			ans = max(ans, ansdfs(i, i, k / 2));
		}
	}
	printf("%d\n", wei[0]-ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double PI = 3.14159265358979323846;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0; i < (n); ++i)

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  bool pos = false;
  for (int i = a; i <= b; ++i) {
    if (i % k == 0) pos = true;
  }
  cout << (pos ? "OK" : "NG") << endl;
  return 0;
}

Measured memory_bytes: 3596
def solve(string):
    n, m = map(int, string.split())
    d = [i for i in range(1, int(m**0.5) + 1) if m % i == 0]
    d.extend([m // i for i in d])
    return str(max([i for i in d if m // i >= n]))


if __name__ == '__main__':
    print(solve(input()))


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

using namespace std;
using llint = long long;

#define LOG(x) cout << "# " << #x <<" => "<< (x) <<endl

int n, ans;
vector<int> a;

int gcd(int a, int b) {
    if (a < b) return gcd(b, a);
    while(b!=0){
        int r = a%b;
        a = b;
        b = r;
    }
    return a; 
}

int main() {
    // Input
    cin >> n;

    a.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> a.at(i);
    }

    // Solve
    ans = a.at(0);
    for (int i = 1; i < n; ++i) {
        ans = gcd(ans, a.at(i));
    }

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

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

using ll = int64_t;

int main() {
    int X, N;
    std::cin >> X >> N;

    int p;
    std::set<int> s;
    for (int i = 0; i < N; ++i) {
        std::cin >> p;
        s.insert(p);
    }

    if (s.count(X) == 0) {
        std::cout << X << std::endl;
        return 0;
    }

    int r = X + 1;
    int l = X - 1;
    while (true) {
        if (s.count(l) == 0) {
            std::cout << l << std::endl;
            return 0;
        } else if (s.count(r) == 0) {
            std::cout << r << std::endl;
            return 0; 
        } else {
            ++r;
            --l;
        }
    }

    return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
	
	public static int halflower(int a[], int t) {		
		int r = a.length - 1, l = 0;
		int m;
		
		while(l < r) {
			m = (r + l) / 2;
			if(r - l <= 1) {
				if(a[m + 1] < t)return m + 1;
				else if(a[m + 1] >= t && a[m] < t)return m;
				else return m - 1;
			}
			else {
				if(a[m] >= t)r = m;
				else l = m;
			}
		}
		
		if(a[0] < t)
		return 0;
		else return -1;
	}
	
	public static int halfupper(int a[], int t) {
		int r = 0, l = a.length - 1;
		int m;
		
		while(r < l) {
			m = (r + l) / 2;
			if(l - r <= 1) {
				if(a[m] > t)return m;
				else if(a[m] <= t && a[m + 1] > t)return m + 1;
				else return m + 2;
			}
			else {
				if(a[m] <= t)r = m;
				else l = m;
			}	
		}
		
		if(a[0] > t)
		return 0;
		else return -1;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n;
		int a[][];
		
		n = sc.nextInt();
		a = new int[3][n];
		for(int i = 0; i < 3; ++i) {
			for(int j = 0; j < n; ++j) {
				a[i][j] = sc.nextInt();
			}
		}
		
		//sort
		for(int i = 0; i < 3; ++i) {
			Arrays.sort(a[i]);
		}
		
		
		long ans = 0;
		long tmp, tmp2;
		for(int i = 0; i < n; ++i) {
			tmp = (long)halflower(a[0], a[1][i]);
			tmp2 = (long)halfupper(a[2], a[1][i]);
			ans += (tmp + 1) * (n - tmp2);
		}
		
		System.out.println(ans);
		
		sc.close();
	}

}


Measured memory_bytes: 95504
def main():
    N = int(input())
    A, B = (int(i) for i in input().split())
    P = [int(i) for i in input().split()]
    cnt = [0, 0, 0]
    for p in P:
        if p <= A:
            cnt[0] += 1
        elif p <= B:
            cnt[1] += 1
        else:
            cnt[2] += 1
    print(min(cnt))


if __name__ == '__main__':
    main()


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<long long> a(n);
	for (auto &it : a) cin >> it;
	long long value = 0, ans = 0;
	for (int i = 1; i < n; i++) {
	    value = max(value, a[i - 1]);
	    if (a[i] - value < 0) {
	        ans += abs(a[i] - value);
	    }
	}
	cout << ans << "\n";
	return 0;
}

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

using namespace std;

int main(){
    int N, Q; cin >> N >> Q;
    string s; cin >> s;

    for (int i = 0; i < N-1; i++) {
        if (s[i] == 'A' && s[i+1] == 'C')
            s[i] = 'a';
    }

    int l[N];
    int r[N];
    for (int i = 0; i < Q; i++) cin >> l[i] >> r[i];

    vector<int> cs(N+1, 0);
    for (int i = 0; i <= N; i++) {
        int n = 0;
        if (s[i] == 'a') n = 1;
        cs[i+1] = cs[i] + n;
    }


    for (int i = 0; i < Q; i++) {
        l[i] -= 1;
        r[i] -= 1;

        int res = cs[r[i]] - cs[l[i]];
        cout << res << endl;
    }

}



Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long A, B, C, D;
    cin >> A >> B >> C >> D;
    ll takahashi_count = C / B, aoki_count = A / D;
    if(C % B > 0) takahashi_count++;
    if(A % D > 0) aoki_count++;
    if(takahashi_count <= aoki_count) cout << "Yes" << endl;
    else cout << "No" << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int n;
    ll k;
    cin >> n >> k;

    vector<pair<ll, ll>> p(n);

    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        p[i] = make_pair(a, b);
    }

    sort(p.begin(), p.end());

    ll cnt = 0;
    rep(i, n) {
        cnt += p[i].second;
        if(k <= cnt) {
            cout << p[i].first;
            break;
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 1792
a,b,c,d = map(int, input().split())
alice = list(range(a,b))
bob = list(range(c,d))
ans = 0

if len(alice) <= len(bob):
    target = alice
    other = bob
else:
    target = bob
    other = alice

for i in range(len(target)):
    if target[i] in other:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N, K;
	cin >> N >> K;
	vector<ll> A(N);
	for(int i=0; i<N; i++) cin >> A[i];

	vector<ll> sums;
	for(int i=0; i<N; i++){
		ll sum = 0;
		for(int j=i; j<N; j++){
			sum += A[j];
			sums.push_back(sum);
		}
	}

	ll ans = 0;
	for(int k=60; k>=0; k--){
		vector<ll> next;
		for(ll x: sums){
			if((x>>k)&1) next.push_back(x);
		}
		if(next.size()>=K){
			swap(sums, next);
			ans = ans | 1ll<<k;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6516
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int main() {

	string a, b;
	cin >> a >> b;

	int n = stoi(a + b);
	int s = sqrt(n);
	if ((s*s) == n)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#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 ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
int second_gcd(int a,int b, int k){
    int c = max(a, b);
    while(k != 0){
        if(a % c == 0 && b % c == 0){
            k--;
        }
        c--;
    }
    return c + 1;
}

int main()
{
    INIT;
    int a, b, k;
    scanf("%d%d%d",&a, &b, &k);
    printf("%d",second_gcd(a, b, k));
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    clock_t start = clock();
    ll D;
    cin >> D;
    vector<ll> C(26);
    rep(i, 26) cin >> C[i];
    vector<vector<ll>> S(D, vector<ll>(26));
    rep(i, D) {
        rep(j, 26) {
            cin >> S[i][j];
        }
    }
    vector<ll> T(D);

    rep(i, D) {
        ll m = - INF;
        rep(j, 26) {
            if (S[i][j] > m) {
                T[i] = j + 1;
                m = S[i][j];
            }
        }
    }
    vector<ll> last(26, 0);

    ll sum = 0;
    auto f = [&] {
        sum = 0;
        last.assign(26, 0);
        rep(d, D) {
            ll t = T[d];
            sum += S[d][t - 1];
            last[t - 1] = d + 1;
            rep(i, 26) {
                sum -= C[i] * ((d + 1) - last[i]);
            }
        }
        return sum;
    };
    ll ans = -INF;
    clock_t end = clock();
    double time = (end - start) / 1000;
    while (time <= 1900) {
        ll r = rand() % 26;
        r++;
        ll d = rand() % 365;
        ll old = T[d];
        T[d] = r;
        ll res = f();
        if (res > ans) {
            ans = res;
        }else {
            T[d] = old;
        }
        // cout << ans << '\n';
        end = clock();
        time = (end - start) / 1000;
    }
    // cout << time << '\n';
    rep(d, D) {
        cout << T[d] << '\n';
    }
}

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


Measured memory_bytes: 3784
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <map>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,int> P;
const int N=100100;

ll x,y,z;
ll a[N],b[N],c[N];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
    cin >> x >> y >> z;
    for(int i=0;i<x+y+z;i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    int n=x+y+z;
    vector<P> v(n);
    for(int i=0;i<n;i++){
        v[i]=make_pair(a[i]-b[i],i);
    }
    sort(v.begin(), v.end());
    // あるKが存在して
    // 0~Kは銅&銀、~Kは金と銅を使うような最大値
    // このKそれぞれについて探索していきたい
    // Kの範囲は？　min:Y+0, max:Y+Z
    vector<ll> le(z+1,0),ri(z+1,0);
    priority_queue<P,vector<P>,greater<P>> q;
    for(int i=0;i<y;i++){
        q.push(make_pair(b[v[i].second]-c[v[i].second],v[i].second));
        le[0]+=b[v[i].second];
    }
    for(int i=0;i<z;i++){
        int id=v[i+y].second;
        q.push(make_pair(b[id]-c[id],id));
        le[i+1]=le[i]+b[id];
        le[i+1]-=q.top().first;
        q.pop();
    }
    while(q.size())q.pop();
    reverse(v.begin(), v.end());
    for(int i=0;i<x;i++){
        q.push(make_pair(a[v[i].second]-c[v[i].second],v[i].second));
        ri[0]+=a[v[i].second];
    }
    for(int i=0;i<z;i++){
        int id=v[i+x].second;
        q.push(make_pair(a[id]-c[id],id));
        ri[i+1]=ri[i]+a[id];
        ri[i+1]-=q.top().first;
        q.pop();
    }
    //ここから上を編集
    ll res=0;
    for(int i=0;i<=z;i++){
        res=max(res,le[i]+ri[z-i]);
    }
    printf("%lld\n",res);
}


Measured memory_bytes: 6772
N = input()
A = map(int, raw_input().split(" "))

is_up = False
is_down = False
last_val = 0
ans = 1

for i in A:
    if last_val == 0:
        last_val = i
    elif not (is_up or is_down) and i > last_val:
        is_up = True
        last_val = i
    elif not (is_up or is_down) and i < last_val:
        is_down = True
        last_val = i
    elif(is_up and i < last_val):
        ans += 1
        is_up = False
        last_val = i
    elif(is_down and i > last_val):
        ans += 1
        is_down = False
        last_val = i
    else:
        last_val = i

print ans

Measured memory_bytes: 11320
fn main() {
    let mut buf = String::new();
    let handle = std::io::stdin();
    handle.read_line(&mut buf).unwrap();
    let mut bell: Vec<isize> = buf.trim().split_whitespace()
        .map(|a| a.parse().unwrap()).collect();
    bell.sort();
    println!("{}", bell[0] + bell[1]);
}

Measured memory_bytes: 4352
import java.util.*;class Main{public static void main(String[]z){Map<String,Map<Integer,Long>>m=new TreeMap<String,Map<Integer,Long>>();String k;for(Scanner s=new Scanner(System.in);s.hasNext();m.get(k).put(s.nextInt(),0L))if(!m.containsKey(k=s.next()))m.put(k,new TreeMap<Integer,Long>());k="";for(String x:m.keySet()){k+=x+"\n";for(int i:m.get(x).keySet())k+=i+" ";k=k.replaceAll(" $","\n");}System.out.print(k);}}

Measured memory_bytes: 12000
use proconio::input;

fn hoge(a0: usize, a1: usize, n: usize, v: &Vec<char>) {
	let mut a: [usize; 100000+1] = [0; 100000+1];
	a[0] = a0;
	a[1] = a1;
	for i in 2..n+1 {
		if a[i-2] == 0 {
			if a[i-1] == 0 {
				//SS
				if v[i-1] == 'o' {
					a[i] = 0;
				}
				else {
					a[i] = 1;
				}
			}
			else {
				//SW
				if v[i-1] == 'o' {
					a[i] = 1;
				}
				else {
					a[i] = 0;
				}
			}
		}
		else {
			if a[i-1] == 0 {
				//WS
				if v[i-1] == 'o' {
					a[i] = 1;
				}
				else {
					a[i] = 0;
				}
			}
			else {
				//WW
				if v[i-1] == 'o' {
					a[i] = 0;
				}
				else {
					a[i] = 1;
				}
			}
		}
	}
	if a[0] != a[n] {
		return;
	}
	if a[0] == 0 {
		if v[0] == 'o' && a[n-1] != a[1] {
			return;
		}
		if v[0] == 'x' && a[n-1] == a[1] {
			return;
		}
	}
	else {
		if v[0] == 'o' && a[n-1] == a[1] {
			return;
		}
		if v[0] == 'x' && a[n-1] != a[1] {
			return;
		}
	}
	for i in 0..n {
		if a[i] == 0 {
			print!("S");
		}
		else {
			print!("W");
		}
	}
	println!("");
	std::process::exit(0);
}

fn main() {
	input!(n: usize);
	input!(s: String);

	let v: Vec<char> = s.chars().collect();
	//SS
	hoge(0, 0, n, &v);
	//SW
	hoge(0, 1, n, &v);
	//WS
	hoge(1, 0, n, &v);
	//WW
	hoge(1, 1, n, &v);

	println!("-1");
}



Measured memory_bytes: 3632
//\\//\\ * * * //\\// ||
#include <bits/stdc++.h> 

#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  cout << (n + 999) / 1000 * 1000 - n << '\n';
  return 0;
}


Measured memory_bytes: 3660
n = int(input())
leaves = list(map(int, input().split()))

sum_leaves = [0]*(n+1)
sum_leaves[0] = leaves[0]
for depth in range(n):
    sum_leaves[depth+1] = sum_leaves[depth] + leaves[depth+1]

ans = 0

root = [None] * (n + 1)
if n == 0:
    root[0] = 0
else:
    root[0] = 1
if root[0] + leaves[0] != 1:
    print(-1)
else:
    for depth in range(n):
        root[depth+1] = min(2*root[depth]-leaves[depth+1],
                            sum_leaves[n]-sum_leaves[depth+1])
        if root[depth + 1] < root[depth] - leaves[depth + 1] or root[depth+1] < 0:
            print(-1)
            break
    else:
        print(sum(root)+sum(leaves))


Measured memory_bytes: 22304
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

void main() {
    auto s = readln.chomp;
    int x = 0;
    foreach (c; s) {
        if (c == 'C') {
            if (x == 0) x++;
        } else if (c == 'F') {
            if (x == 1) x++;
        }
    }
    writeln(x == 2 ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vll b(N);
  vll d(N);
  vector<bool> flag(N, false);
  vll ans(0);
  bool ng = false;
  
  for(int i = 0; i < N; i++){
    cin >> b.at(i);
    d.at(i) = (i+1) - b.at(i);
    if(d.at(i) < 0) ng = true;
  }
  //for(auto x: d) cout << x << endl;

  if(ng){
    cout << -1 << endl;
    return 0;
  }

  int counter = N;
  while(counter--){
    for(int i = N-1; i >= 0; i--){
      if(flag.at(i)) continue;
      if(d.at(i) == 0){
        flag.at(i) = true;
        ans.push_back(b.at(i));
        for(int j = i+1; j < N; j++){
          d.at(j)--;
        }
        break;
      }
    }
  }
  if(ans.size() == N){
    for(int i = N-1; i >= 0; i--){
      cout << ans.at(i) << endl;
    }
  }
  else cout << -1 << endl;
  //for(auto x: d) cout << x << endl;
}

Measured memory_bytes: 256