akhauriyash/Code-Regression huggingface dataset:
#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++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int m1, d1; cin >> m1 >> d1;
    int m2, d2; cin >> m2 >> d2;

    if(m1 == m2) cout << 0 << endl;
    else cout << 1 << endl;

    
    return 0;
}

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

using namespace std;

int gcd(int i, int j) {

	//ユークリッドの互除法で最大公約数を求める
	//2変数の場合

	if (i < j) { swap(i, j); }

	while (i%j != 0) {
		int r;
		r = i % j;
		if (r == 0) { return j; }
		else { i = j; j = r; }
	}
	return j;
}


int main() {

	int k;
	cin >> k;

	int gc = 0;
	int total = 0;
	for (int i1 = 1; i1 <= k; i1++) {
		for (int i2 = 1; i2 <= k; i2++) {
			for (int i3 = 1; i3 <= k; i3++) {
				gc = gcd(i1, i2);
				total+= gcd(gc, i3);
			}
		}
	}

	cout << total << endl;



}

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

const int MAXN = 1<<17;
const int UNSET = -1;


vector<vector<int>> g;
int dp[MAXN], indeg[MAXN];






int main () {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int N, M; cin >> N >> M;
  g.resize(N);

  for (int i = 0; i < M; ++i) {
    int u, v; cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    ++indeg[v];
  }

  vector<int> topo;

  {
    stack<int> q;
    for (int u = 0; u < N; ++u) {
      if (indeg[u] == 0) q.push(u);
    }

    while (q.size()) {
      int u = q.top(); q.pop();
      topo.push_back(u);
      for (int v : g[u]) {
        --indeg[v];
        if (indeg[v] == 0) {
          q.push(v);
        }
      }
    }
  }

  for (int i = N - 1; i >= 0; --i) {
    int u = topo[i];
    for (auto v : g[u]) {
      dp[u] = max(dp[v] + 1, dp[u]);
    }
  }


  cout << *max_element(dp, dp + N) << '\n';



}


Measured memory_bytes: 7032
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<lol, lol>;
typedef vector<int> vit;

/*
struct SegmentTree{
  
  vector<lol> SumV(1000005,0);
  vector<lol> MaxV(1000005,0);
  vector<lol> MinV(1000005,0);
  int N;
  
  void update(int i,int x){
    i += N - 1;
    minv[i] = x;
    maxv[i] = x;
    sumv[i] = x;
    while(i > 0){
      i = (i - 1)/2;
      maxv[i] = max(maxv[i*2+1],maxv[i*2+2]);
      minv[i] = min(minv[i*2+1],minv[i*2+2]);
      sumv[i] = sumv[i*2+1]+sumv[i*2+2];
    }
  }
  
  void add(int i,int x){
    i += N - 1;
    sumv[i] += x;
    maxv[i] += x;
    minv[i] += x;
    while(i > 0){
      i = (i - 1)/2;
      sumv[i] = sumv[i*2+1]+sumv[i*2+2];
      minv[i] = min(minv[i*2+1],minv[i*2+2]);
      maxv[i] = max(maxv[i*2+1],maxv[i*2+2]);
    }
  }
  
  int getmax(int a,int b,int k,int l,int r){
    if(r <= a || b <= l) return -INF;
    if(a <= l && r <= b) return maxv[k];
    else{
      int c1 = getmax(a,b,2*k+1,l,(l+r)/2);
      int c2 = getmax(a,b,2*k+2,(l+r)/2,r);
      return max(c1,c2);
    }
  }
  
  int getmin(int a,int b,int k,int l,int r){
    if(r <= a || b <= l) return INF;
    if(a <= l && r <= b) return minv[k];
    else{
      int c1 = getmin(a,b,2*k+1,l,(l+r)/2);
      int c2 = getmin(a,b,2*k+2,(l+r)/2,r);
      return min(c1,c2);
    }
  }
  
  int getsum(int a,int b,int k,int l,int r){
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return sumv[k];
    else{
      int c1 = getsum(a,b,2*k+1,l,(l+r)/2);
      int c2 = getsum(a,b,2*k+2,(l+r)/2,r);
      return c1+c2;
    }
  }
}
*/

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}
//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int h, w, k;
  cin >> h >> w >> k;
  char c[10][10];
  rep(i, h){
    rep(j, w){
      cin >> c[i][j];
    }
  }

  lol ans = 0;
  rep(bit, (1 << h)){
    rep(bits, (1 << w)){

      int sum = 0;
      rep(i, h){
	if(bit & (1 << i)){
	  continue;
	}
	rep(j, w){
	  if(bits & (1 << j)){
	    continue;
	  }
	  if(c[i][j] == '#'){
	    sum ++;
	  }
	}
      }
      if(sum == k){
	ans ++;
      }
      
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <string>

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;

int wl[2000][2000];
int hl[2000][2000];

void fill_wl(const vector<string>& ss, int w, int h) {
  for (int y = 0; y < h; ++y) {
    int x = 0;
    while (x < w) {
      int l = 0;
      for (int z = x; z < w && ss[y][z] == '.'; ++l, ++z) {}
      if (l == 0) {
        wl[y][x] = 0;
        ++x;
      } else {
        for (int z = x; z < x + l; ++z) {
          wl[y][z] = l;
        }
        x += l;
      }
    }
  }
}

void fill_hl(const vector<string>& ss, int w, int h) {
  for (int x = 0; x < w; ++x) {
    int y = 0;
    while (y < h) {
      int l = 0;
      for (int v = y; v < h && ss[v][x] == '.'; ++l, ++v) {}
      if (l == 0) {
        hl[y][x] = 0;
        ++y;
      } else {
        for (int v = y; v < y + l; ++v) {
          hl[v][x] = l;
        }
        y += l;
      }
    }
  }
}

int max_light(const vector<string>& ss, int w, int h) {
  fill_wl(ss, w, h);
  fill_hl(ss, w, h);
  int c = 0;
  for (int y = 0; y < h; ++y) {
    for (int x = 0; x < w; ++x) {
      if (c < wl[y][x] + hl[y][x] - 1) {
        c = wl[y][x] + hl[y][x] - 1;
      }
    }
  }
  return c;
}

int main(int argc, char* argv[]) {
  int h, w;
  cin >> h >> w;
  std::vector<string> ss(h);
  for (int i = 0; i < h; ++i) {
    cin >> ss[i];
  }
  cout << max_light(ss, w, h) << endl;
  return 0;
}


Measured memory_bytes: 35584
import sys
input=sys.stdin.readline
n=int(input())
S=input()
nagasa=len(list(S))
num=2**(nagasa-1).bit_length()
SEG=[0]*2*num
def word_num(a):
    return 1<<(ord(a)-96)
def init(S):
    for i in range(n):
        SEG[i+num-1]=word_num(S[i])
    for i in range(num-2,-1,-1) :
        SEG[i]=SEG[2*i+1]|SEG[2*i+2]
    
def update(k,x):
    k += num-1
    SEG[k] = word_num(x)
    while k:
        k-=1
        k//=2
        SEG[k] = SEG[k*2+1] | SEG[k*2+2]
    
def query(p,q):
    if q<=p:
        return 0
    p += num-1
    q += num-2
    ans=0
    while q-p>1:
        if p&1 == 0:
            ans|= SEG[p]
        if q&1 == 1:
            ans|= SEG[q]
            q -= 1
        p //=2
        q-=1
        q//=2
    if p == q:
        ans |=SEG[p]
    else:
        ans |= SEG[p]
        ans |= SEG[q]
    return ans
init(S)
q=int(input())
for i in range(q):
    a,s,t=input().split()
    if a=='1':
        s=int(s)
        update(s-1,t)
    if a=='2':
        s=int(s)
        t=int(t)
        print(bin(query(s-1,t)).count('1'))


Measured memory_bytes: 44240
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import numpy as np
    n,m,x=map(int, input().split())
    l=[list(map(int,input().split())) for i in range(n)]
    kanel=[]
    for i in range(2 ** n):
        kaul = np.array([0] * (m+1))
        for j in range(n): 
            if ((i >> j) & 1):  
                l[j]=np.array(l[j])
                kaul=kaul+l[j]
        flag=True
        for k in kaul[1:]:
            if k<x:
                flag = False
                break

        if flag:
            kanel.append(kaul[0])
    if kanel==[]:
        print(-1)
    else:
        print(min(kanel))
resolve()

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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define REP(i,N) for(int i=0;i<N;i++)

int main()
{
    int w,h; cin>>w>>h;
    int x,y; cin>>x>>y;
    cout<<(double)w*(double)h/2.0<<" ";
    if(abs((double)w/2.0-(double)x) < 1e-5 && abs((double)h/2.0-(double)y) < 1e-5){
        cout<<1<<endl;
    } else {
        cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int W = sc.nextInt();
		if(S <= W){
			System.out.println("unsafe");
		}else{
			System.out.println("safe");			
		}
	}
}


Measured memory_bytes: 27076
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#define ll long long
#define MAX 1000003
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
using namespace std;

int main(){
  IOS;
  int n,b; cin>>n>>b;
  vector<vector<int>> a(n);
  for(int i=0;i<n;i++){
  	a[i].resize(b);
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<b;j++){
      cin>>a[i][j];
    }
  }
  int ctr=0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
   		double dist=0;
      	for(int k=0;k<b;k++){
          dist+=pow(a[i][k]-a[j][k],2);
        }
      	if(sqrt(dist)-floor(sqrt(dist))==0)
          ctr++;
    }
  }
  cout<<ctr<<endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var k, n int
	fmt.Scan(&k, &n)
	array := make([]int, n)
	for i := range array {
		fmt.Scan(&array[i])
		array = append(array, array[i]+k)
	}

	ans := make([]int, n)
	for i := 0; i < n; i++ {
		ans[i] = array[len(ans)-1+i] - array[i]

	}
	sort.Ints(ans)
	fmt.Println(ans[0])

}


Measured memory_bytes: 14720
s = STDIN.gets.chomp.split("")
if s.size == 1
  puts 0
  exit
end
diff1 = 0
diff2 = 0

cnt = 0
s.each{|c|
  if (cnt & 1) == 0
    if c != "0"
      diff1 += 1
    else
      diff2 += 1
    end
  else
    if c != "1"
      diff1 += 1
    else
      diff2 += 1
    end
  end
  cnt += 1
  }

if diff1 < diff2
  puts diff1
else
  puts diff2
end

Measured memory_bytes: 9468
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();

        TreeSet<Integer> moneySet = new TreeSet<>();
        moneySet.add(1);
        int tmp = 6;
        while (tmp <= 100000) {
            moneySet.add(tmp);
            tmp *= 6;
        }
        tmp = 9;
        while (tmp <= 100000) {
            moneySet.add(tmp);
            tmp *= 9;
        }

        Set<Integer> set = new HashSet<>();
        set.add(0);
        for (int cnt = 0;; cnt++) {
            if (set.contains(n)) {
                System.out.println(cnt);
                break;
            }

            Integer array[] = set.toArray(new Integer[0]);
            set.clear();
            for (Integer num : array) {
                for (Integer money : moneySet) {
                    set.add(num + money);
                }
            }
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 220588
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
ll ncd(ll n,ll d){
    ll x = 1,y=1;
    for(int i=0;i<d;i++){
        x = x*(n-i)%mod;
        y = y*(i+1)%mod;
    }
    return x*modpow(y,mod-2,mod)%mod;
}
int main() {    
    srand(time(NULL));
    ll d;
    cin >> d;
    d-=26;
    vector<ll>c(26);
    for(int i=0;i<26;i++)cin>> c.at(i);
    ll che[d][26];
    for(int i=0;i<d;i++){
        for(int j=0;j<26;j++){
            cin >> che[i][j];
        }
    }
    for(int i=0;i<26;i++){
        cout<<i+1<<endl;
    }
    for(int i=0;i<d;i++){

          cout<<rand()%26+1<<endl;  
    }
}
    



Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int n,k;cin>>n>>k;
  vector<int> a(n);rep(i,n)cin>>a[i];
  rep(i,k){
    vector<int> b(n,0);
    rep(j,n){
      b[max(0,j-a[j])]++;
      int r = min(n-1,j+a[j]);
      if(r+1 < n)b[r+1]--;
    }
    rep(j,n)if(j)b[j] += b[j-1];
    
    bool isAllN = true;
    rep(j,n){
      a[j] = b[j];
      isAllN &= a[j] == n;
    }
    if(isAllN)break;
  }

  rep(i,n)cout<<a[i]<<" ";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
int nr;
char s[50];
int main()
{
    //ifstream cin ("a.in");
    //ofstream cout ("a.out");
    cin>>s;
    nr=(s[0]-'0')*1000+(s[1]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
    if(nr<2019)
    {
        cout << "Heisei";
        return 0;
    }
    if(nr>2019)
    {
        cout << "TBD";
        return 0;
    }
    nr=(s[5]-'0')*10+s[6]-'0';
    if(nr<4)
    {
        cout << "Heisei";
        return 0;
    }
    if(nr>4)
    {
        cout << "TBD";
        return 0;
    }
    nr=(s[8]-'0')*10+s[9]-'0';
    if(nr<=30)
    {
        cout << "Heisei";
        return 0;
    }
    else
    {
        cout << "TBD";
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
n, m = (int(x) for x in input().split())
ps = []
for _ in range(m):
    p, s = (x for x in input().split())
    ps.append([int(p), s])
ans = [0] * n
pen = 0
tmp = [0] * n
for p, s in ps:
    if ans[p - 1] == 1:
        continue
    if s == 'WA':
        tmp[p - 1] += 1
    else:
        ans[p - 1] = 1
        pen += tmp[p - 1]
print(sum(ans), pen)

Measured memory_bytes: 23488
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> mp;
    REP(i, N){
        cin >> A[i];
        mp[A[i]]++;
    }

    bool can = true;
    if (N % 2 == 1) {
        if (mp[0] != 1) {
            can = false;
        }
        for(int i = 2; i < N;) {
            if (mp[i] != 2) {
                can = false;
                break;
            }
            i+=2;
        }
    } else {
        for(int i = 1; i < N;) {
            if (mp[i] != 2) {
                can = false;
                break;
            }
            i+=2;
        }
    }

    if (!can) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    for(int i = 0; i < N/2; i++) {
        ans *= 2;
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;
class ilds1_3_c{
  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    LinkedList<String> list = new LinkedList<String>();
    for(int i=0; i<n; i++){
      String[] str = Console.ReadLine().Split(' ');
      switch(str[0]){
        case "insert":
          list.AddFirst(str[1]);
          break;
        case "delete":
          list.Remove(str[1]);
          break;
        case "deleteFirst":
          list.RemoveFirst();
          break;
        case "deleteLast":
          list.RemoveLast();
          break;
      }
    }
    Console.WriteLine(string.Join(" ",list));
  }
}



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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint
{
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
};

mint f(int n)
{
    if(n==0)return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2==1) x*=2;
    return x;
}

mint combi(int n, int r){
    mint x = 1, y = 1;
    rep(i,r){
        // 分子
        x *= (n-i);
        // 分母
        y *= i+1;
    }
    return x/y;
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
    int n,k;
    cin >> n >> k;
  	k = min(k, n-1);
    combination c(n);
    mint ans=0;
    rep(i,k+1){
        ans += c(n,i)* c(n-1,i);
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(lint i=(lint)(n);i>0;--i)
#define reps(i,a,b) for(lint i=a;i<=(lint)(b);i++)
typedef long long lint;
typedef long double ld;
using namespace std;

int main(){
    string koyomi;
    cin >> koyomi;
    string cy = koyomi.substr(0,4);
    string cm = koyomi.substr(5,2);
    string cd = koyomi.substr(8,2);
    int y = atoi(cy.c_str());
    int m = atoi(cm.c_str());
    int d = atoi(cd.c_str());
    string res;
    if(y<2019) {res="Heisei";}
    else if(y>2019) {res="TBD";}
    else if(m<=4) {res="Heisei";}
    else if(m>4) {res="TBD";}
    cout << res << endl;
	return 0;
}

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

int main() {
    int A, B;

    cin >> A >> B;

    int ans = A + B;

    if (ans < A - B) {
        ans = A - B;
    }

    if (ans < A * B) {
        ans = A * B;
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
    string S;
    cin >> S;
    int ma = 0, cnt = 0;

    for (const auto& s: S){
        ma = max(ma, cnt);
        if (s == 'A' or s == 'T' or s == 'G' or s == 'C')
            cnt++;
        else
            cnt = 0;
    }

    ma = max(ma, cnt);
    cout << ma << endl;
}

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

int D;
long long G;
vector<int> ps, cs;

int main(){
  cin >> D >> G;
  ps.resize(D); cs.resize(D);
  for (int i = 0; i < D; i++) cin >> ps[i] >> cs[i];
  
  int ans = 1000;
  
  for (int mask = 0; mask < (1<<D); mask++) {
    long long total = 0;
    int num = 0;
    for (int i = 0; i < D; i++) {
      if (mask & (1<<i)) {
        total += 100 * (i + 1) * ps[i] + cs[i];
        num += ps[i];
      }
    }
    if (total < G) {
      for (int i = D - 1; i >= 0; i--) {
        if (!(mask & (1<<i))) {
          for (int j = 0; j < ps[i]; j++) {
            if (total < G) {
              total += 100 * (i + 1);
              num++;
            }
          }
        }
      }
    }
    ans = min(ans, num);
  }
  
  cout << ans << endl;
}

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


int main()
{
    queue<pair<string,int> > Q;
    
    int n,q;
    cin >> n >> q;

    int t;
    string name;

    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: 6292
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int ans[200010];

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

    for(int x = 1; x < 110; x++){
        for(int y = 1; y < 110; y++){
            for(int z = 1; z < 110; z++){
                int tmp = x*x + y*y + z*z + x*y + y*z + z*x;
                ans[tmp]++;
            }
        }
    }

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

    return 0;
}


Measured memory_bytes: 3824
#include <iostream>

using namespace std;

int main(int argc, char **argv) {
  string s;
  unsigned long long K;
  s.reserve(100000);
  cin >> s >> K;
  for (auto i = s.begin(); i < s.end(); ++i) {
    if (*i == 'a') continue;
    if ('z' - *i < K) {
      K -= 'z' - *i + 1;
      *i = 'a';
    }
  }
  K %= ('z' - 'a' + 1);
  K += s.back();
  if (K > 'z') {
    K -= ('z' - 'a' + 1);
  }
  s.back() = (char) K;
  cout << s;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define m 1000000007
using namespace std;

int main()
{
    long long n,k,q;
    cin>>n>>k;
    long long h[n+1],dp[n+1];
    h[0]=0;
    for (int i = 1; i <= n; ++i)
    {
        cin>>h[i];
    }
    dp[1]=0;
    for (long long i = 2; i <= n; ++i)
    {
        dp[i]=999999999999999999;
    }
    for (long long i = 1; i <= n; ++i)
    {
        for (long long j = 1; j <= k; ++j)
        {
            if(i>j)
            {
                dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
            }
        }
    }
    cout<<dp[n];
}

/*int main()
{
    long long t;
    cin>>t;
    string s1,s2;
    for (int i = 0; i < 2*k; ++i)
    {
        cin>>s1>>s2;
    }
    for (int i = s1.length(); i > 0; --i)
    {
        
    }
}*/

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int D = scan.nextInt();
        int T = scan.nextInt();
        int S = scan.nextInt();
        int result = 0;
        if(D%S == 0) result = D/S;
        else result = D/S +1;
        if(result <= T) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 35876
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
#include <set>

using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int n;
    cin >> n;
    int ans = 0;
    rep(i,1,n+1) {
        int count =0;
       rep(j,1,i+1) {
           if (i%j == 0 && j %2 == 1) {
               count++;
           }
       } 
       if (count == 8) {
           ans++;
       }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3124
import sys

#a, b = map(int, input().split(" "))
N = int(input())

arr = [0 for idx in range(100001)]

for i in range(1,10):
	if i >= 9:
		arr[i] = 1
	elif i >= 6:
		arr[i] = i - 5
	else:
		arr[i] = i;

six_mul = 6**2
nine_mul = 9**2
six_index = 6
nine_index = 9

for i in range(10, 100001):
	if i == six_mul:
		six_mul *= 6
		six_index *= 6
		arr[i] = 1
	elif i == nine_mul:
		nine_mul *= 9
		nine_index *= 9
		arr[i] = 1
	else:
		arr[i] = min(arr[i-1], min(arr[i-six_index], arr[i-nine_index]))+1
print(arr[N])

Measured memory_bytes: 3992
n = int(input())
a = list(map(int, input().split()))

flag = True

for i in range(n - 1, 0, -1):
    if a[i - 1] - a[i] > 1:
        flag = False
        break
    elif a[i - 1] - a[i] == 1:
        a[i - 1] -= 1
    
if flag:
    print('Yes')
else:
    print('No')

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

int main(){
    int N;
    long long int X;
    cin>>N>>X;
    
    vector<long long int> S(N+1),P(N+1);
    S[0]=1;P[0]=1;
        for(int i=1;i<=N;i++){
            S[i]=S[i-1]*2+3;
            P[i]=P[i-1]*2+1;
        }
    long long int cnt=0;
    int M=N;
    while(N>=0){
        if(X>(S[N]-1)/2+(M-N)){
            cnt+=(P[N]-1)/2;
            X-=(S[N]-1)/2;
                cnt++;
            N--;
            continue;
        }
        else{
            N--;
        }
    }
    cout<<cnt<<endl;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <cmath>

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

int main(){
    int N,A;

    scanf("%d%d",&N,&A);

    if(N%500<=A)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


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

int ctoi(char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main(){
    string s;
    cin >> s;
    int N = s.size();
    long long mods[2019] = {0}; //累積のあまり
    int d = ctoi(s.at(N -1));;
    mods[d] ++;
    int tens = 1;
    for(int i = 1; i < N; i++){
        tens = (10*tens)%2019;
        d = (tens*ctoi(s.at(N - 1 - i)) + d)%2019;
        mods[d] ++;
    }
    long long ans = 0;
    for(int i = 0; i < 2019; i++){
        ans += mods[i]*(mods[i] - 1)/2;
    }
    ans += mods[0];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3736
s = input()
p = 2019
n = 0
ans = 0
mods = [0]*p
mods[0] = 1
for i, j in enumerate(reversed(s)):
  n += int(j)*pow(10, i, p)
  n %= p
  mods[n] += 1
for i in mods:
  ans += i*(i-1)//2
print(ans)

Measured memory_bytes: 9148
#include <stdio.h>

int main()
{
    char s [3];
    int i, c;

    gets(s);

    c = 0;
    for (i = 0; i < 3; i++) {
        if (s [i] == 'S') c++;
    }

    if (c == 3) printf("0");

    if (c == 2) printf("1");

    if (c == 0) printf("3");

    if (c == 1) {
        if (s [1] == 'S') printf("1");

        if (s [0] == 'S' || s [2] == 'S') printf("2");
    }

    return 0;
}


Measured memory_bytes: 1532
n,m=list(map(int,input().split()))
mat=[]
for i in range(n):
	mat.append(list(map(int,input().split())))

vec=[]
for i in range(m):
	vec.append(int(input()))

res=[]
for i in range(n):
	c=0
	for j in range(m):
		c+=mat[i][j]*vec[j]
	res.append(c)
for i in res:
	print(i)

Measured memory_bytes: 7832
//#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)

#define MAXN 100000
int main() {
  int n, k;
  int a[MAXN];
  int h[MAXN];
  cin >> n >> k;
  forr(i,0,n-1)
    cin >> h[i];
  a[0] = 0;
  forr(i,1,n-1) {
    a[i] = a[i-1] + abs(h[i] - h[i-1]);
    forr(j,2,min(i,k)) {
      a[i] = min(a[i], a[i-j] + abs(h[i] - h[i-j]));
    }
  }
  cout << a[n-1];

}


Measured memory_bytes: 1024
#include<iostream>
#include<cassert>
#include<string>
#include<cctype>
using namespace std;

string S;
size_t cur = 0;
int parse();
int digit();
int number();
int expression();
int term();
int factor();

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S;
		cur = 0;
		S.resize(S.size() - 1);
		cout << expression() << endl;
		assert(cur == S.size());
	}
	
	return 0;
}

int digit() {
	assert(isdigit(S[cur]));
	int n = S[cur] - '0';
	cur++;
	return n;
}

int number() {
	int n = digit();
	while (cur < S.size() && isdigit(S[cur]))
		n = n * 10 + digit();
	return n;
}

int expression() {
	int a = term();
	while (cur < S.size() && (S[cur] == '+' || S[cur] == '-')) {
		char op = S[cur++];
		int b = term();
		if (op == '+') a += b;
		else a -= b;
	}
	return a;

}

int parse() {
	return expression();
}

int term() {
	int a = factor();
	while (cur < S.size() && (S[cur] == '*' || S[cur] == '/')) {
		char op = S[cur++];
		int b = factor();
		if (op == '*') a *= b;
		else a /= b;
	}
	return a;
}

int factor() {
	if (S[cur] != '(') return number();
	cur++;
	int n = expression();
	assert(S[cur] == ')');
	cur++;
	return n;

}

Measured memory_bytes: 1208
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	long long m=0;
	long long a=0;
	long long r=0;
	long long c=0;
	long long h=0;
	long long ans = 0;
	char x[11];
	f(i, 11)x[i] = 0;
	int n;
	scanf("%d", &n);
	f(i,n){
		scanf("%s", x);
		if (x[0] == 'M')m++;
		else if (x[0] == 'A')a++;
		else if (x[0] == 'R')r++;
		else if (x[0] == 'C')c++;
		else if (x[0] == 'H')h++;
	}
	ans += (m*a*r);
	ans += (m*a*c);
	ans += (m*a*h);
	ans += (m*r*c);
	ans += (m*r*h);
	ans += (m*h*c);
	ans += (a*r*c);
	ans += (a*r*h);
	ans += (a*c*h);
	ans += (r*c*h);
	printf("%lld\n",ans);
return 0;
}

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

#define mp make_pair
#define s second 
#define f first
#define pb push_back


typedef long long ll;
typedef double db;


using namespace std;

const int inf=2e9+312;
const int N=2e5+4578;


int xx[4]={0, 0, 1, -1};
int yy[4]={1, -1, 0 ,0};


ll b[N];

int main(){
	for(int i=0; i<=N; i++)
		b[i]=0;
	int n, m;
	cin >> n >> m;
	for(int i=0; i<n; i++){
		ll a, q;
		cin >> a >> q;
		for(int j=m; j>0; j--){
			if(b[j]!=0){
				b[j+a]=max(b[j+a], b[j]+q);
			}
		}
		b[a]=max(b[a], q);
	
		
	}
	
	ll mx=0;
	for(int i=1; i<=m; i++){
		mx=max(mx, b[i]);
	
	}
	cout << mx;
	return 0;
}

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

int main() {
  string s; cin >> s;
  if (s[(int)s.size()-1] == 's') {
    s += "es";
  } else {
    s += "s";
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int slove(int x,int y,int n);
int main(void)
{
    int N,Q;
    scanf("%d %d",&N,&Q);
    while(Q)
    {
        Q--;
        int x,y;
        scanf("%d %d",&x,&y);
        if(N==1)
            printf("%d\n",min(x,y));
        else
        printf("%d\n",slove(x,y,N));
    }
    return 0;
}
int slove(int x,int y,int n)
{
    while(x!=y)
    {
        if(x > y)
            x = (x+n-2)/n;
        else if(y > x)
            y = (y+n-2)/n;
    }
    return x;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define INT long long int
using namespace std;

int main()
{
  string s;
  INT k, p;
  cin>>s>>k;
  for( p = 0 ; s[p] == '1' ; p++ ) k--;
  if( k <= 0 ) return cout<<'1'<<endl, 0;
  cout<<s[p]<<endl;
  return 0;
}


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

#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")

using namespace std;

typedef long long ll;
typedef long double ld;


void solve() {
    string s;
    cin >> s;
    int sum = 0;
    for (int i = 0; i < int(s.size()); ++i) {
        sum += s[i] - '0';
        sum %= 9;
    }
    if (sum == 0) cout << "Yes\n";
    else cout << "No\n";

}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

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

template<typename T>
void fin (T a){
    cout<<a<<endl;
    exit(0);
}

template<typename S>
void print(S a){
    cout<<a<<endl;
}

template<typename U>
void pprint(U a){
    cout<<a<<" ";
}

const ll M = 1000000000+7;


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

    ll n;
    cin>>n;
//    vector<ll> x(n);
//    vector<ll> y(n);
    ll x,y;

    ll tmpx,tmpy;
    ll maxx=-10000000000;
    ll maxy=-10000000000;
    ll minx=10000000000;
    ll miny=10000000000;
    rep(i,n){
        cin>>tmpx>>tmpy;
        x = tmpx-tmpy;
        y = tmpx+tmpy;

        maxx = max(maxx,x);
        maxy = max(maxy,y);
        minx = min(minx,x);
        miny = min(miny,y);
    }

    fin(max(maxx-minx,maxy-miny));



    return 0;
}




Measured memory_bytes: 3644
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
using namespace std;

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N, A, B; cin >> N >> A >> B;
	string S; cin >> S;
	int x = 0;
	int y = 0;
	for (int i = 0; i <= S.length(); i++) {
		if (S[i] == 'a') {
			if (x < A + B) {
				x++;
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
		if (S[i] == 'b') {
			if (x < A + B&& y < B) {
				x++;
				y++;
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
		if (S[i] == 'c') {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 848
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Char

main :: IO ()
main = readLine >>= main'
    where
        main' [n, k] = getLine >>= putStrLn . solve n k

solve :: Int -> Int -> String -> String
solve n k = map mf . zip [1..]
    where
        mf (i, c)
            | i == k = toLower c
            | otherwise = c
            

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 380
#include <iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if (a==b)
    {
        cout<<c;
    }
    else if (a==c)
    {
        cout<<b;
    }
    else if (b==c)
    {
        cout<<a;
    }
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? (-(a)) : (a))

typedef long long ll;

using namespace std;

int X, Y, A, B, C;
priority_queue<int> A_select;
ll A_sum = 0LL;

priority_queue<int> B_select;
ll B_sum = 0LL;

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

	scanf("%d %d %d %d %d", &X, &Y, &A, &B, &C);

	for (int i = 0; i < A; ++i)
	{
		int input;

		scanf("%d", &input);

		if (A_select.size() == X && input < -A_select.top()) continue;
		A_select.push(-input);
		A_sum += input;
		if (A_select.size() > X)
		{
			A_sum += A_select.top();
			A_select.pop();
		}
	}

	for (int i = 0; i < B; ++i)
	{
		int input;

		scanf("%d", &input);

		if (B_select.size() == Y && input < -B_select.top()) continue;
		B_select.push(-input);
		B_sum += input;
		if (B_select.size() > Y)
		{
			B_sum += B_select.top();
			B_select.pop();
		}
	}

	for (int i = 0; i < C; ++i)
	{
		int input;

		scanf("%d", &input);

		if (-A_select.top() <= -B_select.top() && -A_select.top() < input)
		{
			A_sum += A_select.top();
			A_select.pop();

			A_sum += input;
			A_select.push(-input);
		}
		else if (-B_select.top() < -A_select.top() && -B_select.top() < input)
		{
			B_sum += B_select.top();
			B_select.pop();

			B_sum += input;
			B_select.push(-input);
		}

	}

	printf("%lld\n", A_sum + B_sum);

	return 0;
}

Measured memory_bytes: 1400
#include<stdio.h>
int main(){
	int A[9][2]={0};
	for(int i=0;i<9;i++){
		scanf("%d",&A[i][0]);	
	}	
	int N;
	int b;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&b);
		for(int i=0;i<9;i++){
			if(b==A[i][0]){
				A[i][1]=1;
			}	
		}	
	}
	for(int i=0;i<3;i++){
		int c=1;
		for(int j=0;j<3;j++){
			c*=A[i+3*j][1];
		}
		if(c){
			printf("Yes");
			return 0;
		}
	}
	for(int i=0;i<3;i++){
		int c=1;
		for(int j=0;j<3;j++){
			c*=A[3*i+j][1];
		}
		if(c){
			printf("Yes");
			return 0;
		}
	}
	if(A[0][1]*A[4][1]*A[8][1]||A[2][1]*A[4][1]*A[6][1]){
		printf("Yes");
		return 0;
	}
	printf("No");
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    int n = 0, x = 0, t = 0;
    cin >> n >> x >> t;
    if (n % x == 0) {
        cout << n / x * t;
    }
    else {
        cout << ((n / x) + 1) * t;
    }
    return 0;
}

Measured memory_bytes: 3624
#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;
  int cnt=2,ans=0;
  for(int i=1;i<n+1;i+=2){
    for(int j=3;j<i;j+=2){
      if(i%j==0) cnt++;
    }
    if(cnt==8) ans++;
    cnt=2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n;
    //vector<vector<ll>> v(tate,vector<ll> (yoko));
    vector<ll> v(n);
    priority_queue<ll> q;
    rep(i,n)   cin >> v[i];
    sort(v.begin(),v.end(),std::greater<ll>());
    q.push(v[0]);
    //q.push(v[0]);
    for(ll i=1;i<n;i++) {
        sum+=q.top();
        q.pop();
        q.push(v[i]);
        q.push(v[i]);
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 6892
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

#ifdef ENABLE_LL
#define int long long
#endif

#ifdef ENABLE_LL
#define I "%lld"
#define II "%lld%lld"
#define III "%lld%lld%lld"
#define IIII "%lld%lld%lld%lld"
#define IN "%lld\n"
#define IIN "%lld%lld\n"
#define IIIN "%lld%lld%lld\n"
#define IIIIN "%lld%lld%lld%lld\n"
#else
#define I "%d"
#define II "%d%d"
#define III "%d%d%d"
#define IIII "%d%d%d%d"
#define IN "%d\n"
#define IIN "%d%d\n"
#define IIIN "%d%d%d\n"
#define IIIIN "%d%d%d%d\n"
#endif

#ifdef __LOCALE__
#define see(a) std::cout << #a << "=" << a << std::endl
#define ses(a) std::cout << #a << "=" << a << " " 
#else
#define see(a) //std::cout << #a << "=" << a << std::endl
#define ses(a)
#endif
#define repe(a,b) for (int a=0;a<(int)b.size();a++)
#define rep(i,n) for (int i=0;i<n;i++)
#define repa(i,n) for (int i=1;i<=n;i++)
#define repi(i,a,b) for (int i=a;i<=b;i++) 
#define repb(i,a,b) for (int i=a;i>=b;i--)
typedef pair < int , int > pr;
typedef pair < pr  , int > prr;
#define L first
#define R second
template <class T> inline bool checkMin(T& a , T b) { return (a > b ? a=b,1 : 0); }
template <class T> inline bool checkMax(T& a , T b) { return (a < b ? a=b,1 : 0); }
class Scanner{ private: istream& ist;public: Scanner(istream& in):ist(in){} string next(){ string r; ist >> r; return r; } string nextLine(){ string r; getline(ist,r); return r; } int nextInt(){ int r; ist >> r; return r; } double nextDouble(){ double r; ist >> r; return r; }};
Scanner sc(cin);

const int N = 30005;
char s[N];
int n;

void init() {
    scanf(I,&n);
    scanf("%s",s); 
}

char t[N];

bool jury() {
    char *u = t, *v = s;
    while (*u && *v) {
        if (*u == *v) u++;
        v++;
    }
    if (*u == 0) return 1;
    else return 0;
}

void solve() {
    t[3] = 0;
    int ans = 0;
    rep (i,10) rep (j,10) rep (k,10) {
        t[0] = i+'0';
        t[1] = j+'0';
        t[2] = k+'0';
        if (jury()) ans++;
    }
    printf(IN,ans);
}


#ifdef ENABLE_LL
#undef int
#endif
int main(){
    init();
    solve();
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iterator>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cassert>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <climits>
#include <ctime>

using namespace std;
using ll = long long;
using ull = unsigned long long;

void solve() {
	int m;
	cin >> m;
	cout << 48 - m;
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	solve();

#ifdef LOCAL
	cerr << double(clock()) / CLOCKS_PER_SEC << " sec" << endl;
#endif
	return 0;
}

Measured memory_bytes: 256