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

int n;
int main()
{
	scanf("%d", &n);
	if ((n & -n) == n)
	{
		puts("No");
		return 0;
	}
	puts("Yes");
	int m = 1 << (int)log2(n), k = n - m;
	printf("%d %d\n%d %d\n%d %d\n%d %d\n%d %d\n", 1, m, 1, m + 1, m + 1, m + n, m + n, n + 1, n + 1, n + m + 1);
	for (int i = 2; i < n; i += 2)
		if (i != m)
			printf("%d %d\n%d %d\n%d %d\n%d %d\n", 1, i, 1, i + 1, i, n + i + 1, i + 1, n + i);
	if (!(n & 1))
		printf("%d %d\n%d %d\n", m + 1, n, k, 2 * n);
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
using namespace std;

int main() {

	string S; cin >> S;
	int res = 0;
	int len = S.length();
	int count = 0;

	for (int i = 0; i <= len - 1; i++)  if (S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C'){ count++; res = max(res, count);}else{count = 0;}

	cout << res << endl;

}

Measured memory_bytes: 256
// Insertion Sort
#include <stdio.h>

void insertion_sort(int Ap[], int N)
{
    int i, j, k, v;
    for(i = 0; i < N; i++){
        v = Ap[i];
        j = i - 1;
        while(j >= 0 && Ap[j] > v){
            Ap[j + 1] = Ap[j];
            j--;
        }
        Ap[j + 1] = v;
        for(k = 0; k < N; k++){
            printf("%d", Ap[k]);
            if(k != N - 1){
                printf(" ");
            }
        }
        printf("\n");
    }
}

int main(void)
{
    int N, i;
    scanf("%d", &N);
    int A[N];
    for(i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }
    insertion_sort(A, N);
   
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

int main(void) {
  vector<int> vec(3);
  rep(i, 3) {
    cin >> vec[i];
  }
  sort(all(vec));
  int ans = 0;
  int a = vec[2] - vec[0];
  int b = vec[2] - vec[1];
  if (a % 2 != 0 && b % 2 != 0) {
    ans += a / 2 + b / 2;
    ans++;
  } else if (a % 2 == 0 && b % 2 == 0) {
    ans += a / 2 + b / 2;
  } else {
    if (a % 2 == 0) {
      ans += a / 2;
      ans++;
      ans += (b + 1) / 2;
    } else {
      ans += b / 2;
      ans++;
      ans += (a + 1) / 2;
    }
  }
  cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;

map<ll,ll> primes(ll n){
    map<ll, ll> r;
    for(int i=2; i*i<=n; i++){ 
        while(n % i ==0){
            r[i]++;
            n /= i;
        }
    }

    if(n != 1) r[n] = 1;
    return r;
}

int main(){FIN
    
    long double a,b ;cin>>a>>b;
    cout<<ll(a*b)<<endl;

    return 0;
}

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

int main(){
    int n;
    string s, t;
    cin >> n;
    cin >> s >>t;
    string ans = "";

    rep(i,n){
        ans += s.at(i);
        ans += t.at(i);
    }

    cout << ans << endl;

    return 0;
}

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

int main(void){
   int n,i,result=0;
  
  scanf("%d",&n);
  while(n>0){
  	if(n % 10 == 7)result = 1;
    n/=10;
  }
  if(n==7) result = 1;
  if(result==1) printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1,-1, 0, 0};
int dy[4] = {0, 0, 1,-1};
int gcd(int X,int Y) {
    if(X%Y == 0) {
        return Y;
    }
    else {
        return gcd(Y,X%Y);
    }
}
signed main() {
    int N,K;
    cin >> N >> K;
    vector<int>A(N);
    int mx = 0;
    int GCD = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        mx = max(mx,A[i]);
        if(i == 0) {
            GCD = A[i];
        }
        else {
            GCD = gcd(GCD,A[i]);
        }
        if(A[i] == K) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    if(mx < K) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    if((mx-K)%GCD == 0) {
        cout << "POSSIBLE" << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }
}


Measured memory_bytes: 3832
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


N, X = map(int, input().split())
xl = list(map(int, input().split()))

if N == 1:
    print(abs(X-xl[0]))
    exit(0)

xl.append(X)
xl.sort()

k = []
for i in range(1, N+1):
    tmp = xl[i]-xl[i-1]
    if not(tmp in k):
        k.append(tmp)

if len(k) == 1:
    print(k[0])
elif len(k) == 2:
    ans = gcd(k[0], k[1])
    print(ans)
else:
    ans = gcd(k[0], k[1])
    for i in range(2, len(k)):
        ans = gcd(ans, k[i])
    print(ans)


Measured memory_bytes: 14480
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[5];
    for(int i=0;i<5;i++)
    {
        cin>>a[i];
    }
    for(int j=0;j<5;j++)
    {
        if(a[j]==0)
        {
            cout<<j+1<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3600
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<algorithm>
namespace Program
{
    using namespace std;

    class Solver
    {
    private:
        // コンテスト 実施回数 最大 二分探索 上限
        const int contest = 10001;

        // alphabet a-z
        enum { alphabet = 26 };

        int N;
        int K;
        int P[alphabet]{};

    public:
        Solver()
        {
            cin.tie(0);
            ios::sync_with_stdio(false);

            cin >> N;
            cin >> K;

            string tmp;
            for (int i = 0; i < N; i++)
            {
                cin >> tmp;

                // 問題名 頭文字1文字 出現回数
                P[tmp[0] - 'A']++;
            }
        };

        void Solve()
        {
            // 二分探索
            int under = -1;
            int upper = contest;

            while (under + 1 < upper)
            {
                int mid = (under + upper) / 2;
                int cnt = 0;
                for (int i = 0; i < alphabet; i++)
                {
                    cnt += min(P[i], mid);
                }
                if (mid * K > cnt) upper = mid;
                else under = mid;
            }

            cout << under << "\n";
        };
    };
}

int main()
{
    // メンバ関数ポインタ取得
    void (Program::Solver::*pSolve)() = &Program::Solver::Solve;

    // コンストラクタ呼び出し
    Program::Solver obj;

    // .*演算子でアクセス
    (obj.*pSolve)();
    return 0;
}


Measured memory_bytes: 256
N=int(input())
number=list(map(int,input().split()))
ans=1
if 0 in number:
    print(0)
    exit(0)
    
for i in range(N):
    ans *= number[i]
    if ans>1000000000000000000:
        print(-1)
        exit(0)
print(ans)

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


int main() {
int N;
cin>>N;
vector<long> a(N);
for(int i=0;i<N;i++) cin>>a[i];
sort(a.begin(),a.end());
vector<long> b(N);
for(int i=0;i<N;i++){
  if(i==0)  b[0]=a[0];
  else b[i]=b[i-1]+a[i];
}
long ans=N;
long t=0;
for(int i=0;i<N-1;i++){
  if(b[i]*2>=a[i+1]) continue;
  else t=i+1;
}
cout<<ans-t<<endl;
}


Measured memory_bytes: 4820
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut handle = stdin.lock();
    let mut buf = String::new();
    handle.read_line(&mut buf).unwrap();
    let (N, M) = {
        let mut it = buf.trim().split_whitespace();
        let N = it.next().unwrap().parse::<usize>().unwrap();
        let M = it.next().unwrap().parse::<usize>().unwrap();
        (N, M)
    };
    buf.clear();

    let mut prices = Vec::with_capacity(M);
    let mut cs = Vec::with_capacity(M);
    for i in 0..M {
        handle.read_line(&mut buf).unwrap();
        let (a, b) = {
            let mut it = buf.trim().split_whitespace();
            let a = it.next().unwrap().parse::<usize>().unwrap();
            let b = it.next().unwrap().parse::<usize>().unwrap();
            (a, b)
        };
        buf.clear();
        prices.push(a);

        handle.read_line(&mut buf).unwrap();
        cs.push(buf.trim().split_whitespace().map(|x| {
            let t = x.parse::<usize>().unwrap();
            1 << (t - 1)
        }).fold(0, |acc, cur| acc | cur ));
        buf.clear();
    }
    
    let inf = 1 << 60;
    let mut dp = vec![vec![inf; 1 << N]; M + 1];
    dp[0][0] = 0;

    use std::cmp::min;
    for i in 0..M {
        for j in 0..(1 << N) {
            // use the i-th key
            dp[i+1][j | cs[i]] = min(dp[i+1][j | cs[i]], dp[i][j] + prices[i]);

            // not use the i-th key
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }

    let ans = dp[M][(1 << N) - 1];
    if ans == inf {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 41212
while True:
	try:
		path = [0]*101
		while True:
			a,b = map(int, raw_input().split())
			if a == 0: break
			path[a-1] += 1; path[b-1] += 1
		for i in range(3,101):
			if path[i]%2 != 0:
				flag = 0
				break
		else:
			flag = 1
		if path[0]%2 == path[1]%2 == 1 and  flag:
			print "OK"
		else:
			print "NG"
   	except:
   		break

Measured memory_bytes: 4216
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<set>
#include<string> 
#include<vector>
#include<stack>
#include<queue> 
#define PI 3.14159265358979323846
typedef long long ll;
using namespace std;
const ll Mod=1e9+7;
ll gcd(ll a, ll b) 
{
    if (b == 0) return a;
    else gcd(b, a % b);
}
long long quick_mod(long long a,long long b)//a的b次方对Mod取余 
{
    long long ans = 1;
    a %= Mod; //对刚进来的a进行取模运算，避免后面第一次求平方运算溢出
    while(b)
    {
        if(b&1) //对二进制下的 b 进行按位与1运算，求二进制下 b 的最低位是否为1
            ans = ans * a % Mod; //对结果进行保存
        b>>=1; //二进制下的 b 右移一位，相当于十进制下的 b 除以2
        a = a * a % Mod; 
    }
    return ans % Mod;
}
const int inf=0x3f3f3f3f;
int main()
{
	double a=0,h=0,ans=0;
	cin>>a>>h;
	ans=ceil(a/h);
	cout<<ans<<endl;
	return 0;
} 






Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    string S;
    cin >> S;
    int zeroNum = count(S.begin(), S.end(), '0');
    int oneNum = S.length() - zeroNum;
    cout << min(zeroNum, oneNum) * 2 << endl;
}


Measured memory_bytes: 512
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     ll int i,n,p,m,x=0;
     cin>>n;
     ll int ara[n];
     for(i=0;i<n;i++){
        cin>>ara[i];

     }
     p=1;
     sort(ara,ara+n);

     p=ara[0]*p;
     for(i=1;i<n;i++){
        m=ara[i]*p;
        if(m>1000000000000000000 || m<0 || m<p){
        cout<<-1<<endl;return 0;
        }
        p=m;
     }
     cout<<m<<endl;

     return EXIT_SUCCESS;
}






Measured memory_bytes: 4428
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = int64_t;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1'001'001'001;
const ll INFL = (1LL<<60);
const double eps = (1e-9);

const ll mod = 1e9 + 7;

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

  vector<int> a(3);
  rep(i, 3) cin >> a[i];
  sort(ALL(a));
  int ans = 0;
  int x = a[2] - a[1];
  ans += x;

  a[0] += x;
  int y = a[2] - a[0];

  ans += y / 2;
  if (y % 2 != 0) ans += 2;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl

using namespace std;
using ll = long long;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

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

  ll ans = 0;
  for (int c = 1; c <= n-1; ++c) {
    auto v = prime_factorize(c);
    ll cnt = 1;
    for (auto u: v) {
      cnt *= (u.second + 1);
    }
    ans += cnt;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <deque>
#include <string>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <map>
#include <unordered_map>
#include <bitset>

#define _crt_secure_no_warnings
#define FREEELO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define INF 0x3F3F3F3F3F3F3F3F
#define MAX 300001
#define MOD 1000000007
#define ALPHABET 128
#define loop(i, n) for (int i = 1; i <= (n); i++)
#define loop0(i, n) for (int i = 0; i < (n); i++)
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll, ll> llll;
typedef pair<int, int> ii;
typedef unordered_map<int, int> umii;
typedef unordered_map<ll, ll> umll;
int dp[2001];
int main() {
    int n; cin >> n;
    dp[0] = 1;
    for (int i = 3; i <= n; i++){
        for (int j = i - 3; j >= 0; j--){
            (dp[i]+=dp[j]) %= MOD;
        }
    }
    cout << dp[n];
}

Measured memory_bytes: 3192
#include <iostream>
using namespace std;
int main(){
  int A[4];
  char c;
  for(int i=0;i<4;i++){
    cin >> c;A[i]=c-'0';
  }
  for(int bf=0;bf < (1<<3);bf++){
    int sum=A[0]+A[1]+A[2]+A[3];
    for(int k=0;k<3;k++){
      if(bf & (1<<k))sum-=2*A[k+1];
    }
    if(sum==7){
      cout << A[0];
      for(int k=0;k<3;k++){
      	if(bf & (1<<k))cout << '-';
        else cout << '+';
        cout << A[k+1];
      }
      cout << "=7" << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long A=1, B=1;
		while (n-->0) {
			long a = sc.nextLong(), b = sc.nextLong();
          	// Precision issues due to double and ceil
			long m = Math.max((A+a-1)/a, (B+b-1)/b);
			A=m*a; B=m*b;
		}
		System.out.println(A+B);
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 39272
x = input()
num = int(x.split()[1])
perimeter = int(x.split()[0])
houses = [int(i) for i in input().split()]

maxDis = perimeter - houses[-1] + houses[0]
total = maxDis
for i in range(1, len(houses)):
    maxDis = max(maxDis, houses[i]-houses[i-1])
    total += houses[i]-houses[i-1]
print(total-maxDis)

Measured memory_bytes: 31604
import sys
from operator import itemgetter
input = sys.stdin.readline
def nibun_right(a, x):
 lo, hi = 0, len(a)
 while lo < hi:
  mid = (lo+hi)//2
  if x < a[mid][0]: hi = mid
  else: lo = mid+1
 return lo
N,D,A=map(int,input().split())
lst=[0]*N
for i in range(N):
 lst[i]=list(map(int,input().split()))
 lst[i][1]=int((lst[i][1]-1)/A)+1
lst.sort(key=itemgetter(0))
DMG=[0]*(N+1)
ans=0
for i in range(N):
 renji=nibun_right(lst,lst[i][0]+2*D)
 Z=max(lst[i][1]-DMG[i],0)
 DMG[i]+=Z
 DMG[renji]-=Z
 ans+=Z
 DMG[i+1]+=DMG[i]
print(ans)


Measured memory_bytes: 77776
//z-algorithm
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  int n; cin >> n;
  string s; cin >> s;
  int ans = 0;
  vector<int> ms(n, 0);
  for(int e = 0; e < s.length(); e++){
    vector<int> a(n, 0);
    int c = 0;
    for(int i = 1; i + e < s.length(); i++){
      if(i+a[i-c] < c+a[c]){
        a[i] = a[i-c];
      }
      else{
        int j = max(0, c+a[c]-i);
        while(i+j < s.length() && s[e+j] == s[i+e+j]) j++;
        a[i] = j;
        c = i;
      }
    }
    for(int k = 1; k + e < s.length(); k++){
      ms[e] = max(min(a[k], k), ms[e]);
    }
  }
  sort(ms.begin(), ms.end());
  for(int i = 1; i < n; i++){
    ans = max(ms[i], ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
def month_judge(MM):
    if 1 <= int(MM) <= 12:
        return True
    else:
        return False

S = input()
First = S[0:2]
Latter = S[2:4]

if month_judge(First):
    if month_judge(Latter):
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if month_judge(Latter):
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int x;
	cin>>x;
	
	if(x==7 || x==5 || x==3 )cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;


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

    ll n;
    cin>>n;
    set<string> ar;
    while(n--)
    {
        string s;cin>>s;
        ar.insert(s);
    }
    cout<<ar.size();

    return (0);
}


Measured memory_bytes: 19076
#include<iostream>
using namespace std;
int main(){
  int l[4]={0},r[4]={0};
  double a,b;
  while(cin>>a>>b){
    if(a<0.2)l[3]++;
    else if(a<0.6)l[2]++;
    else if(a<1.1)l[1]++;
    else l[0]++;
    if(b<0.2)r[3]++;
    else if(b<0.6)r[2]++;
    else if(b<1.1)r[1]++;
    else r[0]++;
  }
  for(int i=0;i<4;i++)cout<<l[i]<<" "<<r[i]<<endl;
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
  string c[3];
  REP(i, 3) {
    cin >> c[i];
  }

  cout << c[0][0] << c[1][1] << c[2][2] << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
 
	public static void main(String[] args) {
		
		Scanner stdIn = new Scanner(System.in);
 
		String S = stdIn.next();
		String T = stdIn.next();
		
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
 
		String U = stdIn.next();
	
		if( S.equals(U)){
			A--;
			System.out.print( A +" "+ B);
		}else if (T.equals(U)){
			B--;
			System.out.print( A +" "+ B);
		}

	}
    
}

Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(void){
    long long w, h;
    int x, y;
    double area;
    int res = 0;

    cin >> w >> h >> x >> y;

    if(w == 2 * x && h == 2 * y){
        res = 1;
    }
    
    area = w / 2.0 * h;

    printf("%.6lf %d\n", area, res);

    return 0;
}

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

int main(){

  int N,count = 0;
  cin >> N;
  int A[N];
  bool check = true;
  
  for(int i = 0; i < N; ++i){
  
    cin >> A[i];  
  
  }
  
  while(check){
  
    for(int j = 0; j < N; ++j){

      if(A[j] % 2 == 0){
        A[j] /= 2;
      }else{
        check = false;
        break;
      }

    }
    
    if(check){
      count += 1;
    }
    
  }
  
  cout << count << endl;
  
  return 0;

}

Measured memory_bytes: 256
// AOJ 1337: Count the Regions
// 2017.12.5 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 1000002
typedef struct { int x, y; } Q;
Q q[20005]; int top, end;
typedef struct { int x1, y1, x2, y2; } T;
T tbl[52];
int xx[105], xs;
int yy[105], ys;
long long map[105][105];
int mv[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
char buf[50], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	p++;
	return n;
}

int cmp(int *a, int *b) { return *a - *b; }

int uniq(int *a, int n)
{
	int i, j;
	
	for (i = 0, j = 1; j < n; j++) {
		while (j < n && a[j] == a[i]) j++;
		if (j < n) if (++i != j) a[i] = a[j];
	}
	return i+1;
}

int bsch(int *a, int x, int r)
{
	int m, l = 0;

    while (l < r) {
        m = (l + r) >> 1;
		if (a[m] == x) break;
        if (a[m] < x) l = m + 1; else r = m;
    }
	return m;
}

int main()
{
	int n, i, x, y, x1, y1, x2, y2, ans;
	long long id;

	while (fgets(p=buf, 10, stdin) && *p != '0') {
		n = getint();
		xx[0] = yy[0] = 0, xs = ys = 1;
		for (i = 0; i < n; i++) {
			fgets(p=buf, 50, stdin);
			tbl[i].x1 = xx[xs++] = getint()+1;
			tbl[i].y2 = yy[ys++] = getint()+1;
			tbl[i].x2 = xx[xs++] = getint()+1;
			tbl[i].y1 = yy[ys++] = getint()+1;
		}
		xx[xs++] = yy[ys++] = MAX;
		qsort(xx, xs, sizeof(int), cmp); xs = uniq(xx, xs);
		qsort(yy, ys, sizeof(int), cmp); ys = uniq(yy, ys);

		memset(map, 0, sizeof(map));
		for (id = 1, i = 0; i < n; i++, id <<= 1) {
			x1 = bsch(xx, tbl[i].x1, xs);
			y1 = bsch(yy, tbl[i].y1, ys);
			x2 = bsch(xx, tbl[i].x2, xs);
			y2 = bsch(yy, tbl[i].y2, ys);
			for (y = y1; y < y2; y++) for (x = x1; x < x2; x++)
				 map[y][x] |= id;
		}

		ans = 0;
		for (y = 0; y < ys; y++) for (x = 0; x < xs; x++) {
			if (map[y][x] >= 0) {
				id = map[y][x], map[y][x] = -1, ans++;
				q[0].x = x, q[0].y = y, top = 0, end = 1;
				while (top < end) {
					x1 = q[top].x, y1 = q[top++].y;
					for (i = 0; i < 4; i++) {
						x2 = x1 + mv[i][0], y2 = y1 + mv[i][1];
						if (x2 < 0 || x2 >= xs || y2 < 0 || y2 >= ys ||
							map[y2][x2] != id) continue;
						map[y2][x2] = -1;
						q[end].x = x2, q[end++].y = y2;
					}
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1828
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int mod=1e9+7;
inline void add(int &x,int y){
	x+=y;
	x=(x>=mod?x-mod:x);
}
int Pw[10];
inline int ksm(int x,int y){
	int res=1;
	while(y){
		if(y&1) res=(ll)res*x%mod;
		x=(ll)x*x%mod;
		y>>=1;
	}
	return res;
}
int main(){
	int n=read();
	int ans=0;
	Pw[0]=1;
	REP(i,1,8) Pw[i]=Pw[i-1]*10;
	for(int i=1,j=1,di=1,dj=1,Nw=1;j<1e7;){
		while(Nw>n){
			Nw-=dj;
			++j;
			if(j==Pw[dj]) ++dj;
		}
		if(j>=1e7) break;
		if(Nw==n) ++ans;
		++i;
		if(i==Pw[di]) ++di;
		Nw+=di;
	}
	for(int i=1;(ll)i*i<=n;++i) if(n%i==0){
		if(i>=8){
			int u=(ksm(10,i)-ksm(10,i-1)+mod)%mod;
			u=(u-n/i+1+mod)%mod;
			add(ans,u);
		}
		if(n!=i*i && n/i>=8){
			int u=(ksm(10,n/i)-ksm(10,n/i-1)+mod)%mod;
			u=(u-i+1+mod)%mod;
			add(ans,u);
		}
	}
	REP(i,1,n){
		if((n-1)/i<8) break;
		add(ans,max((n-1)/i-max(n/i-1,7),0));
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <algorithm>

using namespace std;

#define MAX_N 100001


/* -----------------------------------------------------------------------------
	型とクラス定義
----------------------------------------------------------------------------- */

/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */
int N;
int M;

std::priority_queue<int> pq;


int main () {

	// 個数の読込み
	scanf("%d %d", &N, &M);
	// 
	for(int i = 0; i < N; i++) {
		int x;
		scanf("%d", &x);
		pq.push(x);
	}
	
	//
	for(int i = 0; i < M; i++) {
		int price = pq.top(); pq.pop();
		price /= 2;
		pq.push(price);
	}

	long long sum = 0;
	while(!pq.empty()) {
		sum += pq.top(); pq.pop();
	}
	printf("%lld\n", sum);

	return 0;
}


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

struct UnionFind {
  vector<int> par;  // par[i]:iの親の番号　

  UnionFind(int N) : par(N) {  //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x) {  // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {  // xとyの木を併合
    int rx = root(x);         // xの根をrx
    int ry = root(y);         // yの根をry
    if (rx == ry) return;  // xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] =
        ry;  // xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y) {  // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind tree(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    tree.unite(a, b);
  }
  vector<int> tf(n);
  int cnt = 0;
  int ma = 0;
  rep(i, n) {
    int k = tree.root(i);
    tf[k]++;
  }
  rep(i, n) { ma = max(tf[i], ma); }
  cout << ma << endl;
}

Measured memory_bytes: 11016
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

vector<int> get_prime(int n){
  vector<int> v;
  int i=2;
  while(n >= i*i){
    if(n%i == 0){
      v.push_back(i);      
      n /= i;
    }
    else{
      i++;
    }
  }
  v.push_back(n);
  return v;
}

int
main(void){  
  ios_base::sync_with_stdio(false);

  int num3=0, n;
  cin >> n;
  
  REP(i, n){
    int itmp;
    cin >> itmp;
    vector<int> v;
    v = get_prime(itmp);
    sort(v.begin(), v.end());    
    num3 += upper_bound(v.begin(), v.end(), 2) - lower_bound(v.begin(), v.end(), 2);        
  }
  
  cout << num3 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,m;
   cin>>n>>m;
   int a[n],sum=0,p,c=0;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
       sum+=a[i];
   }

    for(int i=0;i<n;i++)
    {
        if(a[i]*(4*m)>=sum)
           c++;
    }
    if(c>=m)
        cout<<"Yes\n";
    else
        cout<<"No\n";

  return 0;
}


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

int main() {
    ll N=lin(), K=lin();
    ll a, b;
    vector<pair<ll, ll>> Q;
    rep(i, N){
        a=lin();
        b=lin();
        Q.push_back(make_pair(a, b));
    }
    sort(Q.begin(), Q.end());
    ll count=0;
    ll i=0;
    while(count<K){
        count+=Q.at(i).second;
        i++;
    }
    cout<<Q.at(i-1).first<<endl;
}

Measured memory_bytes: 2420
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;

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

    bool eq = true;
    ll mn = 1e9, s = 0;
    for (int i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;
        if (a != b) eq = false;
        if (a > b) mn = min(mn, b);
        s += a;
    }
    if (eq) cout << 0 << endl;
    else cout << s - mn << endl;

}

Measured memory_bytes: 384
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

P aka[575];
P ao[575];

int
main(void){  
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  REP(i, n) {
    int x, y;
    cin >> x >> y;
    aka[i].first = x; aka[i].second = y;
  }
  REP(i, n) {
    int x, y;
    cin >> x >> y;
    ao[i].first = x; ao[i].second = y;
  }
  sort(aka, aka+n);
  sort(ao, ao+n);
  
  ll ans = 0LL;
  //for aka 
  vector<bool> used(n+1, false);
  
  REP(i, n){
    auto now = ao[i];
    int t = 0;
    int max_idx = -1;
    while(t<n && aka[t].first < now.first){
      if(aka[t].second < now.second && !used[t])
	{
	  if(max_idx == -1 || aka[max_idx].second < aka[t].second) max_idx=t;
	}
      t++;
    }
    if(max_idx == -1) continue;
    ans++;
    used[max_idx] = true;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if (a == 2 || b == 2)cout << "No" << endl;
	else cout << "Yes" << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
if __name__ == '__main__':
  str = input()
  strList = [c for c in str]
  strList.append('e')
  strLength = len(strList)
  rLength = 0
  lLength = 0
  i = 0
  changePoint = 0

  child = [0 for i in range(strLength-1)]

  c = 'R'
  
  while(c != 'e'):
    c = strList[i]
    while(c == 'R'):
      i += 1
      c = strList[i]
      rLength += 1
    
    changePoint = i
    
    while(c == 'L'):
      i += 1
      c = strList[i]
      lLength += 1

    rRight = int(rLength/2)
    rLeft = rLength - rRight

    lLeft = int(lLength/2)
    lRight = lLength - lLeft

    child[changePoint-1] += rLeft + lLeft
    child[changePoint] += rRight + lRight

    rLength = 0
    lLength = 0
  
  for numOfChild in child:
    print(numOfChild, end="")
    print(' ', end="")

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

using namespace std;

void solve() {
    int n, x, t;
    cin >> n >> x >> t;

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

    solve();
    return 0;    
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X;
    cin >> X;
    ll n = X / 100;
    if (n * 5 >= X % 100)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}

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

long long int rui(int i, int p){
  long long int a=1;
  for(int j=0;j<i;j++){
    a=a*p;
  }
  return a;
}

int main(){
  long long int N,n=0;
  cin>>N;
  long long int d=10;
  for(int i=0;i<10;i++){
    if(N<d){
      n=i+1;
      break;
    }
    d=d*10;
  }//n=桁数
  long long int p=1;
  for(int i=0;i<n-1;i++){
    p=p*2;
  }//p=総数
  long long int s=0;
  long long int k=0;
  long long int sk=0;
  for(int i=0;i<n;i++){
    k=(N-N%(rui(i,10)))%rui(i+1,10)/rui(i,10);
    sk=0;
    for(int u=0;u<i;u++){
      sk+=rui(u,10)*rui(i-u-1,2);
    }
    
    s+=(rui(n-i-1,2))*k*(rui(i,10)+sk);
  }
  
  cout<<s<<endl;
    
    
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int a[1000],i,n;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=n-1;i>=1;i--)
{
printf("%d ",a[i]);
}
printf("%d\n",a[0]);
return 0;
}



Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
bool check(string s){
  if(s[0] != 'A'){
    return false;
  }
  int c=0;
  for(int i=2; i<s.size()-1; i++){
    if(s[i] == 'C'){
      c++;
    }
  }
  if(c != 1){
    return false;
  }
  int b=0;
  for(int i=0; i<s.size(); i++){
    if(s[i] >= 'A' && s[i] <= 'Z'){
      b++;
    }
  }
  if(b != 2){
    return false;
  }
  return true;
}
int main() {
  string s;
  cin >> s;
  if(check(s)){
    cout << "AC" << endl;
  }
  else{
    cout << "WA" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int a,b,c,tmp;
 cin >> a >> b >>c;
 tmp=a;
 a=b;
 b=tmp;
  
 tmp=a;
 a=c;
 c=tmp;
 
 cout<<a<<" "<<b<<" "<<c<<endl;
}


Measured memory_bytes: 3568
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    var THP = input.split(' ')[0];
    var Tattack = input.split(' ')[1];
    var AHP = input.split(' ')[2];
    var Aattack = input.split(' ')[3];
    var count = 101;
    for (var i = 0; i < count; i++) {
        AHP = AHP - Tattack;
        if(AHP>0){
            THP = THP - Aattack;
            if (THP <= 0) {
                console.log("No");
                count = -1;
            }
        } else {
            count = -1;
            console.log("Yes");
        }
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29620
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
using namespace std;
#define INF 500000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

int dp[50][500][500];

int main(){
    int N,A,B,a[100],b[100],c[100];
    cin>>N>>A>>B;

    for(int i=0;i<N;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    for(int i=0;i<50;i++){
        for(int j=0;j<500;j++){
            for(int k=0;k<500;k++) dp[i][j][k]=INF;
        }
    }
    dp[0][0][0]=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<400;j++){
            for(int k=0;k<400;k++){
                if(dp[i][j][k]==INF) continue;
                dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
                dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
            }
        }
    }
    int ans=INF;
        for(int j=1;j<=400;j++){
            for(int k=1;k<=400;k++){
                if(A*k==B*j) ans=min(ans,dp[N][j][k]);
            }
        }
        if(ans==INF) cout<<-1<<endl;
        else cout<<ans<<endl;
    
}


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

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define cl(x, v) memset((x), (v), sizeof(x))
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<
#define gcd(x, y) __gcd((x), (y))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vii;

const ld EPS = 1e-9, PI = acos(-1.);
const ll LINF = 0x3f3f3f3f3f3f3f3f, LMOD = 1011112131415161719ll;
const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 1e5+5;

ll n, m, w[N], v[N], dp[N];

int main () {
    scanf("%lld%lld", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%lld%lld", &w[i], &v[i]);
    for (int i = 1; i <= n; i++) {
        for (int j = N-1; j-w[i] >= 0; j--) {
            dp[j] = max(dp[j], dp[j-w[i]]+v[i]);
        }
    }
    printf("%lld\n", dp[m]);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
  
int main(){
  
  long long K, A, B, c;
  cin >> K >> A >> B;
  
  if (A % K == 0 || B % K == 0){
    cout << "OK" << endl;
    return 0;
  }
  
  c = A / K;
  
  if (c * K + K >= A && c * K + K <= B){
    
    
    cout << "OK" << endl;
    return 0;
  }
  
  cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void)
{
        int n,i,h[100],x=1,j,f;

        scanf("%d",&n);

        for(i=0;i<n;i++){
                scanf("%d",&h[i]);
        }

        for(i=1;i<n;i++){
                f=1;
                for(j=0;j<i;j++){
                        if(h[i]<h[j])
                                f=0;
                }
                if(f==1)x++;
        }

        printf("%d\n",x);

        return 0;
}

                                                                    
               

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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;

int main() {
	int a, b, c;
	cin >> a >> b >> c;

	cout << a * b / 2 << endl;



    return 0;
}



Measured memory_bytes: 256
import collections


def main():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    bc = [list(map(int, input().split())) for _ in range(m)]
    A.sort()
    bc.sort(key=lambda x: x[1], reverse=True)
    i, j = 0, 0

    while i < n and j < m:
        if A[i] >= bc[j][1]:
            break
        A[i] = bc[j][1]
        i += 1
        bc[j][0] -= 1
        if bc[j][0] == 0:
            j += 1
    print(sum(A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 33284
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        w: Chars
    };
    let mut arr = vec![0; 1usize + b'z' as usize];
    for c in w {
        arr[c as usize] += 1;
    }
    for c in b'a'..=b'z' {
        if arr[c as usize] % 2 != 0 {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 2172
#include <bits/stdc++.h>
#define nl ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()

using namespace std;

int main() {
    nl // 163 braces

    int d; cin >> d;
    if(d == 25) cout << "Christmas";
    else if(d == 24) cout << "Christmas Eve";
    else if(d == 23) cout << "Christmas Eve Eve";
    else cout << "Christmas Eve Eve Eve";

    return 0;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

typedef long long ll;

using namespace std;
int main () {
int n, ac=0, wa=0, tle=0, re=0;
cin >> n;
for (int i = 0; i < n; i++)
{
    string s;
    cin >> s;
    if(s == "AC") {
        ac++;
    }
    else if(s == "WA") {
        wa++;
    }
    else if(s== "TLE") {
        tle++;
    }
    else if(s=="RE") {
        re++;
    }
}
cout << "AC x " << ac << endl;
cout << "WA x " << wa << endl;
cout << "TLE x " << tle << endl;
cout << "RE x " << re << endl;

return 0 ;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    int n; cin >> n;
    Rep(i, 1, 10) {
        Rep(j, 1, 10) {
            if(i * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int h, w, n;
  	cin >> h >> w >> n;
  	vi a(n);
  	vi ans(h*w);
  	int temp = 0;
  	rep(i,n){
    	cin >> a[i];
      	rep(j,a[i]) {
          	ans[temp] = i+1;
        	temp++;
        }
  	}
	
  	/*
  	rep(i,h*w) cout << ans[i] << " ";
  	cout << endl;
  	*/
  	rep(i,h){
      	if(i%2==0){
			rep(j,w) {
          		cout << ans[j+i*w] << " ";
        	}
        }else{
      		rep(j,w) {
       	   		cout << ans[((w-1)-j)+i*w] << " ";
        	}
        }
      	cout << endl;
    }
  	return;
}

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

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long

using namespace std ;
int dp[3005][3005] ; 

signed main()
{
	ios_base::sync_with_stdio(false) ; 
	cin.tie(NULL) ;            
	                        

	int  n   ;
	cin >> n ; 
	vector<int> a(n) ; 
	int sum = 0 ;
	for(int i = 0 ; i < n ; ++i )
	{
		cin >> a[i] ;
		sum += a[i] ; 
	}		
	for(int d =0 ; d < n ; ++d)
	{
		for(int i = 0 ; i < n-d ;++i)
		{
			int j =  i  +d ; 
			int x = ((i+2) <= j)?dp[i+2][j]:0 ; 
			int y = ((i+1) <= j-1)?dp[i+1][j-1]:0 ; 
			int z = (i <= j-2)?dp[i][j-2]:0 ; 
			dp[i][j] = max(a[i] + min(x, y) , a[j] + min(y,z)) ; 

		}
	}	
	                            
	cout <<( 2* dp[0][n-1] - sum) << endl ;
	
}


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

using namespace std;
using ll = long long;
const ll INF = 100100100100100100;

int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> w(n), v(n);
    rep(i, n) cin >> w[i] >> v[i];

    vector<vector<ll>> dp(n + 1, vector<ll>(110000, INF));
    dp[0][0] = 0;
    for (int i=0;i<n;++i) {
        for (int j=0;j<=100000;++j) {
            if (j < v[i]) dp[i + 1][j] = dp[i][j];
            else dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
        }
    }

    ll ans = 0;
    for (int j=0;j<=100000;++j) if (dp[n][j] <= k) ans = j;

    cout << ans << endl;
}

Measured memory_bytes: 87936