akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se  second
/*ll solve(int i)
{
    if(i>n)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    int x,y;
    if(i+1>n)
        x=0;
    else
        x=abs(a[i]-a[i+1]);
    if(i+2>n)
        y=0;
    else
        y=abs(a[i]-a[i+2]);
    dp[i]=min(solve(i+1)+x,solve(i+2)+y);
    return dp[i];
}*/
int main()
{
    int n;
    cin>>n;
    ll dp[n+1][3],a[n+1];
    for(int i=1; i<=n; ++i)
        cin>>a[i];
    memset(dp,0,sizeof dp);
    for(int i=2; i<=n; ++i)
    {
        if(i-1>0)
            dp[i][1]=min(dp[i-1][1],dp[i-1][2])+abs(a[i]-a[i-1]);
        if(i-2>0)
            dp[i][2]=min(dp[i-2][1],dp[i-2][2])+abs(a[i]-a[i-2]);
        else
            dp[i][2]=1e18;
    }
    cout<<min(dp[n][1],dp[n][2])<<endl;
    return 0;
}


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

void solve(int a){
  if((10<=a && a<=99) || (1000<=a && a<=9999) || a==100000);
  else ans++;
}

signed main(){
  int N;
  cin >> N;
  for(int i=1;i<=N;i++) solve(i);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1e9+7
using namespace std;
typedef long long ll;
const double pi=acos(-1);

int a[1000000][3];
int dp[1000000][3];

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin >> a[i][j];
        }
    }
    for(int i=0;i<3;i++) dp[0][i]=a[0][i];
    for(int i=1;i<n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+a[i][2];
    }

    cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]}) << endl;
}

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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

//bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;


int main() {

    list<ll> l;

    int n;
    cin >> n;
    rep(i, n) {
        ll a;
        cin >> a;
        if (i % 2 == 0) {
            l.push_back(a);
        } else {
            l.push_front(a);
        }
    }

    vector<ll> ans;
    for (ll a : l) {
        ans.push_back(a);
    }

    if (n % 2 == 1) reverse(ans.begin(), ans.end());

    for (ll a : ans) cout << a << ' ';

    cout << endl;
}



Measured memory_bytes: 10100
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define mod 1000000007;
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll arr[n+1];
    arr[0]=0;
    for(int i=1;i<=n;i++)
    cin>>arr[i];
    ll fre[n+1];
    vector<ll>num;
    for(int i=0;i<=n;i++)
    fre[i]=0;
    ll temp=arr[1];
    fre[1]=1;
    num.push_back(1);
    ll count=1;
    while(true)
    {
        if(fre[temp]==1)
        {
        num.push_back(temp);
        break;
        }
        fre[temp]++;
        num.push_back(temp);
        temp=arr[temp];
    }
    for(int i=0;i<num.size()-1;i++)
    {
        if(num[i]==num[num.size()-1])
        {
        count=i;
        break;
        }
    }
    //cout<<count<<" ";
    if(k<num.size())
    {
        cout<<num[k];
        return 0;
    }
    k=k-count;
    ll m=num.size()-count-1;
    //cout<<m<<" ";
    k=k%m;
    cout<<num[count+k];
    

    return 0;
}

Measured memory_bytes: 8456
#include<iostream>
using namespace std;
int main()
{
	while (1) {
		int n, i, j, a[5000], max = -100001, c;
		cin >> n;
		if (n == 0) {
			break;
		}
		for (i = 0; i < n; i++) {
			cin >> a[i];
		}
		for (i = 0; i < n; i++) {
			c = 0;
			for (j = i; j < n; j++) {
				c+= a[j];
				max = max < c ? c : max;
			}
		}
		cout << max << endl;
	}
	return 0;
}

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

int c[50][50];
bool visited[50][50] = {false};
int w, h;


void search(int x, int y){
    if(x < 0 || x >= w || y < 0 || y >= h || c[y][x] == 0){
        return;
    }
    if(visited[y][x] == true){
        return;
    }

    visited[y][x] = true;

    search(x-1, y);
    search(x+1, y);
    search(x, y-1);
    search(x, y+1);
    search(x+1, y+1);
    search(x+1, y-1);
    search(x-1, y+1);
    search(x-1, y-1);
}

void init(){
    for(int y = 0; y < 50; y++){
        for(int x = 0; x < 50; x++){
            visited[y][x] = false;
        }
    }
}


int main(){
    int count;
    int n = 0;
    vector<int> ans;

    while(1){
        cin >> w >> h;

        if(w == 0 and h == 0){
            break;
        }

        n++;
        count = 0;

        for(int y = 0; y < h; y++){
            for(int x = 0; x < w; x++){
                cin >> c[y][x];
            }
        }

        for(int y = 0; y < h; y++){
            for(int x = 0; x < w; x++){
                if(c[y][x] == 1 and visited[y][x] == false){
                    search(x, y);
                    count++;
                }
            }
        }

        ans.push_back(count);
        
        init();
    }

    for(int j = 0; j < n; j++){
        printf("%d\n", ans[j]);
    }

    return 0;

}


Measured memory_bytes: 3204
#include <stdio.h>
#include <string.h>
int main(void)
{
        int a,m,n,i,j=0,k=0,l=0,p;
        char s[1000];

        scanf("%s",s);
        n=strlen(s);//7
        p=(n/2)-1;
        m=((n+3)/2)-1;
        for(i=0; i<p+2; i++)
                if(s[i]==s[n-1-i]) l++;
                if(l!=n/2+1){
                        printf("No\n");
                 return 0;
                 }

        for(i=0; i<p; i++)
                if(s[i]==s[p-i]) k++;
                if(k!=p){
                        printf("No\n");
                return 0;
                }

        for(i=0; i<p; i++)
                if(s[m+i]==s[n-i-1]) j++;
                if(j!=p){
                        printf("No\n");
                 return 0;
                }
        printf("Yes\n");
                return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstring>

using namespace std;

void solve()
{
    long long x, y;
    cin >> x >> y;
    if (x % y == 0) {
        cout << -1 << endl;
        return;
    }
    long long t = x / __gcd(x, y) * y;
    cout << t - x << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
#AGC2 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b = LI()
if a == b:
    if a == 0:
        print('Zero')
    else:
        print('Positive')
elif a <= 0 and b >= 0:
    print('Zero')
elif a < 0 and b < 0:
    if (b-a)%2:
        print('Positive')
    else:
        print('Negative')
else:
    print('Positive')


Measured memory_bytes: 38256
S=input()
w=len(S)-1
l=[]
L=[]
#S一桁の時の例外処理
if w==0:
    print(int(S))
else:
    for i in range(2**w):
        #format（i,'0?b'）で好きな長さの2進数表示にできる
        l.append(format(i, '0{}b'.format(w)))
    #＋が入るなら区切り、入らないなら⋆10して足す
    for e in l:
        q=[]
        x=int(S[0])
        for i in range(len(e)):
            if e[i]=='0':
                x=x*10+int(S[i+1])
            else:
                q.append(x)
                x=int(S[i+1])
        q.append(x)
        L.append(sum(q))
    print(sum(L))

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

int main() {
	int N;
	cin >> N;
	int i=0;
	int a=0;
	
	while(i<N){
		int x,y;
		cin >> x >> y;
		a += y-x+1 ;
		i++; 
	}
	cout << a <<endl;
}

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

typedef long long ll;

int K;
int A[100010];

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

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

    ll a = 2, b = 2;
    for(int i = K - 1; i >= 0; i--) {
        ll na = (a + A[i] - 1) / A[i] * A[i];
        ll nb = b / A[i] * A[i] + A[i] - 1;

        if(na > nb) {
            printf("-1");
            return 0;
        }
        a = na;
        b = nb;
    }
    cout << a << ' ' << b;
}


Measured memory_bytes: 640
import sys, itertools
#def input(): return sys.stdin.readline()
def inpl(): return [int(i) for i in input().split()]
N, K = inpl()
Sushi = []
Neta = set()
ans = 0
for _ in range(N):
    t, d = inpl()
    Sushi.append((d, t))
Sushi.sort(reverse = True)
Db = []
Nd = []
for i in range(K):
    d, t = Sushi[i]
    if t not in Neta:
        Neta.add(t)
        ans += d
    else:
        Db.append(d)
neta = len(Neta)
Db = [0] + list(itertools.accumulate(Db))
Db.reverse()
for i in range(N-K):
    d, t = Sushi[K+i]
    if t not in Neta:
        Neta.add(t)
        Nd.append(d)
Nd = [0] + list(itertools.accumulate(Nd))
print(ans + max([(neta + i)**2 + j + k for i, (j, k) in enumerate(zip(Db, Nd))]))

Measured memory_bytes: 23788
#include<iostream>

using namespace std;

int main() {
	int a,b;
	cin >> a >> b;
	int ans = 0;
	int sockets = 1;
	while(sockets < b){
        sockets--;
        sockets += a;
        ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define ll long long int
#define ld unsigned long long int
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define pu push
#define po pop
#define fi first
#define se second
#define mk make_pair
#define lr(n) for(ll i=0;i<n;i++)

	int main(){
		ios_base::sync_with_stdio(0);
		cin.tie(0);
		cout.tie(0);
		ll n,r,g,b;
		cin>>r>>g>>b>>n;
		ll x3=0,f,ans=0;
		while(n-b*x3>=0){
			f=n-b*x3;
			ll x2=0;
			while(f-g*x2>=0){
				ll k=f-g*x2;
				if(k%r==0)
					ans++;
				x2++;
			}
			x3++;
		}
		cout << ans<<"\n";
		return 0;
	}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	int H,W,D,Q;
	cin >> H >> W >> D;
	vector<vi> B(H*W,vi(2));
	for(int i=1; i<=H; i++){
		for(int j=1; j<=W; j++){
			int A;
			cin >> A;
			A--;
			B[A][0]=i;
			B[A][1]=j;
		}
	}
	cin >> Q;
	vi L(Q),R(Q);
	for(int i=0; i<Q; i++){
		cin >> L[i] >> R[i];
		L[i]--;
		R[i]--;
	}

/*	vector<vi> dp(D,vi(0));
	for(int i=0; i<D; i++){
		dp[i%D].push_back(abs(B[i+D][0]-B[i][0])+abs(B[i+D][1]-B[i][1]));
	}
	for(int i=D; i<H*W-D; i++){
		dp[i%D].push_back(dp[i%D][dp[i%D].size()-1]+abs(B[i+D][0]-B[i][0])+abs(B[i+D][1]-B[i][1]));
	}
*/
	vi dp(H*W,0);
	for(int i=0; i<H*W-D; i++){
		dp[i+D]=dp[i]+abs(B[i+D][0]-B[i][0])+abs(B[i+D][1]-B[i][1]);
	}

	for(int i=0; i<Q; i++){
		int ans=0;
		if(R[i]>0){
			ans=dp[R[i]]-dp[L[i]];
		}else{
			ans=dp[R[i]];
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 7168
#include <iostream>
#include <string>
using namespace std;
using ll = long long int;
const ll MOD = 1000000007;

ll mod_pow(ll A, ll K) {
    ll ret = 1;
    for(; K>0; K>>=1) {
        if(K & 1) (ret *= A) %= MOD;
        (A *= A) %= MOD;
    }
    return ret;
}

ll sum[100010][4];
int main() {
    string s, pat = "ABC?"; cin >> s;
    int N = s.length();

    for(int i=0; i<N; i++) {
        int f = pat.find(s[i]);
        for(int k=0; k<4; k++) {
            sum[i+1][k] = sum[i][k] + (f == k);
        }
    }

    ll ans = 0;
    for(int i=0; i<N; i++) {
        if(s[i] == 'B' or s[i] == '?') {
            ll l_a =             sum[i  ][0], l_q =             sum[i  ][3];
            ll r_c = sum[N][2] - sum[i+1][2], r_q = sum[N][3] - sum[i+1][3];

            ll val_l = (l_a * mod_pow(3, l_q) + l_q * mod_pow(3, l_q - 1)) % MOD;
            ll val_r = (r_c * mod_pow(3, r_q) + r_q * mod_pow(3, r_q - 1)) % MOD;
            (ans += val_l * val_r) %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.string;

void main()
{
  int n, k;
  n = readln.chomp.to!int;
  k = readln.chomp.to!int;

  int res = 1;

  foreach (int i; 0..n) {
    res = min(res * 2, res + k);
  }
  writeln(res);
 }



Measured memory_bytes: 256
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define LL long long
#define NUM 1000000007

using namespace std;

int main()
{
    int n;
    cin >> n;
    map<int, int> m;
    for (int i=0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        auto iter = m.find(tmp);
        if (iter == m.end())
        {
            m.insert(make_pair(tmp, 1));
        }
        else
        {
            iter->second++;
        }
    }
    int ans=0;
    for (auto&& element : m)
    {
        if (element.second % 2 != 0)
        {
            ans++;
        }
    }
    std::cout << ans << endl;
}

Measured memory_bytes: 4864
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn =new Scanner(System.in);
		int n =scn.nextInt();
		double d =scn.nextDouble();
		int cnt=0;
		for(int i=0;i<n;i++){
			long val1 = scn.nextLong();
			long val2 =scn.nextLong();
			long val3 = (val1)*val1 +val2*val2;
			double res= Math.sqrt(val3);
			if(res<=d){
				cnt++;
			}
		}
		System.out.println(cnt);
		

	}

}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
		int s,w; cin>>s>>w;
		if (w>=s) out("unsafe");
		out("safe");
  

    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int i=0; i<n; i++)
#define FOR1(i, n) for(int i=1; i<=n; i++)
#define FORI(i, n) for(int i=n-1; i>=0; i--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, (T)x); }
template<class T, class U, typename... W> void init(vector<T> &v, U x, size_t n, W... m) { v=vector<T>(n);  for(auto& a : v) init(a, x, m...); }

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int h, w, m;
    cin >> h >> w >> m;
//    if (m <= 2) {cout << 2 << endl; return 0;}

    vector<vector<int>> v;
    v.resize(3e5+1);
    int mi = 1;
    map<int, int> H;
    FOR(ii, m){
        int i, j;
        cin >> i >> j;
        umax(mi, i);
        v[i].push_back(j);
        H[j]++;
    }

    set<pii> S;
    for(auto it : H) S.insert({it.second, it.first});
    S.insert({0, 0});
    int sol = 0;
    FOR1(i, mi){
        if (v[i].size() == 0) continue;

        int cntrow = v[i].size();
        for(auto j : v[i]){
            S.erase({H[j], j});
            H[j]--;
            S.insert({H[j], j});
        }
        if (S.size())
            umax(sol, cntrow + S.rbegin()->first);
        else
            umax(sol, cntrow);
        for(auto j : v[i]){
            S.erase({H[j], j});
            H[j]++;
            S.insert({H[j], j});
        }
    }
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}



Measured memory_bytes: 47820
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int k, x;
	int max, min;
	cin >> k >> x;

	if (x - k + 1 < -1000000)	min = -1000000;
	else min = x - k + 1;

	if (x + k - 1 > 1000000)	max = 1000000;
	else max = x + k - 1;

	for (int i = min; i <= max; i++){
		cout << i << " ";
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int n;
	scanf("%d", &n);
	if (n < 10)
		printf("%d", n);
	else if (10 <= n && n < 100)
		printf("9");
	else if (100 <= n && n < 1000)
		printf("%d", n - 90);
	else if (1000 <= n && n < 10000)
		printf("909");
	else if (10000 <= n && n < 100000)//83232
		printf("%d", n - 9090);
	else
		printf("90909");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
template<class T>
inline T qread(T &IEE){
	register T x = 0, f = 1;
	register char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-'){
			f = -f;
		}
		ch = getchar();
	}
	while(isdigit(ch)){
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return IEE = x * f;
}
template<class T>
inline void qwrite(T a){
	if(!a){
		putchar('0');
		return ;
	}
 	if(a < 0){
		putchar('-');
		a = -a;
	}
	if(a > 9) qwrite(a / 10);
	putchar(a % 10 + 48);
	return ;
}
template<class T>
inline T ab(T a){
	return (a > 0) ? a : -a;
}
template<class T>
inline void swa(T &a, T &b){
	a ^= b ^= a ^= b;
	return ;
}
ll a, b, n;
int main(){
//	freopen("1.in", "r", stdin);
//	freopen("1.out", "w", stdout);
	qread(a);
	qread(b);
	qread(n);
	if(n < b){
		cout << (a * n) / b;
	} else {
		cout << (a * (b - 1)) / b;
	}
	puts("");
	return 0;
}


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

int main()
{
	int k;
	string s1;
	cin >> k;
	cin >> s1;
	if(s1.length() > k)
	{
		s1.erase(k,s1.length());
		s1 = s1 + "...";
	}
	cout << s1 << endl;
	
	
	return 0;
 } 

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

int main()
{
	int h, n, k;
	long long sum = 0;
	priority_queue<int, vector<int>, greater<int>> q;
	cin >> n >> k;
	for(int i = 0; i < n; ++i){
		cin >> h;
		sum += h;
		q.push(h);
		if(q.size() > k)
			q.pop();
	}
	while(!q.empty()){
		sum -= q.top();
		q.pop();
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>

int main(void) {

  long n,x;
	scanf("%ld %ld", &n, &x);
	long a[n];
	for (long i = 0; i < n; i++) {
		scanf("%ld", &a[i]);
	}
	long operation = 0;
	if (a[0] > x) {
		operation += a[0]-x;
		a[0] = x;
	}
	for (long i = 1; i < n; i++) {
		if (a[i-1]+a[i] > x) {
			operation += (a[i-1]+a[i]-x);
			a[i] -= (a[i-1]+a[i]-x);
		}
	}
	printf("%ld\n", operation);

  return 0;
}

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

int main()
{
    int N;
    cin >> N;
    rep(i, N)
    {
        char c;
        cin >> c;
        if (c == 'Y')
        {
            cout << "Four" << endl;
            return (0);
        }
    }

    cout << "Three" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int X;
  cin >> X;
  int x = sqrt(X);
  int ans = 1;
  if(X < 4) cout << 1 << endl;
  else {
   for (int i = 2; i <= x; i++) {
     int j = 1;
     while (j <= X) {
       j *= i;
     }
     j /= i;
     if (ans < j) ans = j;
   }
   cout << ans << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define ff first
#define ss second
#define mod 1000000007
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b){ll res=1;a=a%mod; while(b){if(b&1)res=(res*a)%mod; a=(a*a)%mod;b/=2;}return res;}
ll invmod(ll a){return power(a,mod-2);}
int main(void)
{
    FIO    
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(ll i=k;i<=n+1;i++)
    {
        ll mx=((i*(n+n-i+1))%mod*(invmod(2)%mod))%mod;
        ll mn=((i*(i-1))%mod*(invmod(2)%mod))%mod; 
        // cout<<mx<<" "<<mn<<"\n";
        ans=(ans%mod+mx-mn+1+mod)%mod;
        // ans%=mod;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
  
int main(void){
    int a, b, c, temp;
    scanf("%d %d %d", &a, &b, &c);
    if(a > b){
        temp = a;
        a = b;
        b = temp;
    }
    if(b > c){
        temp = b;
        b = c;
        c = temp;
    }
    if(a > b){
        temp = a;
        a = b;
        b = temp;
    }
    printf("%d %d %d\n", a, b, c);
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
        string s;
        cin >> s;
        int p = 0;
        for (int i = 0; i < s.length(); i++)
                if (s[i] == 'p')
                        p++;
        cout << (int)((s.length() / 2) - p) << endl;
        return 0;
}


Measured memory_bytes: 512
import itertools
N, M, Q = [int(x) for x in input().split(" ")]

conditions = [[int(x) for x in input().split(" ")] for _ in range(Q)]

def add(l, N):
    if len(l) == 0:
        b = 1
    else:
        b = l[-1]
    ans = []
    for i in range(b, N+1):
        ans.append(l + [i])
    return ans

L = [[]]
for _ in range(N):
    nex = []
    for l in L:
        nex.extend(add(l, M))
    L = nex

smax = 0
for l in L:
    s = 0
    for c in conditions:
        if l[c[1]-1] - l[c[0]-1] == c[2]:
            s += c[3]
    if s > smax:
        smax = s
print(smax)


Measured memory_bytes: 30368
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

K = INT()
a, b = MAP()

x = ceil(a, K)
y = b // K
if x > y:
    print('NG')
else:
    print('OK')


Measured memory_bytes: 9260
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<bitset>

using namespace std;


int H, W;
vector<vector<int>> A, B, C;

using mybit = bitset<12800>;

int main()
{
	int ans = 0;
	cin >> H;
	cin >> W;
	A = B = C = vector<vector<int>>(H,vector<int>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> B[i][j];
			C[i][j] = abs(A[i][j] - B[i][j]);
		}
	}

	auto sum_list = vector<vector<mybit>>(H, vector<mybit>(W));


	sum_list[0][0].set(C[0][0]);

	for (int i = 1; i < H + W; i++) {
		for (int x = min(i,W-1); x>=0 ; x--) {
			int y = i -	x;
			if (y >= H) { break; }

			if (x > 0) {
				mybit left = sum_list[y][x - 1] << C[y][x];
				mybit right = sum_list[y][x - 1] >> C[y][x];
				string os = sum_list[y][x - 1].to_string();
				reverse(os.begin(),os.end());
				os.erase(C[y][x]);
				mybit over(os);
				over <<= 1;

				sum_list[y][x] |= left | right | over;

			}
			if (y > 0) {
				mybit left = sum_list[y - 1][x] << C[y][x];
				mybit right = sum_list[y - 1][x] >> C[y][x];
				string os = sum_list[y - 1][x].to_string();
				reverse(os.begin(), os.end());
				os.erase(C[y][x]);
				mybit over(os);
				over <<= 1;

				sum_list[y][x] |= left | right | over;
			}
		}
	}

	while(!sum_list[H - 1][W - 1].test(ans)){
		ans++;
	}

	cout << ans << endl;

	return 0;
}



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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N, K; cin >> N >> K;
  ll sum = 0;
  // a = b * q + r
  // b = 0 ... x
  // b = 1; r = 0
  // b = 2; r = 0, 1
  // b = 3; r = 0, 1, 2
  // r >= K より, b >= K + 1
  // b = B; r = K, ..., B - 1
  //        a = B * q + r

  REP(b, K + 1, N + 1) {
    // r = K, ..., B - 1
    // q = 0, ..., N / b (各q に対して B - K 個の r が存在)
    // #a = #q * (B - K) + max(0, (N % B) - K + 1)
    // 但し、K = 0 の場合、b に対して q = 0, r = 0 のケースを取り除く
    sum += N / b * (b - K) + max(0, (N % b) - K + 1);
    if (K == 0) sum--;
  }
  // 0 = b (> K) * q + r (= 0)
  cout << sum << "\n";
}


Measured memory_bytes: 256
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)

def main():
    n,m,q=map(int,input().split())
    data=[]
    ans=0
    for i in range(q):
        a,b,c,d=map(int,input().split())
        data.append([a,b,c,d])
    num=0
    diff=[0]*(n-1)
    res=0
    while num<10**(n-1):
        res=0
        for i in range(q):
            if data[i][2]==sum(diff[data[i][0]-1:data[i][1]-1]):
                res+=data[i][3]
        ans=max(ans,res)
        num+=1
        i=1
        while num<10**n and digitSum(num)>m-1:
            num=(num//10**i)*10**i+10**i
            i+=1
        strDiff=list(str(num).zfill(n-1))
        diff=[int(s) for s in strDiff]
    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 9156
#include <bits/stdc++.h>
#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

int main() {
    cin>>H>>W>>M;
    vec hnum(H, 0), wnum(W, 0), h(M), w(M);
    rep(i,M){
        cin>>h[i]>>w[i];
        --h[i];
        --w[i];
        ++hnum[h[i]];
        ++wnum[w[i]];
    }
    int mh = *max_element(ALL(hnum)), mw = *max_element(ALL(wnum));
    int ans = mh + mw, num = (count(ALL(hnum), mh)) * count(ALL(wnum), mw);
    rep(i,M){
        if(hnum[h[i]] + wnum[w[i]] == mh + mw) --num;
    }
    cout<<ans - (num == 0)<<endl;
}


Measured memory_bytes: 12756
#include<stdio.h>
#include<math.h>

int isprime(int);

int main(){
    int count = 0,n,x;
    
    // read the number of integers and the integers
    scanf("%d",&n);
    for(int i = 0; i < n; i++){
        scanf("%d",&x);
        // count the number of prime numbers
        if (isprime(x)) {
            count += 1;
        }
    }
    
    printf("%d\n",count);
    
    return 0;
}

// if x is prime number then return 1 else return 0
int isprime(int x){
    int i = 3;
    if (x == 2) {
        return 1;
    }
    
    if(x < 2 || x % 2 == 0){
        return 0;
    }
    
    while (i <= sqrt(x)) {
        if(x % i == 0){
            return 0;
        }
        i += 2;
    }
    
    return 1;
}



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

int main(){
	cin.tie(0);	
	cout.tie(0);	
	ios_base::sync_with_stdio(0);
	int m,d,m2,d2;
	cin >> m >> d >> m2 >> d2;
	cout << (m != m2?1:0) << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define pb push_back
#define mp make_pair
#define M 1000000007
#define F first
#define S second
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}

// #define ncr_nikalo
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
}
ll modinv(ll a,ll m)
{
    return power(a,m-2,m);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll int t=1;
    //cin>>t;
    #ifdef ncr_nikalo
        initialvalues();
    #endif
        
    for(ll int g=0;g<t;g++)
    {
    	ll int n,sum=0;
    	cin>>n;
    	ll int a[n];
    	for(ll int i=0;i<n;i++)
    		cin>>a[i];
    	sort(a,a+n,greater<ll int>());
    	vector<ll int>v;
    	v.pb(0);
        v.pb(a[0]);
    	for(ll int i=1;i<n;i++)
    	{
    		v.pb(a[i]);
    		v.pb(a[i]);
    	}
    	for(ll int i=0;i<n;i++)
    		sum+=v[i];
    	cout<<sum;


    }
    return 0;
}

Measured memory_bytes: 8996
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.StringTokenizer; 
import java.util.*;
 
public class Main 
{ 
  
    
    public static void main(String[] args) throws IOException 
    { 
  
       BufferedReader br = new BufferedReader( 
                              new InputStreamReader(System.in));
                               int n =  Integer.parseInt(br.readLine());
                 
                   System.out.println(6.28318530717958623200*n);
                
                     
    }
    }
 


Measured memory_bytes: 33236
m=10000000019
x=0
def mod(x):return (x%m+m)%m
def pow(x,a):
    ret=1
    while a:
        if(a&1):ret=mod(x*ret)
        x=mod(x*x)
        a>>=1
    return ret

for _ in range(int(input())):
    o,y=map(int,input().split())
    if o==1:x=(x+y)%m
    elif o==2:x=(x-y)%m
    elif o==3:x=mod(x*y)
    else:x=mod(x*pow(y,m-2))
print(x if x<(1<<31)else x-m)

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

typedef long long ll;
using namespace std;

struct Star{
	int x,y,b;
	bool operator<(const Star& another) const {
		return b < another.b;
	}
};

class RMQ{
public:
	ll n;
	vector<ll> dat;
	RMQ(ll n_){
		n = 1; while(n < n_) n *= 2;
		dat = vector<ll>(2*n-1,INT_MAX);
	}

	//dat[k] -> a
	void update(int k, int a){
		k += n-1;
		dat[k] = a;
		while(k > 0){
			k = (k-1)/2;
			dat[k] = min(dat[k*2+1], dat[k*2+2]);
		}
	}

	ll query(int a, int b, int k, int l, ll r){
		if(r <= a || b <= l) return INT_MAX;
		if(a <= l && r <= b) return dat[k];
		else return min(query(a, b, k*2+1, l, (l+r)/2), query(a, b, k*2+2, (l+r)/2, r));
	}

	//[a,b) <- coution a~(b-1)
	ll getMin(int a, int b){
		return query(a,b,0,0,n);
	}
};

int N,d;
vector<Star> s;

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

	cin >> N >> d;

	for (int i = 0;i < N;i++){
		int x,y,b; cin >> x >> y >> b;
		s.push_back((Star){x,y,b});
	}

	sort(s.begin(),s.end());

	RMQ minX(N);
	RMQ minY(N);
	RMQ maxX(N);
	RMQ maxY(N);

	for (int i = 0;i < N;i++){
		minX.update(i,s[i].x);
		minY.update(i,s[i].y);
		maxX.update(i,s[i].x*(-1));
		maxY.update(i,s[i].y*(-1));
	}

	ll ans = -1;
	int f = 0, t = 0;

	for(f;f < N;f++){
		while(t < N && s[t].b - s[f].b <= d) t++;
		ll area = (maxX.getMin(f,t)*(-1)-minX.getMin(f,t)) * (maxY.getMin(f,t)*(-1)-minY.getMin(f,t));
		ans = max(ans,area);		
	}

	cout << ans << endl;

	return 0;

}


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

int main() {
  int N;
  cin >> N;
  int a[N];
  for(int i=0; i<N; ++i) {
    cin >> a[i];
  }

  map<int, int> mp;
  for(int i=0; i<N; ++i) {
    ++mp[a[i]];
  }

  int count = 0;
  for(auto p: mp) {
    int x = p.first;
		int n = p.second;
		if (n < x) count += n;
		else count += n - x;
  }

  cout << count << '\n';

  return 0;
}


Measured memory_bytes: 5120
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {
    const rows = input.split('\n')
    const N = rows[0] - 0

    const A = rows[1].split(' ').map(Number)
    A.sort((a, b) => {
        return a < b ? -1 : 1
    })

    const mem = []
    let count = 0

    for (let i = 0; i < N; i ++) {
        if (mem[A[i]] === 1) {
            count--
            mem[A[i]] = 0
            continue
        } else if (mem[A[i]] === 0) {
            continue
        } else {
            mem[A[i]] = 1
        }
        for (let j = 2; A[i] * j <= A[N - 1]; j++) {
            mem[A[i] * j] = 0
        }
        count++
    }
    console.log(count)

})(input)


Measured memory_bytes: 78340
import heapq

N = int(input())
A = list(sorted(map(int,input().split())))

first = A.pop()
Q = [(-first,first,first)]

ans = 0
for i in range(N-1):
    a = A.pop()
    b,c,d = heapq.heappop(Q)
    ans -= b
    heapq.heappush(Q,(-a,c,a))
    heapq.heappush(Q,(-a,d,a))

print(ans)

Measured memory_bytes: 140244
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

int cnt = 0;

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

void shellSort(vector<int> &A, int n, int m, vector<int> G) {
    cnt = 0;
    rep(i, m) insertionSort(A, n, G[i]);
}

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

    int n;
    cin>>n;
    vector<int> A(n);
    rep(i, n) cin>>A[i];

    int m = 0;
    int cn = n;
    vector<int> G;
    while (cn > 0) {
        G.push_back(cn);
        m++;
        cn /= 2;
    }
    shellSort(A, n, m, G);
    cout<<m<<endl;
    rep(i, m - 1) cout<<G[i]<<" ";
    cout<<G[m - 1]<<endl;
    cout<<cnt<<endl;
    rep(i, n) cout<<A[i]<<endl;
}


Measured memory_bytes: 6676
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); i++)

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

    int n, m;
    cin >> n >> m;

    int A[n][m];
    REP(i, n) REP(j, m) {
        int tmp;
        cin >> tmp;
        A[i][j] = tmp;
    }

    int B[m];
    REP(i, m) {
        int tmp;
        cin >> B[i];
    }

    int result[n];
    REP(i, n) {
        result[i] = 0;
    }
    REP(i, n) REP(j, m) {
        result[i] += A[i][j] * B[j];
    }

    REP(i, n) {
        cout << result[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 3212
function Main(s, t) {
  let min = 1000;
  for (let i = 0; i <= s.length - t.length; i++) {
    let change = t.length;
    for (let j = 0; j < t.length; j++) {
      if (s.charAt(i + j) == t.charAt(j)) {
        change--;
      }
    }
    if (change < min) min = change;
  }
  return min;
}

function readlines() {
  return require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
}

(async () => {
  const lines = readlines();
  console.log(await Main(lines[0], lines[1]));
})();

Measured memory_bytes: 32200
// https://atcoder.jp/contests/abc062/tasks/arc074_b

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;
const int A_I_MAX = 1e9;
const ll INF = 1e15;

int N;
int a[N_MAX * 3];

ll L[N_MAX + 1];
ll R[N_MAX + 1];

void solve() {
  priority_queue<int, vector<int>, greater<int> > lq;
  REP(i, N) {
    int la = a[i];
    L[0] += la;
    lq.push(la);
  }
  REP(i, N) {
    int li = lq.top();
    int la = a[N + i];
    if (la > li) {
      L[i + 1] = L[i] - li + la;
      lq.pop(); lq.push(la);
    } else {
      L[i + 1] = L[i];
    }
  }
  priority_queue<int, vector<int> > rq;
  for(int i = N * 3 - 1; i >= N * 2; i--) {
    int ra = a[i];
    R[N] += ra;
    rq.push(ra);
  }
  for (int i = N - 1; i >= 0; i--) {
    int rx = rq.top();
    int ra = a[N + i];
    if (ra < rx) {
      R[i] = R[i + 1] - rx + ra;
      rq.pop(); rq.push(ra);
    } else {
      R[i] = R[i + 1];
    }
  }
  // DUMP(L, N + 1);
  // DUMP(R, N + 1);
  ll ans = -INF;
  REP(i, N + 1) ans = max(ans, L[i] - R[i]);
  printf("%lld\n", ans);
}

void input() {
  scanf("%d", &N);
  REP(i, N * 3) scanf("%d", a + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 3832
a1, a2, a3 = map(int, input().split())

c1 = abs(a2 - a1) + abs(a3 - a1)
c2 = abs(a1 - a2) + abs(a3 - a2)
c3 = abs(a1 - a3) + abs(a2 - a3)

print(min(c1, c2, c3))

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

	int main(){
		int a,b,count=1;
		cin>>a>>b;

		for(int i=0;i<a;i++){
			if(i==0){
			count*=b;
			}
			else{
				count*=(b-1);
			}
		}

		cout<<count<<endl;
		return 0;
	}

Measured memory_bytes: 256
N = int(input())
L = []
for _ in range(N):
    L.append(int(input()))
L = sorted(L)
no_ten = list(filter(lambda x:x%10!=0,L))
ans = sum(L)
if ans % 10 == 0:
    if len(no_ten) != 0:
        ans -= min(no_ten)
    else:
        ans = 0

print(ans)

Measured memory_bytes: 38512
antenna = []
count = 0
n = 0

5.times do
    antenna << gets.chomp.to_i
end
dis = gets.chomp.to_i

antenna.each do|a|
    antenna.each do|b|
        if a - b > dis
            count += 1
        end
    end
end

if count >= 1
    puts ":("
else
    puts "Yay!"
end

Measured memory_bytes: 1788
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    A = list(sorted(list(map(int, input().split()))))
    B = list(sorted(list(map(int, input().split()))))
    C = list(sorted(list(map(int, input().split()))))

    ans = 0
    for b in B:
        a = bisect_left(A, b)
        c = N - bisect_right(C, b)
        ans += a * c

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24128
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize, 
        s: String,
    }
    if a >= 3200 {
        println!("{}", s);
    } else {
        println!("red");
    }
}


Measured memory_bytes: 4352
'''
Created on 2020/03/28

@author: fanta
'''
N,K = map(int,input().split())
A = [int(x) for x in input().split()]
B = []

for i in range(K-1):
    B.append(A[i+1] - A[i])
B.append(A[0] + (N - A[K-1]))

print(N - max(B))

Measured memory_bytes: 26436
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x= sc.nextInt();
        int y= sc.nextInt();
        while(true){
            if(x>=y){
                x%=y;
            }else{
                y%=x;
            }
            if(x*y==0){
                break;
            }
        }
        System.out.println(x+y);
        sc.close();
    }
}


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

int N = 0;

long long All = 1;

int main(){
  cin>>N;
  
 long long A [N];
  
  for(int i = 0;i < N;i++){
    cin>>A[i];
    if(A[i]== 0){
    cout<<0;
    return 0;
    }
  }
  
  
  
  
  
    for(int i = 0;i < N;i++){
      if(A[i] <= 1000000000000000000/All){
        
        All = All * A[i];
    }else{
        cout<<-1;
        return 0;
    }
  
    }
    cout<<All;
  

  return 0;
}


Measured memory_bytes: 4420
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int w=sc.nextInt();int h=sc.nextInt();
  int n=sc.nextInt();
  int po[][]=new int[w][h];
  for(int i=0;i<n;i++){
  	int a=sc.nextInt();int b=sc.nextInt();int c=sc.nextInt();
    if(c==1){
      for(int j=0;j<h;j++){
      	for(int k=0;k<a;k++){
        	po[k][j]=1;
        }
      }
    }
    else if(c==2){
      for(int j=0;j<h;j++){
      	for(int k=a;k<w;k++){
        	po[k][j]=1;
        }
      }
    }
    else if(c==3){
      for(int j=0;j<b;j++){
      	for(int k=0;k<w;k++){
        	po[k][j]=1;
        }
      }
    }
    else{
      for(int j=b;j<h;j++){
      	for(int k=0;k<w;k++){
        	po[k][j]=1;
        }
      }
    }
  }
  int count=0;
  for(int i=0;i<h;i++){
    
  for(int j=0;j<w;j++){
  if(po[j][i]==1){
  count++;
  }
  }
  }
  System.out.println(h*w-count);
}
}


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

int main(){
  
  int a,b;
  
  cin >> a >> b;
  
  if (a*b%2 == 1){
    
    cout << "Odd" << endl;
    
  }
  
  else{
    
    cout << "Even" << endl;
    
  }
}

Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N, K, Q;
	std::vector<int> A;
	std::cin >> N >> K >> Q;
	A.resize(Q);
	for (auto& a : A)
	{
		std::cin >> a;
		--a;
	}
	
	std::vector<int> P;
	P.resize(N);
	for (auto& p : P)
		p = K - Q;

	for (auto a : A)
	{
		++P[a];
	}
	
	for (int i = 0; i < N; ++i)
	{
		if (P[i] <= 0)
			std::cout << "No\n";
		else
			std::cout << "Yes\n";
	}
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
using std::cout;
using std::cin;
using std::endl;
const int MAX_N = 100000;
int parent[MAX_N+10];

void initialize(void){
    for (int i = 0; i < MAX_N+10;i++)
    {
        parent[i] = i;
    }
}

int find(int x){
    if(parent[x]==x)
    {
        return x;
    }else
    {
        return parent[x] = find(parent[x]);
    }
}

void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x==y)
        return;
    else
    {
        parent[x] = y;
    }
}

bool is_same(int x,int y){
    return find(x) == find(y);
}

int main(void)
{
    initialize();
    std::vector<int> numlist;
    int N, M;
    cin >> N >> M;
    int m1,m2;
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &m1);
        numlist.push_back(m1);
    }
    for (int i = 0; i < M;i++)
    {
        scanf("%d %d", &m1, &m2);
        unite(m1, m2);
    }

    int count=0;
    for (int i = 1; i <= N; i++)
    {
        if(is_same(numlist[i-1],find(i))){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>

using namespace std;


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

    cout << 180 * (n-2) << endl;



    return 0;
}



Measured memory_bytes: 888
n = int(input())
a = list(map(int, input().split()))

def 割れる回数(a):
    回数 = 0
    while a % 2 == 0:
        回数 += 1
        a = a // 2
    return 回数

割れる回数のリスト = [割れる回数(a_i) for a_i in a]
答え = min(割れる回数のリスト)
print(答え)

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

int main() {
  ll n;
  cin >> n;
  vector<ll> x(n);
  for(ll i=0;i<n;i++) {
    cin >> x[i];
  }
  ll ans=1e18;
  for(ll i=-100;i<101;i++) {
    ll tans=0;
    for(ll j=0;j<n;j++) {
      tans+=(x[j]-i)*(x[j]-i);
    }
    ans=min(ans,tans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256