akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =99999999999;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




//10億7。　　　100000007
//2*2行列 H*W
//vector<vector<int>> vec(H,vector<int>(W));
//for(int i=0;i<H;i++){
//for(int j=0;j<W;j++){
//cin>>vec[i][j];
//  }
//}

//文字列→数列
//string S;int A=atoi(S.c_str());
//数列→文字列
//int A;string S=to_string(A);
//数字判定　isdigit(a)
//pair宣言　pair<int,int> p(5,7);
//ソート　sort(vec.begin(),vec.end());



int main(){
cout<<fixed<<setprecision(10);
 int A,B;cin>>A>>B;
  cout<<(A-1)*(B-1)<<endl;
}


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

int i,j,k;

int main(){
    int n;cin>>n;
    vector<int> length(n);//棒の長さ
    for(i=0;i<n;i++){cin>>length[i];}
    
    sort(length.begin(),length.end(),greater<int>());//降順sort

    int ans=0;
    for(i=0;i<n-2;i++){
        for(j=i+1;j<n-1;j++){
            for(k=j+1;k<n;k++){
                if(length[i]<length[j]+length[k]){ans++;}
            }
        }
    }

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

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

using namespace std;

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

    int X[N], Y[N];
    for (int i = 0; i < N; ++i)
    {
        cin >> X[i] >> Y[i];
    }

    double distance = 0;
    int counter = 0;
    for (int i = 0; i < N; ++i)
    {

        distance = sqrt(pow(X[i], 2) + pow(Y[i], 2));
        if (distance <= (double)D)
        {
            counter++;
        }
    }
    cout << counter << "\n";
}


Measured memory_bytes: 4792
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

int main(){
	int N;
	cin >> N;
	vector<int> p(N);
	for(int i = 0; i < N; ++i) {
		cin >> p[i];
		--p[i];
	}
	int cnt = 0;
	for(int i = 0; i < N - 1; ++i) {
		if(p[i] == i) {
			swap(p[i], p[i + 1]);
			++cnt;
		}
	}
	if(p[N-1] == N - 1) {
		swap(p[N-1], p[N-2]);
		++cnt;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = new long[n];
            long cnt = 0;
            for (int i = 0; i < n; i++) {
                a[i] = in.nextLong();
            }
            Arrays.sort(a);
            int i = n - 1;
            while (true) {
                long mod = a[i] % n;
                long times = (a[i] - (mod)) / n;
                a[i] = mod;
                cnt += times;
                for (int j = 0; j < n; j++) {
                    if (j != i) a[j] += times;
                }
                boolean done = true;
                for (long k : a) {
                    if (k > n - 1) {
                        done = false;
                    }
                }
                if (done) break;
                i--;
                if (i == -1) {
                    i = n - 1;
                }
            }
            out.println(cnt);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

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

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

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

    }
}



Measured memory_bytes: 23380
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <bitset>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef unsigned long long ull;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int INF = 1 << 27;
const int MAX_V = 101;
//////////////////////////////
// ????°??????¨???
struct edge { int to, cap, cost, rev; };

int V;
vector<edge> G[MAX_V]; //??°???????????£??\???????????¨???
int h[MAX_V]; //??????????????£???
int dist[MAX_V]; //???????????¢
int prevv[MAX_V], preve[MAX_V]; // ??´??????????????¨???

void add_edge(int from, int to, int cap, int cost){
  G[from].push_back((edge){to, cap, cost, (int)G[to].size()});
  G[to].push_back((edge){from, 0, -cost, (int)(G[from].size()) - 1});
}
// s??????t????????????f???????°??????¨???
// ??????????????´??????-1?????????
int min_cost_flow(int s, int t, int f){
  int res = 0;
  fill(h, h + V, 0);
  while(f > 0){
    priority_queue<pi, vector<pi>, greater<pi> > que;
    fill(dist, dist + V, INF);
    dist[s] = 0;
    que.push(pi(0, s));
    while(!que.empty()){
      pi p = que.top(); que.pop();
      int v = p.second;
      if(dist[v] < p.first) continue;
      REP(i, G[v].size()){
        edge &e = G[v][i];
        if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
          dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
          prevv[e.to] = v;
          preve[e.to] = i;
          que.push(pi(dist[e.to], e.to));
        }
      }
    }
    if(dist[t] == INF) return -1;
    REP(v, V) h[v] += dist[v];
    int d = f;
    for(int v = t; v != s; v = prevv[v]) d = min(d, G[prevv[v]][preve[v]].cap);
    f -= d;
    res += d * h[t];
    for(int v = t; v != s; v = prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}

int main() {
  int E, F; cin >>V >>E >>F;
  REP(i, E){
    int a,b,c,d; cin >> a >> b >> c >> d;
		add_edge(a,b,c,d);
  }
  cout << min_cost_flow(0, V-1, F)  <<endl;
  return 0;
}

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

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


//C++14 (GCC 5.4.1)
int main() {
    int N,M;
    cin >>N>>M;

    vector<int> X(M);
    rep(i,M) cin >> X[i];
    
    //-----------------------------------
    bool is=false;
    int ans=0;
    vector<int> Y(M-1);

    sort(X.begin(),X.end());
    rep(i,M-1) Y[i]=X[i+1]-X[i];
    sort(Y.begin(),Y.end());
    rep(i,M-N)ans+=Y[i];

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

Measured memory_bytes: 1024
a,b,c=map(int,input().split())
if a>b:
	(a,b)=(b,a)
	if b>c:
		(b,c)=(c,b)
	if a>b:
		(a,b)=(b,a)
elif b>c:
	(b,c)=(c,b)
	if b>c:
		(b,c)=(c,b)
print(a,b,c)

Measured memory_bytes: 7696
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

//long long a[1002];


int main()
{
	long long N, cnt = 0, tmp, ans = 0;
	long long H, W;
	cin >> H >> W;
	vector<vector<int>> a = vector<vector<int>>(H, vector<int>(W, 0));
	vector<bool> fh(H, true), fw(W, true);
	char c;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> c;
			if (c == '#') {
				a[i][j] = 1;
				fh[i] = false;
			}
		}
	}


	for (int j = 0; j < W; j++) {
		for (int i = 0; i < H; i++) {
			if (a[i][j] == 1) {
				fw[j] = false;
			}
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (fw[j] == false && fh[i] == false) {
				if (a[i][j] == 0) {
					cout << '.';
				}
				else {
					cout << '#';
				}
			}
		}
		if(fh[i] == false)cout << endl;
	}


	char qq;
	cin >> qq;
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<string> keihin(N);

    rep(i,N){
        cin >> keihin[i];
    }

    set<string> keihin2;
    rep(i,N){
        keihin2.insert(keihin[i]);
    }

    int ans=keihin2.size();
    cout << ans <<endl;
}

Measured memory_bytes: 25172
import numpy as np

n = int(input())

happiness = [0]*3

for i in range(n):
    act = list(map(int, input().split()))
    tmp1 = [happiness[(i+1)%3]+act[i] for i in range(3)]
    tmp2 = [happiness[(i+2)%3]+act[i] for i in range(3)]
    happiness = [max(tmp1[i], tmp2[i]) for i in range(3)]

print(max(happiness))

Measured memory_bytes: 14484
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const INF: i64 = 1 << 60;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let X: i64 = sc.get();
    let N: usize = sc.get();
    let p: Vec<i64> = sc.vec(N);
    let p: HashSet<i64> = p.into_iter().collect();
    let mut diff = INF;
    let mut ans = 0;
    for i in 0..=101 {
        if !p.contains(&i) && diff > (i - X).abs() {
            diff = (i - X).abs();
            ans = i;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2144
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <numeric>
#include <climits>
#define ll long long
#define INF 1000000000
using namespace std;
int main(){
    ll N,x;
    cin >> N >> x;
    ll A[N];
    for(int i=0;i<N;i++) cin >> A[i];

    ll ans = 0;
    for(int i=0;i<N-1;i++){
        if(A[i]+A[i+1]>x){
            int d = (A[i+1]+A[i])-x;
            if(A[i+1]>=d){
                A[i+1] -= d;
                ans += d;
            }else{
                ans += d;
                d -= A[i+1];
                A[i+1] = 0;
                A[i] -= d;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
s = input()

res = ''

for i in range(len(s)):
    if res == '':
        if s[i] == 'B':
            pass
        else:
            res += s[i]
    else:
        if s[i] == 'B':
            res = res[:-1]
        else:
            res += s[i]
    
print(res)

Measured memory_bytes: 2940
n, m, l = map(int, raw_input().split())

A = [0]*n*m
for k in xrange(n):
    A[k*m:k*m+m] = map(int, raw_input().split())

B = [0]*m*l
for k in xrange(m):
    B[k*l:k*l+l] = map(int, raw_input().split())

C = [0]*n*l
for i in xrange(n):
    for j in xrange(l):
        for k in xrange(m):
            C[i*l + j] += A[i*m + k] * B[k*l + j]
        if j < l-1:
            print C[i*l + j],
        else:
            print C[i*l + j]

Measured memory_bytes: 5000
def main():
    """
    Tの命令 組合せ: 2^N_T
    max_N_T: 8000

    |x|,|y|<=8000
    -> (x,y) 組合せ: 10^8 < 16,000^2 < 10^9
    """
    s = input()
    x, y = map(int, input().split())

    f(s, x, y)
    return
    solve(s, x, y)


def f(s, x, y):
    # Fの数をまとめる
    f_counts = [
        len(fs)
        for fs in s.split("T")
    ]
    # 曲がる方向が90°より、x,yに分解
    x_counts = []
    y_counts = []
    for i, count in enumerate(f_counts):
        if i % 2 == 0:
            x_counts.append(count)
        else:
            y_counts.append(count)

    x_dp = [{} for _ in range(len(x_counts))]
    y_dp = [{} for _ in range(len(y_counts) + 1)]
    pos_x = x_counts.pop(0)
    x_dp[0][pos_x] = True
    y_dp[0][0] = True

    for i, count in enumerate(x_counts):
        for pos in x_dp[i].keys():
            x_dp[i + 1][pos + count] = True
            x_dp[i + 1][pos - count] = True
    for i, count in enumerate(y_counts):
        for pos in y_dp[i].keys():
            y_dp[i + 1][pos + count] = True
            y_dp[i + 1][pos - count] = True

    if x_dp[-1].get(x) and y_dp[-1].get(y):
        print("Yes")
    else:
        print("No")


def solve(s, x, y):
    pos_x, pos_y = 0, 0
    dir_x, dir_y = 1, 0
    for q in s:
        if q == "F":
            pos_x += dir_x
            pos_y += dir_y
        else:
            pass

    if (pos_x, pos_y) == (x, y):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 452812
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
int x[100000],y[100000],z[100010];
signed main(){
	int a,b,ans=0;
	cin>>a>>b;
	f(i,b){
		int c,d;
		cin>>c>>d;
		z[c]++;
		z[d+1]--;
	}
	f(i,a+1){
		if(i)z[i]+=z[i-1];
		if(z[i]==b)ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
while True:

    n, x = map(int, input().split())
    if n == x == 0 :
        break
    count = 0
    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1,n):
                if (i + j + k + 3 == x):
                    count += 1
    print(count)

Measured memory_bytes: 7652
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a,b;
	cin>>n;
	if(n==1)
		cout<<"Hello World"<<endl;
	if(n==2)
	{
		cin>>a>>b;
		cout<<a+b<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

int main(void) {
    string s;
    cin >> s;
    map<char, int> mp;
    Int length = s.length();
    for (Int i = 0; i < length; ++i) {
        mp[s[i]]++;
    }
    bool result = true;
    for (Int i = 0; i < length; ++i) {
        if (mp[s[i]] != 2) {
            result = false;
        }
    }
    if (result) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3612
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n, h[20], a = 0, b = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (int j = 0; j < n; j++) {
		a = 0;
		for (int k = 0; k < j; k++) {
			if (h[j] >= h[k]) {
				a++;
			}
		}
		if (a == j) {
			b++;
		}
	}
	cout << b << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  bool flag=true;
  for(int i=0;i<S.size()-1;i++){
    if(S.at(i)==S.at(i+1)){
      flag=false;
      break;
    }
  }
  if(flag){
    cout<<"Good"<<endl;
  }
  else{
    cout<<"Bad"<<endl;
  }
}


Measured memory_bytes: 256
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
N = len(s)

cnt = 0
for i in range(N):
    if i%2==0:
        if s[i]=="0":
            cnt += 1
    else:
        if s[i]=="1":
            cnt += 1
print(min(cnt,N-cnt))

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

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	int ans = 0;
	if(n < k){
		ans += n*x;
	}else{
		ans += (k*x + (n - k)*y);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N=2005;
vector<int>v[N];
int n,m,a,b,dist[N][N];
inline bool cmp(vector<int>x,vector<int>y){return x.size()>y.size();}
void bfs()
{
    for(int i=0;i<N;i++)for(int j=0;j<N;j++)dist[i][j]=1e9;
    queue<int>q;
    for(int i=0;i<n;i++)
    {
        q.push(0);
        q.push(i);
        q.push(i);
    }
    while(!q.empty())
    {
        int move=q.front();q.pop();
        int org=q.front();q.pop();
        int now=q.front();q.pop();
        if(dist[org][now]<=move)continue;
        dist[org][now]=move;
        for(int i=0;i<v[now].size();i++)
        {
            int to=v[now][i];
            q.push(move+1);
            q.push(org);
            q.push(to);
        }
    }

}
void solve()
{
    bfs();
    int pnt=0,ans=0;
    vector<int>e[N];
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            if(dist[i][j]>m)
                e[i].pb(j),pnt++;
    for(int i=0;i<n;i++)sort(e[i].begin(),e[i].end());
    while(pnt)
    {
        int MAX=0,num=-1;
        for(int i=0;i<n;i++)
        {
            if(MAX<e[i].size())
            {
                num=i;
                MAX=e[i].size();
            }
        }
        for(int i=0;i<e[num].size();i++)
        {
            int to=e[num][i];
            e[to].erase(lower_bound(e[to].begin(),e[to].end(),num));
        }
        ans++;
        pnt-=e[num].size()*2;
        e[num].clear();
    }
    cout<<ans<<endl;
    return;
}
int main()
{
    cin>>n>>m;
    for(int i=0;i<n-1;i++)
    {
        cin>>a>>b;
        a--,b--;
        v[a].pb(b);
        v[b].pb(a);
    }
    solve();
    return 0;
}

Measured memory_bytes: 65924
#include<iostream>
using namespace std;
int main(){
	int a,b,c,x,cnt=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(i*500+j*100+k*50==x){
					cnt++;
				}
			}
		}
	}
	cout<<cnt<<endl;
return 0;
}


Measured memory_bytes: 256
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	string s;
	while(cin >> s) {
		string ans = "Good";
		REP(i, SZ(s) - 1) {
			if(s[i] == s[i+1]) {
				ans = "Bad";
			}
		}
		cout << ans <<endl;
	}
	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define REP(i, N) for(int i=0, i##_len=(N); i<i##_len; i++)
#define RREP(i, N) for(int i=1, i##_len=(N); i<i##_len; i++)
#define REPP(i, N) for(int i=0, i##_len=(N); i<=i##_len; i++)
#define RREPP(i, N) for(int i=1, i##_len=(N); i<=i##_len; i++)
#define P(x) cout << (x) << '\n'
#define pb push_back
using ll = long long;
using namespace std;

int cnt[2];

int main() {
    string s; cin >> s;
    REP(i, s.length()) cnt[(s[i]=='1')?1:0]++; 
    P(2*min({cnt[0], cnt[1]}));
    return 0;
}


Measured memory_bytes: 512
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();
        int N = r.i();
      	int[] H = r.ii();
      	int num = 1;
        loop: for(int i = 1; i < N; i++){
            for(int j = 0; j < i; j++){
                if(H[i] < H[j]){
                    continue loop;
                }
            }
            num++;
        }        
        print(num);
    }
    static void print(String s){
        System.out.println(s);
    }
  	static void print(int i){
        System.out.println(i);
    }
    static void print(double d){
        System.out.println(d);
    }
    static void print(long l){
        System.out.println(l);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return readLine().split(" ");
        }
        int i() throws IOException{
            return Integer.parseInt(readLine());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++){
                ii[j] = Integer.parseInt(ss[j]);
            }
            return ii;
        }
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

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

    int n; ll W;
    cin >> n >> W;
    vll v(n), w(n);
    rep(i, n) cin >> v[i] >> w[i];
    vector<pair<ll, ll>> wv;
    rep(bit, 1<<(n/2)) {
        ll nw = 0, nv = 0;
        rep(i, n/2) if (bit>>i&1) {
            nw += w[i];
            nv += v[i];
        }
        wv.eb(nw, nv);
    }
    sort(all(wv));
    int m = 1;
    for (int i = 1; i < 1<<(n/2); ++i) {
        if (wv[m-1].se < wv[i].se) {
            wv[m++] = wv[i];
        }
    }
    ll ans = 0;
    const ll inf = 1e18;
    rep(bit, 1<<(n-n/2)) {
        ll nw = 0, nv = 0;
        rep(i, n-n/2) if (bit>>i&1) {
            nw += w[n/2+i];
            nv += v[n/2+i];
        }
        if (nw <= W) {
            auto itr = lower_bound(wv.begin(), wv.begin() + m, make_pair(W-nw, inf)) - 1;
            chmax(ans, nv + itr->se);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 19480
#include<stdio.h>
int main(void)
{
  int n,d[55]={},ans=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&d[i]);
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      ans+=d[i]*d[j];
    }
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int l,r;
cin>>l>>r;
if(l==0)
cout<<0;
else
{
	if((r-l)>=2019)
	cout<<0;
	else
	{
		int ans=10000000;
		for(int i=l;i<=r;i++)
		{
			for(int j=i+1;j<=r;j++)
			ans=min(ans,((i%2019)*(j%2019))%2019);
		}
		cout<<ans;
	}
}
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
solve();
cout<<endl;
}
}


Measured memory_bytes: 3636
n = int(input())
l = [int(x) for x in input().split()]
l.sort()
ans = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    a, b = l[i], l[j]
    s = a+b
    bit_l, bit_r = j+1, n
    while bit_r-bit_l > 1:
      key = (bit_l+bit_r)//2
      if s > l[key]:
        bit_l = key
      else:
        bit_r = key
    if bit_r == n and l[bit_l] >= s:
      bit_r = n-1
    elif bit_l == j+1 and l[bit_l] >= s:
      bit_r = j+1
    ans += bit_r-j-1
print(ans)

Measured memory_bytes: 45020
a,b,c=map(int,input().split())
ans='NO'
A=[]
for i in range(10001):
  A.append((a*i-c)%b)
  if(i>3)and(A[0]==A[-1]):
    break
  if (a*i-c)%b==0:
    ans='YES'
    break
print(ans)

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> coin_cnt(N+1);
  
  for(int i = 1; i <= N; i++){
	int point = i;  
    while(point < K){
      point *= 2;
      coin_cnt[i]++;
    }
  }
  
  double ans = 0, temp = 1 / double(N);
  for(int i = 1; i <= N; i++){
    ans += temp * (1/pow(2, coin_cnt[i]));
  }
  cout << fixed;
  cout << setprecision(12) << ans << endl;
}

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

int main() {
	string s,ans="";
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(i%2==0){
			ans+=s.substr(i,1);
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int main(){
    string s;
    cin>>s;
    int n=0;
    for (int i=0; i<s.size(); i++) {
        if(s.at(i)=='1'){
            n++;
        }
    }
    cout<<n<<endl;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<ll> x(n), y(n);
    for(int i = 0; i < n; i++){
        cin >> x[i];
        y[i] = x[i];
    }
    sort(y.begin(), y.end());
    ll mid1 = y[n / 2 - 1];
    ll mid2 = y[n / 2];
    for(int i = 0; i < n; i++){
        if(x[i] <= mid1){
            cout << mid2 << endl;
        }
        else{
            cout << mid1 << endl;
        }
    }
}

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

using namespace std;

int gcd(int a, int b) {
  return (b ? gcd(b, a%b) : a);
}

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  
  vector<int> left(N+1, 0), right(N+1,0);
  
  for (int i = 0; i < N; i++) {
    left[i+1] = gcd(left[i], A[i]);
  }
  for (int i = N-1; i >= 0; i--) {
    right[i] = gcd(right[i+1], A[i]);
  }
 
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int x = gcd(left[i], right[i+1]);
    if (ans < x){
      ans = x;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int n;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    vi v(2*n); F0R(i,2*n) cin >> v[i];
    sort(all(v));
    ll ans = 0;
    F0R(i,n) ans += v[2*i];
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

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

int main(){
  int k;
  cin >> k;
  string s;
  cin >> s;
  if(k < s.length()) {
    for(int i = 0; i < k; i++){
      cout << s[i];
    }
    cout << "..." << endl;
  }
  else cout << s << endl;
}

    

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, n, M, K;

vector<ll> v;

int main(){
    int a, b;
    cin >> a >>b;
    if((a == 1 && b == 2) or (a == 2 && b == 1) ) cout << 3;
    if((a == 1 && b == 3) or (a == 3 && b == 1) ) cout << 2;
    if((a == 3 && b == 2) or (a == 2 && b == 3) ) cout << 1;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' ';pr(b);}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' ';pr(b,c);}
template<C T,C T2,C T3,C T4>void pr(T a,T2 b,T3 c,T4 d){cout<<a<<' ';pr(b,c,d);}
template<C T>void PR(T a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,x;
  cin >> n >> x;
  if(x==1||x==n*2-1) {
    pr("No");
    return;
  }
  int m=n-1;
  n*=2;
  n--;
  int a[n];
  for(int i=0; i<n; i++) a[i]=i+1;
  if(x>m) {
    while(a[m]!=x) rotate(a+m,a+m+1,a+n);
  } else {
    while(a[m]!=x) rotate(a,a+m,a+m+1);
  }
  pr("Yes");
  rep(i,n) pr(a[i]);
}

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

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  vector<ll> a(n);
  bool pos = true;
  bool neg = true;
  ll sum = 0;
  ll dsum = 0;
  ll mi = LINF;
  ll ma = -LINF;
  vector<ll> ps,ns;
  rep(i,n){
      cin >> a[i];
      sum += a[i];
      dsum += abs(a[i]);
      mi = min(mi,a[i]);
      ma = max(ma,a[i]);
      if(a[i]<0)pos = false;
      if(a[i]>=0)neg = false;
      if(a[i]>=0)ps.pb(a[i]);
      else ns.pb(a[i]);
  }
  sort(all(ps));
  sort(all(ns));
  reverse(all(ns));
  if(n==2){
      cout << ma - mi << endl;
      cout << ma << " " << mi << endl;
      return 0;
  }
  if(pos){
      cout << sum - 2 * mi << endl;
      ll tmp = mi;
      FOR(i,1,n-1){
          cout << tmp << " " << ps[i] << endl;
          tmp -= ps[i];
      }
      cout << ps[n-1] << " " << tmp << endl;
      return 0;
  }
  if(neg){
      cout << -(sum - 2 * ma) << endl;
      ll tmp = ma;
      FOR(i,1,n){
          cout << tmp << " " << ns[i] << endl;
          tmp -= ns[i];
      }
      return 0;
  }
  cout << dsum << endl;
  rep(i,ps.size()-1){
      cout << ns[0] << " " << ps[i] << endl;;
      ns[0] -= ps[i];
  }
  rep(i,ns.size()){
      cout << ps[ps.size()-1] << " " << ns[i] << endl;
      ps[ps.size()-1] -= ns[i];
  }
  
}

Measured memory_bytes: 3572
#include <iostream>
#include <queue>
using namespace std;
typedef pair<int, int> P;

const int M = 2000;

const int dx1[4] = {1, 0, -1, 0};
const int dy1[4] = {0, 1, 0, -1};

int dx2[4], dy2[4];
char c[2002][2002];

int main()
{
    int h, w, d;
    cin >> h >> w >> d;
    for(int i = 0; i < M; i++){
        for(int j = 0; j < M; j++) c[i][j] = '.';
    }
    queue<P> que;
    if(d % 2 == 0){
        dx2[0] = d / 2;
        dx2[1] = -d / 2;
        dx2[2] = -d / 2;
        dx2[3] = d / 2;
        dy2[0] = d / 2;
        dy2[1] = d / 2;
        dy2[2] = -d / 2;
        dy2[3] = -d / 2;
        c[M / 2][M / 2 - 1] = 'R';
        c[M / 2][M / 2] = 'R';
        que.push(P(M / 2, M / 2 - 1));
        que.push(P(M / 2, M / 2));
    }
    else{
        dx2[0] = d / 2 + 1;
        dx2[1] = -d / 2;
        dx2[2] = -d / 2 - 1;
        dx2[3] = d / 2;
        dy2[0] = d / 2;
        dy2[1] = d / 2 + 1;
        dy2[2] = -d / 2;
        dy2[3] = -d / 2 - 1;
        c[M / 2][M / 2] = 'R';
        que.push(P(M / 2, M / 2));
    }
    while(que.size()){
        P p = que.front();
        que.pop();
        int x = p.first, y = p.second;
        for(int i = 0; i < 4; i++){
            int nx = x + dx2[i], ny = y + dy2[i];
            if(nx >= 0 && nx < M && ny >= 0 && ny < M && c[nx][ny] == '.'){
                if(c[x][y] == 'R'){
                    if(i % 2) c[nx][ny] = 'B';
                    else c[nx][ny] = 'G';
                }
                if(c[x][y] == 'B'){
                    if(i % 2) c[nx][ny] = 'R';
                    else c[nx][ny] = 'Y';
                }
                if(c[x][y] == 'G'){
                    if(i % 2) c[nx][ny] = 'Y';
                    else c[nx][ny] = 'R';
                }
                if(c[x][y] == 'Y'){
                    if(i % 2) c[nx][ny] = 'G';
                    else c[nx][ny] = 'B';
                }
                que.push(P(nx, ny));
            }
        }
    }
    while(que.size()) que.pop();
    for(int i = 0; i < M; i++){
        for(int j = 0; j < M; j++){
            if(c[i][j] != '.') que.push(P(i, j));
        }
    }
    while(que.size()){
        P p = que.front();
        que.pop();
        int x = p.first, y = p.second;
        for(int i = 0; i < 4; i++){
            int nx = x + dx1[i], ny = y + dy1[i];
            if(nx >= 0 && nx < M && ny >= 0 && ny < M && c[nx][ny] == '.'){
                c[nx][ny] = c[x][y];
                que.push(P(nx, ny));
            }
        }
    }
    for(int i = M / 2 - h / 2; i < M / 2 - h / 2 + h; i++){
        for(int j = M / 2 - w / 2; j < M / 2 - w / 2 + w; j++){
            cout << c[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 37124
L, R = list(map(int, input().split()))

if (R - L) >= 2019:
    print(0)
else:
    _min = 2019
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            buf = i*j % 2019
            if buf < _min:
                _min = buf
    print(_min)

Measured memory_bytes: 3060
a,b,c = map(int,input().split())
d = 0
l = a // (b+c)
k = a % (b+c)
if b == 0:
    print('0')
    
elif b + c >= a:
    if b < a:
        print(b)
    elif b > a:
        print(a)
    
elif b + c < a:
    if a % (b + c) == 0:
        print(int(l))
    elif a % (b + c) != 0:
        if b > k:
            print(int(l*b + k))
        elif b < k:
            print(int(l*b + b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
  ll ans = 1;
  while(n != 0){
    if(n&1) ans = ans*x % M;
    x = x*x % M;
    n = n >> 1;
  }
  return ans;
}

// 組み合わせ
ll comb(ll a, ll b){ 
  if(a == 0 && b == 0)return 1;
  if(a < b || a < 0)return 0;
  ll tmp = ifac[a-b]* ifac[b] % M;
  return tmp * fac[a] % M;
}

int main() {
  fac[0] = 1;
  ifac[0] = 1;
  for(ll i = 0; i<300000; i++){
    fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
    ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
  }

  ll n, k;
  cin >> n >> k;
  rrep(i, k) {
    ll ans = (comb(n-k+1, i) * comb(k-1, i-1)) % M;
    cout << ans << endl;
  }
}



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

int main(void) {
  int N = 0, alice = 0, bob = 0;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a.begin(),a.end());
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) alice += a[i];
    else bob += a[i];
  }
  cout << max(alice,bob) - min(alice,bob) << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

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

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }

LL N, K;

int main() {
    cin >> N >> K;
    LL tmp = N - (K * (N / K));
    LL prev = tmp;
    while (true) {
        tmp = (tmp < K) ? K - tmp : tmp - K;
        if (tmp > prev) {
            break;
        }
        prev = tmp;
    }
    cout << prev << endl;
    return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on("data", function(chunk) {
    var datas = chunk.trim().split("\n");
    for(var i = 0; i < datas.length; i++) {
        var ab = datas[i].trim().split(" ");
        var a = parseInt(ab[0]);
        var b = parseInt(ab[1]);
        console.log(a + b);
    }
});

Measured memory_bytes: 8876
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vd = vector<double>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)

void self_min(ll &a, ll b) {
	a = min (a,b);
}
template <class T>
void self_max(T &a, T b) {
	a = max(a,b);
}
void add(ll &a, ll b) {
	a = (a+b)% 1000000007;
}

int main() {
	ios::sync_with_stdio(false);

	ll n; cin >> n;
	vd w(n);
	FOR(i,0,n) cin >> w[i];

	vector<vd> dp(n+1,vd(n+1,0.0));
	dp[0][0] = 1.0;

	FOR(i,0,n) {
		FOR(j,0,i+1) {
			dp[i+1][j] += (1.0-w[i]) * dp[i][j];
			dp[i+1][j+1] += dp[i+1][j+1] + w[i] * dp[i][j];
		}
	}
	double sum = 0.0;
	FOR(i,0, (n+1) / 2) {
		sum += dp[n][i];
	}
	cout << fixed << setprecision(10) << 1 - sum << endl;

	return 0;
}


Measured memory_bytes: 70784
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let a = get!();
    let b = get!();
    let c = get!();
    
    use std::cmp::max;
    
    let ans = a * 10 + b + c;
    let ans = max(ans, a + b * 10 + c);
    let ans = max(ans, a + b + c * 10);
    
    println!("{}", ans);
}

Measured memory_bytes: 4352
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

#+++++

def main():
	n = int(input())
	nn = [[min(i,j,n-i-1,n-j-1) for j in range(n)] for i in range(n)]
	is_sit = [[True] * n for _ in range(n)]
	cc = [[0]*n for _ in range(n)]
	
	#b , c = tin()
	pl = list(map(int, input().split()))
	ans = 0
	for p in pl:
		x, y = (p-1) // n, (p-1) % n
		ans += nn[x][y]
		is_sit[x][y] = False
		q = [(x, y, nn[x][y])]
		while q:
			(x, y, v) = q.pop()
			if x >= 0 and nn[x-1][y]>v:
				nn[x-1][y] = v
				q.append((x-1, y, v+is_sit[x-1][y]))
			if x < n-1 and nn[x+1][y]>v:
				nn[x+1][y] = v
				q.append((x+1, y, v+is_sit[x+1][y]))		
			if y >= 0 and nn[x][y-1]>v:
				nn[x][y-1] = v
				q.append((x, y-1, v+is_sit[x][y-1]))
			if y < n-1 and nn[x][y+1]>v:
				nn[x][y+1] = v
				q.append((x, y+1, v+is_sit[x][y+1]))	
		
	print(ans)
	#s = input()	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)


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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    int X, Y, Z;

    ist >> X >> Y >> Z;

    /* ------- 計算 ------- */

    ost << Z << " " << X << " " << Y << endl;
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        char carr[]=br.readLine().toCharArray();
        if(carr[carr.length-1]=='2'||carr[carr.length-1]=='4'||carr[carr.length-1]=='5'||carr[carr.length-1]=='7'||carr[carr.length-1]=='9')
        pw.println("hon");
        else if(carr[carr.length-1]=='3')
        pw.println("bon");
        else
        pw.println("pon");
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 32480