akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  string s;
  ll n, k;

  cin >> n >> k;
  vll h(n);
  REP(i, n) {
    cin >> h[i];
  }

  ll total = 0;
  REP(i, n) {
    if (h[i] >= k) {
      total++;
    }
  }

  COUT(total);


}

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

/*

3 2
*/


Measured memory_bytes: 3976
#include<bits/stdc++.h>
#include <iostream> 
#include <string> 
using namespace std;
int main()
{
    
    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string u;
    cin>>u;
    if(u==s)
    {
        a=a-1;
    }
    else if(u==t)
    {
        b=b-1;
    }
    cout<<a<<" "<<b;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int a,b,c;cin>>a>>b>>c;
    int K;cin>>K;
    int limit = 0;
    for(int i=1;b<=a;i++){
        b *= 2;
        if(a<b) limit = i;
    }
    if(limit>K){
        cout << "No" << endl;
        return 0;
    }
    for(int i=limit+1;c<=b;i++){
        c *= 2;
        if(b<c) limit = i;
    }
    if(limit>K){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long k = sc.nextLong();
		long d = sc.nextLong();
		sc.close();
		
		x = Math.abs(x);
		
		long ans;
		if (k <= x / d) {
			ans = x - k * d;
		} else if ((k - x / d) % 2 == 1) {
			ans = Math.abs(x % d - d);
		} else {
			ans = x % d;
		}
		
		System.out.println(ans);
		
	}
}




Measured memory_bytes: 27012
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int H, W; cin >> H >> W;

    vector<string> a(H);
    rep(i, H) {
        cin >> a[i];
    }
    vector<int> cnt(27);
    rep(i, H) rep(j, W) {
        int ind = a[i][j] - 'a';
        cnt[ind] += 1;
    }

    priority_queue<int> pque;
    rep(i, cnt.size()) {
        if (cnt[i]) pque.emplace(cnt[i]);
    }

    int need_nb = 4;

    rep(i, H/2) {
        rep(j, W/2) {
            int nb = pque.top(); pque.pop();
            if (nb < 4) {
                cout << "No" << endl;
                return 0;
            }
            nb -= 4;
            pque.emplace(nb);
        }
    }

    need_nb = 4;
    if (H % 2 == 1) {
        rep(i, W/2) {
            int nb = pque.top(); pque.pop();
            if (nb < 2) {
                cout << "No" << endl;
                return 0;
            }
            nb -= 2;
            pque.emplace(nb);
        }
    }
    if (W % 2 == 1) {
        rep(i, H/2) {
            int nb = pque.top(); pque.pop();
            if (nb < 2) {
                cout << "No" << endl;
                return 0;
            }
            nb -= 2;
            pque.emplace(nb);
        }
    }
    /*
    if (H % 2 == 1 && W % 2 == 1) {
        int nb = pque.top(); pque.pop();
        if (nb < 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    */

    cout << "Yes" << endl;
    return 0;
}

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

temp=0
dia_break=0

for _ in range(N):
    x = input()    
    if x=="A":
        temp += 1
    elif x=='Un':
        temp -= 1
    if temp < 0:
        dia_break = 1

if dia_break==0 and temp==0:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 5592
#include<stdio.h>
#include<math.h>
int main()
{
	int i, r;
	double n[1000], sum=0, ave;
	
	while(1)
	{
		scanf("%d", &r);
		
		if(r == 0) break;
		
		for(i=0; i<r; i++)
		{
			scanf("%lf", &n[i]);
			sum += n[i]; 
		} 
		
		ave = sum / r; 
		sum=0; 
		
		for(i=0; i<r; i++)
		{
			sum += (n[i] - ave) * (n[i] - ave); 
		} 
		
		sum = sum / r;
		printf("%lf\n", sqrt(sum)); 
		sum=0; 
	} 
	return 0; 
} 

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n , ans;
int a[MAXX];
int b[MAXX];
int c[MAXX];

int main()
{
    _FastIO;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++){
        cin >> b[i];
        ans += b[i];
    }
    for(int i = 1; i <= n - 1; i++){
        cin >> c[i];
    }
    for(int i = 2; i <= n; i++){
        if(a[i] == (a[i - 1] + 1))
            ans += c[a[i - 1]];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n: usize = read();
    let a: Vec<u64> = (0..n).map(|_| read()).collect();

    let mut bits: Vec<Vec<u64>> = (0..61).map(|_| (0..2).map(|_| 0).collect()).collect();

    for b in &a {
        for i in 0..61 {
            let bit = (*b >> i) & 1;
            bits[i][bit as usize] += 1;
        }
    }

    let mut ret = 0;
    let mut shifted = 1;

    for i in 0..61 {
        let bit = (bits[i][0] * bits[i][1]) % MOD;
        let now_bit = (bit * shifted) % MOD;
        shifted = (shifted * 2) % MOD;
        ret = (ret + now_bit) % MOD;
    }

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

const MOD: u64 = 1_000_000_007;


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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var nm = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var p = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var par = new int[nm[0] + 1];
            for (int i = 0; i < par.Count(); i++) par[i] = i;
            for (int i = 0; i < nm[1]; i++) MakeEdge(ref par);

            int ans = 0;
            for (int i = 0; i < nm[0]; i++) if (FindRoot(par, p[i]) == FindRoot(par, p[p[i] - 1])) ans++;
            Console.WriteLine(ans);
        }

        static void MakeEdge(ref int[] par)
        {
            var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int v1 = inp.Max();
            int v2 = inp.Min();
            while (par[v2] != v2) v2 = par[v2];
            while (par[v1] != v1)
            {
                int temp = v1;
                v1 = par[v1];
                par[temp] = v2;
            }
            par[v1] = v2;
        }

        static int FindRoot(int[] par, int x)
        {
            while (par[x] != x) x = par[x];
            return x;
        }
    }
}

Measured memory_bytes: 26720
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = MAP()
A.sort()
print(A[N//2] - (A[N//2-1]))

Measured memory_bytes: 14144
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
static const int MAXN = 100000;
static const int MAX = 1000000007;

int main(){
    ll X, ans = 0, sum = 100;
    cin >> X;
    while(sum < X){
        ans++;
        sum += sum/100;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let mut d: Vec<usize> = sc.vec(n);
    d.sort();
    let a = d[n / 2 - 1];
    let b = d[n / 2];
    println!("{}", b - a);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

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


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

ll gcd(ll a, ll b)
{
	if (a < b) swap(a, b);
	return (a%b ? gcd(a%b, b) : b);
}

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

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	ll n, m;
	cin >> n >> m;
	vi a(n);
	REP(i, n) cin >> a[i];
	vector<ld> p(n);
	REP(i, n)
	{
		ld a; cin >> a;
		p[i] = a / 100.0;
	}
	vector<ll> cnt(1 << n);
	REP(i, 1 << n)
	{
		ll t = 1;
		bool f = false;
		REP(j, n)
		{
			if (!((i >> j) & 1)) continue;
			ll tmp = a[j] / gcd(t, a[j]);
			if (t > LLONG_MAX / tmp) f = true;
			else t *= tmp;
		}
		if (f) cnt[i] = 0;
		else cnt[i] = m / t;
	}

	REP(i, n)REP(j, 1 << n) if (j & 1 << i) cnt[j] -= cnt[j ^ 1 << i];

	ld ans = 0;
	REP(i, 1 << n)
	{
		ld exp = 1.0;
		REP(j, n)
		{
			if ((i >> j) & 1) exp *= p[j];
			else exp *= 1.0 - p[j];
		}
		ans += exp * (m - abs(cnt[i]));
	}
	cout << ans << endl;
	return 0;
}

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

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

  int index = partition(a, 0, n-1);

  for(int i=0; i<n; i++){
    if(i==index){
      cout << "[" << a[i] << "]";
    }else cout << a[i];
    if(i!=n-1) cout << " ";
  }
  cout << endl;

  return 0;
}

int partition(int* a, int p, int r){
  int x=a[r];
  int i=p-1;
  for(int j=p; j<r; j++){
    if(a[j]<=x){
      i++;
      int temp=a[i];
      a[i]=a[j];
      a[j]=temp;
    }
  }
  int temp=a[i+1];
  a[i+1]=a[r];
  a[r]=temp;
  return i+1;
}



Measured memory_bytes: 3384
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int c[300300];

int main()
{
    int n;
    scanf("%d", &n);
    vector<int> a;
    for (int i = 0; i < n; i++)
    {
        int x;
        scanf("%d", &x);
        a.push_back(x);
    }
    int l = 0, r = 0;
    int now = 0;
    long long ans = 0;
    while (l < n)
    {
        while (r < n && (now ^ a[r]) == now + a[r])
        {
            now ^= a[r++], ans++;
        }
        now ^= a[l++];
        ans += r - l;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1400
fun main (args:Array<String>) {
    val bankDeposit = readLine()!!.toLong()
    var upBankDeposit = 100L
    var yearsLater = 0
    while(upBankDeposit < bankDeposit){
        upBankDeposit += upBankDeposit * 1/100
        yearsLater++
    }
    print(yearsLater)

}


Measured memory_bytes: 34280
import heapq

X,Y,A,B,C = map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

a=p[0:X]+q[0:Y]
heapq.heapify(a)

#print(a)
#print(a[0])

flag=True
while flag:
  if len(r)==0:
    flag=False
  elif a[0]<r[0]:
    heapq.heappop(a)
    heapq.heappush(a,r[0])
    r.pop(0)
  else:
    flag=False
print(sum(a))

Measured memory_bytes: 23584
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int N, M, K, H, W, L, R, T;
string S;
signed main(){
  cin >> N;
  if(N==1) {cout << "Hello World" << endl; return 0;}
  int a, b; cin >> a >> b;
  cout << a+b << endl;
  return 0;
}


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

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <stack>
#include <unordered_map>
#include <utility>
#include <vector>

// Aliases
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;

using std::cout;
using std::cerr;
using std::cin;
using std::endl;
using std::string;
using std::vector;
using std::array;
template <class T>
constexpr T inf = std::numeric_limits<T>::max();
template <class T>
constexpr T neg_inf = -std::numeric_limits<T>::max();
template <class T>
constexpr T pi = static_cast<T>(3.141592653589793);

template <class T = i64>
vector<T> read_vector(const u64 n)
{
    vector<T> vec;
    vec.reserve(n);
    for (u64 i = 0; i < n; i++)
    {
        T v;
        cin >> v;
        vec.emplace_back(v);
    }

    return vec;
}

template <class T>
void print(const vector<T>& vec, const bool new_line = false)
{
    const u64 n = vec.size(); 
    if (new_line)
    {
        for (u64 i = 0; i < n; i++)
        {
            cout << vec[i];
            if (i != n - 1) { cout << '\n'; }
        }
    }
    else
    {
        for (u64 i = 0; i < n; i++)
        {
            cout << vec[i];
            if (i != n - 1) { cout << ' '; }
        }
    }

    cout << endl;
}

int main()
{
    u32 n, k;
    cin >> n >> k;
    vector<u32> vec = read_vector<u32>(n);

    auto cnt = std::count_if(vec.begin(), vec.end(), [k](auto v) { return v >= k; });

    cout << cnt << endl;

    return 0;
}


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

namespace AOJ_ICPC1 {
	class Program {
		static void Main(string[] args) {
			while (true) {
				int n = int.Parse(Console.ReadLine());
				if (n == 0) break;

				int[] s = new int[n];
				for (int i = 0; i < n; i++) s[i] = int.Parse(Console.ReadLine());
				Console.WriteLine(result(s).ToString());
			}
		}

		static int result(int[] s) {
			return (s.Sum() - s.Max() - s.Min()) / (s.Length - 2);
		}
	}
}

Measured memory_bytes: 20196
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C(I) cout<<(I)<<endl

ll n,m,a,b,c,x,y,z,aa[100010],ba[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc;
vector<ll> va,vb,vc;
set<int> sta;


int main(){
    cin>>n>>m;
    a=n;
    //va.push_back(a);
    while(a<=m){
        va.push_back(a);
        a*=2;
        
    }
    C(va.size());
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    ll ans=0;
    for(ll i=0;i<=n;i++){
        if(i>0) ans+=(i+n/i*i)*(n/i)/2;
    }
    cout<<ans;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,A,B,a,b,c; cin>>N>>A>>B;
  vector<vector<vector<ll>>> Z(N+1,vector<vector<ll>>(N*10+1,vector<ll>(N*10+1,4001)));
  Z[0][0][0]=0;
  for(int i=1; i<=N; i++){
    cin>>a>>b>>c;
    for(int j=0; j<=N*10; j++){
      for(int k=0; k<=N*10; k++){
        Z[i][j][k]=min(Z[i-1][j][k],Z[i][j][k]);
        if(j>=a && k>=b) Z[i][j][k]=min(Z[i-1][j-a][k-b]+c, Z[i][j][k]);
      }
    }
  }
  ll ans=4001;
  for(int i=1; i<=N; i++){
    for(int j=0; j<=N*10; j++){
      for(int k=0; k<=N*10; k++){
        if(j%A==0 && k%B==0 && j/A==k/B && j!=0 && k!=0) ans=min(ans,Z[i][j][k]);
      }
    }
  }
  if(ans==4001) ans=-1;
  cout<<ans<<endl;
}

Measured memory_bytes: 53504
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T[][] factor(T)(T n) {
    if (n == 1) return [[1, 1]];
    long[][] res;
    for (T i = 2; i * i <= n; i++) {
        if (n % i != 0) continue;
        int k = 0;
        while (n % i == 0) { n /= i; k++; }
        res ~= [i, k];
    }
    if (n > 1) res ~= [n, 1];
    return res;
}

long calc(long a, long b) {
    long g = gcd(a, b);
    if (g == 1) return 1;
    return factor!long(g).length + 1;
}

void main() {
    long a, b; scan(a, b);
    writeln(calc(a, b));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


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

int main() {
  while(1) {
    int n,m;
    cin >> n;
    if(n == 0) break;

    vector <int> sta[101];
    for(int i=1;i<=n;i++) {
      cin >> m;
      sta[i].resize(m);
      for(int j=0;j<m;j++) cin >> sta[i][j];
      sort(sta[i].begin(),sta[i].end());
    }

    int k;
    cin >> k;
    vector <int> ot;
    ot.resize(k);
    for(int i=0;i<k;i++) cin >> ot[i];
    sort(ot.begin(),ot.end());

    int ans = 0;
    for(int i=1;i<=n;i++) {
      int cnt = 0;
      for(int j=0;j<sta[i].size();j++){
	if(sta[i][j] == ot[cnt]) cnt++;
	if(cnt == k && ans != 0) {
	  ans = -1;
	  break;
	}
	if(cnt == k) {
	  ans = i;
	  break;
	}
      }
      if(ans == -1) break;
    }
    if(ans == 0) ans = -1;
    cout << ans <<endl;
  }

  return 0;
}
 

      

Measured memory_bytes: 1260
import java.io.*
import java.util.*

fun solve(a: Int, b: Int){
    val heights = (1..999).scanLeft(0){a,b -> a+b}.toList()
    println(heights[b-a-1] - b)
    return
}

fun <T, R> Iterable<T>.scanLeft(initial: R, operation: (acc: R, T) -> R): Sequence<R> {
    var last = initial
    return this.asSequence().map { last = operation(last, it); last }
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val a = sc.next().toInt()
    val b = sc.next().toInt()
    solve(a, b)
}



Measured memory_bytes: 31872
#include<bits/stdc++.h>
using namespace std;
#define INFTY 10000000000
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
#define rep(i,n) for (int i = 0; i < (n); ++i)
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;}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll , ll> P;
typedef pair<ll, ll> PL;
const ll INT_INF = 2147483646;
const ll ll_INF = 9223372036854775807;
ll mod = 1e9+7;

bool SecondCompare(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
       return a.second>b.second;
}


int gcd(int m, int n){
	if(n == 0){
		return m;
	}
	else{
		gcd(n,m%n);
	}
}
int n,x;
int xx[100010];

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

    for(int i = 0; i < n; i++){
        cin >> xx[i];
        xx[i] = max(xx[i]-x,x-xx[i]);
    }

    int mo;
    mo = gcd(xx[0],xx[1]);
    for(int i = 0; i < n; i++){
        if(xx[i]%mo != 0){
            mo = gcd(mo,xx[i]);
        }
    }

    cout << mo << endl;
}

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

int digits(ll n){
	int res = 0;
	while(n > 0){
		n /= 10;
		res++;
	}
	return res;
}

int compareDigits(ll a, ll b){
	int A = digits(a);
	int B = digits(b);
	return max(A, B);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	int ans = digits(n);
	for(ll i = 1; i*i <= n; ++i){
		if(n%i != 0) continue;
		chmin(ans, compareDigits(i, n/i));
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

inline int read(){
	char ch=getchar();int x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

int work(int x){
	int sum=0;
	for(int i=1;i<=x;i++){
		if(x%i==0) sum++;
	}
	if(sum==8) return 1;
	else return 0;
}

int main(){
	int n=read();
	if(n<105){
		cout<<0<<endl;
		return 0;
	}
	int ans=1;
	for(int i=107;i<=n;i+=2){
		ans+=work(i);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
    int n, l; cin >> n >> l;
    int ans = 0;
    for (int i = 0; i < n ; i++) {
        ans += l + i;
    }
    if (l > 0) {
        ans -= l;
    }
    else if(l + n <= 0){
        ans -= l + n - 1;
    }

    cout << ans << endl;

    return 0;
} 


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int x[10];
    for(int i=0; i<5; i++) scanf("%d", &x[i]);
    if(x[0]==0) printf("%d",1);
    if(x[1]==0) printf("%d", 2);
    if(x[2]==0) printf("%d", 3);
    if(x[3]==0) printf("%d", 4);
    if(x[4]==0) printf("%d", 5);
    return 0;
}    


Measured memory_bytes: 1728
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
char s[20];
long long ans, n;
bool pls[20];
long long calc() {
    long long t = 0, sum = 0;
    for (int i = 0; i < n - 1; ++i) {
        t = t * 10 + s[i];
        if (pls[i]) {
            sum += t;
            t = 0;
        }
    }
    t = t * 10 + s[n - 1];
    return t + sum;
}
void dfs(int k) {
    if (k == n - 1) {
        ans += calc();
        return;
    }
    pls[k] = false;
    dfs(k + 1);
    pls[k] = true;
    dfs(k + 1);
}
int main() {
    ios::sync_with_stdio(0);
    cin >> s;
    n = strlen(s);
    for (int i = 0; i < n; ++i) {
        s[i] -= '0';
    }
    dfs(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
// macro
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define MOD 1000000007
#define ll unsigned long long
#define FOR(i, m, n) for(ll i = m;i < n;i++)
 
using namespace std;
 
// Factorial
// need init
ll factorial_memo[5001];
ll factorial(ll n) {
  factorial_memo[0] = 1;
  if(factorial_memo[n] != -1) return factorial_memo[n];
  factorial_memo[n] = (factorial(n-1) * n) % MOD;
  return factorial_memo[n];
}
 
// Combination(nCr)
// need init
ll nCr_memo[5001][5001];
ll nCr(ll n, ll r) {
  if(r*2 > n) r = n-r;
  if(r == 1) return n;
  if(r == 0) return 1;
  if(nCr_memo[n][r] != -1) return nCr_memo[n][r];
  nCr_memo[n][r] = (nCr(n-1, r) + nCr(n-1, r-1)) % MOD;
  return nCr_memo[n][r];
}

// list of prime numbers
vector<int> primes;
void find_primes(int n) {
  if(n < 2) return;
  primes.push_back(2);
  FOR(i, 3, n+1) {
    bool isPrime = true;
    for(auto itr = primes.begin(); itr != primes.end(); ++itr) {
      int x = *itr;
      if(i % x == 0) {
        isPrime = false;
        break;
      }
      if(x*x > i) break;
    }
    if(isPrime) primes.push_back(i);
  }
}

void solve() {
  int N;
  cin >> N;
  find_primes(N);
  map<int, int> mp;
  for(int &x:primes) {
    mp[x] = 0;
  }
  FOR(i, 1, N+1) {
    int n = i;
    for(int &x:primes) {
      if(n < 2) break;
      while(true) {
        if(n % x == 0) {
          mp[x]++;
          n /= x;
        } else {
          break;
        }
      }
    }
  }
  ll ans = 1;
  for(pair<int, int> p:mp) {
    ll tmp = p.second + 1;
    ans = (ans * tmp) % MOD;
  }
  cout << ans << "\n";
}
 
int main() {
  // init
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_utility.hpp>
#include <utility>
#include <boost/foreach.hpp>
#include <cmath>

int price[1000 + 1];
int N, K;
long long int ans;

int main() {
  std::cin >> N >> K;
  for (int i = 1; i <= N; i++) {
    std::cin >> price[i];
  }

  std::sort(price + 1, price + 1 + N);

  for (int i = 1; i <= K; i++) {
    ans += price[i];
  }

  std::cout << ans << std::endl;

  return 0;
}

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

#define OUT(x) cout << (x) << endl;
#define ALL(v) v.begin(), v.end()
#define REP(i, n) for (int i=0; i<n; ++i)

int main() {
    int r; cin >> r;
    cout << r*r <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int A,B,C,K,ans;
int main () {
    ios_base::sync_with_stdio(false);
    cin>>A>>B>>C>>K;
    ans = 0;
    if(K <= A) {
        ans = K;
    } 
    else {
        if(K-A <= B) {
            ans = A;
        }
        else {
            ans = A-(K-A-B);
        }
    }    
    cout<<ans<<"\n";
    return 0;
}


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

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = long long;
using std::cout;
using std::cin;
using std::endl;
using Mint = Modint<long long, 1000000007>;

int n, m;
int as;
int main(){
	cin >> n >> m;
	for(int i = 0; i < m; ++i){
		int at;
		cin >> at;
		as += at;
	}
	if(n < as){
		cout << "-1" << endl;
	}else{
		cout << n - as << endl;
	}
}


Measured memory_bytes: 3636
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3")
#define rtn return
#define endl '\n'
#define F first
#define S second
#define mt make_tuple
#define pb push_back
#define int long long
#define value_at find_by_order
#define index_of order_of_key
#define fill(a, v) memset(a,v,sizeof(a))
#define copy(a, b) memcpy(b,a,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i, n) for(int i=0;i<(int)n;++i)
#define per(i, n) for(int i=(int)n-1;i>=0;--i)
#define rep1(i, n) for(int i=1;i<=(int)n;++i)
#define per1(i, n) for(int i=(int)n;i>=1;--i)
#define loop(i, begin, end) for(int i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

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

typedef string str;
typedef long double db;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<db> vdb;

template<class T, class V> void remin(T &a, V b) { a > b ? a = b : a = a; }
template<class T, class V> void remax(T &a, V b) { a < b ? a = b : a = a; }
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int INF = 1e18;
const db EPS = 1e-15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 7;

int n;
int a[N];
map<int, int> mp;

int f(int x) {
  rtn x * (x - 1) / 2;
}

int32_t main() {
  FAST_IO;
  cin >> n;
  rep(i, n) {
    cin >> a[i];
    mp[a[i]]++;
  }
  int ans = 0;
  for (auto i : mp) {
    ans += f(i.S);
  }
  rep(i, n) {
    int v = ans - f(mp[a[i]]) + f(mp[a[i]] - 1);
    cout << v << '\n';
  }
  rtn 0;
}


Measured memory_bytes: 12288
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y,ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        ll w=(p*p)%z;
        if(y%2==0)
         return w;
        else
        return (x*w)%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll a,b,c,d,m;
    cin>>a>>b>>c>>d;
    m=a*c;
    m=max(m,a*d);
    m=max(m,b*c);
    m=max(m,b*d);
    cout<<m;}
    
    
    
    

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

int main() {
    int n;
    cin >> n;
    unordered_map<long, int> counter;
    for (int i = 0; i < n; i++) {
        long a;
        cin >> a;
        counter[a]++;
    }

    long le = 0, se = 0;
    for (auto p : counter) {
        if (p.second < 2) {
            continue;
        }
        if (p.first > se) {
            if (p.first > le) {
                if (p.second >= 4) {
                    se = p.first;
                } else {
                    se = le;
                }
                le = p.first;
            } else {
                se = p.first;
            }
        }
    }
    cout << le * se << endl;
    return 0;
}


Measured memory_bytes: 4388
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var L = Sarray()[0];
            var N = 0;
            for (var i = 0; i < 20; ++i)
                if ((L & (1 << i)) != 0) N = i;
            var graph = Enumerable.Range(0, N).Select(_ => new List<(int to, int c)>()).ToArray();
            for (var i = 0; i < N; ++i)
            {
                graph[i].Add((i + 1, 0));
                graph[i].Add((i + 1, (int)Pow(2, i)));
            }
            --L;
            var b = (int)Pow(2, N) - 1;
            var nxt = L - b;
            var pre = L;
            for (var i = 0; i < 19; ++i)
                if ((nxt & (1 << i)) != 0)
                {
                    var c = pre - ((int)Pow(2, i) - 1);
                    graph[i].Add((N, (int)c));
                    pre = c - 1;
                }
            var m = graph.Sum(g => g.Count);
            WriteLine($"{N + 1} {m}");
            for (var i = 0; i < N; ++i)
            {
                foreach (var tc in graph[i])
                {
                    WriteLine($"{i + 1} {tc.to + 1} {tc.c}");
                }
            }
        }
    }
}

Measured memory_bytes: 28692
s = input().split()

x = int(s[0])
n = int(s[1])

s = {i for i in range(-1,102)}

p1 = input().split()

p = set()

for i in p1:
    p.add(int(i))

t = s - p

answer = 20000

for i in t:
    if (abs(x - int(i)) < abs(x - answer)) or (abs(x - int(i)) == abs(x - answer)) and i < answer:
        answer = int(i)

print(answer)

Measured memory_bytes: 9208
/*input
73	
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#define PI 			3.14159265358979323
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
#define N  100005
#define DEC(N)	cout << std::fixed; cout << setprecision(N);
void solve()
{
	long double x; 
	cin >> x;
	long double ans=2*PI*x;
	DEC(20);
	cout << ans << endl;
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 3800
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if a < b:
    r1 = a + v * t
    r2 = b + w * t
    if r1 >= r2:
        print('YES')
    else:
        print('NO')
else:
    r1 = a - v * t
    r2 = b - w * t
    if r1 <= r2:
        print('YES')
    else:
        print('NO')



Measured memory_bytes: 9180
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

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

  if(a>=3200) cout<<s<<endl;
  else cout<<"red"<<endl;
}



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

using namespace std;

int main(){

	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	sort(a, a + n);
	
	int b[a[n-1] - a[0] + 1] = {0};
	
	int j = 0, c = 0, e = 0;
	for(int i = 1; i < n; i++){
		c++;
		if(a[i - 1] != a[i]){
			b[j] = c;
			j += a[i] - a[i-1];
			e += a[i] - a[i-1];
			c = 0;
		}
	}
	b[j] = c + 1;
	
	if(e < 2){
		cout << n << endl;
	}
	
	else{
		
		int d = 1;
		for(int i = 2; i <= e; i++){
			d = max(d, b[i-2]+b[i-1]+b[i]);
		}
		
		cout << d << endl;
	}

}

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

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

    int count = 0;
    for(int i=0; i<s.length(); i++){
        if(s[i] == 'g') count += 1;
        if(s[i] == 'p') count -= 1;
    }
    cout << count / 2 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define f first
#define s second
#define mp make_pair
#define sz size()
#define ll long long
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
  	ll n;
  	cin >> n;
  	if(n % 2) cout << 0, exit(0);
  	n /= 2;
  ll ans = 0;
  while(n) ans += (n /= 5);
  	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int binarySearch(int A[], int n, int key) {
  int left = 0;
  int right = n;
  while (left < right) {
    int mid = (left + right) / 2;
    if (A[mid] == key) return 1;
    else if ( A[mid] < key) left = mid + 1;
    else right = mid;
  }
  return 0;
}

int main() {
  int i, n, A[100000+1], q, key, sum = 0;
  
  scanf("%d", &n);
  for ( i = 0; i < n; i++) scanf("%d", &A[i]);
  
  scanf("%d", &q);
  for( i = 0; i < q; i++) { 
    scanf("%d", &key);
    if ( binarySearch(A, n, key) ) sum++;
  }
  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 3140
#include <iostream>
using namespace std;
const int mod = 1000000007;
int N, K, dp[2009], ndp[2009];
int main() {
	cin >> N >> K; K--;
	for (int i = 0; i < N - K; i++) dp[i] = 1;
	for (int i = N - K + 1; i <= N; i++) {
		int sum = 0;
		for (int j = 0; j < i; j++) {
			sum += dp[j];
			if (sum > mod) sum -= mod;
		}
		for (int j = 0; j < i; j++) {
			ndp[j] = sum;
			if (j >= 1) sum -= dp[j - 1];
			if (sum < 0) sum += mod;
		}
		for (int j = 0; j < i; j++) dp[j] = ndp[j];
	}
	int ret = dp[0];
	for (int i = 0; i < N - K - 2; i++) ret = 2 * ret % mod;
	cout << ret << endl;
	return 0;
}

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

int main(){
    int n, k, x, y, over;
    cin >> n >> k >> x >> y;
    if(n <= k) cout << n * x << endl;
    else{
        over = n - k;
        cout << k * x + over * y << endl;
    }

    return 0;
}

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

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

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int clz(int x) { return 31 - __builtin_clz(x); }
int clz(ll x) { return 63 - __builtin_clzll(x); }
int ctz(int x) { return __builtin_ctz(x); }
int ctz(ll x) { return __builtin_ctzll(x); }

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

double dp[1001][1001];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string a,b;
	cin>>a>>b;
	int n=a.size(),m=b.size();
	rep(i,n+1)dp[i][0]=i;
	rep(j,m+1)dp[0][j]=j;
	range(i,1,n+1){
		range(j,1,m+1){
			dp[i][j]=min({dp[i-1][j]+1,dp[i][j-1]+1,dp[i-1][j-1]+(a[i-1]!=b[j-1])});
		}
	}
	cout<<dp[n][m]<<endl;
}


Measured memory_bytes: 11140
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MOD (ll)1000000007

char n[200002];

int main(void)
{
	scanf("%s", n + 1);
	int ans = 0;
	int ns = strlen(n + 1);
	for (int i = 1; i <= ns; i++)
		ans += n[i]- '0';
	printf(ans % 9 ? "No" : "Yes");
	return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
const int dofm[]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int m1,d1,m2,d2;

int main(){
    cin>>m1>>d1>>m2>>d2;
    if (m1!=2){
        if (d1==dofm[m1]) cout<<1;
        else cout<<0;
    }
    else{
        if (d1==28 || d1==29) cout<<1;
        else cout<<0;
    }
}


Measured memory_bytes: 256
n,a,b=map(int,input().split())

k=10**9+7
we=pow(2,n,k)

su=1
suu=1
for i in range(a):
  su=su*(i+1)%k
  suu=suu*(n-i)%k

df=suu * pow(su,k-2,k)%k

su=1
suu=1
for i in range(b):
  su=su*(i+1)%k
  suu=suu*(n-i)%k
  
df+=suu*pow(su,k-2,k)%k
we=we-df-1

print(we%k)
    

Measured memory_bytes: 3064
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if (i * 500 + j * 100 + k * 50) == x:
                ans += 1
print(ans)


Measured memory_bytes: 39536
#include<iostream>

using namespace std;

int main(void) {
	int a;
	int b;
	int c;
	int d;
	int times;
	int timee;
	int p;

	cin >> a >> b >> c >> d;
	if (a > c) {
		times = a;
	}
	else {
		times = c;
	}
	if (b > d) {
		timee = d;
	}
	else {
		timee = b;
	}
	p = timee - times;
	if (p < 0) {
		cout << "0" << endl;
	}
	else {
		cout << p << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256