akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int n,m,x,y;
    int tmp;
    cin >> n >> m >> x >> y;
    vector<int> xpl;
    vector<int> ypl;
    
    for(int i=0; i < n; i++){
        cin >> tmp;
        xpl.push_back(tmp);
    }
    for(int i=0; i < m; i++){
        cin >> tmp;
        ypl.push_back(tmp);
    }
    sort(xpl.begin(), xpl.end(),greater<int>());
    sort(ypl.begin(), ypl.end());
    
    if(xpl[0] < ypl[0] && y >= ypl[0] && x < xpl[0]){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }
    
    return 0;
}

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

using namespace std;
typedef long long int ll;
int main(){
	ll n,m,res;
	cin>>n>>m;
	if(n> 2 && m>2){
		cout<<(n-2)*(m-2)<<endl;

	}else if(n==2 || m==2){
		cout<<0<<endl;
	}else if(n==1 && m==1){
		cout<<1<<endl;
	}else if(n==1 && m>2){
		cout<<m-2<<endl;
	}else if(n>2 && m==1){
		cout<<n-2<<endl;
	}
	






	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

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

    if(S == "ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;
    return 0;
}


Measured memory_bytes: 3544
(let* ((dmax (read))
       (c (make-array '(27)))
       (cmax 0)
       (s (make-array (list (1+ dmax) 27)))
       (base (make-array '(27)))
       (ans (make-array (list (1+ dmax)))))
  ; read
  (loop :for i :from 1 :to 26
        :do (setf (aref c i) (read))
        :do (setf cmax (max cmax (aref c i))))
  (loop :for d :from 1 :to dmax
        :do (loop :for i :from 1 :to 26
                  :do (setf (aref s d i) (read))))
  (loop :for i :from 1 :to 26
        :do (setf (aref base i) 0))
  (defun find-last (d i )
    (loop :for j :downfrom d :to 0
          :if (= i (aref ans j))
          :do (return-from find-last j))
    0)

  (defun delta (x d)
    (- (+ (aref s d x) (- cmax (aref c x)))
       (loop :for i :from 1 :to 26
             :sum (* (aref c i) (- d (if (= i x) d (find-last d i)))))))
  
  (loop :for d :from 1 :to dmax
        :do (let ((cand-c 1)
                  (cand-v (delta 1 d)))
              (loop :for i :from 2 :to 26
                    :do (let ((v (delta i d)))
                          (when (> v cand-v)
                            (setf cand-c i)
                            (setf cand-v v))))
              (setf (aref base cand-c) d)
              (setf (aref ans d) cand-c)))
  (loop :for d :from 1 :to dmax :do (format t "~A~%" (aref ans d))))


Measured memory_bytes: 29896
#include <stdio.h>
int main(void)
{
    
    int a,b,i;
    char op;
    
    for(i=1;i>0;i++){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+'){
            printf("%d\n",a+b);
        }
        else if(op=='-'){
            printf("%d\n",a-b);
        }
        else if(op=='*'){
            printf("%d\n",a*b);
        }
        else if(op=='/'){
            printf("%d\n",a/b);
        }
        else if(op=='?'){
            break;
            
        }
    }
    
    return 0;
}


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

int main(){
  int h,w;
  cin >> h >> w;
  while(h+w){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(i%2>0){
	  if(j%2>0)cout << "#";
	  else cout << ".";
	}else{
	  if(j%2>0)cout << ".";
	  else cout << "#";
	}
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}

Measured memory_bytes: 3096
S = input()

N = len(S)
mod = 10 ** 9 + 7

dp = [[0 for _ in range(4)] for _ in range(N + 1)]
dp [0][0] = 1
for i in range(N):
    if S[i] == 'A':
        for j in range(4):
            dp[i + 1][j] += dp[i][j]
        dp[i + 1][1] += dp[i][0]
    elif S[i] == 'B':
        for j in range(4):
            dp[i + 1][j] += dp[i][j]
        dp[i + 1][2] += dp[i][1]
    elif S[i] == 'C':
        for j in range(4):
            dp[i + 1][j] += dp[i][j]
        dp[i + 1][3] += dp[i][2]
    else:
        for j in range(4):
            dp[i + 1][j] += dp[i][j] * 3
        dp[i + 1][1] += dp[i][0]
        dp[i + 1][2] += dp[i][1]
        dp[i + 1][3] += dp[i][2]

    for j in range(4):
        dp[i + 1][j] %= mod

print(dp[N][3])

Measured memory_bytes: 27580
#include<stdio.h>
int pop();
void push(int);
int get_num(char *);
int is_digit(char *);
int calc(char *);

int data[100];
int size=0;

int main(){

  int n;
  char s[100000];

  scanf("%[^\n]*s",s);
  printf("%d\n",calc(s));
  return 0;
}

int pop(){
  if(size<=0) return 0;
  return data[--size];
}
void push(int n){
  data[size++]=n;
}

int get_num(char *s){

  int n=0,sign=0;

  if(*s=='+'){
    s++;
  }
  else if(*s=='-'){
    sign=1;
    s++;
  }
		  
  while('0'<=*s && *s<='9'){
    n=n*10+(*s-'0');
    s++;
  }
  if(sign==1) return -n;
  return n;
}

int is_digit(char *s){

  if('0'<=*s && *s<='9') return 1;
  return 0;
}
int calc(char *s){
  
  int a,b,n;

  while(*s){
    //数値のとき
    if(is_digit(s)==1){
      n=get_num(s);
      push(n);
      while(n){
	n/=10;
	s++;
      }
    }
    //数値以外のとき
    else{
      switch(*s){
      case '+':
	a=pop();
	b=pop();
	push(b+a);
	break;
      case '-':
	a=pop();
	b=pop();
	push(b-a);
	break;
      case '*':
	a=pop();
	b=pop();
	push(b*a);
	break;
      }
      s++;
    }
  }
  return pop();
}



Measured memory_bytes: 2144
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);


int main(){
  int N; cin >> N;
  string S; cin >> S;
  int Q; cin >> Q;

  vector <set<int>> st(26);
  for (int i = 0; i < N; i++){
    int now = S[i] - 'a';
    st[now].insert(i);
  }
  vector <int> ans;
  for (int i = 0; i < Q; i++){
    int num; cin >> num;
    if (num == 1){
      int A; char B; cin >> A >> B;
      A--;
      int now = S[A] - 'a', next = B - 'a';
      st[now].erase(A);
      st[next].insert(A);
      S[A] = B;
    }else{
      int L, R; cin >> L >> R;
      L--; R--;
      int sum = 0;
      for (int j = 0; j < 26; j++){
        auto iter = st[j].lower_bound(L);
        if (iter == st[j].end()) continue;

        int now = *iter;
        if (now <= R) sum++;
      }
      ans.push_back(sum);
    }
  }
  
  for (int i = 0; i < ans.size(); i++){
    cout << ans[i] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 24452
#include <iostream>
using namespace std;
int main(void) {
    int W, H;
    
    while(true) {
        cin >> H >> W;
        if(H == 0 && W == 0)   break;
        for(int h = 0; h < H; ++h) {
            for(int w = 0; w < W; ++w) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


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

int main()
{
    ll n, d;
    cin >> n >> d;
    ll count = 0;
    for (ll i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        double ans = sqrt(x * x + y * y);
        if (ans <= d)
            count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define DIVIDE 10000.0
const int INF = 1e9;
const double EPS = 0.00001;
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    ld x[n + 1], y[n + 1], z[n + 1], r[n + 1], l[n + 1];
    for(int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i] >> z[i] >> r[i]>> l[i];
    }
    ld sx, sy, sz, dx, dy, dz;
    for(int i = 0; i < m; i++)
    {
        cin >> sx >> sy >> sz >> dx >> dy >> dz;
        ld ax = (ld)(sx - dx) / DIVIDE;
        ld ay = (ld)(sy - dy) / DIVIDE;
        ld az = (ld)(sz - dz) / DIVIDE;
 
        ld bx = sx;
        ld by = sy;
        ld bz = sz;
        bool flag[n + 1] = {};
        ll ans = 0;
        for(int j = 0; j <= DIVIDE; j++)
        {
            for(int k = 0; k < n; k++)
            {
                ld cx = bx - x[k];
                ld cy = by - y[k];
                ld cz = bz - z[k];
                ld dist = cx * cx + cy * cy + cz * cz;
                if(dist - r[k] * r[k] <= EPS)
                    flag[k] = true;
            }
            bx -= ax;
            by -= ay;
            bz -= az;
        }
        for(int j = 0; j < n; j++)
            if(flag[j])
                ans += l[j];
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3300
<?php
	$num = explode(" ",trim(fgets(STDIN)));
	$food = explode(" ",trim(fgets(STDIN)));
	sort($food);
	$total = 0;
	for($i=0; $i<$num[1]; $i++){
    	$total = $total + $food[$i];
    }
echo $total;
?>

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

long long f(int a, int b){

  long long mn = 1LL<<60;

  // 1辺を固定して考える
  for (int i = 0; i < a; i++) {

    int side1 = i;
    int side2 = (a - i) / 2;

    long long areaA = (long long) i * b;

    long long areaB = (long long) side2 * b;
    long long areaC = (long long) (a - i - side2) * b;

    long long min_ = min(areaA, min(areaB, areaC));
    long long max_ = max(areaA, max(areaB, areaC));

    mn = min(max_ - min_, mn);

    int side3 = b / 2;

    long long areaD = (long long) (a - i) * side3;
    long long areaE = (long long) (a - i) * (b - side3);

    min_ = min(areaA, min(areaD, areaE));
    max_ = max(areaA, max(areaD, areaE));

    mn = min(max_ - min_, mn);

  }

  return mn;

}

int main() {

  int H, W;
  cin >> H >> W;

  long long answer = min(f(H, W), f(W, H));
  
  cout << answer << endl;

  return 0;

}

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

using namespace std;

struct train
{
    int c, s, f;
};

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<train> a(n - 1);
    for (int i = 0; i < n - 1; ++i)
        cin >> a[i].c >> a[i].s >> a[i].f;
    for (int i = 0; i < n - 1; ++i)
    {
        int t = 0;
        for (int j = i; j < n - 1; ++j)
        {
            if (t < a[j].s)
                t = a[j].s;
            if (t % a[j].f != 0)
                t = t + (a[j].f - t % a[j].f);
            t += a[j].c;
        }
        cout << t << endl;
    }
    cout << "0";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int a[N];
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int c,n,maxn=0;
	cin>>c>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i>0){
			int t=a[i]-a[i-1];
			maxn=max(maxn,t);
		}
	}
	maxn=max(maxn,c-a[n-1]+a[0]);
	cout<<c-maxn<<endl;
	return 0;
}

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



signed main(){
    int n,k,a;
    cin >> n >> k;
    int j;
    vector<int> t;
    int y=1;
    for(int i=0;i<n;i++){
        cin >> a;
        j=0;
        while(a!=0&&j<t.size()){
            t[j]+=a%2;
            a=a/2;
            j++;
        }
        while(a!=0){
            t.push_back(a%2);
            a =a/2;
            y *=2;
        }

    }
   
    while((k /y)!=0){t.push_back(0);y*=2;}
    int an[t.size()];
    an[0]= max(t[0],n-t[0]);
    y=2;
    for(int i=1;i<t.size();i++){
        an[i]= an[i-1]+max(t[i] *y,(n-t[i]) *y);
        y*=2;
    }
    int p=0,ans=0;
    y /=2;
    for(int i=t.size()-1;i>0;i--){
        //cerr << ans << ' ';
        if((k%(2*y))/y!=0){
            ans =max(ans,p+t[i] *y+an[i-1]);
            p+=(n-t[i]) *y;
        }
        else p+= t[i] *y;
        y/=2;
    }
    //cerr << ans << ' ';
    if(k%2 !=0)ans=max(ans,p+(n-t[0]));
    //cerr << ans << ' ';
    ans=max(ans,p+t[0]);
    
        
    


    
    cout << ans;
    

    return 0;
}

Measured memory_bytes: 256
N = int(input())
a_array = [int(input()) for i in range(N)]

button_num = 1
push_cnt = 0
while True:
    button_num = a_array[button_num - 1]
    push_cnt += 1
    if button_num == 2:
        print(push_cnt)
        exit()
    if push_cnt == len(a_array):
        print(-1)
        exit()


Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}

int main() {
    fastio;
    ll ans=0;
    ll N;
    cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[N-1-i];
    int i = 1;
    while (a.size()) {
        if (a.back() != i) {
            ++ans;
        } else {
            ++i;
        }
        a.pop_back();
    }
    if (i == 1)
        ans = -1;
    cout << ans << endl;
}


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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
//#define int ll
#define swap(x, y)((x)^=(y)^=(x)^=(y))
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define ff first
#define tcase int _; cin>> _; for( ; _; --_)
#define ss second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	while(exp > 0){
		if(exp % 2 == 1){
			total = mod(((mod(total, m)) * (mod(base, m))), m);
			exp--;
		}
		base= mod((mod(base, m) * mod(base, m)), m);
		exp /= 2;
	}
	return mod(total, m);
}

int n;

void solve(){
    cin>> n;
    vector<char> y(n);
    int r = 0;
    for(int i = 0; i<n; ++i){
        cin>> y[i];
        if(y[i] == 'R') r++;
    }
    
    int swp = 0;
    for(int i = 0; i<r; ++i){
        if(y[i] == 'W') swp++;
    }
    cout<< swp << endl;
}

int32_t main(){
	fastio;
	solve();
	return 0;
}



Measured memory_bytes: 3620
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    N = int(input())

    # dp[i文字目][3文字前][2文字前][1文字前]
    dp = [[[[0] * 5 for _ in range(5)] for _ in range(5)] for _ in range(N + 1)]
    dp[0][0][0][0] = 1

    # _,A,G,C,T = 0,1,2,3,4
    for n in range(N):
        # 3文字前
        for i in range(5):
            # 2文字前
            for j in range(5):
                # 1文字前
                for k in range(5):
                    # 最後の文字
                    for l in range(1, 5):
                        # AG*C
                        if i == 1 and j == 2 and l == 3: continue
                        # A*GC
                        if i == 1 and k == 2 and l == 3: continue
                        # *AGC
                        if j == 1 and k == 2 and l == 3: continue
                        # *GAC
                        if j == 2 and k == 1 and l == 3: continue
                        # *ACG
                        if j == 1 and k == 3 and l == 2: continue
                        dp[n + 1][j][k][l] += dp[n][i][j][k]
                        dp[n + 1][j][k][l] %= mod
    res = 0
    for i in range(5):
        for j in range(5):
            for k in range(5):
                res += dp[-1][i][j][k]
                res %= mod
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9504
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	int H, W;

	while (1) {

		cin >> H >> W;
	
		if (H == 0 && W == 0)break;

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (i == 0 || i == H-1) {
					cout << "#";
				}
				else {
					if (j == 0 || j ==( W - 1)) {
						cout << "#";
					}
					else {
						cout << ".";
					}
				}
			}
			cout << endl;
		}

		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
//#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main() {
  int S=0;
  char len[10];
  cin >> len;

for (int i = 0; i < 4; i++) {
  if (len[i] == '+') {
    S++;
  }else{
    S--;
  }
}

cout << S << '\n';
return 0;
}


Measured memory_bytes: 256
import sys
from fractions import gcd


def eratosthenes_generator():
    yield 2
    n = 3
    h = {}
    while True:
        m = n
        if n in h:
            b = h[n]
            del h[n]
        else:
            b = n
            yield n
        m += b << 1
        while m in h:
            m += b << 1
        h[m] = b
        n += 2


def prime(n):
    ret = []
    for i in eratosthenes_generator():
        if n % i == 0:
            ret.append(i)
            while n % i == 0:
                n = n // i
        if n == 1 or i * i > n:
            break
    if n > 1:
        ret.append(n)
    return ret


def solve(n, aaa):
    g = abs(aaa[-1])
    for a in aaa[:-1]:
        if a != 0:
            g = gcd(g, abs(a))
    ans = set(prime(g))

    for p in eratosthenes_generator():
        if p > n + 2:
            break
        if p in ans or aaa[0] % p != 0:
            continue
        q = p - 1
        tmp = [0] * q
        for i, a in enumerate(aaa):
            tmp[i % q] += a
        if all(t % p == 0 for t in tmp):
            ans.add(p)

    ans = sorted(ans)
    return ans


n = int(input())
aaa = list(map(int, sys.stdin))
aaa.reverse()
print('\n'.join(map(str, solve(n, aaa))))


Measured memory_bytes: 6156
import math
import sys
A,B=map(int, input().split())
Min=min(math.floor(A/0.08),math.floor(B/0.1))
Max=max(math.floor((A+1)/0.08),math.floor((B+1)/0.1))
for i in range(Min,Max):
    #print(i)
    if math.floor(i*0.08)==A and math.floor(i*0.1)==B:
        print(i)
        sys.exit()
print("-1")

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

using namespace std;

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.14159265358979323846;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed

int P, Q, R;

signed main() {
    cin >> P >> Q >> R;
    cout << P + Q + R - max({P, Q, R}) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
using in = int64_t;
const in INF=1<<30;


int main(){
   in n,m;
    cin>>n>>m;
  vector<in> a(m);

  rep(i,m) cin>>a.at(i);
  sort(all(a));
  in dp[100010];
  //rep(i,n+1) dp[i] =INF;
  dp[1]=1;
  dp[2]=2;
  if(n==1){cout<<1;return 0;}
  if(n==2){if(m==0){cout<<2;} else cout<<1;return 0;}
  if(!a.empty())if(a[0]==1){dp[1]=0;dp[2]=1;a.erase(a.begin());}
  if(!a.empty()){if(a[0]==2){dp[2]=0;a.erase(a.begin());}}
  
  
  for(in i=3;i<=n;i++){
    if(!a.empty()){if(i==a[0]){
      dp[i]=0;
      a.erase(a.begin());
      continue;
    }}
     dp[i]=dp[i-1]+dp[i-2];
    if(dp[i]>=waru) dp[i]-=waru;
  }
  cout<<dp[n];
}


Measured memory_bytes: 1792
// https://atcoder.jp/contests/abc127/tasks/abc127_a
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    int age, cost;
    cin >> age >> cost;
    if (age > 12)
        cout << cost << endl;
    else if (age >= 6 && age <= 12)
        cout << cost / 2 << endl;
    else
        cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <deque>

long long dp[4004][4004];
int cut[4004][4004];

int main(){
  int N;
  scanf("%d", &N);
  std::vector<long long > w(N);
  std::vector<long long > sum(N+4);
  sum[0] = 0;
  for (int i=0; i<N; i++){
    scanf("%lld", &w[i]);
    sum[i+1] = sum[i] + w[i];
    cut[i][i+1] = i;
  }
  /*for (int i=0; i<N; i++){
    dp[i][i+1] = w[i];
    }*/
  for (int length = 2; length<=N; length++){
    for (int i=0; i<=N-length; i++){
      //printf("evaluating dp[%d][%d]\n",i,i+length);
      // dp[i][i+length]を求める
      // きる候補はi+1~i+length-1まで
      long long temp = 1e18;
      int cut_index = -1;
      /*for (int j=i+1; j<=i+length-1; j++){
        if (temp>dp[i][j]+dp[j][i+length]){
          cut_index = j;
          temp = dp[i][j]+dp[j][i+length];
        }
        }*/
      for (int j=std::max(i+1,cut[i][i+length-1]); j<=std::min(i+length-1,cut[i+1][i+length]); j++){
        //printf("j=%d\n", j);
        if (temp>dp[i][j]+dp[j][i+length]){
          cut_index = j;
          temp = dp[i][j]+dp[j][i+length];
        }        
      }
      /*if (temp>dp[i][i+1]+dp[i+1][i+length]){
        temp = dp[i][i+1]+dp[i+1][i+length];
      }
      if (temp>dp[i][i+length-1]+dp[i+length-1][i+length]){
        temp = dp[i][i+length-1]+dp[i+length-1][i+length];
        }*/
      cut[i][i+length] = cut_index;
      dp[i][i+length] = sum[i+length]-sum[i]+temp;
      //printf("dp[%d][%d] = %lld-%lld+%lld = %lld\n",
      //i,i+length,sum[i+length], sum[i], temp,dp[i][i+length]);
      //printf("cut[%d][%d]=%d\n", i,i+length,cut_index);
    }
  }
  printf("%lld\n", dp[0][N]);
  return 0;
}



Measured memory_bytes: 125972
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

static const int MAX = 100001;

/******* c++14 don't include *******/

template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }

/*******                      *******/

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    int n, k, q;
    int cor[MAX];
    fill(cor, cor+MAX, 0);
    
    cin >> n >> k >> q;
    rep(i, q){
        int a = 0;
        cin >> a;
        a--;
        cor[a]++;
    }
    
    rep(i, n){
        if(k-(q-cor[i])>0){
            cout << "Yes";
        }
        else cout << "No";
        cout << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int digit (int n){
	int i;
	for (i=0; n!=0; i++) n = n/10;
	return i;
}

int main(void) {
	int a, b;
	while (scanf ("%d %d", &a, &b) != EOF) printf ("%d\n", digit (a+b));
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> ii;

template <class T> int getbit(T s, int i) { return (s >> i) & 1; }
template <class T> T onbit(T s, int i) { return s | (T(1) << i); }
template <class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template <class T> ll cntbit(T s) { return __builtin_popcntll(s); }

#define all(a) (a).begin(), (a).end()
#define ms(a, x) memset(a, x, sizeof(a))
#define forv(v, it) for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); it++)
#define print(x) cout << "L" << __LINE__ << " -- " << #x << " = " << x << endl
#define clear(x) v.clear(); vector<T>(v).swap(v)

#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define eps 1e-12

#define div ___div
#define next ___next
#define prev ___prev
#define left ___left
#define right ___right
#define y0 ___y0
#define y1 ___y1

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

  int n; cin >> n;

  if(n == 0) {
    cout << 2 << endl;
    return 0;
  } else if (n == 1) {
    cout << 1 << endl;
    return 0;
  }

  ull l_0 = 2, l_1 = 1, temp;
  for (int i=2; i<= n; i++) {
    temp = l_0 + l_1;
    l_0 = l_1;
    l_1 = temp;
  }

  cout << temp << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace ABC176
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(" ");
            int N = int.Parse(input[0]);
            int X = int.Parse(input[1]);
            int T = int.Parse(input[2]);

            if (N <= X)
            {
                Console.WriteLine(T);
            }
            else if(N%X == 0)
            {
                Console.WriteLine(N/X*T);
            }
            else
            {
                Console.WriteLine((N / X + 1) * T);
            }
        }
    }
}


Measured memory_bytes: 27472
// Problem : B - 1%
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		
		int k = 1e7;
		int x = 100;
		for(int i=1;i<=k;++i)
		{
			x+= (x/100);
			if(x>=n)
			{
				cout<<i;
				return 0;
			}
		}
		    	
    }
    return 0;
}



Measured memory_bytes: 3692
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i = 1;
		while (true) {
			int x = sc.nextInt();
			if (x == 0) {
				break;
			} else {
				System.out.println("Case " + i + ": " + x);
				i++;
			}
		}
	}
}


Measured memory_bytes: 41880
import sys
import math
import bisect

def solve(s):
    n = len(s)
    if n % 2 == 0:
        return False
    m = (n - 1) // 2
    if s != s[::-1]:
        return False
    left = s[:m]
    right = s[m+1:]
    if left != left[::-1]:
        return False
    if right != right[::-1]:
        return False
    return True

def main():
    if solve(input()):
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ').map(Number);
  let base_idx = partition(arr, 0, n - 1);
  arr[base_idx] = `[${arr[base_idx]}]`;
  console.log(arr.join(` `));
})();

function partition(arr, p, r) {
   let x  = arr[r];
   let i = p - 1;
   for (let j = p; j < r; j++) {
     if (arr[j] <= x) {
       i++;
       [arr[i], arr[j]] = [arr[j], arr[i]];
     }
   }
   [arr[i + 1], arr[r]] = [arr[r], arr[i + 1]];
   return i + 1;
}



Measured memory_bytes: 33652
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int a,b;
  scanf("%d %d\n",&a,&b);
  if(a<=9 && b<=9){
    printf("%d\n",a*b);
  }
  else{
    printf("-1\n");
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, T;
    cin >> N >> T;
    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];

    vv<vector<int>> dp = vvec(N + 1, 6005, vector<int>(2, 0));
    rep(i, N) {
        rep(t, T) {
            dp[i + 1][t][0] = max(dp[i + 1][t][0], dp[i][t][0]);
            dp[i + 1][t][1] = max(dp[i + 1][t][1], dp[i][t][1]);
            dp[i + 1][t + A[i]][0] = max(dp[i + 1][t + A[i]][0], dp[i][t][0] + B[i]);
            dp[i + 1][t + A[i]][1] = max(dp[i + 1][t + A[i]][1], dp[i][t][1] + B[i]);
            dp[i + 1][t][1] = max(dp[i + 1][t][1], dp[i][t][0] + B[i]);
        }
    }

    int ans = 0;
    rep(t, T) {
        ans = max(ans, dp[N][t][1]);
    }
    write(ans);
}

Measured memory_bytes: 995968
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Set;
import java.util.HashSet;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        br.readLine();
        String[] s = br.readLine().split(" ");
        br.readLine();
        String[] t = br.readLine().split(" ");
        
        Set<String> set = new HashSet<String>(Arrays.asList(s));
        set.retainAll(Arrays.asList(t));
        System.out.println(set.size());
    }
}


Measured memory_bytes: 27804
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	cin >> a;
	vector<long long> sum(n + 1);
	rep(i, n) sum[i + 1] = sum[i] + a[i];
	map<long long, long long> mp;
	rep(i, n + 1) {
		mp[sum[i]]++;
	}
	long long ans = 0;
	for (auto c : mp) {
		ans += c.second * (c.second - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 17860
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;

struct Answer {
	int x, y;
	int u, v;
};

int main() {
	int H, W; cin >> H >> W;
	vector<vector<int>> a(H, vector<int>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) cin >> a[i][j];
	}
	vector<Answer> ans;
	for (int i = 0; i < H; i++) {
		if (i % 2 == 0) {
			for (int j = 0; j < W; ++j) {
				if (a[i][j] % 2 == 1) {
					if (j < W - 1) {
						a[i][j + 1]++;
						ans.push_back({ i, j, i, j + 1 });
					}
					else if (i < H - 1) {
						a[i + 1][j]++;
						ans.push_back({ i, j, i + 1, j });
					}
					else continue;
				}
			}
		}
		else {
			for (int j = W - 1; j >= 0; j--) {
				if (a[i][j] % 2 == 1) {
					if (j > 0) {
						a[i][j - 1]++;
						ans.push_back({ i, j, i, j - 1 });
					}
					else if (i < H - 1) {
						a[i + 1][j]++;
						ans.push_back({ i, j, i + 1, j });
					}
				}
			}
		}
	}
	cout << ans.size() << endl;
	for (auto a : ans) cout << a.x + 1 << " " << a.y + 1 << " " << a.u + 1 << " " << a.v + 1 << endl;
	return 0;
}

Measured memory_bytes: 5232
#include<bits/stdc++.h>
using namespace std;
int h,n;
int a[1010],b[1010];
int dp[10010];
int main(){
	cin>>h>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i]>>b[i];
	memset(dp,63,sizeof(dp));
	dp[h]=0;
	for(int i=h;i>=1;i--){
		for(int j=1;j<=n;j++){
			dp[max(i-a[j],0)]=min(dp[max(i-a[j],0)],dp[i]+b[j]);
		}
	}
	cout<<dp[0]<<endl;
	return 0;
} 

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

int main(){
	LL x, p1;
	cin >> x >> p1;
	double p = ((double)p1) / 100.0;
	if(x % 2) x++;
	x /= 2;
	double r = ((double)x)/p;
	printf("%.9lf\n", r);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX=405;
const int INF=0x3f3f3f3f;
pii s,t;
int h,w,depth[MAX],chk[MAX],ans;
char pond[MAX][MAX];
struct edge{
    int idx,cap,flow,ridx;
};
vector<edge> conn[MAX];
vector<int> route;
queue<int> bqueue;
void mconn(int x,int y){
    conn[x].push_back({y,1,0,conn[y].size()});
    conn[y].push_back({x,1,0,conn[x].size()-1});
}
int bfs(){
    for(int i=0;i<h+w;i++) chk[i]=0;
    bqueue.push(s.x);
    for(int i=0;!bqueue.empty();i++){
        int t=bqueue.size();
        for(int j=0;j<t;j++){
            int tmp=bqueue.front();
            bqueue.pop();
            if(chk[tmp]==0){
                chk[tmp]=1,depth[tmp]=i;
                for(int k=0;k<conn[tmp].size();k++) if(chk[conn[tmp][k].idx]==0&&conn[tmp][k].cap>conn[tmp][k].flow) bqueue.push(conn[tmp][k].idx);
            }
        }
    }
    return chk[t.x];
}
int dfs(int x,int v){
    if(t.x==x) return v;
    int tmp_f=0;
    for(int i=0;i<conn[x].size();i++) if(conn[x][i].cap>conn[x][i].flow&&depth[conn[x][i].idx]==depth[x]+1){
        tmp_f=dfs(conn[x][i].idx,min(conn[x][i].cap-conn[x][i].flow,v));
        if(tmp_f>0){
            conn[x][i].flow+=tmp_f;
            conn[conn[x][i].idx][conn[x][i].ridx].flow-=tmp_f;
            return tmp_f;
        }
    }
    return 0;
}
int main(){
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++) scanf("%s",pond[i]);
    for(int i=0;i<h;i++) for(int j=0;j<w;j++){
        if(pond[i][j]=='S') s.x=i,s.y=j;
        if(pond[i][j]=='T') t.x=i,t.y=j;
    }
    if(s.x==t.x||s.y==t.y){
        printf("-1\n");
        return 0;
    }
    for(int i=0;i<h;i++) for(int j=0;j<w;j++){
        if(pond[i][j]!='.') {
            int t1=i,t2=j+h;
            if(t2==s.y+h) t2=s.x;
            if(t2==t.y+h) t2=t.x;
            mconn(t1,t2);
        }
    }
    while(bfs()){
        while(int u=dfs(s.x,INF)){
            ans+=u;
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
//二項係数の計算
int nCr(ll A, ll B) {
    ll ans = 1;
    for (ll i = 0; i < B; i++) {
        ans *= A - i;
    }
    for (ll i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main() {
   int N;
   cin>>N;
   vector<int>H(N);
   bool a=true;
   rep(i,N){
       cin>>H[i];
       if(i==0){
           H[i]--;
       }
       else{
           if(H[i]<H[i-1]){
               a=false;
               break;
           }
           else if(H[i]==H[i-1]){

           }
           else
           {
               H[i]--;
           }
           
       }
   }
   if(a==true){
       cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }
   
}


Measured memory_bytes: 3748
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  COMinit();
  int n,k;
  cin >> n >> k;
  vector<ll>a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  ll ans=0;
  rep(i,n){
    a[i]%=MOD;
    ans+=a[i]*(COM(i,k-1)-COM(n-i-1,k-1));
    ans%=MOD;
  }
  cout<<ans<<endl;
          
}


Measured memory_bytes: 13056
#pragma GCC target("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#define int ll
#define f			first
#define sz(a)       ((int)(a).size())
#define s			second
#define all(v)		v.begin(),v.end()
#define pii 		pair<int,int>
#define vpii 		vector<pii>
#define eb			emplace_back
#define pb			push_back
#define fo(i,n)		for(int i = 0;i<n;i++)
#define Fo(i,k,n)	for(int i=k;i<n;i++)
#define vi			vector<int>

using namespace std;
using ll  = long long;
using lld = long double;

const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;

const int N = 2e5 + 10;
int tree[N << 2] , a[N] , h[N];

void upd(int pos , int val , int l , int r , int t){
    if(l == r){
        tree[t] = val;
        return;
    }
    int mid = (l + r) >> 1;
    if(pos <= mid)
        upd(pos , val , l , mid , t << 1);
    else
        upd(pos , val , mid + 1 , r , t << 1 | 1);
    tree[t] = max(tree[t << 1] , tree[t << 1 | 1]);
}

int qry(int ql , int qr , int l , int r , int t){
    if(l > qr || r < ql)
        return 0;
    if(l >= ql && r <= qr)
        return tree[t];
    int mid = (l + r) >> 1;
    return max(qry(ql , qr , l , mid , t << 1) , qry(ql , qr , mid + 1 , r , t << 1 | 1));
}

signed main(){

#ifndef ONLINE_JUDGE
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);
    
    int n;
    cin >> n;
    fo(i , n) cin >> h[i];
    fo(i , n) cin >> a[i];
    
    fo(i , n){
        int x = qry(0 , h[i] - 1 , 0 , N - 1 , 1);
        upd(h[i] , x + a[i] , 0 , N - 1 , 1);
    }

    cout << tree[1] << '\n';
    
    return 0;

}



Measured memory_bytes: 10848
#include<stdio.h>

int main(){
    int x,a,b;
    scanf("%d%d%d",&x,&a,&b);
    if(b<=a){printf("delicious\n");}
    if(b>a&&b<=a+x){printf("safe\n");}
    if(b>a+x){printf("dangerous\n");}
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    string t;
    map<char, int> v;
    v['I'] = 1; v['V'] = 5; v['X'] = 10; v['L'] = 50; v['C'] = 100; v['D'] = 500; v['M'] = 1000;
    while(getline(cin, t)){
        int mx = 0, ans = 0;
        for (int i = t.size()-1; i >= 0; --i) {
            if(mx <= v[t[i]]){
                mx = v[t[i]];
                ans += v[t[i]];
            }else {
                ans -= v[t[i]];
            }
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <map>
using namespace std;
map<int,long long> sl;
int order[4000];
int main()
{
    int n;
    while(1)
    {
        cin>>n;if(!n)return 0;
        int count=0;
        int od=0;
        sl.clear();
        for(int i=0;i<n;++i){
            int sn;
            long long t,v;
            cin>>sn>>t>>v;
            map<int,long long>::iterator it=sl.find(sn);
            if(it==sl.end()){
                order[od++]=sn;
                sl.insert(make_pair(sn,t*v));
            }
            else it->second+=t*v;
        }
        for(int i=0;i<od;++i){
            if(sl[order[i]]>=1000000){cout<<order[i]<<endl;++count;}
        }
        if(!count)cout<<"NA"<<endl;
    }
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
int main(){
   long long n;
    long long k;
    vector<pair<int,int> >a;
    cin>>n>>k;
    
    for(int i=1;i<=n;i++ ){
        pair<int,int>x;
        cin>>x.first>>x.second;
        a.push_back(x);
    }
    sort(a.begin(),a.end());
    long long count=0;
    for(int i=0;i<a.size();i++){
        
        if(count>=k){
            cout<<a[i-1].first<<endl;
            return 0;
        }
        else
            count+=a[i].second;
    }
    cout<<a[n-1].first<<endl;
}

Measured memory_bytes: 1400
main = do
  [d,n] <- map read . words <$> getLine
  let xs = if d == 0 then 
                     (init $ take 100 [1..]) ++ [101]
                     else 
                     (init $ take 100 [(100^d), ((100^d)*2)..]) ++ [(100^d)*101]
  print $ last $ take n xs

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

int main(){
   int n, k;
   cin >> n >> k;
   string s;
   cin >> s;

   if(s[k-1] == 'A') s[k-1] = 'a';
   if(s[k-1] == 'B') s[k-1] = 'b';
   if(s[k-1] == 'C') s[k-1] = 'c';

   cout << s << endl;

   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define LENGTH 10001

bool linearSearch(int A[], int n, int key) {
    int i = 0;
    A[n] = key;
    while(A[i] != key) i++;
    return i != n;
}

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

    int n;
    int A[LENGTH];
    
    cin >> n;
    for(int i=0; i<n; ++i) {
        cin >> A[i];
    }
    
    int sum = 0;
    int q;
    int key;
    cin >> q;
    for(int i=0; i<q; i++) {
        cin >> key;
        if(linearSearch(A, n, key)) sum++;
    }
    cout << sum << endl;
    
    return 0;
}



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

int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  const int n = N;
  int V[n],C[n],sum = 0;
  for (size_t i = 0; i < n; i++) {
    cin >> V[i];
  }
  for (size_t i = 0; i < n; i++) {
    cin >> C[i];
  }
  for (size_t i = 0; i < n; i++) {
    if (V[i] - C[i] > 0) {
      sum += (V[i]-C[i]);
    }
  }
  cout << sum;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B)          for(int I=A; I<B; I++)
#define LL                  long long
#define PSI                 pair<string,int>
#define MOD                 1000000007
#define MAX                 1000005
#define READ(A)             freopen(A,"r",stdin)

int main() {
    //READ("input.txt");
    int N;
    bool B=false;
    scanf("%d",&N);
    FOR(I,0,N/4+1){
        FOR(J,0,N/7+1){
            if(4*I+7*J==N)B=true;
        }
    }
    if(B)printf("Yes\n");
    else printf("No\n");
}


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

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

		int m = min(a, b);
		int n = min(x, y);

		System.out.println(m+n);
	}

	public static int min (int a, int b) {
		if (b<a)
			a=b;

		return a;
	}
}


Measured memory_bytes: 35668
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <fstream>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

char ToUpper(char cX) { return toupper(cX); }
char Tolower(char cX) { return tolower(cX); }


const long long INF = 1LL << 60;
const long long MOD = 1000000007LL;
const long long MAX = 500000LL;
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
using T = tuple<ll, ll, ll>;

ll V, E;
vector<vector<pair<ll,ll>>> a;
vector<vector<ll>> dp;

ll dfs(ll S, ll v) {

	if (dp[S][v] != -1) {
		return dp[S][v];
	}
	if ((S == (1 << V) - 1) && (v == 0)) {
		return dp[S][v] = 0;
	}

	ll res = INF;
	for (ll i = 0; i < a[v].size(); i++) {
		if ((S >> a[v][i].first) & 1)
			continue;
		chmin(res, dfs(S | (1 << a[v][i].first), a[v][i].first) + a[v][i].second);
	}
	return dp[S][v] = res;
}
int main()
{
	cin >> V >> E;
	a.resize(V);
	dp = vector<vector<ll>>(1 << V, vector<ll>(V, -1));
	for (ll i = 0; i < E; i++) {
		ll s, t, z;
		cin >> s >> t >> z;
		a[s].push_back(make_pair(t, z));
	}
	ll res = INF;
	//cout << dfs(0, 2, 0, 2) << endl;
	chmin(res, dfs(0, 0));
	if (res == INF) {
		puts("-1");
		return 0;
	}
	cout << res << endl;
	
	return 0;
}




Measured memory_bytes: 7532
// テ・ツ淞コテヲツ慊ャテ」ツδ?」ツδウテ」ツδ療」ツδャテ」ツδシテ」ツδ?(テァツクツョテ・ツーツ湘ァツ可?

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
typedef pair<int, int> pii;
typedef long long ll;
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

string L[60];
int N, P[60], A[60], B[60], C[60], D[60], E[60], F[60], S[60], M[60];

struct Elem {
    double ef;
    string s;
};

bool operator<(const Elem &a, const Elem &b) {
    if(a.ef != b.ef) return a.ef > b.ef;
    return a.s < b.s;
}

signed main() {
    while(cin >> N, N) {
        vector<Elem> vs;
        rep(i,0,N) {
            cin >> L[i] >> P[i] >> A[i] >> B[i] >> C[i] >> D[i] >> E[i] >> F[i] >> S[i] >> M[i];
            double tm = A[i] + B[i] + C[i] + M[i] * (D[i] + E[i]);
            double cost = S[i] * F[i] * M[i] - P[i];
            vs.push_back(Elem{cost / tm, L[i]});
        }
        sort(vs.begin(), vs.end());
        rep(i,0,N) {
            cout << vs[i].s << endl;
        }
        cout << "#" << endl;
    }
    return 0;
}

Measured memory_bytes: 3140
import java.util.*;

public class Main {
    public static void main(String[] args) {
        // Your code here!
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        if(k%2==0)System.out.println((long)(n/k)*(n/k)*(n/k)+(long)((n+k/2)/k)*((n+k/2)/k)*((n+k/2)/k));
        else System.out.println((long)(n/k)*(n/k)*(n/k));
    }
}


Measured memory_bytes: 22740
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, A: int, B: int):
    return min(A * N, B)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    result = solve(N, A, B)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5252