akhauriyash/Code-Regression huggingface dataset:
#[allow(unused)]
use std::cmp::{max, min};

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        k: i64,
        x: i64,
    }

    let min = -1000000;
    let max = 1000000;

    let mut vec = Vec::new();

    for i in x - k + 1..x {
        if i > min {
            vec.push(i)
        }
    }

    for i in x..x + k {
        if i < max {
            vec.push(i)
        }
    }

    for i in &vec {
        print!("{} ", i)
    }
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

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

    Vi b(N);
    for (int i = N - 1; i >= 0; i--) {
        int idx = i + 1;
        int tmp = idx * 2;
        int sum = 0;
        while (tmp <= N) {
            sum += b[tmp - 1];
            tmp += idx;
        }
        if (a[idx - 1] == 0) {
            if (sum % 2 == 0) {
                b[idx - 1] = 0;
            }
            else {
                b[idx - 1] = 1;
            }
        }
        else {
            if (sum % 2 == 0) {
                b[idx - 1] = 1;
            }
            else {
                b[idx - 1] = 0;
            }
        }
    }

    Vi ans;
    for (int i = 0; i < N; i++) {
        if (b[i] == 1) {
            ans.push_back(i + 1);
        }
    }

    cout << ans.size() << '\n';
    int n_ans = ans.size();
    if (n_ans > 0) {
        for (int i = 0; i < n_ans - 1; i++) {
            cout << ans[i] << ' ';
        }
        cout << ans[n_ans - 1] << '\n';
    }



    return 0;
}

Measured memory_bytes: 3192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Pavel Mavrin
 */
public class Main {

    private void solve() throws IOException {
        int a = nextInt();
        int b = nextInt();
        int[][] d = new int[a + 1][b + 1];
        for (int x = 1; x <= a; x++) {
            for (int y = 1; y <= b; y++) {
                d[x][y] = nextInt();
            }
        }

        int n = 150;
        int[][] c = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                c[i][j] = 0;
                for (int x = 1; x <= a; x++) {
                    for (int y = 1; y <= b; y++) {
                        c[i][j] = Math.max(c[i][j], d[x][y] - i * x - j * y);
                    }
                }
            }
        }

        for (int x = 1; x <= a; x++) {
            for (int y = 1; y <= b; y++) {
                int r = Integer.MAX_VALUE;
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < n; j++) {
                        r = Math.min(r, i * x + j * y + c[i][j]);
                    }
                }
                if (r != d[x][y]) {
                    out.println("Impossible");
                    return;
                }
            }
        }
        out.println("Possible");
        out.println((2 * n) + " " + (2 * (n - 1) + n * n));
        for (int i = 0; i < n - 1; i++) {
            out.println((i + 1) + " " + (i + 2) + " X");
            out.println((n + i + 2) + " " + (n + i + 1) + " Y");
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                out.println((i + 1) + " " + (n + j + 1) + " " + c[i][j]);
            }
        }
        out.println(1 + " " + (n + 1));
    }

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

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    PrintWriter out = new PrintWriter(System.out);

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    private void run() throws IOException {
        solve();
        out.close();
    }

}


Measured memory_bytes: 27020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

int main(){
    ll X=in();
    ll a=X/500;
    X-=a*500;
    ll b=X/5;
    cout<<1000*a+5*b<<endl;
}

Measured memory_bytes: 256
//In The Name Of God
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int, int>
#define pb push_back
using namespace std;
const int N = 2e6 + 5, Mod = 1e9 + 7, P = 727, Lg = 17, TOF = 1900;

int main(){
      ios_base::sync_with_stdio(0); cin.tie(0);
      string s; cin >> s;
      string bad = "keyence";
      if(s == bad)
            return cout << "YES", 0;
      int n = s.size();
      for(int i = 0; i < n; i++){
            for(int j = i; j < n; j++){
                  string ret = "";
                  for(int x = 0; x < i; x++)
                        ret += s[x];
                  for(int x = j + 1; x < n; x++)
                        ret += s[x];
                  if(ret == bad)
                        return cout << "YES", 0;
            }
      }
      return cout << "NO", 0;
}


Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
#define rep(i,s,k) for(int i=s;i<k;i++)
#define int long long
signed main(void){
    int n,m,a,b,c;
    int ans=1;
    cin>>n;
    int num[n];
    m=0;
    rep(i,0,n){
        cin>>num[i];
        if(num[i]>m)
        m=num[i];
        if(num[0]!=0){
            cout<<"0"<<endl;
            return 0;
        }
    }
    int tree[m+1];
    rep(i,0,m+1) tree[i]=0;
    rep(i,0,n) tree[num[i]]++;
    rep(i,0,m+1){
        if(i==0&&tree[0]>1){
            cout<<"0"<<endl;
            return 0;
        }
        if(tree[i]==0){
            cout<<"0"<<endl;
            return 0;
        }
        if(i>0){
            int t=1;
            rep(j,0,tree[i]){ t=t*tree[i-1]%998244353;}
            ans=(ans*t)%998244353;
        }
    }
    cout<<ans%998244353<<endl;
   
    return 0;
    
    
}


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define vint vector<int>
#define INF 1e9

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;


int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> michi(n+1, vector<int>());
    int tmp1, tmp2;
    REP(i, 0, m){
        cin >> tmp1 >> tmp2;
        michi[tmp1].push_back(tmp2);
        michi[tmp2].push_back(tmp1);
    }

    vint ans(n+1, 0);

    queue<int> bfs;
    REP(i, 0, michi[1].size()){
        bfs.push(michi[1][i]);
        ans[michi[1][i]] = 1;
    }

    int target;
    while (not bfs.empty()){
        target = bfs.front();
        REP(i, 0, michi[target].size()){
            if(ans[michi[target][i]] != 0){ continue;}
            bfs.push(michi[target][i]);
            ans[michi[target][i]] = target;
        }
        bfs.pop();
    }

    REP(i, 2, n+1){
        if(ans[i] == 0){
            p("No");
            return 0;
        }
    }

    p("Yes");
    REP(i, 2, n+1){
        p(ans[i]);
    }

    return 0;
}


Measured memory_bytes: 10276
#include<stdio.h>

int main() {
  int a[4810] = {};
  int dist[10] = {};
  int n;
  scanf("%d", &n);
  int i;
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] < 400) {
      dist[1] += 1;
    } else if (a[i] < 800) {
      dist[2] += 1;
    } else if (a[i] < 1200) {
      dist[3] += 1;
    } else if (a[i] < 1600) {
      dist[4] += 1;
    } else if (a[i] < 2000) {
      dist[5] += 1;
    } else if (a[i] < 2400) {
      dist[6] += 1;
    } else if (a[i] < 2800) {
      dist[7] += 1;
    } else if (a[i] < 3200) {
      dist[8] += 1;
    } else if (a[i] >= 3200) {
      dist[9] += 1;
    }
  }
  int min = 0;
  int max = 0;
  for (i = 1; i < 9; i++) {
    if (dist[i] > 0) {
      min += 1;
      max += 1;
    }
  }
  if (min == 0) {
    min = 1;
  }
  max += dist[9];
  printf("%d %d\n", min, max);
  return 0;
}


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

using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int tmp;
    tmp = a;
    a = b;
    b = tmp;
    tmp = a;
    a = c;
    c = tmp;
    cout << a << " " << b << " " << c;
}


Measured memory_bytes: 256
while True:
  a,op,b = input().split()  
  a = int(a)                  
  b = int(b)  
  if op == "?":
        break
  if op == "+":
        x = a + b
  elif op == "-":
        x = a - b
  elif op == "*":
        x = a * b
  else:
        x = a // b
  print(x)


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

cin >> A >> B ;


if (( A + B >= A - B ) && ( A + B >= A * B )) {
cout << A + B << endl;
}

else if (( A - B >= A + B ) && ( A - B >= A * B )){
cout << A - B << endl;
}

else {
cout << A * B << endl;
}
}

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

int main()
{
    int n;
    cin >> n;
    double p[n];
    double q[n + 1];
    double dp[n + 1][n + 1];
    for (int i = 0; i < n; i++)
        cin >> p[i];
    for (int i = 0; i <= n; i++)
    {
        cin >> q[i];
        dp[i][i] = q[i];
    }
    double pSum[n][n];
    for (int i = 0; i < n; i++)
    {
        pSum[i][i] = p[i];
        for (int j = i + 1; j < n; j++)
            pSum[i][j] = pSum[i][j - 1] + p[j];
    }
    double qSum[n + 1][n + 1];
    for (int i = 0; i < n + 1; i++)
    {
        qSum[i][i] = q[i];
        for (int j = i + 1; j < n + 1; j++)
            qSum[i][j] = qSum[i][j - 1] + q[j];
    }
    for (int i = 1; i < n + 1; i++)
    {
        for (int j = 0; j < n + 1 - i; j++)
        {
            dp[j][j + i] = 1145141919;
            for (int k = 0; k < i; k++)
            {
                double tmp = dp[j][j + k] + dp[j + k + 1][j + i] + pSum[j][j + i - 1] + qSum[j][j + i];
                dp[j][j + i] = min(dp[j][j + i], tmp);
            }
        }
    }
    printf("%.8f\n", dp[0][n]);
}


Measured memory_bytes: 9092
import java.util.Scanner;

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

	String s = scan.next();
	int price = 700;

	if(s.charAt(0) == 'o')price += 100;
	if(s.charAt(1) == 'o')price += 100;
	if(s.charAt(2) == 'o')price += 100;

	System.out.println(price);
    }
}


Measured memory_bytes: 22740
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iostream>
#include<queue>
#include<stack>
#include<math.h>
#define Max 1000000
#define INF 1000000000000000000
using namespace std;

bool prime[Max];

void makePrime(){

	for(int i=0;i<Max;i++)
		prime[i] = true;
	for(int i=4;i<Max;i+=2)
		prime[i] = false;
	for(int i=3;i*i<Max;i++){
		if(prime[i]){
			for(int j=i*i;j<Max;j+=i)
				prime[j] = false;
		}
	}
}


int main(){

	makePrime();
	int x;
	scanf("%d",&x);
	while(prime[x] != true)
		x++;
	printf("%d\n",x);
	
	return 0;
}

Measured memory_bytes: 1280
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

for i in range(n):
    for j in range(3):
        for k in range(3):
                if b[i]==a[j][k]:
                    a[j][k]=0

if a[0][0]+a[0][1]+a[0][2]==0:
    print("Yes")
elif a[1][0]+a[1][1]+a[1][2]==0:
    print("Yes")
elif a[2][0]+a[2][1]+a[2][2]==0:
    print("Yes")
elif a[0][0]+a[1][0]+a[2][0]==0:
    print("Yes")
elif a[0][1]+a[1][1]+a[2][1]==0:
    print("Yes")
elif a[0][2]+a[1][2]+a[2][2]==0:
    print("Yes")
elif a[0][0]+a[1][1]+a[2][2]==0:
    print("Yes")
elif a[2][0]+a[1][1]+a[0][2]==0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include "bits/stdc++.h"

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main() {
  int N;
  cin >> N;
  cout << (N-1)/2;
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);


*/


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>

int main(void) {
  std::string T;
  std::string P;

  std::cin >> T;
  std::cin >> P;
  
  if (T.size() < P.size()) {
    return 0;
  }

  int index = 0;

  for (int i = 0; i <= T.size() - P.size(); i++) {
    if (P == T.substr(i, P.size())) {
      printf("%d\n", i);
      //std::cout << i << std::endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 2048
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

typedef long long LL;

const int N = 2010;
const int Mod = 1e9 + 7;

LL Pow(LL x, LL e){
	LL ret = 1;
	while(e){
		if(e & 1) ret = ret * x % Mod;
		x = x * x % Mod;
		e >>= 1;
	}
	return ret;
}

LL fac[N * N], rfac[N * N];
int n, k;

inline LL C(int a, int b){
	return fac[a] * rfac[b] % Mod * rfac[a - b] % Mod;
}

LL dp[N][N];

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

	if(k == 1){
		puts("1");
		return 0;
	}
	
	fac[0] = 1;
	For(i, 1, n * k) fac[i] = fac[i - 1] * i % Mod;
	rfac[n * k] = Pow(fac[n * k], Mod - 2);
	Forr(i, n * k - 1, 0) rfac[i] = rfac[i + 1] * (i + 1) % Mod;

	dp[0][0] = 1;
	For(i, 0, n) For(j, i, n){
		(dp[i + 1][j] += dp[i][j]) %= Mod;
		(dp[i][j + 1] += dp[i][j] * C(i + (j + 1) * (k - 1) - 1, k - 2)) %= Mod;
	}

	printf("%lld\n", dp[n][n] * fac[n] % Mod);
	return 0;
}

Measured memory_bytes: 94592
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;


template<typename T>
bool is_prime(T n)
{
	if (n == 2)
	{
		return true;
	}
	else if ((n == 1) || (n % 2 == 0))
	{
		return false;
	}

	T p = (T)sqrt(n);
	for (T i = 3; i <= p; i += 2)
	{
		if (n % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
vector<T> prime_factor(T n)
{
	vector<T> pf;

	T m = n;
	for (T i = 2; m > 1;)
	{
		if (m % i == 0)
		{
			m /= i;
			if (pf.empty() || pf.back() != i)
			{
				pf.push_back(i);
			}
		}
		else
		{
			if (is_prime(m))
			{
				pf.push_back(m);
				return pf;
			}
			else
			{
				i++;
			}
		}
	}
	return pf;
}

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

	vector<int> pf = prime_factor(n);
	double sum = n;
	for (int i = 0; i < pf.size(); i++)
	{
		sum *= (1.0 - 1.0 / pf.at(i));
	}

	cout << (int)sum << endl;
}


Measured memory_bytes: 3144
#include<stdio.h>
int main(void){
	int i,j,h,w,x;
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0&&w==0) break;
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
			    x=i+j;
				if(x%2==0){
					putchar('#');
				}else{
					putchar('.');
				}
			}
			putchar('\n');
		}
		putchar('\n');
	}

return(0);
}



Measured memory_bytes: 2124
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		int L = nextInt();

		int[] apple = new int[N];

		for(int i=0;i<N;i++) {
			apple[i] = i+L;
		}
		long sum = 0;
		int minabs = Math.abs(apple[0]);
		int minabs_i = 0;
		for(int i=0;i<N;i++) {
			sum += apple[i];
			int t_abs = Math.abs(apple[i]);
			if(t_abs<minabs) {
				minabs = t_abs;
				minabs_i = i;
			}
		}
		sum -= apple[minabs_i];
		out.println(sum);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}
}

Measured memory_bytes: 21844
# coding: utf-8
# Your code here!
n,m, = map(int,input().split())
list = [] 
for i in range(n+1):
    list.append(0)
for i in range(m):
    load1,load2 = map(int,input().split())
    list[load1] = list[load1]+1
    list[load2] = list[load2]+1
for i in range(1,n+1):
    print(list[i])

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
  int a,b,c,x,y;
  
  cin >> a >> b >> c >> x >> y;
  if (a+b<=c*2){
    cout << (a*x + b*y) << endl;
  } else {
    if (x<y){
      cout << (x*2*c+(y-x)*MIN(b,2*c)) << endl;
    } else {
      cout << (y*2*c+(x-y)*MIN(a,2*c)) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
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 main() {
  int N, M; cin >> N >> M;
  vector<int> step1, step2;
  rep(i, M) {
    int a, b; cin >> a >> b;
    if(a == 1) step1.push_back(b);
    else if(b == N) step2.push_back(a);
  }
  sort(step1.begin(), step1.end());
  sort(step2.begin(), step2.end());

  for(auto i:step2) {
    if(binary_search(step1.begin(), step1.end(), i)) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
// #define s second
#define int long long

int32_t main()
{
 
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   int t;
   cin >> t;
vll arr(4);
   while(t--){
   	string s;
   	cin >> s;
   	
   	if(s == "AC")arr[0]++;
   	else if(s == "WA")arr[1]++;
   	else if(s == "TLE")arr[2]++;
   	else if(s == "RE")arr[3]++;

   }
   	
   		cout << "AC x " << arr[0] << endl;
   		cout << "WA x " << arr[1] << endl;
   		cout << "TLE x " << arr[2] << endl;
   		cout << "RE x " << arr[3] << endl;
   	
 
return 0;
}


Measured memory_bytes: 3616
def main():
    n = int(input())
    a = list(map(int, input().split()))

    cnt = 0
    for i, e in enumerate(a):
        if (i+1) % 2 == 1 and e % 2 == 1:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9112
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
#define MAX_N 105
#define X 1000000007
using namespace std;
bool debug=false;


int main(){
  long long sum=0;
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)sum+=i;
  cout<<sum<<endl;
  
  return 0;
}

Measured memory_bytes: 256
s = input()
# print(s)
flag=0
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        print(i+1,i+2)
        flag = 1
        break
    if i<len(s)-2:
        if s[i]==s[i+2]:
            print(i+1,i+3)
            flag = 1
            break
if flag ==0:
    print(-1,-1)

Measured memory_bytes: 3188
//by xxj
#include<bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define lowbit(x) x&-x
const int inf=1e9+7;
const double eps=1e-10;
const ll linf=1e18+7;
const ll hh=523;
const int mod=1e9+7;
int qsm(int a,int c){
	int re=1;
	while (c!=0){
		if (c%2==1){
			re=1ll*re*a%mod;
		}
		a=1ll*a*a%mod;
		c/=2;
	} 
	return re;
}
int jc[200007],njc[200007];
int C(int n,int m){
	return (1ll*jc[n]*njc[m]%mod)*njc[n-m]%mod;
}
int n;
void init(){
	jc[0]=1;
	for (int i=1;i<=2*n;i++){
		jc[i]=1ll*jc[i-1]*i%mod;
//		cout<<i<<' '<<jc[i]<<endl;
	}
	njc[2*n]=qsm(jc[2*n],mod-2);
	for (int i=2*n-1;i>=0;i--){
		njc[i]=1ll*njc[i+1]*(i+1)%mod;
	}
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int a,b,c;
	scanf("%d%d%d%d",&n,&a,&b,&c);
	init();
	ll ans=0;
	int reala=1ll*qsm(a+b,mod-2)*a%mod;
	int realb=1ll*qsm(a+b,mod-2)*b%mod;
	int realc=1ll*100*qsm(100-c,mod-2)%mod;
//	cout<<reala<<' '<<realb<<endl;
	for (int i=n;i<=2*n-1;i++){
		ll A=1ll*qsm(reala,n)*qsm(realb,i-n)%mod;
		ll B=1ll*qsm(realb,n)*qsm(reala,i-n)%mod;
//		cout<<A<<' '<<B<<' '<<ans<<endl;
		ans=(ans+((1ll*C(i-1,n-1)*(A+B)%mod)*i%mod)*realc%mod)%mod;
//		cout<<A+B<<endl;
	}
	printf("%lld\n",ans);
	return 0;
}
/*
input:
*/


Measured memory_bytes: 1792
import sys
cs = { c : 0 for c in list("abcdefghijklmnopqrstuvwxyz")}
for c in list(sys.stdin.read()):
    c = c.lower()
    if c in cs.keys():
        cs[c] = cs[c] + 1
for (c,cnt) in sorted(list(cs.items())):
    print('{0} : {1}'.format(c,cnt))

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

class P
{
    static void Main()
    {
        Console.ReadLine();
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] b = new int[a.Length];
        if (a.Length % 2 == 0)
        {
            for (int i = 0; i < a.Length; i++)
            {
                b[a.Length / 2 + (i % 2 == 0 ? 1 : -1) * (i + 1) / 2] = a[i];
            }
        }
        else
        {
            for (int i = 0; i < a.Length; i++)
            {
                b[a.Length / 2 + (i % 2 == 0 ? -1 : 1) * (i + 1) / 2] = a[i];
            }
        }
        Console.WriteLine(string.Join(" ", b));
    }
}

Measured memory_bytes: 48440
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    string s;
    cin>>n;
    cin>>s;
    int sum=0;
    
    for(int i=0;i<n-2;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
            sum++;
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
#include <set>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl;
typedef long long ll;
typedef pair<int, int> P;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if (a > b) {
        int tmp = a;
        a = b;
        b = tmp;
    }
    if (a < c && b > c) {
        cout << "Yes" << endl;
    }
    else
    {
        OUT("No");
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int unused __attribute__((unused));
  char N[5];
  unused = scanf("%s", N);

  if(N[0]==N[1] && N[0]==N[2]) printf("Yes");
  else if(N[1]==N[2] && N[1]==N[3]) printf("Yes");
  else printf("No");

  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
    public static int n;
    public static int A[];
    public static int q;
    public static int M[];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        A = new int[n+1];
        for(int i = 0;i < n;i++){
            A[i] = sc.nextInt();
        }
        q = sc.nextInt();
        M = new int[q+1];
        for(int i = 0; i < q;i++){
            M[i]= sc.nextInt();
        }
        for(int i = 0;i < q; i++){
            if(dfs(0,0,M[i])) System.out.println("yes");
            else System.out.println("no");            
        }
        sc.close();
    }

    private static boolean  dfs(int i,int sum,int ans){
        if (i==n) return sum == ans;
        if(dfs(i+1,sum,ans)) return true;
        if(dfs(i+1,sum+A[i],ans)) return true;
        return false;
    }
}



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

// int choose(int n, int a){
//     int x = 1, y = 1;
//     rep(i, a){
//         x *= n-i;
//         y *= i+1;
//     }
//     return x / y;
// }

int main() {
    int n;
    cin >> n;
    int x[n], y[n];
    double sum = 0;
    rep(i, n){
        cin >> x[i] >> y[i];
    }
    rep(i, n)rep(j, n){
        if(i == j) continue;
        sum += sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
    }
    // int fact = 1;
    // for(int i = 1; i <= n; i++){
    //     fact *= i;
    // }
    // cout << sum/n << endl;
    printf("%.10f", sum/n);

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long int a,b,c,d,s=0;
	scanf("%lld",&a);
	s+=a/500*1000;
	a-=a/500*500;
	s+=a/5*5;
	printf("%lld",s);
	
	
	
	
	
 } 

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int a, b, c;
    
    cin >> a >> b;
    
    if (a%2!=0 && b%2!=0)
        cout << "Yes\n";
    else 
        cout << "No\n";
    

    return 0;
}

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

int main() {
    int K; cin >> K;
    queue<int64_t> que;
    for(int i = 1; i < 10; ++i) que.push(i);
    K--;
    while(K--) {
        auto t = que.front();
        que.pop();
        int l = t % 10;
        for(int i = max(0, l - 1); i <= min(9, l + 1); ++i) {
            que.push(10 * t + i);
        }
    }
    cout << que.front() << '\n';
    return 0;
}


Measured memory_bytes: 5128
//const int N = 51;
//ll dp[N][N*N+N][N];
//int _(){
//    int n;
//    cin >> n;
//    vi arr(n);
//    cin >> arr;
//    vi ans;
//    rep(i,0,n-1)
//        ans.pb(abs(i-(n-i-1)));
//    sort(all(ans));
//    sort(all(arr));
//    if(ans != arr)
//        return 0;
//    return ipow(2,n/2);
//
//
//}
//
//
#include <iomanip>
#include <algorithm>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define pb push_back
#define REP_INT(i,l,r) for(int i = l; i <= r; ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
ll ipow(ll x, ll p, ll mod = MOD){
    if(abs(x) >= mod)
        x %= mod;
    if(x < 0)
        x += mod;
    if(p == 0)
        return 1;
    if(p == 1)
        return x;
    return ipow(x * x % mod, p / 2, mod) * ipow(x, p % 2, mod) % mod;
}
const int N = 51;
ll dp[N][N*N+N][N];
int _(){
    int n;
    cin >> n;
    vi arr(n);
    cin >> arr;
    vi ans;
    rep(i,0,n-1)
        ans.pb(abs(i-(n-i-1)));
    sort(all(ans));
    sort(all(arr));
    if(ans != arr)
        return 0;
    return ipow(2,n/2);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


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

namespace IO {
    const int maxn(1 << 21 | 1);

    char ibuf[maxn], *iS, *iT, c;
    int f;

    inline char Getc() {
        return iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, maxn, stdin), (iS == iT ? EOF : *iS++)) : *iS++;
    }

    template <class Int> inline void In(Int &x) {
        for (f = 1, c = Getc(); c < '0' || c > '9'; c = Getc()) f = c == '-' ? -1 : 1;
        for (x = 0; c >= '0' && c <= '9'; c = Getc()) x = (x << 1) + (x << 3) + (c ^ 48);
        x *= f;
    }
}

using IO :: In;

const int maxn(1e5 + 5);
const int mx(2200);

int n, tot, ans;
ll v[maxn], p[maxn], s, pri[mx];
map <ll, int> cnt, vis;

int main() {
	for (int i = 2; i < mx; ++i) {
		int flg = 0;
		for (int j = 2; j * j <= i && !flg; ++j)
			if (i % j == 0) flg = 1;
		if (!flg) pri[++tot] = i;
	}
	In(n);
	for (int i = 1; i <= n; ++i) {
		In(s), v[i] = p[i] = 1;
		for (int j = 1; j <= tot && s >= pri[j]; ++j)
			if (s % pri[j] == 0) {
				int num = 0;
				while (s % pri[j] == 0) s /= pri[j], ++num;
				if (!(num %= 3)) continue;
				if (num == 1) p[i] *= pri[j] * pri[j], v[i] *= pri[j];
				else v[i] *= pri[j] * pri[j], p[i] *= pri[j];
			}
		if (s > 1) {
			ll x = sqrt(s);
			if (x * x == s) p[i] *= x, v[i] *= x * x;
			else v[i] *= s, p[i] *= s * s;
		}
		++cnt[v[i]];
	}
	if (cnt[1]) cnt[1] = 1;
	for (int i = 1; i <= n; ++i)
		if (!vis[v[i]]) {
			ans += max(cnt[v[i]], cnt[p[i]]);
			vis[v[i]] = vis[p[i]] = 1;
		}
	printf("%d\n", ans);
    return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

constexpr auto M = 1000000007L;

int main() {
    int64_t n, c;
    cin >> n >> c;

    vector<int64_t> a(n), b(n);
    for (auto i : irange(0L, n)) {
        cin >> a[i];
    }
    for (auto i : irange(0L, n)) {
        cin >> b[i];
    }

    vector<vector<int64_t>> powsum(401, vector<int64_t>(401));
    for (auto i : irange(1L, 401L)) {
        // i^j
        int64_t i_j = 1;
        for (auto j : irange(0L, 401L)) {
            powsum[j][i] = powsum[j][i - 1] + i_j;
            powsum[j][i] %= M;
            i_j = i_j * i % M;
        }
    }

    vector<vector<int64_t>> dp(n + 1, vector<int64_t>(c + 1));
    dp[0][0] = 1;
    for (auto i : irange(0L, n)) {
        for (auto d : irange(0L, c + 1)) {
            for (auto cc : irange(0L, d + 1)) {
                dp[i + 1][d] +=
                        dp[i][cc] *
                        (powsum[d - cc][b[i]] - powsum[d - cc][a[i] - 1] + M) % M;
                dp[i + 1][d] %= M;
            }
        }
    }

    cout << dp[n][c] << endl;
}

Measured memory_bytes: 2816
from collections import Counter
ans=0
n=int(input())
a=list(map(int,input().split()))
a_tmp=dict(Counter(a).most_common())
for i,j in a_tmp.items():
    i=int(i)
    j=int(j)
    if i==j:
        pass
    elif i<j:
        ans+=j-i
    else:
        ans+=j
print(ans)


Measured memory_bytes: 26732
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String N = scan.next();
        int n = Integer.parseInt(N);
        String M = scan.next();
        int m = Integer.parseInt(M);
        
        ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>();

        for (int i = 0; i < n; i++) {
            list.add(new ArrayList<Integer>());
        }

        for (int i = 0; i < m; i++) {
            String A = scan.next();
            int a = Integer.parseInt(A);
            String B = scan.next();
            int b = Integer.parseInt(B);
            a--;
            b--;
            list.get(a).add(b);
            list.get(b).add(a);
        }
        //System.out.println(list);

        Queue<Integer> q = new ArrayDeque<>();

        ArrayList<Integer> dist = new ArrayList<Integer>();
        int depth = n;
        for (int i = 0; i < n; i++) {
            dist.add(n);
        }
        //System.out.println(dist);

        ArrayList<Integer> pre = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            pre.add(-1);
        }
        //System.out.println(pre);

        dist.set(0, 0);
        q.add(0);
        while (q.peek() != null) {
            int v = q.poll();
            for (int u: list.get(v)) {
                if (dist.get(u) != n) continue;
                dist.set(u, dist.get(v) + 1);
                pre.set(u, v);
                q.add(u);
            }
        }

        System.out.println("Yes");
        for (int i = 0; i < n; i++) {
            if (i == 0) continue;
            int ans = pre.get(i);
            ans++;
            System.out.println(ans);
        }
    }
}

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

#define MAX_N 400

int n;
ll a[MAX_N];
ll sum[MAX_N + 1];
ll dp[MAX_N][MAX_N + 1];

ll get(int left, int right){
    return sum[right] - sum[left];
}

ll rec(int left, int right){
    if(dp[left][right] != -1){
        return dp[left][right];
    }
    if(right - left <= 1){
        return dp[left][right] = 0;
    }
    ll res = LINF;
    for(int i = left + 1; i < right; i++){
        res = min(res, rec(left, i) + rec(i, right) + get(left, i) + get(i, right));
    }
    return dp[left][right] = res;
}

signed main(){
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        sum[i + 1] = sum[i] + a[i];
    }
    fill(dp[0], dp[MAX_N], -1);
    cout << rec(0, n) << endl;
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <cstdlib>
#include <algorithm>
using namespace std;
/*
int dfs(int w,int h,int noww,int nowh,int n,int b){
	++n;
	if(noww>w || nowh>h) return 0;
	if(noww==w && nowh==h) return 1;
	int ret=0;
	for(int i=0; i<2; ++i){
		if(n>=2){
			n=0;
			if(i==0){
				b=1;
				ret+=dfs(w,h,++noww,nowh,n,b);
			} else if(i==1){
				b=2;
				ret+=dfs(w,h,noww,++nowh,n,b);
			}
		} else{
			if(b==1)ret+=dfs(w,h,++noww,nowh,n,b);
			if(b==2)ret+=dfs(w,h,noww,++nowh,n,b);
		}
	}
	return ret;
}

int main()u{
	int w,h;
	cin >> w >> h;
	cout << dfs(w,h,1,1,2,0) << endl;
	return 0;
}
*/
int calc(vector<int> balls,int i,int cas1,int cas2,int a,int sum);

int main(){
	int n;
	cin >> n;
	for(int i=0; i<n; ++i){
		vector<int> balls(10);
		for(int i=0 ;i<10; ++i){
			cin >> balls[i];
		}
		int sum=0;
		if(calc(balls,0,0,0,0,sum)>0){
			cout << "YES" << endl;
		} else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

int calc(vector<int> balls,int i,int cas1,int cas2,int a,int sum){
	if(i==10) {
		//cout << cas1 << " " << cas2 << " " << a << " " << balls[i-1] << endl;
		return 1;
	}
	if(a==0&&balls[i]<cas1) return 0;
	if(a==1&&balls[i]<cas2) return 0;
	if(a==0)cas1=balls[i];
	if(a==1)cas2=balls[i];
	sum += calc(balls,i+1,cas1,cas2,0,sum);
	sum += calc(balls,i+1,cas1,cas2,1,sum);

	return sum;
}

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

int main(){
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	int ans=0;
	for(int i=0;i<s.size();i++){
		if(s.substr(i)==t.substr(0,n-i)){
			ans=max(ans,n-i);
		}
	}
	cout<<n*2-ans<<endl;
}


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

using namespace std;
#define endl "\n"
#define int long long

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    auto p = a;
    int count{0};
    for (int j = 0; j < n - 2; j++) {
        int temp = a[j + 1];
        sort(a.begin() + j, a.begin() + j + 3);
        if (a[j + 1] == temp)
            count++;
        a = p;
    }
    return cout << count, 0;
}

Measured memory_bytes: 256
package main
  
import (
    "fmt"
)

func main() {
    var bs []byte
    fmt.Scan(&bs)
    var l int
    for i := range bs {
        if bs[i] == 'x' {
            l++
        }
    }
    if l >= 8 {
        fmt.Println("NO")
    } else {
        fmt.Println("YES")
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

class ModInt {
  int val; static const int MOD = 1e9+7; static_assert(MOD > 0, "Modulus not set!");
  static int modInverse(int a, int mod = MOD) { // simplified extended GCD, only solving for x
    int b = mod, x = 0, x_ = 1, q; while (a != 0) { q = b / a; swap(b, a); a %= b;
    swap(x, x_); x_ -= q * x; } assert(b == 1); return (x %= mod) < 0 ? (x + mod) : x; }
  public: ModInt() : val(0) { } ModInt(int v) : val(v) { if ((val %= MOD) < 0) val += MOD; }
    ModInt& operator += (const ModInt& b) { (val += b.val) %= MOD; return *this; }
    ModInt& operator -= (const ModInt& b) { return (*this) += MOD-b.val; }
    ModInt& operator *= (const ModInt& b) { val = ((ll)val*(ll)b.val) % MOD; return *this; }
    ModInt& operator /= (const ModInt& b) { return (*this) *= modInverse(b.val); }
#define _op(op, op2) ModInt operator op (const ModInt& b) const { ModInt ans = *this; return ans op2 b; }
    _op(+, +=); _op(-, -=); _op(*, *=); _op(/, /=);
#undef _op
    ModInt pow(ll e) const { ModInt res(1), b(*this); for (; e>0; e/=2, b*=b) { if (e&1) res*=b; } return res; }
    int toInt() const { return val; }
};

ModInt nCr(int n, int r) {
  if (r>n) return 0;
  if (r<<1>n) r=n-r;
  if (!r) return 1;
  ModInt res=n;
  for (int i = 2; i <= r; ++i) {
    res *= (n-i+1);
    res /= i;
  } return res;
}

// b^e % mod
ModInt modpow(ModInt b, int e) { ModInt res = 1; for (; e>0; e>>=1, b*=b) { if (e&1) res*=b; } return res; }

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  int n, a, b; cin >> n >> a >> b;
  ModInt all = modpow(2,n)-1;
  ModInt sub = nCr(n,a) + nCr(n,b);
  ModInt ans = all - sub;

  cout << ans.toInt() << nl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>

using namespace std;

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

double solve(int n, int m, int k){
    vector<int> cnt(1, 1);
    int T = 0;
    rep(i, n){
        vector<int> nxt(T + m + 1, 0);
        for(int j=0; j<=T; ++j)if(cnt[j]){
            for(int x=1; x<=m; ++x)nxt[j+x] += cnt[j];
        }
        nxt.swap(cnt);
        T += m;
    }
    int sum = 0;
    for(int i=1; i<=T; ++i)sum += max(1, i - k) * cnt[i];
    return sum / pow(m, n);
}

int main(){
    int n, m, k;
    while(cin >> n >> m >> k, n|m|k){
        cout << fixed << setprecision(9) << solve(n, m, k) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1360
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = map(int, input().split())
cakes = []
for _ in range(N):
    cakes.append(list(map(int, input().split())))


def sum_cake(a, b, c):
    ret = []
    for x in cakes:
        ret.append(x[0]*a+x[1]*b+x[2]*c)

    ret = sorted(ret, reverse=True)
    return sum(ret[:M])


def solve2():
    ans = 0
    p = [1, -1]
    for a in p:
        for b in p:
            for c in p:
                ans = max(sum_cake(a, b, c), ans)
    print(ans)


solve2()


Measured memory_bytes: 3316
S=0
N = int(input())
l = map(int, input().split())

l = list(sorted(l))

for i in range(1, N+1):
    if i%2 == 1:
        S+=l[N-i]
        #print(S)
    else:
        S-=l[N-i]
        #print(S)
            

#print('--------')
print(S)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    vector<int> H;
    rep (i, 0, N) {
        int h; cin >> h;
        H.push_back(h);
    }

    reverse(H.begin(), H.end());

    int before = H[0];
    rep (i, 1, H.size()) {
        if (before >= H[i]) {
            before = H[i];
            continue;
        }
        else if (before == H[i]-1) {
            H[i] -= 1;
            before = H[i];
        }
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 892
fn main(){
  let mut pv: Vec<bool> = vec![true;1000001];
  pv[0] = false;
  pv[1] = false;

  let mut i: usize = 2;
  
  while i * i <= 1000000 {
    if pv[i] {
      let mut j: usize = i * i;

      while j <= 1000000 {
        pv[j] = false;
        j += i;
      }
    }
    i += 1;
  }
  
  loop {
    let nx:Vec<usize> = read_vec();
    let n = nx[0];
    let x = nx[1];

    if n == 0 && x == 0 { break; }

    let mut dp: Vec<bool> = vec![false;x+1];
    dp[0] = true;
    
    for _ in 0 .. n {
      let i: usize = read();

      for j in 0 .. x + 1 {
        if dp[j] && i + j <= x {
          dp[i + j] = true;
        }
      }
    }

    let mut ans = 0;
    
    for i in (1 .. x + 1).rev() {
      if dp[i] && pv[i] {
        ans = i;
        break;
      }
    }

    if ans == 0 {
      println!("NA");
    } else {
      println!("{}", ans);
    }
  }
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003;
const int INF=(1<<30);

int state[MAX],N,D[MAX];
vector<pair<int,int>> S[MAX];
priority_queue<pair<int,int>> Q;

void dijkstra(int u){
    int cnt=0;
    for(int i=0;i<N;i++){
        state[i]=0;
        D[i]=INF;
    }
    
    D[u]=0;
    Q.push(make_pair(0,u));
    
    while(1){
        int a=Q.top().second;
        Q.pop();
        if(state[a]==0){
            state[a]=1;
            for(int i=0;i<S[a].size();i++){
                if(state[S[a][i].first]==0){
                    Q.push(make_pair(-(D[a]+S[a][i].second),S[a][i].first));
                    D[S[a][i].first]=min(D[S[a][i].first],D[a]+S[a][i].second);
                }
            }
            cnt++;
        }
        if(cnt==N) break;
    }
    return;
}


int main(){

    cin>>N;
    for(int i=0;i<N;i++){
        int l,a;cin>>l>>a;
        for(int j=0;j<a;j++){
            int b,c;cin>>b>>c;
            S[i].push_back(make_pair(b,c));
        }
    }
    dijkstra(0);
    for(int i=0;i<N;i++){
        cout<<i<<" "<<D[i]<<endl;
    }
}



Measured memory_bytes: 11912
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, *a = [ri() for _ in range(6)]
print(math.ceil(n / min(a)) + 4)














Measured memory_bytes: 27008