akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> input = Arrays.asList(br.readLine().split(""));

            String result = "No";
            // coooooが通ってしまうけどそれでいいの？
            if (!input.get(0).equals(input.get(1))
                && input.get(2).equals(input.get(3))
                && input.get(4).equals(input.get(5))) {
                result = "Yes";
            }

            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#include <limits>
#include <iomanip>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    string s;
    cin >> s;
    string k = "keyence";
    for (int i = 0; i <= s.size()-7; i++) {
        for (int j = 0; j < s.size()-max(1,i); j++) {
            string t = s;
            t.erase (j, i);
            if (t == k) {
                cout << "YES" << endl;
                return 0; // ここでreturn 0とするのも上手い
            }
        }
    }
    cout << "NO" << endl;
}
// この問題解けなかったことは要反省


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

int main() {

  int A,B,C;
  cin>>A>>B>>C;
  if(A*B%2==1)
  {
    cout<<"Yes"<<endl;
  }
    if(A*B%2==0)
  {
        if(C%2==0)
        {
          cout<<"No"<<endl;
        }
      else
      {
        cout<<"Yes"<<endl;
      }
  }
}
  


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

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i32,
        b: i32,
        c: i32,
    }
    let mut vec = vec![a, b, c];
    vec.sort();
    for num in 0..vec.len() - 1 {
        print!("{} ", vec[num]);
    }
    println!("{}", vec[vec.len() - 1]);
}


Measured memory_bytes: 5024
#include <bits/stdc++.h>
    using namespace std;
    
    long ans;
    void divide(long a , long b , long c){
        if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1){
            return;
        }
        if(a == b && b == c){
            ans = -1;
            return;
        }
        ans += 1;
        long ta , tb , tc;
        ta = (b + c) / 2;
        tb = (a + c) / 2;
        tc = (a + b) / 2;
        divide( ta ,  tb  , tc );
        return;
    }
    
    int main(){
        long a , b , c ;
        cin >> a >> b >> c;
        ans = 0; 
        divide(a , b , c);
        cout <<  ans  << endl;
        
        return 0;
    }

Measured memory_bytes: 256
import math
def solve():
    N = int(input())
    X = list(map(int, input().split()))

    mn = float('inf')
    for i in range(1, 101):
        mn = min(mn, calc(X, i))
    print(mn)


def calc(X, P):
    retval = 0
    for x in X:
        retval += (x - P) ** 2 
    return retval
    
if __name__ == '__main__':
    solve()

Measured memory_bytes: 38896
import Control.Applicative
import Control.Monad
import Data.Functor
import Data.List
import Data.Maybe

base = 10 ^ 9 + 7

mmul x y = (x * y) `mod` base
mpow x 0 = 1
mpow x y
  | odd y  = mmul x $ mmul t t
  | even y = mmul t t
  where
    t = mpow x $ div y 2

minv = flip mpow (base - 2)

c n k
  | k == 0 || k==n   = 1
  | k<0 || k > n     = 0
  | otherwise        = mmul (foldl1 mmul [n-k+1..n]) (foldl1 mmul $ map minv [1..k])

f x y
  | q /= 0 = 0
  | x < p = 0
  | y < p = 0
  | otherwise = c p (min x y - p)
  where
    (p, q) = divMod (x + y) 3

main = map read . words <$> getLine >>= \[x, y] -> print $ f x y

Measured memory_bytes: 60412
#include <stdio.h>

int main(void){
	int n,i,len;
	char taro[101];
	char hanako[101];
	char *tp;
	char *hp;
	tp = taro;
	hp = hanako;
	int cnt = 0;
	int t_len = 0;
	int h_len = 0;
	int t_score = 0;
	int h_score = 0;

	scanf("%d", &n);

	while(cnt != n){
		t_len = 0;
		h_len = 0;
		len = 0;
		scanf("%s %s", taro, hanako);

		while(taro[t_len] != '\0'){
			t_len++;
		}

		while(hanako[h_len] != '\0'){
			h_len++;
		}

		if(t_len > h_len){
			len = t_len;
		}else{
			len = h_len;
		}

		for(i = 0;i < len;i++){
			if(*(tp + i) > *(hp + i)){
				t_score += 3;
				break;
			}else if(*(tp + i) < *(hp + i)){
				h_score += 3;
				break;
			}

			if(i == len - 1){
				if(*(tp + i) == *(hp + i)){
					t_score++;
					h_score++;
					break;
				}
			}
		}
		cnt++;
	}

	printf("%d %d\n", t_score, h_score);

	return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 1e9+7
#define N 1000010
#define MAX_V 400010
#define vec vector<int>
#define ALL(c) (c).begin(),(c).end()

int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
using namespace std;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<ll,int,custom_hash>
struct pair_hash
{
    template<class T1,class T2>
    size_t operator() (const pair<T1,T2> &p)const{
        return hash<T1>()(p.first)^hash<T2>()(p.second);
    }
};
ll ans;
vector<ll> v;
int f;
vec x;
void calc(int kk){
    if(kk<0)return;

    vec a[100];
    rep(i,x.size()){
        ll t=v[x[i]];
        int k=0;
        while(t){
            if(t%2)a[k].pb(x[i]);
            t/=2;
            k++;
        }
    }
    rep3(i,kk,0){
        if(a[i].size()>=f){
            ans+=(ll)1<<i;
            x=a[i];
            calc(i-1);
            return;
        }
    }
}

main(){
    int n;
    cin>>n>>f;
    ll a[N];
    rep2(i,1,n)cin>>a[i];
    ll s[N];
    s[1]=a[1];
    rep2(i,1,n){
        s[i+1]=a[i+1]+s[i];
    }
    rep(i,n){
        rep2(j,i+1,n){
            v.pb(s[j]-s[i]);
        }
    }
    rep(i,n*(n+1)/2)x.pb(i);
    calc(50);
    cout<<ans;
}




Measured memory_bytes: 60140
using System;
using System.Linq;

namespace PictureManagement
{
    class Program
    {
        static void Main(string[] args)
        {
            var sp = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            Solution sol = new Solution();
            Console.WriteLine(sol.GetMaxBiscuit(sp[0], sp[1], sp[2]));
        }
    }

    public class Solution
    {
        public long GetMaxBiscuit(long K, long A, long B)
        {
            if (B - A - 2 <= 0 || K < A)
                return K + 1;

            long biscuit = A;
            K = K - A + 1;
            while(true)
            {
                if (K >= 2)
                    biscuit += B - A;
                else
                    break;
                K -= 2;
            }

            return biscuit + K;
        }
    }
}

Measured memory_bytes: 13396
N, K = map(int, input().split())
d = []
A = set()
for i in range(K):
  d.append(int(input()))
  A = A.union(set(map(int, input().split())))

ans = 0
for j in range(1, N+1):
  if j in A:
    pass
  else:
    ans += 1

print(ans)

Measured memory_bytes: 9116
#include <iostream>

using namespace std;

int abs(int a)
{
    if(a>=0) return a;
    else return -a;
}

int main()
{
    int n,k;
    cin >> n >> k;
    int h[n];
    for(int i=0;i<n;i++) cin >> h[i];
    int dp[n];
    for(int i=0;i<n;i++) dp[i]=1000000000;
    dp[n-1]=0;
    for(int o=n-1;o>=0;o--)
    {
        for(int i=o+1;i<min(n,o+k+1);i++) dp[o]=min(dp[o],dp[i]+abs(h[o]-h[i]));
    }
    cout << dp[0] << endl;
    return 0;
}


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

int main() {
    double L;
    cin >> L;

    cout << fixed;
    cout << setprecision(8) << (L/3) * (L/3) * (L/3) << endl;

    return 0;
}

 

Measured memory_bytes: 256
#include <cstdio>
#include <math.h>
#include <algorithm>
using namespace std;
int main(void){
    int N,T,A;
    scanf("%d",&N);
    scanf("%d",&T);
    scanf("%d",&A);
    int H[N];
    double resultord = 1000000000000;
    double resultnew;
    int fin;
    int k = -1;
    for(int i = 0; i < N; i++){
        scanf("%d", &H[i]);
        resultnew = fabs(A - (T - H[i] * 0.006));
        if(resultnew < resultord){
            fin = i + 1;
            resultord = resultnew;
        }
    }
    printf("%d\n", fin);
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void){
    int a,b;

    scanf("%d %d", &a, &b);

    if(a > b){
        printf("a > b\n");
    }
    else if(a == b){
        printf("a == b\n");
    }
    else if(a < b){
        printf("a < b\n");
    }

    return 0;
}



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

int main(){
  int N;
  cin >> N;
  vector<vector<int>> A(2, vector<int>(N));
  for (int i=0; i<2; i++) {
    for (int j=0; j<N; j++) {
      cin >> A.at(i).at(j);
    }
  }
  ll max_candy = 0;
  for (int i=0; i<N; i++) {
    ll candy = 0;
    for (int j=0; j<i+1; j++) {
      candy += A.at(0).at(j);
    }
    for (int j=i; j<N; j++) {
      candy += A.at(1).at(j);
    }
    if (candy > max_candy) max_candy = candy;
  }
  cout << max_candy << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

n = int(input())
ret = ""
if n==0:
    ret = "0"
while n!=0:
    if n%2 ==1:
        ret= "1" + ret
        n-=1
    else:
        ret= "0" + ret
    n = n//(-2)

print(ret)

Measured memory_bytes: 3060
def getInput():
    """

    :return: list of list of str. 1st dim: row, 2nd dim: column.
    """
    separator = ' '
    ret_array = []
    while True:
        try:
            row = input().split(sep=separator)
            ret_array.append(row)
        except EOFError:
            break
    return ret_array


g = getInput()

print(48-int(g[0][0]))

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

using namespace std;

int main(){
    long long N,M;
    cin>>N>>M;
    vector<int> vec(M);

    for(int i=0;i<N;++i){
        int K;
        cin>>K;
        for(int k=0;k<K;++k){
            int A;
            cin>>A;
            vec[A-1]++;
        }
    }

int ans=0;
    for(int i=0;i<M;++i){
        if(vec[i]==N){
            ans++;
        }

    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H_list = list(map(int, input().split()))


dif_list = []
for i in range(N):
    iTemp = T - (H_list[i] * 0.006)
    dif = abs(A - iTemp)
    dif_list.append(dif)

M = min(dif_list)
l = dif_list.index(M)

print(l + 1)




Measured memory_bytes: 3060
import sys
N,Y=map(int,input().split())
for x in range(N+1):
  for y in range(N+1):
    z=N-x-y
    if 10000*x+5000*y+1000*z==Y and 0<=z:
      print(x,y,z)
      sys.exit()
    else:
      pass
print(-1,-1,-1)
      

Measured memory_bytes: 2940
q,h,s,d = map(int,input().split())
n=int(input())

res = 0
ll=min(q*8,h*4,s*2,d)
l=min(q*4,h*2,s)
if n%2== 0:
    print(ll*(n//2))
else:
    print(ll*(n//2)+l)


Measured memory_bytes: 38384
n, k = map(int, input().split())
a = list(map(int, input().split()))
MOD = 10**9 + 7

dp = [[0]*(k+1) for i in range(n+1)]
dp[0][0] = 1
ruiseki = [0] * (k+2)
for j in range(k+1):
    ruiseki[j+1] = ruiseki[j] + dp[0][j]

for i in range(n):
    for j in range(k+1):
        dp[i+1][j] = ruiseki[j+1] - ruiseki[max(j-a[i], 0)]
        dp[i+1][j] %= MOD
    ruiseki = [0] * (k+2)
    for j in range(k+1):
        ruiseki[j+1] = ruiseki[j] + dp[i+1][j]

print(dp[n][k])

Measured memory_bytes: 136676
#include<stdio.h>
int main()
{
    int x,y,N;
    char op;
    scanf("%d %c %d",&x,&op,&y);
    if(op=='+')
    {
        N=x+y;
        printf("%d\n",N);
    }
    else if(op=='-')
    {
        N=x-y;
        printf("%d\n",N);
    }
    return 0;
}


Measured memory_bytes: 128
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int Q = scanner.nextInt();
        for(int i = 1; i <= Q; i++) {
            long A = scanner.nextLong();
            long B = scanner.nextLong();
            long C = (long)Math.sqrt(A*B);
            if (C * (C+1) < A*B) {
                System.out.println(2*C - 1);
            }
            else if ( A*B == C*C && A!=B) {
                System.out.println(2*C - 3);
            }
            else {
                System.out.println(2*C - 2);
            }
        }
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned
#define ull unsigned ll
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define y1 wzpakking
#define fi first
#define se second
#define BG begin
#define ED end
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define sqr(x) (1ll*x*x)
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
#define inf (1<<30)
#define INF (1ll<<58)
using namespace std;
const int N=105;
int n,cnt,e[N][N];
pii q[N];
int main(){
	scanf("%d",&n);
	for (int i=1,j=n-(n&1);i<=j;i++,j--) q[++cnt]=pii(i,j);
	if (n&1) q[++cnt]=pii(n,0);
	For(i,1,cnt){
		int j=i%cnt+1;
		e[q[i].fi][q[j].fi]=1;
		e[q[i].se][q[j].fi]=1;
		e[q[i].fi][q[j].se]=1;
		e[q[i].se][q[j].se]=1;
	}
	cnt=0;
	For(i,1,n) For(j,i+1,n)
		if (e[i][j]|=e[j][i]) ++cnt;
	printf("%d\n",cnt);
	For(i,1,n) For(j,i+1,n)
		if (e[i][j]) printf("%d %d\n",i,j); 
}

Measured memory_bytes: 256
import Data.List
 
(|>) :: a -> (a -> b) -> b
infixl 1 |>
x |> f = f $! x
 
($>) :: (Functor m) => m a -> (a -> b) -> m b
infixl 1 $>
x $> f = fmap f $! x

calc :: [Int] -> Int
calc xs
    | len >= num = len - num
    | otherwise  = len
    where len = length xs
          num = head xs

main = do
    getLine
    ax <- getLine $> words $> map read :: IO [Int]
    ax |> sort |> group |> map calc |> sum |> print

Measured memory_bytes: 39676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
int main(){
    int n;
    cin >> n;
    vector<string> arr(n);
    for(int i = 0; i < n; ++i){
        cin >> arr[i];
        sort(arr[i].begin(),arr[i].end());
    }
    string total = arr[0];
    for(int i = 1; i < n; ++i){
        string mix;
        set_intersection(arr[i].begin(),arr[i].end(),total.begin(),total.end(),back_inserter(mix));
        total = mix;
    }
    cout << total << '\n';
}


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

ll dp[110][101010];
ll sum[101010];

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> A(n);
    rep(i, n) cin >> A[i];
    int a = 0;
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        a += A[i];
        memset(sum, 0, sizeof sum);
        for(int j = 1; j <= k + 1; j++) sum[j] = (sum[j - 1] + dp[i][j - 1]) % mod;
        for(int j = 0; j <= min(a, k); j++) dp[i + 1][j] = (sum[j + 1] - sum[max(0, j - A[i])] + mod) % mod;
    }
    cout << dp[n][k] << endl;
    return 0;
}

Measured memory_bytes: 81408
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int n;
int ans=0x3fffffff;

int work(int x){
    int cnt=0;
    while(x){
        cnt+=x%10;
        x/=10;
    }
    return cnt;
}

int main(){
    scanf("%d",&n);
    for(int a=1;a<=n/2;a++){
        int b=n-a;
        ans=min(ans,work(a)+work(b));
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <stack>
#include <cstring>
using namespace std;

int a, b,c;

int main()
{
	string word;
	stack <int> S;
	while (cin >> word)
	{
		if (word == "+")
		{

			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a + b);
		}
		else if (word == "-")
		{
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(b - a);
		}
		else if (word == "*")
		{
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a * b);
		}
		else
		{
			c = atoi(word.c_str());
			S.push(c);
		}
	}
	cout << S.top() << endl;
	return 0;
}




Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll q;
    cin >> q;
    rep(i, q) {
        string s, t;
        cin >> s >> t;
        ll n = s.size(), m = t.size();
        ll dp[1100][1100] = {0};
        rep(i, n) rep(j, m) {
            if(s[i] == t[j]) dp[i+1][j+1] = max({dp[i][j] + 1, dp[i+1][j], dp[i][j+1]});
            else dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
        }
        cout << dp[n][m] << endl;
    }
}



Measured memory_bytes: 12660
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 1024;

int main(void) {
	// in = fopen("A.in", "rt");
	
	int h, w, n;
	fscanf(in, "%d %d %d", &h, &w, &n);
	
	int ans = 0;
	if (h > w) {
	    while (n > 0) {
	        n -= h;
	        ans++;
        }
    } else {
        while (n > 0) {
            n -= w;
            ans++;
        }
    }
    fprintf(out, "%d\n", ans);
	
	
	return 0;
}

Measured memory_bytes: 128
// 2011/09/20 Tazoe

#include <iostream>
using namespace std;

int main()
{
	bool S[30];
	for(int i=0; i<30; i++)
		S[i] = false;

	for(int i=0; i<28; i++){
		int s;
		cin >> s;
		S[s-1] = true;
	}

	for(int i=0; i<30; i++)
		if(!S[i])
			cout << i+1 << endl;

	return 0;
}

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

using namespace std;

#define B_to_Y 380000

int main(void){
  int N;
  cin >> N;
  vector <float> x(N);
  vector <string> u(N);
  int i;
  float sum=0.0;
  for(i=0;i<N;i++){
    cin >> x[i] >> u[i];
    sum += u[i] == "JPY" ? x[i] : x[i]*B_to_Y;
  }
  cout << sum << endl;

  return 0;
}

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

int main(){
	int H, W;
	while (true){
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++)	cout << "#";
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    ll x;cin>>x;
    ll a=100;
    ll n=0;
    while(a<x)
    {
        a*=1.01;
        n++;
        //cout<<a<<endl;
    }
    cout<<n<<endl;
}


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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)


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

	long long int i = floor(n / (a + b));

	ll ans = 0;
	if (n % (a + b) >= a)
		ans = a * (i + 1);
	else
		ans = a * i + n % (a + b);

	cout << ans << endl;



}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

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

signed main() {
  int N; cin >> N;
  string S;
  N --;
  while(N >= 0){
    char C = 'a' + N%26;
    S = C + S;
    N /= 26;
    N--;
  }
  cout << S << endl;
}

Measured memory_bytes: 3648
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    int n = nextInt();
    int k = nextInt();

    int ans = 0;

    for(;n>0;){
      n /= k;
      ans++;
    }


    System.out.println(ans);

  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


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


int main() {

    string n;
    cin >> n;
    if (n[0] == n[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n;
    scanf("%d",&n);

    int p[n],i,cnt=0;
    for(i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    for(i=0;i<n;i++){
        if(p[i]!=i+1){
            cnt++;
        }
    }
    if(cnt<3){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>

using namespace std;

int main(){
  string s1, s2, s3;
  
  cin >> s1 >> s2 >> s3;
  char c1 = 'A'+s1[0]-'a';
  char c2 = 'A'+s2[0]-'a';
  char c3 = 'A'+s3[0]-'a';
  cout << c1 << c2 << c3 << endl;
}


Measured memory_bytes: 384
while True:
    N=input()
    if N==0:break
    x,y=[0]*N,[0]*N
    tx,ty=(-1,0,1,0),(0,-1,0,1)
    for i in range(1,N):
        n,d=map(int,raw_input().split())
        x[i]=x[n]+tx[d]
        y[i]=y[n]+ty[d]
    print max(x)-min(x)+1,max(y)-min(y)+1

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



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s,t;
    cin>>s>>t;
    for (int i=0;i<(int)s.size();i++){
    	if (s[i]!=t[i]){
    		cout<<"No\n";
    		return 0;
    	}
    }
    if (t.size()!=s.size()+1){
    	cout<<"No\n";
    	return 0;
    }
    cout<<"Yes\n";

	return 0;
}


Measured memory_bytes: 3640
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;


int main ()
{
	int N;
	int ansa = 0 , ansb = -1;
	cin >> N;
	int a , b;
	for( size_t i = 0; i < N; i++ )
	{
		cin >> a >> b;
		if( b > ansb )
		{
			ansa = a;
			ansb = b;
		}
		if( ansb == b &&a < ansa )
		{
			ansa = a;
		}
	}
	cout << ansa << " " << ansb << endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int a[maxn], book[maxn];
vector <int> g[maxn];
int n, m;
void dfs(int u)
{
	book[u] = 1;
	for(int i = 0; i < g[u].size(); i++){
		int v = g[u][i];
		if(book[v] == 0){
			a[v] = a[v] + a[u];
			dfs(v);
		}
	}
}
int main()
{
	cin >> n >> m;
	for(int i = 1; i <= n - 1; i++){
		int c, d;
		scanf("%d %d", &c, &d);
		g[c].push_back(d);
	}
	for(int i = 1; i <= m; i++){
		int c, d;
		scanf("%d %d", &c, &d);
		a[c] += d;
	}
	dfs(1);
	for(int i = 1; i <= n; i++){
		printf("%d ", a[i]);
	}
	return 0;
} 

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    reverse(a, a + n);
    int alice = 0, bob = 0;
    rep(i, n) {
        if (i % 2) bob += a[i];
        else alice += a[i];
    }
    cout << alice - bob << endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<int> cnt(9);
	rep(i, n) {
		int t = a[i] / 400;
		if (t > 8) t = 8;
		cnt[t]++;
	}
	int mn = 0;
	rep(i, 8) {
		if (cnt[i]) mn++;
	}
	int mx = mn + cnt[8];
	if (mn == 0) {
		mn++;
	}
	cout << mn << " " << mx << endl;
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define mem(a, b) memset(a, (b), sizeof(a))
#define fore(i,a) for(int i=0;i<a;i++)
#define fore1(i,j,a) for(int i=j;i<a;i++)
#define print(ar) for(int i=0;i<ar.size();i++)cout<<ar[i]<<" ";
#define END cout<<'\n'
const double pi=acos(-1.0);
 
typedef pair<int, int> PII;
 
typedef vector<long long> VI;
 
typedef vector<string> VS;
 
typedef vector<PII> VII;
 
typedef vector<VI> VVI;
 
typedef map<int,int> MPII;
 
typedef set<int> SETI;
 
typedef multiset<int> MSETI;
 
typedef long int li;
 
typedef unsigned long int uli;
 
typedef long long int ll;
 
typedef unsigned long long int  ull;
ll fastexp (ll a, ll b, ll n) {
  ll res = 1;
  while (b) {
      if (b & 1) res = res*a%n;
      a = a*a%n;
      b >>= 1;
  }
  return res;
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int diff(string a,string b){
    int dc=0;
    fore(i,a.length()){
        if(a[i]!=b[i])dc++;
    }
    return dc;
}
int main()
 {  fast();
     string a,b;
     cin>>a>>b;
     int n= a.length();
     int m = b.length();
     int arr[n+1][m+1];
     fore(i,n+1){
         arr[i][0]=0;
     }
     fore(j,m+1)arr[0][j]=0;
     fore1(i,1,n+1){
         fore1(j,1,m+1){
             if(a[i-1]==b[j-1])arr[i][j]=arr[i-1][j-1]+1;
             else arr[i][j]=max(arr[i][j-1],arr[i-1][j]);
         }
     }
    int i=n;
     int j=m;
     string ans="";
     while(i>0&&j>0){
         if(arr[i][j]==arr[i-1][j-1]+1&&a[i-1]==b[j-1]){
             ans=a[i-1]+ans;
             i--;
             j--;
         }
         else if(arr[i][j]==arr[i][j-1])j--;
         else i--;
     }
     cout<<ans<<endl;
	}
	/*5
2 4
abac
zbab
2 4
aaaa
bbbb
3 3
baa
aaa
aab
2 2
ab
bb
3 1
a
b
c*/

Measured memory_bytes: 35456
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
using namespace std;

int main(){
	char s[10];
	int n,ac=0,wa=0,tle=0,re=0;
	scanf("%d",&n);
	getchar();
	for(int i=1;i<=n;i++)
    {
        scanf("%s",s);
        getchar();
        switch(s[0])
        {
            case 'A':ac++;break;
            case 'W':wa++;break;
            case 'T':tle++;break;
            case 'R':re++;break;
        }
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",ac,wa,tle,re);
	return 0;
}


Measured memory_bytes: 3828
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=3e3+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15), sINF = ll(1e9);

ll dp[MAXn][MAXn];

int main()
{
    IOS();
    dp[1][1] = 1;
    ll n;
    cin>>n;
    string s;
    cin>>s;
    REP1(i, n-1)
    {
        if(s[i-1] == '<')
        {
            ll tt = 0;
            REP1(j, i+1)
            {
                dp[i+1][j] = tt;
                tt = (tt + dp[i][j])%MOD;
            }
        }
        else
        {
            ll tt = 0;
            for(int j = i;j >= 1;j --)
            {
                tt = (tt + dp[i][j])%MOD;
                dp[i+1][j] = tt;
            }
        }
    }
    ll tt = 0;
    REP1(i, n)tt = (tt + dp[n][i]) % MOD;
    cout<<tt<<endl;
}


Measured memory_bytes: 69120
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int H, W; cin >> H >> W;
    vector<int> vA(H*W);
    vector<int> vH_idx(H*W);
    vector<int> vW_idx(H*W);
    for(int h=0; h<H; ++h){
        int a;
        for(int w=0; w<W; ++w){
            cin >> a;
            vA    [W*h + w] = a;
            vH_idx[W*h + w] = h+1;
            vW_idx[W*h + w] = w+1;
        }
        
        if(h%2==0){ continue; }
        reverse(&    vA[W*h + 0], &    vA[W*h + W]);
        reverse(&vH_idx[W*h + 0], &vH_idx[W*h + W]);
        reverse(&vW_idx[W*h + 0], &vW_idx[W*h + W]);
    }
    
    vector<string> vS;
    for(int i=0; i<H*W-1; ++i){
        if(vA[i]%2==0){ continue; }
        ++vA[i+1];
        int h = vH_idx[i];
        int w = vW_idx[i];
        int h_next = vH_idx[i+1];
        int w_next = vW_idx[i+1];
//        cout << h << ' ' << w << ' ' << h_next << ' ' << w_next << endl;
        string buf = to_string(h) + ' ' + to_string(w) + ' ' + to_string(h_next) + ' ' + to_string(w_next);
        vS.push_back( buf );
    }
    
    cout << vS.size() << endl;
    for(uint i=0; i<vS.size(); ++i){
        cout << vS[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 13812
#include <bits/stdc++.h>
using namespace std;
#define show(x) cout << #x << " : " << x << endl;

int main ()
{
 int n, i, cnt = 0;
 cin >> n;
 int a[n+1];
 for(i = 1; i <= n; i++) cin >> a[i];
 for(i = 2; i < n; i++)
 {
   if((a[i] < a[i-1] and a[i] > a[i+1]) or a[i] > a[i-1] and a[i] < a[i+1]) cnt++;
 }
 cout << cnt << endl;
}

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

int main(){
    int n, q;
    cin >> n >> q;
    vector<pair<string, int>> que(n);
    rep(i,n){
        cin >> que[i].first >> que[i].second;
    }
    queue<pair<string, int>> ar;
    rep(i,n){
        ar.push(que[i]);
    }
    int ti = 0;
    pair<string, int> p;
    while (!ar.empty()){
        if (ar.front().second > q){
            ti += q;
            ar.front().second -= q;
            p = ar.front();
            ar.pop();
            ar.push(p);
        }
        else {
            ti += ar.front().second;
            cout << ar.front().first << " " << ti << endl;
            ar.pop();
        }
    }
}


Measured memory_bytes: 6828
#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=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
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;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    vll a(n), b(n), c(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    rep(i, 0, n) cin >> c[i];
    ll ans = 0;
    sort(all(a)); sort(all(b)); sort(all(c));
    rep(i, 0, n) {
        ll s = lower_bound(all(a), b[i]) - a.begin(), u = upper_bound(all(c), b[i]) - c.begin();
        ans += s * (n - u);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
//int ans = 0;

long long int recursive(int arr[100005][3], int sz, int row, int initial, long long int dp[100005][3]) {
	if (row >= sz)
		return 0;

	if (dp[row][initial] != -1)
		return dp[row][initial];

	int ans = 0;

	if (initial == 0) {
		int mchoice = arr[row][1] + recursive(arr, sz, row + 1, 1, dp);
		int rchoice = arr[row][2] + recursive(arr, sz, row + 1, 2, dp);
		ans = max(ans,max(mchoice, rchoice));
	} else if (initial == 1) {
		int lchoice = arr[row][0] + recursive(arr, sz, row + 1, 0, dp);
		int rchoice = arr[row][2] + recursive(arr, sz, row + 1, 2, dp);
		ans += max(ans,max(lchoice, rchoice));
	} else if (initial == 2) {
		int lchoice = arr[row][0] + recursive(arr, sz, row + 1, 0, dp);
		int mchoice = arr[row][1] + recursive(arr, sz, row + 1, 1, dp);
		ans += max(ans,max(lchoice, mchoice));

	}
	else {
		int lans = arr[row][0] + recursive(arr, sz, row + 1, 0, dp);
		int mans = arr[row][1] + recursive(arr, sz, row + 1, 1, dp);
		int rans = arr[row][2] + recursive(arr, sz, row + 1, 2, dp);
		ans += max(ans,max(lans,max(mans, rans)));

	}

	return dp[row][initial] = ans;

}

int main() {
	int n;
	cin >> n;
	int arr[100005][3];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 3; j++)
			cin >> arr[i][j];


	long long int dp[100005][3];

	memset(dp, -1, sizeof dp);
	cout << recursive(arr, n, 0, 3, dp) << "\n";
	return 0;
}

Measured memory_bytes: 17968
<?php

function check($a, $b, $c)
{
    $sum = 0;
    for ($i = 0; $i < count($a); $i++) {
        $sum += $a[$i] * $b[$i];
    }

    return $sum + $c > 0;
}

// 入力
fscanf(STDIN, "%d %d %d", $n, $m, $c);
$strB = fgets(STDIN);
$b = array_map('intval', explode(' ', $strB));

$result = 0;

for ($i = 0; $i < $n; $i++) {
    $strA = fgets(STDIN);
    $a = array_map('intval', explode(' ', $strA));

    if (check($a, $b, $c)) {
        $result++;
    }
}

# 出力
echo $result . "\n";


Measured memory_bytes: 4728
#include<iostream>

using namespace std;

int main (){
  int N,i;
  int *V;
  int *C;
  
  //宝石の個数を入力（１以上２０以下の整数）
  cin>> N;
  //宝石の価値を入力（１以上５０以下の整数）
  V = new int[N];
  for(i=0;i<N;i++){
    cin>> V[i];
  }
  //宝石のコストを入力（１以上５０以下の整数）
  C = new int[N];
  for(i=0;i<N;i++){
    cin>> C[i];
  }
 int X=0,Y=0;
  for(i=0;i<N;i++){
    if(V[i]>C[i]){
    	X+=V[i];
        Y+=C[i];
    }
  }
  cout<< X-Y <<endl;
  delete[] V;
  delete[] C;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
inline int Add(int x,int y){
    return (x+=y)>=mod?x-mod:x;
}
inline int Sub(int x,int y){
    return (x-=y)>=0?x:x+mod;
}
inline int Mul(int x,int y){
    return 1ll*x*y%mod;
}
int n,x,y,z;
int dp[1<<16],newdp[1<<16];
bool ok[1<<17];
bool check(int n){
    vector<int> v;
    int c=0;
    while(n){
        c++;
        if(n&1){
            v.push_back(c);
            c=0;
        }
        n>>=1;
    }
    int o=z;
    int sum=0;
    for(int i=0;i<v.size();i++){
        sum+=v[i];
        if(sum==o){
            if(o==z)o+=y;
            else if(o==y+z)o+=x;
            else o=-1;
        }
    }
    if(o==-1)return false;
    return true;
}
int main(){
    scanf("%d%d%d%d",&n,&x,&y,&z);
    int m=x+y+z-1;
    for(int i=0;i<(1<<m+1);i++)ok[i]=check(i);
    //for(int i=0;i<(1<<m);i++)cout<<i<<' '<<ok[i]<<endl;
    dp[0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<(1<<m);j++)newdp[j]=0;
        for(int j=0;j<(1<<m);j++){
            if(dp[j]==0)continue;
            for(int k=1;k<=10;k++){
                int x=(j<<k|(1<<(k-1)))&((1<<m+1)-1);
                if(ok[x]){
                    x=x&((1<<m)-1);
                    newdp[x]=Add(newdp[x],dp[j]);
                }
            }
        }
        for(int j=0;j<(1<<m);j++)dp[j]=newdp[j];
    }
    int ans=1;
    for(int i=1;i<=n;i++)ans=Mul(ans,10);
    for(int i=0;i<(1<<m);i++)ans=Sub(ans,dp[i]);
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 896
/*  -*- coding: utf-8 -*-
 *
 * b.cc: D: Card Eater
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_A = 100000;

/* typedef */

/* global variables */

int cs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int ai;
    cin >> ai;
    ai--;
    cs[ai]++;
  }

  int on = 0, en = 0, e0 = -1, e1 = -1;
  for (int i = 0; i < MAX_A; i++)
    if (cs[i]) {
      if (cs[i] & 1) on++;
      else {
	en++;
	if (e0 < 0) e0 = i;
	else e1 = i;
      }
    }
  //printf("on=%d,en=%d,e0=%d,e1=%d\n", on, en, e0, e1);

  int ans;
  if (en & 1) ans = on + en -1;
  else if (en == 0 || e0 + 1 != e1) ans = on + en;
  else ans = on + en - 1;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
main()
{
    long long a,b,i,j,k,l;
    cin>>l>>a>>b;
      i=a-1;
      k=min(i,b);
      j=(k*l)/a;
    cout<<j<<endl;
    return 0;
}


Measured memory_bytes: 3508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll mod = 1e9+7;
typedef pair<int,int> P;
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,m,N) for(int i=m;i<N;i++)
#define mm(n,m) memset(n,m,sizeof(n))

int main(){
    ll n,m;
    cin>>n>>m;
    ll a[n];
    priority_queue<ll>p;
    rep(i,n){
        cin>>a[i];
        p.push(a[i]);
    }
    rep(i,m){
        ll t = p.top();
        p.pop();
        p.push(t/2);
    }
    ll ans = 0;
    rep(i,n){
        a[i] = p.top();
        p.pop();
    }
    rep(i,n)ans+=a[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 1912