akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict

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

d = defaultdict(int)

for i in li:
  d[i] += 1

newLi = []  
  
if len(d) <= K:
  print(0)
else:
  a = len(d) - K
  
  for i in d:
    newLi.append(d[i])

  newList = sorted(newLi)
  ans = 0
  
  for s in range(a):
    ans += newList[s]
  
  print(ans)

Measured memory_bytes: 32572
#include<stdio.h>

int main()
{
	int w,n,a,b,x,y;
	scanf("%d",&w);
	scanf("%d",&n);
	int m[30]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30};

	for(x=0;x<n;x++)
	{
		scanf("%d,%d",&a,&b);
		if(m[a-1]<=m[b-1])
		{
			y=m[b-1]-m[a-1];
			m[a-1]+=y;
			m[b-1]-=y;
		}
		else if(m[a-1]>m[b-1])
		{
			y=m[a-1]-m[b-1];
			m[b-1]+=y;
			m[a-1]-=y;
		}
	}

	for(x=0;x<w;x++)
	{
		printf("%d\n",m[x]);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) ((a)>(0)?(a):-(a))
#define rep(i,l,r) for((i)=(l);(i)<(r);(i)++)
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(c-(a-b)>0)cout<<c-(a-b)<<endl;
    else cout<<"0"<<endl;
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)
#define fi first
#define se second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr const char* YES = "Yes";
static constexpr const char* NO = "No";

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long K;
  scanf("%lld", &K);
  long long X;
  scanf("%lld", &X);

  put(K * 500 >= X ? YES : NO);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

template <class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) {
  T c = min(a, b), d = max(a, b);
  return c * (d / gcd(c, d));
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <map>


using namespace std;

int main() {
    map <int ,int> cnt;
    int t;
    for (int i = 0; i < 3; ++i) {
        cin>>t;
        cnt[t]++;
    }
    if(cnt.size()==2)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}




Measured memory_bytes: 256
s=input()
t=input()
n=len(s)
t_str=''
for i in range(n):
    if i==0:
        t_str=s
        if t_str==t:
            print('Yes')
            exit()
    t_str=t_str[-1]+t_str[:n-1]
    if t_str==t:
        print('Yes')
        exit()
print('No')


Measured memory_bytes: 3060
// A

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll MOD=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

int main(){
  int N,i;
  cin>>N>>i;
  cout << N+1-i << endl;
  return 0;
}



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

int main(){
	int n=1,r1,r2;
	while (scanf("%d",&n)==1) {
		if (n==0)
			break;
		for (int k=1;k<=n;k++) {
			double p=double(n)/k-double(k)/2+0.5;
			if (p<1) {
				cout<<r1<<' '<<r2<<endl;
				break;
			}
			if (int(p)==p) {
				r1=int(p);
				r2=k;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3148
using System;

namespace ABC165_b
{
    class Program
    {
        static void Main(string[] args)
        {
            long x = long.Parse(Console.ReadLine());
            long deposit = 100;
            long year = 0;

            while(deposit < x) {
                deposit += deposit / 100; //deposit = (long)(deposit * 1.01)とするとオーバーフローした 
                year++;
            }
            Console.WriteLine(year);
        }
    }
}


Measured memory_bytes: 27480
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
#include<ctime>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;

#define ll long long
#define MP make_pair

int h,w,vis[1000][1000]={},num=0;
vector<string> a(1000);
queue<pair<int,int>> q;
queue<queue<pair<int,int>>> qcnt;

bool bfs(int hi,int wi){
    bool jud=true;
    for (int i = -1; i < 2; i+=2) {
        if(hi+i>=0&&hi+i<=h-1){
            if(a[hi+i][wi]=='.'){
                jud=false;
                a[hi+i][wi]='#';
                q.push(MP(hi+i,wi));
            }
        }
        if(wi+i>=0&&wi+i<=w-1){
            if(a[hi][wi+i]=='.'){
                jud=false;
                a[hi][wi+i]='#';
                q.push(MP(hi,wi+i));
            }
        }
    }

    return jud;
}

void cnt(){
    bool jud=true;
    while(!qcnt.front().empty()){
        if(!bfs(qcnt.front().front().first,qcnt.front().front().second)){
            jud=false;
        }
        qcnt.front().pop();
    }
    if(jud){
        queue<queue<pair<int,int>>>().swap(qcnt);
        return;
    }
    num++;

    return;
}

int main(void) {

    cin>>h>>w;

    for (int i = 0; i < h; i++) {
        cin>>a[i];
        for (int j = 0; j < w; j++) {
            if(a[i][j]=='#')q.push(MP(i,j));
        }
    }

    qcnt.push(q);
    queue<pair<int,int>>().swap(q);
    
    while(!qcnt.empty()){
        cnt();
        qcnt.push(q);
        queue<pair<int,int>>().swap(q);
        qcnt.pop();
    }

    

    cout<<num<<"\n";

    
    
    return 0;
}

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

int main(){
	bool isHamming[1000001];
	int n,m;
	for(int i = 0; i < 1000001; i++){
		isHamming[i]=false;
	}
	for(int i = 1; i < 1000001; i *= 2){
		for(int j = i; j < 1000001; j *= 3){
			for(int k = j; k < 1000001; k *= 5){
				isHamming[k] = true;
			}
		}
	}
	while(true){
		cin >> n;
		if(cin.eof() || n == 0){
			break;
		}
		cin >> m;
		int c=0;
		for(int i = n; i <= m; i++){
			if(isHamming[i])
				c++;
		}
		cout << c << endl;
	}
	return 0;
}


Measured memory_bytes: 2132
import bisect
import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
kouzi = []
for _ in range(N):
    S, T, X = map(int, input().split())
    kouzi.append([X, S, T-1])
kouzi.sort(reverse = True)

human = [int(input()) for _ in range(Q)]
ans = [-1]*(Q+1)


N0 = 2**(Q-1).bit_length()
data = [None]*(2*N0)
INF = (-1, 2**31-1)

def update(l, r, v):
    L = l + N0; R = r + N0
    while L < R:
        if R & 1:
            R -= 1
            data[R-1] = v

        if L & 1:
            data[L-1] = v
            L += 1
        L >>= 1; R >>= 1
def _query(k):
    k += N0-1
    s = INF
    while k >= 0:
        if data[k]:
            s = max(s, data[k])
        k = (k - 1) // 2
    return s
def query(k):
    return _query(k)[1]
t = 0
for task in kouzi:
    t += 1
    x = task[0]
    l = bisect.bisect_left(human, task[1]-x)
    r = bisect.bisect_right(human, task[2]-x)
    if l == r:
        continue
    update(l, r, (t, x))

for i in range(Q):
    q = query(i)
    if q == 2147483647:
        print(-1)
    else:
        print(q)


Measured memory_bytes: 112176
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(1000001);
    vector<int> q(n);
    int ans=0;
    bool g = false;

    vector<bool> p(1000001);
    rep(i,1000001){
        a[i]=0;
        p[i]=0;
    }
    rep(i,n){
        cin >> q[i];
        if(q[i]==1){
            g=true;
        }
        if(a[q[i]]==1){
            p[q[i]]=1;
        }
        a[q[i]]=1;
    }
    for(int j=2;j<1000001;j++){
        if(a[j]==1){
            for(int i=2;i*j<=1000000;i++){
                a[i*j]=0;
            }
        }
    }
    rep(i,n){
        if(!p[q[i]]){
            if(a[q[i]]==1){
                ans+=1;
            }
            else if(q[i]==1){
                ans+=1;
            }
        }
    }
    if(g){
        if(p[1]){
            cout << 0;
            return 0;
        }
        else{
            cout << 1;
            return 0;
        }
    }
    else{
        cout << ans;
    }


    return 0;
}

Measured memory_bytes: 8256
n,m,x=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]

ans=10**9
for i in range(2**n):
  t_ans=0
  us=[0 for q in range(m)]
  for j in range(n):
    if (i>>j)&1:
      use=l[j]
      t_ans+=use[0]
      for w in range(m):
        us[w]+=use[w+1]
  check=1
  for z in us:
    if z<x:
      check=0
  if check==1:
    ans=min(ans,t_ans)

print(ans if ans!=10**9 else -1)

Measured memory_bytes: 9228
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define v vector<ll>
#define mp make_pair
#define fir first
#define sec second
#define _fast_ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
ll n,sum1,sum2;
ll arr[3005];
ll dp[3000][3000];
ll go_dp(ll x,ll y)
{
    if(x>y || x>n-1 || y<0)
    {
        return 0;
    }
    if(dp[x][y] != -1)
    {
        return dp[x][y];
    }
    if(x == y)
    {
        return dp[x][y] = arr[x];
    }
    dp[x][y] = max(arr[x]-go_dp(x+1,y),arr[y]-go_dp(x,y-1));
    return dp[x][y];

}
int main()
{
    _fast_
    ll t = 1;
    //cin>>t;
    while(t--){
    cin>>n;
    sum1 = 0;
    sum2 = 0;

    f(n)
    {
        cin>>arr[i];
        sum2 += arr[i];
    }
    rep(i,0,n)
    {
        rep(j,0,n)
        {
            dp[i][j] = -1;
        }
    }
    sum1 = go_dp(0,n-1);
    cout<<sum1<<"\n";
    }
    return 0;
}

Measured memory_bytes: 70784
#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<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v.at(i);
  map<int, int> mp1;
  for(int i = 0; i <= n-1; i += 2) {
    mp1[v.at(i)]++;
  }
  int a;
  int max1 = 0;
  for(auto p : mp1) {
    max1 = max(max1, p.second);
    if(max1==p.second) a = p.first;
  }
  map<int, int> mp2;
  for(int i = 1; i <= n-1; i += 2) {
    mp2[v.at(i)]++;
  }
  int max2 = 0;
  for(auto p : mp2) {
    if(p.first==a) continue;
    max2 = max(max2, p.second);
  }
  int ans1 = n - max1 - max2;
  int b;
  int max3 = 0;
  for(auto p : mp2) {
    max3 = max(max3, p.second);
    if(max3==p.second) b = p.first;
  }
  int max4 = 0;
  for(auto p : mp1) {
    if(p.first==b) continue;
    max4 = max(max4, p.second);
  }
  int ans2 = n - max3 - max4;
  cout << min(ans1,ans2) << endl;
  return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <queue>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(){
	
	int n,q,t;
	string name;
	cin>>n>>q;
	queue<pair<string, int>> Q;// 创建任务队列
	
	for(int i=0;i<n;i++){
		cin>>name>>t;
		Q.push(make_pair(name, t));
	} 
	
	pair<string,int> u;
	int elaps = 0,a;
	
	while(!Q.empty()){
		u = Q.front();Q.pop();
		a = min(u.second,q);
		u.second -= a;
		elaps += a;
		if(u.second>0){
			Q.push(u);
		}
		else{
			cout<<u.first<<" "<<elaps<<endl;
		}
	}
	return 0;

}


Measured memory_bytes: 6336
from fractions import gcd

a, b, c, d = [int(x) for x in input().split()]

c_num = b // c - (a - 1) // c
d_num = b // d - (a - 1) // d

c_d_lcm = c * d // gcd(c, d)
c_d_num = b // c_d_lcm - (a - 1) // c_d_lcm

ans = b - a + 1 - c_num - d_num + c_d_num
print(ans)

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

int main(){
  int N;
  cin >> N;
  if(N%10==2||N%10==4||N%10==5||N%10==7||N%10==9) cout <<"hon";
  if(N%10==0||N%10==1||N%10==6||N%10==8) cout << "pon";
  if(N%10==3) cout << "bon";
}

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

#define int long long int
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define umii unordered_map<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007

using namespace std;

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

    int n, d, a, i, damage=0, ans=0, bombs;
    cin>>n>>d>>a;
    vii xh(n);
    queue <pii> q;
    for (i=0; i<n; i++)
        cin>>xh[i].ff>>xh[i].ss;
    sort(xh.begin(), xh.end());
    for (i=0; i<n; i++)
    {
        while (!q.empty() && q.front().ff<xh[i].ff)
        {
            damage-=q.front().ss;
            q.pop();
        }
        xh[i].ss-=damage;
        if (xh[i].ss<=0)
            continue;
        bombs=xh[i].ss/a;
        if (xh[i].ss%a)
            bombs++;
        ans+=bombs;
        damage+=a*bombs;
        q.push(mp(xh[i].ff+2*d, a*bombs));
    }
    cout<<ans;
}


Measured memory_bytes: 4992
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, LR):
    l = 1
    r = N
    for L, R in LR:
        l = max(l, L)
        r = min(r, R)
    return max((r - l + 1), 0)


def main():
    # N = read_int()
    N, M = read_int_n()
    LR = [read_int_n() for _ in range(M)]
    print(slv(N, M, LR))


if __name__ == '__main__':
    main()


Measured memory_bytes: 29688
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main(){
    input!{
        a: i32,
        b: i32,
        c: i32
    }
    let mut d = c - (a - b);
    if d < 0 {
        d = 0;
    }
    println!("{}", d);

}

Measured memory_bytes: 2160
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;
const int N = 1000000;

int isprime[N];
vector<int> prime;

void makePrime(){
    REP(i, N) isprime[i] = true;
    isprime[0] = false;
    isprime[1] = false;

    for(int i = 2; i < N; i++){
        if(!isprime[i]) continue;
        prime.push_back(i);
        for(int j = i + i; j < N; j += i) isprime[j] = false;
    }
}

int main(){
    makePrime();
    int n;
    while(cin >>n && n){
        int ans = 0;
        REP(i, n) ans += prime[i];
        cout <<ans <<endl;
    }
    return 0;
}

Measured memory_bytes: 5488
#include<stdio.h>
#define N 1000000

int min(int a,int b){return (a>b)?b:a;}

int dp[N],dp_odd[N];

int main(){
  int i,j,n,tmp;
  int plc[1000],num;

  for(i=0;i<N;i++)dp[i] = dp_odd[i] = N+1;
  dp[0] = dp_odd[0] = 0;

  tmp = 1;
  for(num=1;;num++){
    plc[num] = tmp;
    tmp *= num+3; tmp /= num;
    if(tmp>=N)break;
  }
  
  for(i=0;i<N;i++){
    for(j=1;j<num;j++){
      if(i<plc[j])break;
      dp[i] = min(dp[i],dp[i-plc[j]]+1);
      if(plc[j]&1)dp_odd[i] = min(dp_odd[i],dp_odd[i-plc[j]]+1);
    }
  }

  while(scanf("%d",&n) && n)printf("%d %d\n",dp[n],dp_odd[n]);
}

Measured memory_bytes: 8448
#include <iostream>

int main(int argc, char** argv)
{
	while (true)
	{
		int n, x;
		std::cin >> n >> x;
		if (n == 0 && x == 0)
		{
			break;
		}

		int count = 0;
		for (int i = 1; i <= n - 2; ++i)
		{
			for (int j = i + 1; j <= n - 1; ++j)
			{
				for (int k = j + 1; k <= n; ++k)
				{
					if (i + k + j == x)
					{
						++count;
					}
				}
			}
		}

		std::cout << count << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3080
def solve(K, A, B):
    if A > B:
        return K + 1

    if K < A:
        return K + 1

    ret = K + 1

    ans = B
    K -= A + 1
    ans += (K // 2) * (B - A)
    ans += K % 2

    return max(ans, ret)

K, A, B = map(int, input().split())
print(solve(K, A, B))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
 
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
 
#define infi INT_MAX
#define infl LONG_LONG_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second
#define G(a,b) get<a>(b)
#define MP make_pair
#define MT make_tuple
#define pll pair<ll,ll> 
#define endl "\n"
#define ALL(v) v.begin(),v.end()
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;
#define deb printf("***************************************************************************************\n");

inline ll ceil(ll a,ll b)
{
  return (a+b-1)/b;
}



void func()
{ 
  string s;
  cin>>s;
  if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes\n";
  else cout<<"No\n";
} 

int main() 
{
    //fast
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE*/
    
    ll ntc=1;
    //cin>>ntc;

    f(i,1,ntc+1)
    {
      //cout<<"Case #"<<i<<": ";
      func();
    }
 
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{
    public static void Main()
    {
        long N = long.Parse(Console.ReadLine());
        long [] A =new long[N];
        String[] input = Console.ReadLine().Split();
        long[] num = new long[100002];
        for(int i = 0; i < N; i++) { A[i] = long.Parse(input[i]);num[A[i]]++; }
        long ans = A.Sum();
        long Q = long.Parse(Console.ReadLine());

        long[] B = new long[Q];
        long[] C = new long[Q];
        for (int i = 0; i < Q; i++) { input = Console.ReadLine().Split(); B[i] = long.Parse(input[0]); C[i] = long.Parse(input[1]); }

        for(int i = 0; i < Q; i++) {
            ans = ans + (C[i] - B[i]) * num[B[i]];
            num[C[i]] += num[B[i]]; num[B[i]]=0;
            Console.WriteLine(ans);
        }

    }
}

Measured memory_bytes: 50500
### 素因数分解する。
from collections import defaultdict

def factorize(n):
    """

    """
    tmp = n
    for i in range(2, int(n**0.5)+1):
        if tmp % i==0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if i in LCM:
                LCM[i] = max(LCM[i], cnt)
            else:
                LCM[i] = cnt
    if tmp != 1:
        if tmp in LCM:
            LCM[tmp] = max(LCM[tmp], 1)
        else:
            LCM[tmp] = 1
    if not LCM:
        if n in LCM:
            LCM[n] = max(LCM[n], 1)
        else:
            LCM[n] = 1
def inv(n, p):
    return pow(n, p-2, p)

LCM = dict()
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7

for i in range(N):
    if A[i] != 1:
        factorize(A[i])

lcm = 1
for key, val in LCM.items():
    lcm *= pow(key, val, mod)
    lcm %= mod

inv_sum = 0
for i in range(N):
    inv_sum += inv(A[i], mod)
    inv_sum %= mod

print(lcm * inv_sum % mod)

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;



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


	ll a,b,n;cin>>a>>b>>n;
	
	ll x =n;
	
	if(n >=b-1) x = b-1;
	ll ans = a*x/b-a*(x/b);
	writeln(ans);
}




Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <algorithm>

int n,ans;
int a[205];

int main (){
	scanf("%d",&n);
	n*=2;
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	std::sort (a+1,a+n+1);
	for (int i=1;i<=n;i+=2)
		ans+=a[i];
	std::cout <<ans<<std::endl;
	return 0 ;
}

Measured memory_bytes: 256
from __future__ import print_function
import sys
import heapq

n, q = map(int, sys.stdin.readline().split())
a = [[] for i in range(n)]

for i in range(q):
    g = list(map(int, sys.stdin.readline().split()))
    if g[0] == 0:
        heapq.heappush(a[g[1]], -g[2])
    elif g[0] == 1:
        a[g[1]] and print(-a[g[1]][0])
    else:
        a[g[1]] and heapq.heappop(a[g[1]])



Measured memory_bytes: 13456
/* ITP1_10_B:Triangle */
/* 20181125 AOJ */

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>
#define RAD M_PI / 180

int main(void) {
	double a, b, c, C, S, L, h;

	scanf("%lf %lf %lf", &a, &b, &C);
	
	C = C * RAD;
	c = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(C));
	h = b * sin(C);
	S = a * h / 2;
	L = a + b + c;

	printf("%f\n", S);
	printf("%f\n", L);
	printf("%f\n", h);

	return 0;
}


Measured memory_bytes: 2076
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int n,m,c;
    cin>>n>>m>>c;
    vector<int>b(m);
    rep(i,m)cin>>b[i];
    int ans=0;
    rep(i,n){
        vector<int>a(m);
        rep(i,m)cin>>a[i];
        int sum=0;
        rep(i,m)sum+=(a[i]*b[i]);
        if(sum+c>0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
int ceil(int a,int b){
    return (a+b-1)/b;
}
int main(void){
   int h,w;
   cin>>h>>w;
   string s[h];
   rep(i,h) cin>>s[i];
   rep(i,h){
       rep(j,w){
           if(s[i][j]=='#')  continue;
           int num=0;
           rep(k,8){ 
               int yy=i+dy[k]; 
               int xx=j+dx[k];
               if(xx<0 || xx>=w) continue;
               if(yy<0 || yy>=h) continue;
               if(s[yy][xx]=='#') num++;
           }
           s[i][j]=(char)(num+'0');
       }
   }
   rep(i,h) cout<<s[i]<<endl; 
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};

struct edge{lint to,cost;};
lint V;
vector<edge> G[200000]; // MAX_V
lint d[200000]; // MAX_V
void dijkstra(lint S){
  priority_queue<plint,vector<plint>,greater<plint>> que;
  fill(d,d+V,LINF);
  d[S]=0;
  que.push(plint(0,S));
  while(!que.empty()){
    plint p=que.top();
    que.pop();
    lint v=p.second;
    if(d[v]<p.first) continue;
    rep(i,G[v].size()){
      edge e=G[v][i];
      if(d[e.to]>d[v]+e.cost){
        d[e.to]=d[v]+e.cost;
        que.push(plint(d[e.to],e.to));
      }
    }
  }
}

int main(void){
    lint N,M,S;
    cin >> N >> M >> S;
    V=N*2500;
    S=min(S,2499LL);
    lint U[M],V[M],A[M],B[M];
    rep(i,M) cin >> U[i] >> V[i] >> A[i] >> B[i];
    lint C[N],D[N];
    rep(i,N) cin >> C[i] >> D[i];
    rep(i,M){
        U[i]--,V[i]--;
        rep(j,2500){
            if(j-A[i]>=0){
                G[U[i]*2500+j].push_back({V[i]*2500+j-A[i],B[i]});
                G[V[i]*2500+j].push_back({U[i]*2500+j-A[i],B[i]});
            }
        }
    }
    rep(i,N) rep(j,2500){
        int to=j+C[i];
        to=min(to,2499);
        G[i*2500+j].push_back({i*2500+to,D[i]});
    }
    dijkstra(S);
    for(int i=1;i<N;i++){
        lint ans=LINF;
        rep(j,2500) ans=min(ans,d[i*2500+j]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 25660
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
using namespace std;

int main(void){
    int n;
    long long ans=1;
    vector<int> used(26,1);
    string s;
    cin >> n >> s;
    for(int i=0; i<n; i++){
        used[s[i]-'a']++;
    }
    for(int i=0; i<26; i++){
        if(used[i])ans=(ans*used[i])%MOD;
    }
    cout << ans-1 << endl;
    return 0;
}

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


/*//______OPTIMISATION______//
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/

//________________MACROS_______________//
#define   fast 	 		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define   int   		long long int
#define   pb  			push_back
#define   f     		first
#define   s     		second
#define   deb(x) 		cerr << #x << " " << x << endl;
#define   debb(x, y) 		cerr << #x << " = " << x << "," << #y << " = " << y << endl <<endl;
#define   in            	insert
#define   lb            	lower_bound
#define   ub            	upper_bound
#define   all(x)        	x.begin(), x.end()
#define   endl              '\n'
bool isPrime(int n)
{
	for(int i = 2; i * i <= n; i++)
	{
		if(n % i == 0)
		{
			return false;
		}
	}
	return true;
}

bool isPowerOfTwo (int x)
{
    return (x && (!(x&(x-1))));
}

int countDigit(int num)
{
	return (floor(log10(num)) + 1);
}

int rightMostFirstSetBit (int n)
{
    return log2(n & -n)+1;
}

int noOfBitInBinaryRepresntation(int n)
{
    return log2(n)+1;
}
signed main()
{
    fast ;

    int test_case = 1;
    //cin >> test_case;

    while (test_case--)
    {
        int n ;
        cin >> n ;

        int rem = n % 1000;
        if (rem == 0)
        {
            rem = 1000;
        }
        int ans = 1000 - rem ;
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3492
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : August 07, 2020 4:32 PM
 *    Problem Name  : C - Vacation
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/dp/tasks/dp_c
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
using namespace std;

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

    int n;
    cin >> n;

    int abc[n][3];

    for(int i=0; i<n; i++){
        for(int j=0; j<3; j++){
            cin >> abc[i][j];
        }
    }

    int dp[n+1][3];

    for(int i=0; i<3; i++){
        dp[0][i] = abc[0][i];
    }

    for(int i=1; i<n; i++){
        dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + abc[i][0];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + abc[i][1];
        dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + abc[i][2];
    }

    cout << max(dp[n-1][2],max(dp[n-1][1], dp[n-1][0])) << endl;

    return 0 ;
}


Measured memory_bytes: 5960
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		 String s = sc.next();
		 int answer = 0;
		
		 for(int i = 0;i < s.length();i++) {
			 char mas = s.charAt(i);
			 if('1' == mas) {
				 answer++;
			 }
		 }
		 System.out.println(answer);
	}
}


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

int main() {
  int N, M, X, a;
  cin >> N >> M >> X;
  int c1 = 0, c2 = 0;
  for (int i = 0; i < M; i++) {
    cin >> a;
    if (X < a) c2++;
    else c1++;
  }
  cout << min(c1, c2) << endl;
}

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

int main() {
  ll L,R;
  cin >> L >> R;
  ll m = 2019;
  R = R-(L/2019)*2019;
  L = L%2019;
  for(ll i=L; i<=min(R,L+2019); i++){
    for(ll j=i+1; j<=min(R,i+1+2019); j++){
      if ((i*j)%2019 < m) m = (i*j)%2019;
    }
  }
  
  cout << m << endl;

  return 0;
}


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

/// --- Dinic Libary {{{ ///
// solve max flow

struct Dinic {
  struct Edge {
    int to; ll cap; int rev;
    Edge(int to, ll cap, int rev):
      to(to), cap(cap), rev(rev) {}
  };

  int size;
  vector< vector< Edge > > g;
  ll inf;
  Dinic(int size, ll inf = 1e18): size(size), g(size), inf(inf) {}

  void addEdge(int a, int b, ll cap, bool undirected = false) {
    g[a].emplace_back(b, cap, g[b].size());
    g[b].emplace_back(a, undirected ? cap : 0, g[a].size() - 1);
  }

  ll solve(int s, int t) {
    vector<int> level(size);
    ll flow = 0;
    while(bfs(s, level), level[t] > 0) {
      ll newflow = dfs(s, t, inf, level);
      if(newflow == 0) break;
      flow += newflow;
      if(flow >= inf) return inf;
    }
    return flow;
  }

  private:
  void bfs(int s, vector<int> & level) {
    fill(begin(level), end(level), -1);
    queue<int> q;
    q.push(s);
    level[s] = 0;
    while(q.size()) {
      int i = q.front(); q.pop();
      for(Edge edge : g[i])
        if(level[edge.to] == -1 && edge.cap > 0) {
          level[edge.to] = level[i] + 1;
          q.push(edge.to);
        }
    }
  }

  ll dfs(int i, int t, ll flow, vector<int> const & level) {
    if(i == t) return flow;
    for(Edge &edge : g[i])
      if(edge.cap > 0 && level[edge.to] > level[i]) {
        ll newflow = dfs(edge.to, t, min(flow, edge.cap), level);
        if(newflow == 0) continue;
        edge.cap -= newflow;
        g[edge.to][edge.rev].cap += newflow;
        return newflow;
      }
    return 0;
  }
};

/// ---}}} ///

ll inf = 1e18;
Dinic ecasdqina(102, inf);
// s : 0
// t : 101
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n; cin >> n;
  ll ans = 0;
  int s = 0, t = 101;
  for(int i = 1; i <= n; i++) {
    int x; cin >> x;
    if(x < 0) {
      ecasdqina.addEdge(s, i, -x);
      ecasdqina.addEdge(i, t, 0);
    } else {
      ecasdqina.addEdge(s, i, 0);
      ecasdqina.addEdge(i, t, x);
      ans += x;
    }
    for(int k = i * 2; k <= n; k += i) {
      ecasdqina.addEdge(i, k, inf);
    }
  }
  ans -= ecasdqina.solve(s, t);
  cout << ans << endl;
}


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

int main(){
  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
// 1,2はxだけ、3,4はyだけみればいい
// 1のうち最大値、2のうち最小値、3のうち最大値、4のうち最小値だけみればいい
// (min(w, min(x2))-max(0, max(x1)))*(min(h, min(y4))-max(0, max(y3)))
// ex: sample1) (w-2)*(3-0) = 3*3 = 9
package main
import "fmt"
var w, h, n int
func main(){
	fmt.Scan(&w, &h, &n)
	maxX1, minX2, maxY3, minY4 := 0, w, 0, h
	for i:=0; i<n; i++{
		var x, y, a int
		fmt.Scan(&x, &y, &a)
		if a == 1{
			if maxX1 < x{
				maxX1 = x
			}
		}else if a == 2{
			if minX2 > x{
				minX2 = x
			}
		}else if a == 3{
			if maxY3 < y{
				maxY3 = y
			}
		}else if a == 4{
			if minY4 > y{
				minY4 = y
			}
		}
	}
	if maxX1 > minX2 || maxY3 > minY4{
		fmt.Println(0)
	}else{
		fmt.Println((minX2-maxX1)*(minY4-maxY3))
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<P> input(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> input[i].second >> input[i].first;
		}
		sort(input.begin(), input.end());
		bool flag = true;
		int sum = 0;
		for(int i = 0; i < n; ++i)
		{
			sum += input[i].second;
			if(sum > input[i].first)
			{
				cout << "No" << endl;
				flag = false;
				break;
			}
		}
		if(flag)
		{
			cout << "Yes" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9


int main(){ 
  int N;
  cin >> N;
  vector<int> W(N);
  int sum = 0;
  REP(i, N){
    cin >> W[i];
    sum += W[i];
  }
  int S = 0, ans = INF;
  REP(i, N-1){
    S+= W[i];
    if(abs(S-(sum-S)) < ans){
      ans = abs(S-(sum-S));
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
stairs = [i for i in range(1, n+1)]
a = [0 for _ in range(m)]
for i in range(m):
  a[i] = int(input())
a = set(a)
  
dp = [0] * (n + 1)
dp[0] = 1

for i in range(1, n+1):
  if i in a:
    continue
  dp[i] = dp[i-1]
  if i > 1:
    dp[i] += dp[i-2]

print(dp[n] % 1000000007)

Measured memory_bytes: 469664
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int a,b;
  cin >> a >> b;
  cout << (a+b+1)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>

using namespace std;



int main()
{

	vector<long long> prime;
	prime.push_back(2);
	prime.push_back(3);
	prime.push_back(5);
 
	for(int i=7;prime.back()<100000/2;i+=2){
		bool ok=true;
		for(int j=0;prime[j]*prime[j]<=i && ok;j++){
			if(i%prime[j]==0) ok=false;
		}
		if(ok) prime.push_back(i);
	}	

	long long m,a,b;
	while(cin>>m>>a>>b,m|a|b){
		long p=0,q=0;
		for(long i=0;i<prime.size();i++){
			for(long j=i;j<prime.size() && prime[i]*prime[j]<=m ;j++){
				if(a*prime[j]<=b*prime[i] && p*q<prime[i]*prime[j]){
					p=prime[i]; q=prime[j];
				}
			}
		}
		cout<<p<<" "<<q<<endl;
	}

	return 0;
}

Measured memory_bytes: 1324
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
#define ll long long
#define int long long
ll n,val=0,store[12],len;
char alphabet[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
string s="";
signed main(){
	scanf("%lld",&n);
	while(n>0){
		n--;
		store[val]=n%26;
		val++;
		n/=26;
	}
	for(int i=val-1;i>=0;i--){
		int now=store[i];char nw=alphabet[now];s+=nw;
	}
	cout<<s<<endl; 
	return 0;
}

Measured memory_bytes: 3804
import java.util.Scanner;
class Main{
public static void main(String[]args){
Scanner input=new Scanner(System.in);
  long a=input.nextInt();
  long b=input.nextInt();
  long c=input.nextInt();
  long d=input.nextInt();
  long max=a*c>b*d?a*c:b*d;
  max=max>a*d?max:a*d;
  max=max>b*c?max:b*c;
    System.out.println(max);
}
}

Measured memory_bytes: 35916
#include <bits/stdc++.h>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define PI 3.14159265358979323846264338327950L
#define e18 1000000000000000000

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

long long myGcd(long long a, long long b);
int myGcd(int a, int b);
long long myLcm(long long a, long long b);
int myLcm(int a, int b);
long long checkDigit(long long num);
int checkDigit(int num);

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

	vector<int> li(101, 0); //0 to 100

	int X, N;

	cin >> X >> N;
	if (N == 0)
	{
		cout << X << endl;
		return 0;
	}

	REP(i, N)
	{
		int tmp;
		cin >> tmp;
		li[tmp] = 1;
	}

	REP(i, 100)
	{
		if (X - i >= 0)
		{
			if (li[X - i] == 0)
			{
				cout << X - i << endl;
				return 0;
			}
		}
		
		if (X + i <= 101)
		{
			if (li[X + i] == 0)
			{
				cout << X + i << endl;
				return 0;
			}
		}
	}

	return 0;
}

long long myGcd(long long a, long long b)
{
	if (a % b == 0)
		return b;
	return myGcd(b, a % b);
}

int myGcd(int a, int b)
{
	if (a % b == 0)
		return b;
	return myGcd(b, a % b);
}

long long myLcm(long long a, long long b)
{
	return a * b / myGcd(a, b);
}

int myLcm(int a, int b)
{
	return a * b / myGcd(a, b);
}

long long checkDigit(long long num)
{
	string st = to_string(num);
	return st.size() - 1;
}

int checkDigit(int num)
{
	string st = to_string(num);
	return st.size() - 1;
}

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

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

	static class TaskB {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
			}
			Arrays.sort(a);
			long s = 0;
			for (int x : a) {
				s += x;
			}
			int ans = 1;
			for (int i = n - 1; i >= 0; i--) {
				s -= a[i];
				if (2 * s < a[i]) {
					break;
				} else {
					++ans;
				}
			}
			out.println(ans);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

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

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

	}
}



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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin >> n;
  string s;
  cin >> s;

  ll ans = 0;
  for(ll i = 0; i+2<n; i++){
    if(s.substr(i, 3)=="ABC")
      ans++;
  }

  cout << ans << endl;
}


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

int
main(int argc, char *argv[])
{
        char in;
        int cnt[26] = {0};
        int i;

        while (in = getc(stdin), in != EOF) {
                if ('a' <= in && in <= 'z')
                        cnt[in - 'a']++;
                if ('A' <= in && in <= 'Z')
                        cnt[in - 'A']++;
        }
        for (i = 0; i < 26; i++)
                printf("%c : %d\n", i + 'a', cnt[i]);

        return 0;
}

Measured memory_bytes: 524
package main

import "fmt"

func ifval(cond bool, a interface{}, b interface{}) interface{} {
	return map[bool]interface{}{true: a, false: b}[cond]
}

func main() {
	for {
		var h, w int

		fmt.Scan(&h, &w)
		if h == 0 && w == 0 {
			break
		}

		for i := 0; i < h; i++ {
			for j := 0; j < w; j++ {
				fmt.Print(ifval((i+j)%2 == 0, "#", "."))
			}
			fmt.Println()
		}
		fmt.Println()
	}
}



Measured memory_bytes: 5920
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, a, k;
  cin >> n >> a;
  k  = n;
  while(n >= 500){
    n -= 500;
    k = n;
  }
  if(k <= a) cout << "Yes\n";
  else cout << "No\n";

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int x[n], p = INT_MIN,ans1 =0, ans2 = 0, ans = INT_MAX ;
	for(int i =0; i<n;i++)
	{
		cin >> x[i];
		ans1+= (x[i]*x[i]);
		ans2+= (x[i]);
		p = max(p,x[i]);
	}
	for(int i=p;i>=0;i--)
	{
		ans = min(ans1-2*ans2*i+i*i*n, ans);
	}
	cout << ans;
}


Measured memory_bytes: 256
(N, M), *LR, = [map(int, s.split()) for s in open(0)]
card_l = 1
card_r = N
for l, r in LR:
    card_l = max(l, card_l)
    card_r = min(r, card_r)
print(max(0, card_r - card_l + 1))

Measured memory_bytes: 49652
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
#define F first
#define S second

const int mxn = 1e4+5;
int n, ans[mxn];

void solve(){
    cin >> n;
    const int mx = 500;
    for(int i = 1; i <= mx; ++i){
        for(int j = 1; j <= mx; ++j){
            for(int k = 1; k <= mx; ++k){
                int res = i*i + j*j + k*k + i*j + i*k + j*k;
                if(res < mxn) ans[res]++;
            }
        }
    }

    for(int i = 1; i <= n; ++i){
        cout << ans[i] << '\n';
    }
}

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

Measured memory_bytes: 3640