akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
using namespace std;

int main()
{
  int n;
  string tarou;
  string hanako;
  string buf;
  char c;

  int p_t=0;
  int p_h=0;
  int l;

  cin >> n;
  for(int i=0;i<n;i++)
    {
      cin >> tarou >> hanako;

      if(tarou.size()>hanako.size())
	l=hanako.size();
      else
	l=tarou.size();
    
      if(tarou==hanako)
	{
	  p_t++;
	  p_h++;
	}
      else
	{
	  for(int j=0;j<l;j++)
	    {
	      if(tarou[j]<hanako[j])
		{
		  p_h+=3;
		 
		  break;
		}
	      else if(tarou[j]>hanako[j])
		{
		  p_t+=3;
		  
		
		  break;

		}

	      if(j==l-1)
		{
		  if(tarou.size()>hanako.size())		
		    p_t+=3;		
		  else
		    p_h+=3;
		}
	    }
	}


    }

  cout << p_t << " " << p_h << endl;

  return 0;
}

Measured memory_bytes: 1208
#include<stdio.h>
#define MAX 100

int m[MAX+1][MAX+1];
int p[MAX+1];

int min(int a,int b)
{
  if( a > b ) return b;
  else return a;
}

int main()
{
  int n;
  int i,l;
  int j,k;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
      }

  for(i=1;i<=n;i++){
    m[i][i] = 0;
  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j = i + l - 1;
      m[i][j] = (1 << 21);
      for(k=i;k<=j-1;k++){
	m[i][j] = min(m[i][j],m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
      }
    }
  }
    
  printf("%d\n",m[1][n]);

  return 0;
}
  



Measured memory_bytes: 2052
import collections
N = int(input())
l=[]
for i in range(N):
    l.append(input())
c = collections.Counter(l)
values, counts = zip(*c.most_common())
s=len(values)
l=[]
for i in range(s):
    l.append(values[i])
    if i!=s-1 and counts[i] != counts[i+1]:
        break
l=sorted(l)
for i in l:print(i)

Measured memory_bytes: 59508
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	long long x,ans=0,g=100;
	cin>>x;
	while(g<x){
	    ans++;
	    g+=g/100;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(){
  int x,y;
  long int sum=0;
  scanf("%d%d",&x,&y);
    if(x<4)
      sum+=((4-x)*100000);
    if(y<4)
      sum+=((4-y)*100000);
  if(x==1&&y==1)
    sum+=400000;
  printf("%ld",sum);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <regex>
#include <climits>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define forin(i, a) for(auto i: (a))
#define p(...) printf(__VA_ARGS__); cout << endl;
#define in(...) __VA_ARGS__; input__(__VA_ARGS__);
#define input(...) in(__VA_ARGS__)
#define out(...) output__(__VA_ARGS__);
#define output(...) out(__VA_ARGS__)
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](auto const &a, auto const &b){ return c ;}
#define key(t, x, compare) [](const t &a, const t &b){ return a x compare b x ;}
#define unless(a) if(!(a))

using namespace std;

using pii = pair<int, int>;

template <class... T>
void input__(T &...a) {
  for(auto v: {&a...}) {
    cin >> *v;
  }
}

void output__(){
  cout << endl;
}

template <class Head, class... T>
void output__(Head const &v, T const &...a) {
  if(sizeof...(a) == 0) {
    cout << v;
  } else {
    cout << v << " ";
  }
  output__(a...);
}

int main(){
  long long in(n, a, b);
  if(n < a + b - 1 or a * b < n) {
    out(-1);
    exit(0);
  }

  long long at = n - b;
  long long top = n;

  vector<long long> results;
  while(top > 0) {
    FOR(i, top - min(a - 1, at), top + 1) {
      if(i == 0) {
        exit(0);
      }
      results.push_back(i);
    }

    top -= min(a - 1, at) + 1;
    at = at - (a - 1);
    if(at < 0) {
      at = 0;
    }
  }

  cout << results[0];
  for(auto bgn = results.begin() + 1; bgn != results.end(); bgn++) {
    cout << " " << *bgn;
  }
  cout << endl;
}


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

int main(){
  int N ; 
  cin >> N  ; 
  vector<vector<int>> A(N , vector<int>(3)) ;
  vector<vector<int>> dp(N , vector<int>(3)) ; 
  
  for(int i = 0 ; i < N ; i++){
    int a , b  ,c ;
    cin >> a >> b >> c ;
    A.at(i).at(0) = a ;
    A.at(i).at(1) = b ;
    A.at(i).at(2) = c ;    
  }
  for(int i = 0 ; i < 1 ; i++){
    for(int j = 0 ; j < 3 ; j++){
    	dp.at(i).at(j) = A.at(i).at(j);
    }
  }
  
  for(int i = 1 ; i < N ; i++){
    	dp.at(i).at(0) = max(dp.at(i-1).at(1)+A.at(i).at(0),dp.at(i-1).at(2)+A.at(i).at(0));
    	dp.at(i).at(1) = max(dp.at(i-1).at(0)+A.at(i).at(1),dp.at(i-1).at(2)+A.at(i).at(1));
    	dp.at(i).at(2) = max(dp.at(i-1).at(0)+A.at(i).at(2),dp.at(i-1).at(1)+A.at(i).at(2));      
    
  }
  
  cout << max(dp.at(N-1).at(0),max(dp.at(N-1).at(1),dp.at(N-1).at(2))) ; 

}

Measured memory_bytes: 13996
using namespace std;

#include <cstdio>
#include <cstdint>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>


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

    int     N = 0;
    int     n = 0;
    int     ans = 0;
    cin >> N;
    ans = N % 1000;
    if( ans != 0){
        ans = 1000 - ans;
    }

    cout << ans << "\n";
    return 0;
    
}


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

int main(){
  int n,tmp,num2=0;cin>>n;
  REP(i,n){
    cin>>tmp;
    if(!(tmp%4)) num2+=2;
    else if(!(tmp%2)) num2++;
  }
  cout<<((!(n%2)&&num2>=n)||((n%2)&&num2>=n-1)?"Yes":"No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h,w,op;
char s[105][105];
int dp[105][105];

int main(){
	cin>>h>>w;
	for(int i=1;i<=h;i++) cin>>s[i]+1;
	dp[1][1]=1;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(i+j==2) continue;
			dp[i][j]=1e9;
			if(i>1){
				if(s[i][j]!=s[i-1][j]) dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
				else dp[i][j]=min(dp[i][j],dp[i-1][j]);
			}
			if(j>1){
				if(s[i][j]!=s[i][j-1]) dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
				else dp[i][j]=min(dp[i][j],dp[i][j-1]);
			}
		}
	}
	if(s[1][1]=='#') cout<<(dp[h][w]+1)/2<<endl;
	else cout<<dp[h][w]/2<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
  ll n, h; cin >> n >> h;
  vector <pair <ll, ll>> a(n, pair <ll, ll> ());
  vector <pair <ll, ll>> b(n, pair <ll, ll> ());
  rep(i, n) {
    cin >> a.at(i).first >> b.at(i).first;
    a.at(i).second = i; b.at(i).second = i;
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  ll tmp_a = a.at(n-1).first, tmp_loc = a.at(n-1).second, tmp_b;
  rep(i, n) {
    if (b.at(i).second == tmp_loc) {
      tmp_b = b.at(i).first;
      break;
    }
  }
  ll res = 0;
  for (ll i = n-1; i >= 0; i--) {
    if (b.at(i).second != tmp_loc) {
      if (b.at(i).first > tmp_a) {
        h -= b.at(i).first;
        res++;
      }
    }
    if (h>0 && h-tmp_b<=0) {
      h = 0;
      res++;
    }
    if (h <= 0) break;
  }
  if (h > 0) {
    h -= tmp_b;
    res++;
    if (h > 0) {
      if (h%tmp_a) res += h/tmp_a+1;
      else res += h/tmp_a;
    }
  }
  cout << res << endl;
}

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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	// freopen("in.txt", "r", stdin);
	int n;
	cin >> n;
	int a[n];
	for(int i=0; i<n; i++) cin >> a[i];
	int ans = 0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			ans += a[i] * a[j];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _sc _il bool scan
_T T in(int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_il int in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _ot _il void out
#define _ol _il void outl
_ot(bool b) {pcu('0'+b);}
_ot(const char *s){while(*s)pcu(*s++);}
_ot(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_ot(string s){for(char c:s)pcu(c);}
#endif
_T _ot(T n){static char b[20];char *p=b,m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=n%10*m+'0',n/=10;while(p!=b)pcu(*--p);}
_ol(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _ot(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _ot(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _ol(T&&... t){out(move(t)...);outl();}

int main() {
	for (int N, M; N = in(), M = in();) {
		vector<int> t(N), u;
		for (int &p: t)
			p = in();
		t.push_back(0);
		sort(t.begin(), t.end());
		for (auto i = t.begin(); i != t.end(); i++)
			for (auto j = i; j != t.end(); j++)
				if (*i + *j <= M)
					u.push_back(*i + *j);
		sort(u.begin(), u.end());
		u.erase(unique(u.begin(), u.end()), u.end());
		int r = 0;
		for (auto i = u.begin(), e = u.end() - 1; i <= e; i++) {
			for (; *i + *e >= M; e--)
				;
			if (*i + *e > r)
				r = *i + *e;
		}
		outl(r);
	}
}


Measured memory_bytes: 6212
/*g++ main.cpp -o main.out*/
/*./main.out*/

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

#define LL long long
#define LD long double
//#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

LL a[1000005],s[1000005];

int main()
{
    rer(i,1,1000000)
    {
        if(i%3==0||i%5==0)a[i]=0;
        else a[i]=i;
        s[i]=s[i-1]+a[i];
    }
    int n;
    cin>>n;
    cout<<s[n]<<endl;
    return 0;
}


Measured memory_bytes: 19260
import math

n,a,b=(int(x) for x in input().split())

sum = a+b
n_num = math.floor(n/sum)
n_amari = n%sum

result = 0

if a != 0:
    result = a*n_num
    if n_amari != 0 and n_amari < a:
        result += n_amari
    elif n_amari != 0 and n_amari > a:
        result += a
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;
using ll = long long int;

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
void chmax(ll & a, ll b){if(a<b) a=b;};
int N;
vector<ll> A;

void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N;
    A.assign(3*N+1,0LL);
    for (int i = 1; i <= 3*N; i++) cin >> A[i];
}

int wrong_solve(){
    multiset<ll> le,ri;
    ll score=0;
    for (int i = 1; i <= N; i++)
    {
        le.insert(A[i]);
        ri.insert(A[2*N+i]);
    }
    auto itr_min = le.begin();
    auto itr_max = --ri.end();
    int l=N+1,r=2*N;
    int l_last=l-1,r_last=r+1;
    while(l_last<r && l<r_last){
        ll sl = A[l]-*itr_min;
        ll sr = *itr_max-A[r];
        if(sl>sr && sl>0){
            le.erase(itr_min);
            le.insert(A[l]);
            l_last=l;
            l++;
            itr_min = le.begin();
        } 
        else if(sl<sr && sr>0){
            ri.erase(itr_max);
            ri.insert(A[r]);
            r_last=r;
            r--;
            itr_max = --ri.end();
        }
        else if(sl<=0) l++;
        else if(sr<=0) r--;
    }
    for(auto itr=le.begin();itr!=le.end();++itr) {score += *itr; DBG(*itr)}
    for(auto itr=ri.begin();itr!=ri.end();++itr) {score -= *itr; DBG(*itr)}
    cout << score << endl;
    return 0;
}   

int solve(){
    multiset<ll> le,ri;
    vector<ll> L(3*N+1,0),R(3*N+1,0);
    L[1] = A[1];
    R[3*N] = 0;
    for (int i = 1; i < N; i++) L[i+1] = L[i]+A[i+1];
    for (int i = 3*N; i > 2*N; i--) R[i-1] = R[i]-A[i];

    for (int i = 1; i <= N; i++)
    {
        le.insert(A[i]);
        ri.insert(-A[2*N+i]);
    }    
    for (int i = N+1; i <= 2*N; i++)
    {
        L[i] = L[i-1];
        if(A[i]<=*le.begin()) continue;
        else{
            L[i] -= *le.begin();
            L[i] += A[i];
            le.erase(le.begin());
            le.insert(A[i]);
        }
    }
    for (int i = 2*N; i >= N+1; i--)
    {
        R[i-1] = R[i];
        if(-A[i]<=*ri.begin()) continue;
        else{
            R[i-1] -= *ri.begin();
            R[i-1] += -A[i];
            ri.erase(ri.begin());
            ri.insert(-A[i]);
        }
    }
    ll ans=-1e18;
    DBG(L)
    DBG(R)
    for (int i = N; i <= 2*N; i++) chmax(ans,L[i]+R[i]);
    cout << ans << endl;
    return 0;
}

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


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll dp[10100][2][110];
const ll MOD = 1e9+7;


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

  string S;
  cin >> S;
  int D;
  cin >> D;

  for(int i = 0; i <= S.length(); i++){
    for(int j = 0; j < 2; j++){
      for(int k = 0; k < D; k++){
        dp[i][j][k] = 0;
      }
    }
  }

  dp[0][0][0] = 1;

  for(int i = 0; i < S.length(); i++){
    for(int j = 0; j < 2; j++){
      for(int k = 0; k < 10; k++){
        int nj = j;
        if(j == 0 && k > (S[i] - '0')){
          continue;
        };
        if(j == 0 && k < (S[i] - '0')){
          nj = 1;
        }
        for(int d = 0; d < D; d++){
          dp[i+1][nj][(d+k)%D] += dp[i][j][d];
          dp[i+1][nj][(d+k)%D] = (dp[i+1][nj][(d+k)%D]) % MOD;
        }
      }
    }
  }

  ll ans = 0;
  ans = (dp[S.length()][0][0] + dp[S.length()][1][0] + MOD - 1) % MOD;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 17408
import sys
input = sys.stdin.readline

h,w = map(int,input().split())
c = []
for i in range(h):
  a = input()
  c.append(a)
  
from collections import deque

d = [[-1] * w for i in range(h)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

que = deque([])
for i in range(h):
  for j in range(w):
    if c[i][j] == '#':
      que.append((i,j,0))
      d[i][j] = 0

ans = 0
while que:
  p = que.popleft()
  for i in range(4):
      nw = p[1] + dx[i]
      nh = p[0] + dy[i]
      if 0 <= nw < w and 0 <= nh < h and d[nh][nw]==-1:
          que.append((nh,nw,p[2]+1))
          d[nh][nw] = p[2]+1
          ans = max(ans,p[2]+1)

print(ans)

Measured memory_bytes: 136540
#include <iomanip>
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int a, b; cin >> a >> b;
  
  cout << a/b << ' ' << a%b << ' ' << fixed << setprecision(7) << (double)a/double(b) << endl;
  return 0;
}

Measured memory_bytes: 1240
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);

        int c = a * b;
        if (c % 2 == 1)
        {
            Console.WriteLine("Odd");
        }
        else
        {
            Console.WriteLine("Even");
        }
    }
}

Measured memory_bytes: 11092
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 == 100000 || n == 10000 || n == 1000 || n == 100 || n == 10 ){
            System.out.println(10);
            return;
        }

        int sum = 0;
        int a = 0;
        while (n > 0){
            a = n % 10;
            n = n / 10;
            sum += a;
        }


        System.out.println(sum);
    }
}


Measured memory_bytes: 21972
#include <stdio.h>
#include <algorithm>
using namespace std;
const int N=123456;
int a[N];
int main()
{
    int n,c,k;
    scanf("%d %d %d",&n,&c,&k);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    int mins=a[0];
    int h=0;
    int s=0;
    for(int i=0;i<n;i++)
    {
        while(a[i]-mins<=k && i<n)
        {
            h++;
            //printf("h==%d\n",h);
            if(h==c || i==n-1)
            {
                s++;
                h=0;
                mins=a[i+1];
            }
            //printf("s==%d\n",s);
            i++;
            //printf("i==%d\n",i);
        }
        if(a[i]-mins>k)
        {
            s++;
            //puts("sajfk");
        }
        mins=a[i];
        i--;
        h=0;
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

int main(void)
{
  int n,k;
  cin>>n>>k;
  char s;
  if(n%k==0){
    cout<<"0"<<endl;
  }else{
    cout<<"1"<<endl;
  }
  return 0;
}


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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int n;
VI a(100100);
VI cnt(100010,0);

signed main()
{
    cin >> n;
    a.resize(n-1);
    cnt.resize(n);
    REP(i, n-1){
        cin >> a[i];
    }


    REP(i,n-1){
        cnt[a[i]-1]++;
    }

    REP(i, cnt.size()){
        cout << cnt[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 6996
import math

sm = 0
dishes = []
for i in range(5):
    nm = int(input())
    if nm % 10 == 0:
        sm += nm
        continue
    dishes.append(nm)
last = min(dishes, key=(lambda x: x % 10), default=0)
discovered = False
for e in dishes:
    if e == last and not discovered:
        discovered = True
        continue
    sm += math.ceil(e / 10.0) * 10

print(sm + last)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	long long a,b,c,d,n;cin>>a>>b>>c>>d>>n;
	c=min(c,4*a);
	c=min(c,2*b);
	long long ans=0;
	if(n%2==1)ans+=c;
	ans+=min(c*2,d)*(n/2);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>

using namespace std;
typedef pair<int,bool> Pair;

int main(){

  int A,H;
  int cnt = 0;

  cin >> H >> A;

  while(H > 0){

    H = H - A;
    cnt++;

  }

  cout << cnt << endl;

  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

int main() {
    cin>>S;
    N = S.size();
    vec num(2019, 0);
    ++num[0];
    ll temp = 1, sum = 0, mod = 2019, ans = 0;
    Rrep(i,N){
        (sum += temp * (S[i] - '0'))%=mod;
        ans += num[sum];
        ++num[sum];
        (temp *= 10)%=mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,x,y;
    scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
    if((a+b)>=2*c)
    {
        if(x>=y)
        {
            int ans=c*2*y+(x-y)*a;
            int s=c*2*x;
            ans=min(ans,s);
            printf("%d\n",ans);
        }
        else
        {
            int ans=c*2*x+(y-x)*b;
            int s=c*2*y;
            ans=min(ans,s);
            printf("%d\n",ans);
        }
    }
    else
    {
        int ans=a*x+b*y;
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

ll dp[3005][3005];
int aray[3005];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    rep(i, n) cin >> aray[i];
    for(int l=n-1; l>=0; l--)
        iter(r, l, n+1) {
            if(l == r) {
                dp[l][r] = 0;
                continue;
            }
            dp[l][r] = max(aray[r-1] - dp[l][r-1], aray[l] - dp[l+1][r]);
        }
    cout << dp[0][n] << endl;
}



Measured memory_bytes: 70016
#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <string>
#include <string.h>
#include <limits>
#include <utility>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <chrono>
#include <cmath>

using namespace std;

namespace
{

}

#if 1
int main()
{
	const string origin = "keyence";
	string str;
	cin >> str;

	for (size_t i = 0; i < str.size(); i++)
	{
		for (size_t j = 0; j < str.size() - i; j++)
		{
			string t = str;
			t.erase(i, j);
			if (t == origin)
			{
				cout << "YES";
				return 0;
			}
		}
	}

	cout << "NO";
	return 0;
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 5e3 + 30, Mod = 998244353;
const ll SQ = 330;

ll mul(ll a, ll b) {
	return (a * b) % Mod;
}
ll sum(ll a, ll b) {
	return (a + b + Mod) % Mod;
}
ll dp[N][N], n, s, a[N]; 
int main () {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> s;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	dp[0][0] = 1;
	for (int i = 1; i <= n; i ++) {
		for (int j = 0; j < N; j ++) {
			ll val = a[i];
			ll res = 0;
			if (j >= val) res = mul(1, dp[i - 1][j - val]);
			res = sum(res, mul(2, dp[i - 1][j]));
			dp[i][j] = res;
		}
	}
	cout << dp[n][s];
}

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

int main(){
  
  string s;
  cin >>s;
  int ca=0,cb=0;
  for(int i=0; i<s.size(); i++){
  	if(s[i]=='0') ca++;
    else cb++;
  }
  
  cout << min(ca,cb)*2 << endl;
  
}

Measured memory_bytes: 512
input()
A = list(input())
B = list(input())
C = list(input())

ans = 0
for a, b, c in zip(A, B, C):
  if a == b == c:
    ans += 0
  elif a == b or b == c or c == a:
    ans += 1
  else:
    ans += 2
print(ans)

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m;
    cin >> n >> m;
    cout << min(m / 2, (m + 2 * n) / 4) << '\n';
}


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

using pii = pair<int, int>;

constexpr int inf = 1e9;

// 0-indexed
template <typename T>
class fenwick_tree {
public:
    fenwick_tree(int n) : n(n), dat(n, 0) {}

    void add(int i, T value) {
        for(; i<n; i |= i + 1) {
            dat[i] += value;
        }
    }

    T sum(int i) const {
        T res = 0;
        for(; i>=0; i = (i & (i+1)) - 1) {
            res += dat[i];
        }
        return res;
    }
    // [l, r)
    T sum(int l, int r) const {
        return sum(r-1) - sum(l-1);
    }

private:
    const int n;
    std::vector<T> dat;
};

int main() {
    int n;
    cin >> n;
    n = 2 * n;
    vector<char> c(n);
    vector<int> a(n);
    vector<pii> b, w;
    for(int i = 0; i < n; ++i) {
        cin >> c[i] >> a[i];
        if(c[i] == 'B') {
            b.emplace_back(a[i], i);
        } else {
            w.emplace_back(a[i], i);
        }
    }
    sort(begin(b), end(b));
    sort(begin(w), end(w));

    const int wn = w.size();
    const int bn = b.size();

    vector<vector<int>> cnt_w(wn + 1, vector<int>(bn + 1)), cnt_b(bn + 1, vector<int>(wn + 1));
    for(int i = 0; i < wn; ++i) {
        int cnt = 0;
        for(int j = 0; j < i; ++j) {
            if(w[i].second < w[j].second) {
                cnt += 1;
            }
        }
        fenwick_tree<int> bit(n + 1);
        for(int j = 0; j <= bn; ++j) {
            cnt_w[i][j] = cnt + bit.sum(0, w[i].second);
            bit.add(0, 1);
            bit.add(b[j].second, -1);
        }
    }
    for(int i = 0; i < bn; ++i) {
        int cnt = 0;
        for(int j = 0; j < i; ++j) {
            if(b[i].second < b[j].second) {
                cnt += 1;
            }
        }
        fenwick_tree<int> bit(n + 1);
        for(int j = 0; j <= wn; ++j) {
            cnt_b[i][j] = cnt + bit.sum(0, b[i].second);
            bit.add(0, 1);
            bit.add(w[j].second, -1);
        }
    }

    vector<vector<int>> dp(n + 1, vector<int>(bn + 1, inf));
    dp[0][0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= bn; ++j) {
            if(i - j < 0) continue;
            if(dp[i][j] == inf) continue;
            if(j + 1 <= bn) {
                int bp = b[j].second + cnt_b[j][i - j];
                dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + max(0, bp - i));
            }
            if(i - j < (int)w.size()) {
                int wp = w[i - j].second + cnt_w[i - j][j];
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + max(0, wp - i));
            }
        }
    }
    //for(int i = 0; i <= n; ++i) {
    //    for(int j = 0; j <= bn; ++j) {
    //        cout << dp[i][j] << ' ';
    //    }
    //    cout << endl;
    //}

    cout << dp[n][bn] << endl;
}


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

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

int main()
{
	int n;
	cin >> n;
	VI  a(n), b(n), c(n-1);
	IN(n, a);
	IN(n, b);
	IN(n-1, c);

	int ans = 0;
	FOR(0, n)
	{
		ans += b[a[i] - 1];
		if (i < n - 1 && (a[i] + 1) == a[i + 1])  ans += c[a[i] - 1];
	}
	
	cout << ans << endl;
}

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

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

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

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

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

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

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

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

fn main() {
    input! {
        n:i32,
    }
    println!("{}", (n + 1) / 2);
}


Measured memory_bytes: 4476
#include<stdlib.h>
#define N 100009
typedef long long LL;
int up(int*a,int*b){return*(int*)a-*(int*)b;}
int dn(int*a,int*b){return*(int*)b-*(int*)a;}
int n,i,a[N],b[N],c[N];LL ans=0;
#define rp for(i=0;i<n;i++)
int compA(int x,int y){return a[y]>=x?1:0;}
int compC(int x,int y){return c[y]<=x?1:0;}
LL BS(int x,int n,int c){
  int O=n,X=-1,mid=n/2;
  while(O-X>1){mid=(O+X)/2;c?(compA(x,mid)?(O=mid):(X=mid)):(compC(x,mid)?(O=mid):(X=mid));}
  return O;
}

int main(){
  scanf("%d",&n);
  rp scanf("%d",a+i);qsort(a,n,4,up);
  rp scanf("%d",b+i);qsort(b,n,4,up);
  rp scanf("%d",c+i);qsort(c,n,4,dn);
  rp ans+=BS(b[i],n,1)*BS(b[i],n,0);
  printf("%lld",ans);
}

Measured memory_bytes: 3276
l, r= map(int,input().split())
li=[]
ans=1000000

if r-l>=2019:
    print(0)
else:
    for i in range(l,r+1):
        li.append(i%2019)
    for i in range(len(li)):
        for j in range(i+1,len(li)):
            #print(i,j)
            ans=min(ans,li[i]*li[j]%2019)
    print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int N, D;
	cin >> N >> D;
	vector<vector<int>> x(N, vector<int>(D));
	REP(i, N) {
		REP(j, D) {
			cin >> x[i][j];
		}
	}
	int cnt = 0;
	REP(i, N - 1) {
		FOR(j, i + 1, N) {
			int d2 = 0;
			REP(k, D) {
				int tmp = x[i][k] - x[j][k];
				d2 += tmp * tmp;
			}
			int l = 1;
			while (l*l < d2) l++;
			if (l*l == d2) cnt++;
		}
	}
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(1){
    c-=b;
    if(c<=0){  
    cout<<"Yes"<<endl;
    break;
    }
    a-=d;
    if(a<=0){
      cout<<"No"<<endl;
      break;
    }
  }
  
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

signed main(){
    int A,B,C,D; cin>>A>>B>>C>>D;
    int HPT = A/D;
    if(A%D != 0) HPT += 1;
    int HPA = C/B;
    if(C%B != 0) HPA += 1;
    if(HPT>=HPA) Out("Yes");
    else Out("No");
}

Measured memory_bytes: 3640
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let a = get!([usize]);
    let mut count = 1;
    let mut state = None;
    for i in 0..n-1 {
        if a[i] < a[i+1] {
            if state.is_none() {
                state = Some(true);
            } else if !state.unwrap() {
                state = None;
                count += 1;
            }
        } else if a[i] > a[i+1] {
            if state.is_none() {
                state = Some(false);
            } else if state.unwrap() {
                state = None;
                count += 1;
            }
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 10620
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long K, string S) {
    return min(N - S.group.count + 2 * K, N - 1);
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long K;
    K = input.front.to!long;
    input.popFront;

    string S;
    S = input.front.to!string;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(N, K, S);
    else
        solve(N, K, S).writeln;
}


Measured memory_bytes: 2556
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
         
        int[] a = new int[m];
        int[] b = new int[m];
         
        int cost = 0;
        int max = 0;
        for(int i = 0; i < m; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            if( a[i] < n) {
                int x = n - a[i];
                cost += x;
                max = Math.max(max, x);
            }
        }
         
        System.out.println(Math.max(0, cost - max));
    }
}


Measured memory_bytes: 31528
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

int main(void) {
  int W,H,N;

  std::cin >> W >> H >> N;
  
  int map[100][100] = {0};

  for (int i = 0; i < N; ++i) {
    int x, y, a;
    std::cin >> x >> y >> a;
    switch (a) {
      case 1:
        for (int i = 0; i < x; i++) {
          for (int j = 0; j < H; j++) {
            map[i][j] = 1;
          }
        }
        break;
      case 2:
        for (int i = x; i < W; i++) {
          for (int j = 0; j < H; j++) {
            map[i][j] = 1;
          }
        }
        break;
      case 3:
        for (int i = 0; i < W; i++) {
          for (int j = 0; j < y; j++) {
            map[i][j] = 1;
          }
        }
        break;
      case 4:
        for (int i = 0; i < W; i++) {
          for (int j = y; j < H; j++) {
            map[i][j] = 1;
          }
        }
        break;
      default:
        break;
    }
  }

  int count = 0;
  for (int i = 0; i < W; i++) {
    for (int j = 0; j < H; j++) {
      if (map[i][j] == 0) {
        count++;
      }
    }
  }
  
  std::cout << count << std::endl;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,avx,avx2,popcnt,tune=native")
#pragma comment(linker, "/STACK:36777216")
#pragma GCC optimize("Ofast")
#define _CRT_SECURE_NO_WARNINGS

#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <time.h>//////////////
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define queuel queue<long long>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(), v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for (auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for (int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for (int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for (int i = 0; i < n; ++i){int a; cin >> a; s.insert(a); }
#define fastio() ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); srand(time(NULL))
#define sp system("pause")
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;//СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚
					//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const int MAXN = 6e3 + 228;
const int inf = 1e9;
const ld PI = acos(-1);
const int mod = (int)998244353;
const int MOD = 1000000007;
const int MOD9 = 1000000009;
const int a228 = 18;
const ld obr = (ld)1 / sqrt(2);
int main()
{
	int a, b;
	cin >> a >> b;
	if (a % 2 != b % 2)
	{
		cout << "IMPOSSIBLE";
	}
	else cout << (a + b) / 2;
}


//you should actually read the stuff at the bottom
/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?), set tle
* do smth instead of nothing and stay organized
*/

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

int prime(int a){
    for(int i=2;i*i<= a;i++){
        if(a%i==0)
            return 0;
    }
    return 1;
}

int main(){
    int n,x,sum=0;
     cin >> n;
    for(int i = 0;i<n;i++){
        cin >> x;
        sum+= prime(x);
    }
    cout << sum <<endl;
    
}




Measured memory_bytes: 3096
n = int(input())
a = list(map(int, input().split()))
m = 0
b = []
box = [0] * n

for i in range(n, 0, -1):
    if i > n//2:
        if a[i-1] == 1:
            box[i-1] += 1
    elif i == 1:
        if a[0] != (sum(box) % 2):
            box[0] += 1
    elif a[i-1] != (sum(box[i-1:: i]) % 2):
        box[i-1] += 1

for i in range(n):
    if box[i] == 1:
        m += 1
        b.append(i+1)

print(m)
for x in b:
    print(x, end=' ')


Measured memory_bytes: 12468
from collections import deque
N = int(input())
edge = [[] for _ in range(N+1)]
for i in range(N):
  A = list(map(int, input().split()))
  edge[A[0]] = A[2:]

ans = [-1]*N
ans[0] = 0
d = deque([[1,0]])
while len(d)>0:
  v,dist = d.popleft()
  for w in edge[v]:
    if ans[w-1]==-1:
      ans[w-1]=dist+1
      d.append([w,dist+1])
for i in range(N):
  print(i+1,ans[i])


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

using namespace std;

typedef long long LL;
#define N 60

LL n,m,p,s,t,k,c[N][N],a[N],b[N],C[N],f[1<<18],ans;


void fmt(LL f[]){
	for (LL i=0;i<k;++i){
		for (LL j=0;j<1<<k;j+=1<<(i+1)){
			LL *f0=f+j,*f1=f+j+(1<<i);
			for (LL t=0;t<1<<i;++t) f1[t]+=f0[t];
		}
	}
}

LL bit(LL x,LL k){
	return x>>k&1;
}

int main(){
	scanf("%lld%lld%lld%lld",&n,&m,&s,&t);
	if ((s|t)!=t){puts("0"); return 0;}
	for (LL i=0;i<18;++i){
		if (bit(s,i)!=bit(t,i)){
			b[k++]=i;
		}
	}
	for (LL i=1;i<=n;++i){
		LL x; scanf("%lld",&x);
		if ((x&s)!=s) continue;
		if ((x|t)!=t) continue;
		++p;
		for (LL j=0;j<k;++j){
			a[p]|=bit(x,b[j])<<j;
		}
	}
	for (LL i=0;i<=n;++i){
		c[i][0]=1;
		for (LL j=1;j<=i;++j) c[i][j]=c[i-1][j]+c[i-1][j-1];
	}
	for (LL i=0;i<=n;++i){
		for (LL j=0;j<m;++j) C[i]+=c[i][j];
	}
	for (LL i=1;i<=p;++i){
		memset(f,0,sizeof f);
		for (LL j=i+1;j<=p;++j){
			++f[a[j]^a[i]];
		}
		fmt(f);
		for (LL j=0;j<1<<k;++j){
			ans+=C[f[j]]*((k-__builtin_popcount(j))&1?-1:1);
		}
	}
	printf("%lld\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 5844
#include<stdio.h>

int main(){
	int n, k, i;
	scanf("%d", &n);
	int a[n];
	for(i=0; i<n; i++){
		a[i]=0;
	}
	for(i=0; i<n-1; i++){
		scanf("%d", &k);
		a[k-1]++;
	}
	for(i=0;i<n; i++){
		printf("%d\n", a[i]);
	}
	return 0;
}

Measured memory_bytes: 2512
import scala.io.StdIn.{readLine, readInt};
object Main {
    def main(args: Array[String]): Unit = {
        val n = readInt;
        val p = new Array[Int](n + 1);
        (1 to n).foreach { i => 
            val input = readLine.split(" ").map(_.toInt);
            if (i == 1) p(0) = input(0);
            p(i) = input(1);
        }
        println(mcm(n, p));
    }
    def mcm(n: Int, p: Array[Int]): Int = {
        val dp = Array.ofDim[Int](n + 1, n + 1);
        (0 to n).foreach { y => (0 to n).foreach { x => if (y != x) dp(y)(x) = -1}};
        // y番目(包含)からx番目(包含)までの連鎖行列積を求める。
        def _go(y: Int, x: Int): Int = {
            if (dp(y)(x) != -1) {
                dp(y)(x);
            } else {
                // M1, M2, M3, M4 の中からコストが最小となるような区切り方を選択する。(y=1, x=4)
                //  [M1], [M2, M3, M4]  /  [M1, M2], [M3, M4]  /  [M1, M2, M3], [M4] 
                val min = (y until x).foldLeft(-1) { (minCost, sep) =>
                    // 今回の増分 = 左辺の行数 * 左辺の列数 * 右辺の列数
                    val incremental = p(y - 1) * p(sep) * p(x);
                    // 左辺の最小コスト * 右辺の最小コスト * 今回の増分
                    val cost = _go(y, sep) + _go(sep + 1, x) + incremental;
                    if (minCost > 0 && minCost < cost) minCost else cost;
                }
                dp(y)(x) = min;
                min;
            }
        }
        _go(1, n);
    }
}



Measured memory_bytes: 53572
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#define re register
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define MAXN 4000007
#define mo 19930726
#define ll long long
using namespace std;
typedef unsigned long long ull;
#define ms(arr) memset(arr, 0, sizeof(arr))
const int inf = 0x3f3f3f3f;
ll n,a[200001],sum[200001],sor[200001];
int main()
{
	cin>>n;
	for(re int i=1;i<=n;i++){
		cin>>a[i];
		sum[i]=sum[i-1]+a[i];
		sor[i]=sor[i-1]^a[i];
	}
	ll ans=0;
	for(re int i=1;i<=n;i++){
		int l=i,r=n;
		while(l<=r){
			int mid=l+r>>1;
			if(sum[mid]-sum[i-1]!=(sor[mid]^sor[i-1])) r=mid-1;
			else l=mid+1;
		}
		ans+=l-i;
	}
	cout<<ans;
}

Measured memory_bytes: 4992
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP2(i,n,s) for(int i=(int)s;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

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

    int m = max({a,b,c});
    if((3*m-(a+b+c))%2 == 0) {
        cout << (3*m-(a+b+c))/2 << endl;
    }else{
        cout << (3*(m+1)-(a+b+c))/2 << endl;
    }
}


Measured memory_bytes: 256