akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(c) (c).begin(), (c).end()

template <class C, class T> inline bool contains(const C& c, const T& x) { return c.find(x) != c.end(); }

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

    int H, W, M; cin >> H >> W >> M;
    set<pair<int, int>> targets;
    REP(i, M) {
        int h, w; cin >> h >> w; --h; --w;
        targets.emplace(h, w);
    }

    vector<int> vertical_counts(W);
    for (auto target : targets) {
        int x = target.second;
        ++vertical_counts[x];
    }
    int v_max = *max_element(ALL(vertical_counts));
    vector<int> max_cols;
    REP(x, W) {
        if (vertical_counts[x] == v_max)
            max_cols.push_back(x);
    }

    vector<int> horizontal_counts(H);
    for (auto target : targets) {
        int y = target.first;
        ++horizontal_counts[y];
    }
    int h_max = *max_element(ALL(horizontal_counts));
    vector<int> max_rows;
    REP(y, H) {
        if (horizontal_counts[y] == h_max)
            max_rows.push_back(y);
    }

    if (max_rows.size() * max_cols.size() > (size_t)M) {
        cout << v_max + h_max << '\n';
    } else {
        bool found = false;
        for (int r : max_rows) {
            for (int c : max_cols) {
                if (!contains(targets, make_pair(r, c))) {
                    found = true;
                    goto exit_loops;
                }
            }
        }
exit_loops:
        int ans = v_max + h_max - (found ? 0 : 1);
        cout << ans << '\n';
    }
}


Measured memory_bytes: 23852
import sys
#import cython

def main():
    read = lambda: sys.stdin.readline().rstrip()

    N, K = map(int,read().split())
    cnt = [0]*N
    #N: cython.longlong = 0
    for _ in range(K):
        d = int(read())
        A = list(map(int,read().split()))
        for num in A:
            cnt[num-1] += 1
    
    print(cnt.count(0))


 
if __name__ == "__main__":
    main()

Measured memory_bytes: 9168
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastIO;
    int n;
    cin >> n;

    string s;
    cin >> s;
    int maxv = 0, cur = 0;
    for (auto ch : s) {
        if (ch == 'I') {
            cur++;
        } else {
            cur--;
        }
        maxv = max(maxv, cur);
    }
    cout << maxv << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 1e5 + 10;
int n, cnt[MAX];

int main(void) {
    cin >> n;
    REP(i, n) {
        int a;
        cin >> a;
        cnt[a + 1]++;
        cnt[a - 1 + 1]++;
        cnt[a + 1 + 1]++;
    }
    int ma = 0;
    REP(i, MAX) chmax(ma, cnt[i]);
    cout << ma << endl;
}


Measured memory_bytes: 640
N,M,C = map(int,input().split())
B = input().split()
Anm = []
for i in range(N):
    Anm.append(input().split())
cont = 0
for A in Anm:
    c = C
    for i in range(M):
        c += int(A[i]) * int(B[i])
    if c > 0:
        cont += 1
print(cont)

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

int main(){

    int N;
    int M;
    int R;

    cin >> N;
    cin >> M;

    R = (N - M) * 100 + M *1900;

    for(int i = 1;i<=M;i++){
        R *=2;
    }

    cout << R << endl;
    return 0;




}

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

using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

  ll sum = 0;

  rep(a, k) {
    rep(b, k) {
      rep(c, k) { sum += gcd(gcd(a + 1, b + 1), c + 1); }
    }
  }

  cout << sum << endl;

  return 0;
}


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

using namespace std;

int main()
{
 int i,j;
 int a,b;
 int result;
 
  cin >> i >> j;
  cin >> a >> b;
  
  result = (i-a)*(j-b);
  
  cout << result;
  
  return 0;
}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;
extern crate num_bigint; // 0.2.2
extern crate num_traits; // 0.2.8
use num_bigint::BigInt;
use num_traits::Pow;

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
use libm::*;
use std::cmp::*;
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::*;
use std::ops::Range;
use std::str::FromStr;
use superslice::*;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//abc176-C
// #[fastout]
fn main() {
    input![n: usize, a: [u64; n]];

    let mut ans: u64 = 0;
    let mut prev = 0;

    for i in 0..n {
        if a[i] >= prev {
            prev = a[i];
            continue;
        } else {
            let diff = prev - a[i];
            ans += diff;
            prev = prev;
        }
    }

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

// use lazy_static::lazy_static;
// use std::sync::Mutex;

// lazy_static! {
//     static ref VALUES: Mutex<Vec<i32>> = Mutex::default();
// }

// let mut values = VALUES.lock().unwrap();
// values.extend_from_slice(&[1, 2, 3, 4]);
// assert_eq!(&*values, &[1, 2, 3, 4]);

// -100000000
//  1000000000


Measured memory_bytes: 5564
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const int N = 31;

int main(void){
    for(int n, res; cin >> n, n; cout << res << endl){
        vvi free(n, vi(N));

        rep(i, n){
            int f; cin >> f;

            rep(j, f){
                int d; cin >> d;
                free[i][d] = true;
            }
        }

        vector< set<int> > stones(n);
        rep(i, n) stones[i].insert(i);

        res = -1;

        rep(i, N){
            vi men;
            rep(j, n){
                if(free[j][i]){
                    men.pb(j);
                }
            }

            if(2 <= men.size()){
                range(j, 1, men.size()){
                    each(itr, stones[men[j]]){
                        stones[men[0]].insert(*itr);
                    }
                }

                range(j, 1, men.size()){
                    stones[men[j]] = stones[men[0]];
                }

                if(stones[men[0]].size() == n){
                    res = i;
                    break;
                }
            }
        }
    }

	return 0;
}

Measured memory_bytes: 1344
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

struct Combination
{
    int maxn;
    vector<ll> fmemo;
    vector<ll> imemo;
    vector<ll> ifmemo;
    
    Combination(int maxn) : maxn(maxn){
        fmemo.resize(maxn + 1);
        imemo.resize(maxn + 1);
        ifmemo.resize(maxn + 1);
        for(ll i = 1; i <= maxn; i++){
            imemo[i] = modpow(i, MOD - 2);
        }
    }

    ll fact(ll n){
        if(n == 0) return 1;
        if(fmemo[n]) return fmemo[n];
        return fmemo[n] = n * fact(n - 1) % MOD;
    }

    ll ifact(ll n){
        if(n == 0) return 1;
        if(ifmemo[n]) return ifmemo[n];
        return ifmemo[n] = imemo[n] * ifact(n - 1) % MOD;
    }

    ll com(ll n, ll k){
        if(k > n || k < 0) return 0;
        if(k == n || k == 0) return 1;
        return (fact(n) * ifact(k) % MOD) * ifact(n - k) % MOD;
    }
};

int main()
{
    int k;
    cin >> k;
    string s;
    cin >> s;
    int n = s.size();
    Combination com(n + k + 1);
    ll ans = 0;
    for(int i = 0; i <= k; i++){
        ans = (ans + (com.com(n + i, n) + MOD - com.com(n + i - 1, n)) % MOD * 
               modpow(25, i) % MOD * modpow(26, k - i) % MOD) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 82648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(9);
	bool flg=true;
	rep(i,n){
		int x;
		cin >> x;
		flg=true;
		for(int j=1;j<9;++j){
			if(j*400>x){
				a.at(j-1)++;
				flg=false;
				break;
			}
		}
		if(flg) a.at(8)++;
	}
	int ans=0;
	rep(i,8) if(a.at(i)) ans++;
	if(ans==0) cout << 1 << " " << a.at(8) << endl;
	else cout << ans << " " << ans+a.at(8) << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

mon = 0
for i in range(N):
    if A[i] >= B[i]:
        mon += B[i]
    else:
        mon += A[i]
        res = B[i] - A[i]
        if A[i + 1] >= res:
            A[i + 1] = A[i + 1] - res
            mon += res
        else:
            mon += A[i + 1]
            A[i + 1] = 0
    # print(mon)

print(mon)


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

long long first = 2ll;
long long second = 1ll;
long long answer = 0ll;

int n;

int main() {
	scanf("%d", &n);
	if(n == 1) {
		puts("1");
		return 0;
	}
	for (int i = 1; i < n; i++) {
		answer = first + second;
		first = second;
		second = answer;
	}
	printf("%lld", answer);
	return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  ll N; cin >> N;
  vector<ll> A(N); REP(i, N) cin >> A[i];
  ll tmp = 0;
  REP(i, N) {
    tmp ^= A[i];
  }
  REP(i, N) {
    cout << (tmp ^ A[i]) << " ";
  }
  cout << endl;
}

Measured memory_bytes: 4768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n); rep (i, 1, n) cin >> a[i];
    vector<int> b(n); rep (i, 1, n) b[a[i] - 1]++;
    rep (i, n) cout << b[i] << "\n";
    return 0;
}

Measured memory_bytes: 5548
import java.util.*;

/**
 * Created by Seiya on 2016/10/16.
 */
public class Main {
    static final long MOD = 1000000007;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int[] a = new int[100000];
        int N = scanner.nextInt();
        int amari = (N + 1) % 2;

        int flag = 1;
        for (int i = 0; i < N; i++) {
            int temp = scanner.nextInt();
            if(temp % 2 != amari)flag = 0;
            a[temp / 2]++;
            if(a[temp / 2] > 2)flag = 0;
        }

        if(amari == 0 && a[0] != 1)flag = 0;

        long ans = 1;
        if(flag == 0){
            System.out.println("0");
        }else{
            for (int i = 0; i < N / 2; i++) {
                ans = ans * 2 % MOD;
            }
            System.out.println(ans);
        }


    }





}




Measured memory_bytes: 31988
#include <stdio.h>
#define N 101
#define WHITE 0
#define GRAY 1
#define BLACK 2
  
int A[N][N], color[N];
int d[N], Q[N+1];
int n, q1 = 0, q2 = 0;
  

void bfs() {
  int i, u;
  for(i = 1; i <= n; i++) {
    color[i] = WHITE;
    d[i] = -1;
  }
  color[1] = GRAY;
  d[1] = 0;
  Q[q1] = 1;
  q1++;
  while(q1 != q2) {
    u = Q[q2];
    q2++;
    for(i = 1; i<= n; i++) {
      if(A[u][i] == 1) {
        if(color[i] == WHITE) {
          color[i] = GRAY;
          d[i] = d[u] + 1;
          Q[q1] = i;
          q1++;
        }
      }
    }
    color[u] = BLACK;
  }
}

  
int main() {
  int u, v, k, i, j;
  
  scanf("%d", &n);
  for(i = 1; i <= n; i++) {
    Q[i] = -1;
    for(j = 1; j <= n; j++) {
      A[i][j] = 0;
    }
  }
  Q[n+1] = -1;
  
  for(i = 1; i <= n; i++) {
    scanf("%d", &u);
    scanf("%d", &k);
    for(j = 1; j <= k; j++) {
      scanf("%d", &v);
      A[u][v] = 1;
    }
  }
  
  bfs();
  
  for(i = 1; i <= n; i++) {
    printf("%d %d\n", i, d[i]);
  }
  
  return 0;
}
  
  

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int h,w,k;
  cin>>h>>w>>k;
  char a[h][w];
  rep(i,0,h){
    rep(j,0,w){
      cin>>a[i][j];
    }
  }
  
  int ans=10000;
  rep(i,0,1<<(h-1)){
    int cur=0;
    int b[h];
    b[0]=0;
    rep(j,0,h-1){
      if(i>>j & 1){
        cur++;
      }
      b[j+1]=cur;
    }
    
    int now=0;
    int c[cur+1];
    int d[cur+1];
    rep(j,0,cur+1){
      c[j]=0;
      d[j]=0;
    }
    rep(j,0,h){
      if(a[j][0]=='1'){
        c[b[j]]++;
      }
    }
    bool q=true;
    rep(j,0,cur+1){
      if(c[j]>k){
        q=false;
      }
    }
    if(!q) continue;
      
    rep(j,0,w-1){
      rep(l,0,cur+1){
        d[l]=0;
      }
      rep(l,0,h){
        if(a[l][j+1]=='1'){
          d[b[l]]++;
        }
      }
      rep(l,0,cur+1){
        if(d[l]>k){
          q=false;
        }
      }
      if(!q) break;
      bool p=true;
      rep(l,0,cur+1){
        if(c[l]+d[l]>k){
          p=false;
        }
      }
      if(!p){
        now++;
        rep(l,0,cur+1){
          c[l]=d[l];
        }
      }
      else{
        rep(l,0,cur+1){
          c[l]+=d[l];
        }
      }
    }
    if(q){
      ans=min(ans,now+cur);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import bisect
def bisect_left_reverse(a, x):
    if a[0] <= x:
        return 0
    if x < a[-1]:
        return len(a)
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] <= x:
            ok = mid
        else:
            ng = mid
    return ok
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
A = p[:X]+q[:Y]
B = []
A.sort(reverse=True)
for i in range(len(r)):
    n = r[i]
    if A[0] == 0:
      break
    if A[-1] < n:
        index = bisect_left_reverse(A,n)
        A.pop(-1)
        B.append(n)
    else:
        break
print(sum(A)+sum(B))

Measured memory_bytes: 106576
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[] a = new int[n];
			for(int i=0;i<n;i++)a[i]=sc.nextInt();
			int s = 0;
			for(int j=n-1;j>=1;j--){
				for(int i=0;i<j;i++){
					if(a[i+1]<a[i]){
						int t = a[i];
						a[i]=a[i+1];
						a[i+1]=t;
						s++;
					}
				}
			}
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 20968
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,G; cin>>N>>G;
    vint p(N),c(N);
    REP(i,N) cin>>p[i]>>c[i];

    int ans=1e9;
    REP(S,1<<N){
        int sum=0,cnt=0;
        REP(i,N) if(S>>i&1){
            sum+=100*(i+1)*p[i]+c[i];
            cnt+=p[i];
        }
        for(int i=N-1;i>=0;i--){
            if(S>>i&1) continue;
            REP(j,p[i]-1) if(sum<G){
                sum+=100*(i+1);
                cnt++;
            }
        }
        if(sum>=G) ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

struct Combination {
    vector<lint> fac, finv, inv;
    Combination(lint maxN) : fac(maxN + 100), finv(maxN + 100), inv(maxN + 100) {
        maxN += 100; // for safety
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1]            = 1;
        for (lint i = 2; i <= maxN; ++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;
        }
    }
    lint operator()(lint n, lint 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() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint x, y;
    cin >> x >> y;
    Combination nCk(2000000);
    lint z = x + y;
    if (z % 3 != 0 || (z / 3) < abs(x - y)) {
        cout << 0 << "\n";
        return 0;
    }
    z /= 3;
    x -= z, y -= z;
    cout << nCk(x + y, x) << "\n";
    return 0;
}

Measured memory_bytes: 47104
import java.util.Arrays;
import java.util.Scanner;

class Main {
	int n,c,k;
	int[] t;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}

	Main(Scanner sc) {
		n = sc.nextInt();
		c = sc.nextInt();
		k = sc.nextInt();
		t = new int[n];
		for(int i=0;i<n;i++){
			t[i] = sc.nextInt();
		}
	}

	void solve() {
		int bus = 1;
		int cnt = 0;
		Arrays.sort(t);
		for(int i=0;i<n;i++){
			if ((cnt==c) || (t[i]-t[i-cnt])>k) {
				bus++;
				cnt=0;
			}
			cnt++;
		}
		System.out.println(bus);
	}
}

Measured memory_bytes: 49592
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
h = Counter()
for x in a:
    h[x] += 1
f = True
for k, v in h.items():
    if n % 2 == 1 and k == 0:
        if v != 1:
            f = False
            break
    elif v != 2:
        f = False
        break
MOD = 1000000007
def mpow(n, p, mod):
    r = 1
    while p > 0:
        if p & 1 == 1:
            r = r * n % mod
        n = n * n % mod
        p >>= 1
    return r
print(mpow(2, int(n / 2), MOD) if f else 0) 

Measured memory_bytes: 14820
#118
import collections
N, M = map(int, input().split())
A = [[] for _ in range(N)]
for i in range(N):
    A[i] = list(map(int, input().split()))
All = []
count = 0
for v in A:
    v.pop(0)
    
for v in A:
    for _v in v:
        All.append(_v)
_All= collections.Counter(All)
#All = set(All)
for v in _All:
    if _All[v] == N:
        count += 1
print(count)

Measured memory_bytes: 3316
package main

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

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

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	k := scanInt()
	facInit(n*2)

	ans := 0
	for i := 0; i < min(k,n-1)+1; i++ {
		ans = (ans+comb(n,i)*comb(n-1,n-1-i)%mod)%mod
		// fmt.Fprintln(wr, ans)
	}

	fmt.Fprintln(wr, ans)
}

const mod = 1000000007

var fac, ifac []int

func facInit(n int) {
	fac = make([]int,n+1)
	ifac = make([]int,n+1)
	inv := make([]int, n+1)

	fac[0] = 1; fac[1] = 1
	ifac[0] = 1; ifac[1] = 1
	inv[1] = 1

	for i := 1; i < n; i++ {
		fac[i+1] = fac[i]*(i+1)%mod
		inv[i+1] = mod-inv[mod%(i+1)]*(mod/(i+1))%mod
		ifac[i+1] = ifac[i]*inv[i+1]%mod
	}
}

func comb(a,b int) int { return (fac[a]*ifac[b]%mod)*ifac[a-b]%mod }
func perm(a,b int) int { return fac[a]*ifac[a-b]%mod }


Measured memory_bytes: 10752
N,K = map(int,input().split())
h_list = [int(input()) for i in range(N)]
h_list.sort()
ans = h_list[N-1] - h_list[0]

for i in range(N-K+1):
    if h_list[i+K-1] - h_list[i] < ans:
        ans = h_list[i+K-1]-h_list[i]

print(ans)


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

AB = []
for _ in range(N):
    AB.append(tuple(map(int, input().split())))

AB.sort(key=lambda x: x[1])

T = 0
R = "Yes"
for a, b in AB:
    T += a
    if T > b:
        R = "No"

print(R)

Measured memory_bytes: 31868
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, U, V = lr()
edges = [[] for _ in range(N+1)] # 1-indexed
for _ in range(N-1):
    a, b = lr()
    edges[a].append(b)
    edges[b].append(a)

def dfs(v):
    dist = [-1] * (N+1)
    dist[v] = 0
    stack = [v]
    while stack:
        s = stack.pop()
        for x in edges[s]:
            if dist[x] != -1:
                continue
            dist[x] = dist[s] + 1
            stack.append(x)
    return dist

DU, DV = dfs(U), dfs(V)
answer = 0
for u, v in zip(DU[1:], DV[1:]):
    if v > u:
        x = v - 1
        if x > answer:
            answer = x

print(answer)


Measured memory_bytes: 33968
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define INF 100000000
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)

//https://atcoder.jp/contests/arc090/tasks/arc090_b
struct Edge {
    int pre,post,weight;
    bool operator<(const Edge& o) const{
        return weight < o.weight;
    }
};

class UnionFind{
    private:
        vector<int> par;
        vector<int> rank;
        vector<int> diff_weight;
    public:
        UnionFind(int N):par(N),rank(N),diff_weight(N){
            for(int i=0;i<N;i++){
                this->par[i] = i;
                this->rank[i] = 0;
                this->diff_weight[i] =0;
            }
        };//constructer
    ~UnionFind(){};
    int root(int x){
        if(x==this->par[x]) return x;
        else{
            int r = root(par[x]);
            this->diff_weight[x] += this->diff_weight[par[x]];
            return par[x] = r;
        }
    };

    int weight(int x){
        this->root(x);
        return this->diff_weight[x];
    }

    void unite(int x_ch, int y_ch, int w){
        w += this->weight(x_ch);
        w -= this->weight(y_ch);
        int x = this->root(x_ch);
        int y = this->root(y_ch);
        if(x != y){
            if(this->rank[x]<this->rank[y]){swap(x,y);w=-w;}
            if(this->rank[x]==this->rank[y]) this->rank[x] ++;
            this->par[y] = x;
            this->diff_weight[y] = w;
        }
    };

    int diff(int x,int y){
        return this->weight(y)-this->weight(x);
    }
};

int main(){
    int N,M,L,R,D;
    cin >> N >> M;
    UnionFind tree(N);
    vector<Edge>edge_arr;
    for(int i=0;i<M;i++){
        cin>>L >>R >> D;
        Edge tmp{L-1,R-1,D};
        edge_arr.push_back(tmp);
    }

    for(int i=0;i<M;i++){
        int pre = edge_arr[i].pre;
        int post = edge_arr[i].post;
        if(tree.root(pre) == tree.root(post)){
            int diff = tree.diff(pre,post);
            if(diff!=edge_arr[i].weight){
                cout << "No" << endl;
                return 0;
            }
        }
        else tree.unite(pre, post,edge_arr[i].weight);
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
int main(){

    int N,i,j;
    cin >> N;
    int A[2][N],B[N] = {0};
    for(i = 0; i < 2; i++) {
        for(j = 0; j < N; j++) {
            cin >> A[i][j];
        }
    }

    for(i = 0; i < N; i++) {
        for(j = 0; j < i + 1; j++) {
            B[i] += A[0][j];
        }
    }
    
    for(i = 0; i < N; i++) {
        for(j = i; j < N; j++) {
            B[i] += A[1][j];
        }
    }

    sort(B,B+N);
    reverse(B,B+N);
  
    cout << B[0] << endl;
  
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<vector>
#include<set>
#define LL long long int
using namespace std;

const LL mod = 1000000007;
const int maxn = 120000;
LL save[maxn];
int arr[maxn];
int vis[maxn];

void init()
{
	memset(vis,-1,sizeof(vis));
}
void pre()
{
	save[0] = 1;
	for(int i = 1;i<maxn;i++)
	{
		save[i] = save[i-1]*i;
		save[i] %= mod;
	}
}
int n;

LL extgcd(LL a, LL b, LL& x, LL& y)
{
    LL d = a;
    if(b != 0){
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else {
        x = 1;
        y = 0;
    }
    return d;
}
LL mod_inverse(LL a, LL m)
{
    LL x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}

LL ans[maxn];

LL C(int n,int m)
{
	LL tmp = save[m]*save[n - m];
	tmp %= mod;
	tmp = mod_inverse(tmp,mod);
	return save[n]*tmp%mod;
}



int main()
{
	pre();
	while(cin >> n)
	{
		init();
		int left,right;
		for(int i = 0;i<n + 1;i++)
		{
			int x;
			scanf("%d",&x);
			arr[i] = x;
			if(vis[x] != -1)
			{
				left = vis[x];
				right = i;
			}
			vis[x] = i;
		}
		int dis = n + 1 - right;
		int tdis = left + 1;
		ans[1] = n;
		//cout<<left<<" "<<right<<endl;
		for(int i = 2;i<=n;i++)
		{
			ans[i] = C(n+1,i);
			if(i - 1<=dis+tdis-2)
				ans[i] = ans[i] - C(dis + tdis - 2,i-1) + mod;
			ans[i] %= mod;
		}
		ans[n+1] = 1;
		for(int i = 1;i<=n+1;i++)
		{
			printf("%lld\n",ans[i]);
		}
	}
	return 0;
}

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

int main(void){
    string num;
    int result = 0;
    while(1){
        cin >> num;
        if(num == "0") break;

        for(int i = 0; i < num.size(); i++){
            result += num[i] - '0';
        }
        cout << result << endl;
        result = 0;
    }
    return 0;
}


Measured memory_bytes: 3164
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb emplace_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<int, pii>
#define puu pair<ULL, ULL>
#define pdd pair<long double, long double>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 1e5 + 5;
int a[N], n;
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    sort(a+1, a+1+n);
    if(a[n/2] == a[n/2+1]) return 0*puts("0");
    else printf("%d\n", a[n/2+1]-a[n/2]);
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define forn(i, s, f) for (int i = s; i < f; i++)
#define ll long long
#define pii pair <int, int>
#define fs first
#define sc second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector <int> pref(n + 1);
    forn (i, 0, n) {
        pref[i + 1] = pref[i];
        if (s[i] == 'A' && s[i + 1] == 'C')
            pref[i + 1]++;
    }
    forn (i, 0, q) {
        int l, r;
        cin >> l >> r;
        l--;
        cout << pref[r - 1] - pref[l] << "\n";
    }
    return 0;
}


Measured memory_bytes: 1488
n=int(input())
a=list(map(int,input().split()))
c=[0]*9

for r in a:
  x=r//400
  if x>8:
    x=8
  c[x]+=1
ans=0
for i in range(9):
  if i==8:
    if ans==0:
      mn=1
      mx=n
    else:
      mn=ans
      mx=ans+c[i]
  if c[i]!=0:
    ans+=1

print("{} {}".format(mn,mx))

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

using namespace std;
#define EPS (1e-10)
typedef complex<double> P;
//実数同士の比較
bool EQ(double a, double b){
    return (abs(a - b) < EPS);
}
 
//二つのベクトルが等しいかどうか
bool EQV(P a, P b){
    return (EQ(a.real(), b.real()) && EQ(a.imag(), b.imag()));
}
 
//内積
double dot(P a, P b){
    return (a.real() * b.real() + a.imag() * b.imag());
}
 
//外積
double cross(P a, P b){
    return (a.real() * b.imag() - a.imag() * b.real());
}
 
// 点a,bを通る直線と点cとの距離
double distance_l_p(P a, P b, P c) {
  return abs(cross(b-a, c-a)) / abs(b-a);
}
 
// 点cが線分a,b上にあるかないか(3)
int is_point_on_line(P a, P b, P c) {
  // |a-c| + |c-b| <= |a-b| なら線分上
  return (abs(a-c) + abs(c-b) < abs(a-b) + EPS);
}
 
// 点a,bを端点とする線分と点cとの距離
double distance_ls_p(P a, P b, P c) {
  if ( dot(b-a, c-a) < EPS ) return abs(c-a);
  if ( dot(a-b, c-b) < EPS ) return abs(c-b);
  return abs(cross(b-a, c-a)) / abs(b-a);
}
 
//図を思い出す
int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if( cross(b,c) > EPS ) return +1;
    if( cross(b,c) < -EPS ) return -1;
    if( dot(b,c) < 0 ) return +2;
    if( norm(b) < norm(c) ) return -2;
    return 0;
}
 
// a1,a2を端点とする線分とb1,b2を端点とする線分の交差判定
int is_intersected_ls(P a1, P a2, P b1, P b2) {
  return ( ccw(a1,a2,b1) * ccw(a1,a2,b2) <= 0 ) &&
           ( ccw(b1,b2,a1) * ccw(b1,b2,a2) <= 0 );
}
 
// a1,a2を通る直線とb1,b2を通る直線の交点計算
P intersection_l(P a1, P a2, P b1, P b2) {
  P a = a2 - a1; P b = b2 - b1;
  return a1 + a * cross(b, b1-a1) / cross(b, a);
}

double distance(P p0, P p1, P p2, P p3){
  double ans = 1e10;
        ans = min(ans, distance_ls_p(p0, p1, p2));
        ans = min(ans, distance_ls_p(p0, p1, p3));
        ans = min(ans, distance_ls_p(p2, p3, p0));
        ans = min(ans, distance_ls_p(p2, p3, p1));
        if(is_intersected_ls(p0, p1, p2, p3)) ans = 0.0;
		return ans;
}

int main(){
  while(true){
		int n; cin >> n;
		if(n == 0 )break;
		double x, y;
		cin >> x >> y;
		P s = P(x,y);
		cin >> x >> y;
		P g = P(x,y);
		vector<P> mins(n), maxs(n);
		vector<double> h(n);
		for(int i = 0; i < n; i++){
			cin >> x >> y;
			//if(z == 24)printf("%.0f %.0f",x,y);
			mins[i].real(x); mins[i].imag(y);
			cin >> x >> y;
			//if(z == 24)printf(" %.0f %.0f",x,y);
			maxs[i].real(x); maxs[i].imag(y);
			cin >> h[i];
			//if(z == 24)printf(" %.0f \n",h[i]);
		}
		double ans = 1e9;
		for(int i = 0; i < n;i++){
			double d = 1e9;
			P p1 = mins[i], p3 = maxs[i];
			P p2(mins[i].real(), maxs[i].imag());
			P p4(maxs[i].real(), mins[i].imag());
			if(p1.real() < s.real() && s.real() < p3.real() && 
				p1.imag() < s.imag() && s.imag() < p3.imag()){
				ans = 0;/*
				if(z==24){
					printf("%.0f %.0f %.0f %.0f\n",p1.real(),p1.imag(),p3.real(),p3.imag());
					cout << "break" << endl;}*/
				break;
			}
			d = min(d, distance(s, g, p1,p2));
			d = min(d, distance(s, g, p2,p3));
			d = min(d, distance(s, g, p3,p4));
			d = min(d, distance(s, g, p4,p1));
			double r = (h[i]*h[i]+d*d)/(2*h[i]);
			if(h[i] < d){
				ans = min(ans, r);
			}
			else{
				ans = min(ans, d);
			}
		}
		printf("%.4f\n",ans);
	}

	return 0;
}




Measured memory_bytes: 3244
if __name__ == '__main__':
    N, K = map(int, input().split())
    g = {}
    for i, a in enumerate(list(map(int, input().split()))):
        g[i + 1] = a

    rs = [1, g[1]]
    pos = g[1]
    used = [False for _ in range(N)]
    used[0] = True
    roop_i = None
    while 1:
        rs.append(g[pos])
        used[pos - 1] = True
        pos = g[pos]
        if used[pos - 1] is True:
            roop_i = pos
            break

    idx1 = rs.index(roop_i)

    d1 = idx1
    d2 = len(rs) - idx1 - 1

    if K <= d1:
        print(rs[K])
    else:
        print(rs[(K - d1) % d2 + d1])


Measured memory_bytes: 38960
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	string A,B,C; cin>>A>>B>>C;
	int l1 = A.length(), l2 = B.length(), l3 = C.length();
	int st=1, id1=0,id2=0,id3=0;
	while(1)
	{
	    if(st==1)
	    {
	        if(id1==l1){ cout<<'A'; return 0; }
	        if(A[id1]=='a') st=1;
	        else if(A[id1]=='b') st=2;
	        else st=3;
	        id1++;
	    }
	    else if(st==2)
	    {
	        if(id2==l2){ cout<<'B'; return 0; }
	        if(B[id2]=='a') st=1;
	        else if(B[id2]=='b') st=2;
	        else st=3;
	        id2++;
	    }
	    else
	    {
	        if(id3==l3){ cout<<'C'; return 0; }
	        if(C[id3]=='a') st=1;
	        else if(C[id3]=='b') st=2;
	        else st=3;
	        id3++;
	    }
	    
	}
	
	return 0;
}


Measured memory_bytes: 256
s = input()


def checkSpell(c):
    return c=="A" or c =="C" or c =="G" or c =="T"

cnt = 0
res = 0
for i in s:
    if checkSpell(i) == True:
        cnt += 1
        res = max(res,cnt)
    else:
        cnt = 0
        
print(res)

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

int main() {
  string s;
  getline(cin, s);
  
  int size = s.size();
  
  for (int i=0; i<size; i++) {
    char x = s.at(i);
    if(isalpha(x)) {
      if(isupper(x)) {
        x = tolower(x);
        cout << x;
      }
      else {
        x = toupper(x);
        cout << x;
      }
    }
    
    else {
      cout << x;
    }
  }
  
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 3204
//file_name:ABC95_C.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    ll a,b,c;
    int x,y;
    scanf("%lld%lld%lld%d%d",&a,&b,&c,&x,&y);
    ll ans = 0;
    if(b<a){
        swap(a,b);
        swap(x,y);
    }
    ans=a*x+b*y;
    rep(i,max(x,y)+1){
        ll ans2=a*x+b*y-min(i,x)*a-min(i,y)*b+c*i*2;
        mins(ans,ans2);
    }


    

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



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(void){
  int n;
  int x;
  scanf("%d%d",&n,&x);
  int l[n];
  int i,j,k;
  for(i=0;i<n;i++){
    scanf("%d",&l[i]);
  }
  int ans=0;
  int dist=0;
  i=0;
  int flag=0;

  while(x>=dist){

    dist=dist+l[i];
    ans++;
    i++;
  }

  if(ans>n+1){
    ans=n+1;
  }

  printf("%d",ans);


  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <set>
using namespace std;
int main(void){
    int n;
    set<int> s;
    cin >> n;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        s.insert(a);
    }
    if(s.size() == n) puts("YES");
    else puts("NO");
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define rep(i,n,m) for(ll i = (n); i <(m); i++)
#define rrep(i,n,m) for(ll i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

const int MAX_H = 110;
const int MAX_W = 15;
const int MAX_K = 15;
const ll MOD = 1000000007;

ll dp[MAX_H][MAX_W];

ll power_mod(ll n, ll m)
{
    ll res = 1;
    ll base = n;
    while (m > 0)
    {
        if (m&1) res = (res * base) % MOD;
        base = (base * base) % MOD;
        m >>= 1;
    }
    return res;
}
ll inv_mod(ll n)
{
    return power_mod(n, MOD-2);
}
ll comb_mod(ll n, ll m)
{
    ll res = 1;
    rep(i, n - m + 1, n + 1)
        res = (res * i) % MOD;
    rep(i, 1, m + 1)
        res = (res * inv_mod(i)) % MOD;
    return res;
}

int main()
{
    ll H, W, K;
    cin >> H >> W >> K;

    dp[0][0] = 1;
    rep(h, 0, H)
    rep(w, 0, W)
    for (int i = 0; i < (1 << (W-1)); i++)
    {
        bool flag = true;
        rep(j, 0, W - 2)
            flag &= !((i >> j) & (i >> (j + 1)));
        // cout << h << ' ' << w << ' ' << i << ' ' << flag << endl;
        if (not flag)
            continue;

        if ((i >> w)&1) 
            dp[h + 1][w + 1] += dp[h][w];
        else if (w > 0 and (i >> (w-1))&1)
            dp[h + 1][w - 1] += dp[h][w];
        else
            dp[h + 1][w] += dp[h][w];

        dp[h + 1][w-1] %= MOD;
        dp[h + 1][w] %= MOD;
        dp[h + 1][w+1] %= MOD;
        // cout << h << ' ' << w << ' ' << i << ' ' << dp[h+1][w-1] << ' ' << dp[h+1][w] << ' ' <<dp[h+1][w+1] << endl;

    }

    cout << dp[H][K-1] << endl;
    return 0;

}

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

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = (b+a-3)/(a-1);
    cout << ans << endl;
}

Measured memory_bytes: 3600
import sys
def myin():
    for s in sys.stdin:
        for t in s.split():
            yield t
##
_in=myin()
H,W=int(next(_in)),int(next(_in))
h,w=int(next(_in)),int(next(_in))
print(H*W-(h*W+w*H-w*h))
##


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

string s;
int cnt;

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> s;
	for (int i = 0; i < (int)s.size(); i++)cnt += s[i] - '0';
	if (cnt % 9 == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
#define maxn -20000000000 //negative value to break code and force you to put right constraint
#define mod 1073741824
#define md(x) (x) % mod;
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ps push
#define prt(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define INF 100000000000
#define INFd 1e9
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<double> vd;

int main()
{
	
	ll n,k;
	cin>>n>>k;
	vector<ll> v(n+1);
	for(ll i=1;i<=n;i++)
		cin>>v[i];
	ll dp[100005]={0};

		for(ll j=0;j<=k;j++)
		{
			for(int i=1;i<=n;i++){
			if((j-v[i])<0)
				dp[j]=0||dp[j];
			else
			{
				dp[j]=(1-dp[j-v[i]])||(dp[j]);
			}

		}
		//cout<<dp[j];
	}
	if(dp[k]==1)
		cout<<"First";
	else
		cout<<"Second";
}


Measured memory_bytes: 1024
import math

n = int(input())
top_bottom_num = {str(i): {str(j): 0 for j in range(10)} for i in range(10)}
for i in range(1, n + 1):
    str_num = str(i)
    top_bottom_num[str_num[0]][str_num[-1]] += 1
ans = 0
for i in range(10):
    for j in range(10):
        i_j = top_bottom_num[str(i)][str(j)]
        j_i = top_bottom_num[str(j)][str(i)]
        ans += i_j * j_i
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#pragma warning (disable:4996)

int arr[101] = { 0 };
void fun() {
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			int value = i*j;
			arr[value] = { 1 };
		}
	}
}

int main() {
	
	fun();
	int n = 0;
	scanf("%d", &n);
	if (arr[n] == 1) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;

}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
	int A,B,H,M;
	double MIN,thetaA,thetaB;
	double xA,yA,xB,yB,ans;
	char str[100000];
 
	fgets(str, sizeof(str), stdin);
	A=atoi(strtok(str," "));
	B=atoi(strtok(NULL," "));
	H=atoi(strtok(NULL," "));
	M=atoi(strtok(NULL," "));

	MIN=60*H+M;
	thetaA=0.5*MIN*2*3.14159265358979/360;
	thetaB=6.0*MIN*2*3.14159265358979/360;

	xA=A*cos(thetaA);
	xB=B*cos(thetaB);

	yA=A*sin(thetaA);
	yB=B*sin(thetaB);

	ans=sqrt( (xA-xB)*(xA-xB) +(yA-yB)*(yA-yB) );

	printf("%.10lf\n",ans);

	return 0;
}

Measured memory_bytes: 2584
#include <iostream>
#include <vector>

using namespace std;

const int MAX_N = 2e3 + 5;

vector<int> adj [MAX_N];

void dfs (int u, int p, int lft, int &cur) {
  if (lft < 0) cur++;
  for (int nxt : adj[u]) {
    if (nxt != p) {
      dfs(nxt, u, lft - 1, cur);
    }
  }
}

int main () {
  int n, K;
  cin >> n >> K;

  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;

    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  int ans = MAX_N;

  // try to root at all vertices
  for (int i = 1; i <= n; i++) {
    int cur = 0;
    dfs(i, 0, K / 2, cur);
    ans = min(ans, cur);
  }

  // try to root at all edges
  for (int u = 1; u <= n; u++) {
    for (int v : adj[u]) {
      int cur = 0;
      dfs(u, v, (K - 1) / 2, cur);
      dfs(v, u, (K - 1) / 2, cur);
      ans = min(ans, cur);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3788
//In the name of Allah
#include <bits/stdc++.h>
using namespace std;
#define MAX 1011
#define mod 1000000007
#define inf 1000000000000000
#define ll long long
#define endl '\n'
string a[MAX];
ll dp[MAX][MAX];

int main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,m;
	cin>>n>>m;
	dp[0][0] = 1;
	for(int i = 0 ; i < n; i++){
		cin>>a[i];
		for(int j = 0; j < m ; j++){
			if(a[i][j] == '#' || (i == 0 && j == 0))continue;
			if(i > 0)dp[i][j] += dp[i-1][j];
			if(j > 0)dp[i][j] += dp[i][j-1];
			dp[i][j] %= mod;
		}
	}
	cout<<dp[n-1][m-1];
	return 0; 
} 

Measured memory_bytes: 9216