akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define MAX_R 50
#define MAX_C 50
#define INF (1<<29)
typedef pair<int, int> pii;

bool inField(int x, int y, int C, int R)
{
    return (0 <= x && x < C && 0 <= y && y < R);
}

int main()
{
    int R, C, M;
    char field[MAX_R][MAX_C];
    cin >> R >> C >> M;
    for (int i = 0; i < R; i++) {
        for (int j = 0; j < C; j++) {
            cin >> field[i][j];
        }
    }
    int cost[3][MAX_R][MAX_C];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < R; j++) {
            for (int k = 0; k < C; k++) {
                cin >> cost[i][j][k];
            }
        }
    }
    vector<int> X(M), Y(M);
    for (int i = 0; i < M; i++) {
        cin >> Y[i] >> X[i];
    }

    const int dx[] = {-1, 0, 1, 0};
    const int dy[] = {0, -1, 0, 1};
    
    map<pii, vector<int>> vis;
    int prev_d = 0;
    for (int i = 1; i < M; i++) {
        queue<pii> Q; Q.push(pii(X[i-1], Y[i-1]));
        vector<vector<int>> d(MAX_R, vector<int>(MAX_C, INF));
        vector<vector<int>> prev(MAX_R, vector<int>(MAX_C, INF));
        d[Y[i-1]][X[i-1]] = prev_d;
        while (!Q.empty()) {
            pii p = Q.front(); Q.pop();
            int x = p.first, y = p.second;
            if (x == X[i] && y == Y[i]) {
                prev_d = d[y][x];
                break;
            }
            for (int j = 0; j < 4; j++) {
                int nx = x + dx[j], ny = y + dy[j];
                if (!inField(nx, ny, C, R) ||
                    field[ny][nx] == '#') {
                    continue;
                }
                if (d[y][x] + 1 < d[ny][nx]) {
                    d[ny][nx] = d[y][x] + 1;
                    prev[ny][nx] = y*C + x;
                    Q.push(pii(nx, ny));
                }
            }
        }
        int x = X[i], y = Y[i];
        vis[pii(x, y)].push_back(d[y][x]);           
        while (x != X[i-1] || y != Y[i-1]) {           
            int nx = x, ny = y;
            nx = prev[y][x] % C;
            ny = prev[y][x] / C;
            x = nx; y = ny;
            vis[pii(x, y)].push_back(d[y][x]);           
        }
    }
    int sum = 0;
    for (auto &v : vis) {
        int x = v.first.first;
        int y = v.first.second;
        vector<int> p = v.second;
        sum += cost[1][y][x] + cost[2][y][x];
        if (p.size() > 1) {
            for (int i = 1; i < (int)p.size(); i++) {
                sum += min(cost[2][y][x] + cost[1][y][x], (p[i] - p[i-1]) * cost[0][y][x]);
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 8140
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << min({a+b, b+c, c+a}) << endl;
    return 0;
}

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

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

	int N;
	cin >> N;
	int A, B;
	cin >> A >> B;
	int S = 0;
	for (int i = A; i <= N; i++) {
		int z = i;
		int sum = 0;
		while (z > 0) {
			sum += z % 10;
			z /= 10;
		}
		if (sum >= A && sum <= B) {
			S += i;
		}
	}
	cout << S;
}

Measured memory_bytes: 256
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
ll n, a, b;
vector<ll> x;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>a>>b;
    for (int i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        x.push_back(temp);
    }
    ll zahyou=x[0];
    ll ans=0;
    for(int i=1;i<n;i++){
        ans+=min(a*(x[i]-zahyou),b);
        zahyou=x[i];
    }
    cout << ans << "\n";
}



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

    int A[N];
    for (int i = 0; i < N; i++) cin >> A[i];

    int max = A[0];
    int min = A[0];

    for (int i = 1; i < N; i++)
    {
        if (A[i] > max)
        {
            max = A[i];
        }
        if (A[i] < min)
        {
            min = A[i];
        }
    }

    cout << max - min << endl;

    return 0;
}

Measured memory_bytes: 256
class Card
  include Comparable

  attr_reader :suit, :value

  def initialize(suit, value)
    @suit = suit
    @value = value
  end

  def <=>(other)
    @value - other.value
  end

  def ==(other)
    @suit == other.suit && @value == other.value
  end

  def to_s
    "#{@suit}#{@value}"
  end
end

def bubble_sort(arr)
  n = arr.size

  n.times do |i|
    (n - 1).downto(i + 1) do |j|
      if arr[j] < arr[j - 1]
        arr[j - 1], arr[j] = arr[j], arr[j - 1]
      end
    end
  end
end

def selection_sort(arr)
  n = arr.size

  n.times do |i|
    min_pos = i

    i.upto(n - 1) do |j|
      if arr[j] < arr[min_pos]
        min_pos = j
      end
    end

    arr[i], arr[min_pos] = arr[min_pos], arr[i]
  end
end

def is_stable(arr1, arr2)
  return false unless arr1.size == arr2.size

  arr1.size.times do |i|
    return false unless arr1[i] == arr2[i]
  end

  return true
end

n = gets.to_i

arr1 = gets.split.map do |str|
  suit = str[0].to_sym
  value = str[1].to_i

  Card.new(suit, value)
end

arr2 = arr1.dup

bubble_sort(arr1)
selection_sort(arr2)

puts arr1.join(' ')
puts 'Stable'

puts arr2.join(' ')
puts is_stable(arr1, arr2) ? 'Stable' : 'Not stable'

Measured memory_bytes: 8704
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
#define printd(x) printf("%.12f\n", ans);
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using Pll = pair<ll, ll>;
using P = pair<int, int>;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

int main(void) {

    ios::sync_with_stdio(false); cin.tie(0);

    
    

    int n;
    string s;
    cin >> s;

    if (s.size() % 2) {
        No()
        return  0;
    }

    rep (i, s.size() - 1) {
        if (s[i] == 'h' && s[i + 1] == 'i') {
            i ++;
        }
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int N, W;
int w[110], v[110];
int dp[110][110][310];

signed main() {
    cin >> N >> W;
    repq(i,1,N) cin >> w[i] >> v[i];
    int flr = w[1];
    repq(i,1,N) w[i] -= flr;
    memset(dp, 0, sizeof(dp));
    int ans = 0;
    repq(i,1,N) repq(j,1,i) repq(k,0,300) {
        dp[i][j][k] = dp[i-1][j][k];
        if(k-w[i] >= 0 && k + j * flr <= W)
            dp[i][j][k] = max(dp[i][j][k], dp[i-1][j-1][k-w[i]] + v[i]);
        if(i == N) ans = max(ans, dp[i][j][k]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 29568
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------
struct edge{
    ll to,cost;
};

ll V;
vector<edge>G[100001];
ll d[100001];

void dijkstra_ant(ll s){
    priority_queue<Pll,vector<Pll>,greater<Pll>>que;
    fill(d,d+V,INF);
    d[s]=0;
    que.push(mp(0,s));
    while(!que.empty()){
        Pll p=que.top();que.pop();
        ll v=p.se;
        if(d[v]<p.fi)continue;
        for(ll i=0;i<G[v].size();i++){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(mp(d[e.to],e.to));
            }
        }
    }
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    cin>>V;
    for(ll i=0;i<V-1;i++){
        ll a,b,c;cin>>a>>b>>c;
        a--;b--;
        edge M;M.to=b;M.cost=c;
        edge M2;M2.to=a;M2.cost=c;
        G[a].pb(M);G[b].pb(M2);
    }
    ll q,k;cin>>q>>k;
    k--;
    dijkstra_ant(k);
    for(ll i=0;i<q;i++){
        ll x,y;cin>>x>>y;
        x--;y--;
        cout<<d[x]+d[y]<<endl;
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 11120
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
int main()
{
	int N, M, x, y;
	cin >> N >> M;
	UnionFind tree(N);
	vector<int> p(N);
	rep(i, 0, N)cin >> p[i], p[i]--;
	rep(i, 0, M) {
		cin >> x >> y;
		x--, y--;
		tree.unite(p[x], p[y]);
	}
	int ans = 0;
	rep(i, 0, N)ans += tree.same(p[i], i);
	printf("%d\n", ans);
	return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    lint N, M;
    cin >> N >> M;

    vector<lint> divs(0);
    for (int i = 1; i * i <= M; i++) {
        if (M % i == 0) {
            divs.push_back(i);
            if (i * i != M) divs.push_back(M / i);
        }
    }
    sort(all(divs));
    // dump(divs);

    lint ans = -1;
    for (lint i = 0; i < divs.size(); i++) {
        // d(i);
        // d(M / divs[i]);
        if (N <= M / divs[i]) ans = max(ans, divs[i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3612
def main():
    S = input()
    for word in ["eraser", "erase", "dreamer", "dream"]:
        S = S.replace(word, ".")
    # print(S)
    if len(set(S)) == 1:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using NX = System.Int64;


public class Prog
{
    public static void Solve()
    {
        int N = NextInt();
        string S = NextString();
        Console.WriteLine((S.Substring(0, N / 2) == S.Substring(N / 2)) ? "Yes" : "No");
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
        return;
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 11220
num = int(input())
L = [int(x) for x in input().split()]
L.append(2020)
input()
s = [int(x)-1 for x in input().split()]

for i in s:
    if L[i+1] > L[i] +1:
        L[i] += 1

for i in range(len(L) -1):
    print(L[i])



Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll ans = LONG_LONG_MAX;
    ans = min(ans, a * x + b * y);
    ans = min(ans, c * x * 2 + b * max(0LL, y - x));
    ans = min(ans, c * y * 2 + a * max(0LL, x - y));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())

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

now = 1

d = []
set_d = set()

while True:
    if A[now-1] in set_d:
        i = d.index(A[now-1])
        check = d[i:]
        break
    now = A[now-1]
    d.append(now)
    set_d.add(now)

    if len(set_d) >= K:
        break

if K <= len(set_d):
    print(d[K-1])
else:
    K -= (len(set_d)-len(check))
    K = K % len(check)
    print(check[K-1])



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

int main()
{
    int k, a, b;
    cin >> k;
    cin >> a >> b;

    for (int i = a; i <= b; i++)
    {
        if (i % k == 0)
        {
            puts("OK");
            exit(0);
        }
    }

    puts("NG");
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
#define N (int)1e5
#define INF (int)1e9
#define mod (int)1e9 + 7
#define LL long long
int n, c, k, ans, i2;
int t[N];
int main()
{
	cin >> n >> c >> k;
	for (int i = 0; i < n; i++)
		cin >> t[i];
	sort(t, t + n);
	for (int i = 0; i < n; i++)
	{
		for (int j = i; j < n; j++)
		{
			if (t[j] > t[i] + k)
			{
				i = j - 1;
				ans++;
				break;
			}
			if (j == i + c - 1 || j == n - 1)
			{
				i = j;
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;
}

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

using namespace std;
const long long P = 1000000007;

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

  long long a=1,b=1,c=1;
  for(int i = 0; i < n; i++) {
    a *= 10;
    a %= P;
    b *= 8;
    b %= P;
    c *= 9;
    c %= P;
  }
  long long ans = a+b-2*c;
  ans %= P;
  if(ans < 0) ans += P;
  cout << ans << endl;
  return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
  ll N; cin >> N;
  Vi a(N);
  REP(i, N) cin >> a[i];
  RSORT(a);
  REP(i, N){
    if(a[i] != N - 1 - (i / 2) * 2){
      cout << 0 << endl;
      return 0;
    }
  }
  cout << pow(2, N / 2, MOD) << endl;
}


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

int main() {
  int N, X, Y;
  std::cin >> N >> X >> Y;
  for(int k = 1; k < N; ++k) {
    // 1. on the shortest line 1 to N
    int l = N-(Y-X);
    int ans = std::max(0, l+1-k);

    // 2. on the circle including X and Y
    int c = (Y-X) + 1;
    if(k*2 < c) ans += c;
    else if(k*2 == c) ans += k;

    // remove double count of X to Y in 1. and 2. on k = 1;
    if(k == 1) --ans;
    // from: (1 to X-1) or (N to Y+1), to: circle\{X, Y}
    else {
      for(int z: {X-1, N-Y}) {
        if(z == 0) continue; // no from:
        int b = std::max(1, z+2-k);
        int e = std::min(z, z+(c-1)/2-k+1);
        ans += 2*std::max(0, e-b+1);
        // remove double count of to: X or Y
        if(k <= z+1) --ans;
        // add the center of circle case
        if(c%2==0 && c/2 < k && k <= c/2+z) ++ans;
      }
    }
    std::cout << ans << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  map<string,int> M;
  cin>>n;
  rep(i,n){
      string s;
      cin>>s;
      M[s]++;
  }
  cout<<"AC x "<<M["AC"]<<'\n';
  cout<<"WA x "<<M["WA"]<<'\n';
  cout<<"TLE x "<<M["TLE"]<<'\n';
  cout<<"RE x "<<M["RE"]<<'\n';
  return(0);
}

Measured memory_bytes: 3628
n, y = map(int, input().split())
res = [-1, -1, -1]
for a in range(n + 1):
    for b in range(n - a + 1):
        if 10000 * a + 5000 * b + 1000 * (n - a - b) == y:
            res[0] = a
            res[1] = b
            res[2] = n - a - b
print(' '.join(map(str, res)))


Measured memory_bytes: 3060
#include <stdio.h>
#include <queue>
#include <unordered_set>
#include <utility>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp make_pair

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

struct S {
    int x, y, d;
    S() {}
    S(int x, int y, int d) : x(x), y(y), d(d) {}
};

inline int sig(const S& s) {
    return (s.x<<8) | (s.y<<2) | s.d;
}

inline int sig(const pair<S, S>& p) {
    return (sig(p.first) << 16) | sig(p.second);
}

bool operator<(const S& l, const S& r) {
    if (l.x != r.x) return l.x < r.x;
    if (l.y != r.y) return l.y < r.y;
    return l.d < r.d;
}

int H, W;
char f[16][64];
int sx, sy, sd, tx, ty, td;

S forward(int x, int y, int d) {
    for (;;) {
        const int nx = x + dx[d], ny = y + dy[d];
        if (f[nx][ny] == '#') return S(x, y, d);
        x = nx, y = ny;
    }
}

#define PUSH(q, vis, s) { \
    const int si = sig(s); \
    if (!vis.count(si)) vis.insert(si), q.push(s); \
}

bool reach() {
    unordered_set<int> vis;
    queue<S> q;
    const S st = forward(sx, sy, sd);
    PUSH(q, vis, st);
    while (!q.empty()) {
        const S cur = q.front();
        q.pop();
        if (cur.x == tx && cur.y == ty) return true;
        int dd = 1;
        rep (_, 2) {
            const S p = forward(cur.x, cur.y, (cur.d+dd)%4);
            PUSH(q, vis, p);
            dd += 2;
        }
    }
    return false;
}

void push(queue<pair<S, S> >& q, unordered_set<int>& vis, const S& l, int x, int y, int d) {
    const int rd = (d+2) % 4;
    if (f[x+dx[d]][y+dy[d]] != '#') return ;
    for (;;) {
        const pair<S, S> ss(l, S(x, y, d));
        PUSH(q, vis, ss);
        const int nx = x + dx[rd], ny = y + dy[rd];
        if (f[nx][ny] == '#') break;
        x = nx, y = ny;
    }
}

bool accomplish() {
    unordered_set<int> vis;
    queue<pair<S, S> > q;
    const S st = forward(sx, sy, sd);
    rep (d, 4) push(q, vis, st, sx, sy, d);
    while (!q.empty()) {
        const pair<S, S> vv = q.front();
        q.pop();
        const S cur = vv.first, rev = vv.second;
        if (cur.x == tx && cur.y == ty
                && rev.x == tx && rev.y == ty && rev.d == td) {
            return true;
        }
        int dd = 1;
        rep (_, 2) {
            push(q, vis, forward(cur.x, cur.y, (cur.d+dd)%4),
                    rev.x, rev.y, (rev.d+dd)%4);
            dd += 2;
        }
    }
    return false;
}

void solve() {
    rep (i, H) rep (j, W) if (f[i][j] == 'K') {
        f[i][j] = '.';
        sx = i, sy = j;
        rep (d, 4) if (f[i+dx[d]][j+dy[d]] != '#') sd = d;
    }
    rep (i, H) rep (j, W) if (f[i][j] == 'M') {
        f[i][j] = '.';
        tx = i, ty = j;
        rep (d, 4) if (f[i+dx[d]][j+dy[d]] != '#') td = d;
    }
    if (!reach()) puts("He cannot bring tea to his master.");
    else if (!accomplish()) puts("He cannot return to the kitchen.");
    else puts("He can accomplish his mission.");
}

int main() {
    for (;;) {
        scanf("%d%d", &W, &H);
        if (H == 0) return 0;
        rep (i, H) rep (j, W) scanf(" %c", f[i]+j);
        solve();
    }
}

Measured memory_bytes: 16944
//Created by Aminul on 6/27/2020.

import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args)throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        char[] s = in.next().toCharArray();
        char[] t = in.next().toCharArray();
        int cnt = 0;
        for (int i = 0; i < s.length; i++) {
            if(s[i] != t[i]) cnt++;
        }

        pw.println(cnt);

        pw.close();
    }

    static void debug(Object...obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}

Measured memory_bytes: 32760
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#define int long long
using namespace std;
     
int read(){
   	int x=0,f=1;
   	char c=getchar();
   	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
   	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
   	return x*f;
}
     
int k,m,n,a[100010];
int gcd(int x,int y){
 	if(!y)return x;
   	return gcd(y,x%y);
}
signed main(){
 	n=read();k=read();
   	for(register int i=1;i<=n;i++)a[i]=read();
	m=a[1];
   	for(register int i=2;i<=n;i++){
   		m*=a[i]/gcd(m,a[i]);
   		if(m>k*2){puts("0");return 0;}
   	}
	for(register int i=1;i<=n;i++){
		if((m/a[i])%2==0){puts("0");return 0;}
	}
   	printf("%lld\n",((k*2/m)+1)/2);
   	return 0;
}

Measured memory_bytes: 1024
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
    int n;
    //int a[55];
    vector<int> v;
    int v1;
    double max =0;
    cin >> n;
    vector<int >a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    double ans = a[0];
    for (int i = 1; i < n; i++) {
        ans += a[i];
        ans /= 2;
    }
    //for (int i = 1; i <= n; i++) {
    //    v.push_back(i);
    //}

    //do {
    //    double sum = a[v[0]];
    //    for (int i = 1; i < n; i++) {
    //        sum += a[v[i]];
    //        sum /= 2;

    //        if (i == n - 1) {
    //            if (max < sum)max = sum;

    //            
    //        }
    //    }
    //} while (next_permutation(v.begin(), v.end()));
    printf("%.10f", ans);
}



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

if N <= 2:
  print(1)
  exit()

inc, dec = False, False
cnt = 1

for i in range(N-1):
  if A[i+1] > A[i]:
    inc = True
  elif A[i+1] < A[i]:
    dec = True
  
  if inc and dec:
    cnt += 1
    inc, dec = False, False

print(cnt)

Measured memory_bytes: 15020
N = int(input())

f = False
for i in range(N):
    for j in range(N):
        if i*4 + j*7 == N:
            f = True
            break
        if i*4 + j*7 > N:
            break
    if f:
        break

if f:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s1, s2, ans;
  cin >> s1 >> s2;
  int len = min(s1.size(), s2.size());
  for (int i = 0; i < len; i++){
    ans += s1[i];
    ans += s2[i];
  }
  if (s1.size() > s2.size()) ans += s1[len];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:1024000000,1024000000")
/* vim: set fdm=marker */
//{{{
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < 0) return gcd(-a, b);
	if(b < 0) return gcd( a,-b);
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}

ll qpow(ll a, ll n, ll mod) {
	a %= mod;
	ll ans = 1LL;
	while(n) {
		if(n & 1) ans = (ans*a % mod);
		a = (a*a % mod);
		n >>= 1;
	}
	return ans;
}

inline ll rev(ll a, ll p) {
	return qpow(a, p - 2, p);
}

#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define rep(x, st, en) for(int x = st; x < en; x++)
#define rer(x, st, en) for(int x = st; x >= en; x--)
#define pb push_back
#define mp make_pair
#define dbgm(msg, var) cerr<<#msg<<" "<<#var<<" = "<<var<<endl; 
#define dbg(var) cerr<<#var<<" = "<<var<<endl;
#define X first
#define Y second
// build prefix sum
template<typename T>
inline void BPS(T* DST, T* SRC, int N, int s = 0) {
	DST[s] = SRC[s];
	rep(i, 1, N) DST[s + i] = DST[s + i - 1] + SRC[s + i];
}
inline int in() { int x; cin>>x; return x; }
#ifdef ALNDBG
namespace alndbg {
	clock_t s, e;
}
#endif

inline void tic() {
#ifdef ALNDBG
	alndbg::s = clock();
#endif
}

inline void toc() {
#ifdef ALNDBG
	alndbg::e = clock();
	cerr<<1000.0 * (alndbg::e - alndbg::s) / CLOCKS_PER_SEC<<" ms"<<endl;
#endif
}

//}}}

// -------------------- Spliters ------------------------
const int maxn =1e5+5 ;

int cnt[maxn];
bool red[maxn];

int main() {
	find_me_at: 
	http://codeforces.com
	ios::sync_with_stdio(0);
	red[1] = true;
	int n, m;cin>>n>>m;
	rep(i,1,n+1)cnt[i]=1;
	rep(i,0,m) {
		int x, y; cin>>x>>y;//x->y
		red[y] |= red[x];
		cnt[x]--;cnt[y]++;
		if(cnt[x] == 0) red[x] = false;
	}
	int ans = 0;
	rep(i,1,n+1) ans+=red[i];
	cout<<ans<<endl;

	return 0;
}
// --USE C++11
// *-USE O2


Measured memory_bytes: 768
program ABC105B
    implicit none
    integer(8)::N
    integer(8)::flg=0

    read(5,*)N

    if(mod(N,4)==0 .or. mod(N,7)==0)then
        print'(A)',"Yes"
    else
        do
            N=N-4
            !print'(i0)',N
            if(mod(N,7)==0 .or. mod(N,4)==0)then
                flg=1
                exit
            else if(N<4)then
                exit
            end if
        end do

        if(flg==0)then
            print'(A)',"No"
        else
            print'(A)',"Yes"
        end if
    end if
    
end program ABC105B

Measured memory_bytes: 512
#include <iostream>
#include <vector>

using namespace std;
using ll = long long int;

ll mod = 1e9 + 7;
ll memo[4000];

//拡張ユークリッドの互除法
//ax + by = cとなるようなc=gcd(a,b)をxをペアにして返す
//firstがx,secondがc
template <typename number>
pair<number, number> extended_euclid(number a, number b)
{
    number r0, r1, a0, a1, b0, b1;
    r0 = a; r1 = b;
    a0 = 1; a1 = 0;
    b0 = 0; b1 = 1;
    while (r1>0) {
        number q1 = r0 / r1;
        number r2 = r0 % r1;
        number a2 = a0 - q1 * a1;
        number b2 = b0 - q1 * b1;
        r0 = r1 ; r1 = r2;
        a0 = a1 ; a1 = a2;
        b0 = b1 ; b1 = b2;
    }
    number c = r0;
    a = a0; //x
    b = b0; //y
    return  {a, c};
}

//Nを法とした逆元を求める関数
template  <typename number>
number inverse_N(number a, number N)
{
    pair<number, number> result = extended_euclid(a, N);
    if(result.first < 0)
    {
        result.first = result.first + N;
    }
    return result.first;
}

ll get_comb(ll n, ll r){
    if(n < r){
        return 0;
    }else{
        ll result = memo[n];
        ll temp = (memo[r] * memo[n - r]) % mod;
        temp = inverse_N(temp, mod);
        result = (result * temp) % mod;
        return result;
    }
}

ll calc_comb(ll n, ll k, ll i)
{
    ll blue, red;
    blue = red = 1;
    //blueはk個を0個の人がいないi人への分け方
    ll m = k - 1;
    ll r = i - 1;
    blue = get_comb(m, r);
    //redはn - k + i個の中からi個を選ぶ組み合わせ
    m = n + 1;
    r = i;
    red = get_comb(m, r);
    //cout << blue << " " << red << endl;
    ll result = (blue * red) % mod;
    return result;
}

int main(){
   ll n, k;
   cin >> n >> k;
   memo[0] = 1ll;
   for(ll i = 1; i < 4000; i++)
   {
       memo[i] = (memo[i - 1] * i) % mod;
   }
   for(ll i = 1; i <= k; i++)
   {
       cout << calc_comb(n - k, k, i) << endl;
   }
}

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

int n, k;
int* w;

bool search(int x) {
  int cost = 0;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (w[i] > x)
      return false;
    cost += w[i];
    if (cost > x) {
      cost = w[i];
      cnt++;
      if (cnt == k)
        return false;
    }
  }
  return true;
}

int main() {
  cin >> n >> k;
  w = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> w[i];
  }
  
  int l = 0;
  int r = INT_MAX;

  while (l < r) {
    int m = (l + r) / 2;
    if (search(m)) 
      r = m;
    else
      l = m + 1;
  }

  cout << l << endl;

  return 0;
}

Measured memory_bytes: 1572
s=input()
t=input()
c=0
f=0
if len(t)!=(len(s)+1):
    print("No")
    f=1

for i in range(len(s)):
    if s[i]==t[i]:
        c+=1
    elif s[i] != t[i]:
        print("No")
        f=1
        break
    elif len(t)!=len(s)+1:
        print("No")
        f=1
        break
if c==len(t)-1 and f==0:
    print("Yes")


Measured memory_bytes: 61920
import collections
S = collections.deque(list(input()))
N = int(input())
parity = True
for i in range(N):
  query = input().split()
  if query[0] == "1":
    if parity == True:
      parity = False
    else:
      parity = True
  if query[0] == "2":
    if parity:
      if query[1] == "1":
        S.appendleft(query[2])
      else:
        S.append(query[2])
    else:
      if query[1] == "1":
        S.append(query[2])
      else:
        S.appendleft(query[2])

Sstr = ""
if parity:
  for i in range(len(S)):
    Sstr = Sstr + S.popleft()
else:
  for i in range(len(S)):
    Sstr = Sstr + S.pop()
print(Sstr)

Measured memory_bytes: 6372
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;

int team[100], num[100], ans[100];

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n*(n-1)/2; i++){
		int a,b,c,d;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		a--; b--;
		if(c == d){
			team[a]++;
			team[b]++;
		} else if(c > d){
			team[a] += 3;
		} else{
			team[b] += 3;
		}
	}
	for(int i = 0; i < n; i++) num[i] = team[i];
	sort(num,num+n,greater<int>());
	for(int i = 0; i < n; i++){
		if(i != 0 && num[i] == num[i-1]) continue;
		for(int j = 0; j < n; j++){
			if(team[j] == num[i]) ans[j] = i+1;
		}
	}
	for(int i = 0; i < n; i++) printf("%d\n", ans[i]);
}

Measured memory_bytes: 1044
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/05/04 11:01:57 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

using namespace std;

#define	int	long long
#define MOD 1000000007
#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++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

typedef long long 			ll;
typedef vector<int>			VI;
typedef vector<vector<int>>	VVI;
typedef pair<int, int>		PII;

// TOP
void	Main()
{
	int	n;
	cin >> n;

	int ans;
	ans = 0;
	VVI	V(3, VI(n));
	rep(i, 3)
	{
		rep(j, n)
			cin >> V.at(i).at(j);
		sort(V.at(i).begin(), V.at(i).end());
	}
	VI	A(n);
	int	sum;
	sum = 0;
	rrep(i, n - 1)
	{
		int x;

		x = V.at(2).end() - upper_bound(V.at(2).begin(), V.at(2).end(), V.at(1).at(i));
		sum += x;
		A.at(i) = sum;
	}
	rep(i, n)
	{
		int first_upper;

		first_upper  = upper_bound(V.at(1).begin(), V.at(1).end(), V.at(0).at(i)) - V.at(1).begin();
		if (first_upper != n)
		ans += A.at(first_upper);
	}
	// rep(i, n)
	// {
	// 	int	start  = upper_bound(V.at(1).begin(), V.at(1).end(), V.at(0).at(i)) - V.at(1).begin();
	// 	rep2(j, start, n)
	// 	{
	// 		int x = V.at(2).end() - upper_bound(V.at(2).begin(), V.at(2).end(), V.at(1).at(j));
	// 		ans += x;
	// 	}
	// }
	cout << ans << endl;
}
// END

int32_t	main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3568
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var X int

func main() {
	sc.Split(bufio.ScanWords)

	X = nextInt()
	ans := 1
	if X == 1 {
		fmt.Println(ans)
		return
	}
	for i := 2; i <= 100; i++ {
		for j := 2; j <= 100; j++ {
			y := powInt(i, j)
			if X < y {
				break
			}
			ans = maxInt(y, ans)
		}
	}

	fmt.Println(ans)
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  int a,b,k;cin>>a>>b>>k;
  int n=min(a,b);
  int c=0;
  int ans=0;
  for(int i=n; i>0; i--){
    if((a%i==0)&&(b%i==0)){
      c++;
    }
    if(c==k){
      ans=i;
      break;
    }
  }
  cout << ans << endl;
}


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

const long long MOD = 1000000007;

int main() {
  long long n, k;
  cin >> n >> k;
  long long ans = 0;
  for (long long i = k; i <= n + 1; ++i) {
    ans += i * (n - i + 1) + 1;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3616
// A - Two Rectangles
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define irp(i,n) for(int i=(n);i>=0;i--)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define dw(i,s,e,d) for(int i=(s);i>(e);i-=(d))
// #define in(x) cin>>(x)
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define vecmax(v) (*max_element(v.begin(),v.end()))
void bye(auto x, int code=0){cout<<(x)<<endl;exit(code);}
// int in(){int x;cin>>x;return x;}
int in(){int x;scanf("%d",&x);return x;}
// template<class T> T in(){T x;cin>>x;return x;}

void vprn(vector<int> &v){ for(int i=0;i<v.size();i++) cout<<v[i]<<(i<v.size()-1?",\t":"\n"); }
void vvprn(vector<vector<int>> &vv){ for(auto v:vv) vprn(v); }

// template<class T> void vprn(T &v, string s, string m, string e)
// {cout<<s;for(int i=0;i<v.size();i++)cout<<v[i]<<m;cout<<e;}
// template<class T> void vvprn(T &vv, string s, string m, string e)
// {for(auto v:vv) vprn(v,s,m,e);}

int main(){
	int a,b,c,d;cin>>a>>b>>c>>d;
	cout<< (a*b>c*d? a*b: c*d) <<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;
static const long k10E7 = 1000000007;

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

    long an[n + 1] = {};
    for(long& a : an){
        cin >> a;
    }

    uint64_t monster = 0;

    long b_prev = 0;
    for(long i = 0; i < n + 1; i++){
        long b = 0;
        if(i < n){
            cin >> b;
        }
        
        long a_left = an[i];

        if(b_prev >= a_left){
            monster += a_left;
            a_left = 0;
        } else {
            monster += b_prev;
            a_left -= b_prev;
        }

        if(b >= a_left){
            monster += a_left;
            b_prev = b - a_left;
        } else {
            monster += b;
            b_prev = 0;
        }
    }

    cout << monster << endl;

    return 0;
}



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

int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if (x+r<=W && y+r<=H && 0<=x-r && 0<=y-r) {cout << "Yes" << endl;}
    else {cout << "No" <<endl;}
}


Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int r; cin >> r;
    cout << (3 * r * r) << endl;
}


Measured memory_bytes: 256