akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

// constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
// constexpr int MOD = 1'000'000'007;

template<class T> inline T sqr(T x) {return x*x;}

struct S {
    int x,y,p;
};

void solve() {
    int n;
    cin >> n;
    vector<S> ss(n);
    REP(i,0,n) {
        cin >> ss[i].x >> ss[i].y >> ss[i].p;
    }

    VVI hd(1<<n,VI(n, 1<<30)), vd(1<<n,VI(n, 1<<30));
    REP(bit,0,1<<n) {
        VI hs;
        hs.push_back(0);
        REP(i,0,n) {
            if (!(bit & (1<<i))) continue;
            hs.push_back(ss[i].x);
        }
        REP(i,0,n) {
            for (int h: hs) chmin(hd[bit][i], min(abs(ss[i].x - h), abs(ss[i].y)));
        }
    }
    REP(bit,0,1<<n) {
        VI vs;
        vs.push_back(0);
        REP(i,0,n) {
            if (!(bit & (1<<i))) continue;
            vs.push_back(ss[i].y);
        }
        REP(i,0,n) {
            for (int v: vs) chmin(vd[bit][i], min(abs(ss[i].y - v), abs(ss[i].x)));
        }
    }

    int pat = 1;
    REP(i,0,n) pat *= 3;
    VLL mv(n+1, 1LL<<60);
    REP(bit,0,pat) {
        int cnt = 0;
        LL hs = 0, vs = 0;
        int v = bit;
        REP(i,0,n) {
            cnt += (v % 3 > 0);
            if (v % 3 == 1) hs |= 1LL << i;
            if (v % 3 == 2) vs |= 1LL << i;
            v /= 3;
        }

        LL sum = 0;
        REP(i,0,n) {
            sum += 1LL * min(hd[hs][i], vd[vs][i]) * ss[i].p;
        }
        chmin(mv[cnt], sum);
        // cerr << bit << ": " << cnt << ", " << sum << endl;
    }
    REP(i,0,n+1) cout << mv[i] << endl;
}

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

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

int gcd(int n,int m){
	if(n>m)return gcd(m,n);
	while(n!=0){
		int tmp=n;
		n=m%n;
		m=tmp;
	}
	return m;
}
int abs(int z){return z>0?z:-z;}
int a,b,c,d;
int main(){
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int x=abs(a-c),y=abs(b-d);
	if(x>y){int t=x;x=y;y=t;}
	int ans=0;
	if(x){
		int d=gcd(x,y),t=x/d+y/d-1;
		ans=t*d;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
 
int main() {
  long long a,b,c,d=0,e=0;
  cin>>a>>b;
  for(int i=1;i<=10000;i++){
        c=i*0.08;
    d=i*0.1;
    if(c==a&&d==b){
      cout<<i;
      return 0;
    }
  }
  cout<<-1;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ab = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(ab[0] == 2 || ab[1] == 2 ? "No" : "Yes");
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define MAX 10000003
#define pb push_back
// #define mp make_pair
#define mem(x,y) memset(x,y,sizeof(x))
#define lcm(a,b) (a*b)/__gcd(a,b)
#define set_bit_count(x) __builtin_popcount(x)
#define str_rev(str) reverse(str.begin(),str.end())
#define loop(i,x,y) for(ll i=x;i<y;i++)
#define rloop(i,x,y) for(ll i=x-1;i>=y;i--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fastio;
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(ll i=k;i<=n+1;i++)
    {
        ll s=(i*(i-1))/2;
        ll e=n*i-s;
        ans=(ans+e-s+1+mod)%mod;
    }
    cout << ans%mod << endl;
    return 0;
}

Measured memory_bytes: 3612
/*
g++ -std=c++14 -O2 -Wall a.cpp -o a && a
*/

//  io
#include <iostream>
//#include <fstream> //http://www.cplusplus.com/reference/fstream/fstream/
//#include <cstdio>
#include <iomanip> //http://www.cplusplus.com/reference/iomanip/
#include <limits>
//  util
#include <string>
#include <cstring>
#include <algorithm>
//#include <utility>
//#include <functional> //http://www.cplusplus.com/reference/functional/
//#include <cstdlib>
//#include <cmath>
//#include <complex>
//#include <random>
//#include <bitset>
//  containers https://en.cppreference.com/w/cpp/container
#include <vector>
//#include <queue>
#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//  time
//#include <ctime>
//#include <chrono>
//                  https://en.cppreference.com/w/cpp/header/chrono
//                  http://www.cplusplus.com/reference/chrono/

using namespace std;
typedef vector<int> arri;
typedef vector<float> arrf;
typedef pair<int, int> pairi;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 0x7fffffffffffffff;
const ll infneg = -0x7fffffffffffffff;

//int modadd(int a, int b) { return ((a += b) < mod) ? a : (a - mod); }
//int modmult(int a, int b) { return (int)((a * b) % mod) }

//file input routed to stdinout
/*
std::ifstream inFile("input.txt");
std::ofstream outFile("output.txt");
std::cin.rdbuf(inFile.rdbuf());
std::cout.rdbuf(outFile.rdbuf());
*/

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

    int m, d;
    cin >> m >> d;

    int ans = 0;
    for (int i = 1; i <= m; i++)
    {
        for (int j = 22; j <= d; j++)
        {
            if ((j / 10) < 2 || (j % 10) < 2)
                continue;
            if ((j % 10) * (j / 10) == i)
            {
                ans++;
            }
        }
    }

    cout << ans;
}


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

int main(){
long long n;
cin>>n;
vector<long long> vec(n-1);
for(int i=0;i<n-1;i++){
cin>>vec.at(i);
}
vector<long long> ans(n);
for(int i=0;i<n-1;i++){
ans.at(vec.at(i)-1)+=1;
}
for(int i=0;i<n;i++){
cout<<ans.at(i)<<endl;
}
}


Measured memory_bytes: 6340
input :: IO [Float]
input = do
 [d, t, s] <- map read . words <$> getLine
 return [d, t, s]

check :: [Float] -> String
check [d, t, s] = if (d / s) <= t then "Yes" else "No"

main :: IO ()
main = (check <$> input) >>= putStrLn


Measured memory_bytes: 3956
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

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

    int n;
    cin >> n;

    ll s = 0;
    int p[60] = {};

    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;

        s += a % P * (n - 1) % P;

        ll t = 1;
        for (int k = 0; k < 60; k++) {
            if (a & t) {
                s -= t % P * 2 * p[k]++ % P;
            }
            t <<= 1;
        }
    }

    s %= P;
    if (s < 0) s += P;

    cout << s << endl;

    //xorすると、基本は足し算だが、両方立ってるビットは消えてしまう
    //単なる和と比べるとandの2倍だけ減る

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }


int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int p,q,r;
    cin>>p>>q>>r;
    int ans=INF;
    chmin(ans,p+q);
    chmin(ans,p+r);
    chmin(ans,r+p);
    chmin(ans,r+q);
    chmin(ans,q+p);
    chmin(ans,q+r);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
<?php

$line = explode(' ', fgets(STDIN));

$A = (int)$line[0];
$B = (int)$line[1];
$C = (int)$line[2];
$K = (int)$line[3];

$A = (string)$A;
$B = (string)$B;
$C = (string)$C;
$K = (string)$K;

if($A > $K){
  echo $K; 
}else if($A >= $K || $A + $B >= $K){
  echo $A;
}else {
  echo $A - ($K - ($A + $B));
}


Measured memory_bytes: 16212
import java.util.*;
import java.lang.*;
import java.io.*;


public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if(x<30){
			System.out.println("No");
		}
		else{
				System.out.println("Yes");
		}

    }
}


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

int main(){
	int N;
	cin >> N;
	vector<int> p(N);
	for(int i = 0;i < N;i++){
		cin >> p[i];
	}
	
	bool flag = true;
	int count = 0;

	for(int i = 0;i < N;i++){
		if(p[i] != i+1 && count == 0){
			count++;
			for(int j = i+1;j < N;j++){
				if(p[j] != j+1){
					int tmp = p[i];
					p[i] = p[j];
					p[j] = tmp;
					break;
				}
			}
		}else if(count > 0){
			break;
		}
	}

	for(int i = 0;i < N;i++){
		if(p[i] != i + 1){
			flag = false;
			break;
		}
	}

	
	if(flag){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in insert
#define mp make_pair
#define F first
#define pb push_back
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}
ll a[200006];
ll n;
int main(){
     cin>>n;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        a[i]=a[i]-i-1;
    }
    sort(a,a+n);
    ll b=a[n/2];
    ll sum=0;
    for(ll i=0;i<n;i++){
        sum+=abs(a[i]-b);
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Data
{
public:
    long long h, a, d, s;
    bool operator<(const Data& other) const
    {
        return h * other.a < other.h * a;
    }
};

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

    Data usagi;
    cin >> usagi.h >> usagi.a >> usagi.d >> usagi.s;

    vector<Data> enemy;
    for(int i=0; i<n; ++i){
        Data tmp;
        cin >> tmp.h >> tmp.a >> tmp.d >> tmp.s;
        if(tmp.a > usagi.d)
            enemy.push_back(tmp);
    }
    n = enemy.size();

    for(int i=0; i<n; ++i){
        enemy[i].a = max(enemy[i].a - usagi.d, 0LL);
        long long damage = usagi.a - enemy[i].d;
        if(damage <= 0){
            cout << -1 << endl;
            return 0;
        }else{
            enemy[i].h = (enemy[i].h + damage - 1) / damage;
            if(enemy[i].s > usagi.s)
                enemy[i].s = 0;
            else
                enemy[i].s = 1;
        }
    }
    sort(enemy.begin(), enemy.end());

    long long t = 0;
    long long ret = 0;
    for(int i=0; i<n; ++i){
        t += enemy[i].h;
        ret += (t - enemy[i].s) * enemy[i].a;
        if(ret >= usagi.h){
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ret << endl;

    return 0;
}

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

int main(){
    ll n,m;
    cin >> n >> m;

    map<ll, ll> wa;
    vector<ll> ac(n+1, 0);
    int ans_ac = 0, ans_wa=0;

    rep(i, m){
        ll p;
        string s;
        cin >> p >> s;

        if(s=="AC"){
            if(ac.at(p)==0){
                ans_ac+=1;
                ac.at(p)=1;
                if(wa.count(p)) ans_wa+=wa.at(p);
            }
        }
        else{ // WA
            wa[p]+=1;
        }
    }
    cout << ans_ac << ' ' << ans_wa << endl;
    return 0;
}

Measured memory_bytes: 4864
A,B,C = map(int, input().split())
K = int(input())
ans = 'No'
if A < B and B < C:
  print('Yes')
elif A < B:
  if B < C*(2**K):
    print('Yes')
  else:
    print('No')
else:
  for i in range(K):
      if A < B*(2**i) and B*(2**i) < C*(2**(K-i)):
        ans = 'Yes'
        break
  print(ans)

Measured memory_bytes: 9128
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //String str = sc.next();
        int[] count = new int[4];
        boolean test = true;
        
        for(int i=0; i<6; i++){
            int N = sc.nextInt();
            count[N-1]++;
        }
        for(int i=0; i<4; i++){
            if(count[i]>2){
                test = false;
            }
        }
        if(test){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

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

int main()
{
    string A, B, C;
    int N, counter = 0;
    cin >> N >> A >> B >> C;
    for (int i = 0; i < N; i++)
    {
        if (A[i] == B[i] && A[i] != C[i]) counter++;
        if (B[i] == C[i] && B[i] != A[i]) counter++;
        if (C[i] == A[i] && C[i] != B[i]) counter++;
        if (A[i] != B[i] && C[i] != B[i] && A[i] != C[i]) counter = counter + 2;
        }
    cout << counter << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ma = 1
mi = n
for i in range(m):
    l, r  = map(int, input().split())
    ma = max(ma, l)
    mi = min(mi, r)

ans = mi - ma + 1
if ans < 0:
    ans = 0
print(ans)


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

int main(void) {

	string s;
	int cnt[3] = { 0 };

	cin >> s;

	for (int i = 0; i < 3; i++) {
		if ('a' == s[i]) cnt[0]++;
		if ('b' == s[i]) cnt[1]++;
		if ('c' == s[i]) cnt[2]++;
	}
	if (cnt[0] == 1 && cnt[1] == 1 && cnt[2] == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
M=max(a)
m=min(a)
x=[0]*(M-m+3)
for i in a:
  x[i-m]+=1
  x[i-m+1]+=1
  x[i-m+2]+=1
print(max(x))

Measured memory_bytes: 52908
N = gets.to_i
A = gets.split.map(&:to_i)
counter = Hash.new(0)
A.each do |a|
  color = case a
          when 1..399
            0
          when 400..799
            1
          when 800..1199
            2
          when 1200..1599
            3
          when 1600..1999
            4
          when 2000..2399
            5
          when 2400..2799
            6
          when 2800..3199
            7
          else
            8
          end
  counter[color] += 1
end

colors = counter.keys.select { |x| x <= 7 }
min = [colors.size, [counter[8], 1].min].max
max = colors.size + counter[8]
puts [min, max].join(' ')


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

int main()
{
  string S, T;

  cin >> S >> T;

  int cnt = 0;

  auto sit = S.begin();
  auto tit = T.begin();

  for(; sit!=S.end(); ++sit, ++tit){
    if(*sit != *tit) ++cnt;
  }

  cout << cnt << endl;

  return 0;
}


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

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

  sort(a, a + n);
  map<int, int> m;
  for (int i=0; i<n; i++) {
    ++m[a[i]];
  }

  int ans = 0;
  for (int i=32; i>=0; i--) {
    long b = pow(2, i);
    for (auto e: m) {
      long c = b - e.first;
      if (m.find(c) == m.end()) {
        continue;
      }
      if (c == e.first) {
        ans += e.second / 2;
        m[c] -= e.second / 2;
      } else if (e.second < m[c]) {
        ans += e.second;
        m[c] -= e.second;
        m[e.first] = 0;
      } else {
        ans += m[c];
        m[e.first] -= m[c];
        m[c] = 0;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main() 
{
	int N, K;
	cin >> N >> K;
	int ans = K;
	for (int i = 1; i < N; i++) {
		ans *= K - 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import math
N=int(input())
i=2
digitSum=pow(10,5)
A=int(2)
while i<=int(N/2)+1:
    A=i
    B=N-A
    A_digitsum=0
    while A>=10:
        A_digitsum += A%10
        A = A//10
    if A<10:
        A_digitsum+=A
    B_digitsum=0
    while B>=10:
        B_digitsum += B%10
        B = B//10
    if B<10:
        B_digitsum+= B
    if digitSum > A_digitsum+B_digitsum:
        digitSum = A_digitsum+B_digitsum
    i+=1
print(digitSum)


Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Integer[] p = new Integer[m];
        Integer[] y = new Integer[m];
        Map<Integer, PriorityQueue<Integer>> map = new HashMap<>();
        for (int i = 1; i <= n; i++) {
            map.put(i, new PriorityQueue<Integer>());
        }
        for (int i = 0; i < m; i++) {
            p[i] = Integer.parseInt(sc.next());
            y[i] = Integer.parseInt(sc.next());
            map.get(p[i]).add(y[i]);
        }
        sc.close();

        // 主処理
        Map<Integer, Integer> birthNumberMap = new HashMap<>();
        for (int i = 1; i <= n; i++) {
            int num = 1;
            while (!map.get(i).isEmpty()) {
                birthNumberMap.put(map.get(i).poll(), num);
                num++;
            }
        }

        List<String> list = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            String left = String.format("%06d", p[i]);
            String right = String.format("%06d", birthNumberMap.get(y[i]));
            list.add(left + right);
        }

        String result = String.join("\r\n", list);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 137500
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  bool ans=false;
  cin>>n;
  int a=n/4;
  int b=n/7;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      if(i*4+j*7==n)ans=true;
    }
  }
  if(ans==true)puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def solve(A: int, B: int, C: int):
    cut = []
    cut.append(A * B * C - 2 * (A // 2) * B * C)
    cut.append(A * B * C - 2 * (B // 2) * A * C)
    cut.append(A * B * C - 2 * (C // 2) * B * A)
    print(min(cut))


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools
# (tips: You use the default template now. You can remove this line by
# using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,m;
  cin >> n >> m;
  vi a(3,-1);
  rep(i,m){
    int s,c;
    cin >>s >>c;
    s--;
    if(a[s] != -1){
      if(a[s] == c)continue;
      cout<<-1<<endl;
      return 0;
    }
    a[s] = c;
  }
  if(a[0] ==0 ){
    if(n == 1){
      cout<< 0 <<endl;
    }
    else  cout<<-1<<endl;
      return 0;
  }
  if(n == 1 && m == 0){
    cout<<0<<endl;
    return 0;
  }
  if(a[0] == -1) a[0] = 1;
  srep(i,1,n)if(a[i] == -1) a[i] = 0;
  rep(i,n)cout<<a[i];
  cout<<endl;
  return 0;
}

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

#define _ { \
	ios_base::sync_with_stdio(false); \
    cin.tie(NULL); \
}

int main(){
   _;
 string s;cin>>s;
 int n=s.length();
 if(n&1)cout<<"No";
 else {
     for(int i=0;i<n;i+=2){
         if(s[i]=='h'&&s[i+1]=='i')continue;
         else{
             cout<<"No";return 0;
         }
         
     }
     cout<<"Yes";return 0;
 }

}

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

int main(){
    int N,M;
    cin>>N>>M;
    vector<long long> a(N),b(N),c(M),d(M);
    for(int i=0;i<N;i++) cin>>a[i]>>b[i];
    for(int i=0;i<M;i++) cin>>c[i]>>d[i];

    int space[N]={};
    long long mi;
    long long tmp;

    for(int i=0;i<N;i++){
        mi = abs(a[i]-c[0])+abs(b[i]-d[0]);
        space[i] = 1;
        for(int j=1;j<M;j++){
            tmp = abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(tmp<mi){
                mi=tmp;
                space[i] = j+1;
            }
        }
    }

    for(int i=0;i<N;i++) cout<<space[i]<<endl;
    //for(int i=0;i<N;i++) cout<<a[i]<<b[i]<<endl;
    //for(int i=0;i<M;i++) cout<<c[i]<<d[i]<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    int n, x, mi, sum = 0, in;
    scanf("%d %d %d", &n, &x, &mi);
    sum += mi;
    for (int i = 1; i < n; ++i){
        scanf("%d", &in);
        sum += in;
        if (in < mi) mi = in;
    }
    printf("%d\n", (int)(n + floor(1.0 * (x - sum) / mi)));
    return 0;
}


Measured memory_bytes: 256
package main

import (
    "bufio"
    "fmt"
    "os"
    "strconv"
    "strings"
)

// 組み合わせの数
func main() {
	sc := bufio.NewScanner(os.Stdin)
		sc.Scan()
		ary := strings.Split(sc.Text(), " ")
		n, _ := strconv.Atoi(ary[0])
		fmt.Println(n * n * n)
}



Measured memory_bytes: 1096
#include <iostream>
#include <algorithm>

using namespace std;

int gcd(int a, int b)
{
  int smaller = min(a, b);
  int bigger = max(a, b);
  int surplus = bigger % smaller;
  if(surplus == 0) return smaller;
  surplus = gcd(smaller, surplus);
  return surplus;
}
int main()
{
  int a, b;
  cin >> a >> b;
  cout << gcd(a, b) << endl;
  return 0;
}


Measured memory_bytes: 3116
#include <stdio.h>
#include <stdbool.h>

typedef enum
{
    MEIJI, TAISHO, SHOWA, HEISEI, PREMEIJI
}Era_name;

Era_name judge_era_name(int year, int month, int day);

int main()
{
    int year, month, day;
    Era_name era_name;

    while (true) {
        if (scanf("%d %d %d", &year, &month, &day) == EOF) {
            break;
        } else {
            era_name = judge_era_name(year, month, day);
            switch (era_name) {
                case MEIJI:
                    printf("meiji %d %d %d\n", year - 1867, month, day);
                    break;
                case TAISHO:
                    printf("taisho %d %d %d\n", year - 1911, month, day);
                    break;
                case SHOWA:
                    printf("showa %d %d %d\n", year - 1925, month, day);
                    break;
                case HEISEI:
                    printf("heisei %d %d %d\n", year - 1988, month, day);
                    break;
                case PREMEIJI:
                    printf("pre-meiji\n");
                    break;
                default:
                    break;
            }
        }
    }
    return 0;
}

Era_name judge_era_name(int year, int month, int day)
{
    if (year < 1868) {
        return PREMEIJI;
    }
    if (year == 1868) {
        if (month < 9) {
            return PREMEIJI;
        } else if (month == 9) {
            if (day < 8) {
                return PREMEIJI;
            } else {
                return MEIJI;
            }
        } else {
            return MEIJI;
        }

    }
    if (year > 1868 && year < 1912) {
        return MEIJI;
    }
    if (year == 1912) {
        if (month < 7) {
            return MEIJI;
        } else if (month == 7) {
            if (day < 30) {
                return MEIJI;
            } else {
                return TAISHO;
            }
        } else {
            return TAISHO;
        }
    }
    if (year > 1912 && year < 1926) {
        return TAISHO;
    }
    if (year == 1926) {
        if (month < 12) {
            return TAISHO;
        } else if (month == 12) {
            if (day < 25) {
                return TAISHO;
            } else {
                return SHOWA;
            }
        } else {
            return SHOWA;
        }
    }
    if (year > 1926 && year < 1989) {
        return SHOWA;
    }
    if (year == 1989) {
        if (month < 1) {
            return SHOWA;
        } else if (month == 1) {
            if (day < 8) {
                return SHOWA;
            } else {
                return HEISEI;
            }
        } else {
            return HEISEI;
        }
    }
    if (year > 1989) {
        return HEISEI;
    }
}

Measured memory_bytes: 608
import random
import time
t_start = time.time()

d = int(input())
c_l = list(map(int,input().split()))
s_l = [list(map(int,input().split())) for i in range(d)]


def calc_score(contest_num, last_l):
  contest_val = s_l[day][contest_num]
  point = contest_val

  temp_last_l = last_l[:]
  temp_last_l[contest_num] = day


  for i in range(26):
    point -= c_l[i] * (day - temp_last_l[i])

  return point


last_l = [-1 for i in range(26)]
ans = []
ans_p = []

point = 0
for day in range(d):
  each_point = 0
  each_contest_num = 0

  for temp_contest_num in range(26):
    temp_point = calc_score(temp_contest_num, last_l)

    if temp_point > each_point:
      each_point = temp_point
      each_contest_num = temp_contest_num

  last_l[each_contest_num] = day
#  ans.append(each_contest_num + 1)
  ans.append(each_contest_num)
  ans_p.append(each_point)
#  print(last_l)

def cp(t_l):
  ans = 0
  for day in range(d):
    contest_num = t_l[day]
    contest_num -= 1

    contest_val = s_l[day][contest_num]

    ans += contest_val
    last_l[contest_num] = day

    for i in range(26):
      ans -= c_l[i] * (day - last_l[i])

  return ans
#    print(ans)

cnt = 0
elapsed_time = time.time() - t_start
while elapsed_time < 1.70:
  cnt += 1
  change_day = random.randint(0, len(ans)-1)
  old_contest_num = ans[change_day]
  old_point = sum(ans_p)
  new_contest_num = random.randint(0, 26)

  ans[change_day] = new_contest_num
  new_point = cp(ans)
  if new_point < old_point:
    ans[change_day] = old_contest_num

  elapsed_time = time.time() - t_start

#print(cnt)
for i in ans:
  print(i+1)

#print(sum(ans_p))

Measured memory_bytes: 81824
abcd = str(input())
ans = ''

for i in range(2**(len(abcd)-1)):
  total = int(abcd[0])
  ans = abcd[0]
  for j in range(len(abcd)-1):
    if (i >> j) & 1:
      total += int(abcd[j+1])
      ans = ans + '+' + abcd[j+1]
    else:
      total -= int(abcd[j+1])
      ans = ans + '-' + abcd[j+1]
  if total == 7:
    ans = ans + '=7'
    break
print(ans)

Measured memory_bytes: 9212
import sys
from itertools import combinations


def main():
    input = sys.stdin.buffer.readline
    _n = int(input())
    d = list(map(int, input().split()))
    ans = 0
    for i, j in combinations(d, 2):
        ans += i * j
    print(ans)


if __name__ == "__main__":
    main()



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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

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

template<typename T>
void cmpmax(T* reference, T value) {
	*reference = max(*reference, value);
}

template<typename T>
void cmpmin(T* reference, T value) {
	*reference = min(*reference, value);
}

const ll mod = 1000000007;

static const ll INF = 1e15;

class Primes {
private:
	vector<int> Prime_Number;
	vector<bool> is_prime_;
public:
	Primes(int N) {
		is_prime_.resize(N + 1, true);
		is_prime_[0] = is_prime_[1] = false;
		for (int i = 0; i < N + 1; i++) {
			if (is_prime_[i]) {
				Prime_Number.push_back(i);
				for (int j = 2 * i; j <= N; j += i) is_prime_[j] = false;
			}
		}
	}
	int operator[](int i) { return Prime_Number[i]; }
	int size() { return Prime_Number.size(); }
	int back() { return Prime_Number.back(); }
	bool isPrime(int q) { return is_prime_[q]; }
};

class Divisor {
private:
	vector<ll> F;
	vector<pair<ll, ll>> pfactorize;
public:
	Divisor(ll N) {
		for (ll i = 1; i * i <= N; i++) {
			if (N % i == 0) {
				F.push_back(i);
				if (i * i != N) F.push_back(N / i);
			}
		}
		sort(begin(F), end(F));
		Primes p((ll)sqrt(N) + 1);
		for (int i = 0; i < p.size(); i++) {
			pfactorize.emplace_back(p[i], 0);
			while (N % p[i] == 0) {
				N /= p[i];
				pfactorize.back().second++;
			}
			if (pfactorize.back().second == 0) pfactorize.pop_back();
		}
		if (N > 1) pfactorize.emplace_back(N, 1);
	}
	int size() { return F.size(); }
	const vector<pair<ll, ll>>& pfac() { return pfactorize; } const
		ll operator[](int k) { return F[k]; }
};

int main() {
	ll n;
	cin >> n;
	Divisor d(n);
	ll up = 0;
	for (auto p : d.pfac()) {
		ll r = p.second;
		int i = 1;
		while (r > 0) {
			r -= i;
			if (r >= 0) {
				up++;
			}
			i++;
		}
	}
	cout << up << endl;
	return 0;
}
	


Measured memory_bytes: 4048
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

N, K = mi()
    
cnt_n = 0
ini_n = K
while ini_n <= N:
    cnt_n += 1
    ini_n += K

ans = cnt_n ** 3

if K % 2 == 0:
    ini_k = K // 2
    cnt_k = 0
    while ini_k <= N:
        cnt_k += 1
        ini_k += K
    ans += cnt_k ** 3

print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main(){
    ll a,b,ans=0;
    cin >> a >> b;
    vector<ll> c(5);
    for(ll i=a;i<=b;i++){
        ll x=i;
        for(ll j=0;j<5;j++){
            c[j]=x%10;
            x/=10;
        }
        if(c[0]==c[4]&&c[1]==c[3]) ans++;
    }
    cout << ans << endl;

    return 0;
}





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

int main() {
  long long N;
  cin >> N;
  deque<int> que;
  bool flag = false;
  while (N != 0){
    if (flag == true){
      N -= 1;
      flag = false;
      continue;
    }
    que.push_back(N % 26);
    if (N % 26 == 0) flag = true;
    N /= 26;
  }
  string S = "";
  int count = que.size();
  while (!que.empty()){
    int a = que.front();
    que.pop_front();
    char b = 'a' + a - 1;
    if (a == 0) b = 'z';
    S = b + S;
  }
  cout << S << endl;
}

Measured memory_bytes: 3600
#include<stdio.h>

int main(void)
{
	int x,y,tmp;
	y=x=999;
	for( ; 0 != x || 0 != y; ) {
		scanf( "%d%d",&x,&y );
		if( 0 != x || 0 != y ) {
			if( y < x ) {
				tmp=y;
				y=x;
				x=tmp;
			}
			printf( "%d %d\n", x, y );
		}
	}
	return 0;
}

Measured memory_bytes: 600
n = int(input())
links = [[] for _ in range(n + 1)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    links[u].append((v, w))
    links[v].append((u, w))
ans = [-1] * (n + 1)
q = [(1, 0, 0)]
while q:
    v, d, p = q.pop()
    ans[v] = d
    for u, w in links[v]:
        if u == p:
            continue
        q.append((u, d + w, v))
print('\n'.join(map(lambda x: str(x % 2), ans[1:])))

Measured memory_bytes: 49072
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN=5e5+5;
int n;
int h[MAXN];
void maxHeapify (int cur) {
	int l=(cur<<1),r=l+1,mx=cur;
	if (l<=n&&h[l]>h[mx]) mx=l;
	if (r<=n&&h[r]>h[mx]) mx=r;
	if (mx!=cur) {
		swap (h[cur],h[mx]);
		maxHeapify (mx);
	}
}
int main () {
    scanf ("%d",&n);
    for (int i=1;i<=n;i++) {
    	scanf ("%d",&h[i]);
	}
	for (int i=(n>>1);i>0;i--) {
		maxHeapify (i);
	}
	for (int i=1;i<=n;i++) {
		printf (" %d",h[i]);
	}
	printf ("\n");
    return 0;
}


Measured memory_bytes: 4620
#include<stdio.h>
int main()
{
    int n,count=1;;
    char a[5],c;
    scanf("%d",&n);
    sprintf(a,"%d",n);
    c=a[0];
    int i;
    for(i=1;i<4;i++)
    {
        if(c==a[i])
            count++;
        else
        {
            if(count>=3)
                break;
            else
            {
                count=1;
                c=a[i];
            }
        }

    }
    if(count>=3)
        printf("Yes");
    else
    printf("No");
}


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

int main() {

    int N;
    cin >> N;

    list<int> l;
    string command;
    int num;

    for (int i = 0; i < N; i++) {
        cin >> command;
        if (command == "insert") {
            cin >> num;
            l.push_front(num);
        }
        else if (command == "delete") {
            cin >> num;
            for (auto itr = l.begin(); itr != l.end() ; itr++) {
                if (*itr == num) {
                    l.erase(itr);
                    break;
                }
            }
        }
        else if (command == "deleteFirst") {
            l.pop_front();
        }
        else if (command == "deleteLast") {
            l.pop_back();
        }
    }

    for (auto itr = l.begin(); itr != l.end(); itr++) {
        auto nitr = next(itr, 1);
        if (nitr == l.end()) {
            cout << *itr << endl;
        }
        else {
            cout << *itr << " ";
        }
    }


    return 0;
}



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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(200005), cnt(200005);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cnt[a[i]]++;
    }
    ll sum = 0;
    for(int i = 0; i < 200005; i++){
        if(cnt[i] >= 2){
            sum += cnt[i]*(cnt[i]-1)/2;
        }
    }
    for(int i = 0; i < n; i++){
        cout << sum - (cnt[a[i]] - 1) << endl;
    }
}

Measured memory_bytes: 6436
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int v[51];
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
	}
	sort(v,v+n);
	double d=v[0];
	for(int j=1;j<n;j++)
	{
		d=(d+v[j])*1.0/2.0;
	}
	printf("%.5f",d);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    ll n; cin >> n;
    ll s = 0;
    for(ll i = 1; i <= n; i++)
    {
        s += (n - 1) / i;
    }
    cout << s;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>

using namespace std;
const int MAX_T = 100100;
long long weight[110], value[110];
long long dp[110][100100];

template<class T> void chmin(T & a, T b) {
	if (a > b) a = b;
}

template<class T> void chmax(T & a, T b) {
	if (a < b) a = b;
}

int main() {
	int N, W; cin >> N >> W;
	
	for (int i = 0; i < N; i++) {
		scanf("%lld%lld", &weight[i], &value[i]);
	}

	for (int i = 0; i < N; i++) {
		for (int sum_w = 0; sum_w < 100100; sum_w++) {
			if (sum_w - weight[i] >= 0) {
				chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
			}
			chmax(dp[i + 1][sum_w], dp[i][sum_w]);
		}
	}

	cout << dp[N][W] << endl;

	return 0;
}

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


// A[i]~A[j] を2つに分ける位置を探す
void divideHalf( long long& F, long long& S, int i, int j, vector<long long>& A )
{
    // それぞれの和が同じくらいになる位置を二部探索
    long long s = A[j]-A[i];
    auto itr_l = lower_bound(A.begin()+i, A.begin()+j+1, s/2+A[i]);
    auto itr_s = itr_l--;
    // abs(F-S) = abs( 2*(*itr) - (A[i]+A[j]) ) を小さくする方を採用する
    if( abs( 2*(*itr_l)-(A[i]+A[j]) ) < abs( 2*(*itr_s)-(A[i]+A[j]) ) ){
        F = *itr_l-A[i];
        S = A[j]-*itr_l;
    }else{
        F = *itr_s-A[i];
        S = A[j]-*itr_s;
    }
}


int main()
{
    int N;
    cin >> N;
    vector<long long> A(N+1, 0);
    for( int i = 1; i <= N; ++i ) cin >> A[i];


    // 累積話
    for( int i = 1; i <= N; ++i ) A[i] += A[i-1];

    long long ans = 1e+15;
    // 真ん中の分割点について全探索
    for( int i = 2; i <= N-2; ++i ){
        long long P, Q, R, S;
        divideHalf(P, Q, 0, i, A);  // 左側
        divideHalf(R, S, i, N, A);  // 右側
        ans = min( ans, max({P,Q,R,S}) - min({P,Q,R,S}) );
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
using namespace std;
int main(void)
{
    long long l,r,mn=4e18;
    scanf("%lld %lld" ,&l,&r);
    if(l/2019!=r/2019)
    {
        printf("0");
        return 0;
    }
    for(long long i=l;i<=r;i++)
        for(long long j=i+1;j<=r;j++)
        {
//            mn=min(mn,(i%2019)*(j%2019)%2019);
            mn=min(mn, i*j%2019);
        }
    printf("%d" ,mn);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

inline void solve(){
  int r,g,b,n;
  cin >> r >> g >> b >> n;
  int ans = 0;
  
  for(int i=0;i*r <= n;i++){
    for(int j = 0;j*g<=n;j++){
      int tmp = n - (r*i +g*j);
      if(tmp >= 0 && tmp%b==0){
          
        ans++;
      }
    }
  }

  cout << ans fin;
}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
vector<int>sw[60];
int n,m,ans;

int p[60],temp[60];
bool vis[60];
 
void dfs(int x)
{
    if(x==n+1)
    {
        memset(temp,0,sizeof(temp));
        for(int i=1;i<=n;i++)
        {
            if(!vis[i]) continue;
            for(int j=0;j<sw[i].size();j++)
            {
                int b=sw[i][j];
                temp[b]++;
            }
        }
        for(int i=1;i<=m;i++) if(temp[i]%2!=p[i]) return ;
        ans++;
        return ;
    }
    dfs(x+1);
    vis[x]=true;
    dfs(x+1);
    vis[x]=false;
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int k;
        cin>>k;
        for(int j=0;j<k;j++)
        {
            int t;
            cin>>t;
            sw[t].push_back(i);
        }
    }
    for(int i=1;i<=m;i++) cin>>p[i];
    dfs(1);
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>

using namespace std;

#define LL long long

LL n,ans;

int main() {
    scanf("%lld",&n);
    ans = (n - 1) / 2;
    printf("%lld\n",ans);
//    system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#define MAX_N 2005

using namespace std;

int n,K,ans=0;
int s[MAX_N][MAX_N];

void read()
{
	scanf("%d%d",&n,&K);
	int x,y; char c[4];
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%s",&x,&y,c);
		if(c[0]=='W') y+=K;
		s[x%(K<<1)][y%(K<<1)]++;
	}
	/*for(int i=0;i<(K<<1);i++)
	{
		for(int j=0;j<(K<<1);j++)
		{
			cout<<s[i][j]<<" ";
		}
		cout<<endl;
	}*/
}

void cal_s()
{
	for(int i=0;i<(K<<1);i++)
	{
		for(int j=0;j<(K<<1);j++)
		{
			if(i) s[i][j]+=s[i-1][j];
			if(j) s[i][j]+=s[i][j-1];
			if(i && j) s[i][j]-=s[i-1][j-1];
		}
	}
}

inline void to_valid(int &x)
{
	x=min((K<<1)-1,max(0,x));
}

inline bool is_valid(int &l,int &d,int &r,int &u)
{
	l=max(l,0),d=max(d,0),r=min(r,(K<<1)-1),u=min(u,(K<<1)-1);
	// cout<<"  to_valid: l = "<<l<<" d = "<<d<<" r = "<<r<<" u = "<<u<<endl;
	return l<=r && d<=u;
}

inline int get_s(int l,int d,int r,int u)
{
	if(!is_valid(l,d,r,u)) return 0;
	int ans=s[r][u];
	if(l>0) ans-=s[l-1][u];
	if(d>0) ans-=s[r][d-1];
	if(l>0 && d>0) ans+=s[l-1][d-1];
	return ans;
}

inline int get_ans(int x,int y)
{
	int ans=0;
	// cout<<"get_ans: x = "<<x<<" y = "<<y<<endl;
	ans+=get_s(x,y,x+K-1,y+K-1);
	// cout<<" (md) ans = "<<ans<<endl;
	ans+=get_s(x-K,y-K,x-1,y-1);
	// cout<<" (ld) ans = "<<ans<<endl;
	ans+=get_s(x-K,y+K,x-1,y+(K<<1)-1);
	// cout<<" (lu) ans = "<<ans<<endl;
	ans+=get_s(x+K,y-K,x+(K<<1)-1,y-1);
	// cout<<" (rd) ans = "<<ans<<endl;
	ans+=get_s(x+K,y+K,x+(K<<1)-1,y+(K<<1)-1);
	// cout<<" (ru) ans = "<<ans<<endl;
	return ans;
}

void work()
{
	cal_s();
	for(int i=0;i<K;i++)
	{
		for(int j=0;j<K;j++)
		{
			int now=get_ans(i,j);
			ans=max(ans,max(now,n-now));
			// cout<<" i = "<<i<<" j = "<<j<<" ans = "<<ans<<endl;
		}
	}
	printf("%d\n",ans);
}

int main()
{
	read();
	work();
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int k;
    cin>>k;
    vector<ll> a(k);
    rep(i,k) cin>>a[i];
    
    ll MIN,MAX;
    {
        ll ok=LINF,ng=0;
        while(ok-ng>1) {
            ll mid=(ok+ng)/2;
            ll kids=mid;
            rep(i,k) {
                kids-=kids%a[i];
            }
            (kids>=2 ? ok : ng)=mid;
        }
        MIN=ok;
    }
    {
        ll ok=0,ng=LINF;
        while(ng-ok>1) {
            ll mid=(ok+ng)/2;
            ll kids=mid;
            rep(i,k) {
                kids-=kids%a[i];
            }
            (kids<=2 ? ok : ng)=mid;
        }
        MAX=ok;
    }
    
    if(MIN>MAX) cout<<-1<<endl;
    else cout<<MIN<<" "<<MAX<<endl;
}


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

signed main(){
	int N;
	cin >> N;
	vector<int> A(N);
	set<int> s;
	int cnt = 0;
	for(int i = 0; i < N; ++i) {
		cin >> A[i];
		if(s.find(A[i]) != s.end()){
			cnt++;
		} else {
			s.insert(A[i]);
		}
	}
	if(cnt % 2 == 0) {
		cout << N - cnt << endl;
	} else {
		cout << N - cnt - 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
char a[10001];
int main()
{
	int pd=0,w=0;
	cin>>a;
	int lena=strlen(a);
	for(int i=0;i<=lena-1;i++)
	{
		if(a[i]=='C'&&pd==0)
		{
			pd++;
		}
		if(a[i]=='F'&&pd==1)
		{
			w++;
			break;
		}
	}
	if(w==1)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long dp[100][100001];
long long solve(int item_no,int capacity,vector<pair<int,long long>> &wv) {
  if (item_no >= wv.size()) return 0;
  if (dp[item_no][capacity]!=-1) return dp[item_no][capacity];
  long long res = 0;
  if (wv[item_no].first <= capacity) {
    res = wv[item_no].second + solve(item_no+1,capacity-wv[item_no].first,wv);
  }
  res = max(res,solve(item_no+1,capacity,wv));
  dp[item_no][capacity] = res;
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  for(int i=0;i<100;i++) {
    for(int j=0;j<100001;j++) {
      dp[i][j] = -1;
    }
  }
  int n,W;
  cin >> n >> W;
  vector<pair<int,long long>> wv(n);
  for(int i=0;i<n;i++) {
    cin >> wv[i].first >> wv[i].second;
  }
  cout << solve(0,W,wv);
  return 0;
}

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

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

using namespace std;

int main() {
    long int N;
    cin >> N;
    
    vector<long int> d(N);
    rep(i, N) {
        cin >> d[i];
    }
    
    sort(d.begin(), d.end());
    
    int d_sizehalf=d.size()/2;
    
    if(d[d_sizehalf]==d[d_sizehalf-1]) {
        cout << 0 << endl;
    } else {
        cout << d[d_sizehalf]-d[d_sizehalf-1] << endl;
    }
    
    

    return 0;
    
}

Measured memory_bytes: 1024