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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}

#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

void err(vector<string>::iterator it) {}

template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int w, h;

	cin >> w >> h;
	REPU(i, 0, w) REPU(j, 0, h) {
		string s; cin >> s;
		if (s == "snuke") printf("%c%d", j + 'A', i + 1);
	}

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main(void){
    char map[12]="yhnujmkiolp",line[33];
    int i,sign,sum;
    for(;sum=0,i=1,scanf("%s",line),line[0] != '#';){
        if(strchr(map,line[0]) == NULL)
            sign=0;
        else
            sign=1;
        while(line[i]){
            if(strchr(map,line[i]) != NULL && sign == 0){
                sign=1;
                sum++;
            }
            else if(strchr(map,line[i]) == NULL && sign == 1){
                sign=0;
                sum++;
            }
            i++;
        }
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 544
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>

struct vertex {
  int dis;
  int k;
  int visited;
  int *vlist;
};

struct vertex *adj;

int *queue, n, in, out;

int main(int argc, char *argv[])
{
  int i, j, id, d, v;

  scanf("%d", &n);
  adj = (struct vertex *)malloc(sizeof(struct vertex) * (n + 1));
  queue = (int *)malloc(sizeof(int) * (n + 1));
  in = 0;
  out = 0;

  for (i = 0; i < n; i++) {
    scanf("%d", &id);
    scanf("%d", &(adj[id].k));
    adj[id].vlist = (int *)malloc(sizeof(int) * adj[id].k);
    adj[id].visited = 0;
    adj[id].dis = -1;
    for (j = 0; j < adj[id].k; j++) scanf("%d", &(adj[id].vlist[j]));
  }
  
  adj[1].dis = 0;
  adj[1].visited = 1;
  queue[in] = 1;
  in = (in + 1) % n;
  while (in != out) {
    v = queue[out];
    out = (out + 1) % n;
    for (i = 0; i < adj[v].k; i++) {
      if (adj[adj[v].vlist[i]].visited == 0) {
	adj[adj[v].vlist[i]].visited = 1;
	adj[adj[v].vlist[i]].dis = adj[v].dis + 1;
	queue[in] = adj[v].vlist[i];
	in = (in + 1) % n;
      }
    }
  }

  for (i = 1; i <= n; i++) printf("%d %d\n", i, adj[i].dis);

  return 0;
}

Measured memory_bytes: 600
s = list(input())

pre_c = None
l_count = 0
for c in s:
  if c == pre_c:
    l_count += 1
    pre_c = '0' if c == '1' else '1'
  else:
    pre_c = c

pre_c = None
r_count = 0
s.reverse()
for c in s:
  if c == pre_c:
    r_count += 1
    pre_c = '0' if c == '1' else '1'
  else:
    pre_c = c
print(min(l_count, r_count))

Measured memory_bytes: 3956
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        if(n % 2 == 0) {
            System.out.println((double)(n/2)/n);
        } else {
            System.out.println((double)((n+1)/2)/n);
        }
    }
}

Measured memory_bytes: 22100
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<int> a(n);
    int e = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if(a[i]%2 == 0) e++;
    }
    ll all = pow(3.0, n);
    ll even = pow(2.0, e);
    //cout << all << std::endl;
    //cout << even << std::endl;
    cout << all - even << std::endl;
    return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
S=list(input())
if S[K-1]=="A":
    S[K-1]="a"
elif S[K-1]=="B":
    S[K-1]="b"
elif S[K-1]=="C":
    S[K-1]="c"
print("".join(S))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int n,k,a[100005],dp[100005];
int solve(int idx){
    if(idx >= n - 1)
        return 0;
    int &ans = dp[idx];
    if(ans != -1)
        return ans;
    ans = 1e9;
    for(int i = 1; i <= k; i++){
        if(idx + i < n)
            ans = min(ans, abs(a[idx] - a[idx + i]) + solve(idx + i));
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(0);
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> a[i], dp[i] = 1e9;
    dp[n - 1] = 0;
    for(int i = n - 1; i > -1; i--){
        for(int j = 1; j <= k; j++){
            if(i - j > -1)
                dp[i - j] = min(dp[i - j], abs(a[i] - a[i - j]) + dp[i]);
        }
    }
    cout << dp[0] << endl;
    return 0;
}
		

Measured memory_bytes: 1024
#n , m , l = map(int , input().split())

# list_n = list(map(int , inpuut().split()))<Paste>

#n = input()
# list = [input() for i in range(N)

#list = [[i for i in range(N)] for _ in range(M)]


import math

A, B = map(int, input().split())
print(math.ceil((B-1)/(A-1)))


Measured memory_bytes: 9064
n,m=map(int,input().split())
st=[[] for i in range(n)]
en=[[] for i in range(n)]
ju=[0 for i in range(m)] #0：未処理、1：処理中、－１：処理後
for i in range(m):
    a,b=map(int,input().split())
    st[a-1].append(i)
    en[b-1].append(i)
ans=0
co=0
now=[]
while(co<n):
    if len(now)!=0 and len(en[co])!=0:
        ch=False
        for i in en[co]:
            if ju[i]==1:
                ch=True
        if ch:       
            for i in now:
                ju[i]=-1
            ans+=1
            now=[]
    for i in st[co]:
        ju[i]=1
        now.append(i)
    co+=1
print(ans)

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

typedef long long ll;

int Get(const std::vector<int>& v, int val)
{
	int s = 0;
	int e = v.size() - 1;
	while (s <= e)
	{
		int m = s + (e - s) / 2;
		if (v[m] <= val)
		{
			e = m - 1;
		}
		else
		{
			s = m + 1;
		}
	}
	return e;
}

int main()
{
	int n;
	scanf("%d", &n);
	std::vector<int> a[3] = { std::vector<int>(n), std::vector<int>(n), std::vector<int>(n) };
	for (int j = 0; j < 3; ++j)
	{
		for (int i = 0; i < n; ++i)
		{
			scanf("%d", &a[j][i]);
		}
		std::sort(a[j].begin(), a[j].end(), std::greater<int>());
	}
	std::vector<ll> acum(n);
	acum[0] = static_cast<int>(std::lower_bound(a[2].begin(), a[2].end(), a[1][0], std::greater<int>()) - a[2].begin());
	for (int i = 1; i < n; ++i)
	{
		acum[i] = static_cast<int>(std::lower_bound(a[2].begin(), a[2].end(), a[1][i], std::greater<int>()) - a[2].begin());
		acum[i] += acum[i - 1];
	}
	ll ans = 0;
	for (int i = 0; i < n; ++i)
	{
		// int temp = std::lower_bound(a[1].begin(), a[1].end(), a[0][i], std::greater<int>()) - a[1].begin();
		int temp = Get(a[1], a[0][i]);
		if (0 <= temp && temp < n)
		{
			ans += acum[temp];
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main (){
  
  string S ;
  cin >> S ;
  if ( S == "ABC" ){
    cout << "ARC" << endl ;
  }
  
  else if ( S == "ARC"){
    cout << "ABC" << endl;
  }
  
  
  
}

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

signed main() {
  std::vector<int> v(4);
  for(int i=0;i<4;i++)cin>>v[i];
  sort(v.begin(),v.end());
  if(v[0]==1&&v[1]==4&&v[2]==7&&v[3]==9)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const int Maxn=200005;
int a[Maxn];
int main(){
	int n,m,ans=0;scanf("%d%d",&n,&m);
	for(int i=1;i<=2*n;i++)scanf("%d",&a[i]);
	sort(a+1,a+2*n+1);
	int l=0,r=n;
	while(l<=r){
		int mid=(l+r)/2,chk=true;
		for(int i=2*mid+1,j=2*n;i<=j;i++,j--)
			chk&=a[i]+a[j]>=m;
		if(chk)r=mid-1;
		else l=mid+1;
	}
	for(int i=1,j=2*l;i<=j;i++,j--)ans=max(ans,a[i]+a[j]);
	for(int i=2*l+1,j=2*n;i<=j;i++,j--)ans=max(ans,a[i]+a[j]-m);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main(){
	var w, h, x, y, r int
	fmt.Scan(&w, &h, &x, &y, &r)
	if (x + r) <= w && (x - r) >= 0 && (y + r) <= h && (y - r) >= 0{
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1156
#include <iostream>

using namespace std;

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

	int ans = 0;
	for (int a = 1; a <= n; a++) {
		for (int b = 1; b <= n; b++) {
			if (n <= a * b) {
				break;
			}
			int c = n - a * b;
			if (c > 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3644
N, A = map(int, input().split())
xs = list(map(int, input().split()))
dp = [{} for i in range(N+1)]
dp[0][0] = 1
for i in range(N):
  x = xs[i]-A
  for s in dp[i]:
    n = dp[i][s]
    if s not in dp[i+1]: dp[i+1][s] = 0
    dp[i+1][s] += n
    if s+x not in dp[i+1]: dp[i+1][s+x] = 0
    dp[i+1][s+x] += n
r = dp[N][0]-1
print(r)


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

int main(){
  string S;
  cin >> S;
  int E = S.size();
  vector<int> M1(E, 0),M2(E, 0);
  M1.at(0) = 1; M2.at(0) = 0;
  M1.at(1) = (S.at(0) == S.at(1) ? 1 : 2);
  M1.at(2) = (S.at(0) != S.at(1) && S.at(1) != S.at(2) ? 3 : 2);
  M2.at(1) == 1; M2.at(2) = 2;
  for (int i=3;i < E;i++) {
    M1.at(i) = (S.at(i) == S.at(i-1) ? M2.at(i-1) + 1 : max(M1.at(i-1) + 1,M2.at(i-1) + 1));
    M2.at(i) = (S.at(i) == S.at(i-2) && S.at(i-1) == S.at(i-3) ? M1.at(i-2) + 1 : max(M1.at(i-2) + 1,M2.at(i-2) + 1));
  }
  cout << max(M1.at(E-1), M2.at(E-1)) << endl;
}

Measured memory_bytes: 2180
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

N = ri()
A = ri_()
B = [0] * N
for Ai in A:
    B[Ai - 1] += 1
for Bi in B:
    print(Bi)


Measured memory_bytes: 32232
#ifdef loc
    #include "codes/loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 100005;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    string prev = "";
    int res = 0;
    rep(i, 0, sz(s)) {
        if(string(1, s[i]) != prev) {
            prev = string(1, s[i]);
            res++;
        } else {
            if(i < sz(s) - 1) {
                prev = s[i] + "" + s[i + 1];
                res++;
                i++;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 720
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] <= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) left = mid;
		else right = mid;
	}
	/* left は条件を満たす最大の値、right は条件を満たさない最小の値になっている */
	return left;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
double PI = 3.141592653589793238;
vector<vector<int>>G(100030);
int main() {
	int x;
	cin >> x;
	int a = x / 100;
	int b = x % 100;
	if (a * 5 >= b) {
		cout << 1;
	}
	else {
		cout << 0;
	}
}

Measured memory_bytes: 5448
def era()
  a=Array.new(10001,false)
  ans=[]
  for i in 2..10000
    if !a[i]
      ans.push(i)
      j=i
      while j<=10000
        a[j]=true
        j+=i
      end
    end
  end
  return ans
end

def bin_search(a,k,n)
  l=k
  r=a.length
  while r-l>0
    t=(r+l)/2
    if a[t]==n
      return true
    elsif a[t]<n
      l=t+1
    else
      r=t
    end
  end
  return false
end

def sum(a)
  s=Array.new(a.length+1,0)
  for i in 0..a.length-1
    s[i+1]=s[i]+a[i]
  end
  return s
end

def prime(a,t,su)
  count=0
  for s in 0..a.length
    if(bin_search(su,s,t+su[s]))
      count+=1
    end
  end
  return count
end

a=era()
su=sum(a)
while true
  t=gets.to_i
  if t==0
    break
  end
  puts prime(a,t,su)
end
    

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

#define long long long int
using namespace std;

// @author: pashka

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

    string s;
    cin >> s;
    int q;
    cin >> q;
    deque<char> d;
    d.insert(d.end(), s.begin(), s.end());
    bool reversed = false;
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            reversed = !reversed;
        } else {
            int f; cin >> f;
            char c; cin >> c;
            if ((f == 1) ^ reversed) {
                d.push_front(c);
            } else {
                d.push_back(c);
            }
        }
    }
    if (reversed) {
        reverse(d.begin(), d.end());
    }
    for (char c : d) {
        cout << c;
    }

    return 0;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n, q;
    cin >> n >> q;
    vvint g(n);
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        g[a].pb(b);
        g[b].pb(a);
    }

    vint c(n, 0);
    rep(i, q)
    {
        int p, x;
        cin >> p >> x;
        --p;
        c[p] += x;
    }

    deque<bool> seen(n, false);
    vint ans(n, 0);
    ans[0] = c[0];
    qint que;
    que.push(0);

    while (!que.empty())
    {
        int v = que.front();
        que.pop();

        seen[v] = true;

        for (const auto nv : g[v])
        {
            if (seen[nv] == true)
                continue;
            ans[nv] = ans[v] + c[nv];
            que.push(nv);
        }
    }
    rep(i, n)
    {
        cout << ans[i] << (i == n - 1 ? "\n" : " ");
    }
}

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


Measured memory_bytes: 16500
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,d;
  	
  	int count=1;
  	cin>>n>>d;
  int sa=n-(2*d+1);
    while(sa>0){
      	sa=sa-(2*d+1);
      		
        	
      count=count+1;
        }
  	cout<<count<<endl;
   
}

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
	cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	cout << head;
	if (sizeof...(tail) != 0) cout << " ";
	print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
	for (auto& a : vec) {
		cout << a;
		if (&a != &vec.back()) cout << " ";
	}
	cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
	for (auto& vec : df) {
		print(vec);
	}
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

#ifdef LOCALCODE
signed solve()
#else
signed main()
#endif
{
	i64 A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	i64 ans = 0;
	i64 same = min(X, Y);
	if (A + B <= C * 2)
		ans = A * same + B * same;
	else
		ans = C * 2 * same;

	i64 x = X - same;
	i64 y = Y - same;
	if (x > 0)
		ans += min(A * x, C * 2 * x);
	else
		ans += min(B * y, C * 2 * y);

	print(ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
 
using namespace std;
 
typedef long long ll;
const ll nmax = 1e9 + 7;
const ll mod = 998244353;
const double PI = 2 * asin(1);

int main() {
  int N, M, C, ans;
  cin >> N >> M >> C;
  ans = 0;
  
  vector<int> B(M);
  for (int i = 0; i < M; i++) {
    cin >> B.at(i);
  };
  
  for (int i = 0; i < N; i++) {
    
    vector<int> A(M);
    for (int j = 0; j < M; j++) {
      cin >> A.at(j); 
    };
    
    int judgement = 0;
    for (int k = 0; k < M; k++) {
      judgement = judgement + A.at(k) * B.at(k);
    };

    if (judgement + C > 0){
      ans++;
    };
  };
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"

using namespace std;
typedef long long ll;
typedef pair <int,pair <int,int > > pii;

const int MOD = 1000000007;

int main()
{
    ll n,t,i,last = -2e9,x,sol = 0;
    cin >> n >> t;
    for(i = 1;i <= n;i++){
        cin >> x;
        if(last + t >= x){
            sol -= (last + t - x);
        }
        sol += t;
        last = x;
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int main()
{
	int n;get1(n);map<int,int> cnt;
	for(int i=1,x;i<=n;i++){get1(x);cnt[x]++;}
	int ans=0;for(auto x:cnt)if(x.ff<=x.ss)ans+=x.ss-x.ff;else ans+=x.ss;
	printendl(ans);
	return 0;
}

Measured memory_bytes: 4736
n = int(input());
mylist = list(map(int, input().split()));
sum = 0;
for k in mylist:
	sum += k;
sum /= len(mylist);
maxi = 0;
for i in range(len(mylist)):
	if (abs(mylist[maxi] - sum) > abs(mylist[i] - sum)):
		maxi = i;
print(maxi);

Measured memory_bytes: 3064
#include<bits/stdc++.h>
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=2e5;
typedef ll fuko[yuzu|10];
fuko a;

int main(){
int i,n=read();
for (i=1;i<=n;++i) a[i]=a[i-1]+read();
int l=1,r=3;
ll nowmax,nowmin,ans=1e18;
for (i=2;i<n-1;++i){
  for (;a[l]*2<a[i];++l);
  for (;a[r]*2<a[i]+a[n];++r);
  if (a[l-1]+a[l]>a[i]) --l;
  if (a[r-1]+a[r]>a[i]+a[n]) --r;
  nowmax=max(max(a[l],a[i]-a[l]),max(a[r]-a[i],a[n]-a[r]));
  nowmin=min(min(a[l],a[i]-a[l]),min(a[r]-a[i],a[n]-a[r]));
  ans=min(ans,nowmax-nowmin);
  }write(ans);
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int N = sc.nextInt();
		
		int[] d = new int[N];
		int ans = 0;
		int avg = 0;
		for (int i = 0; i < N; i++) {
			d[i] = sc.nextInt();
		}
		Arrays.sort(d);
		System.out.println(d[N/2] - d[(N/2)-1]);
//		int center = (d[(N/2)-1]+d[N/2])/2;
	}		
}


Measured memory_bytes: 49936
#include <iostream>

int n, v[50];
unsigned long long res;

int main ()
{
	std::cin >> n;
	for(int i=0; i<n; i++) std::cin >> v[i];
	
	for(int i=0; i<n-1; i++) for(int j=i+1; j<n; j++) res+=(unsigned long long)v[i]*v[j];
	std::cout << res;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int n;
  cin >> n;
  ll res = 0;
  for(int i = 1; i <= n; i++){
    if((i % 3) != 0 && (i % 5) != 0) res += i;
  }
  cout << res;
}


Measured memory_bytes: 3640
import java.util.*;

class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int []a=new int[n];

        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }

        Arrays.sort(a);

        long s=0;

        for (int i=0;i<n;i++){
            s+=a[i];
        }
        System.out.println(a[0] + " " + a [n-1] + " " +  s );

    }
}


Measured memory_bytes: 41428
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();

        Map<Long, Integer> map = new HashMap<>();
        long tmp = N;
        for (long i = 2; i*i <= N; i++) {
            while (tmp%i == 0) {
                map.put(i,map.getOrDefault(i,0)+1);
                tmp /= i;
            }
        }
        if (tmp != 1) {
            map.put(tmp,1);
        }

        int ans = 0;
        for (int value : map.values()) {
            int x = 1;
            while (x*(x+1) <= value*2) {
                ans++;
                x++;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 37224
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,k;
  while(1){
    cin>>n;
    if(n==0)break;
    vi a(n);
    rep(i,n)cin>>a[i];
    cin>>k;
    int r=n-1;
    int l=0;
    rep(i,n){
      int mid=(r+l)/2;
      if(a[mid]==k){
	cout<<i+1<<endl;
	break;
      }
      if(a[mid]<k)l=mid+1;
      else r=mid-1;
      if(r<l){
        cout<<i+1<<endl;
        break;
      }
    }

  }
}

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

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

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

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

int main() {
  ll n, m;
  cin >> n >> m;
  vl p(n);
  rep(i,n) {
    cin >> p[i];
    p[i]--;
  }
  
  UnionFind uf(n);
  
  rep(i,m) {
    ll x, y;
    cin >> x >> y;
    x--; y--;
    uf.unite(x,y);
  }
  
  ll ans = 0;
  
  rep(i,n)
    if (uf.same(i,p[i])) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 4416
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

template< typename flow_t, typename cost_t >
struct MinCostFlow {
  const cost_t INF;

  struct edge {
    int to;
    flow_t cap;
    cost_t cost;
    int rev;
    bool isrev;
  };
  vector<vector<edge>> graph;
  vector<cost_t> potential,min_cost;
  vector<int> prevv,preve;

  MinCostFlow(int V) : graph(V),INF(numeric_limits< cost_t >::max()) {}

  void add_edge(int from,int to,flow_t cap,cost_t cost){
    graph[from].emplace_back((edge){to,cap,cost,(int)graph[to].size(),false});
    graph[to].emplace_back((edge){from,0,-cost,(int)graph[from].size()-1,true});
  }

  cost_t min_cost_flow(int s,int t,flow_t f){
    int V=(int)graph.size();
    cost_t ret=0;
    using Pi = pair<cost_t,int>;
    priority_queue<Pi,vector<Pi>,greater<Pi>> PQ;
    potential.assign(V,0);
    preve.assign(V,-1);
    prevv.assign(V,-1);

    while(f>0){
      min_cost.assign(V,INF);
      PQ.emplace(0,s);
      min_cost[s]=0;
      while(!PQ.empty()){
        cost_t d;
        int now;
        tie(d,now)=PQ.top();
        PQ.pop();
        if(min_cost[now]<d) continue;
        
        for(int i=0;i<graph[now].size();i++){
          edge &e=graph[now][i];
          cost_t nextCost=min_cost[now]+(e.cost+potential[now]-potential[e.to]);
          if(e.cap>0&&min_cost[e.to]>nextCost){
            min_cost[e.to]=nextCost;
            prevv[e.to]=now;
            preve[e.to]=i;
            PQ.emplace(min_cost[e.to],e.to);
          }
        }
      }

      if(min_cost[t]==INF) return -1;

      for(int v=0;v<V;v++) potential[v]+=min_cost[v];
      flow_t addflow=f;
      for(int v=t;v!=s;v=prevv[v]){
        addflow=min(addflow,graph[prevv[v]][preve[v]].cap);
      }
      f-=addflow;
      ret+=addflow*potential[t];
      
      for(int v=t;v!=s;v=prevv[v]){
        edge &e=graph[prevv[v]][preve[v]];
        e.cap-=addflow;
        graph[v][e.rev].cap+=addflow;
      }
    }
    return ret;
  }
};

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

  int N,K;
  cin>>N>>K;
  vector<vector<ll>> A(N,vector<ll> (N));
  rep(i,N) rep(j,N) cin>>A[i][j];

  MinCostFlow<int,ll> mcf(2*N+2);
  int S=2*N,T=2*N+1;
  mcf.add_edge(S,T,N*K,0);
  for(int i=0;i<N;i++){
      mcf.add_edge(S,i,K,0);
      mcf.add_edge(i+N,T,K,0);
  }
  rep(i,N) rep(j,N){
      mcf.add_edge(i,N+j,1,-A[i][j]);
  }

  ll result=mcf.min_cost_flow(S,T,N*K);
  cout<<abs(result)<<"\n";

  vector<string> ans(N,string(N,'.'));
  for(int i=0;i<N;i++){
      for(auto &e:mcf.graph[i]){
          if(e.isrev) continue;
          int flow=mcf.graph[e.to][e.rev].cap;
          if(flow) ans[i][e.to-N]='X';
      }
  }

  rep(i,N) cout<<ans[i]<<"\n";

  return 0;
}


Measured memory_bytes: 3872
from sys import exit
a, b = map(int, input().split())
s = input()
for i in range(a):
  if s[i] not in '0123456789':
    print('No')
    exit()
if s[a] != '-':
  print('No')
  exit()
for i in range(a + 1, a + b + 1):
  if s[i] not in '0123456789':
    print('No')
    exit()
print('Yes')


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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

#define MOD 2019

int binary_square(int x, int n);

int main(){
    string s;
    cin >> s;
    int s_len = s.length();
    int *dp = new int[s_len+1];
    dp[s_len] = 0;
    rep2(i, 1, s_len+1){
        int a = s[s_len-i] - '0';
        // cout << a << endl;
        dp[s_len-i] = (dp[s_len-i+1] + binary_square(10, i-1) * a % MOD) % MOD;
        // cout << binary_square(10, i-1) << endl;
    }
    int cnt=0;
    rep2(i, 0, 2019){
        int m = 0;
        rep(j, s_len+1){
            if(dp[j]==i){
                m++;
            }
        }
        cnt += m * (m-1) / 2;
    }
    // rep(i, s_len){
    //     //cout << dp[i] << endl;
    //     rep2(j, i+1, s_len+1){
    //         if(dp[i]==dp[j]) cnt++;
    //     }
    // }
    cout << cnt << endl;
    return 0;
}

int binary_square(int x, int n){
    int m = MOD;
    int ans = 1;
    while(n){
        if(n%2==1){
            ans = ans * x % m;
        }
        x = x * x % m;
        n >>= 1;
    }
    return ans % m;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int dp[310];

bool easy[310];
vector<vi> recipe[310];


int main(void){
	int n,e,t;
	cin >> n >> e >> t;
	rep(i,n) cin >> easy[i];
	rep(i,e){
		vi in;
		int g,c;
		cin >> g >> c;
		rep(j,c){
			int s;
			cin >> s;
			in.pb(s-1);
		}
		recipe[g-1].pb(in);
	}
	rep(i,n) dp[i]=-1;
	rep(loop,n)rep(v,n){
		if(easy[v]){
			dp[v]=1;
			continue;
		}

		int res=-1;
		for(auto &r:recipe[v]){
			bool ok=true;
			vi cost;
			for(auto &i:r){
				if(dp[i]==-1) ok=false;
				cost.pb(dp[i]);
			}
			if(!ok) continue;
			int cur=0,m=cost.size();
			sort(cost.begin(),cost.end());
			rep(i,m) cur=max(cur,cost[i]+(m-1-i));
			if(res==-1||res>cur) res=cur;
		}
		if(dp[v]==-1||dp[v]>res) dp[v]=res;
	}
	cout << dp[t-1] << endl;
	return 0;
}

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

bool nonprime[10000001] = {};

int main(){
    vector<int> prime;
    nonprime[0] = nonprime[1] = true;
    for(int i = 2; i < 10000001; i++){
        if(!nonprime[i]){
            prime.push_back(i);
            for(int j = i+i; j < 10000001; j+=i)
                nonprime[j] = true;
        }
    }

    vector<int> quad;
    for(int i = 0; i <= prime.size()-4; i++){
        if(prime[i]+2 == prime[i+1] && prime[i]+6 == prime[i+2] && prime[i]+8 == prime[i+3]){
            quad.push_back(prime[i+3]);
        }
    }

    int n;
    while(cin >> n, n){
        vector<int>::iterator it = lower_bound(quad.begin(), quad.end(), n);
        if(*it == n){
            cout << n << endl;
        }else{
            it--;
            cout << *it << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 16516
import java.util.*;
import java.io.*;
import java.math.BigInteger; 

  class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
// ends

//......................................@uthor_Alx..............................................


//  (Binary lifting)LCS implementation <O(NlogN,logN)>...<preprocessing,query>
//static int l,time;
//static int[][] f; // f[n][l]..
//static int[] tin, tout;
//static List<Integer>[] adj;
/*	return tin[u]<=tin[v]&&tout[u]>=tout[v]; 
}
static void dfs(int u, int p){
	tin[u]=time++;
	f[u][0]=p;
	for(int i=1;i<=l;i++){
		f[u][i]= f[f[u][i-1]][i-1];
	}

	for(int v: adj[u]){
		if(v!=p) dfs(v,u);
	}
	tout[u]=time++;
}
static int lca(int u, int v){
	if(ok(u,v)){return u;}
	if(ok(v,u)){return v;}

	for(int i=l;i>=0;i--){
		if(!ok(f[u][i],v)){
			u=f[u][i];
		}
	}
	return f[u][0];
}*/

public static void main(String[] args) throws  IOException{
	        		  assign();
              String s=read();
              if(s.charAt(2)==s.charAt(3)&&s.charAt(4)==s.charAt(5)){
              	out.write("Yes\n");
              }
              else{out.write("No\n");}
              out.flush();
	        		 
	        	}
	       
	          
	        }

	    

	
  





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

int main(){
	int N, M;
	cin >> N >> M;
	vector<int> box (N);//各箱内のボールの数
	vector<bool> red (N);//赤いボールが含まれる可能性が存在するか
	red.at(0) = true;
	box.at(0) = 1;
	for(int i = 1;i < N;i++){
		red.at(i) = false;
		box.at(i) = 1;
	}//1番目の箱以外はred false
	for(int i = 0;i < M;i++){
		int from, to;
		cin >> from >> to;//from から to へボールを移動
		box.at(from-1)--;//from のボールの個数を減らす
		box.at(to-1)++;//to のボールの個数を増やす
		if(red.at(from-1) == true){
			red.at(to-1) = true;
		}
		if(box.at(from-1) == 0){
			red.at(from-1) = false;//from のボールが無くなった場合赤が含まれる可能性もなくなる
		}
	}
	int count = 0;
	for(int i = 0;i < N;i++){
		if(red.at(i)){
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define N 105
const int mod=1e9+7;
int dp[55][N][N];
int a[N],n,m;
int main(){
    scanf("%d",&n);m=n*2-1;
    for(int i=1;i<=m;i++) scanf("%d",&a[i]);
    sort(a+1,a+m+1);
    dp[n][1][1]=1;
    for(int i=n;i>=1;i--){
        int ml=a[m-i+1]!=a[m-i+2],mr=a[i]!=a[i-1];
        for(int j=1;j<=m;j++)
            for(int k=1,v;k<=m;k++)
                if(v=dp[i][j][k]){
                    (dp[i-1][j+ml][k+mr]+=v)%=mod;
                    for(int t=1;t<j+ml;t++) (dp[i-1][t][k+mr+1]+=v)%=mod;
                    for(int t=1;t<k+mr;t++) (dp[i-1][j+ml+1][t]+=v)%=mod;
                }
    }
    long long ans=0;
    for(int i=1;i<=m;i++)
        for(int j=1;j<=m;j++)
            ans+=dp[1][i][j];
    cout<<ans%mod<<endl;
    return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	ll int n,T,res,m;

	ll int maxi=-mx,mini=mx,count=0,m1=mx,m2=mx,m3=mx;

	ll int i,j,k,pos1,pos2,pos3;

	bool flag;

	string s1,s2;

	char s[100000];


	cin>>n;

	vll ara(n),ara2(n),ara3(n);

    f(i,0,n-1) cin>>ara[i];
    f(i,0,n-1) cin>>ara2[i];
    f(i,0,n-1) cin>>ara3[i];

    sort(ara.bb,ara.ee);
    sort(ara2.bb,ara2.ee);
    sort(ara3.bb,ara3.ee);

    for(i=0;i<n;i++)
    {
        k=ara2[i];


        m=upper_bound(ara.bb,ara.ee,k-1)-ara.bb;
        res=lower_bound(ara3.bb,ara3.ee,k+1)-ara3.bb;

        count+=(m*(n-res));

    }

    cout<<count<<endl;

}


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

int euclid(int a, int b) {
  if (a > b) {
    int c;
    c = a;
    a = b;
    b = c;
  }
  if (a == 0) return b;
  if (a == 1) return 1;
  return euclid(b % a, a);
}
  
int main()
{
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int gcdl[n], gcdr[n];
  gcdl[0] = a[0];
  gcdr[n-1] = a[n-1];
  
  for (int i = 1; i < n; ++i) {
   	gcdl[i] = euclid(gcdl[i-1], a[i]);
  }
  for (int i = n - 2; i >= 0; --i) {
    gcdr[i] = euclid(gcdr[i+1], a[i]);
  }
  
  int gcd;
  gcd = max(gcdl[n-2], gcdr[1]);
  for (int i = 1; i < n-1; ++i) {
  	gcd = max(gcd, euclid(gcdl[i-1], gcdr[i+1]) );
  }
  cout << gcd << endl;
  return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main(){
  long long int i,j,h,w,dp[1010][1010],map[1010][1010];
  char s;
  const int mod=1000000007;
  scanf("%lld %lld\n",&h,&w);
  for(i=0;i<=h;i++){
    for(j=0;j<=w;j++){
      map[i][j]=1;
      dp[i][j]=0;
    }
  }
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      scanf("%c",&s);
      if(s=='.'){
        map[i][j]=0;
      }
    }
    scanf("\n");
  }
  dp[1][1]=1;
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      if(map[i-1][j]==0){
        dp[i][j]+=dp[i-1][j];
        dp[i][j]=dp[i][j]%mod;
      }
      if(map[i][j-1]==0){
        dp[i][j]+=dp[i][j-1];
        dp[i][j]=dp[i][j]%mod;
      }
    }
  }
  printf("%lld\n",dp[h][w]);
  return 0;
}

Measured memory_bytes: 16000
#include<iostream>
#define ll long long
using namespace std;

inline ll s(ll x) {
	ll res=0;
	while(x)  res+=x%10,x/=10;
	return res;
}
int main() {
	ll n,d=1,ans=1;
	cin>>n;
	cout<<1<<'\n';
	while(--n) {
		if((ans+10*d)*s(ans+d)<(ans+d)*s(ans+10*d))  d*=10;
		cout<<(ans+=d)<<'\n';
	}
	return 0;
}

Measured memory_bytes: 256
import sys,heapq,fractions
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
def ddprint(x):
  if DBG:
    print(x)

def foo(x,c,d):
    xc = (x)//c + 1
    xd = (x)//d + 1
    g = c * d // fractions.gcd(c,d)
    xg = (x)//g + 1
    z = x+1-(xc+xd-xg)
    ddprint("x {} c {} d {} xc {} xd {} g {} xg {} z {}".format(x,c,d,xc,xd,g,xg,z))
    return z

a,b,c,d = inm()
print(foo(b,c,d)-foo(a-1,c,d))


Measured memory_bytes: 5044
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();

        boolean flag = true;
        for (int i = 0 ; i < N ; i++) {
            int A = scanner.nextInt();
            if (A % 2 == 0 && A % 3 != 0 && A % 5 != 0) {
                System.out.println("DENIED");
                return;
            }
        }

        System.out.println("APPROVED");
    }
}


Measured memory_bytes: 35588
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}


int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c){
    if(a%2==0)cout<<-1<<endl;
    else cout<<0<<endl;
    return 0;
  }
  int tmp1,tmp2,tmp3;
  int counter=0;
  while(1){
    if(a%2==1||b%2==1||c%2==1) break;
    else {
      tmp1=a/2+b/2;
      tmp2=b/2+c/2;
      tmp3=c/2+a/2;
      counter++;
      a=tmp1;
      b=tmp2;
      c=tmp3;
    }
  }
  cout<<counter<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
int arr[101];
int N = 100;
std::vector<bool> IsPrime;

void sieve(size_t max) {
    if (max + 1 > IsPrime.size()) {     
        IsPrime.resize(max + 1, true); 
    }
    IsPrime[0] = false; 
    IsPrime[1] = false; 

    for (size_t i = 2; i*i <= max; ++i) 
        if (IsPrime[i]) 
            for (size_t j = 2; i*j <= max; ++j) 
                IsPrime[i*j] = false;      
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,d;
    cin >> n >> d;
    
    sieve(100);
    int ans = 0;
    for (int i = 2; i <= n; ++i) {
        if (IsPrime[i]==false) {
            for (int j = 2; j <= d; ++j) {
                int d1 = j / 10, d2 = j % 10;
                if (d2 >= 2 && d1 >= 2 && d1*d2 == i) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256