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

using namespace std;


int main(){
	int N;
	scanf("%d",&N);
	int S[N];
	for(int i = 0; i < N; i++)scanf("%d",&S[i]);

	int M;
	scanf("%d",&M);

	int Q[M];
	for(int i = 0; i < M; i++)scanf("%d",&Q[i]);
	sort(Q,Q+M);

	int left = 0,right,m,count = 0;

	for(int i = 0; i < M; i++){
		right = N-1;
		m = (left+right)/2;

		while(left <= right){
			if(S[m] == Q[i]){
				count++;
				left= m+1;
				break;
			}else if(S[m] > Q[i]){
				right = m-1;
			}else{ //S[m] < Q[i]
				left = m+1;
			}
			m = (left+right)/2;
		}
	}
	printf("%d\n",count);
}


Measured memory_bytes: 3820
using System;

class alds13b
{
    struct work
    {
        public string name;
        public int lt;
    }
    static void Main()
    {
        System.Collections.Generic.Queue <work> Q= new System.Collections.Generic.Queue<work>(); 
        String[] setup = Console.ReadLine().Split(' ');
        int n = int.Parse(setup[0]);
        int q = int.Parse(setup[1]);
        int tt=0;
        for (int i = 0; i < n; i++)
        {
            string[] input = Console.ReadLine().Split(' ');
            Q.Enqueue(new work{name=input[0],lt=int.Parse(input[1])});
        }
        while(Q.Count>0){
            work cw = Q.Dequeue();
            if(cw.lt>q){
                cw.lt-=q;
                tt+=q;
                Q.Enqueue(cw);
            }else{
                tt+=cw.lt;
                Console.WriteLine(cw.name +" "+tt);
            }
        }
    }
}

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

using namespace std;

int main() {
    string S, data;
    cin >> S;

    data = "ACGT";

    int sum = 0;
    int ans = 0;

    for (int i = 0; i < S.size(); i++) {
        bool isACGT = false;
        for (int j = 0; j < data.size(); j++) {
            if (S[i] == data[j]) {
                sum++;
                isACGT = true;
            }
        }
         if (!isACGT) {
             sum = 0;
         } else {
             ans = max(sum, ans);
         }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
r,g,b,n=map(int,input().split())

rr=n//r+1
gg=n//g+1
bb=n//b+1
ans=0
for i in range(rr):
  for j in range(gg):
    x=i*r+j*g
    if (x>n):
      break
    if (n-x)%b==0:
      ans+=1
print(ans)

Measured memory_bytes: 66636
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
#define mod 1000000007;
using namespace std;


int main(){
    int i,k;
    char S[59];
    cin>>i>>k;
    cin >>S;
    S[k-1]+=32;
    cout << S << endl;
}



Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 998244353;
ll power(ll x, ll y, ll p) {
	ll res = 1;
	x = x % p;
	while (y) {
		if (y & 1ll)res = (res * x) % p;
		y = y >> 1ll;
		x = (x * x) % p;
	}
	return res;
}
signed main(){
  int n;
  cin>>n;
  map<int,ll> m;
  int c,mi=0;
  for(int i=0;i<n;++i){
    cin>>c;
    if(!i&&c)return cout<<0,0;
    mi=max(mi,c);
    ++m[c];
  }
  if(n==1)return cout<<(c?0:1),0;
  int res=1;
  for(int i=1;i<=mi;++i)res=(res * power(m[i-1],m[i],mod))%mod;
  if(m[0]!=1)res=0;
  for(int i=1;i<=mi;++i)if(m[i]==0)res=0;
  cout << res << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;

#define rep(i, from, to) for(int i = from; i < to; i++)
#define inf 1000000000

int main(){
  ll Q,H,S,D,N,res = 0;
  cin >> Q >> H >> S >> D >> N;
  res += min(min(8*Q,4*H),min(2*S,D))*(N/2);
  if (N%2 == 1){
    res += min(min(4*Q,2*H),S);
  }
  cout << res << endl;
}


Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,m = inpm()
    a = inpl()
    ans = n-sum(a)
    if ans >= 0:
        print(ans)
    else:
        print(-1)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 72992
# -*- coding: utf-8 -*-
n, m, x = map(int, input().split())
a = [0]*n
for i in range(n):
    a[i] = list(map(int, input().split()))

result = -1
for i in range(2**n):
    rikai = [0]*m
    cost = 0
    # print(bin(i))
    for j in range(n):
        if ((i >> j) & 1):
            for k in range(m):
                rikai[k] += a[j][k+1]
            cost += a[j][0]
        # print(rikai)
    satisfied = True
    for rj in rikai:
        if rj < x:
            satisfied = False
            break

    if result == -1:
        if satisfied:
            result = cost
    else:
        if satisfied & (cost<result):
            result = cost

print (result)



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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll r;
    cin >> r;
    MSG(pow(r, 2))
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b,c,d=0,e=0;
while(scanf("%d,%d,%d\n",&a,&b,&c)!=EOF){
if(a*a+b*b==c*c){
d++;
}
else if(a==b){
e++;
}
}
printf("%d\n",d);
printf("%d\n",e);
return 0;
}


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

int main(){

  int stack[10] = {};
  int p = 0;

  while(cin >> stack[p]){
    if(stack[p] == 0){
      cout << stack[p-1] << endl;
      p--;
    }
    else{
      p++;
    }
  }
 
  return 0;
}

Measured memory_bytes: 1160
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	h := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}

	ans, cnt := 0, 0
	for i := 1; i < n; i++ {
		if h[i] <= h[i-1] {
			cnt++
		} else {
			if ans < cnt {
				ans = cnt
			}
			cnt = 0
		}
	}
	if ans < cnt {
		ans = cnt
	}
	fmt.Println(ans)
}


Measured memory_bytes: 7296
//sieu nhan
#include <bits/stdc++.h>
using namespace std;
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
#define rand rd
#define int long long
#define inp "test.inp"
#define out "test.out"
#define oo 55
#define inf 1e15
#define mod 1000000007
#define rese(x,y) memset(x,y,sizeof(x))
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define y1 hungdzno1
int n,A,a[oo],f[oo][oo*100];
void nhap(){
  cin>>n>>A;
  for(int i=1;i<=n;++i) cin>>a[i];
}
void xuly(){
  f[0][2500]=1;
  for(int i=1;i<=n;++i){
		a[i]-=A;
		for(int j=0;j<5001;++j){
			f[i][j]+=f[i-1][j];
			f[i][j+a[i]]+=f[i-1][j];
		}
	}
	cout<<f[n][2500]-1;
}
main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  nhap();
  xuly();
}


Measured memory_bytes: 2432
list = []
list.append(input())
list.append(input())
list.append(input())
list.append(input())
list.append(input())

k = input()

ju = "Yay!"

for i in range(5):
    for j in range(5):
        if i == j:
            pass
        else:
            dis = abs(int(list[i]) - int(list[j]))
            if dis > int(k):
                ju = ":("

print(ju)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>

using namespace std;

class Stu{
public:
    int m;
    int f;
    int r;
    Stu(int _m, int _f, int _r) : m(_m), f(_f), r(_r) {}
};

int main(){
    int r, c;
    cin >> r >> c;
    int **Input = new int*[r];
    for (int i = 0; i < r; i++)
    {
        Input[i] = new int[c];
        for (int j = 0; j < c; j++)
        {
            cin >> Input[i][j];
        }
    }

    int sum = 0;
    for (int i = 0; i < r; i++)
    {
        sum = 0;
        for (int j = 0; j < c + 1; j++)
        {
           if(j == c){
               cout << sum << endl;
           }else{
               cout << Input[i][j] << " ";
               sum += Input[i][j];
           }
        }
    }
    
    int sumAll = 0;
    for (int i = 0; i < c; i++)
    {
        sum = 0;
        for (int j = 0; j < r+1; j++)
        {
           if(j == r){
               cout << sum << " ";
               sumAll += sum;
           }else{
               sum += Input[j][i];
           }
        }
    }
    cout << sumAll << endl;

    return 0;
}


Measured memory_bytes: 3120
n,m,q = map(int,input().split())
li = [[0 for _ in range(n)] for _ in range(n)]

for i in range(m):
    l,r = map(int,input().split())
    li[l-1][r-1] += 1

li2 = [[0 for _ in range(n)] for _ in range(n)]
li3 = [[0 for _ in range(n)] for _ in range(n)]

for i in range(n):
    for j in range(n):
        if j == 0:
            li2[i][j] = li[i][j]
        else:
            li2[i][j] = li2[i][j-1] + li[i][j]

for i in range(n):
    for j in range(n):
        if i == 0:
            li3[i][j] = li2[i][j]
        else:
            li3[i][j] = li3[i-1][j] + li2[i][j]

for i in range(q):
    p,q = map(int,input().split())
    if p == 1:
        print(li3[q-1][q-1])
    else:
        print(li3[q-1][q-1]-li3[q-1][p-2]-li3[p-2][q-1]+li3[p-2][p-2])


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

int main() {
  int64_t a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;
  int x=abs(a-b);
  int y=v-w;
  if(y<=0)cout<< "NO" << endl;
  else{
    if(x-y*t<=0) cout<< "YES" << endl;
    else cout<< "NO" << endl;
  }

}

Measured memory_bytes: 3632
#n = int(input())
n, d = map(int, input().split())
#a = list(map(int, input().split()))
#a = [list(map(int, input().split())) for i in range(n)]
ans = 0
from math import sqrt
for i in range(n):
  x, y = map(int, input().split())
  dis = sqrt(x**2+y**2)
  if dis<=d:
    ans+=1
print(ans)

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

int main(){
    int N; int M;
    cin >> N >> M;
    long long x[1010], y[1010], z[1010];
    for(int i=0; i<N; i++){
        cin >> x[i] >> y[i] >> z[i];
    }
    long long dx[2]={1,-1};
    long long dy[2]={1,-1};
    long long dz[2]={1,-1};

    long long ans=0;
    for(int i=0; i<2; i++){
        for(int j=0; j<2; j++){
            for(int k=0; k<2; k++){
                long long x1[1010],y1[1010],z1[1010];
                long long s[1010];
                for(int l=0; l<N; l++){
                    x1[l]=x[l]*dx[i];
                    y1[l]=y[l]*dy[j];
                    z1[l]=z[l]*dz[k];
                    s[l]=x1[l]+y1[l]+z1[l];
                }
                sort(s,s+N,greater<long long>());
                long long ans1=0;
                for(int l=0; l<M; l++){
                    ans1 +=s[l];
                }
                ans = max(ans, ans1);
            }
        }
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char Ga[610][610];
char Gb[310][310];

int main()
{
  int64_t N, ans = 0;
  cin >> N;
  char c;
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      cin >> c;
      Ga[i][j] = Ga[i + N][j] = Ga[i][j + N] = Ga[i + N][j + N] = c;
    }
  }
  for (int a = 0; a < N; a++)
  {
    for (int b = 0; b < N; b++)
    {
      bool ok = 1;
      for (int i = a + 1; i < N + a; i++)
      {
        for (int j = b; j < (i - a) + b; j++)
        {
          if (Ga[i][j] != Ga[j - b + a][i - a + b]) // i-a, j-b -> j-b, i-a -> j-b+a, i-a+b
          {
            ok = 0;
            break;
          }
        }
        if (!ok)
          break;
      }
      if (ok)
        ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3968
//#pragma warning(disable:4996)
//#include <Windows.h>
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;
template<class T>
using pqueue = priority_queue<T, vector<T>, function<bool(T, T)>>;

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

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

void input();
void solve();

void daminput();
void naive();

void outputinput();

int main() {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	input();
	//daminput();
	solve();
	//naive();
	//outputinput();
	return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////

LL N;

void input() {
	cin >> N;
}

void daminput() {
}

//ax+by=gcd(a,b)の解
LL extgcd(LL a, LL b, LL& x, LL& y) {
	LL d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1; y = 0;
	}
	return d;
}

//約数列挙(重複分も個数回追加)
void enumerateFactors(LL N, vector<LL>& V) {
	LL p = 2;
	while (N > 1) {
		if (p * p > N) {
			V.push_back(N);
			return;
		}
		if (N % p == 0) {
			V.push_back(p);
			N /= p;
		}
		else p++;
	}
	return;
}

bigint solve(LL u, LL v) {
	LL x;
	LL y;
	extgcd(u, v, x, y);
	LL t1 = x / v;
	LL t2 = (-y) / u;
	bigint t(max(t1, t2));
	bigint vb(v);
	bigint ub(u);
	bigint xb(x);
	bigint yb(y);
	while (v * t <= x || u * t <= -y)t++;
	bigint a = vb * t - xb;
	bigint k = a * ub;
	return k;
}

void solve() {
	vector<PLL> primes;   //(prime,time)
	{
		VLL V;
		enumerateFactors(2*N, V);
		primes.push_back(PLL(V[0], 1));
		for (int n = 1; n < V.size(); n++) {
			LL p = V[n];
			if (primes.back().first == p)primes.back().second++;
			else primes.push_back(PLL(p, 1));
		}
	}
	for (PLL& pll : primes) {
		LL p = pll.first;
		LL ans = 1;
		for (int t = 0; t < pll.second; t++) {
			ans *= p;
		}
		pll.first = ans;
	}
	bigint ans(1e15);
	ans *= ans;
	for (int code = 0; code < ((LL)1 << primes.size()); code++) {
		LL first = 1;
		LL second = 1;
		for (int b = 0; b < primes.size(); b++) {
			if (((1 << b) & code) != 0)first *= primes[b].first;
			else second *= primes[b].first;
		}
		bigint k = solve(first, second);
		if (ans > k)ans = k;
	}
	cout << ans << "\n";
}

void naive() {
}

void outputinput() {
}

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

using namespace std;

int main(){
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for(int i=0;i<N;i++){ // Separate point
    int cnt=0;
    for(int c='a';c<='z';c++){
      int f=0;
      for(int k=0;k<N;k++){
        if(S[k] == c) f |= k<=i?1:2;
      }
      if(f == 3) cnt++;
    }
    ans = max(ans, cnt);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
	int front[10];
	int side[10];
	int w,d;
	int i,j;
	int result;
	while(1) {
		scanf("%d%d",&w,&d);
		if(w==0 && d==0)break;
		for(i=0;i<w;i++)scanf("%d",&front[i]);
		for(i=0;i<d;i++)scanf("%d",&side[i]);
		for(i=0;i<w;i++) {
			for(j=0;j<d;j++) {
				if(front[i]==side[j]) {
					side[j]=0;
					break;
				}
			}
		}
		result=0;
		for(i=0;i<w;i++)result+=front[i];
		for(i=0;i<d;i++)result+=side[i];
		printf("%d\n",result);
	}
	return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n;
double ans;
vector<int> v;

signed main() {
    cin >> n;
    rep(i,n) {
        int tmp;
        cin >> tmp;
        v.pb(tmp);
    }
    sort(all(v));
    ans = (v[0]+v[1])/2.0;
    repo(i,2,n) ans = (ans+v[i])/2.0;
    cout << ans << endl;


}




Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int k, n=0;
    cin>>k;
    for (int i=1; i<=k; i++) {
        if (i%2==0) n++;
    }
    if (k%2==0) cout << n*n<<endl;
    else cout << n * (n+1) << endl;
    return 0;
}


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

struct newrm{
  ll start,end,dot;
  newrm* next;
};
void write(newrm* begin,ll i,ll s){
  ll tmp;
  newrm *prev,*pres,*sinki;
  
  prev=begin;
  pres=prev->next;

  while(pres!=NULL){
    tmp=pres->start-prev->end;
    if(tmp==1){
    }
    else{
      sinki=new newrm();
      sinki->start=prev->end+1;
      sinki->dot=i;
      if(tmp-1<s){
	sinki->end=pres->start-1;
	s-=tmp-1;
      }
      else 	{
	sinki->end=sinki->start+s-1;
	s=0;

      }
      prev->next=sinki;
      sinki->next=pres;
      if(s==0)return;
    }
    prev=prev->next;
    pres=prev->next;
  }
  //  cout<<"test"<<endl;
  sinki=new newrm();
  prev->next=sinki;
  sinki->start=prev->end+1;
  sinki->end=sinki->start+s-1;
  sinki->dot=i;
  sinki->next=NULL;
}

void read(newrm* begin,ll p){
  //cout<<"read!\n";
  
  newrm *prev,*pres;
  prev=begin;
  pres=prev->next;
  while(pres!=NULL){
    if(pres->start <= p&& pres->end >= p){
      cout<<pres->dot<<endl;
      return;
    } 
    else if(pres->end < p){
      //  cout<<prev->end<<" | "<<pres->start<<endl;
      prev=pres;
      pres=pres->next;
      //cout<<prev->end<<" || "<<pres->start<<endl;
      continue;
    }
    else {cout<<-1<<endl;
      return;
    } 
  }
  cout<<-1<<endl;
}

void del(newrm* begin,ll i){
  newrm *prev,*pres,*tmp;  
  prev=begin;
  pres=prev->next;
  while(pres!=NULL){
    if(pres->dot==i){
      tmp=pres;
      prev->next=pres->next;
      pres=prev->next;
      //      cout<<"debug"<<tmp->start<<endl;
      delete tmp;
      continue;
    }
    prev=prev->next;
    pres=prev->next;
  }
}
void reset(newrm* begin){
  newrm *prev,*pres;
  prev=begin;
  pres=prev->next; 
  while(pres!=NULL){
    delete prev;
    prev=pres;
    pres=pres->next;
  }
  delete prev;
  return;
}
void debug(newrm* begin){
  ll i;
  while(begin!=NULL){
    for(i=begin->start;i<=begin->end;i++)
      cout<<" "<<begin->dot<<" ";
    if(begin->next==NULL) break;
    for(;i<begin->next->start;i++)
      cout<<" "<<'x'<<" ";
    begin=begin->next;
  }
  cout<<endl;
}
int main(){
  ll N,i,p,s;
  char com;
  while(1){
    newrm* begin=new newrm();
    begin->start=-2;
    begin->end=-1;
    begin->dot=-1;
    begin->next=NULL;
    cin>>N;
    
    if(N==0) return 0;
    for(ll i=0;i<N;i++){
      cin>>com;
    
      if(com=='W'){
	cin>>p>>s;
	write(begin,p,s);
      }
      else if(com=='D'){
	cin>>p;
	del(begin,p);
      }
      else if(com=='R'){
	cin>>p;
	read(begin,p);
      }
      //      else if(com=='B')
      //debug(begin);
    }
    //     reset(begin);
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1556
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N+1);
  for(int &ai: A) cin >> ai;
  vector<int> B(N);
  for(int &bi: B) cin >> bi;
  long r=0;
  for(int i=0; i<N; i++){
    int c = min(A[i], B[i]);
    A[i] -= c;
    B[i] -= c;
    r += c;
    int d = min(A[i+1], B[i]);
    A[i+1] -= d;
    B[i]   -= d;
    r += d;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n;
  cin >> n;
  vector<LL> s(n);
  for(auto &x:s) cin >> x;
  LL answer = 0;
  FOR(a,1,n) {
    LL tmp = 0;
    for(LL pos = 0; pos < n-a; pos += a) {
      if(pos == n-pos-1) break;
      if(pos - a == n-pos-1) break;
      tmp += s[pos];
      tmp += s[n-pos-1];
      answer = max(answer, tmp);
    }
  }
  cout << answer << endl;
  return 0;
}


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

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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  cout << ((C % gcd(A, B) == 0)?"YES":"NO") << endl;
}

Measured memory_bytes: 256
n = gets.to_i
# s = gets.chomp
x = gets.split.map(&:to_i)

c = 0
ans = (100 - 0) ** 2 * 100 + 1000000000000
101.times do |i|
    c = 0
    x.each do |y|
        c += ( y - i ) ** 2
    end
    ans = c if ans > c
end

p ans

    


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

int main() {
    string S,T; 
    cin >> S >> T;

    int ans = 0;
    for(int i=0; i<3; i++){
        if(S.at(i) == T.at(i)){
            ans += 1;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
#define mod 1000000007
#define maxn 200001
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)
#define pb push_back
#define pf(x) push_front((ll)(x))
#define nl cout << "\n";
 
//void ini(){
//	#ifndef ONLINE_JUDGE
//		freopen("input.txt","r",stdin);
//		freopen("output.txt","w",stdout);
//	#endif
//}

long double dp[3001][3001];
long double a[3001],mult[3001];

long double coins(ll n,ll m,ll len){
	//cout <<a[n]<<" ";
	if(n==0){
		if(len<m){
			return 1; 
		}else{
			return a[n];
		}
	}

	if(dp[n][len]==-1){
		if(len==m){
			return dp[n][len]=mult[n];
		}

		return dp[n][len]=coins(n-1,m,len+1)*(1-a[n])+coins(n-1,m,len)*a[n];
	}

	return dp[n][len];
}

int main(){
//	ini();
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
    ll n;
    cin >> n;
    f(i,0,n){
    	cin >> a[i];
    	f(j,0,n){
    		dp[i][j]=-1;
    	}
    }

    mult[0]=a[0];
    f(i,1,n){
    	mult[i]=mult[i-1]*a[i];
    }

    if(n%2==0){
    	cout <<fixed<<setprecision(10)<< coins(n-1,(n/2),0);
    }else{
    	cout <<fixed<<setprecision(10)<< coins(n-1,(n/2),0);
    }

    //cout << path(n-1,m-1);
}

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& v){
    for(T& x: v) istr >> x;
    return istr;
}

template<typename T, typename U>
istream& operator >> (istream& istr, pair<T,U>& p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    ostr << p.first << ", " << p.second;
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll x(n); x[i]=a;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define EPS 1e-12
#define INF (ll)1e+12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define fix(x) cout << fixed << setprecision(x)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()

template<typename T> T sum(vector<T> &v) {return accumulate(all(v), (T)0LL);}
template<typename T> void sort(vector<T> &v){sort(all(v));}
template<typename T> void rsort(vector<T> &v){sort(all(v),greater<T>());}

int main(){
    ll n, r = 0;
    cin >> n >> r;
    if(n>=10) cout << r << endl;
    else cout << r+100*(10-n) << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var NK=ReadLine().Split().Select(int.Parse).ToArray();
        var N =NK[0];
        var K =NK[1];
        var ans =1;
        N-=K;
        for (int i = 0; N>0; i++)
        {
            N-=K-1;
            ans++;
        }
        ReadLine();
        WriteLine(ans);
    }
}

Measured memory_bytes: 15456
#include <stdio.h>

using namespace std;

int main(void) {
    char S[4];
    int i, sum = 700;

    scanf("%s", S);
    for (i = 0; i < 3; i++) {
        if (S[i] == 'o') sum += 100;
    }
    printf("%d\n", sum);

    return 0;
}

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

//#include <unordered_map>

//#include <iostream>//POJ
//#include <vector>
//#include <string>
//#include <iomanip>
//#include <math.h>
//#include <algorithm>
//#include <cstring>
using namespace std;
#define setc cin.tie(0);ios::sync_with_stdio(0)
#define dd(n) cout<<fixed<<setprecision(n)
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define repir(i,a,b) for(int i=(a)-1, i##_first=(b); i>=i##_first; --i)
#define repr(i,n) repir(i,n,0)
#define repir_(i,a,b) for(int i=(a), i##_first=(b); i>=i##_first; --i)
#define repr_(i,n) repir_(i,n,0)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
//template<typename T> T vpop(vector<T> *v) {
//	T res = v->back();
//	v->pop_back();
//	return res;
//}
//char vpop(string *v) {
//	char res = v->back();
//	v->pop_back();
//	return res;
//}
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define pi 3.14159265358979
#define co(x) cout<<x<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#define wildcard(T) numeric_limits<T>::min()

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

#define lint long long
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<lint> lvec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

const int
dx8[8] ={ 0,1,1,1,0,-1,-1,-1 },
dy8[8] ={ 1,1,0,-1,-1,-1,0,1 },
dx4[4] ={ 0,1,0,-1 },
dy4[4] ={ 1,0,-1,0 };

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

int main(){
	setc;

	char c;cin>>c;
	coc((c=='a'||c=='i'||c=='u'||c=='e'||c=='o'),"vowel","consonant");
	gc();
}

Measured memory_bytes: 256
N = int(input())
A, B = map(int, input().split())
p_list = tuple(map(int, input().split()))

first = []
second = []
third = []
for p in p_list:
    if p <= A:
        first.append(p)
    elif p <= B:
        second.append(p)
    else:
        third.append(p)

print(min(len(first), len(second), len(third)))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000



int main(){
	
	int H,W,K;
	cin>>H>>W>>K;
	
	vector<string> S(H);
	for(int i=0;i<H;i++){
		cin>>S[i];
	}
	
	int sx,sy;
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(S[i][j]=='S'){
				sx=j;
				sy=i;
				break;
			}
		}
	}
	
	vector<vector<int>> dis(H,vector<int>(W,Inf));
	dis[sy][sx]=0;
	queue<pair<int,int>> Q;
	Q.emplace(sy,sx);
	
	while(Q.size()!=0){
		int y = Q.front().first;
		int x = Q.front().second;
		Q.pop();
		for(int i=0;i<4;i++){
			int yy = y;
			int xx = x;
			if(i==0)yy++;
			if(i==1)yy--;
			if(i==2)xx++;
			if(i==3)xx--;
			if(yy<0||yy>=H||xx<0||xx>=W)continue;
			if(S[yy][xx]=='#')continue;
			if(dis[yy][xx]!=Inf)continue;
			dis[yy][xx] = dis[y][x] + 1;
			Q.emplace(yy,xx);
		}
	}
	
	int ans = Inf;
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(dis[i][j]>K)continue;
			int a = min({i,j,H-1-i,W-1-j});
			ans = min(ans,(a+K-1)/K);
		}
	}
	cout<<ans+1<<endl;


	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using P = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  bool ok = false;
  for (int i = 0; i <= m; i++) {
    for (int j = 0; j <= n; j++) {
      int total = j * (m - i) + i * (n - j);
      if (total == k) ok = true;
    }
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
  char a,b;cin>>a>>b;
  if(a==b)cout<<'H'<<endl;
  else cout<<'D'<<endl;
    return 0;
}

Measured memory_bytes: 256
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
#define ld long double
#define ar array
#define read(A) scanf("%lld",&A);
const ll maxN=1e5+5;
ll n , m , k;
string  s[7] ;
set<ll> sti , stj ;
bool solve(ll i , ll j){
	sti.clear();
	stj.clear();
	ll ans=0;
	for(ll z=0 ; z<6 ; z++){
		if(i&(1<<z))sti.insert(z);
		if(j&(1<<z))stj.insert(z);
	}
	// cerr<<i<< " "<< j <<endl;
	// for(auto x : sti)cerr<<x<<" ";
	// cerr<<endl;
	// for(auto x:stj)cerr<<x<<" ";
	// cerr<<endl;
	for(ll p=0;p<n ; p++){
		if(sti.count(p))continue;
		for(ll q=0;q<m ; q++){
			if(stj.count(q))continue;
			if(s[p][q]=='#')ans++;
		}
	}
	return ans==k;
}

void solve(){
	cin>> n >> m >> k ;
	ll ans=0;
	for(ll i=0;i<n ;i++)cin>>s[i];
	ll p=pow(2LL , n); ll q=pow(2LL , m);
	
	for(ll i=0;i<p ; i++){
		for(ll j=0; j<q; j++){
			if(solve(i , j))ans++;
		}
	}
	cout<<ans<<endl;
}
int main(){
	//mahakal(),fast;
	ll t =1 ;
	// cin>> t ;
	while(t--)solve();

	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  string s; cin >> s;
  reverse(s.begin(), s.end());
  int N = s.size();
  vector<string> T = { "dream", "dreamer", "erase", "eraser", };
  vector<string> pre;
  for (int i = 0; i < 4; ++i) {
    reverse(T[i].begin(), T[i].end());
    pre.push_back(T[i].substr(0, 3));
  }
  bool ok = true;
  for (int i = 0; ok and i + 5 <= N; ) {
    string t = s.substr(i, 3);
    ok = false;
    for (int j = 0; j < 4; ++j) {
      if (t == pre[j]) {
        ok = true;
        if (i + (int)T[j].size() > N) {
          ok = false;
          break;
        }
        for (int k = 0; k < (int)T[j].size(); ++k) {
          if (s[i + k] != T[j][k]) {
            ok = false;
            break;
          }
        }
        i += T[j].size();
        break;
      }
    }
    if (not ok) { break; }
  }
  printf("%s\n", ok ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct Word
{
    char	word[30];
    int		page;
} WORD;

WORD wordArray[100];

void input(char *, int);
int is_smaller(char *, int, int);
void output(WORD *);

int main()
{
	char	tempWord[30];
    int		tempPage;
    int index = 0;
	char last_print_word[] = "";
	
	while(scanf("%s %d", tempWord, &tempPage) != EOF)
    	input(tempWord, tempPage);
    
    output(wordArray);
	
	return 0;
}

void input(char *input_word, int input_page)
{
	int cnt1, cnt2;
	
	for(cnt1 = 0; cnt1 < 100; cnt1++)
	{
		if(wordArray[cnt1].page == 0)
		{
			wordArray[cnt1].page = input_page;
			strcpy(wordArray[cnt1].word, input_word);
			break;
		}
		else if(is_smaller(input_word, input_page, cnt1))
		{
			for(cnt2 = 98; cnt2 >= cnt1; cnt2--)
			{
				strcpy(wordArray[cnt2 + 1].word, wordArray[cnt2].word);
				wordArray[cnt2 + 1].page = wordArray[cnt2].page;
			}
			strcpy(wordArray[cnt1].word, input_word);
			wordArray[cnt1].page = input_page;
			break;
		}
	}
}

int is_smaller(char *input_word, int input_page, int cnt)
{
	if(strcmp(input_word, wordArray[cnt].word) < 0)
		return 1;
	else if(strcmp(input_word, wordArray[cnt].word) == 0)
	{
		if(input_page < wordArray[cnt].page)
			return 1;
		else
			return 0;
	}
	else
		return 0;
}

void output(WORD *output_array)
{
	int		output_cnt = 0;
	char	last_print_word[30] = "";

	while(output_array[output_cnt].page != 0)
	{
		if(strcmp(last_print_word, "") == 0)
		{
			printf("%s\n", output_array[output_cnt].word);
			strcpy(last_print_word, output_array[output_cnt].word);
		}
		else if(strcmp(output_array[output_cnt].word, last_print_word) != 0)
		{
			printf("\n%s\n", output_array[output_cnt].word);
			strcpy(last_print_word, output_array[output_cnt].word);
		}
		else
		{
			printf(" ");
			
		}
		printf("%d", output_array[output_cnt].page);
		output_cnt++;
	}
	printf("\n");
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, N_digit = 1; cin >> N;
    ll K = 26;

    vector<ll> pow_tmp, sum_tmp;
    pow_tmp.push_back(1); sum_tmp.push_back(0);
    while (true){
        pow_tmp.push_back(pow_tmp.back() * K);
        sum_tmp.push_back(sum_tmp.back() + pow_tmp.back());
        ll size = sum_tmp.size();
        if (sum_tmp.at(size - 2) < N && N <= sum_tmp.at(size - 1)){
            N -= sum_tmp.at(size - 2);
            break;
        }
        if (sum_tmp.back() > 1000000000000001){break;}
        N_digit++;
    }

    N--;
    vector<ll> x;
    rep(i, N_digit){
        x.push_back(N % K);
        N = N / K;
    }
    reverse(x.begin(), x.end());
    for (auto a: x){
        cout << (char) ('a' + a);
    }
}

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


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

int main() {
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  ll ta=0,tb=0,tc=0;
  char n='a';
  while(1) {
    if(n=='a') {
      if(ta==s1.size()) {
        cout << "A" << endl;
        return 0;
      }
      n=s1[ta];
      ta++;
    }
    if(n=='b') {
      if(tb==s2.size()) {
        cout << "B" << endl;
        return 0;
      }
      n=s2[tb];
      tb++;
    }
    if(n=='c') {
      if(tc==s3.size()) {
        cout << "C" << endl;
        return 0;
      }
      n=s3[tc];
      tc++;
    }
  }
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)

s = gets.chomp
t = gets.chomp

g = n.gcd(m)

ans = true
g.times do |k|
    ds = s[(n / g) * k]
    dt = t[(m / g) * k]
    ans &= ds == dt
end

if ans then    
    puts n*m/g 
else
    puts -1
end

Measured memory_bytes: 4092
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
 
int N;
int A[101010],B[101010],C[101010];
ll pat[101010];
 
 
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i];
	FOR(i,N) cin>>B[i];
	FOR(i,N) cin>>C[i];
	sort(A,A+N);
	sort(B,B+N);
	x=0;
	FOR(i,N) {
		while(x<N && A[x]<B[i]) x++;
		pat[i]=x;
	}
	sort(C,C+N);
	x=0;
	ll ret=0,sum=0;
	FOR(i,N) {
		while(x<N && B[x]<C[i]) sum+=pat[x],x++;
		ret+=sum;
	}
	cout<<ret<<endl;
	
	
}
 
 
int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Measured memory_bytes: 2176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();
		StringBuffer sb = new StringBuffer();

		for (int i = 0; i < s.length(); i++) {
			String s2 = String.valueOf(s.charAt(i));
			
			if (s2.equals("0") || s2.equals("1")) {
				sb.append(s2);
			} else if (s2.equals("B") && sb.length()>0) {
				sb.deleteCharAt(sb.length() -1);
			}

		}
		
		System.out.println(sb.toString());

	}

}

Measured memory_bytes: 8148
#include<bits/stdc++.h>
using namespace std;
/*------- Constants---- */

#define LL                      long long
#define Ulong                   unsigned long long
#define REP(i,n)                for(long long i=0; i < n ; i++ )
#define mp                      make_pair
#define pb                      push_back
#define all(x)                  (x).begin(),(x).end()
#define PI                      acos(-1.0)
#define EPS                     1e-14
#define F                       first
#define S                       second
#define di(x)                   int x; input(x)
#define in(x)                   input(x)
#define in2(x,y)                in(x),in(y)
#define in3(x,y,z)              in(x),in2(y,z)
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl
#define nl                      cout<<endl
#define ms(ara_name,value)      memset(ara_name,value,sizeof(ara_name))
#define IO                      ios_base::sync_with_stdio(0);cin.tie(0)
#define READ                    freopen("/home/matrixcode/Desktop/in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
template<class T> inline void input(T &x) {
    char c = getchar();x = 0;
    int neg = 0;
    for(; ((c<48 || c>57) && c != '-'); c = getchar());
    if(c=='-'){neg = 1;c = getchar();}
    for(; c>47 && c<58 ; c = getchar()){x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x = -x;
}
inline long long bigmod(long long p,long long e,long long M){
    long long ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/***************************** END OF TEMPLATE *******************************/


const int N = 1001;

int main()
{
    string s;
    int n;
    cin >> s >> n;
    for(int i = 0; i < s.size(); i += n) {
        cout << s[i];
    }
}


Measured memory_bytes: 256
import numpy as np
H,W=map(int, input().split())
C=[]
for i in range(10):
    c=list(map(int, input().split()))
    C.append(c)

A=[]
for h in range(H):
    a=map(int, input().split())
    A.append(a)
C=np.array(C)
D={-1:0}
#print(C)
#dfs
def dfs(start, now,done=[]):
    next_done=done+[start]
    #print(done)
    to_one=C[start,1]
    c=C[start]
    result=to_one
    for node, power in enumerate(c):
        
        if (node in next_done) or (start==node):
            continue
        if power<to_one:
            result=min(result,dfs(node,now+power, next_done)-now)
    #print(now,result)
    return now+result
        
for i in range(10):
    done=[]
    D[i]=dfs(i,0,[])
ans=0
for h in range(H):
    a=list(map(lambda x: D[x], A[h]))
    ans+=sum(a)
    
print(ans)

Measured memory_bytes: 14536
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const int INF=(1<<30)-1;
const int MOD=1000000007;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

string slct[] = {"dreamer", "eraser", "dream", "erase"};
string s;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> s;
    int n = s.size();
    int r = n;
    eper(l, n-1, 0) {
        string sb = s.substr(l, r-l);
        rep(i, 0, 4) {
            if (slct[i] == sb) {
                s.erase(s.begin()+l, s.begin()+r);
                r = l;
            }
        }
    }
    if (!s.empty()) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main{
	  public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
		    int n = sc.nextInt();        //nターン
		    int t1 = 0; //太郎の点数
		    int t2 = 0; //花子の点数

		    for(int i = 0;i < n;i++){
		    	String a =sc.next(); //太郎が出したカード
		    	String b =sc.next(); //花子が出したカード		    	
		    	
//		    	System.out.println(a.compareTo(b));
		    	if(a.compareTo(b) > 0){
		    		t1 += 3;
		    	}else if(a.compareTo(b) < 0){
		    		t2 += 3;
		    	}else if(a.compareTo(b) == 0){
		    		t1 += 1;
		    	    t2 += 1;
		        }
		    }
		    System.out.println(t1 +" "+ t2);
	}
}



Measured memory_bytes: 29800
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def bs(ar,eq,n) en=(eq==1 ? :>= : :>); ar.bsearch_index{|x|x.send(en,n)} end
def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n, m = gsmi
py =
  m.times.map do |i|
    ar = gsmi
    ar.unshift(i)
    ar
  end.sort{|x,y|(x[1]<=>y[1]).nonzero?||x[2]<=>y[2]}

ans = Array.new(m)
prev = -1
p_cnt = 0
m.times do |i|
  pref = py[i][1]
  if prev==pref
    p_cnt+=1
  else
    p_cnt = 1
    prev = pref
  end
  ans[py[i][0]] = "#{'%06d' % pref}#{'%06d' % p_cnt}"
end

puts ans


Measured memory_bytes: 33752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n, q;
  cin >> n >> q;
  queue<pair<string, int>> que;
  for (int i = 0; i < n; ++i)
  {
    string s;
    cin >> s;
    int num;
    cin >> num;
    que.emplace(s, num);
  }

  int sum = 0;
  while (!que.empty())
  {
    pair<string, int> p = que.front();
    que.pop();
    if (p.second > q)
    {
      p.second -= q;
      sum += q;
      que.push(p);
    }
    else
    {
      sum += p.second;
      cout << p.first << ' ' << sum << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 6356
#include <iostream>
#include <vector>

using namespace std;

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

  vector<bool> vec = {true, true, true};
  vec[a-1] = false;
  vec[b-1] = false;
  for (int i = 0; i < 3; ++i) {
    if (not vec[i])
      continue;
    cout << i + 1 << endl;
    break;
  }
}

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

int main() {
  int N;
  cin >> N;
  int h[N];
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  
  int ans = 1;
  for (int i = 1; i < N; i++) {
    bool ok = true;
    for (int j = 0; j < i; j++) {
      if (h[j] > h[i]) {ok = false;}
    }
    if (ok) {ans++;}
  }
  
  cout << ans << endl;
}
      


Measured memory_bytes: 256
<?php

while (true) {
    list($r, $a) = explode(' ', trim(fgets(STDIN)));
    if (0 == $r && 0 == $a) break;
    $r_dash = str_split($r);
    $a_dash = str_split($a);
    $cnt = 0;
    for ($i = 0; $i < 4; $i++) {
        $cnt += $r_dash[$i] == $a_dash[$i] ? 1 : 0;
    }
    $answer = [];
    $answer[] = $cnt;
    $answer[] = 4 - count(array_diff($r_dash, $a_dash)) - $cnt;
    echo implode(' ', $answer) . PHP_EOL;
}


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

int main() {
	int N;
	cin >> N;
	vector <int> vec( N );
	rep( i, 0, N ) cin >> vec[ i ];
	vector <int> bin( N );
	rep( i, 0, N ){
		int cnt = 0;
		for(; !( vec[ i ] & 1 ); cnt++, vec[ i ] >>= 1);
		bin[ i ] = cnt;
	}
	sort( bin.begin(), bin.end());
	rep( i, 0, N / 2 ){
		if (( bin[ i ] + bin[ N - i - 1 ] ) < 2){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}


Measured memory_bytes: 1024