akhauriyash/Code-Regression huggingface dataset:
x=[0,0,0]
n=int(input())
for i in input().split():
    if int(i)%4==0:
        x[0]+=1
    elif int(i)%2==0:
        x[1]+=1
    else:
        x[2]+=1
if x[1]==0:
    if x[0]+1>=x[2]:
        print("Yes")
    else:
        print("No")
else:
    if x[0]>=x[2]:
        print("Yes")
    else:
        print("No")
#print(x)


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

using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;
	int ans = 0;

	if (A > B) {
		ans += A;
		A--;
	} else {
		ans += B;
		B--;
	}
	ans += max(A, B);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin>> A >> B >> C >> D;
  if (A+B>C+D)
    cout<<"Left"<<endl;
  else if(A+B==C+D)
  	cout<<"Balanced"<<endl;
  else
    cout<<"Right"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int h,w,i,j;
    cin>>h>>w;
    while(h>=1&&w>=1){
        for(i=1;i<=h/2;i++){
            for(j=1;j<=w/2;j++){
                cout<<"#.";
            }
            if(w%2==1){
                cout<<"#";
            }
            cout<<"\n";
            for(j=1;j<=w/2;j++){
                cout<<".#";
            }
            if(w%2==1){
                cout<<".";
            }
            cout<<"\n";
        }
        if(h%2==1){
            for(i=1;i<=w/2;i++){
                cout<<"#.";
            }
            if(w%2==1){
                cout<<"#";
            }
            cout<<"\n";
        }
        cout<<"\n";
        cin>>h>>w;
    }
}

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

int main(){
  int n,m;
  cin >> n;
  vector<int> a(n),b(n);
  rep(i,n){
    cin >> a[i];
    b[i] = a[i];
    }
  sort(b.begin(),b.end());
  rep(i,n){
    if(a[i] == b.back())cout << b[b.size()-2] << "\n";
    else cout << b.back() << "\n";
  }
}

Measured memory_bytes: 3200
def main():

    from collections import Counter
    import sys

    n = int(input())
    a = list(map(int, sys.stdin.readline().split()))

    d = Counter(a)

    base = sum(v * (v - 1) // 2 for v in d.values())
    e = {k: base - (v >= 2) * (v - 1) for k, v in d.items()}
    for i in a:
        print(e[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 32488
import sys
import math
from collections import Counter
import itertools
import fractions
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################
 
A,B,N = MI()

mini = min(B-1,N)
s = math.floor(A*mini/B) - A * math.floor(mini/B)
print(s)

Measured memory_bytes: 10464
#include<stdio.h>

int main()
{
  short rate_before,rate_after;
  int price_before,i,a,b,max;
  int n,m,p,q,r;
    
  // i,p = ?¨???????????????????
  // n,r = ????¨???????????????????
  // a,b = ????¨???????????????????

  while(1){
    max = 0;
    scanf("%hd %hd %d",&rate_before,&rate_after,&price_before);

    if(rate_before == 0 && rate_after == 0 && price_before == 0){
      break;
    }

    for(i = 1;i <= price_before/2;i++){
      n = i * (100+rate_before) / 100;
      m = price_before - n;
      p = m * 100 / (100+rate_before);

      while(1){
          p++;
          q = p * (100+rate_before) / 100;
          if(n + q != price_before){
              p--;
              break;
          }
      }

      r = p * (100+rate_before) / 100;

      if(n + r == price_before){
          a = i * (100+rate_after) / 100;
          b = p * (100+rate_after) / 100;
          if(a+b > max){
              max = a + b;
          }
      }
    }
    
    printf("%d\n",max);
  }

  return 0;
}

Measured memory_bytes: 600
if __name__ == "__main__":
    time_interval = int(input())
    t0_num = int(input())
    min_num = t0_num
    t1_num = int(input())
    if t1_num < t0_num:
        min_num = t1_num
    max_diff = t1_num - t0_num

    for _ in range(2, time_interval):
        t_num = int(input())
        if max_diff < t_num - min_num:
            max_diff = t_num - min_num
        if t_num < min_num:
            min_num = t_num

    print(f"{max_diff}")



Measured memory_bytes: 5620
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
	BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
	int n=Integer.parseInt(input.readLine());
	for(int i=0;i<n;i++)
	    {
		String str=input.readLine();
		
		int a[]=new int[8];
		int b[]=new int[8];
		for(int j=0;j<8;j++)
		    {
			a[j]=Integer.parseInt(str.charAt(j)+"");
			b[j]=Integer.parseInt(str.charAt(j)+"");
		    }
		for(int j=0;j<8;j++)
		    {
			for(int k=7;j<k;k--)
			    {
				if(a[k-1]>a[k])
				    {
					int tmp=a[k-1];
					a[k-1]=a[k];
					a[k]=tmp;
				    }
				if(b[k-1]<b[k])
				    {
					int tmp=b[k-1];
					b[k-1]=b[k];
					b[k]=tmp;
				    }
			    }

		    }
		
		int sumb=0,suma=0;
		for(int j=0;j<8;j++)
		    {
			sumb+=b[j]*((int)(Math.pow(10,7-j)));
			if(a[j]==0)continue;
			suma+=a[j]*((int)(Math.pow(10,7-j)));
		    }
		System.out.println(sumb-suma);
	    }
    }
}

Measured memory_bytes: 16888
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 




int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   long long int X;
  long long int a = 100;
  long long int sum = 0;
  cin>>X;
  while(a < X)
  {
    a += (a/100);
    sum += 1;
  }
  cout<<sum<<'\n';
}




Measured memory_bytes: 3628
sentinel = 1000000001

def merge(A, left, mid, right):
    L = A[left:mid]
    n1 = len(L)
    L.append(sentinel)
    R = A[mid:right]
    R.append(sentinel)
    i = 0
    j = 0
    cnt = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            cnt += n1 - i
    return cnt

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        cnt1 = mergeSort(A, left, mid)
        cnt2 = mergeSort(A, mid, right)
        cnt3 = merge(A, left, mid, right)
        return cnt1 + cnt2 + cnt3
    else:
        return 0


n = int(input())
S = list(map(int, input().split()))

cnt = 0

n_ivs =  mergeSort(S, 0, n)

print(n_ivs)

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

int main() {
  ll n;
  cin>>n;
  ll ans=0;
  ll co=n/10;
  while(co>0){
    ans+=co;
    co/=5;
  }
  if(n%2==0){
    cout<<ans<<endl;  
  }
  else{
    cout<<0<<endl;
  }
}



Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define mp make_pair
#define pi pair<int,int>
#define pb push_back
using namespace std;
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
int fa[500003],sz[500003];
int x[500003],y[500003];
int t[500003],tmp[500003];
set<int> s;
int find(int x) { return (fa[x]==x)?x:fa[x]=find(fa[x]); }
void merge(int x,int y)
{
	x=find(x),y=find(y);
	if(x!=y) fa[x]=y,sz[y]+=sz[x];
	return ;
}
int main()
{
	int n=read();
	for(int i=1; i<=n; i++) x[i]=read(),y[i]=read(),sz[i]=1,fa[i]=i,t[x[i]]=y[i];
	s.insert(t[1]);
	for(int i=2; i<=n; i++)
	{
		set<int>::iterator it=s.lower_bound(t[i]);
		if(it==s.begin()) { s.insert(t[i]); continue; }
		int len=0;
		for(set<int>::iterator j=s.begin(); j!=it; j++) tmp[++len]=*j;
		for(int j=1; j<len; j++) merge(tmp[j+1],tmp[j]);
		merge(t[i],tmp[1]),s.insert(tmp[1]);
	}
	for(int i=1; i<=n; i++) printf("%d\n",sz[find(y[i])]);
	return 0;
}


Measured memory_bytes: 12588
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		String i = kb.next();
		String j = kb.next();
		kb.close();
		String k = "123".replace(i, "");
		 k = k.replace(j, "");
		 System.out.println(k);
	}

}


Measured memory_bytes: 21844
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		Map<Long, Integer> sheSaid = new HashMap<>();

		int turns = Integer.parseInt(scanner.nextLine());
		for (int turn = 0; turn < turns; turn++) {
			long number = Long.parseLong(scanner.nextLine());
			sheSaid.put(number, Optional.ofNullable(sheSaid.get(number)).orElse(0) + 1);
		}

		System.out.println(sheSaid.entrySet().stream().filter(e -> e.getValue() % 2 != 0).count());
	}
}


Measured memory_bytes: 99044
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	int A, B;
	double j = 1;
	cin >> A >> B;
	REP(i, 12000) {
		if (floor(j * 0.08) == A && floor(j * 0.1) == B) {
			cout << j;
			return 0;
		}
		j++;
	}
	cout << -1;
}

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

int main(void){
    int N;
    cin >> N;

    vector<int> numbers(N);
    for(int i=0; i<N; i++){
        cin >> numbers.at(i);
    }

    int counter = 0;
    while(1){
        for(int i=0; i<N; i++){
            if(!(numbers.at(i)%2==0)){
                cout << counter << endl;
                return 0;
            }
            numbers.at(i)/=2;
        }
        counter++;
    }
    return 0;
}

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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int N,K;
int b[2002][2002];
int s[4002][4002];
 
int get(int x , int y){
	return s[x+K-1][y+K-1] + s[x-1][y-1] - s[x-1][y+K-1] - s[x+K-1][y-1];
}
 
signed main(){
	cin >> N >> K;
	rep(i,0,N){
		int x,y;
		char c;
		cin >> x >> y >> c;
		if(c=='W') y += K;
		++b[x%(2*K)+1][y%(2*K)+1];
	}
	rep(i,1,4*K+1){
		rep(j,1,4*K+1){
			s[i][j] =b[(i-1)%(2*K)+1][(j-1)%(2*K)+1];
		}
	}
	rep(i,1,4*K+1){
		rep(j,1,4*K+1){
			s[i][j] += s[i][j-1];
		}
	}
	rep(j,1,4*K+1){
		rep(i,1,4*K+1){
			s[i][j] += s[i-1][j];
		}
	}
	int ans = 0;
	rep(i,1,2*K+1){
		rep(j,1,2*K+1){
			ans = max(ans , get(i,j) + get(i+K,j+K));
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int a,b;
    char op;
    while(1){
        cin >> a >> op >> b;
        if(op == '?') break;
        if(op == '+') cout << a + b << endl;
        if(op == '-') cout << a - b << endl;
        if(op == '*') cout << a * b << endl;
        if(op == '/') cout << a / b << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
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 debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
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;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

// 行き止まり (A か B の少なくとも一方に行けない
// or 行けるけど行き止まりのとこだった) の頂点を見つけよう

int N, M;
string s;
vector<int> G[200010];
int is_terminate[200010], cand_A[200010], cand_B[200010];
 
signed main() {
    cin >> N >> M >> s;
    for(int i=0; i<M; i++) {
        int u, v; cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
        // u -> v
        (s[v] == 'A' ? cand_A : cand_B)[u]++;
        // v -> u
        (s[u] == 'A' ? cand_A : cand_B)[v]++;
    }

    // 一手で不可能なやつ
    queue<int> que;
    for(int i=0; i<N; i++) {
        bool find_A = false, find_B = false;
        for(auto to : G[i]) {
            find_A |= (s[to] == 'A');
            find_B |= (s[to] == 'B');
        }
        if((find_A & find_B) == false) {
            // i 番目から任意の文字列を作るのは不可能
            is_terminate[i] = true;
            que.push(i);
        }
    }

    // 推移的にやるやつ
    while(que.size()) {
        int i = que.front(); que.pop();
        // fprintf(stderr, "impossible: %lld\n", i);

        for(auto to : G[i]) {
            (s[i] == 'A' ? cand_A : cand_B)[to]--;

            // fprintf(stderr, "to = %lld, cand_A = %lld, cand_B = %lld\n", to, cand_A[to], cand_B[to]);
            if((cand_A[to] == 0 or cand_B[to] == 0) and is_terminate[to] == false) {
                is_terminate[to] = true;
                que.push(to);
            }
        }
    }

    bool yes = false;
    for(int i=0; i<N; i++) {
        yes |= (is_terminate[i] == false);
    }
    cout << (yes ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 17284
#include <bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(int i = l; i < (r); i++)
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0);cin.tie(0)
using ll = long long;
using ull = unsigned long long;

int main() {
  fastio;
  int N; cin >> N;
  unordered_map<int, int> mp; // boss -> subs cnt
  int a;
  rep(i,0,N-1) {
    cin >> a;
    mp[a]++;
  }
  for (int i = 1; i <= N; i++) {
    cout << mp[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 11492
#include<bits/stdc++.h>
#define ll long long
const int N=100005;
using namespace std;
string s;
int x; 
int main(){
	cin>>s;
	x+=s[0]-48;
	x+=s[1]-48;
	x+=s[2]-48;
	cout<<x;
    return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];

    int c[h][w];
    int y = 0, x = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < a[i]; j++) {
            c[y][x] = i + 1;
            if (y % 2 == 0) {
                if (x == w - 1) y++;
                else x++;
            } else {
                if (x == 0) y++;
                else x--;
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (j == w - 1) cout << c[i][j] << endl;
            else cout << c[i][j] << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	ans := n
	for i := 1; i * i <= n; i++ {
		if n % i != 0 {
			continue
		}
		j := n / i
		if i+j - 2 < ans{
				ans = i+j-2
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <cstdio>
#include <list>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
  int n, i, a;
  char s[20];
  list<int> v;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s", s);
    if (s[0] == 'i') {
      scanf("%d", &a);
      v.push_front(a);
    }
    else if (s[6] == 'F')
      v.pop_front();
    else if (s[6] == 'L')
      v.pop_back();
    else {
      scanf("%d", &a);
      for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
	if (*it == a) {
	  v.erase(it);
	  break;
	}
      }
    }
  }
  i = 0;
  for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
    if (i++)
        printf(" ");
    printf("%d", *it);
  }
  putchar('\n');
}



Measured memory_bytes: 33984
from collections import defaultdict

cnt = defaultdict(int)

N = int(input())
for _ in range(N):
    cnt[input()] += 1

M = int(input())
for _ in range(M):
    cnt[input()] -= 1

ans = 0
for c in cnt.values():
    ans = max(ans, c)

print(ans)

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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;


void solve(){
    int n;
    cin>>n;
    string s;
    map<string, bool> mp;
    fr(i, n){
        cin>>s;
        mp[s] = 1;
    }
    cout<<mp.size();
}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



Measured memory_bytes: 19200
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


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

    int n, k; cin >> n >> k;
    int ans=0;
    rep(i, n){
        int h; cin >> h;
        if(h>=k) ++ans;
    }
    cout << ans << endl;

    
    return 0;
}

Measured memory_bytes: 256
from decimal import Decimal
from decimal import Decimal, getcontext
import math
a,b = map(float,(input().split()))

#a = 10**15 #test
#ans = a * b
#getcontext().prec = 10**16
#b = b * 100
#ans = a *b
#ans = ans /100

a = str(a)
b = str(b)
ans = Decimal(a) * Decimal(b)

ans = math.floor(ans)

print(ans)


Measured memory_bytes: 10084
from functools import reduce

# def gcd(a, b):
#   if (b == 0):
#     return a
#   return gcd(b, a % b)

# def lcm(a, b):
#   return a * b / gcd(a, b)

def lcm(a, b): 
    def gcd(a, b):  # a >= b
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    return a * b // gcd(a, b)

def main():
  n = int(input())
  li = []
  for i in range(n):
    inp = int(input())
    li.append(inp)

  ans = int(reduce((lambda x, y: lcm(x, y)), li))
  if ans > 1000000000000000000:
    ans = 1000000000000000000
  print(ans)

if __name__ == "__main__":
  main()

Measured memory_bytes: 3572
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;

#define rep0(n) for(int i=0;i<n;i++)
#define rep(n) for(int i=1;i<=n;i++)

double const pi = 3.1415926535;
int const mod = 1000000007;
int const inf = 2147483647;

int yesno(bool flag, string yes, string no) {
	if (flag)cout << yes << endl;
	else cout << no << endl;
	return 0;
}

int printint(int n) {
	cout << n << endl;
	return 0;
}

int prints(string s) {
	cout << s << endl;
	return 0;
}

int main() {

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	cout << min(a, b) + min(c, d) << endl;

	return 0;
}

Measured memory_bytes: 764
#import <stdio.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)

int main() {
    int n;
    scanf("%d ", &n);
    int s[2] = {0};
    rep(i,n) s[getchar() == 'R' ? 1 : 0]++;
    puts(s[1] > s[0] ? "Yes" : "No");
}


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

int main()
  {
   int n, k; cin >> n >> k;
   int a[n]; for(int i=0; i<n; i++) cin >> a[i];
  sort(a, a+n);
  int ans=0;
  for(int i=0; i<k; i++) ans += a[i];
  cout << ans << endl;
}

Measured memory_bytes: 3572
while True:
    w, h = map(int, input().split())
    if w == 0:
        break
    row = []
    col = []
    for i in range(h-1):
        row.append(input().split())
        col.append(input().split())
    row.append(input().split())
    check_map = [[False for i in range(w)] for j in range(h)]
    search_list = [[0, 0, 1]]
    check_map[0][0] = True
    ok = False
    while len(search_list) > 0:
        x, y, step = search_list.pop(0)
        if x == w-1 and y == h-1:
            print(step)
            ok = True
            break
        # 左
        if x > 0:
            if row[y][x-1] == "0" and not check_map[y][x-1]:
                search_list.append([x-1, y, step+1])
                check_map[y][x-1] = True
        # 右
        if x < w-1:
            if row[y][x] == "0" and not check_map[y][x+1]:
                search_list.append([x+1, y, step+1])
                check_map[y][x+1] = True
        # 上
        if y > 0:
            if col[y-1][x] == "0" and not check_map[y-1][x]:
                search_list.append([x, y-1, step+1])
                check_map[y-1][x] = True
        # 下
        if y < h-1:
            if col[y][x] == "0" and not check_map[y+1][x]:
                search_list.append([x, y+1, step+1])
                check_map[y+1][x] = True
    if not ok:
        print(0)



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

const ll INF = 1E18+5;
const ll mod = 1E9+7;

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int i,cnt1 = 0, cnt2 = 0,ans = 0;
    for(i=0;i<n;i++)
        if(s[i]=='R')
            cnt1++;
    for(i=0;i<cnt1;i++)
        if(s[i]!='R')
            ans++;
    cout<<ans;
}




Measured memory_bytes: 3756
// D - Grid Repainting
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using VC = vector<char>;
using VVC = vector<VC>;
using PII = pair<int,int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int bfs(int H, int W, VVC &S){
	int dx[4]={0,-1,0,1}, dy[4]={-1,0,1,0};
	vvi dist(H+1, vi(W+1, -1));
	dist[1][1] = 0;
	queue<PII> q;
	q.push({1, 1});
	while(!q.empty()){
		int i,j; tie(i,j)= q.front(); q.pop();
		if(S[i][j] == '_') continue;
		S[i][j] = '_';
		if(i==H && j==W) break;
		rpz(k, 4){
			int y = i + dy[k], x = j + dx[k];
			if(S[y][x] != '.') continue;
			dist[y][x] = dist[i][j] + 1;
			q.push({y, x});
		}
	}
	return dist[H][W];
}

int main(){
	int H,W; cin>>H>>W;
	VVC S(H+2,VC(W+2, '#'));
	int block = 0;
	rpz(i, H){
		string s; cin>>s;
		rpz(j, W){
			if(s[j] == '#') block++;
			S[i+1][j+1] = s[j];
		}
	}
	int dist = bfs(H, W, S);
	cout<< (dist<0? -1: H*W - block - dist - 1) <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    i64 N, D, A;
    cin >> N >> D >> A;
    vector<pair<i64,i64>> M(N);
    rep(i, N) {
        cin >> M[i].first >> M[i].second;
        M[i].second = (M[i].second + A - 1) / A;
    }
    sort(all(M));

    vector<i64> damage(N + 1, 0);
    i64 ans = 0;
    int right = 0;

    rep(i,N){
        while(right < N && M[right].first <= M[i].first + 2*D) right++;
        M[i].second -= damage[i];
        if(M[i].second > 0){
            ans += M[i].second;
            damage[i] += M[i].second;
            damage[right] -= M[i].second;
        }
        damage[i+1] += damage[i];
    }

    cout << ans << endl;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> vec(200001,0);
    rep(i,n){
        int a;
        cin >> a;
        vec[a]++;
    }
    sort(vec.begin(),vec.end(),greater<int>());
    ll total=0;
    for(int i=0;i<k;i++){
        total+=vec[i];
    }
    if(total==n){
        cout << 0 << endl;
    }
    else{
        cout << n-total << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;



int main()
{
    ll N,X,T;
    cin >> N >> X >> T;
    ll tmp=N/X;
    if(N%X!=0) tmp++;
    cout << tmp * T << endl;



    return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){
    int n;
    cin>>n;
    long long  x[n];
    double  sum=0;
    rep(i,n){
        cin>>x[i];
        sum+=x[i];
    }
    sum/=n;
    sum=floor(sum+0.5);
    long long  ans=0;
    rep(i,n){
        ans+=(x[i]-sum)*(x[i]-sum);
    }
    cout<<ans<<endl;
    return 0;

}
/*


*/


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

int main(){
	int a[3];
	for(int i = 0; i < 3; i++){
	cin >> a[i];
}
	sort(a, a+3);
	cout << a[0] << " " << a[1] << " " << a[2] << endl;
	return 0;
}

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

signed main() {
  int N,T;
  cin >> N >> T;
  vector<int>vec(N);
  int ans = 0;
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  for(int i=0; i<N-1; i++){
    ans += min(T,vec[i+1]-vec[i]);
   }
   cout << ans+T << endl;
}

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


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

	ll t=1;
	// cin>>t;

	while(t--){
		ll x;
		cin>>x;
		cout<<(x^1)<<'\n';	
	}	

	return 0;
}	


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

using namespace std;

int n, x[2], y[105];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", y + i);
		if (y[i] == y[i - 1]) {
			swap(x[0], x[1]);
			x[1] = min(x[0], x[1]) + 1;
		} else {
			x[0] = min(x[0], x[1]);
			x[1] = x[0] + 1;
		}
	}
	printf("%d\n", min(x[0], x[1]));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ze(int a) {
  if (a < 0) return -a;
  return a;
}
int main () {
  int N;
  cin >> N;
  vector<int>A(N);
  for (int i = 0; i < N; i ++) cin >> A[i];
  int sum = 0;
  for (int i = 0; i < N; i ++) sum += A[i];
  int ko = sum / N;
  int ko_ = ko + 1;
  if (sum < 0) ko_ = ko - 1;
  if (ze(ko * N - sum) > ze(ko_ * N - sum)) ko = ko_;
  int ans = 0;
  for (int i = 0; i < N; i ++) {
    ans += (A[i] - ko) * (A[i] - ko);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
'use strict'
function main(inp) {
  let Nums:array = inp.trim().split('\n');
  const X:array = Nums[0].split(' ')[0]*1;
  const N:array = Nums[0].split(' ')[1]*1;
  let ans:number = 0;
  let min:number = 102;
  if (N == 0) {ans = X;}
  else {
    const Ps:array = Nums[1].split(' ').map(x=> x*1);
    for(let i = 0; i < 102; i++){
      if( Math.abs(X - i) < min && (Ps.indexOf(i) == -1)){
          ans = i;
          min = Math.abs(X - i);
      }
    }
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		
		String str = br.readLine();
		int n = Integer.parseInt(br.readLine());
		
		for(int i = 0; i < n; i++){
			String[] input = br.readLine().split(" ");
			int a = Integer.parseInt(input[1]);
			int b = Integer.parseInt(input[2]);
			
			if(input[0].equals("print")){
				System.out.println(str.substring(a, b+1));
			}
			else if(input[0].equals("reverse")){
				StringBuffer sb = new StringBuffer(str);
				sb.replace(a, b+1, new StringBuffer(str.substring(a, b + 1)).reverse().toString());
				
				str = sb.toString();
			}
			else if(input[0].equals("replace")){
				StringBuffer sb = new StringBuffer(str);
				sb.replace(a, b+1, input[3]);
				
				str = sb.toString();
			}
		}

//		System.out.println(count);

//
//			if(Character.isLowerCase(c)){
//				System.out.print(Character.toUpperCase(c));
//			}
//
//			else if(Character.isUpperCase(c)){
//				System.out.print(Character.toLowerCase(c));
//			}
//			else {
//				System.out.print(c);
//			}
//		}
//		System.out.println();

//		String[] tmpArray = br.readLine().split(" ");
//		int n = Integer.parseInt(tmpArray[0]);
//		int m = Integer.parseInt(tmpArray[1]);
//		int l = Integer.parseInt(tmpArray[2]);
//
//		long[][] a = new long[n][m];
//		long[][] b = new long[m][l];
//		long[][] c = new long[n][l];
//
//		for(int i = 0; i < n; i ++){
//			tmpArray = br.readLine().split(" ");
//			for(int j = 0; j < m; j++){
//				a[i][j] = Long.parseLong(tmpArray[j]);
//			}
//		}
//
//		for(int i = 0; i < m; i ++){
//			tmpArray = br.readLine().split(" ");
//			for(int j = 0; j < l; j++){
//				b[i][j] = Integer.parseInt(tmpArray[j]);
//			}
//		}
//
//		for(int i = 0; i < n; i++){
//			for(int j = 0; j < l; j++){
//				for(int k = 0; k < m; k++){
//					c[i][j] += a[i][k]*b[k][j];
//				}
//
//				if(j != 0 ){
//					System.out.print(" ");
//				}
//				System.out.print(c[i][j]);
//			}
//			System.out.println();
//		}


	}

}

Measured memory_bytes: 25108
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll h, w, K;
    cin >> h >> w >> K;
    K--;

    vvl dp(h+1, vl(w));  // dp[i+1][j] : i行目を通過した直後にj列目にいる場合の数(i,jは0-index)
    dp[0][0] = 1;
    rep(i, h) {
        rep(j, w) {
            rep(b, 1<<(w-1)) {  // kビット目が1のとき縦棒kと縦棒k+1を結ぶ

                vl v(w);  // v[k] : 縦棒kと縦棒k+1を結ぶとき1
                rep(k, w-1) {
                    if(b & (1<<k)) {
                        v[k] = 1;
                    }
                }

                ll flag = 0;  // 2つの横棒が端点を共有するとき1
                rep(k, w-2) {
                    if(v[k] && v[k+1]) {
                        flag = 1;
                    }
                }
                if(flag) {
                    continue;
                }

                if(j > 0 && v[j-1]) {  // 左から右に移動する場合
                    dp[i+1][j] += dp[i][j-1];
                }
                else if(j < w-1 && v[j]) {  // 右から左に移動する場合
                    dp[i+1][j] += dp[i][j+1];
                }
                else {  // 横に移動しない場合
                    dp[i+1][j] += dp[i][j];
                }
                
                dp[i+1][j] %= mod;
            }
        }
    }

    out(dp[h][K]);
    re0;
}

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

X = 0
j = A[0]
for i in A:
  X += B[i-1]
  if i == j+1:
    X+= C[j-1]
  j = i
print(X)


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  int a[300],b[300],i,k,u,H,W;
  for(i=0;i<300;i++){
    scanf("%d%d",&a[i],&b[i]);
    if(a[i]==0 && b[i]==0)break;
      }
  for(k=0;k<i;k++){
    for(H=1;H<=a[k];H++){
      if(H%2==1)for(W=1;W<=b[k];W++){
	  if(W%2==1)printf("#");
	  else printf(".");
	}
      if(H%2==0)for(W=1;W<=b[k];W++){
	  if(W%2==1)printf(".");
	  else printf("#");
	}
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x) \
  ll x;      \
  cin >> x;  \
  while (x--) 

void cpc()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main()
{
  cpc();
  int n,k,i,a,a1,j,ans=0;
  cin>>n>>k;
  vector<int> vec(n,0);
  for(i=0;i<k;i++){
    cin>>a;
    for(j=0;j<a;j++){
      cin>>a1;
      vec[a1-1]++;
    }
  }
  for(i=0;i<n;i++){
    if(vec[i]==0){
      ans++;
    }
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 3656
#include<stdio.h>

int main()
{
    long long int m,n,sum=0;
    scanf("%lld",&n);
    for(m=1;m<=n;m++)
    {
        if((m%3==0 && m%5==0)||(m%3==0)||(m%5==0))
        continue;
        else
         sum=sum+m;
    }
    printf("%lld\n",sum);
    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

void solve(long long A, long long B) {
  int ans = max(A + B, max(A - B, A * B));
  cout << ans << endl;
}

int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(A, B);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int n;
  int k, p;

  std::cin >> n;

  for (int i = 0; i < n; ++i) {
    std::cin >> k >> p;

    if (k % p == 0) {
      std::cout << p << std::endl;
    } else {
      std::cout << k % p << std::endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3088
import collections

N = int(input())
A = [int(x) for x in input().split()]
Q = int(input())
B = [0] * Q
C = [0] * Q
for i in range(Q):
  B[i], C[i] = [int(x) for x in input().split()]

count = collections.defaultdict(lambda: 0)
current = 0
for a in A:
  count[a] += 1
  current += a

for b, c in zip(B,C):
  current += (c - b) * count[b]
  print(current)
  count[c] += count[b]
  del count[b]


Measured memory_bytes: 30108
#!python3

from time import perf_counter

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from random import randrange
from bisect import bisect

def resolve():
    it = map(int, sys.stdin.read().split())
    D = next(it)
    C = [next(it) for i in range(26)]
    S = [[next(it) for i in range(26)] for i in range(D)]
    L = [[-1] for i in range(26)]
    T = [0] * D

    def update(di, qi):
        T1, L1 = T[:], L[:]

        score = 0
        t0 = T[di]
        score += S[di][qi]-S[di][t0]
        T1[di] = qi

        L1[t0] = li = L[t0][:]
        ii = li.index(di)
        la = D if len(li)-1 == ii else li[ii+1]
        score -= C[t0] * (di-li[ii-1])*(la-di)
        li.pop(ii)

        L1[qi] = li = L[qi][:]
        ii = bisect(li, di)
        li.insert(ii, di)
        la = D if len(li)-1 == ii else li[ii+1]
        score += C[qi] * (di-li[ii-1])*(la-di)

        return score, T1, L1

    score = 0
    x = (1+D)*D//2
    for i in range(D):
        score += S[i][0]
        L[0].append(i)

    for i in range(1, 26):
        score -= C[i] * x

    i = 0
    while perf_counter() < 1.0:
        diff, T1, L1 = update(randrange(0, D),  i % 26)
        if diff > 0:
            score += diff
            T, L = T1, L1
        i += 1

    while perf_counter() < 1.9:
        diff, T1, L1 = update(randrange(0, D), randrange(0, 26))
        if diff > 0:
            score += diff
            T, L = T1, L1

    print(*(i+1 for i in T), sep="\n")

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 78240
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int a[n],b[n],c[n-1];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<n-1;i++)cin>>c[i];
    int x=-1,sum=0;
    for(int i=0;i<n;i++)
    {
        if(x==a[i]-1)
            sum+=c[x-1];

        x=a[i];
        sum+=b[a[i]-1];
    }
    cout<<sum;
    return 0;
}


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

int main(int argc, char const *argv[])
{
	int r, d, x; cin >> r >> d >> x;
	for (int i = 0; i < 10; ++i) {
		x = r * x - d;
		cout << x << endl;
	}
	return 0;
}


Measured memory_bytes: 256
defmodule Main do
  def main do
    IO.gets("")
    |> String.trim()
    |> String.to_integer()
    |> get_mod()
    |> IO.puts()
  end
 
  def get_mod(m) do
    d=rem(m,1000)
    d==0&&0||1000-d
  end
end


Measured memory_bytes: 30844
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    ll N;cin>>N;
    ll m[110000];
    REP(i,110000)m[i]=0;
    ll ans=0;
    REP(i,N){
        ll a;cin>>a;
        m[a]++;
        ans+=a;
    }
    ll Q;cin>>Q;
    REP(i,Q){
        ll b,c;cin>>b>>c;
        ans-=b*m[b];ans+=c*m[b];
        ll tmp=m[b];
        m[b]=0;
        m[c]+=tmp;
        cout<<ans<<"\n";
    }
}

Measured memory_bytes: 4472
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <inttypes.h>

int main(void){
	char w[100]={0};
	int ans[26]={0};
	int i;
	int j;
	char temp;

	scanf("%s",w);
	for(i=0;i<100;i++){
		temp=w[i];
		ans[temp-97]++;
	}
	for(j=0;j<26;j++){
		if(ans[j]%2==1){
			printf("No");
			return 0;
		}
	}
	printf("Yes");

	return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int k = sc.nextInt();

			int[] f = new int[n];

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

			Arrays.sort(f);
			
			int ans = 0;

			for (int i = 0; i < k; i++) {
				ans += f[i];
			}

			System.out.println(ans);

		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}


Measured memory_bytes: 38716
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"sort"
)

func euclidean(a, b int) int {
	x, y := a, b
	if x < y {
		x, y = y, x
	}
	if y == 0 {
		return x
	}
	return euclidean(y, x%y)
}

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}

	l, r := make([]int, n+1), make([]int, n+1)
	l[0], r[n] = 0, 0
	for i := 0; i < n; i++ {
		l[i+1] = euclidean(l[i], a[i])
	}
	for i := n; i > 0; i-- {
		r[i-1] = euclidean(r[i], a[i-1])
	}

	gcd := make([]int, n)
	for i := 0; i < n; i++ {
		gcd[i] = euclidean(l[i], r[i+1])
	}

	sort.Ints(gcd)
	fmt.Println(gcd[n-1])
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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 INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k,c;cin >> n >> k >> c;
    string s;cin >> s;
    if(c==0){
        int cnt=0;
        for(int i=0;i<n;i++){
            if(s[i]=='o'){
                cnt++;
            }
        }
        if(cnt!=k){
            cout << endl;
        }
        else{
            for(int i=0;i<n;i++){
                if(s[i]=='o'){
                    cout << i+1 << endl;
                }
            }
        }
        return 0;
    }
    vector<int> sum(n+1),sr(n+1);
    for(int i=0;i<n;i++){
        if(s[i]=='o'){
            if(i<c){
                sum[i+1]++;
            }
            else{
                sum[i+1]=sum[i-c]+1;
            }
        }
        else{
            sum[i+1]=sum[i];
        }
    }
    for(int i=n;i>0;i--){
        if(s[i-1]=='o'){
            if(i+c<n){
                sr[i-1]=sr[i+c]+1;
            }
            else{
                sr[i-1]++;
            }
        }
        else{
            sr[i-1]=sr[i];
        }
    }
    vector<int> imos(n+1);
    for(int i=-c+1;i<n;i++){
        if(sum[max(0,i)]+sr[min(n,i+c)]>=k){
            imos[max(0,i)]++;
            imos[min(n,i+c)]--;
        }
    }
    int t=0;
    for(int i=0;i<n;i++){
        t+=imos[i];
        if(t==0&&s[i]=='o'){
            cout << i+1 << endl;;
        }
    }
}

Measured memory_bytes: 2964
#include <iostream>

using namespace std;

int main()
{
    string n;
    int sum;
    cin >> n;
    for (char c : n) {
        sum += int(c) - 48;
    }
    if (sum % 9 == 0) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}

Measured memory_bytes: 3692
const main = (txt: any): void => {
  const input = txt.split('\n')
  input.pop()
  for (const i in input) {
    if (parseInt(i) > 0) {
      console.log(input[i])
      console.log(input[i])
    }
  }
}



main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 11180
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A = input()
N = len(A)

ans = N*(N-1)//2

for v in Counter(A).values():
	ans -= v*(v-1)//2

print(ans+1)

Measured memory_bytes: 10276
n,q = map(int,input().split())
s = str(input())

t = [0]
for i in range(n-1):
        if s[i:i+2] == "AC":
                t.append(t[-1]+1)
        else:
                t.append(t[-1])

for i in range(q):
        l,r = map(int,input().split())
        print(t[r-1]-t[l-1])

Measured memory_bytes: 6100
#include<iostream>
    #include<math.h>
    #include<iomanip>
    #include<vector>
    using namespace std;
    #define PI 3.14159265358979

    int main(void)
    {

    int N;
    int a;
    string s; 
    cin>>s;
    if(s=="Sunny") cout<<"Cloudy"<<endl;

    if(s=="Cloudy") cout<<"Rainy"<<endl;

    if(s=="Rainy")cout<<"Sunny"<<endl;


    }



Measured memory_bytes: 256