akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
struct Matrix{ 
	int a[2][2] = {{0,0},{0,0}};
	Matrix operator *(const Matrix& other){
		Matrix product;
		for(int i=0;i<2;i++){
			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){
						product.a[i][k] =product.a[i][k] + (ll)a[i][j]*other.a[j][k];
				}
			}
		}
		return product;
	}
};
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 ll a,b,c,d;
	 cin>>a>>b>>c>>d;
	 ll ans = max({a*c,b*c,a*d,b*d});
	 cout<<ans<<'\n';
	 return 0;
}


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

int main(void) {
    int N,K;cin>>N>>K;
    set<int> se;
    for (int i = 1; i <= K; i++) {
        int d;cin>>d;
        for (int j = 1; j <= d; j++) {
            int a;cin>>a;
            se.insert(a);
        }
    }
    cout << N - se.size() << endl;
    return 0;
}

Measured memory_bytes: 3192
import static java.lang.System.*;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		out.println(x * y + " " + (x * 2 + y * 2));

	}

}


Measured memory_bytes: 26080
def prim(cost):
    sumcost = 0
    V = len(cost)
    mincost = [float('inf')] * V
    used = [False] * V
    mincost[0] = 0
    while True:
        j = -1
        for i in range(V):
            if not used[i] and (j == -1 or mincost[i] < mincost[j]):
                j = i
        if j == -1:
            break
        used[j] = True
        sumcost = sumcost + mincost[j]
        for i in range(V):
            if cost[i][j] == -1:
                continue
            mincost[i] = min(mincost[i], cost[j][i])
    return sumcost

n = int(raw_input())
A = [0] * n
for i in range(n):
    A[i] = map(int, raw_input().split())

result = prim(A)
print(result)

Measured memory_bytes: 6508
# include <bits/stdc++.h>
# define ll long long
# define all(x) x.begin(), x.end()
# define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
# define MOD 1000000007
														
using namespace std;

int main(){
	string s;
	cin>>s;
	int a[26]{0};
	for (char c:s){
		a[c-'a']++;
	}
	bool re=true;
	for (auto i:a){
		if (i%2) re=false;
	}
	cout<<((re)?"Yes":"No")<<'\n';
	return 0;
}

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

int main() {
    int N,i,r=0;
    cin >> N;
    vector<int> p(N);

    for(i=0; i<N; i++)
        cin >> p.at(i);
    sort(p.begin(), p.end());

    for(i=0; i<N-1; i++)
        r += p.at(i);
    r += p.at(N-1)/2;

    cout << r << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    char Sa[100],Sb[100],Sc[100];
    int i=0,j=0,k=0;
    char p='a';
    scanf("%s",Sa);
    scanf("%s",Sb);
    scanf("%s",Sc);
    while(1){
        switch(p){
            case 'a':{
                if(Sa[i]=='a')p='a';
                else if(Sa[i]=='b')p='b';
                else p='c';
                i++; break;
            }
            case 'b':{
                if(Sb[j]=='a')p='a';
                else if(Sb[j]=='b')p='b';
                else p='c';
                j++; break;
            }
            case 'c':{
                if(Sc[k]=='a')p='a';
                else if(Sc[k]=='b')p='b';
                else p='c';
                k++; break;
            }
        }
        if(p=='a'){
            if(Sa[i]=='\0'){
                printf("A");
                break;
            }
        }else if(p=='b'){
            if(Sb[j]=='\0'){
                printf("B");
                break;
            }
        }else{
            if(Sc[k]=='\0'){
                printf("C");
                break;
            }
        }
        
    }
    return 0;
}


Measured memory_bytes: 1644
(defun solve (k s)
  (concatenate 'string
               (subseq s 0 (1- k))
               (string (char-downcase (aref s (1- k))))
               (subseq s k (length s))))

(defun main ()
  (read)
  (let ((k (read))
        (s (read-line)))
    (format t "~A~%" (solve k s))))

(main)


Measured memory_bytes: 13156
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int n,k;
    cin>>n>>k;
    cout<<fixed<<setprecision(10);
     vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    int cur=0;
    for(int i=0;i<k;i++) cur+=a[i]+1;
    int ans=cur;
    for(int i=k;i<n;i++)
    {
        cur+=a[i]-a[i-k];
        ans=max(ans,cur);
    }
    cout<<(double)ans/2.0<<'\n';
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
using namespace std;
const int N=2010;
int n,m;
int h[N],sta[N];
bool mp[N][N];
char s[N][N];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i) scanf("%s",s[i]+1);
	for (int i=1;i<n;++i)
		for (int j=1;j<m;++j)
		mp[i][j]=(s[i][j]=='#')^(s[i][j+1]=='#')^(s[i+1][j]=='#')^(s[i+1][j+1]=='#')^1;
	int ans=max(n,m);
	for (int i=1;i<n;++i){
		for (int j=1;j<m;++j) h[j]=(h[j]+1)*mp[i][j];
		int top=0;
		for (int j=1;j<=m;++j){
			while (top&&h[sta[top]]>=h[j]){
				ans=max(ans,(h[sta[top]]+1)*(j-sta[top-1]));
				--top;
			}
			sta[++top]=j;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 8192
from math import sqrt, ceil


def main():
    N = int(input())
    lst = []
    for a in range(1, ceil(sqrt(N)) + 1)[::-1]:
        if N % a == 0:
            b = N // a
            lst.append(a + b - 2)

    print(min(lst))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define	PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vll vector<ll>
#define vbl vector<bool>
#define vpll vector<pll>
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(),x.end()
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define mod 1000000007
#define INF 1000000000000000
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set_pll;
#define ook order_of_key
#define fbo find_by_order
/*  
	Query 1 - order_of_key(k) : Number of items strictly smaller than k.
	Query 2 - find_by_order(k) : K-th element in the set (counting from zero).
	less<ll> means Query 1 will return numbers strictly less than k.
	greater<ll> means Query 1 will return numbers strictly greater than k.
*/
ll powmod(ll x, ll n){
	ll res = 1;
	while(n){
		if(n & 1){
			res *= x;
			res %= mod;
		}
		x *= x;
		x %= mod;
		n >>= 1;
	}
	return res;
}
ll invmod(ll a){
	return powmod(a, mod - 2);
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin >> n;
	vector<int> p(n);
	iota(all(p), 1);
	vector<int> a(n), b(n);
	for(auto &i : a){
		cin >> i;
	}
	for(auto &i : b){
		cin >> i;
	}
	int l = -1, r = -1;
	ll i = 1;
	do{
		if(a == p){
			l = i;
		}
		if(b == p){
			r = i;
		}
		i++;
	}while(next_permutation(all(p)));
	cout << abs(l - r);
}

Measured memory_bytes: 256
#include<cstdio>
int main()
{
	int n;
	scanf("%d",&n);
	if(n>=100){
		n%=100;
		n%=10;
	}
	if(n>=10) n%=10;
	
	if(n==0||n==1||n==6||n==8) printf("pon\n");
	else if(n==3) printf("bon\n");
	else printf("hon\n");
	return 0;
}


Measured memory_bytes: 1608
<?php
fscanf(STDIN, "%d %d %d", $a, $b, $c);
$count = 0;
for ($i=1;$i<=$b;$i++) {
    $number = $i * $c;
    if ($a<=$number && $number<=$b){
        $count++;
    }
}
echo $count;
?>


Measured memory_bytes: 15984
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)


N, K = list(map(int, input().split()))
a = list(map(int, input().split()))

def check(x):
    sum_cut = 0
    for i in range(N):
        sum_cut += math.ceil(a[i]/x) - 1
    if sum_cut <= K:
        return True
    else:
        return False

M = 10**9 + 1
m = 1

x = (m+M) // 2

while True:
    y = x
    if check(x):
        M = x
        x = (m + x) // 2
    else:
        m = x
        x = (x + M) // 2

    if x == y:
        if check(x):
            print(x)
            sys.exit()
        else:
            print(x+1)
            sys.exit()



Measured memory_bytes: 103960
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


template<std::size_t T>
class ncr_t {
  static_assert(T <= 67, "T must be less than or equal to 67");
    
public:
  ncr_t() {
    memo_ = std::unique_ptr<std::unique_ptr<long long[]>[]>(new std::unique_ptr<long long[]>[T]);

    for (int i = 0; i < T; i ++) {
      memo_[i] = std::unique_ptr<long long[]>(new long long[T]);

      memo_[i][0] = memo_[i][i] = 1;
    }

    for (int i = 1; i < T; i ++)
      for (int j = 1; j < i; j ++)
        memo_[i][j] = memo_[i - 1][j - 1] + memo_[i - 1][j];
  };

public:
  long long operator()(int n, int r) const {
    assert(n < T);
    assert(r <= n);

    return memo_[n][r];
  };

private:
  std::unique_ptr<std::unique_ptr<long long[]>[]> memo_;
};


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(9);
  std::cerr << std::fixed << std::setprecision(6);

  int N, A, B;

  long long v[55];

  std::cin >> N >> A >> B;

  for (int i = 0; i < N; i ++)
    std::cin >> v[i];

  std::sort(v, v + N, std::greater<long long>());

  std::vector<std::pair<long long, int>> a;

  long long sp = 0, np = 1;

  long long s = 0;
  
  for (int i = 1; i <= N; i ++) {
    s += v[i - 1];

    if (A <= i && i <= B) {
      double m = 1. * s / i;

      a.emplace_back(s, i);

      if (s * np > sp * i) {
        sp = s;
        np = i;
      }
    }
  }

  std::cout << 1. * sp / np << std::endl;

  long long C = 0;

  ncr_t<67> ncr;

  for (const auto& pair : a) {
    long long s = pair.first, n = pair.second;

    if (s * np == sp * n) {
      long long target = v[n - 1];
      
      int c1 = std::count(v, v + N, target), c2 = std::count(v, v + n, target);

      C += ncr(c1, c2);
    }
  }

  std::cout << C << std::endl;

  return 0;
}


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

const int MOD = 998244353;

int K;
vector<int> ones;
int dp[305][305][305];

int f(int pos, int ops, int cnt) {
  if (ops > K || cnt < 0) return 0;
  if (pos < 0) return cnt == 0;
  int &res = dp[pos][ops][cnt];
  if (res != -1) return res;
  res = 0;
  for (int i = 0; i <= ones[pos]; i++) {
    res += f(pos - 1, ops + i, cnt + i);
    if (res >= MOD) res -= MOD;
  }
  for (int i = 1; i <= cnt; i++) {
    res += f(pos - 1, ops, cnt - i);
    if (res >= MOD) res -= MOD;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  memset(dp, -1, sizeof(dp));

  string S;
  cin >> S >> K;
  ones.push_back(0);
  for (auto i : S) {
    if (i == '0') {
      ones.push_back(0);
    } else {
      ones.back()++;
    }
  }
  cout << f(int(ones.size()) - 1, 0, 0) << "\n";
  return 0;
}


Measured memory_bytes: 114480
#include <bits/stdc++.h>
typedef unsigned long long ull;
typedef long long ll;
#define __TRUE "Yes"
#define __FALSE "No"
#define cout(x) cout << (x) << endl
#define MAX 100001
using namespace std;

int main() {
  ll N;
  cin >> N;
  vector<ll> t(N+1),x(N+1),y(N+1);
  t[0]=0,x[0]=0,y[0]=0;
  for(int i=1;i<=N;i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  bool flag=true;
  for(int i=1;i<=N;i++) {
    //距離的に間に合わない
    if( (t[i]-t[i-1])<(llabs(x[i]-x[i-1]) + llabs(y[i]-y[i-1]))) {
      flag=false;
      break;
    }
    //距離的には間に合うが、偶奇が異なる
    if( (t[i]-t[i-1])%2 != (llabs(x[i]-x[i-1]) + llabs(y[i]-y[i-1])) %2 ) {
      flag=false;
      break;
    }
  }
  if(flag) cout << __TRUE << endl;
  else cout << __FALSE << endl;
}

Measured memory_bytes: 2560
/*
    to amy
*/

#include <bits/stdc++.h>
#define MAX 100010
#define pb push_back
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,x,l,d,ans=0;
    while(cin>>n>>x){
        d = 0;ans=1;
        for(int i=0;i<n;i++){
            cin>>l;
            d+=l;
            if(d<=x)ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
<?php 

 
fscanf(STDIN, "%s", $input);

$arr1 = str_split($input);
$flag = true;

foreach ($arr1 as $key =>$val){
	
  //echo $key."/".$val;
  
  $num = $key+1;
  
  if($num%2==0) {
	//偶数
    if($val=="R"){
    	$flag = false;
    }
  }else{
  	//奇数
    if($val=="L"){
    	$flag = false;
    }
    
  }
  
}

if($flag){
  	echo "Yes";
  }else{
  	echo "No";
  }

?>

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define MIN(x) *min_element(all(x))
#define MAX(x) *max_element(all(x))
#define in(x) cin >> x
#define co(x) cout << x
#define el  cout << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


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

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>

using namespace std;

int main(){
    int N, Q;
    cin >> N >> Q;

    vector<vector<int> > edge(N);
    vector<int> value(N,0);
    vector<int> total(N);

    //cout << "NQ " << N << Q << endl;
    for(int i=0; i < N-1; ++i){
        int a, b;
        cin >> a >> b;
        //cout << "ab " << a << " " << b << endl;
        edge[a-1].push_back(b-1);
        edge[b-1].push_back(a-1);
    }

    for(int i=0; i < Q; ++i){
        int p, x;
        cin >> p >> x;
        value[p-1] += x;
        //cout << "out " << p << " " << x << endl;
    }

    /*for(int i=0; i < N; ++i){
        cout << " " << value[i] << endl;
    }*/

    deque<pair<int, int> > dq;
    pair<int, int> x;
    x.first = 0; x.second = -1;
    dq.push_back(x);
    while (!(dq.empty())){
        pair<int, int> st = dq[0];
        dq.pop_front();
        int node = st.first, parent = st.second;
        vector<int> children = edge[node];
        int l = children.size();
        for(int i=0; i < l; ++i){
            int child = children[i];
            if(child == parent) continue;
            //cout << "add " << child << " " << node << endl;
            value[child] += value[node];
            x.first = child; x.second = node;
            dq.push_back(x);
            //cout << "i " << i << endl;
        }
    }
    bool not_first = false;
    for(int i=0; i < N; ++i){
        if(not_first) cout << " ";
        else not_first = true;
        cout << value[i];
    }
    cout << endl;
}

Measured memory_bytes: 17124
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    vector<pair<ll, ll>> stroke;
    Rep (i, N) {
        cin >> A[i] >> B[i];
        stroke.push_back(make_pair(A[i] + B[i], i));
    }

    sort(stroke.begin(), stroke.end());
    reverse(stroke.begin(), stroke.end());

    ll score = 0;
    Rep (i, N) {
        auto target = stroke[i].second;
        if (i%2 == 0) {
            score += A[target];
        } else {
            score -= B[target];
        }
    }

    cout << score << endl;
}

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

int main(void) {
    int r[10000] = {2}, n;
	for (int i = 2; i <= 10000; ++i) r[i-1] = r[i-2]+i;

	while (cin >> n) {
	    cout << r[n-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#include <queue>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
	int n, total = 0;
	cin >> n;
	vector<int> a(n);
	rep(i, 0, n) {
		cin >> a[i];
		total += a[i];
	}
	int num = round((double)total / n);
	int ans = 0;
	rep(i, 0, n) {
		ans += (a[i] - num)*(a[i] - num);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
rectangle = 0
parallelogram = 0

while True:
    try:
        a,b,d = (int(x) for x in input().split(","))
        if d * d == (a * a) + (b * b):
            rectangle += 1
        elif a == b:
            parallelogram += 1
    except EOFError:
        break
print(rectangle)
print(parallelogram)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
ll ans = 1, v[10000005];
int n, p[10000005];
int main(){
	scanf("%d", &n);
	for(int i=1; i<=n; i++) v[i] = p[i] = i; 
	for(int t=2; t<=n; t++){
		if(p[t] != 1){
			ans += 2 * t;
			for(int s=t*2; s<=n; s+=t){
				for(ll vi = v[s]; p[s] % t == 0; p[s] /= t, v[s] += vi);
			}
		}else ans += v[t];
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 121000
#define _USE_MATH_DEFINES
  
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>
#include <vector>
#include <string>
#include <queue>
  
using namespace std;

void solution() {
    int n;
    cin >> n;
    vector <int> v(n);
    int xr = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &v[i]);
        xr ^= v[i];
    }
    for (int i = 0; i < n; i++) {
        printf("%d ", v[i] ^ xr);
    }
    cout << endl;
}
  
/*-------------------*/
      
int main()
{
#ifdef Files
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    /*Test*/
    //freopen("input.txt", "w", stdout);
      
    double OcZ2X = clock();
#else
    //freopen("joke.in", "r", stdin);
    //freopen("joke.out", "w", stdout);
#endif
      
/*
　　     　 　          ∧_,,∧　　　
    　            ♪　  (・ω・)　♪
               ＿＿＿＿○＿＿つヾ＿＿＿＿＿
             /δ⊆・⊇ 。/†: :† /δ ⊆・⊇｡ /|
            |￣￣￣￣￣￣￣￣￣￣￣￣￣ | |
            |　　　*/solution();/* 　　| |
            |　　　　　　　　　　　　　 |
*/
       
#ifdef Time
double P2HxQ = clock();
printf("\n*** Total time = %.3f sec ***\n", (P2HxQ - OcZ2X) / CLOCKS_PER_SEC);
#endif
}

Measured memory_bytes: 4044
N = int(input())
AB = []
CD = []
for _ in range(N):
    ab = list(map(int, input().split()))
    ab.append(True)
    AB.append(ab)
for _ in range(N):
    cd = list(map(int, input().split()))
    cd.append(True)
    CD.append(cd)
AB.sort(key=lambda x: x[1], reverse=True)
CD.sort(key=lambda x: x[0])
ans = 0

for i in range(N):
    for j in range(N):
        if AB[j][2] and CD[i][2]:
            if AB[j][0] < CD[i][0]:
                if AB[j][1] < CD[i][1]:
                    ans += 1
                    AB[j][2] = False
                    CD[i][2] = False
                    break

print(ans)


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

string s, t, u;
int a, b;

int main() {
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;

  if (s == u) {
    printf("%d %d", a - 1, b);
  } else
  {
    printf("%d %d", a, b - 1);
  }

  return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
s = input()
nums = [str(i) for i in range(10)]
if s[a] == "-":
    while True:
        for i in range(len(s)):
            if i == a:
                continue
            if not(s[i] in nums):
                print("No")
                quit()
        print("Yes")
        quit()
else:
    print("No")


Measured memory_bytes: 3060
import java.util.*;

class Main {
	public static void main(String args[]) {
		
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int l = sc.nextInt();
		
		PriorityQueue<String> list = new PriorityQueue<>();
		
		for (int i = 0; i < n; i++) list.add(sc.next());
		for (int i = 0; i < n; i++) System.out.print(list.poll());
	}
}

Measured memory_bytes: 23380
g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
 
x, y = map(int, input().split())
 
if (x in g1 and y in g1) or (x in g2 and y in g2):
  print("Yes")
else:
  print("No")
 

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

using namespace std;
typedef long long ll;
ll sum;
bool dp[5005][5005];
int N,K;
int a[5005];
int main() {
  cin >> N >> K;
  for(int i = 0; i < N; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if(sum < K) {
    cout << N <<endl; return 0;
  }
  sort(a,a+N,greater<int>());

  int l = 0;
  int r = N+1;
 
  while(r - l > 1) {
    for(int i = 0; i <= N; i++) fill(dp[i],dp[i]+N+1,false);
    int mid = (l+r) / 2;
    if(a[mid] > K) {
      l = mid;
	continue;
    }
  
    int tmp = a[mid];
    a[mid] = 0;
    dp[0][0] = true;
    for(int i = 0; i < N; i++) {
      for(int j = K-1; j >= 0; j--) {
	dp[i+1][j] = dp[i][j];
	if(dp[i][j] && j + a[i] < 5000) {
	  dp[i+1][j+a[i]] = dp[i][j];
	}
      }
    }
    a[mid] = tmp;
    bool there = false;
    for(int i = K - tmp; i < K; i++) {
      if(dp[N][i]) {
	there = true;
	break;
      }
    }
    if(there) l = mid;
    else r = mid;
    //cout <<r<<endl;
  }

  cout << N - r <<endl;
}
  


Measured memory_bytes: 24704
#include <iostream>
#include<vector>
using namespace std;
int main(){
    int N;
    vector<int>p(55);
    int ans=0;

    cin>>N;
    for(int i=0;i<N;++i){
        cin>>p[i];
    }
    for(int i=0;i<N;++i){
        if(p[i]==i+1)continue;
        else ans++;
    }
    
    if(ans<=2)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}

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

#define endl '\n'

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

    long long n, k, ans=0; cin >> n >> k;
    long long ac[n+1]; ac[0] = 0;
    map<long long, long long> freq;
    freq[0] = 1;
    for (int i=1; i<=n; i++){
        if (i >= k) freq[(ac[i-k] - i + k)%k]--;
        cin >> ac[i];
        if (k == 1 && ac[i]%k == 1) ans++;
        ac[i] += ac[i-1];
        ans += freq[(ac[i] - i)%k]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 14336
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long k = sc.nextLong();
    long ans = (n % k);
    ans = Math.min(ans, k - ans);
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int MAX_N = 200000;
int Par[MAX_N],Rank[MAX_N] = {};
int N;
void init(){
  int i;
  for(i=0;i<N;i++){
    Par[i] = i;
  }
}
int find(int x){//根元探し
  if(Par[x] == x) return x;
  else{
    Par[x] = find(Par[x]);
    return Par[x];
  }
}
bool unite(int x,int y){//結合
  x = find(x);y = find(y);
  if(x == y) return false;//すでに同じ木ならばfalse
  if(Rank[x] < Rank[y]) swap(x,y);
  Par[y] = x;
  if(Rank[x] == Rank[y]) Rank[x]++;
  return true;
}
bool same(int x,int y){//同じ木に含まれているか
  return find(x) == find(y);
}
int main(){
  int Q,i,t,u,v;scanf("%d%d",&N,&Q);
  init();
  for(i=0;i<Q;i++){
    scanf("%d%d%d",&t,&u,&v);
    if(t == 0) unite(u,v);
    else printf(same(u,v) ? "1\n":"0\n");
  }
}

Measured memory_bytes: 5200
#include <bits/stdc++.h>
const double PI=acos(-1);
using namespace std;
#define ll long long
#define ull unsigned long long
#define ul unsigned long
#define MOD 1000000007

long findmin(long a,long b) {
    return a<b?a:b;
}
long findmax(long a,long b) {
    return a>b?a:b;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long n,d;
    cin>>n>>d;
    long x,y,count=0;
    while(n--) {
		cin>>x>>y;
		if(sqrt(x*x + y*y)<=d) {
			count++;
		}
	}
	cout<<count<<"\n";
    cout.flush();
	return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <typeinfo>
    
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(b-a == c-b) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int r, c;
    cin >> r >> c;
    vector<vector<int>> a(r + 1, vector<int>(c + 1, 0));
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            cin >> a[i][j];
            a[i][c] += a[i][j];
            a[r][j] += a[i][j];
            a[r][c] += a[i][j];
        }
    }
    for (int i = 0; i <= r; i++)
        printv(a[i]);
}



Measured memory_bytes: 3264
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 3e5;
int n, m, l[N], r[N], a[N];
vector<int> L[N], R[N];
ll ans;
ll f[N * 4], lazy[N * 4], mx[N * 4];
void pushdown(int k) {
	if (lazy[k]) {
		lazy[k << 1] += lazy[k];
		mx[k << 1] += lazy[k];
		lazy[k << 1 | 1] += lazy[k];
		mx[k << 1 | 1] += lazy[k];
		lazy[k] = 0;
	}
}
void Ins(int k, int l, int r, int p, ll v) {
	if (l != r) pushdown(k);
	if (l == r) {
		mx[k] = v;
		return;
	}
	int mid = l + r >> 1;
	if (p <= mid)
		Ins(k << 1, l, mid, p, v);
	else 
		Ins(k << 1 | 1, mid + 1, r, p, v);
	mx[k] = max(mx[k << 1], mx[k << 1 | 1]);
}
void Add(int k, int l, int r, int p, int q, ll v) {// cout << k << ",";
	if (l != r) pushdown(k);
	if (l > q || r < p) return;
	if (r <= q && l >= p) {
		lazy[k] = v;
		mx[k] += v;
		return;
	}
	int mid = l + r >> 1;
	Add(k << 1, l, mid, p, q, v);
	Add(k << 1 | 1, mid + 1, r, p, q, v);
	mx[k] = max(mx[k << 1], mx[k << 1 | 1]);
}
ll Query(int k, int l, int r, int p, int q) {
	if (l != r) pushdown(k);
	if (l > q || r < p) return -1e18;
	if (r <= q && l >= p) return mx[k];
	int mid = l + r >> 1;
	return max(Query(k << 1, l, mid, p, q), Query(k << 1 | 1, mid + 1, r, p, q));
}
int main() {
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		scanf("%d %d %d", l + i, r + i, a + i);
		L[l[i]].push_back(i);
		R[r[i] + 1].push_back(i);
	}
	Ins(1, 0, n, 0, 0);
	for (int i = 1; i <= n; ++i) {
		for (int j: L[i]) Add(1, 0, n, 0, l[j] - 1, a[j]);
		for (int j: R[i]) Add(1, 0, n, 0, l[j] - 1, -a[j]);
		//cout << i << ":" << endl;
		//for (int j = 0; j < i; ++j) cout << Query(1, 0, n, j, j) << "/"; cout << endl;
		ll tmp = Query(1, 0, n, 0, i - 1);
		Ins(1, 0, n, i, tmp);
		ans = max(ans, tmp);
		//cout << tmp << "/";
	}
	cout << ans;
}



Measured memory_bytes: 43776
import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		int L=sc.nextInt();
		int R=sc.nextInt();
		
		
		int t=R/2019;
		
		if(t*2019>=L) {
			p(0);
		}else {
			int ans=1000000009;
			
			for(int i=L;i<R;i++) {
				for(int g=i+1;g<=R;g++) {
					int s=((i%2019)*(g%2019))%2019;
					
					ans=Math.min(ans, s);
				}
				
			}
			
			
			p(ans);
			
			
			
		}
		
		
		
	}
	

	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 23252
module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";var r=n(1),i=new(n(2))(r.readFileSync("/dev/stdin","utf8").trim().split(/\s+/g));n(4)(i)},function(t,e){t.exports=require("fs")},function(t,e,n){"use strict";var r=n(3);t.exports=class{constructor(t){this.inp=new r(t)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,n){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,n){"use strict";t.exports=function(t){for(var e=t.in(),n=t.in(),r=t.in(),i=t.in(),o=Math.min(i,e-i),s=Math.min(r,n-r),u=new Array(e),c=0;c<e;c++){var f="",a=s;if(c<o)for(var l=0;l<n;l++)f+=a>0?"1":"0",a--;else for(var d=0;d<n;d++)f+=a>0?"0":"1",a--;u[c]=f}console.log(u.join("\n"))}}]);

Measured memory_bytes: 69324
#include <cstdio>
int n,m;
int main() {
    scanf ("%d %d",&n,&m);
    if (n <= 0 && m >= 0) printf("Zero");
    if (n > 0) printf("Positive");
    if (m < 0){
    	if ((n - m) % 2 == 0) printf("Negative");
    	else printf("Positive");
	}
}

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
	long N, A, B;
	char S[100001];
	scanf("%ld %ld %ld", &N, &A, &B);
	scanf("%s", S);
	
	int i, flag[100000] = {}, total = 0, domestic = 0, abroad = 0;
	for (i = 0; i < N; i++) {
		if (S[i] == 'a') {
			if (total < A + B) {
				flag[i] = 1;
				total++;
				domestic++;
			}
		} else if (S[i] == 'b') {
			abroad++;
			if (total < A + B && abroad <= B) {
				flag[i] = 1;
				total++;
			}
		}
	}
	
	for (i = 0; i < N; i++) {
		if (flag[i] == 1) printf("Yes\n");
		else printf("No\n");
	}
	fflush(stdout);
	return 0;
}

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

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

  int sharps = 0;
  string s;
  rep(i,0,H-1) {
    cin >> s;
    for (char c : s)
      if (c == '#') sharps++;
  }

  if (sharps == H + W - 1)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
  return 0;
}


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

int main() {
  string S,T;
  int i,answer=0,N,K;
  
  cin >> N >> K ;
  
  int *h = new int[N];

  for ( i = 0; i < N; i++)
  {
    cin >> h[i];
    if(h[i]>=K)
    answer++;
  }

  cout << answer << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	while (b) {
		int r = a % b; a = b; b = r;
	}
	return a;
}

void solve() {
	//init();

	int n; cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	sort(a.begin(), a.end());
	ll ans = 1;
	rep(i, n) {
		ll g = gcd(i, a[i]);
		ans = ans * g%mod;
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(5);
	//while (cin >> n,n)solve();
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 640
fun main(args : Array<String>) {
    val s = readLine()!!
    val key = "keyence"

    if (s.startsWith(key) || s.endsWith(key)) {
        println("YES")
        return
    }

    for (i in 1 until key.length) {
        val key1 = key.take(i)
        val key2 = key.takeLast(key.length-i)

        if (s.startsWith(key1) && s.endsWith(key2)) {
            println("YES")
            return
        }
    }

    println("NO")
}

Measured memory_bytes: 33776
/* */

#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;

#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
#else
	#define errp(...)
#endif
#define dbg(x) errp(" %s = %s\n", #x, to_string(x).data())
/* ==================== */ 
int main() {
	int a1, a2, a3;
	scanf("%d%d%d", &a1, &a2, &a3);
	if (a1 + a2 + a3 >= 22) printf("bust\n");
	else printf("win\n");
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using namespace std;

void QuickSort(int *array, int left, int right)
{
	int pivot, i, j, temp;
	i = left;
	j = right;
	pivot = *(array + (left + (right - left)));

	while (1)
	{
		while (*(array + i) > pivot)
		{
			i++;
		}
		while (pivot > *(array + j))
		{
			j--;
		}
		if (j <= i)break;

		//swap
		temp = *(array + i);
		*(array + i) = *(array + j);
		*(array + j) = temp;

		j--; i++;
	}
	if (left < i - 1)
	{
		QuickSort(array, left, i - 1);
	}
	if (j + 1 < right)
	{
		QuickSort(array, j + 1, right);
	}
}


int main()
{
	int tasks[3];
	int cost = 0;
	int min = 101;
	cin >> tasks[0] >> tasks[1] >> tasks[2];

	QuickSort(tasks, 0, 2);

	for (int i = 2; i > 0; i--)
	{
		cost += abs(tasks[i] - tasks[i - 1]);
	}

	cout << cost << endl;

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

n = int(raw_input().split()[0])
a1 = [int(i) for i in raw_input().split()]
a2 = [int(i) for i in raw_input().split()]

maxS = 0
for i in range(1, n + 2):
    s = sum(a1[:i]) + sum(a2[i - 1:])
    # print i, a1[:i], a2[i - 1:],
    if s > maxS:
        # print '!!',
        maxS = s
    # print
    
sys.stdout.write('%d\n' % maxS)
sys.stdout.flush()


Measured memory_bytes: 2692
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;
#define INF 10000000
int mini = INF;

void BFS(int num,int *a,int time,bool used[5]){
	if(num == 5){
		if(mini > time){
			mini = time;
		}
		return;
	}
	int time1;
	rep(i,0,5){
		if(!used[i]){
			used[i] = true;
			time1 = time + a[i];
			while(num!=4 && time1 % 10 != 0){
				time1++;
			}
			BFS(num+1,a,time1,used);
			used[i] = false;	
		}
	}
}

int main(){
	int a[5];
	int time=0;
	bool used[5];

	rep(i,0,5){
		cin >> a[i];
		used[i] = false;
	}
	BFS(0,a,time,used);
	cout << mini << endl;
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int ta = (c+b-1)/b;
    int tb = (a+d-1)/d;
    if(ta<=tb)cout<<"Yes"<<endl;
    else      cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3636
# AOJ 0100 Sale Result

while line = gets
  n_data = line.to_i
  break if n_data.zero?

  sale = Hash.new(0)
  n_data.times do
    i, p, q = gets.split.map {|v| v.to_i}
    sale[i] += p * q
  end

  good_workers = sale.select {|k, v| v >= 1000000}.map {|k, v| k}

  if good_workers.empty?
    puts "NA"
  else
    good_workers.each {|i| puts i}
  end
end

Measured memory_bytes: 6112
#168A
#∴(Therefore)

n=int(input())
read_hon=[2,4,5,7,9]
read_pon=[0,1,6,8]
read_bon=[3]
n%=10

if n in read_hon:
    print('hon')
elif n in read_pon:
    print('pon')
elif n in read_bon:
    print('bon')

Measured memory_bytes: 9140
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *l;
  struct node *r;
  struct node *p;
  int key;
};

typedef struct node *Node;

Node root;

Node TreeMin(Node x){
  while(x->l!=NIL)x=x->l;
  return x;
}

Node TreeSearch(Node x, int k){
  if(x==NIL||k==x->key) return x;
  if(k<x->key) return TreeSearch(x->l,k);
  else return TreeSearch(x->r,k);
}

Node TreeSuccessor(Node x){
  Node y,p;
  if(x->r!=NIL)return TreeMin(x->r);
  y=x->p;
  while(y!=NIL&&x==y->r){
    x=y;
    y=y->p;
  }
  return y;
}

void TreeDelete(Node z){
  Node x,y;
  if(z->l==NIL||z->r==NIL) y=z;
  else y=TreeSuccessor(z);

  if(y->l!=NIL) x=y->l;
  else x=y->r;

  if(x!=NIL) x->p=y->p;

  if(y->p==NIL) root=x;
  else if(y==y->p->l) y->p->l=x;
  else y->p->r=x;

  if(y!=z) z->key=y->key;
}

void TreeInsert(int k){
  Node y=NIL;
  Node x=root;
  Node z;
  z=malloc(sizeof(struct node));
  z->key=k;
  z->l=NIL;
  z->r=NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key) x=x->l;
    else x=x->r;
  }
  z->p=y;
  if(y==NIL) root=z;
  else if(z->key<y->key) y->l=z;
  else y->r=z;
}

void Iorder(Node u){ //Inorder
  if(u!=NIL){
      Iorder(u->l);
      printf(" %d",u->key);
      Iorder(u->r);
  }
}

void Porder(Node u){ //Preorder
  printf(" %d",u->key);
  if(u!=NIL){
    if(u->l!=NIL)Porder(u->l);
    if(u->r!=NIL)Porder(u->r);
  }
}

int main(){
  int n,i,x;
  char array[20];
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",array);
    if(array[0]=='f'){
      scanf("%d",&x);
      Node t = TreeSearch(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    } else if(array[0]=='i'){
      scanf("%d",&x);
      TreeInsert(x);
    } else if(array[0]=='p'){
      Iorder(root);
      printf("\n");
      Porder(root);
      printf("\n");
    } else if(array[0]=='d'){
      scanf("%d",&x);
      TreeDelete(TreeSearch(root,x));
    }
  }
  return 0;
}

Measured memory_bytes: 19364
#include <iostream>

using namespace std;
typedef long long lld;

int main(void)
{
	cin.tie(0);	ios_base::sync_with_stdio(0);
	lld h, w;	cin >> h >> w;
	if(h == 1 || w == 1)
		cout << 1;
	else if((h*w) & 1)
		cout << h*w/2 + 1;
	else
		cout << h*w/2;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"
var N, M, ans int
var u, w, v int
var dp []int
var DP, A [][]int
var vis, dist, indeg []int

const (
	MaxInt = 1<<31 - 1
	MinInt = -MaxInt - 1
)
func max(a, b int) int {
	if a > b { return a }
	return b
}

func min(a, b int) int {
	if a < b { return a }
	return b
}

func abs(a int) int {
	if a < 0 { return -a }
	return a
}

func dfs(U int) {
	for _, V:= range A[U] {
		dist[V] = max(dist[V], dist[U]+1)
		ans = max(ans, dist[V])
		indeg[V]--
		if indeg[V] == 0 {
			dfs(V)
		}
	}
}

func main() {
	_,e := fmt.Scanf("%d%d", &N, &M)
	if e != nil { return }
	A = make([][]int, N+1)
	ans = 0
	dist, indeg = make([]int, N+1), make([]int, N+1)
	for i:=0; i<N; i++ {
		A[0] = append(A[0], i+1)
		indeg[i+1]++
	}

	for i:=1; i<=M; i++ {
		_,e = fmt.Scanf("%d%d", &u, &v)
		if e != nil { return }
		A[u] = append(A[u], v)
		indeg[v]++
	}
	dfs(0)
	fmt.Println(ans-1)
}


Measured memory_bytes: 15448
#include <iostream>
#include <typeinfo>
#include <cstring>
#include <utility>
#include <vector>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;


int main() {
    unsigned long long N;
    cin >> N;

    unsigned long long n3 = N / 3;
    unsigned long long n5 = N / 5;
    unsigned long long n15 = N / 15;

    cout << (N * (N+1) - 3 * n3 * (n3 + 1) - 5 * n5 * (n5 + 1) + 15 * n15 * (n15 + 1) ) / 2 << endl;

    return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
using ll = long long;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using namespace std;
using vl = vector<ll>;
using pll =  pair<ll,ll>;

ll destroy(ll h){
    if(h == 1)
        return 1;
    else 
        return 1 + 2 * destroy(h/2);
}

void solve()
{   
    ll h,n,sum =0;
    cin>>h;
    ll ans = destroy(h);
    cout<<ans;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll N;
  scanf("%lld", &N);

  map<string, ll> m;

  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    string s;
    cin >> s;

    if (m[s] == 0) {
      ans += 1;
    }
    m[s] = 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 17684
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
 
/*** Template Begins ***/
 
typedef long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<int, int> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;
typedef long double ld;
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
// #define mp           make_pair
#define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007LL
// #define h 998244353
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p)
{
  ll res = 1;
  x = x % p;
  while (y > 0)
  { 
    if (y & 1) 
      res = (res*x) % p;
    y = y>>1;
    x = (x*x) % p;
  } 
  return res; 
} 
const int MAXN = 2e5+5;

// Debug //
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll euclid(ll x,ll y,ll a,ll b)
{
  return (a-x)*(a-x)+(b-y)*(b-y);
}
// Constants //
bool comp(ll a,ll b)
{
  return a>b;
}
void solve()
{
  ld th,ts,ah,as;
  cin>>th>>ts>>ah>>as;
  ld dt = ceil(th/as),da=ceil(ah/ts);
  // trace2(dt,da);
  if(dt>=da)
    cout<<"Yes";
  else
    cout<<"No";
}

int main()
{ 
  ios;
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  ll t,i;
  t=1;
  // cin>>t;
  while(t--)
  {
    solve();
    // cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3736