akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int input = sc.nextInt();
        int ans = 1;
        while(input >= ans*2){
            ans *= 2;
        }
        out.println(ans);
        out.flush();

    }

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


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

using namespace std;

static const int64_t MOD = 1000000007;

int main() {
  int N, K;
  cin >> N >> K;
  int64_t small = 0;
  int64_t large = 0;
  int64_t answer = 0;
  for (int k = 1; k <= N + 1; k++) {
    small += k - 1;
    large += N - k + 1;
    if (k >= K) {
      answer = (answer + large - small + 1) % MOD;
    }
  }
  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 3636
//OPTIMIZATONS
#pragma GCC optimize("02")
//CODE
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n,m;
	cin>>n>>m;
	int h[n];
	for(int i=0;i<n;i++) cin>>h[i];
	bool visit[n];
	memset(visit,0,sizeof(visit));
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--; b--;
		if(h[a]>=h[b]) visit[b] = true;
		if(h[b]>=h[a]) visit[a] = true;
	}
	int ans = 0;
	for(int i=0;i<n;i++) if(!visit[i]) ans++;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 4532
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int n, v[100], dp[100][10];
int calc(int i, int m) {
	if (i == n)
		return m ? 0 : -1e9;
	int &ret = dp[i][m];
	if (ret != -1)
		return ret;
	ret = calc(i + 1, m);
	ret = max(ret, v[i] + calc(i + 1, (m + v[i]) % 10));
	return ret;
}
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", &v[i]);
	memset(dp, -1, sizeof(dp));
	printf("%d\n", max(0, calc(0, 0)));
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

// a>=0, b>=0, x*a+y*b=gcd>=0, a>0,b>0=>abs(y)<=a,abs(x)<=b
LL gcdex(LL a,LL b,LL& x, LL& y){
	LL ax=1,ay=0;
	LL bx=0,by=1;
	while(b){
		LL r=a/b;
		LL t=a-r*b; a=b; b=t;
		LL tx=ax-r*bx; ax=bx; bx=tx;
		LL ty=ay-r*by; ay=by; by=ty;
	}
	x=ax;
	y=ay;
	return a;
}
LL modinv(LL a, LL m){
	LL x,y;
	gcdex(a,m,x,y);
	if(x<0){
		x+=m;
	} else if(x>=m){
		x-=m;
	}
	return x;
}
const LL M=1e9+7;
LL B,W;
const int L=2e5+10;
LL ps[L];
LL vs[L];
int main() {
	cin >> B >> W;
	LL i2=modinv(2,M);
	ps[0]=1;
	vs[0]=1;
	for(int i=1;i<=B+W;i++){
		ps[i]=i*ps[i-1]%M;
		vs[i]=i2*vs[i-1]%M;
	}
	LL b=0,w=0;
	for(int i=1;i<=B+W;i++){
		LL r=(1+M-b+M-w)%M;
		//cerr << b << ", " << w << ", " << r << endl;
		cout << (r*i2%M+w)%M << endl;
		if(i>=B){
			b+=vs[i]*ps[i-1]%M*modinv(ps[B-1]*ps[i-B]%M,M)%M;
			b%=M;
		}
		if(i>=W){
			w+=vs[i]*ps[i-1]%M*modinv(ps[W-1]*ps[i-W]%M,M)%M;
			w%=M;
		}
	}

	return 0;
}



Measured memory_bytes: 5376
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
    id = i+1
    key = a[i]
    print('node %i: key = %i,'%(id, key), end='')
    
    if i>0:
        parent = a[id//2-1]
        print(' parent key = %i,'%parent, end='')
    
    if id*2-1<n:
        left = a[id*2-1]
        print(' left key = %i,'%(left), end='')
    if id*2<n:
        right = a[id*2]
        print(' right key = %i,'%(right), end='')
        
    print(' ')


Measured memory_bytes: 5692
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

char s[100] ;

int main ()
{
	scanf(" %s ",s+1);
	int a , b , A=0 , B=0 ;
	a=(s[1]-'0')*10+s[2]-'0',b=(s[3]-'0')*10+s[4]-'0';
	if ( a<=12 && a>=1 ) A=1;
	if ( b<=12 && b>=1 ) B=1;
	if ( A==1 && B==1 ) puts("AMBIGUOUS");
	else if ( A==1 ) puts("MMYY");
	else if ( B==1 ) puts("YYMM");
	else puts("NA");
	return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 50+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n;
vector<int> a;

bool ok(int i, int j){
	vector<int> b(a);
	swap(b[i], b[j]);
	for(int k=0; k<n; k++){
		if (b[k] == k+1) continue;
		return false;
	}
	return true;
}
int main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n;
	a.resize(n);
	for(int i=0; i<n; i++) cin >> a[i];
	for(int i=0; i<n; i++){
		for(int j=i; j<n; j++){
			if (ok(i,j)) return 0*puts("YES");
		}
	}
	puts("NO");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
  
int isSame(const int *A,const int *B)
{
    int p1, p2, t1, t2, f1, f2, e, h;
  
    h = 0;
    for (p1 = 0; p1 < 6; p1++)
    {
        if (A[0] == B[p1] && A[5] == B[5 - p1])
        {
            h = 1;
            break;
        }
    }
    if (!h) return 0;
  
    h = 0;
    for (p2 = 0; p2 < 6; p2++)
    {
        if (p2 == p1 || p2 == 5 - p1) continue;
        if (A[1] == B[p2] && A[4] == B[5 - p2])
        {
            h = 1;
            break;
        }
    }
    if (!h) return 0;
  
    t1 = p1 / 3;
    t2 = t1 > 0 ? 3 - (t1 + p1 % 3) : p1 % 3;
    f1 = p2 / 3;
    f2 = f1 > 0 ? 3 - (f1 + p2 % 3) : p2 % 3;
  
    e = t1 ^ f1;
    e = f2 - (t2 + 1) % 3 != 0 ? !e * 3 : e * 3;
    e += e > 0 ? (t2 + f2) - 1 : 3 - (t2 + f2);
          
    if (A[2] != B[e] || A[3] != B[5 - e]) return 0;
  
    return 1;   
}
  
int main()
{
    int A[6];
    int B[6];
    int i;
  
    for (i = 0; i < 6; i++) scanf("%d", &A[i]);
    for (i = 0; i < 6; i++) scanf("%d", &B[i]);
  
    if (isSame(A, B)) printf("Yes\n");
    else printf("No\n");
  
    return 0;
  
}


Measured memory_bytes: 2104
using System;
using System.Linq;

namespace AtCoderPractic0718
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] h = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            //h[0] = h1  h[N-1] = hN
            int ans = 0;
            int active = 0;

            for(int i=0; i<N; i++)
            {
                if(active >= h[i])
                {
                    active = h[i];
                }
                else
                {
                    ans += h[i] - active;
                    active = h[i];
                }
            }

            Console.WriteLine(ans);
            //k=1 hk=5 　k=2 h2=10 

        }
    }
}


Measured memory_bytes: 28204
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

int main() {
	int N, Y; cin >> N >> Y;
	int res, yen;

	rep(i,0, N+1){
		rep(j, 0, N-i+1) {
			res = N - i - j;
			yen = 10000 * i + 5000 * j + 1000 * res;
			if (yen == Y) {
				cout << i << ' ' << j << ' ' << res << "\n";
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << "\n";
	
	return 0;
}


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

int main()
{
    int n;cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int s=0;
    if(n==1)
    {
        cout<<a[0]<<endl;return 0;
    }
    else if(n==2)
    {
        cout<<max(a[0],a[1])<<endl;
        return 0;
    }
    for(int i=0;i<n;i++)s+=a[i];
    sort(a,a+n);
    bitset<4000000>b;
    b[0]=1;
    for(int i=0;i<n;i++)
    {
        b |= (b<<a[i]);
    }
    for(int j=(s+1)/2;j<s;j++)
    {
        if(b[j])
        {
            cout<<j<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    ll m = INF, sum = 0;;
    rep(i, N){
        ll A, B;
        cin >> A >> B;
        sum += A;
        if(A > B) m = min(m, B);
    }
    if(m == INF) cout << 0 << endl;
    else cout << sum-m << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <assert.h>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
using namespace std;

// #define __DEBUG__

#ifdef __DEBUG__
bool debug_disabled = false;
#else
bool debug_disabled = true;
#endif

#define dbg if (debug_disabled) {} else cerr

void solve() {
    string S, T;
    cin >> S >> T;
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] != T[i]) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.setf(ios::showpoint);
    cout.precision(12);
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int T = 1;
    // cin >> T;
    for (int i = 1; i <= T; ++i) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int a[100+1];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		a[x]=1;
	}
	int s=0;
	for(int i=1;i<=100;i++){
		if(a[i]==1)s++;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8');
// const input = fs.readFileSync('./input.txt', 'utf8');
const L = BigInt(10 ** 9 + 7);

_c(input);

function _c(input: string) {
  const [_N, _A] = input.split('\n');
  const A = _A.split(' ').map((s) => BigInt(s));
  // console.log(A);

  const sumFor: bigint[] = [];
  sumFor[A.length - 1] = A[A.length - 1];
  for (let i = A.length - 2; i > 0; i--) {
    sumFor[i] = A[i] + sumFor[i + 1];
  }
  // console.log(sumFor);

  let sum = 0n;
  for (let i = 0; i < A.length - 1; i++) {
    sum = (sum + A[i] * sumFor[i + 1]) % L;
  }

  console.log(sum.toString());
}


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

typedef long long int ll;

ll gcd(ll a, ll b){
	if(b == 0)
		return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
	return (a * b) / gcd(a, b);
}

int main(){

	int n, m;
	string s, t;
	cin >> n >> m;
	cin >> s;
	cin >> t;

	ll l = lcm(n, m);
	ll c = lcm(l / n, l / m);
	ll a = c / (l / n);
	ll b = c / (l / m);

	int i = 0;
	int j = 0;
	
	while(i < n && j < m){
		if(s[i] != t[j]){
			cout << -1 << endl;
			return 0;
		}
		i += a;
		j += b;
	}

	cout << l << endl;

	return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int a, b; cin >> a >> b;
  int ans;

  if (a >= 13) ans = b;
  else if (a >= 6) ans = b / 2;
  else ans = 0;

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


Measured memory_bytes: 256
// Problem : D - Replacing
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

/*
 * author :Sadik Hassan(_sad_)
 *
*/
#include "bits/stdc++.h"
using namespace std;
using   ll =          long long;
using   ld =          long double;
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define MP            make_pair
#define PI            (acos(-1.0))
#define rep1(i,n)     for(int i=1;i<=n;i++)
#define rep(i,n)      for(int i=0;i<n;i++)
#define SZ(s)         (int)s.size()
#define all(x)        (x).begin(), (x).end()
#define rall(x)       (x).rbegin(), (x).rend()
#define w(t)          int t;cin>>t;while(t--)
#define TSU(s)        transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSL(s)        transform(s.begin(),s.end(),s.begin(),::tolower);
#define _SAD()     	  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0),cout<<fixed<<setprecision(15);

typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;
/*---------------------------------------------------------------------*/

const int N = (int)2e5+5;
const int MOD =(int)1e9+7;
const ll INF = (ll)1e18+5;

int main()
{
    _SAD()
    ll n;
    cin>>n;
    string s;
    while(n>0)
    {
        n--;
        ll aa=(n)%26;
        s+=('a'+aa);
        n/=26;
    }
    for(int i=SZ(s)-1;i>=0;i--)cout<<s[i];
    return 0;
}


Measured memory_bytes: 3656
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n],
    }

    let mut dp = vec![false; 100000 + 1];

    for i in 0..k+1 {
        for j in 0..n {
            if i >= a[j] {
                dp[i] |= !dp[i-a[j]];
            }
        }
    }

    if dp[k] {
        println!("First");
    } else {
        println!("Second");
    }

    
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int x,a,b;
	cin >> x >> a >> b;
	if (b -a >x){
		cout << "dangerous" <<endl;
	}
	else if(b-a > 0){
		cout << "safe" << endl;
	}
	else{
		cout << "delicious" << endl;
	}
	return 0;
}

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

int main(void) {
	int N;
	scanf("%d", &N);
	int T, A;
	scanf("%d %d", &T, &A);
	double tempMin = 1000000;
	int ans;
	for (int i = 0; i < N; i++) {
		int H;
		scanf("%d", &H);
		double diff = abs(A - (T - H * 0.006));
		if (diff < tempMin) {
			tempMin = diff;
			ans = i + 1;
		}
	}
	printf("%d\n", ans );

	return 0;
}


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

int main()
{
    int H,W;
    for(int r=0; ; r++){
        cin >> H >> W;
        if(H==0 && W==0)
            break;
        for(int i=0; i<H; i++){
            if(i%2 == 0){
                for(int j=0; j<W; j++)
                    if(j%2==0)
                        cout << '#';
                    else
                        cout << '.';
            }
            else
                for(int r=0; r<W; r++)
                    if(r%2==0)
                        cout << '.';
                    else
                        cout << '#';
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3100
#include<iostream>

using namespace std;

int main()
{
	int N,L; cin>>N>>L;int count=(2*L+N-1)*N/2;
  	if(N+L-1<0)
    {cout<<count-(L+N-1)<<endl;}
  	else
    {if(L>0)
	  cout<<count-L<<endl;
     else
       cout<<count<<endl;
    }
  	return 0;
}


Measured memory_bytes: 256
s = input()

s_li = list(s)

rev_li = s_li[::-1]

n = len(s_li)
pre_n = (n - 1) // 2
sa_n = (n + 3) // 2 - 1

ans = True

if not s_li == rev_li:
    ans = False

if ans:
    pre_li = s_li[:pre_n]
    #print(pre_li)
    rev_pre_li = pre_li[::-1]
    if not pre_li == rev_pre_li:
        ans = False

if ans:
    sa_li = s_li[sa_n:]
    #print(sa_li)
    rev_sa_li = sa_li[::-1]
    if not sa_li == rev_sa_li:
        ans = False
        
if ans:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 38256
def check(x,l)
  return if l == 0
  l -= 1
  check(x,l)
  xx = x.dup
  xx = [xx,$ca[l]].transpose.map { |ele| ele.inject(:+) }
  if xx[0] < $cmin
    if xx[1..].min >= $x
      $cmin = xx[0]
    else
      check(xx,l)
    end
  end
end

  n,m,$x = gets.strip.split.map(&:to_i)
  $ca = []
  n.times { $ca.append gets.strip.split.map(&:to_i) }
  $ttt = Time.now
  
  xx = $ca.inject(Array.new(m+1,0)){|r,i| [r,i].transpose.map { |ele| ele.inject(:+) } }
  $cmin = xx.shift
  if xx.min < $x
    p -1
    exit
  end
  check(Array.new(m+1,0),n)
  p $cmin

Measured memory_bytes: 14212
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    long long int N,A,B;
    cin>>N>>A>>B;

    cout<<(N/(A+B)*A)+(min(A,N-(N/(A+B)*(A+B))))<<endl;


}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b){
	return *(int*)b - *(int*)a;
}
int main(void){
	int n, k;
	scanf("%d%d", &n, &k);
	int l[n];
	for(int i = 0; i < n; i++){
		scanf("%d", &l[i]);
	}
	qsort(l, n, sizeof(int), compare_int);
	int ans = 0;
	for(int i = 0; i < k; i++){
		ans += l[i];
	}
	printf("%d\n", ans);
}

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 5001
#define int ll



int N,X,T;
int32_t main(){
	fast;
	
	cin>>N>>X>>T;
	
	int a = N / X;
	if (N % X != 0) a++;
	cout<<a * T;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	string a;
	cin >> a;
	ll n = a.size();
	int d[26] = {};
	for(int i = 0;i < n;i++){
		d[a[i]-'a']++;
	}

	ll ans = 0;
	for(int i = 0;i < 25;++i){
		for(int j = i+1;j < 26;++j){
			ans += (ll)d[i] * d[j];
		}
	}

	cout << ans + 1 << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <cstring>
#include <ctime>
#include <map>
#include <algorithm>
#include <cmath>
#define MAXN 100005
#define eps 1e-8
//#define ivorysi
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long int64;
typedef double db;
int N;
struct node {
    int to,next;
}E[MAXN * 2];
int head[MAXN],sumE,sizW[MAXN];
int F[MAXN],G[MAXN],H[MAXN],ans,son[MAXN],fa[MAXN],Ah[MAXN];
char c[MAXN];
void add(int u,int v) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    head[u] = sumE;
}
void addtwo(int u,int v) {
    add(u,v);add(v,u);
}
void dfs(int u) {
    if(c[u] == 'W') sizW[u] = 1;
    else sizW[u] = 0;
    for(int i = head[u] ; i ; i = E[i].next) {
	int v = E[i].to;
	if(v != fa[u]) {
	    fa[v] = u;
	    dfs(v);
	    sizW[u] += sizW[v];
	}
    }
}
void dfs1(int u,int fa) {
    int Sum = 0;
    for(int i = head[u] ; i ; i = E[i].next) {
	int v = E[i].to;
	if(v != fa && sizW[v]) {
	    dfs1(v,u);
	    ++son[u];
	    F[u] += F[v];
	    Sum += F[v];
	}
    }
    if(!son[u] && c[u] == 'W') {
	G[u] = F[u] = 1;return;
    }
    F[u] += son[u] + 1;
    if(c[u] == 'W') F[u] += ((son[u] + 1) ^ 1) & 1;
    else F[u] += (son[u] + 1 & 1);
    G[u] = Sum;
    for(int i = head[u] ; i ; i = E[i].next) {
	int v = E[i].to;
	if(v != fa && sizW[v]) {
	    G[u] = min(G[u],Sum - F[v] + G[v]);
	}
    }
    G[u] += son[u];
    if(c[u] == 'W') G[u] += (son[u] ^ 1) & 1;
    else G[u] += son[u] & 1;
    G[u] = min(G[u],F[u]);
    H[u] = 0x7fffffff;
    if(son[u] != 1) {
    		
	pii t = mp(0,0);
	for(int i = head[u] ; i ; i = E[i].next) {
	    int v = E[i].to;
	    if(v != fa && sizW[v]) {
		if(F[v] - G[v] > t.se) t.se = F[v] - G[v];
		if(t.se > t.fi) swap(t.se,t.fi);
	    }
	}
	int tmp = c[u] == 'W' ? ((son[u] - 1) ^ 1) & 1 : (son[u] - 1) & 1;
	H[u] = Sum - t.fi - t.se + tmp + son[u] - 1;
	Ah[u] = tmp;
    }
    for(int i = head[u] ; i ; i = E[i].next) {
	int v = E[i].to;
	if(v != fa && sizW[v]) {
	    int tmp = Sum - F[v] + H[v] + 1 - Ah[v] + (Ah[v] ^ 1) + son[u];
	    int t = c[u] == 'W' ? (son[u] ^ 1) & 1 : son[u] & 1;
	    if(tmp + t < H[u]) {
		H[u] = tmp + t;Ah[u] = t;
	    }
	}
    }
}
void Init() {
    scanf("%d",&N);
    int u,v;
    for(int i = 1 ; i < N ; ++i) {
	scanf("%d%d",&u,&v);
	addtwo(u,v);
    }
    scanf("%s",c + 1);
    dfs(1);
}
void Solve() {
    ans = 0x7fffffff;
    dfs1(1,0);
    if(sizW[1] == 0) ans = 0;
    else if(sizW[1] == 1) ans = 1;
    else {
	for(int i = 1 ; i <= N ; ++i) {
	    if(sizW[i] == sizW[1]) {
		ans = min(ans,G[i]);
		ans = min(ans,F[i]);
		ans = min(ans,H[i]);
	    }
	}
    }
    printf("%d\n",ans);
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Init();
    Solve();
    return 0;
}


Measured memory_bytes: 10624
#include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int Y,M,D,ans=1;
		cin>>Y>>M>>D;
		int cny=Y,cnm=M;
		if(cny%3!=0){
			if(cnm%2!=0){
				ans+=20-D;
				ans+=(10-cnm)/2*20;
				ans+=((10-cnm)/2+1)*19;
			}
			else{
				ans+=19-D;
				ans+=(10-cnm)/2*20;
				ans+=(10-cnm)/2*19;
			}
		}
		else{
			ans+=20-D;
			ans+=(10-cnm)*20;	
		}
		cny++;
		while(1000-cny>0){
			if(cny%3==0){
				ans+=200;
			}
			else{
				ans+=195;
			}
			cny++;
		}
	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), x.end()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
const double eps = 1e-9;
int cnt[50][50];

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n; cin >> n;
  int nx = 0;
  vector<pii> a;
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    int ok = 1;
    // trav(x, s) ok |= x == '.';
    ll v = 0, it = 0;
    for (int j = 0; j < sz(s); j++) {
      if (s[j] != '.')
        v = v * 10 + s[j]-'0';
      if (s[j] == '.') {
        ok = 0;
        continue;
      }
      if (ok) continue;
      it++;
    }
    while (it < 9)
      v *= 10ll, it++;
    int p2 = 0, p5 = 0;
    ll nv = v;
    while (v % 2 == 0)
      v /= 2, p2++;
    while (v % 5 == 0)
      v /= 5, p5++;
    // a.push_back(mp(p2, p5));
    cnt[p2][p5]++;
  }
  ll ans = 0;
  for (int i = 0; i < 47; i++)
    for (int j = 0; j < 22; j++)
      for (int ii = 0; ii < 47; ii++)
        for (int jj = 0; jj < 22; jj++)
          if (ii != i || jj != j) {
            if (min(i+ii, j+jj) >= 18)
              ans += cnt[i][j] * 1ll * cnt[ii][jj];
          } else {
            if (min(i+ii, j+jj) >= 18)
              ans += cnt[i][j] * 1ll * (cnt[ii][jj] - 1);
          }
  ans /= 2;
  // for (int i = 0; i < n; i++)
  //   for (int j = i+1; j < n; j++)
  //     if (min(a[i].st+a[j].st, a[i].nd+a[j].nd) >= 18)
  //       ans++;
  cout << ans << "\n";
  return 0;
}


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

const int MAXV = 50;
ll dp[55][2];

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

  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  memset(dp, -1, sizeof(dp));

  dp[0][0] = 0;
  for (int d = 0; d < MAXV; d++) {
    ll mask = 1LL << (MAXV - d - 1);

    int num = 0;
    for (int i = 0; i < n; i++) if(a[i] & mask) ++num;

    //xのd桁目を0,1にするときの数
    ll cost0 = mask * num;
    ll cost1 = mask * (n - num);

    //0:tight 1:loose
    //loose -> loose
    if(dp[d][1] != -1) {
      dp[d + 1][1] = max(dp[d + 1][1], dp[d][1] + (max(cost0, cost1)));
    }
    //tight -> tight
    if(dp[d][0] != -1) {
      if(k & mask) dp[d + 1][0] = max(dp[d + 1][0], dp[d][0] + cost1); //1が立ってる
      else dp[d + 1][0] = max(dp[d + 1][0], dp[d][0] + cost0);
    }

    //tight -> loose
    if(dp[d][0] != -1) {
      if(k & mask) dp[d + 1][1] = max(dp[d + 1][1], dp[d][0] + cost0);
    }
  }

  cout << max(dp[MAXV][0], dp[MAXV][1]) << endl;
}

Measured memory_bytes: 1024
#include <iostream> 
#include <vector>
#include <algorithm>
#include <cmath>
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define debug freopen("input", "r", stdin);freopen("output", "w", stdout)
#define endl '\n'
#define all(var) var.begin(), var.end()
typedef unsigned long long ll;
int const MOD = 1e9+7;
using namespace std;

ll fast_expo(ll a, ll n){
    ll res = 1;
    while(n){
        if(n&1)
            res = res*a%MOD;
        a=a*a%MOD;
        n >>= 1;
    }
    return res%MOD;
}

ll nCr(ll n, ll r){
    ll res1 = 1, res2 = 1;
    for(ll i = 1; i <= r; i++){
        res1 = res1*(n-i+1)%MOD;
        res2 = res2*i%MOD;
    }
    return res1*fast_expo(res2, MOD-2)%MOD;
}

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = ((((fast_expo(2, n)-1-nCr(n,a)+MOD)%MOD) - nCr(n,b)+MOD)%MOD)%MOD;
    cout << ans << endl;
}


Measured memory_bytes: 256
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,s,z[3018][3018]={1};
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>s;
	for(;i++<n;)
	{
		cin>>k;
		for(j=k;j--;)z[i][j]=2*z[i-1][j]%998244353;
		for(j=k-1;j++<s;)
		{
			z[i][j]=(2*z[i-1][j]+z[i-1][j-k])%998244353;
		}
	}
	cout<<z[n][s];
}

Measured memory_bytes: 74372
Q, H, S, D = map(int, input().split())
n = int(input())
coffee = [[Q*4, 0.25, Q], [H*2, 0.5, H], [S, 1, S], [D/2, 2, D]]
coffee_cost = sorted(coffee)
cost = 0
Qt = n
for i in range(4):
    cost += (round(Qt // coffee_cost[i][1]) * coffee_cost[i][2])
    Qt = round(Qt % coffee_cost[i][1])
    if Qt == 0:
        print(int(cost))
        exit()


Measured memory_bytes: 9192
K = int(input())
S = 0

def gcd(a,b):
   while b != 0:
       a, b = b, a % b
       if b ==0:
           return a
A1 = [0,0]
A2 = [0,0,0]
for i in range(1, K+1):
    S = S + i

if K > 1:
    for j in range(1, K):
        A1[0] =  j
        for k in range(j+1,K+1):
            A1[1] = k
            S += 6 * gcd(A1[1],A1[0])

if K > 2:
    for i1 in range(1, K-1):
        A2[0] = i1
        for k1 in range(i1+1, K):
            A2[1] = k1
            for j1 in range(k1+1,K+1):
                A2[2] = j1
                G3 = gcd(A2[2],A2[1])
                if G3 >= A2[0]:
                    S += 6 * gcd(G3,A2[0])
                else:
                    S += 6 * gcd(A2[0],G3)
print(S)

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

using namespace std;

int main(){
        int N;
        cin>>N;
        vector <int> A(N), B(N);
        int amax=0;
        for(int i=0;i<N;i++){
                cin>>A[i]>>B[i];
                if(A[amax]<=A[i]){
                        amax=i;
                }
        }
        cout<<A[amax]+B[amax]<<endl;
        return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define sec second
#define fir first
#define mo  998244353
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)
#define adiii\                               
  ios_base::sync_with_stdio(false);\                                      
  cin.tie(NULL);\
  cout.tie(NULL);									
 
ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}
ll gcd(ll a,ll b) {if (b == 0) return a;return gcd(b, a % b);}

int main(){
	adiii
	ll n;cin>>n;
	vector <ll> f1(100005,0),f2(100005,0);
	ll x;
	rep(i,1,n+1){cin>>x; i%2 ? f1[x]++ : f2[x]++;}
	vector <pair<ll,ll>> h1,h2; 
	rep(i,1,100005){
		if(f1[i]>0) h1.pb({f1[i],i});
		if(f2[i]>0) h2.pb({f2[i],i});
	}
	ll n1 = h1.size();
	ll n2 = h2.size();
	sort(h1.begin(),h1.end());
	sort(h2.begin(),h2.end());

	if(h1[n1-1].second != h2[n2-1].second) cout<<n - h1[n1-1].first - h2[n2-1].first;
	else{
		if(n1==1 && n2==1) cout<<n/2;
		if(n1==1 && n2>1) cout<<n/2 - h2[n2-2].first;
		if(n1>1 && n2==1) cout<<n/2 - h1[n1-2].first;
		if(n1>1 && n2>1){
			if(h2[n2-1].first>h1[n1-1].first) cout<<n - h1[n1-2].first - h2[n2-1].first;
			else if(h1[n1-1].first < h2[n2-1].first ) cout<<n - h2[n2-2].first - h1[n1-1].first;
			else cout<<n - h2[n2-1].first - max(h2[n2-2].first,h1[n1-2].first);
		}
		
		
	}	
	
	

	
}


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
using namespace std;

int main() {
	long long N, M, H[100005], A[100005], B[100005], R[100005];
	cin >> N >> M;
	rep(i, N) {
		cin >> H[i];
		R[i] = 1;
	}
	rep(i, M) {
		cin >> A[i] >> B[i];
	}
	rep(i, M) {
		if (H[A[i] - 1] == H[B[i] - 1]) {
			R[A[i] - 1] = 0;
			R[B[i] - 1] = 0;
		} else if (H[A[i] - 1] < H[B[i] - 1]) {
			R[A[i] - 1] = 0;
		}
		else {
			R[B[i] - 1] = 0;
		}
	}
	long long count = 0;
	rep(i, N) {
		if (R[i] == 1) {
			count += 1;
		}
	}
	cout << count << endl;
	return 0;
}

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

int main(){
    int n,max_a = -1,max_i = -1;
    cin >> n;
    vector<int> a(n);
    bool is_p = 0,is_n = 0;

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

        if(a[i]>=0) is_p = 1;
        else is_n = 1;
        
        if(max_a<abs(a[i])) {max_a = abs(a[i]);max_i = i;}
    }
    if(a[max_i]>=0) is_n = 0;
    else is_p = 0;

    cout << 2*(n-1) << endl;
    for(int i = 0;i < n;i ++){
        if(max_i!=i) cout << max_i+1 << " " << i+1 << endl;
    }
    if(is_p) for(int i = 0;i < n-1;i ++){
        cout << i+1 << " " << i+2 << endl;
    }
    else for (int i = n-1;i >= 1;i --){
        cout << i+1 << " " << i << endl;
    }

    return 0;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	long long n;
	cin >> n;
	vector<int> vs(n);
	vector<int> ws(n);
	for(int i=0;i<n;i++){
		cin >> vs[i] >> ws[i];
	}
	int q;
	cin >> q;
	
	vector<vector<pair<int,int>>> rek(n);
	int han=11;
	int sikiri=(1<<han)-1;
	for(int i=0;i<n;i++){
		vector<int> ta,ta2;
		int cur=i;
		for(int j=0;j<han;j++){
			ta.push_back(ws[cur]);
			ta2.push_back(vs[cur]);
			int nex=(cur-1)/2;
			if(cur==0) break;
			cur=nex;
			if(i>=sikiri && nex<sikiri) break;
		}
		
		vector<pair<int,int>> zen(1,make_pair(0,0));
		for(int j=0;j<(int)ta.size();j++){
			vector<pair<int,int>> nzen=zen;
			for(int k=0;k<(int)zen.size();k++){
				pair<int,int> p0=make_pair(zen[k].first+ta[j],zen[k].second+ta2[j]);
				nzen.push_back(p0);
			}
			nzen.swap(zen);
		}
		sort(zen.begin(),zen.end());
		int mx=0;
		for(int i=0;i<(int)zen.size();i++){
			mx=max(mx,zen[i].second);
			zen[i].second=mx;
			//cout << zen[i].first << " " << zen[i].second << "\n";
		}
		//cout << "\n";
		rek[i]=zen;
	}
	
	for(int tc=0;tc<q;tc++){
		int v,L;
		cin >> v >> L;
		v--;
		
		vector<int> left;
		for(int i=0;i<(int)rek[v].size();i++){
			left.push_back(rek[v][i].first);
		}
		int cur=v;
		bool bo=true;
		for(int j=0;j<han;j++){
			int nex=(cur-1)/2;
			if(cur==0){
				bo=false;
				break;
			}
			cur=nex;
			if(v>=sikiri && nex<sikiri) break;
		}
		if(!bo){
			int ind=(int)(upper_bound(left.begin(),left.end(),L)-left.begin());
			if(ind==0){
				cout << 0 << "\n";
			}else{
				ind--;
				cout << rek[v][ind].second << "\n";
			}
			continue;
		}
		vector<int> right;
		for(int i=0;i<(int)rek[cur].size();i++){
			right.push_back(rek[cur][i].first);
		}
		
		int res=0;
		int rind=(int)right.size();
		rind--;
		for(int i=0;i<(int)left.size();i++){
			if(left[i]>L) break;
			long long dif=L-left[i];
			while(rind>=0 && right[rind]>dif) rind--;
			if(rind<0) break;
			res=max(res,rek[v][i].second+rek[cur][rind].second);
		}
		cout << res << "\n";
	}
	return 0;
}

Measured memory_bytes: 212076
fun main(args: Array<String>) {
    abc142c()
}

fun abc142c() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map { it.toInt() }

    val answer = aList.mapIndexed { index, i -> Pair(index + 1, i) }
        .sortedBy { it.second }.map { it.first }

    println(answer.joinToString(separator = " "))
}


Measured memory_bytes: 86368
a,x,b,y=map(int,input().split());m=10**9+7;N=2000010;F=[1 for i in range(N+1)]
def v(x):return pow(x,m-2,m)
for i in range(N):F[i+1]=-~i*F[i]%m
def f(r,c):return F[r+c]*v(F[r])*v(F[c])%m
print((f(b+1,y+1)-f(b+1,x)-f(a,y+1)+f(a,x))%m)

Measured memory_bytes: 82200
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int ans = 0,sum=0;
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	ans += max(e, f);
	sum += a + b + c + d;
	sum -= min(min(a, b), min(c, d));
	cout << sum + ans << endl;
}


Measured memory_bytes: 3092
#include <stdio.h>
int main() {
	long long A, B, K;
	long long p[201] = { 0 };
	scanf("%lld%lld%lld", &A, &B,&K);
	if (2 * K <= (B - A) + 1) {
		for (int i = 0; i < K; i++) {
			p[i] = A + i;
			p[2 * K - i - 1] = B - i;
		}
		for (int i = 0; i < 2 * K; i++) {
			printf("%lld\n", p[i]);
		}
	}
	else {
		for (int i = 0; i <= (B - A); i++) {
			p[i] = A + i;
			printf("%lld\n", p[i]);
		}
	}
	return 0;
}


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

#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main() {
    fast;
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> arr(n);
    for (ll i = 0; i < n; i++)
        cin >> arr[i].first >> arr[i].second;
    sort(arr.begin(), arr.end());
    ll cost = 0, i = 0;
    while (m) {
        if (arr[i].second > m) {
            cost += arr[i].first*m;
            m = 0;
        }
        else {
            cost += arr[i].first* arr[i].second;
            m -= arr[i].second;
        }
        i++;
    }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b,a%b));
}

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin>>n;
    vec<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(ALL(a));
    
    ll mini=INF,num=0;
    rep(i,n-1){
        mini=min(mini,abs(a[n-1]/2 - a[i]));
        if(mini==abs(a[n-1]/2 -a[i])) num=i;
        }
    cout<<a[n-1]<<" "<<a[num]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int, int> P;
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> G[N];
    for(int i = 0; i < M; i++){
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        G[u].push_back(v);
    }
    queue<P> q, temp;
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    q.push(P(s, 0));
    vector<vector<int>> d(3, vector<int>(N, -1));
    d[0][s] = 0;
    while(!q.empty()){
        P v = q.front();
        q.pop();
        temp.push(v);
        while(!temp.empty()){
            P u = temp.front();
            temp.pop();
            for(int j: G[u.first]){
                int te = u.second + 1 - v.second;
                if(te < 3 && d[te][j] == -1){
                    temp.push(P(j, u.second + 1));
                    d[te][j] = u.second + 1;
                }
                else if(te == 3 && d[0][j] == -1){
                    q.push(P(j, u.second + 1));
                    d[0][j] = u.second + 1; 
                }
            }
        }
    }
    if(d[0][t] == -1) cout << -1 << endl;
    else cout << d[0][t] / 3 << endl;
}


Measured memory_bytes: 10188
#include <stdio.h>

int main(void){

	int x, y;
	while(1){
		scanf("%d %d", &x, &y);
		if(x == 0 && y == 0)break;
		
		if(x < y){
			printf("%d %d\n", x, y);
		}else{
			printf("%d %d\n", y, x);
		}
		
	}

	return 0;
}

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

int main(){
 	int n,k,x,sum=0;
  	cin>>n>>k;
  	for(int i=1;i<=n;i++){
      	cin>>x;
    	if(x>k)
          	sum+=(x-k)*2;
      	else
          	if(x<k-x)
              	sum+=x*2;
      		else
              	sum+=(k-x)*2;
    }
  	cout<<sum<<endl;
}

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

signed main () {
    string s;
    cin >> s;
    int n = int(s.size()), k;
    cin >> k;
    set < string > used;
    vector < string > srt;
    for (int i = 0; i < n; ++i) {
        string cur = "";
        for (int j = i; j < min(i + k, n); ++j) {
            cur += s[j];
            if (used.find(cur) == used.end()) {
                srt.push_back(cur);
                used.insert(cur);
            }
        }
    }
    sort(srt.begin(), srt.end());
    cout << srt[k - 1] << '\n';
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string Order;
    rep(i,tx-sx) Order.push_back('R');
    rep(i, ty-sy) Order.push_back('U');
    rep(i,tx-sx) Order.push_back('L');
    rep(i, ty-sy+1) Order.push_back('D');
    rep(i,tx-sx+1) Order.push_back('R');
    rep(i, ty-sy+1) Order.push_back('U');
    Order.push_back('L');
    Order.push_back('U');
    rep(i,tx-sx+1) Order.push_back('L');
    rep(i, ty-sy+1) Order.push_back('D');
    Order.push_back('R');

    cout << Order << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp( a, b ) make_pair( a, b )
#define mt( ... ) make_tuple( __VA_ARGS__ )

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )

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

#define MOD ( 1e9 + 7 )


int main()
{
	ll N, M;
	cin >> N >> M;

	vector<ll> v( N );
	rep( i, N )
	{
		cin >> v[i];
	}

	vector<Pll> vv( M );
	rep( i, M )
	{
		cin >> vv[i].F >> vv[i].S;
	}

	// Aiの昇順にソート
	sort( ALL( v ) );

	// Cの値で降順ソート
	sort ( ALL( vv ), []( Pll a, Pll b ) {
			return ( a.S > b.S );
		} );

	ll ptr = 0;
	rep( i, M )
	{
		// vは値の昇順にソートされているので、前から書き換えて行けばOK
		rep( j, vv[i].F )
		{
			if ( v[ptr] < vv[i].S )
			{
				v[ptr++] = vv[i].S;
			}
			else
			{
				goto end;
			}
		}
	}
end:

	ll sum = 0;
	for ( auto &&it : v )
	{
		sum += it;
	}

	cout << sum << endl;

	return ( 0 );
}


Measured memory_bytes: 2560