akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void main(String[] args) {		
        Scanner scan = new Scanner(System.in);
        String str1 = scan.next();
        String str2 = scan.next();
		float a =Float.parseFloat(str1);
		float b =Float.parseFloat(str2);
		float c ;
		c = a/b;
		System.out.println(c);
    }
}


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

int main(){
  int N;
  cin >> N;
  vector<int> B(N-1);
  vector<int> A(N);
  int ans=0;
  for(int i=0; i<N-1; i++){
    cin >> B.at(i);
  }
  A.at(0)=B.at(0);
  for(int i=1; i<N-1; i++){
    A.at(i)=min(B.at(i-1), B.at(i));
  }
  A.at(N-1)=B.at(N-2);
  for(int i=0; i<N; i++) ans+=A.at(i);
  cout << ans << endl;
}


Measured memory_bytes: 256
result = 0
N = int(input())
array=[int(x) for x in input().split()]
array = list(array)
# print(array)

while(len(array)!=1):
    array.sort()
    newNum = array[0]+array[1]
    del array[0]
    del array[0]
    array.append(newNum/2)

print(array[0])

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

typedef long long ll;
const int _ = 4e3 + 10;
const ll mod = 924844033;
int tot, N, K, edge[_];
ll f[_][_][2], fac[_], ans = 0;

int main() {
	scanf("%d%d", &N, &K);
	fac[0] = 1;
	for (int i = 1; i <= N; ++i) fac[i] = fac[i - 1] * i % mod;
	for (int i = 1; i <= K; ++i)
		for (int t = 1; t <= 2; ++t)
			for (int j = i; j <= N; j += K) {
				++tot;
				if (j != i) edge[tot] = 1;
			}
	f[0][0][0] = 1;
	for (int i = 1; i <= N * 2; ++i) {
		for (int j = 0; j <= i / 2; ++j) {
			f[i][j][0] = (f[i][j][0] + f[i - 1][j][0] + f[i - 1][j][1]) % mod;
			if (edge[i] && j > 0) f[i][j][1] = (f[i][j][1] + f[i - 1][j - 1][0]) % mod;
		}
	}
	ll p = 1;
	for (int i = 0; i <= N; ++i) {
		ans = (ans + p * (f[N * 2][i][0] + f[N * 2][i][1]) % mod * fac[N - i] % mod + mod) % mod;
		p *= -1;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 248704
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  int q = in();
  multiset<int> s;
  rep(_,q){
    int kind = in();
    if(kind==0){
      int add = in();
      s.emplace(add);
      cout << s.size() << endl;
    }else if(kind==1){
      int x = in();
      cout << s.count(x) << endl;
    }else if(kind==2){
      int x = in();
      s.erase(x);
    }else{
      int x = in();
      int y = in();
      auto from = s.lower_bound(x);
      auto end = s.upper_bound(y);
      while(from!=end){
        cout << *from << endl;
        ++from;
      }
    }
  }
}



Measured memory_bytes: 12340
#include <iostream>
#include <algorithm>
#include <vector>
 
#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
 
template <class T> T& chmin(T& a, T b){return (a > b) ? a = b : a;}
template <class T> T& chmax(T& a, T b){return (a < b) ? a = b : a;}
 
using lli = long long int;
 
std::string s;
std::vector<int> A, K;

void make_it(int n){
    K.resize(0);
    int i = 0;
    while(i < n){
        int cnt = 1;
        char c = s[i];
        while(i + 1 < n and s[i + 1] == c){i++; cnt++;}
        K.push_back(cnt); i++;
    }
}

int main(void){
    std::cin >> s; const int n = s.size(); A.resize(n, 0);
    make_it(n);
    const int m = K.size();
    int p = -1;
    for(int i = 0; i < m; i++){
        p += K[i];
        int even, odd;
        even = K[i] >> 1; odd = K[i] - even;
        A[p]   += odd;
        A[p+1] += even;
        i++;
        even = K[i] >> 1; odd = K[i] - even;
        A[p]   += even;
        A[p+1] += odd;
        p += K[i];
    }
    REP(i, n){ printf("%d", A[i]); putchar(i == n - 1 ? '\n' : ' ');}
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int j : a) {
        if (j % 2 == 0 && j % 3 != 0 && j % 5 != 0) {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
}


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

using namespace std;

int complete(int n) {
	while (n % 10 != 0) n++;
	return n;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.setf(ios::fixed);
	cout.precision(4);
	
	int a, b, c, d, e;
	vector<int> ans(10);
	vector<int> min(10);

	cin >> a >> b >> c >> d >> e;

	ans[0] = complete(a);
	ans[1] = complete(b);
	ans[2] = complete(c);
	ans[3] = complete(d);
	ans[4] = complete(e);

	min[0] = a + ans[1] + ans[2] + ans[3] + ans[4];
	min[1] = ans[0] + b + ans[2] + ans[3] + ans[4];
	min[2] = ans[0] + ans[1] + c + ans[3] + ans[4];
	min[3] = ans[0] + ans[1] + ans[2] + d + ans[4];
	min[4] = ans[0] + ans[1] + ans[2] + ans[3] + e;

	int out = 1000000;

	for (int i = 0; i < 5; i++) {
		if (out > min[i]) out = min[i];
	}

	cout << out << '\n';

	return 0;
}

Measured memory_bytes: 256
/************************************************
   Start coding only after you have clear idea. 
*************************************************/

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 2e3+23;
const int maxn = 2e5+35;
int n,k,a[maxn];
bool check(int mid){
    int num = 0;
    for(int i = 1;i <= n; ++i){
        num += (a[i]+mid-1)/mid-1;
    }
    return num <= k;
}
int main(){
    scanf("%d %d",&n,&k);
    for(int i = 1;i <= n; ++i) scanf("%d",a+i);
    int L = 1,R = 1e9+19,ans;
    while(L <= R){
        int mid = (L+R) >> 1;
        if(check(mid)){
            ans = mid;
            R = mid-1;
        }
        else L = mid+1;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 4520
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#include<queue>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
int ceil(int a,int b){// a以上bの倍数の最小値//
     return (a+b-1)/b*b;
 }
int stoii(string s){//stoi関数の代用 文字列⇒int型//
    return atoi(s.c_str());
}

int R,C;
int sy,sx;
int gy,gx;
string c[51];
int dp[1010][1010]={0};
string s;
ll sum2=0;
void dfs(int i,ll sum,ll z){
	if(i==s.size()-1) {
		sum2+=sum+z;
		return ;
	}
	dfs(i+1,sum+z,s[i+1]-'0');
	dfs(i+1,sum,z*10+s[i+1]-'0');   
}
int main(){
    cin>>s;
	
	dfs(0,0,s[0]-'0');
	cout<<sum2<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        int[] input=Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
        
        if(input[0]>=input[3]) {
            Console.WriteLine(input[3]);
        } else {
            if(input[1]>=input[3]-input[0]) {
                Console.WriteLine(input[0]);   
            } else {
                Console.WriteLine(input[0]-(input[3]-input[0]-input[1]));
            }
        } 


    }
    
}


Measured memory_bytes: 19120
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int a,b,c;double d;cin>>a>>b;
	if(b<10)c=a*10+b;
	else if(b<100)c=a*100+b;
	else if(b==100)c=a*1000+b;
	d=sqrt(c);
	if(d==(int)d)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

using namespace std;

void printArray(int n, vector<int> &a)
{
    for (int i = 0; i < n; i++)
    {
        cout << a[i];
        if (i != n - 1)
            printf(" ");
        else
            printf("\n");
    }
}

void insertionSort(int n, vector<int> &a)
{
    int v;
    for (int i = 0; i < n; i++)
    {
        v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v)
        {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        printArray(n, a);
    }
}

int main()
{
    int n;

    scanf("%d", &n);

    vector<int> a(n);

    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }

    vector<int> &r = a;

    insertionSort(n, r);

    return 0;
}



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

int n,a[2][110],dp[2][110];

int main()
{
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[0][i];
	for(int i=0;i<n;i++) cin>>a[1][i];
	
	dp[0][0]=a[0][0];
	dp[1][0]=a[0][0]+a[1][0];
	for(int j=1;j<n;j++)
		for(int i=0;i<2;i++)
		{
			if(i==0) dp[i][j]=dp[i][j-1]+a[i][j];
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j];
		}
	/*
	for(int i=0;i<2;i++)
	{
		for(int j=0;j<n;j++) cout<<dp[i][j]<<' ';
		cout<<endl;
	}
	*/
	cout<<dp[1][n-1];
	
	return 0;
}

Measured memory_bytes: 256
import sys
from itertools import product
def input(): return sys.stdin.readline().rstrip()

def main():
    N, M, X = map(int, input().split())
    CA = [list(map(int, input().split())) for _ in range(N)]

    ans = -1
    bit_list = list(product([0, 1], repeat=N))
    for bits in bit_list:
        tmp_ans = 0
        m_list = [0] * M

        for ca, bit in zip(CA, bits):
            if bit == 0:
                continue
            tmp_ans += ca[0]
            if ans > 0 and tmp_ans > ans:
                break
            for i, v in enumerate(ca[1:]):
                m_list[i] += v
        if min(m_list) >= X:
            if tmp_ans < ans or ans < 0:
                ans = tmp_ans
    print(ans)

if __name__ == '__main__':
    main()


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

int main() {
  string s;
  cin>>s;
  int n=s.size();
  vector<int>a(n);
  a[0]=s[n-1]-'0';
  int kake=10;
  for(int i=1;i<n;i++){
    a[i]=(s[n-1-i]-'0')*kake+a[i-1];
    a[i]%=2019;
    kake*=10;
    kake%=2019;
  }
  sort(a.begin(),a.end());
  long long ans=0;
  long long x=1;
  int y=a[0];
  for(int i=1;i<n;i++){
    if(y==a[i]){
      x++;
      if(i==n-1) ans+=x*(x-1)/2;
    }
    else{
      ans+=x*(x-1)/2;
      x=1;
      y=a[i];
    }
  }
  int i=0;
  while(a[i]==0){
    ans++;
    i++;
  }
  if(n==1) cout<<0<<endl;
  else cout<<ans<<endl;
}

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

using namespace std;

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

    string s,t;
    cin >> s >> t;

    int last = t.length();
    for(int x=0;x<=(s.length()-t.length());x++){
        int min = 0;
        for(int y=0;y<t.length();y++){
            if(s[x+y]!=t[y])min++;
        }
        //cout << min << endl;
        if(min<last){
            last = min;
        }
    }
    cout << last << endl;
}

Measured memory_bytes: 3580
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) c.begin(),c.end()
static const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
static const int MOD = (int)(1e9 + 7);

signed main() {
	for (int n, r; cin >> n >> r&&n;) {
		vector<int> v(n); rep(i, 0, n) { v[i] = n - i; }
		rep(i, 0, r) {
			vector<int> tmp = v;
			int p, c; cin >> p >> c;
			rep(j, 0, p - 1) {
				tmp[j + c] = v[j];
			}
			rep(j, 0, c) {
				tmp[j] = v[j + p - 1];
			}
			swap(tmp, v);
		}
		cout << v[0] << endl;
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  int next = 1;
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(a[i] == next){
      next++;
    }else{
      ans++;
    }
  }
  if(ans == n){
    ans = -1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int power(int b,int p); 
	int x,maxv=0;
	cin>>x;
	if (x==1) 
	{
		cout<<'1';
		return 0;
	}
	for (int i=2;i<=int(sqrt(x));++i)
	{
		for(int j=2;j<=10;j++)
		{
			if (power(i,j)<=x&&power(i,j)>maxv)
			maxv=power(i,j);
		}
	}
	cout<<maxv;
	return 0;
}
int power (int i,int j)
{
	int ans=1;
	for (int k=1;k<=j;k++)
	{
		ans*=i;
	}
	return ans;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

n = int(readline())
a = list(map(int, readline().split()))
q = int(readline())
m = map(int, read().split())

counter = defaultdict(int)

for x in a:
    counter[x] += 1

total = sum(a)

for b, c in zip(m, m):
    total += (c-b) * counter[b]
    counter[c] += counter[b]
    counter[b] = 0
    print(total)


Measured memory_bytes: 35160
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

//最大公約数を求める
long long gcd(unsigned long long a, unsigned long long b)
{
	if (b) {
		return gcd(b, a % b);
	} else {
		return a;
	}
}

//最小公倍数を求める
unsigned long long lcm(unsigned long long a, unsigned long long b)
{
  unsigned long long g = gcd(a, b);
   return a / g * b;
}

int main()
{
	unsigned long long N;

	cin >> N;

	unsigned long long clockTop[N];

	for (int loop = 0; loop < N; ++loop) {
		cin >> clockTop[loop];
	}

	unsigned long long result = 1LL;
	for (int loop = 0; loop < N; ++loop) {
		result = lcm(result, clockTop[loop]);
	}

	cout << result;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sca=new Scanner(System.in);
		String a=sca.next();

int c=Integer.parseInt(a.substring(5,7));
if(c<=4) {
	System.out.println("Heisei");
}
else {
	System.out.println("TBD");
}
	}

}


Measured memory_bytes: 22996
import java.io.*;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
  
  public static void main(String[] args){
    
    try {
      
      //標準入力受け取り
      Scanner scan            = new Scanner(System.in);
      ArrayList<Integer> strs = new ArrayList<Integer>();
      
      while (scan.hasNext()){
      	strs.add(scan.nextInt());
      }
      
      //変数へ代入
      int [][] bingo  = new int[3][3]; //ビンゴ表
      int      num    = 0;             //チェック値
      String   jadge  = "No";          //判定
      
      for (int x=0; x<9; x++) {
      	for (int y=9; y<strs.size(); y++){
            bingo[x/3][x%3] = 0;
            //穴が開いた場合
            if (strs.get(x) == strs.get(y) ) {
	          bingo[x/3][x%3] = 1;
              break;
            }
        }
      }
      
      //ビンゴ有無チェック
      //横
      loop: for (int i=0; i<3; i++){
      	for(int j=0; j<3; j++){
          
          num += bingo[i][j];
          if (num == 3){
            jadge ="Yes";
            break loop;
          }
        }
        num = 0;
      }
      
      //縦
      loop: for (int j=0; j<3; j++){
      	for(int i=0; i<3; i++){
          
          num += bingo[i][j];
          if (num == 3){
            jadge ="Yes";
            break loop;
          }
        }
        num = 0;
      }
      
      //斜め
      num = bingo[0][0]+bingo[1][1]+bingo[2][2];
      if(num==3){
        jadge = "Yes";
      }
      
      num = bingo[0][2]+bingo[1][1]+bingo[2][0];
      if(num==3){
        jadge = "Yes";
      }
      
      System.out.println(jadge);
      
    } catch (Exception e) {
      
      System.out.println("error");

    }
  }
}


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

#define for(i, a, b) for(ll (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)
#define sz(x)        ((ll)(x).size())

const ll inf = 1 << 25;
const ll mod = 1e9 + 7;

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

int main() {
    string s;
    cin >> s;
    
    rep(i, 26) {
        bool flg = false;
        rep(j, s.length()) if (s[j] == 'a' + i) flg = true;
        if (!flg) {
            cout << (char)('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    
    return 0;
}

Measured memory_bytes: 512
import math
import sys
S = int(input())
if S < 3:
    print(0)
    sys.exit(0)
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
u = 0
t = S//3 
for i in range(t):
    u += combinations_count(S-2*i-3, i)
k = u % (10**9 + 7)
print(k)

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

int main() {
    int N;
    ll K;
    cin>>N>>K;
    vector<int> A(N);
    for (int i = 0; i < N; i++){
        int tmp;
        cin>>tmp;
        A[i]=tmp-1;
    }
    vector<bool> visited(N);
    vector<int> when(N);
    vector<int> where(N);
    int now=0;
    int was;
    int time=0;
    while(visited[now]!=true){
        visited[now]=true;
        when[now]=time;
        where[time]=now;
        was=now;
        now=A[now];
        time++;
    }
    int roop=when[was]-when[now]+1;
    ll before_roop=when[was]-roop+1;
    int ans=min(K,before_roop);
    K=max((ll)0,K-before_roop);
    ans+=K%roop;
    cout<<where[ans]+1<<endl;
}

Measured memory_bytes: 5640
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=(a);i<=(int)(n);++i)
#define lpd(i,a,n) for(int i=(a);i>=(int)(n);--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int n,x,y,z;
ll a[N],b[N],c[N],ans;
ll mxL[N],mxR[N];
vi idx;

int main(){
    read3i(x,y,z);
    n = x+y+z;
    lp(i,1,n){
        cin >>a[i] >>b[i] >>c[i];
        ans += c[i];
        a[i] -= c[i];
        b[i] -= c[i];
        idx.pb(i);
    }

    sort(all(idx), [](int i, int j){return a[i]-b[i] > a[j]-b[j];});

    ll curr = 0;
    multiset<ll> st;
    lp(i,0,n-1){
        int j = idx[i];
        curr += a[j];
        st.insert(a[j]);
        if(sz(st) > x){
            curr -= *st.begin();
            st.erase(st.begin());
        }
        if(sz(st) == x) mxL[i] = curr;
        else mxL[i] = -infll;
    }

    curr = 0;
    st.clear();
    lpd(i,n-1,0){
        int j = idx[i];
        curr += b[j];
        st.insert(b[j]);
        if(sz(st) > y){
            curr -= *st.begin();
            st.erase(st.begin());
        }
        if(sz(st) == y) mxR[i] = curr;
        else mxR[i] = -infll;
    }

    ll bst = -infll;
    lp(i,0,n-2) bst = max(bst, mxL[i] + mxR[i+1]);
    cout <<ans + bst;
}

/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/


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

vector <int> vec;
vector <int> ansVec;
bool flag = true;

void printAns(){
  if(flag == false) cout << -1 << endl;
  else{
    reverse(ansVec.begin(), ansVec.end());
    for(int i = 0; i < ansVec.size(); i++){
      cout << ansVec[i] + 1 << endl; 
    }
  }
}

void solveForTrue(int n){
  while(vec.empty() == false && flag == true){
    for(int i = vec.size() - 1; i >= 0; i--){
      if(vec[i] == i){  // Right Most in correct position
        ansVec.push_back(vec[i]);
        vec.erase(vec.begin() + i);
        break;
      }
      else if(vec[i] > i){
        flag = false;
      }
    }
  }
}

void solve(int n){
  solveForTrue(n);
  printAns();
}

int main() {
  int n , num;
  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> num;
    vec.push_back(num-1);
  }
  solve(n);
}

Measured memory_bytes: 3172
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>

using namespace std;


#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;


/*vectorの要素を全部確認するやつだよ。普通に拡張for文したほうがいいよ。

for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}

*/


/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/


/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/


/*実行開始からの経過時間を表すよ。

while (clock() < 1900000) {  }

*/


/*まだ使えないテクニックのメモだよ。

for (int bit = 0; bit < (1<<n); ++bit)//bit全探索用のfor文だよ

*/


/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/

int main() {
	int n; cin >> n;
	int d[114514];
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}

	sort(d, d + n);

	cout << d[n / 2] - d[n / 2 - 1] << endl;



	return 0;
}


Measured memory_bytes: 640
loop do
    a, op, b = gets.split(" ")

    a = a.to_i
    b = b.to_i

    case op
    when "+" then
        puts a + b
    when "-" then
        puts a - b
    when "*" then
        puts a * b
    when "/" then
        puts a / b
    else
        break
    end
end

Measured memory_bytes: 8648
import math

time_list = list()

for _ in range(5):
    time_list.append(int(input()))

# 全探索
ans = 1e6
for i in range(len(time_list)):
    tmp = 0
    for j in range(len(time_list)):
        if i == j:
            tmp += time_list[i]
            continue
        tmp += math.ceil(time_list[j] / 10) * 10
    ans = min(tmp, ans)

print(ans)

Measured memory_bytes: 3060
/**
    AUTHOR:JUNSH
    TIME:19/5/19
**/
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rev(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
inline int read(){
    int f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
const int inf=0x3f3f3f3f;
const int maxn=2e6;
int vis[maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int m,k;
    cin>>m>>k;
    int tot=(1<<m)-1;
    if(k>tot){
        cout<<"-1"<<endl;
        return 0;
    }
    if(m==1){
        if(k==0)
            cout<<"0 0 1 1"<<endl;
        else cout<<"-1"<<endl;
        return 0;
    }
    if(k==0){
        for(int i=0;i<=tot;++i)
        cout<<i<<" "<<i<<" ";
        cout<<endl;
        return 0;
    }
    int i=1,j=2;
    for(;i<=tot&&j<=tot;){
        while(vis[i]||vis[i^k])i++;
        while(vis[j]||vis[j^k]||j==i||j==(i^k))j++;
        if(i>tot||j>tot)break;
        vis[i]=1;
        vis[j]=1;
        vis[i^k]=1;
        vis[j^k]=1;
        cout<<i<<" "<<(i^k)<<" "<<j<<" "<<(j^k)<<" "<<(i^k)<<" "<<i<<" "<<(j^k)<<" "<<j<<" ";
    }
    cout<<endl;
}


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


int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	bool sameFlag = false;
	if (a + b == c) { sameFlag = true; }
	else if (b + c == a) { sameFlag = true; }
	else if (c + a == b) { sameFlag = true; }
	cout << (sameFlag == true ? "Yes":"No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d) cout << "Yes" << endl;
	else if (abs(a - b) <= d && abs(b - c) <= d) cout << "Yes" << endl;
	else cout << "No" <<  endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long A,B,H,M,N,W,r;
  string S;
  cin >> S;
  N=S.size();
  //cout << N << endl;
  //vector<long long> vec(N);
  //for (i=0;i<N;i++) {
   //cin >> vec.at(i);
  //}
  r=0;
  A=0;
  A=((N-1)/2+1)/2;
  for (int i=0;i<A;i++) {
   if (S[i]==S[(N-1)/2-i-1] && S[(N-1)/2-i-1]==S[(N+3)/2+i-1] && S[(N+3)/2+i-1]==S[N-1-i]) {
   ;}
   else {r=1;}
  }
  if (r==1) {cout << "No" << endl;} else {cout << "Yes" << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

// auto mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
      if ((x += a.x) >= mod) x -= mod;
      return *this;
    }
    mint& operator-=(const mint a) {
      if ((x += mod-a.x) >= mod) x -= mod;
      return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
      if (t&1) a *= *this;
      return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int n;
string s1, s2;

int main() {
    cin >> n;
    cin >> s1 >> s2;
    vector<bool> tate(n, false);
    for(int i = 0; i < n; ++i) {
        if(s1.at(i) == s2.at(i)) tate.at(i) = true;
    }

    mint ans = 1;
    for(int i = 0; i < n;) {
        if(i == 0) {
            if(tate.at(i)) {
                ans *= (mint)3;
                i++;
            }else {
                ans *= (mint)(3*2);
                i+=2;
            }
        }else {
            if(tate.at(i)) {
                if(tate.at(i-1)) ans *= (mint)2;
                else ans *= (mint)1;
                i++;
            }else {
                if(tate.at(i-1)) ans *= (mint)2;
                else ans *= (mint)3;
                i+=2;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3540
#include<stdio.h>

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

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  cout << max(A + B, max(A - B, A*B)) << endl;
  
  return 0;
}


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

using ll = long long;
 
const ll MOD = 1e9 + 7;
const int MX = 2e6 + 5;
 
ll n;
ll ans = 1;
 
ll fac[MX], inv[MX];
 
ll binpow(ll a, ll b) {
    a %= MOD;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}
 
ll combo(ll t, ll k) {
	ll res = 1;
	res = res * fac[t] % MOD;
	res = res * inv[k] % MOD;
	res = res * inv[t - k] % MOD;
	return res;
}
 

int main(){
    int k; string ss;
    cin >> k >> ss;
    
    int sz = ss.size();
    fac[0] = fac[1] = 1;
	inv[0] = inv[1] = 1;
	for (int i = 2; i <= MX - 5; ++i) {
		fac[i] = i * fac[i - 1] % MOD;
		inv[i] = binpow(fac[i], MOD - 2);
	}
    
    long long answer = 0;
    for(int i = sz; i <= sz + k; i++){
        answer += (combo(sz + k, i)*binpow(25, sz + k - i)%MOD);
        answer %= MOD;
    }
    
    cout << answer%MOD << endl;
}


Measured memory_bytes: 35636
x = sorted(list(map(int, input().split())))
cnt = 0
flag = True
while flag:
    if (x[1] - x[0]) == 0:
        while x[0] < x[2]:
            x[0] += 1
            x[1] += 1
            cnt += 1
    elif ((x[1] - x[0])%2) == 0:
        while x[0] < x[1]:
            x[0] += 2
            cnt += 1
    elif ((x[1] - x[0])%2) != 0:
        x[0] += 1
        x[2] += 1
        cnt += 1
    if x[0] == x[1] == x[2]:
        flag = False
print(cnt)

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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

int main(){
    int A[3];
    cin >> A[0] >> A[1] >> A[2];
    sort(A,A+3);
    int cnt=0;
    cnt+=(A[2]-A[0])/2;
    A[0]+=(A[2]-A[0])/2*2;
    cnt+=(A[2]-A[1])/2;
    A[1]+=(A[2]-A[1])/2*2;    
    if(A[0]==A[1]){
        if(A[1]!=A[2]) cnt++;
    }else cnt+=2;

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
import fractions
import math

def primefac(n):
    ret = []
    e = 0
    for i in range(2, math.floor(n**(1/2)) + 1):
        if n % i == 0:
            e = 0
            while n % i == 0:
                e += 1
                n //= i
            ret.append((i, e))
    if n != 1:
        ret.append((n, 1))
    return ret

A, B = map(int, input().split())
c = fractions.gcd(A, B)
print(len(primefac(c))+1)

Measured memory_bytes: 5048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = new List<string>();

            for (int i = 0; i < N; i++)
            {
                S.Add(Console.ReadLine());
            }
            IEnumerable<string> list =  S.Distinct();
            int ans = list.Count();
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 41304
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        try (Scanner scan = new Scanner(System.in)) {
            // スキップ
            scan.nextLine();

            // 検索対象をmapに格納する
            Map<String, String> map = new HashMap<String, String>();
            for (String num : scan.nextLine().split(" ")) {
                map.put(num, "");
            }

            // スキップ
            scan.nextLine();

            // 検索対象が存在する場合はカウントする
            int count = 0;
            for (String num : scan.nextLine().split(" ")) {
                if (map.containsKey(num)) {
                    count++;
                }
            }

            System.out.println(count);
        }

    }

}



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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    string s;
    while (cin >> s) {
        const int n = s.size();
        LL i = 0, cnt = 0, ans = 0;
        while (i < n) {
            int j = i;
            while (j < n && s[j] == 'A')
                j++;
            cnt += j-i;
            if (j-i) {
                while (j+1 < n && s[j] == 'B' && s[j+1] == 'C') {
                    ans += cnt; j += 2;
                }
                i = j;
            }
            else {
                i++; cnt = 0;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 720
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
N, K, Q = map(int, input().split())

score = [K-Q]*(N+1)
for _ in range(Q):
  a = int(input())
  score[a] += 1
[print("No" if ans < 1 else "Yes") for ans in score[1:]]

Measured memory_bytes: 8228
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=1;i<=(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int 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 highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
/*lcm(gcd(N1, M), gcd(N2, M), ..., gcd(Nk, M)) = gcd(lcm(N1, ..., Nk), M)
gcd(lcm(N1, M), lcm(N2, M), ..., lcm(Nk, M)) = lcm(gcd(N1, ..., Nk), M).

If gcd(N1, N2) = 1, then
gcd(N1·N2, M) = gcd(N1, M)·gcd(N2, M)
lcm(N1·N2, M) = lcm(N1, M)·lcm(N2, M)/M.

lcm(M, N, P) · gcd(M, N) · gcd(N, P) · gcd(P, M) = NMP · gcd(N, M, P).
*/
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    int n;
    cin>>n;
    int a[n+1];
    REP(i,n)cin>>a[i];
    int i=1;
    int ans=0;
    while(i<=n)
    {
        if(a[i]==i)
        {
            if(a[i+1]==i+1 && i<n)
            {
                i=i+2;
            }
            else i++;
            ans++;
        }
        else i++;
    }
    cout<<ans;
  }  
  return 0;
}
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* 1LL<<i and not 1<<i
* overflow (int vs ll?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

Measured memory_bytes: 4012
package main
import (
       "fmt"
       "os"
       "strconv"
       "bufio"
)

func main() {
     sc := bufio.NewScanner(os.Stdin)

     var n int
     if sc.Scan() { n, _ = strconv.Atoi(sc.Text()) }
     h := n / 3600
     s := n % 60
     m := (n - h*3600) / 60
     fmt.Printf("%d:%d:%d\n", h, m, s)
}



Measured memory_bytes: 1084
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <string.h>


typedef struct dice
{
	int label[6];
	int direction[6]; // 転がしたときに対応するラベル

}Dice;


void diceRotation(Dice *dice, char order) {
	int tmpDirc[6] = { 0 };
	for (size_t i = 0; i < 6; i++)
	{
		tmpDirc[i] = dice->direction[i];
	}

	if (order == 'S') {
		dice->direction[0] = tmpDirc[4];
		dice->direction[1] = tmpDirc[0];
		dice->direction[4] = tmpDirc[5];
		dice->direction[5] = tmpDirc[1];
	}
	else if (order == 'N') {
		dice->direction[0] = tmpDirc[1];
		dice->direction[1] = tmpDirc[5];
		dice->direction[4] = tmpDirc[0];
		dice->direction[5] = tmpDirc[4];
	}
	else if (order == 'W') {
		dice->direction[0] = tmpDirc[2];
		dice->direction[2] = tmpDirc[5];
		dice->direction[3] = tmpDirc[0];
		dice->direction[5] = tmpDirc[3];

	}
	else if (order == 'E') {
		dice->direction[0] = tmpDirc[3];
		dice->direction[2] = tmpDirc[0];
		dice->direction[3] = tmpDirc[5];
		dice->direction[5] = tmpDirc[2];
	}
}


int main(void) {

	int result[1001] = { 0 };

	char order1[10] = "SSSWSSS";
	char order2[10] = "EEE";

	int n = 6;

	Dice dice;
	int init = 0;

	for (; init < n; init++) {
		dice.label[init] = 0;
		dice.direction[init] = init;
	}


	scanf("%d %d %d %d %d %d", &dice.label[0], &dice.label[1], &dice.label[2], &dice.label[3], &dice.label[4], &dice.label[5]);


	int q = 0;
	scanf("%d", &q);

	int yomikomi = 0;
	for (; yomikomi < q; yomikomi++) {
		int top, front;
		scanf("%d %d", &top, &front);



		// まずは転がして(SSSWSSS)、前面を入力にそろえる
		// 次に上面を確認する。
		// そろってなければEを最大３回繰り返すと上面も入力にそろう
		// その時のdirection[2]を出力する

		int orderlen = strlen(order1);
		int i = 0;
		for (; i < orderlen; i++) {
			if (dice.label[dice.direction[1]] == front) {
				break;
			}
			diceRotation(&dice, order1[i]);
		}

		orderlen = strlen(order2);
		for (i = 0; i < orderlen; i++) {
			if (dice.label[dice.direction[0]] == top) {
				break;
			}
			diceRotation(&dice, order2[i]);
		}

		//result[yomikomi] = dice.label[dice.direction[2]];
		printf("%d\n", dice.label[dice.direction[2]]);
	}

	/*for (size_t i = 0; i < q; i++)
	{
		printf("%d\n", result[i]);
	}
	*/

	return 0;
}



Measured memory_bytes: 2132
//Author: Rahul Purohit

#include<bits/stdc++.h>
#define vi vector<int>
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll  long long int
#define pi pair<ll,ll>
#define f first
#define mp make_pair
#define mod 1000000007
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
int gcd(int a, int b)
{
	if(b==0)
		return a;
	else
		return (b,a%b);
}
/*ll isp[N]={1};
void sieve(int n)
{
	isp[0]=isp[1]=0;
	for(int i=2;i<=n;i++)
	{
		if(isp[i]==1)
		{
			for(int j=i*i;j<=n;j+=i)
			{
				isp[j]==0;
			}
		}
	}
}*/
ll pow(int x,int  y,int m)
{
	ll ans=1;
	while(y!=0)
	{
		if(y%2==1)
		{
			ans=(ans*x)%m;
		}
		x=(x*x)%m;
		y/=2;
	}
	return ans;
}
template <class x>
void swap(x &a,x &b)
{
	x tp;
	tp=a;
	a=b;
	b=tp;
}
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
    ll n;
    cin>>n;
    ll a=n%100;
    ll b=n/100;
    //cout<<a<<" "<<b<<endl;
    if(b>=1&&b<=12)
    {
        if(a>=1&&a<=12)
        {
            cout<<"AMBIGUOUS";
        }
        else
        {
            cout<<"MMYY";
        }
    }
    else
    {
        if(a>=1&&a<=12)
        {
            cout<<"YYMM";
        }
        else
        {
            cout<<"NA";
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
  int m,d;cin>>m>>d;
  int ans = 0;
  for(int i = 1; m >= i; i++){
    for(int j = 1; d >= j; j++){
      int d1 = j%10;
      int d10 = j/10;
      if(d1 >= 2 && d10 >= 2 && d1*d10==i)ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	initComb()
	N, K := sc.nextInt(), sc.nextInt()
	ans := 1
	k := min(K, N-1)
	// iは0になる部屋の数
	for i := 1; i <= k; i++ {
		ans += modComb(N, i) * modComb(N-1, i) % MOD
		ans %= MOD
	}

	fmt.Fprintln(wtr, ans)
}

// Combination
const MAX = int(1e+6)

var fac [MAX]int
var finv [MAX]int
var inv [MAX]int

func initComb() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1
	for i := 2; i < MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

func modComb(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}


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

using namespace std;

int main() {
  string s; cin >> s;
  
  if(s.size() >= 6 && s[2] == s[3] && s[4] == s[5])
 	cout << "Yes" << endl;
  else
    cout << "No" << endl;
    
 	return 0; 
}

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()))
sum_=0


for i,menu in enumerate(a):
  sum_+=b[menu-1]
  if i>0:
    if menu==a[i-1]+1:
      sum_+=c[menu-2]
print(sum_)

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = sum(B)
for i in range(N-1):
	if A[i] + 1 == A[i+1]:
		ans += C[A[i]-1]
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int		main()
{
	int		A, K, N;
	int		*meter;
	int		sum, dis, max, num, i;

	i = 0;
	sum = 0;
	max = 0;
	dis = 0;
	scanf("%d %d\n", &K, &N);
	meter = (int *)malloc(sizeof(int) * (N + 3));
	while (i <= N)
	{
		if (i < N)
			scanf("%d ", &meter[i]);
		else
			meter[i] = K;
		if (i)
			dis = meter[i] - meter[i - 1];
		if (i == N && meter[0])
			dis += meter[0];
		if (dis >= max)
		{
			max = dis;
			num = i;
		}
		sum += dis;
		i++;
	}
	sum -= max;
	printf("%d\n", sum);
	return (0);
}


Measured memory_bytes: 896
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <memory>
#include <initializer_list>
#include <iomanip>
#include <stack>
#include <bitset>
#include <cstdio>
// #include <complex>
#include <random>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll INF = 1e18;
// const ld INF = 1e20;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-9;
//const double PI = acos(-1);

void solve() {
    int a, b;
    cin >> a >> b;
    if (a < 10 && b < 10) {
        cout << a * b << "\n";
    } else {
        cout << "-1\n";
    }
}

int main() {
    // freopen("moscow.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    solve();
    return 0;
}


Measured memory_bytes: 256