akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
using namespace std;

int sumDigit(int a) {
	if (a < 10) return a;
	return a % 10 + sumDigit(a /10);
}

int main(void) {
	int N;
	cin >> N;
	int S = sumDigit(N);

	if (N % S == 0) {
		cout << "Yes" << "\n";
	} else {
		cout << "No" << "\n";
	}

}




Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, L: int, A: "List[int]", B: "List[int]", C: "List[int]", Q: int, s: "List[int]", t: "List[int]"):
    import numpy as np    
    from scipy.sparse import coo_matrix    
    from scipy.sparse.csgraph import floyd_warshall
    from itertools import filterfalse
    # coo_matrix((data, (i, j)), [shape=(M, N)])
    mat = floyd_warshall(coo_matrix((C, (A, B)), shape=(N+1, N+1), dtype=np.int32).tocsr(), directed=False)
    mat = floyd_warshall(mat <= L, directed=False)
    for ss, tt in zip(s, t):
        yield -1 if np.isinf(mat[ss][tt]) else int(mat[ss][tt]) - 1


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    L = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    C = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    Q = int(next(tokens))  # type: int
    s = [int()] * (Q)  # type: "List[int]"
    t = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        s[i] = int(next(tokens))
        t[i] = int(next(tokens))
    print(*solve(N, M, L, A, B, C, Q, s, t), sep="\n")

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

int main() {

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

    if ( a > c ) cout << "NO";
    else if ( a == c ) cout << "YES";
    else if ( a < c && a + b >= c ) cout << "YES";
    else cout << "NO";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(void){
    double x1, x2, y1, y2, dis;
    scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
    dis = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
    printf("%f\n", dis);
    return 0;
}

Measured memory_bytes: 3200
from math import gcd
flag=0
N=int(input())
A=list(map(int,input().split()))
Max=max(A)
a=[0]*(Max+1)
for i in A:
    a[i]+=1
for i in range(2,Max+1):
    if sum(a[i::i])>=2:
        flag=1
        break
if flag==0:
    print('pairwise coprime')
else:
    r=A[0]
    for i in A:
        r=gcd(r,i)
    if r==1:
        print('setwise coprime')
    else:
        print("not coprime")

Measured memory_bytes: 132568
n,k=map(int,input().split())
a=list(map(int,input().split()))
scores0=[0]*50
scores1=[0]*50
for i in range(n):
  s='{0:b}'.format(a[i])
  s2=[]
  for j in range(len(s)):
    s2.append(s[j])
  s2.reverse()
  for j in range(50-len(s)):
    s2.append('0')
  for j in range(50):
    if s2[j]=='0':
      scores0[j]+=1
    else:
      scores1[j]+=1
k2=[]
k='{0:b}'.format(k)
for j in range(len(k)):
  k2.append(k[j])
k2.reverse()
for j in range(50-len(k)):
  k2.append('0')
maxscore=0
for start in range(-1,50):
  if start>=0 and k2[start]=='0':
    continue
  score=0
  for j in range(49,start,-1):
    if k2[j]=='1':
      score+=scores0[j]*pow(2,j)
    else:
      score+=scores1[j]*pow(2,j)
  if start==-1:
    maxscore=max(maxscore,score)
    continue
  score+=scores1[start]*pow(2,start)
  for j in range(start-1,-1,-1):
    score+=max(scores0[j],scores1[j])*pow(2,j)
  maxscore=max(maxscore,score)
print(maxscore)
  

Measured memory_bytes: 84228
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <deque>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)

#define rdi(i) ll i; scanf("%lld", &i)
#define rds(s) string s; cin >> s
#define rdc(c) char c; cin >> c

#define INF 10000000000
#define MOD 1000000007

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

ll mod_pow(ll a, ll b)
{
    if (b == 0) {
        return 1;
    } else if (b == 1) {
        return a % MOD;
    } else if (b % 2 == 0) {
        ll work = mod_pow(a, b / 2);
        return (work * work) % MOD;
    } else {
        ll work = mod_pow(a, b - 1);
        return (a * work) % MOD;
    }
}

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> work(k + 1);
    rrepp(i, 1, k) {
        work[i] = mod_pow(k / i, n);
    }
    vector<ll> count(work);
    for (ll i = k; i >= 1; --i) {
        for (ll j = i * 2; j <= k; j += i) {
            count[i] = (count[i] - count[j] + MOD) % MOD;
        }
    }
    ll s = 0;
    rrepp(i, 1, k) {
        s = (s + count[i] * i) % MOD;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 4352
#include<iostream>
#include<fstream>
#include<algorithm>
using namespace std;
long long n,x,y,h;
int main()
{
     cin>>n;
     for(int i=1;i<=n;i++)
     {
     	cin>>x>>y;
     	h+=y-x+1;
     }
     cout<<h<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
static const int MAX = 100;

class Stack{
public:
  int elem[MAX];
  int pt=0;
  void push(int n);
  int pop();
  bool isEmpty();
  bool isFull();
}stack;

void Stack::push(int n){
  elem[pt] = n;
  pt++;
}

int Stack::pop(){
  pt--;
  return elem[pt];
}

bool Stack::isEmpty(){
  if(pt == 0) return true;
  else return false;
}

bool Stack::isFull(){
  if(pt == MAX) return true;
  else return false;
}

int main(){
  char s[10];
  int a, b;
  while(scanf("%s", s) != EOF){
    if(s[0] == '+'){
      b = stack.pop();
      a = stack.pop();
      stack.push(a+b);
    }else if(s[0] == '-'){
      b = stack.pop();
      a = stack.pop();
      stack.push(a-b);
    }else if(s[0] == '*'){
      b = stack.pop();
      a = stack.pop();
      stack.push(a*b);
    }else{
      stack.push(atoi(s));
    }
  }

  cout << stack.pop() << endl;
  return 0;
}



Measured memory_bytes: 3260
#include <iostream>
#include <string>
#include <bits/stdc++.h>
#include <stdlib.h>

using namespace std;

long long memo[102][100002] = {-1};

long long compute(int n, int w, int item, int total, int weight[], long long value[]){
    if(item >= n){
        return 0;
    }
    if(memo[item][total] != -1){
        return memo[item][total];
    }
    if(weight[item] + total > w){
        long long answer = compute(n, w, item + 1, total, weight, value);
        memo[item][total] = answer;
        return answer;
    }
    long long answer = max(compute(n, w, item + 1, total, weight, value), compute(n, w, item + 1, total + weight[item], weight, value) + value[item]);
    memo[item][total] = answer;
    return answer;
}

int main(){
    int n;
    int w;
    cin >> n >> w;
    int weight[n] = {0};
    long long value[n] = {0};
    for(int i = 0; i < n; i++){
        cin >> weight[i] >> value[i];
        for(int j = 0; j <= w; j++){
            memo[i][j] = -1;
        }
    }
    cout << compute(n, w, 0, 0, weight, value) << endl;
    return 0;
}

Measured memory_bytes: 78336
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int A[][] = new int[3][3];
		boolean c[][] = new boolean[3][3];
		for(int i=0; i<3; i++) {
			for(int j=0; j<3; j++) {
				A[i][j]=sc.nextInt();
			}
		}
		int n = sc.nextInt();
		for(int i=0; i<n; i++) {
			int b = sc.nextInt();
			for(int j=0; j<3; j++) {
				for(int k=0; k<3; k++) {
					if(A[j][k]==b) {
						c[j][k]=true;
					}
				}
			}
		}
		boolean ans = false;
		for(int i=0; i<3; i++) {
			if(c[i][0] && c[i][1] && c[i][2]) {
				ans = true;
			}
		}
		for(int i=0; i<3; i++) {
			if(c[0][i] && c[1][i] && c[2][i]) {
				ans = true;
			}
		}
		if(c[0][0] && c[1][1] && c[2][2]) {
			ans = true;
		}
		if(c[0][2] && c[1][1] && c[2][0]) {
			ans = true;
		}
		if(ans) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}
}


Measured memory_bytes: 23252
is_prime = [1] * 200000
primes = []
for i in range(2,200000):
    if is_prime [i] == False:
        continue
    primes.append(i)
    for j in range(i * 2,200000,i):
        is_prime [j] = False

while True:
    N = int(input())
    if N == 0:
        break
    print(sum(primes [:N]))

Measured memory_bytes: 9880
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
	using namespace std;

	int main() {
		int A, B;
		cin >> A >> B;

		cout << 6 - A - B << endl;
	}
		



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
INF = 10**10
 
def dfs(edge, visited, n):
    if visited[n]:
        return
    visited[n] = True
    for to, _ in edge[n]:
        dfs(edge, visited, to)

def bellman_ford(edge, mask):
    dist = [INF] * n
    dist[0] = 0

    for _ in range(n):
        update = False
        for i, es in enumerate(edge):
            if not mask[i]:
                continue
            for to, cost in es:
                if not mask[to]:
                    continue
                if dist[i] != INF and dist[i] + cost < dist[to]:
                    dist[to] = dist[i] + cost
                    update = True
        if not update:
            return dist
    else:
        # Found minus loops
        return -INF

if __name__ == "__main__":
    n, m, p = [int(item) for item in input().split()]
    edge = [[] for _ in range(n)]
    redge = [[] for _ in range(n)]
    for i in range(m):
        a, b, c = [int(item) for item in input().split()]
        a -= 1; b -= 1; c -= p
        c *= -1
        edge[a].append((b, c))
        redge[b].append((a, c)) 
    
    visited = [False] * n
    dfs(edge, visited, 0)
    rvisited = [False] * n
    dfs(redge, rvisited, n-1)
    mask = [forward and backward for forward, backward in zip(visited, rvisited)]
    dist = bellman_ford(edge, mask)
    if dist == -INF:
        print(-1)
    else:
        print(max(0, -dist[n-1]))

Measured memory_bytes: 66136
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Therefore | diff Therefore.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Therefore.cpp && ./a.out

/*

 5/17/2020

 5:00-

 */

const int MAX_N=1e6+1;
LL A[MAX_N];
int N;

string solve() {
  int x=N%10;
  if(x==3) return "bon";
  if(x==0||x==1||x==6||x==8) return "pon";
  return "hon";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N;
  cout<<solve()<<endl;

  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long ans=0;
  int N,P;
  cin>>N>>P;
  int kisuu=0,guusuu=0;
  for(int i=0;i<N;i++){
    int a;cin>>a;
    if(a%2)
      kisuu++;
    else
      guusuu++;
  }
  if(P==1){
    if(kisuu==0)
      ;
    else{
      ans+=pow(2,guusuu)*pow(2,kisuu);
      ans/=2;
    }
  }else{
      ans+=pow(2,kisuu)*pow(2,guusuu);
      if(kisuu==0){
	;}else if(N!=1)
	ans/=2;
  }
  cout<<ans<<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;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	n %= k;
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
                    
                    
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> H;

    for(int i = 0; i < N;i++){
        int h;
        cin >> h;
        H.push_back(h);
    }

    sort(H.begin(), H.end());
    reverse(H.begin(), H.end());
    int64_t ans = 0;
    for(int i = K;i < H.size();i++){
        ans += H.at(i);
    }           
    
    cout << ans << endl;
}

Measured memory_bytes: 1400
#include<stdio.h>
int main()
{
    int x;
    scanf("%d",&x);
    if(x>=1800)
        printf("1");
    else if(x>=1600)
        printf("2");
    else if(x>=1400)
        printf("3");
    else if(x>=1200)
        printf("4");
    else if(x>=1000)
        printf("5");
    else if(x>=800)
        printf("6");
    else if(x>=600)
        printf("7");
    else
        printf("8");
    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    int a = A%B;
    for(int i=0;i<10000;i++){
        if((a*i)%B == C){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int x1,x2,x3,x4,x5;
    
        scanf("%d%d%d%d%d",&x1,&x2,&x3,&x4,&x5);
    
        if(x1==0)
            printf("1\n");
    else if(x2==0)
        printf("2\n");
    else if(x3==0)
        printf("3\n");
    else if(x4==0)
        printf("4\n");
    else
        printf("5\n");
    return 0;
}

Measured memory_bytes: 1644
def main():
    n = int(input())
    t, a = map(int, input().split())
    h = [int(s) for s in input().split()]
    y = [abs(t - 0.006 * x - a) for x in h]
    i = min(range(n), key=lambda j: y[j])
    print(i + 1)

main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,n,sum = 0;
    cin >> h >> n;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        sum += a;
    }
    sum >= h ? cout << "Yes" : cout << "No";
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i = 0;i < (n); ++i)
#define all(v) sort(v.begin(),v.end())
#define ALL(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int n;
    cin >> n;
    int a[2][n];
    vector<int> b;
    rep(i,2){
        rep(j,n){
            cin >> a[i][j];
        }
    }
    int d = 1;
    rep(i,n){
        int sum = 0;
        rep(j,d){
            sum += a[0][j];
        }
        for(int j=(d-1);j<n;j++){
            sum += a[1][j];
        }
        d++;
        b.pb(sum);
    }
    ALL(b);
    cout << b[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10 , MOD=1e9+7;
const ll INF=1e18+10;
ll a[N] , seg[4*N];
int dp[N][2] , n;
int add(int a , int b){
    return (a+b)%MOD;
}
void upd(int x , ll val , int s=0 , int e=n , int id=1){
    if(e<=x || x<s)
        return;
    if(e-s==1){
        seg[id] = val;
        return;
    }
    int mid = (s+e)/2;
    upd(x , val , s , mid , 2*id);
    upd(x , val , mid , e , 2*id+1);
    seg[id] = min(seg[2*id] , seg[2*id+1]);
}
ll get(int l , int r , int s=0 , int e=n , int id=1){
    if(r<=l)
        return INF;
    if(e<=l || r<=s)
        return INF;
    if(l<=s && e<=r)
        return seg[id];
    int mid=(s+e)/2;
    return min( get(l , r , s , mid , 2*id) , get(l , r , mid , e , 2*id+1) );
}

int main(){
    cin >> n;
    ll A , B;cin >> A >> B;A--;B--;
    for(int i=0 ; i<n ; i++)
        cin >> a[i];
    sort(a , a+n);
    for(int i=0 ; i<n ; i++)
        upd(i , (i<n-1 ? a[i+1]-a[i] : INF) );
    dp[0][0] = dp[0][1] = 1;
    for(int i=1 ; i<n ; i++){
        int ind = lower_bound(a , a+n , a[i]-A) - a;
        if(ind==i)
            dp[i][0] = add( dp[i-1][1] , dp[i-1][0] );
        if(ind<i && get(ind , i-1) > B)
            dp[i][0] = dp[ind][1];
        ind = lower_bound(a , a+n , a[i]-B) - a;
        if(ind==i)
            dp[i][1] = add( dp[i-1][0] , dp[i-1][1] );
        if(ind<i && get(ind , i-1) > A)
            dp[i][1] = dp[ind][0];
    }
    cout << add( dp[n-1][0] , dp[n-1][1] ) << "\n";
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

const int SIZE = 425252;

int n,m,s,gg;
map<pii,int> ids;
pii rev[SIZE];
inline int getid(const pii P){
  if(ids.count(P)==0){
    int id = ids.size();
    ids[P] = id;
    rev[id] = P;
  }
  return ids[P];
}
vi tms[125252];

vector<pii> g[SIZE];
int dist[SIZE];

int main(){
  scanf("%d%d%d%d",&n,&m,&s,&gg);
  --s;--gg;
  int start = getid(pii(s,0));
  tms[s].push_back(0);
  REP(i,m){
    int u,v,t,c;
    scanf("%d%d%d%d",&u,&v,&t,&c);
    --u;--v;
    tms[u].push_back(t);
    tms[v].push_back(t+c);
    g[getid(pii(u,t))].push_back(pii(getid(pii(v,t+c)),0));
  }
  REP(i,n){
    sort(ALL(tms[i]));
    tms[i].erase(unique(ALL(tms[i])),tms[i].end());
    REP(j,tms[i].size()-1){
      g[getid(pii(i,tms[i][j]))].push_back(pii(getid(pii(i,tms[i][j+1])),tms[i][j+1]-tms[i][j]));
    }
  }

  REP(i,ids.size())dist[i] = 1e9;

  int ans = 1e9;
  priority_queue<pll> Q;
  Q.push(pll(-0, start));
  dist[start] = 0;
  while(!Q.empty()){
    pll P = Q.top(); Q.pop();
    int p = P.second;
    ll d = dist[p];
    for(pii S : g[p]){
      int to = S.first;
      ll cost = S.second;
      ll nd = d + cost;
      if(dist[to] <= nd)continue;
      dist[to] = nd;
      if(rev[to].first==gg)CHMIN(ans,(int)nd);
      Q.push(pll(-nd, to));
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 60516
S = str(input())
S_iterator = reversed(S)
S_list = list(S_iterator)
s1 = ['m','a','e','r','d']
s2 = ['r','e','m','a','e','r','d']
s3 = ['e','s','a','r','e']
s4 = ['r','e','s','a','r','e']

i=0
while(i < len(S_list)):
    if(S_list[i:i+5]==s1):
        err = 0
        i = i+5
    elif(S_list[i:i+7]==s2):
        err = 0
        i = i+7
    elif(S_list[i:i+5]==s3):
        err = 0
        i = i+5
    elif(S_list[i:i+6]==s4):
        err = 0
        i = i+6
    else:
        err = 1
        break
    
if(err == 0):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>

using namespace std;

int main() {
  int r,d,x;
  cin >> r >> d >> x;
  
  for(int i = 0; i < 10; i++) {
    x = r*x-d;
    cout << x << endl;
  }
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			long result = 1;
			for (int i = 0; i < n; i++) {
				result = lcm(result, scanner.nextLong());
			}
			System.out.println(result);
		}
	}

	/**
	 * @param a
	 * @param b
	 * @return aとbの最大公約数
	 */
	private static long gcd(long a, long b) {
		long temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return b;
	}

	/**
	 * @param a
	 * @param b
	 * @return aとbの最小公倍数
	 */
	private static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}
}


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

int main()
{
	long long n, m; cin >> n >> m;
	
	if (m < n) swap(n, m);

	long long ans;

	if (n == 1 && m == 1) {
		ans = 1;
	}
	else if (n == 1) {
		ans = m - 2;
	}
	else {
		ans = (n - 2) * (m - 2);
	}

	cout << ans << endl;

	return 0;
}

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

const int MAXN = 200010;
const int MAXE = MAXN * 20;
const int INF = 0x3f3f3f3f;
int head[MAXN], nxt[MAXE], to[MAXE], val[MAXE], tot = 1;
void addedge(int b, int e, int v, int v2 = 0) {
	nxt[++tot] = head[b]; to[head[b] = tot] = e; val[tot] = v;
	nxt[++tot] = head[e]; to[head[e] = tot] = b; val[tot] = v2;
}
int dis[MAXN], S, T, idx;
std::queue<int> q;
bool bfs() {
	memset(dis, 0, idx + 1 << 2);
	q.push(S); dis[S] = 1;
	while (!q.empty()) {
		int t = q.front(); q.pop();
		for (int i = head[t]; i; i = nxt[i])
			if (val[i] && !dis[to[i]])
				dis[to[i]] = dis[t] + 1, q.push(to[i]);
	}
	return dis[T] > 0;
}
int dinic(int u, int minv) {
	if (u == T || !minv) return minv;
	int res = 0, t;
	for (int & i = head[u]; i; i = nxt[i])
		if (val[i] && dis[to[i]] == dis[u] + 1 && (t = dinic(to[i], std::min(minv, val[i])))) {
			val[i] -= t;
			val[i ^ 1] += t;
			res += t;
			minv -= t;
			if (!minv) break;
		}
	if (!res) dis[u] = -1;
	return res;
}
int maxflow() {
	int res = 0;
	static int th[MAXN];
	memcpy(th, head, idx + 1 << 2);
	while (bfs()) {
		res += dinic(S, INF);
		memcpy(head, th, idx + 1 << 2);
	}
	return res;
}
int n, P[MAXN], Q[MAXN];
int vis[MAXN];
struct EX {
	int a, b, c, d, e, f, g;
} ds[1 << 4];
int A[MAXN], B[MAXN];
int main() {
	for (int i = 0; i != (1 << 4); ++i) {
		static int g[4];
		g[0] = i & 1, g[1] = i >> 1 & 1;
		g[2] = i >> 2 & 1, g[3] = i >> 3 & 1;
		int t = g[0] + g[1] + g[2] + g[3];
		g[0] = t - g[0];
		g[1] = t - g[1];
		g[2] = t - g[2];
		g[3] = t - g[3];
		bool can = false;
		for (int a = 0; a <= g[0]; ++a) {
			int c = g[0] - a;
			for (int b = 0; b <= g[3]; ++b) {
				int d = g[3] - b;
				int e = g[2] - a - d;
				int f = g[1] - b - c;
				if (e >= 0 && f >= 0) {
					can = true;
					ds[i] = (EX) {a, b, c, d, e, f, t};
					break;
				}
			}
		}
		if (!can) ds[i].a = -1;
	}
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for (int i = 0; i < n; ++i) std::cin >> P[i];
	for (int i = 0; i < n; ++i) std::cin >> Q[i];
	S = 0, T = idx = 1;
	for (int i = 0; i < n; ++i) if (!vis[i]) {
		int now = i; ++idx;
		while (!vis[i] || now != i) {
			A[now] = idx;
			vis[now] = true, now = P[now];
		}
	}
	memset(vis, 0, n + 1 << 2);
	for (int i = 0; i < n; ++i) if (!vis[i]) {
		int now = i; ++idx;
		while (!vis[i] || now != i) {
			B[now] = idx;
			vis[now] = true, now = Q[now];
		}
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		static int f[4];
		f[0] = i != Q[i];
		f[1] = P[i] != Q[i];
		f[2] = i != i;
		f[3] = P[i] != i;
		EX t = ds[f[0] | f[1] << 1 | f[2] << 2 | f[3] << 3];
		if (t.a) addedge(S, A[i], t.a);
		if (t.b) addedge(A[i], T, t.b);
		if (t.c) addedge(S, B[i], t.c);
		if (t.d) addedge(B[i], T, t.d);
		if (t.e || t.f) addedge(B[i], A[i], t.e, t.f);
		ans += t.g;
	}
	ans -= maxflow();
	std::cout << ans << std::endl;
	return 0;
}


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

int main(void)
{
  int A,B,C,X;
  cin >> A >> B >> C >> X;
  int sum, count=0;
  
  for(int i=0; i <= A; i++)
  {
    for(int j=0; j<= B; j++)
    {
      for(int k=0;k<=C;k++)
      {
        sum = 500*i + 100*j + 50*k;
        if( X==sum) count++;
      }
    }
  }  
  cout << count;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int MOD = 1000000007;

//////検証する数,超えられない数////
long long cine(long long a, long long b) {
	if (a <= b) {
		return a;
	}
	else {
		return b;
	}
};
//vector型の初期化
void vec_initialize(vector<ll>& a, const ll N) {
	ll c;

	for (int i = 0; i < N; i++) {

		cin >> c;
		a.push_back(c);

	}

};
void vec_pair_initialize(vector<pair<ll, ll>>& a, const ll N) {
	ll c, d;
	for (int i = 0; i < N; i++) {
		cin >> c >> d;
		a.push_back(make_pair(c, d));
	}
};

int main() {
	ll N;
	cin >> N;
	vector<ll>a;
	a.push_back(0);
	ll c;
	for (int i = 0; i < N; i++) {
		cin >> c;
		a.push_back(c);
	}
	a.push_back(0);
	ll sum=0;
	for (int i = 0; i < N+1; i++) {
		sum += labs(a[i+1] - a[i]);
	}
	ll tmp;
	for (int i = 1; i < N+1; i++) {
		tmp = labs(a[i + 1] - a[i - 1]) - labs(a[i + 1] - a[i]) - labs(a[i] - a[i - 1]);
			cout << sum + tmp<<endl;
	}


}

Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(2e2 + 5);
const int V = (int)(1e5 + 5);
const int LOG = (int)(20);

lli n, wl;
lli dp[N][V], w[N], v[N];

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	for(int i = 0; i < N; i++)
		for(int j = 1; j < V; j++)
			dp[i][j] = 1e10;
	cin >> n >> wl;
	for(int i = 1; i <= n; i++)
		cin >> w[i] >> v[i];
	for(int i = 1; i <= n; i++)
		for(int j = 0; j < V; j++) {
			dp[i][j] = dp[i - 1][j];
			if(j - v[i] >= 0 && dp[i - 1][j - v[i]] + w[i] <= wl)
				dp[i][j] = min(dp[i - 1][j - v[i]] + w[i], dp[i][j]);
		}
	
	for(int i = V - 1; i > 0; i--) {
		if(dp[n][i] < 1e10) {
			cout << i;
			return 0;
		}
	}
}

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

#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
using ll = long long;

ll lcm(ll a,ll b){
	
	return (a*b)/(__gcd(a,b));
}

void solve() 
{ 

int n;
cin>>n;
vector<int> v(n);
rep(i,n){
	cin>>v[i];
}
int j=1;
int ans=0;
rep(i,n){
	if(v[i]==j){
		ans++;
		j++;
	}
}
if(ans==0){
	cout<<-1;
	return ;
}
cout<<n-ans;
}
 

int main(){


		solve();
		cout<<endl;
	
					
}
		

	

		

 



Measured memory_bytes: 3992
#include <iostream>
 
using namespace std;
 
int main() {
  int n, count = 0;
  cin >> n;
  for (int i = 0, num; i < n; i++) {
    cin >> num;
    count += (i + 1 != num);
  }
  cout << ((count == 0 || count == 2) ? "YES" : "NO");
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int s1, s2;
    int number[5];
    int max, max_num;
    int i;
    
    while (1){
        scanf("%d %d", &s1, &s2);
        if ((s1 == 0) && (s2 == 0)) break;
        number[0] = s1 + s2;
        max = number[0];
        max_num = 0;
        for (i = 1; i < 5; i++){
            scanf("%d %d", &s1, &s2);
            number[i] = s1 + s2;
            if (max < number[i]){
                max = number[i];
                max_num = i;
            }
        }
        switch (max_num){
            case 0:
                printf("A %d\n", max);
                break;
            case 1:
                printf("B %d\n", max);
                break;
            case 2:
                printf("C %d\n", max);
                break;
            case 3:
                printf("D %d\n", max);
                break;
            case 4:
                printf("E %d\n", max);
                break;
            default:
                break;
        }
    }
    
    return (0);
}

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

int main(){
    int N; cin >> N;
    double sum = 0;
    for (int i = 0; i < N; i++)
    {
        int a; cin >> a;
        sum += 1./ (double) a;
    }
    cout << 1./sum << endl;
    
}

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

int main()
{
	long long X;
	cin >> X;

	long long l=0, r=1e9;
	long long m;

	while (l < r) {
		long long m = (l + r) / 2;
		long long x = X;
		for (int i = m; i > 0;) {
			x -= i;
			if(x<i)i = x;
			else i--;
		}
		if (x <= 0) {
			r = m;
		}
		else l = m + 1;
	}

	cout << l << endl;

    return 0;
}

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

/*==========type============*/
typedef long long ll;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
typedef std::pair<std::string,ll> psl;

/*==========constant============*/
#define INF INT_MAX
#define INF_L LONG_MAX
#define INF_LL LLONG_MAX
#define MOD 1000000007

/*==========function============*/
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

using namespace std;

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

    ll n;
    cin >> n;
    
    string ans = n >= 30 ? "Yes" : "No";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
  string s,t;
  cin>>s>>t;
  reverse(s.begin(),s.end());
  if(s==t){cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}
  return 0;
}

Measured memory_bytes: 3612
n = int(input())
arr = []
for i in range(n):
    arr.append([i + 1] + list(input().split(" ")))
arr = [(a, b, -int(c)) for (a, b, c) in arr]
sarr = sorted(arr, key=lambda x: (x[1], x[2]))

for i, _, _ in sarr:
    print(i)


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

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

  int c = 0;
  for (int i=0; i<4; ++i) {
    for (int j=i+1; j<4; ++j) {
      if (S[i] == S[j]) ++c;
    }
  }

  if (c == 2) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	
	int n;
	char str[50];
	int chan1 = 0,chan2 = 0,chan3 = 0,chan4 = 0;
	scanf("%d" , &n);
	for(int i = 0 ; i < n ; i++){
		scanf("%s" , &str);
		if(str[0] == 'A'){
			chan1++;
		}
		else if(str[0] == 'W'){
			chan2++;
		}
		else if(str[0] == 'T'){
			chan3++;
		}
		else{
			chan4++;
		}
			
	}
	
	printf("AC x %d\n" , chan1);
	printf("WA x %d\n" , chan2);
	printf("TLE x %d\n" , chan3);
	printf("RE x %d\n" , chan4);
		
	return 0;
}

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

int main()
{
    int n, q;
    scanf("%d", &n);
    int s[n];
    for (int i = 0; i < n; i++){
        scanf("%d", &s[i]);
    }
    scanf("%d", &q);
    int t[q];
    int cnt = 0;
    for(int i = 0; i < q; i++){
        scanf("%d", &t[i]);

        for ( int j = 0; j < n; j++){
            if (s[j] == t[i]) {
                cnt++;
                break;
            }
        }

    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 2720
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        var n = long.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

        long ans = 0;
        for (int i = 0; i < n; i++)
        {
            ans += a[i] -1;
        }
        Console.WriteLine(ans);

    }

}


Measured memory_bytes: 13408
#include <cstdio>
#include <algorithm>
#include <cctype>
#include <cmath>
using namespace std;
typedef long long int64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
int64 a, b, c, d, e;
int64 ans;
int main()
{
    a = read(), ans = read(), c = read(), d = read(), e = read();
    if(!a||!d||!e) ans += a/2*2+d/2*2+e/2*2;
    else ans += a+d+e-(a%2 != d%2||a%2 != e%2);
    printf("%lld\n", ans);
    return 0;
}

/* 
1 1 1 3
2 1 1
2 0 0 2
0 2 0 2
0 0 2 2
*/

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int v[200005];
int main(){
    int n,k,x;
    long long resp=0LL;

    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    sort(v,v+n);
    for(int i=0;i<n-k;i++){
        resp+=v[i];

    }


    cout<<resp;
}

Measured memory_bytes: 1024
#include<iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    int tmp, sum, tsum=0, ans=0;
    for(int i=1; i<=N; i++){
        tmp=i;
        sum=0;
        while(tmp%2==0){
            tmp=tmp/2;
            sum++;
        }
        //cout << i << sum << endl;
        if(tsum<=sum){
            tsum=sum;
            ans=i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

struct Card {char suit, value; };

void bubble(struct Card A[], int N)
{
  for(int i=0;i<N;i++)
  {
    for(int j=N-1;j>i;j--)
    {
      if(A[j].value < A[j-1].value)
      {
        Card c = A[j];
        A[j] = A[j-1];
        A[j-1] = c;
      }
    }
  }
}

void selection(struct Card A[], int N)
{
  bool frag = 1;
  for(int i=0;i<N;i++)
  {
    int minj = i;
    for(int j=i;j<N;j++)
    {
      if(A[j].value < A[minj].value)
      {
        minj = j;
      }
    }
    Card c = A[i];
    A[i] = A[minj];
    A[minj] = c;
  }
}

void print(struct Card A[], int N)
{
  for(int i=0;i<N;i++)
  {
    if(i>0) printf(" ");
    printf("%c%c",A[i].suit,A[i].value);
  }
  printf("\n");
}

bool isStable(struct Card C1[], struct Card C2[], int N)
{
  for(int i=0;i<N;i++)
  {
    if(C1[i].suit != C2[i].suit) return false;
  }
  return true;
}

int main()
{
  Card C1[100], C2[100];
  int N;

  cin >> N;
  for(int i=0;i<N;i++)
  {
    cin >> C1[i].suit >> C1[i].value;
  }
  for(int i=0;i<N;i++)
  {
    C2[i] = C1[i];
  }
  bubble(C1,N);

  selection(C2,N);
  

  print(C1,N);
  cout << "Stable" << endl;
  print(C2,N);
  if(isStable(C1,C2,N)) cout << "Stable" << endl;
  else cout << "Not stable" << endl;
  return 0;
}



Measured memory_bytes: 3188
A = int(input())
B=int(input())
C =int(input())
X = int(input())

ans = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k == X:
                ans +=1

print(ans)


Measured memory_bytes: 66812
#include <bits/stdc++.h>
using namespace std;
int n,W,w[110],v[110];
long long dp[110][100010];
int main(){
    cin>>n>>W;
    for (int i=1;i<=n;i++)
        cin>>w[i]>>v[i];
    for (int i=1;i<=W;i++)
        dp[0][i]=0;
    for (int i=1;i<=n;i++)
        for (int j=1;j<=W;j++)
        {
            if (w[i]<=j)
            {
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
            }
            else dp[i][j]=dp[i-1][j];
        }
    long long res=0;
    for (int i=1;i<=W;i++)
        res=max(res,dp[n][i]);
    cout<<res;
}


Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,i,h,sum=0;
    cin>>t;
    for(i=0;i<t;i++){
        cin>>h;
        sum=sum^h;
    }
    if(sum==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
ll x,y,a,b,c;
const int maxn=1e5+5;
ll p[maxn];
ll q[maxn];
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    cin>>x>>y>>a>>b>>c;
	vector<ll> r;
	repA(i,1,a) cin>>p[i];
	repA(i,1,b) cin>>q[i];
	repA(i,1,c)
	{
		ll val;
		cin>>val;
		r.pb(val);
	}
	sort(p+1,p+a+1);
	sort(q+1,q+b+1);
	sortA(r);
	ll total=x+y;
	ll idx=a;
	while(x)
	{
		r.pb(p[idx]);
		idx--;
		x--;
	}
	idx=b;
	while(y)
	{
		r.pb(q[idx]);
		idx--;
		y--;
	}
	sortA(r);
	ll ans=0;
	reverse(r.begin(),r.end());
	rep(i,total)
	{
		//watch(r[i]);
		ans+=r[i];
	}	
	cout<<ans<<'\n';
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 8912
<?php
fscanf(STDIN, "%d %d", $n, $t);
$x = 1001;
while ($n--) {
	fscanf(STDIN, "%d %d", $c, $v);
	if ($v <= $t && $c < $x) {
		$x = $c;
	}
}
echo $x < 1001 ? $x : 'TLE';

Measured memory_bytes: 4604
// Aizu 2305: Beautiful Currency
// 2017.10.30 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <math.h>

#define MAX 150000
int a[22];
double dp[22][MAX+2];

int main()
{
	int n, i, j, k;
	double ans;

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", a+i);

	memset(dp, 0x77, sizeof(dp));
	for (j = 1; j < MAX; j++) dp[0][j] = fabs((double)(a[0] - j))/a[0];

    for (i = 0; i < n; i++) for (j = 1; j < MAX; j++) {
		for (k = j; k < MAX; k += j) {
			double x = fabs((double)(a[i] - k))/a[i];
			if (dp[i][j] > x) x = dp[i][j];
			if (x < dp[i+1][k]) dp[i+1][k] = x;
		}
	}

	ans = 1.0;
	for (j = 1; j < MAX; j++) if (dp[n][j] < ans) ans = dp[n][j]; 
	printf("%.12lf\n", ans);
	return 0;
}

Measured memory_bytes: 27580
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<char>S(N);
  for(int i=0;i<N;i++){
    cin>>S.at(i);
  }
  int x=N;
 
    for(int i=1;i<N;i++){
      if(S.at(i)==S.at(i-1)){
        x--;
      }
    }
  cout<<x<<endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		char[] chars = sc.next().toCharArray();
		int borderNum = 0;
		for(int i = 0; i < n - 1; i++){
			if(chars[i] != chars[i + 1]){
				borderNum += 1;
			}
		}
		int ans = Math.min(n - 1, n - 1 - borderNum + k * 2);
		System.out.println(ans);
	}
}


Measured memory_bytes: 26296
function main()
    # zi=xi+yi,wi=zi-yiとすると
    # |xi−xj|+|yi−yj|
    # =max(xi−xj,xj−xi)+max(yi−yj,yj−yi)
    # =max((xi−xj)+(yi−yj),(xi−xj)+(yj−yi),(xj−xi)+(yi−yj),(xj−xi)+(yj−yi))
    # =max(xi+yi−(xj+yj),xi−yi−(xj−yj),−(xi−yi)+(xj−yj),−(xi+yi)+xj+yj)
    # =max(|xi+yi−(xj+yj)|,|xi−yi−(xj−yj)|)
    # =max(|zi-zj|,|wi-wj|)
    # つまり答えは
    # max(|xi−xj|+|yi−yj|)
    # =max(max(|zi-zj|,|wi-wj|))
    # =max(max(|zi-zj|),max(|wi-wj|))
    # =max(max(zi)-min(zi),max(wi)-min(wi))
    n=myread(Int)
    zmax,zmin,wmax,wmin=-1<<40,1<<40,-1<<40,1<<40
    for i=1:n
        x,y=myreads(Int)
        zmax,zmin,wmax,wmin=max(zmax,x+y),min(zmin,x+y),max(wmax,x-y),min(wmin,x-y)
    end
    println(max(zmax-zmin,wmax-wmin))
end

# ----------input function----------
sread()=chomp(readline())
sreads(sp=" ")=split(readline(),sp)
myread(ty)=parse(ty,readline())
myreads(ty)=map(x->parse(ty,x),split(readline()))
main()

Measured memory_bytes: 206172
#include<bits/stdc++.h>
namespace FastIO{const char* ln="\n";struct Reader{char buf[1<<20],*s,*t;bool EOF_FLG;Reader():s(buf),t(buf),EOF_FLG(false) {};char gt() {return s==t&&((t=(s=buf)+fread(buf,1,1<<20,stdin))==s)?EOF:(*s++);}Reader& operator>>(char* str) {if(EOF_FLG)return *str=0,*this;while((*str=gt())!=' '&&*str!='\n'&&*str!=EOF)++str;if(*str==EOF)EOF_FLG=true;*str=0;return *this;}template<typename T>Reader&operator>>(T&x) {if(EOF_FLG)return *this;char c=0,d;while(c!=EOF&&(c<'0'||c>'9'))d=c,c=gt();if(c==EOF){EOF_FLG=true;return *this;}else x=0;while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=gt();if(d=='-')x=-x;return *this;}}in;struct Writer{char buf[1<<20],*s,*t;Writer():s(buf),t(buf+(1<<20)){}~Writer(){fwrite(buf,1,s-buf,stdout);}void pt(char c){(s==t)?(fwrite(s=buf,1,1<<20,stdout),*s++=c):(*s++=c);}template<typename T>Writer&operator<<(T x){if(!x)return pt('0'),*this;if(x<0)pt('-'),x=-x;char a[40],t=0;while(x)a[t++]=x%10,x/=10;while(t--)pt(a[t]+'0');return *this;}Writer&operator<<(const char*s) {while(*s)pt(*s++);return *this;}}out;}using namespace FastIO;
namespace ZDY{
    #define ll long long
    #define db double
    #define sht short
    #define MB template <class T>
    #define Fur(i,x,y) for(int i=x;i<=y;i++)
    #define fur(i,x,y) for(i=x;i<=y;i++)
    #define Fdr(i,x,y) for(int i=x;i>=y;i--)
    #define fdr(i,x,y) for(i=x;i>=y;i--)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define inf 0x3f3f3f3f
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdout)
    #define l2(n) (int(log2(n)))
    #define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define fcin ios::sync_with_stdio(false)
    MB T ABS(T x){return x>0?x:-x;}
    MB T MAX(T x,T y){return x>=y?x:y;}
    MB T MIN(T x,T y){return x<=y?x:y;}
    MB T GCD(T x,T y){return y?GCD(y,x%y):x;}
    void SWAP(int &x,int &y){x^=y;y^=x;x^=y;}
}using namespace ZDY;using namespace std;
#define N 1000001
int main(){
    int x,y,z;
    in>>x>>y>>z;
    if(x>2019||(x==2019&&(y>4||(y==4&&z>30))))printf("TBD");
    else printf("Heisei");
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>

//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define what_is(x) cout<<#x<<" is "<<x<<en;

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

void solve()
{
	string kek;
	cin >> kek;
	bool rev = false;
	int q;
	cin >> q;
	deque<char> s;
	for (auto to : kek)
		s.pb(to);

	while (q--)
	{
		int type;
		cin >> type;
		if (type == 1)
		{
			rev = !rev;
		}
		else
		{
			int f;
			char c;
			cin >> f;
			cin >> c;
			if (f == 1)
				if (!rev)
					s.push_front(c);
				else
					s.pb(c);
			else
				if (!rev)
					s.pb(c);
				else
				s.push_front(c);
		}

	}

	if (rev)
		reverse(all(s));

	for (auto to : s)
		cout << to;

}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();

}

Measured memory_bytes: 960
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	string s; cin >> s; 
	if( s == "ABC" ) cout << "ARC" << endl;
	else cout << "ABC" << endl;
}

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

using namespace std;

int main() {
	int a,b,c;
	int aa,bb,cc;
	int A=0,B=0,C=0,D=0;
	
	cin >> a >> b >> c;
	int a1=0,a2=0,a3=0,a4=0;
	for(int i=0;i<c;i++){
		cin >> aa >> bb >> cc;
		if(cc==1){
			if(aa>a1){
				A=aa;
				a1=aa;
			}
			
		}else if(cc==2){
			if(a-aa>a2){
				B=a-aa;
				a2=a-aa;
			}
		}else if(cc==3){
			if(bb>a3){
				C=bb;
				a3=bb;
			}
		}else if(cc==4){
			if(b-bb>a4){
				D=b-bb;
				a4=b-bb;
			}
		}
	}
	int AA,BB;
	AA=a-A-B;
	BB=b-C-D;
	if(AA<0) AA=0;
	if(BB<0) BB=0;
	cout << AA*BB << endl;
	
	
	return 0;
}

Measured memory_bytes: 256