akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long a[300010];
long long b[300010];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    b[0]=a[0];
    for(int i=1;i<n;i++){
        b[i]=a[i]+b[i-1];
    }
    long long ans=abs(b[0]-b[n-1]+b[0]);
    for(int i=1;i<n-1;i++){
        ans=min(abs(b[i]-b[n-1]+b[i]),ans);

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


Measured memory_bytes: 3840
import std;

void main() {
	int N, M, Q;
	scanf("%d %d %d\n", &N, &M, &Q);
	auto as = new int[Q];
	auto bs = new int[Q];
	auto cs = new int[Q];
	auto ds = new int[Q];
	foreach(q;0..Q) {
		int a, b, c, d;
		scanf("%d %d %d %d\n", &a, &b, &c, &d);
		as[q] = a-1;
		bs[q] = b-1;
		cs[q] = c;
		ds[q] = d;
	}
	auto As = new int[10];
	long scoremax = -1;
	foreach(d0; 0..M){
		foreach(d1; d0..M){
			foreach(d2; d1..M){
				foreach(d3; d2..M){
					foreach(d4; d3..M){
						foreach(d5; d4..M){
							foreach(d6; d5..M){
								foreach(d7; d6..M){
									foreach(d8; d7..M){
										foreach(d9; d8..M){
											long score;
											As[0] = d0;
											As[1] = d1;
											As[2] = d2;
											As[3] = d3;
											As[4] = d4;
											As[5] = d5;
											As[6] = d6;
											As[7] = d7;
											As[8] = d8;
											As[9] = d9;
											foreach(q; 0..Q){
												if (As[bs[q]]-As[as[q]] == cs[q])
													score += ds[q];
											}
											scoremax = max(score, scoremax);
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	scoremax.write;
}


Measured memory_bytes: 3696
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	int cnt = 0;
	if(a%2 == 1) cnt++;
	if(b%2 == 1) cnt++;
	if(c%2 == 1) cnt++;
	if(cnt == 1){
		if(a%2 == 1){
			b++;
			c++;
		}
		else if(b%2 == 1){
			a++;
			c++;
		}
		else{
			a++;
			b++;
		}
		ans++;
	}
	else if(cnt == 2){
		if(a%2 == 0){
			b++;
			c++;
		}
		else if(b%2 == 0){
			a++;
			c++;
		}
		else{
			a++;
			b++;
		}
		ans++;
	}
	int mx = max({a,b,c});
	ans += (3*mx - a - b - c)/2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;
//using namespace boost::multiprecision;

int main(){

    int s;
    cin >> s;

    int s1 = s / 100;
    int s2 = s % 100;

    if(1 <= s1 && s1 <= 12){
        if(1 <= s2 && s2 <= 12){
            cout << "AMBIGUOUS";
        }else{
            cout << "MMYY";
        }
    }else{
        if(1 <= s2 && s2 <= 12){
            cout << "YYMM";
        }else{
            cout << "NA";
        }
    }

    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {

        static void Main(string[] args)
        {
            int[] HW = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int H = HW[0];
            int W = HW[1];
            char[,] hairetu = new char[H, W];
            for (int i = 0; i < H; i++)
            {
                char[] tmp = Console.ReadLine().ToCharArray();
                for (int j = 0; j < W; j++)
                {
                    hairetu[i, j] = tmp[j];
                }
            }
            List<int> num = new List<int>();
            Boolean[,] yoko = new Boolean[H, W];
            Boolean[,] tate = new Boolean[H, W];
            for (int i = 0; i < H; i++)
            {
                Boolean flg = false;
                for (int j = 0; j < W; j++)
                {
                    if (hairetu[i, j] == '#')
                    {
                        if (!num.Contains(j))
                        {
                            num.Add(j);
                        }
                        flg = true;
                    }
                }
                if (flg)
                {
                    for (int j = 0; j < W; j++)
                    {
                        yoko[i, j] = true;
                    }
                }
            }
            if (num.Count != 0)
            {
                for (int j = 0; j < num.Count; j++)
                {
                    for (int i = 0; i < H; i++)
                    {
                        tate[i, num[j]] = true;
                    }
                }
            }
            string ans = "";
            for (int i = 0; i < H; i++)
            {
                Boolean f = false;
                for (int j = 0; j < W; j++)
                {
                    if (tate[i, j] && yoko[i, j])
                    {
                        ans += hairetu[i, j].ToString();
                        f = true;
                    }
                }
                if (f)
                {
                    ans += "\n";
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 46656
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
int dp[25][15][170];
int main(int argc,char const* argv[])
{
  int n,k,s;
  while(cin >> n >> k >> s && n)
    {
      memset(dp,0,sizeof(dp));
      /*i under 1 set in i under 2 set in ... in i under n set*/  
      dp[0][0][0]=1;
      for(int i=1;i<=n;i++)
	{
	  for(int j=0;j<=k;j++)
	    {
	      for(int l=0;l<=s;l++)
		{
		  if(l-i>=0 && j!=0) dp[i][j][l]+=dp[i-1][j-1][l-i];
		  dp[i][j][l]+=dp[i-1][j][l];
		}
	    }
	}
      cout << dp[n][k][s] << endl;
    }
  return 0;
}



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

using namespace std;

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

    int n;
    cin>>n;

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

    int q;
    cin>>q;

    while(q--)
    {
        int key;
        cin>>key;

        cout<<(lower_bound(arr.begin(),arr.end(),key)-arr.begin())<<" "
            <<(upper_bound(arr.begin(),arr.end(),key)-arr.begin())<<endl;
    }

    return 0;
}



Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n, q;
	cin >> n >> q;
	char s[100000];
	cin >> s;
	VI l(q), r(q);
	REP(i, q)
		cin >> l[i] >> r[i];
	VI k(n);
	k[0] = 0;
	for(int i = 1;i < n;i++){
		if (s[i - 1] == 'A' && s[i] == 'C')
			k[i] = k[i - 1] + 1;
		else
			k[i] = k[i - 1];
	}
	REP(i, q) {
		cout << k[r[i] - 1] - k[l[i] - 1] << '\n';
	}
}

Measured memory_bytes: 2048
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int x;cin>>x;
  int kyu;
  if(x<2000)kyu=1;
  if(x<1800)kyu=2;
  if(x<1600)kyu=3;
  if(x<1400)kyu=4;
  if(x<1200)kyu=5;
  if(x<1000)kyu=6;
  if(x<800)kyu=7;
  if(x<600)kyu=8;
  cout<<kyu<<"\n";
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(void){
  int N,X,T;
  cin >> N >> X >> T;
  if(N%X > 0){
  	cout << ((N/X)+1)*T<< endl;
  }else{
    cout << (N/X)*T << endl;
  }
  return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long[] luca = new long[87];
		luca[0] = 2;
		luca[1] = 1;
		
		if (n >= 2) {
			for (int i = 2; i <= n; i++) {
				luca[i] = luca[i-1]+luca[i-2];
			}
		}
		
		System.out.println(luca[n]);
	}
}


Measured memory_bytes: 23892
N,M = map(int,input().split())
if (N == 0 or N == 1) and (M == 0 or M == 1):
    print(0)
elif (N == 0 or N == 1) and M != 0 and M != 1:
    print(M*(M-1)//2)
elif N != 0 and N != 1 and (M == 0 or M == 1):
    print(N*(N-1)//2)
else:
    print(N*(N-1)//2 + M*(M-1)//2)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

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

  ll tmp = n%(a+b);
  ll tasu;
  if(tmp>a){
    tasu=a;
  }else if(tmp<=a){
    tasu = tmp;
  }
  ll tmp2 = n/(a+b);

  ll ans = a*tmp2;
  cout << ans+tasu << endl;
  //cout << 7%8 << endl;//=7
  return 0;
}



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

long long GetLeastCommonMultiple(long long a, long long b)
{
	long long m = a;
	long long n = b;
	long long temp;
	
	while (m % n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}	
	return a * b / n;
}

int main()
{
	long long a, b, c, d; cin >> a >> b >> c >> d;
	
	long long ans;
	long long leastCommom_c_d = GetLeastCommonMultiple(c, d);

	// 1 to a - 1 のうちc       で割り切れるものの数 = (a - 1) / c 
	// 1 to a - 1 のうちd       で割り切れるものの数 = (a - 1) / d
	// 1 to a - 1 のうちcまたはdで割り切れるものの数 = (a - 1) / c  +  (a - 1) / d - (a - 1) / leastCommom_c_d   ①

	// 1 to b     のうちc       で割り切れるものの数 = b / c 
	// 1 to b     のうちd       で割り切れるものの数 = b / d
	// 1 to b     のうちcまたはdで割り切れるものの数 = b / c  +  b / d - b / leastCommom_c_d   ②	

	// a to b     のうちcまたはdで割り切れるものの数 = ② - ①

	// a to b     のうちcでもdでも割り切ないものの数 = b - a + 1 - (② - ①)
	
	long long x = (a - 1) / c + (a - 1) / d - (a - 1) / leastCommom_c_d;
	long long y = b / c + b / d - b / leastCommom_c_d;
		
	ans = b - a + 1;
	ans -= y - x;

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

Measured memory_bytes: 256
use std::cmp;
use std::collections::BinaryHeap; // 優先度付きキュー
use std::collections::HashMap; // 連想配列
use std::collections::HashSet; // 連想配列 キーのみ
use std::collections::VecDeque; // キュー or スタック
use std::io::Read;
use std::usize::MAX;

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)*}};}
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)*}};}
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, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        k: usize,
        v: [i64;n]
    }

    let mut ans = -999_999_999;

    let length = cmp::min(k, n);
    for i in 0..length + 1 {
        for l in 0..i + 1 {
            let r = i - l;
            let mut minus: BinaryHeap<i64> = BinaryHeap::new();

            let mut total = 0;
            let left_max = cmp::min(l, k);
            for i in 0..left_max {
                total += v[i];
                if v[i] < 0 {
                    minus.push(v[i] * -1);
                }
            }

            let right_min = cmp::max(n - r, left_max);
            for i in (right_min..n).rev() {
                total += v[i];
                if v[i] < 0 {
                    minus.push(v[i] * -1);
                }
            }

            let delete = cmp::min(k - i, minus.len());
            for i in 0..delete {
                let minus_num = minus.pop().unwrap();
                total += minus_num;
            }

            ans = cmp::max(ans, total);
        }
    }

    println!("{}", ans);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 8572
import java.util.Scanner;

class Main{



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		String string = sc.next();
		int count =0 ;
		for(int i = 0;i < string.length();i++){
			if(string.charAt(i) == '2'){
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  vector<int> v;
  rep(i,3){
    int a;
    cin >> a;
    v.push_back(a);
  }
  sort(ALLOF(v));

  int ret = 10000000;

  int A = v[0], B = v[1];
  int mx = v[2];

  int a = mx - A;
  int b = mx - B;
  if(a%2 == b%2){
    if(a%2 == 1){
      ret = min(ret, 1 + (a-1)/2 + (b-1)/2);
    }else{
      ret = min(ret, a/2 + b/2);
    }
  }else{
    a = mx+1 - A;
    b = mx+1 - B;
    if(a%2 == 1){
      a--;
    }
    else if(b%2 == 1){
      b--;
    }
    ret = min(ret, 1 + a/2 + b/2);
  }

  cout << ret << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
        }
    return true;
}


map<string,int>m;
int main()
{
    weewoo;
    vector<string>a;
    set<string>ans;
    ll n;
    cin >> n;
    int mx = 0;
    for(int i=0;i<n;i++){
        string x;
        cin >> x;
        a.push_back(x);
        m[x]++;
        mx = max(m[x],mx);
    }
    for(int i=0;i<n;i++){
        if(m[a[i]]==mx)
            ans.insert(a[i]);
    }
    for(auto i : ans)
        cout << i << ' ';
    cout << endl;
    return 0;
}


Measured memory_bytes: 34800
#include<bits/stdc++.h>
 
using namespace std;
 
int n, a[105], ans;
 
int main(){
	scanf("%d%d", &n, &a[0]);
	for(int i = 1; i < n; i++){
		scanf("%d", &a[i]);
      	if(a[i] == a[i-1]){
          ans++;
          a[i] = 0;
        }
	}
	printf("%d\n", ans);
}

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

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> p(a), q(b), r(c);
	long long ans = 0;
	for (int i = 0; i < a; ++i){
		cin >> p[i];
	}
	for (int i = 0; i < b; ++i){
		cin >> q[i];
	}
	for (int i = 0; i < c; ++i){
		cin >> r[i];
	}
	sort(p.rbegin(), p.rend());
	sort(q.rbegin(), q.rend());
	sort(r.rbegin(), r.rend());
	int nx = 0, ny = 0, nz = 0;
	int np = 0, nq = 0, nr = 0;
	while (nx + ny + nz < x + y){
		if ((ny == y && p[np] >= r[nr]) || (nx < x && p[np] >= q[nq] && p[np] >= r[nr])){
			ans += p[np++];
			nx++;
		}
		else if ((nx == x && q[nq] >= r[nr]) || (ny < y && q[nq] >= p[np] && q[nq] >= r[nr])){
			ans += q[nq++];
			ny++;
		}
		else{
			ans += r[nr++];
			nz++;
		}
	}
	cout << ans;
	return 0;
}



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

signed main(void)
{
	int n; cin >> n;
	set<char> s;
	rep(i, n) 
	{
		char c;
		cin >> c;
		s.insert(c);
	}
	if (s.size() == 4)
		cout << "Four" << endl;
	if (s.size() == 3)
		cout << "Three" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>

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

using namespace std;

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

	int ans=2*k;
	rep(i,n-1) if(s[i]==s[i+1]) ans++;
	cout<<min(ans,n-1)<<endl;

	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;
ll const MOD = 1e9+7;

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

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

int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  k = min(k, n-1);

  COMinit();

  rep(i, k+1) {
    ans += COM(n, i) * COM(n-1, i);
    ans %= MOD;
  }

  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 12160
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())

A = [0] * N
for i in range(N):
    A[i] = int(input())

dp = [0] * N

dp[0] = A[0]
cur = 1
for i in range(1, N):
    left = -1
    right = cur
    while right - left > 1:
        mid = left + (right - left) // 2
        if dp[mid] < A[i]:
            left = mid
        else:
            right = mid
    if cur == right:
        cur += 1
    dp[right] = A[i]
print(cur)

    


Measured memory_bytes: 10652
N, M = map(int,input().split())
students = []
points = []
for _ in range(N):
    students.append(list(map(int,input().split())))
for _ in range(M):
    points.append(list(map(int,input().split())))

for i in range(N):
    MIN = 10 ** 10
    index = -1
    for j in range(M):
        if MIN > abs(students[i][0] - points[j][0]) + abs(students[i][1] - points[j][1]):
            MIN = abs(students[i][0] - points[j][0]) + abs(students[i][1] - points[j][1])
            index = j
    print(index + 1)

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

using namespace std;

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

  bool c = false, f = false;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'C') c = true;
    if (s[i] == 'F' && c) f = true;
  }

  if (c && f)
    puts("Yes");
  else
    puts("No");

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define fast       ios_base::sync_with_stdio(false); cin.tie(NULL);

int main (){
    double R;
    cin>>R;
    double ans = 2*R*3.14;
    cout<<ans<<"\n";
    
}

Measured memory_bytes: 3784
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  int ret = INF;
  for (int i = 0; i < n; ++i) {
    int len = 0, x;
    cin >> x;
    while (x % 2 == 0) {
      x /= 2;
      ++len;
    }
    ret = min(ret, len);
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 384
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k%2){
		cout<<b-a<<endl;

	}
	else{
		cout<<a-b<<endl;
	}
} 
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long 
#define double long double
#define MAX 1010
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = INF;
ll modulo = pow(10,9)+7;
string dir = "DRUL";
int dif[4] = { 1, 1, -1, -1};
void deal(){
	int h,w,n, x, y;
	cin>>w>>h>>n>>x>>y;
	string a,b;
	cin>>a>>b;
	int lef, rig;
	lef = 0, rig = h+1;
	for(int i=n-1; i>-1; i--){
		if(b[i] == 'L' )
			++rig;
		else if(b[i] == 'R')
			--lef;
		lef = max(lef,0)	;
		rig = min(rig, h+1) ;
		if(a[i] == 'L' )
			++lef;
		else if(a[i] == 'R')
			--rig;
		if(lef >= rig || rig == 1 || lef == h){
			cout<<"NO";
			return;
		}
	//	cout<<"possible "<<lef<<" "<<rig<<endl;
	}
	if(y <= lef  || y>=rig){
		cout<<"NO";
		return;
	}
	lef = 0, rig = w+1;
	for(int i=n-1; i>-1; i--){
		if(b[i] == 'U' )
			++rig;
		else if(b[i] == 'D')
			--lef;
		lef = max(lef,0);
		rig = min(rig, w+1);
		if(a[i] == 'U' )
			++lef;
		else if(a[i] == 'D')
			--rig;
		if(lef >= rig || lef == w || rig == 1){
			cout<<"NO";
			return;
		}
	//	cout<<"possible "<<lef<<" "<<rig<<endl;
	}
	if(x<=lef || x>=rig)
		cout<<"NO";
	else
		cout<<"YES";
}
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}



























Measured memory_bytes: 920
#
import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

# Calculate count of combination
def combination(n, r):
    a = 1
    b = 1
    for i in range(r):
        a *= (n - i)
        b *= (i + 1)
    return a // b


def main():
    mod = 10 ** 9 + 7
    n, k = map(int, input().split())
    for i in range(1, k + 1):
        ans = combination(n - k + 1, i) * combination(k - 1, i - 1) % mod
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 46940
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MAX_N = 100001;
const ll MAX_E = 200001;
const ll INF   = 1000000000000;
struct edge {ll u; ll v; ll cost;};
struct pos {ll x; ll y; ll n;};
edge es[MAX_E];
pos city[MAX_N];
ll N, E;

bool comp_x(const pos& p1, const pos& p2) {
  return p1.x < p2.x;
}
bool comp_y(const pos& p1, const pos& p2) {
  return p1.y < p2.y;
}
bool comp_edge(const edge& e1, const edge& e2) {
  return e1.cost < e2.cost;
}

struct UnionFind {
  vector<int> par;
  vector<int> rank;
  vector<int> size;
    
  UnionFind(int N) : par(N), rank(N), size(N) {
    for (int i = 0; i < N; i++) {
      par[i]  = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }
  
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  
  bool unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return false;
    
    if (rank[rx] < rank[ry]) {
      par[rx] = ry;
      size[ry] = size[ry] + size[rx];
    }
    else if (rank[rx] > rank[ry]) {
      par[ry] = rx;
      size[rx] = size[rx] + size[ry];
    }
    else {
      par[ry] = rx;
      size[rx] = size[rx] + size[ry];
      rank[rx]++;
    }
    return true;
  }
  
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  
  int get_size(int x) {
    int rx = root(x);
    return size[rx];
  }
  
};


ll kruskal() {
  sort(es, es + E, comp_edge);
  UnionFind uf = UnionFind(N);
  ll res = 0;
  for (ll i = 0; i < E; i++) {
    edge e = es[i];
    if(!uf.same(e.u, e.v)) {
      uf.unite(e.u, e.v);
      res += e.cost;
    }
  }
  return res;
}

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

    cin >> N;
    
    ll x, y;
    for (ll i = 0; i < N; i++) {
      cin >> x >> y;
      pos p;
      p.x = x; p.y = y; p.n = i;
      city[i] = p;
    }

    E = (N - 1) * 2;
    
    sort(city, city + N, comp_x);
    for (ll i = 0; i < N - 1; i++) {
      ll n1 = city[i].n;
      ll n2 = city[i+1].n;
      ll d = abs(city[i].x - city[i + 1].x);
      
      edge e;
      e.u = n1; e.v = n2; e.cost = d;
      es[i] = e;
    }

    sort(city, city + N, comp_y);
    for (ll i = 0; i < N - 1; i++) {
      ll n1 = city[i].n;
      ll n2 = city[i+1].n;
      ll d = abs(city[i].y - city[i + 1].y);

      edge e;
      e.u = n1; e.v = n2; e.cost = d;
      es[N - 1 + i] = e;
    }

    ll ans = kruskal();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11084
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            string b = Console.ReadLine();
            int A = int.Parse(b);
            string an="No";
            for (int i = 1; i < 10;i++){
                if (A % i == 0 && A / i < 10) { an = "Yes"; }
            }
            Console.Write(an);
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int n, m; cin >> n >> m;
  vector< map<int, int> > x(n+1);
  vector<int> p(m);
  vector<int> y(m);
  for(int i=0; i<m; i++) {
    cin >> p[i] >> y[i];

    x[p[i]][y[i]] = 0;
  }

  for(int i=0; i<n; i++){
    int jj = 1;
    for(auto j=x[i+1].begin(); j !=x[i+1].end(); j++){
      j->second = jj;
      jj++;
    }
  }

  for(int i=0; i<m; i++){
    cout << string(6-to_string(p[i]).size(), '0') << p[i];
    cout << string(6-to_string(x[p[i]][y[i]]).size(), '0') << x[p[i]][y[i]] << endl;
  }


  return 0;
}


///


Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
//const long double PI = 2 * acos(0.0);
//typedef complex <double> base;


int main(){

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

    int n,x;
    cin>>n;
    int duinai=0, duiekta=0, duiduita=0;

    for(int i=0; i<n; i++){
        cin>>x;
        if(x%4==0) duiduita++;
        else if(x%2==0) duiekta++;
        else duinai++;
    }

    if(duinai>duiduita){
        if(duinai==duiduita+1 and duiekta==0) cout<<"Yes";
        else cout<<"No";
    }
    else cout<<"Yes";
}


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

int main() {
  int n;
  unsigned long int k;
  int *a, *cntr;
  cin >> n >> k;
  a = new int[2*n];
  cntr = a+n;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    cntr[i]=0;
  }
  int crt_twn=1;
  unsigned long int roop_twn, rest;
  int rp_flag=0;
  for(unsigned long int i=0;i<k;i++){
    //cout<<crt_twn<<endl;
    crt_twn=a[crt_twn-1];
    if(cntr[crt_twn-1]!=0){
      roop_twn=i-cntr[crt_twn-1];
      rest = k-i-1;
      rp_flag=1;
      //cout << "over"<< endl << "rootptwn" <<  roop_twn << endl;
      break;
    }
    cntr[crt_twn-1]=i;    
  }

  //cout << endl << "rest" << rest << endl;
  //cout << rp_flag;
  if(rp_flag==1){
    rest = rest%roop_twn;
    //cout << rest;
    for(int j=0;j<rest;j++){
      //cout<<crt_twn<<endl;
      crt_twn=a[crt_twn-1];
    }
  }

  cout << crt_twn;

  delete[] a;
  return 0;
}

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

#define INF ((1LL<<62)-(1LL<<31))

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

    vector<int> a(N,0);
    long long int dp[N+1][N+1] = {};

    for (int i = 0; i < N; ++i)
    {
        int tmp;
        cin >> tmp;
        a.at(i) = tmp;
    }
/*
    for (int i = 0; i < N; ++i)
    {
        dp[i][i+1] = a.at(i);
    }
*/
    for (int len = 2; len <= N; ++len)
    {
        for (int i = 0; i+len <= N; ++ i)
        {
            int j = i + len;
            long long int ss = 0;
            long long int tmp = INF;
            for (int k = i; k < j; ++k)
            {
                ss += a.at(k);
            }
            for (int k = i+1; k < j; ++k)
            {
                tmp = min(tmp, dp[i][k]+dp[k][j]);
            }
            dp[i][j] = tmp + ss;
        }
    }
    
    cout << dp[0][N] << endl;

    return 0;
}



Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if (m <= 2 * n) {
        ans = m / 2;
    } else {
        ll r = m - 2 * n;
        ans = n + r / 4;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}


struct union_find {
	vector<int> rnk, par;
	union_find(int n) {
		rnk.resize(n);
		par.resize(n);
		rep(i, rnk.size()) {
			par[i] = i;
			rnk[i] = 0;
		}
	}
	int find(int x) {
		if (par[x] == x) return x;
		return par[x] = find(par[x]);
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (rnk[x] < rnk[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (rnk[x] == rnk[y])rnk[x]++;
		}
	}
	bool same(int x, int y) {
		return (find(x) == find(y));
	}
};

int main() {
	int n,m,x,y;
	cin>>n>>m;
	vl p(n);
	rep(i,n)cin>>p[i];
	union_find u(n);
	rep(i,m){
		cin>>x>>y;
		u.unite(x-1,y-1);
	}
	ll ans=0;
	rep(i,n)if(u.same(i,p[i]-1))ans++;
	cout<<ans<<endl;
}



Measured memory_bytes: 1792
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int w = scan.nextInt();
        int h = scan.nextInt();
        System.out.println((n - w + 1) * (n - h + 1));
        scan.close();
    }
}


Measured memory_bytes: 27056
package main

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

func main() {
	defer writer.Flush()
	N, Q := ReadInt(), ReadInt()
	c := append([]int{0}, ReadInts(N)...)
	lefts := make([]int, Q)
	rights := make([]int, Q)
	queryIDs := make([]int, Q)
	for q := 0; q < Q; q++ {
		queryIDs[q] = q
		lefts[q], rights[q] = ReadInt(), ReadInt()+1
	}
	sort.Slice(queryIDs, func(i, j int) bool {
		return rights[queryIDs[i]] < rights[queryIDs[j]]
	})

	t := MakeSegTree(N + 1)
	seen := make([]int, N+1)
	q := 0
	answers := make([]int, Q)
	for i := 1; i <= N; i++ {
		if seen[c[i]] > 0 {
			t.Add(seen[c[i]], -1)
		}
		t.Add(i, 1)
		seen[c[i]] = i
		for q < Q && i+1 == rights[queryIDs[q]] {
			answers[queryIDs[q]] = t.Sum(lefts[queryIDs[q]], rights[queryIDs[q]])
			q++
		}
	}
	for _, answer := range answers {
		Println(answer)
	}
}

type SegTree []int

func MakeSegTree(n_ int) SegTree {
	n := 1
	for n < n_ {
		n <<= 1
	}
	return make([]int, n*2)
}

func (t SegTree) Add(i, x int) {
	i += len(t) >> 1
	for i > 0 {
		t[i] += x
		i >>= 1
	}
}

func (t SegTree) Sum(a, b int) int {
	return t.sumRecur(a, b, 1, 0, len(t)>>1)
}
func (t SegTree) sumRecur(a, b, k, l, r int) int {
	if b <= l || r <= a {
		return 0
	}
	if a <= l && r <= b {
		return t[k]
	}
	v := 0
	v += t.sumRecur(a, b, k<<1, l, (l+r)>>1)
	v += t.sumRecur(a, b, k<<1+1, (l+r)>>1, r)
	return v
}

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}
func Println(a ...interface{}) { fmt.Fprintln(writer, a...) }


Measured memory_bytes: 47060
a, b, c = gets.split.map(&:to_i)
c = c * Math::PI / 180
puts(0.5 * a * b * Math.sin(c))
puts(a + b + Math.sqrt(a**2 + b**2 - 2 * a * b * Math.cos(c)))
puts(b * Math.sin(c))



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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  ll n, m;
  cin >> n >> m;
  vector<ll_ll> drinks(n);
  for (auto& p : drinks) {
    cin >> p.first >> p.second;
  }

  sort(all(drinks));

  ll ans = 0;
  for (auto p : drinks) {
    ll price = p.first;
    ll num = p.second;
    if (num <= m) {
      ans += price * num;
      m -= num;
      if (m == 0) break;
      continue;
    }
    ans += m * price;
    break;
  }

  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 1792
def c_half_and_half(A, B, C, X, Y):
    if X <= Y:
        tmp = X * 2 * C + (Y - X) * B
    else:
        tmp = Y * 2 * C + (X - Y) * A
    ans = min(tmp, max(X, Y) * 2 * C, X * A + Y * B)
    return ans

A,B,C,X,Y = [int(i) for i in input().split()]
print(c_half_and_half(A, B, C, X, Y))

Measured memory_bytes: 3064
#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 warshall_floyd(Graph &graph) {
    int V = graph.size();
    for (int k = 0; k < V; ++k) {
        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < V; ++j) {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }
}

void Main() {
    ll H, W;
    cin >> H >> W;
    Graph graph(10, vector<ll>(10, 0));
    rep(i, 10) {
        rep(j, 10) {
            ll c;
            cin >> c;
            graph[i][j] = c;
        }
    }
    warshall_floyd(graph);
    ll ans = 0;
    rep(i, H) {
        rep(j, W) {
            ll a;
            cin >> a;
            if (a == -1) continue;
            ans += graph[a][1];
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
from itertools import accumulate

def divisors(N):
    U = int(N ** 0.5) + 1
    L = [i for i in range(1, U) if N % i == 0]
    return L + [N // i for i in reversed(L) if N != i * i]

N, K, *A = map(int, open(0).read().split())

for d in reversed(divisors(sum(A))):
    R = [0] + list(accumulate(sorted(a % d for a in A)))
    for i in range(N):
        l = R[i]
        r = (N - i) * d - (R[N] - R[i])
        if max(l, r) <= K:
            print(d)
            quit()


Measured memory_bytes: 3188
#include <stdio.h>
int main(void) {
  int k, x, i;
  scanf("%d%d", &k, &x);
  for(i=x-k+1; i<x; i++){
    printf("%d ", i);
  }
  for(i=x; i<=x+k-1; i++){
    printf("%d ", i);
  }
}

Measured memory_bytes: 128
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}
function pow(base, n) {
  if (n === 0) return 1;
  let p = pow(base, Math.floor(n / 2));
  let res = mul(mod(p), mod(p));
  if (n % 2 === 1) res = mul(mod(res), base);
  return res;
}

function main() {
  let t = +readLine();
  let count = 0;

  while (t--) {
    const [a, b] = readLine()
      .split(" ")
      .map((n) => parseInt(n));

    if (count < 3) {
      if (a === b) count++;
      else count = 0;
    }
  }
  if (count === 3) console.log("Yes");
  else console.log("No");
}


Measured memory_bytes: 29832
#include <iostream>

using namespace std;

int main()
{
    int a,b,d,c=1;
    cin>>a>>b;
    d=a;
    if(b<=1)
    {
        cout<<0;
        return 0;
    }
    while(b>a)
    {
        a+=d-1;
        c++;
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  
  int A;
  int B;
  
  scanf("%d %d",&A,&B);
  
  int K = A * B;
  
  if(K % 2 == 0){
    puts("No");
  }
  else{
    puts("Yes");
  }
  
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

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

int main(){
    fast_io

    int k;
    cin>>k;

    ll sum=0;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                sum+=gcd(gcd(a, b), c);
            }
        }
    }
    
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3652
N, K = map(int, input().split())
A = list(map(int, input().split()))


l = 0
r = 10 ** 9 + 1

while r - l > 1:
    m = (r + l) // 2
    cnt = 0
    for i in A:
        cnt += i // m
        if i >= m and i % m == 0:
            cnt -= 1
    if cnt <= K:
        r = m
    else:
        l = m

print(r)

Measured memory_bytes: 31152
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <vector>
using namespace std;

#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define FILLA(a, x) memset((a), (x), sizeof (a))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
#define COPYA(a, b) memcpy((b), (a), sizeof (a))

typedef unsigned long long lu;
typedef long long li;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;

inline int Add(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Sub(int &x, int y) { x = Sub(x - y); }
inline int Mul(int x, int y) { return (int)((lu)x * y % mod); }
inline int Mul(int x, int y, int z) { return (int)((lu)x * y % mod * z % mod); }

int Pow(int x, int y) {
  int z = 1;
  for (; y; y >>= 1) {
    if (y & 1) z = Mul(z, x);
    x = Mul(x, x);
  }
  return z;
}

int Inv(int x) { return Pow(x, mod - 2); }
template <class T> inline void Max(T &x, T y) { if (y > x) x = y; }
template <class T> inline void Min(T &x, T y) { if (y < x) x = y; }

// ----------------------------------------

const int maxn = 40;

int N, n, A[maxn][maxn];
li dp[maxn][maxn][maxn][maxn];
li dp2[maxn][maxn][maxn][maxn];

li DP(int a, int b, int c, int d);
li DP2(int a, int b, int c, int d);

li DP(int a, int b, int c, int d) {
  li &ans = dp[a][b][c][d];
  if (ans != -1) return ans;
  ans = 0;
  for (int p = a; p <= b; ++p) {
    for (int q = c; q <= d; ++q) {
      if (A[p][q]) {
        ans += DP2(a, p - 1, p + 1, b) * DP2(c, q - 1, q + 1, d);
      }
    }
  }
  return ans;
}

li DP2(int a, int b, int c, int d) {
  li &ans = dp2[a][b][c][d];
  if (ans != -1) return ans;
  if (a == b + 1 && c == d + 1) {
    return ans = 1;
  }
  ans = 0;
  for (int p = a; p <= b; ++p) {
    for (int q = c; q <= d; ++q) {
      ans += DP(a, p, q, d) * DP2(p + 1, b, c, q - 1);
    }
  }
  return ans;
}

int main(void) {
  FILLA(dp, -1);
  FILLA(dp2, -1);
  scanf("%d", &N);
  n = N * 2;
  for (int i = 0; i < n; ++i) {
    char s[100];
    scanf("%s", s);
    for (int j = 0; j < n; ++j) {
      A[i][j] = s[j] - '0';
    }
  }
  li ans = 0;
  for (int i = 1; i < n; ++i) {
    if (A[0][i]) {
      ans += DP2(1, i - 1, i + 1, n - 1);
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 40192
import java.util.*;

public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        sc.close();

        int ans = 0;
        char[] c = new char [5]; 
        for (int i = A; i <= B; ++i) {
            c = String.valueOf(i).toCharArray();
            if (c[0] == c[4] && c[1] == c[3]) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 30036
import java.util.Scanner;

public class Main {

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] d = new int[n];
    for (int i = 0; i < n; i++) {
      d[i] = sc.nextInt();
    }

    int sum = 0;

    for (int i = 0; i < n - 1; i++) {
      for (int j = i + 1; j < n; j++) {
        sum += d[i] * d[j];
      }
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 22100