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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int cnt = 0;
        while (N>0) {
            N/=K;
            cnt++;
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 23124
void main()
{
    long a, b, n;
    rdVals(a, b, n);

    long calc(long x)
    {
        return (a * x) / b - a * (x / b);
    }

    long t = b - 1;
    if (t <= n) calc(t).writeln;
    else calc(n).writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 2684
#include<iostream>
#include<math.h>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include <time.h>
#include<string.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 2005;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=2.718281828459045235360287471352662;
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back

int main()
{
    ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
int a,b,c,d;
cin>>a>>b>>c>>d;
cout<<min(a,b)+min(c,d) <<endl;
   //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define mp make_pair
#define vvll vector <vll>
#define vsi vector <si>
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("a.in","r",stdin);
#endif
    string s;
    cin>>s;
    if (s=="ABC")
        cout<<"ARC";
    else
        cout<<"ABC";




}

Measured memory_bytes: 3652
import java.util.Scanner;

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

		 
		        int n = scanner.nextInt();
		        int tarop = 0;
		        int hanakop = 0;
		        String tarow;
		        String hanakow;
		 
		        for(int i = 0; i < n; i++){
		            tarow=scanner.next();
		            hanakow=scanner.next();
		            if(tarow.compareTo(hanakow) < 0)  {      hanakop =hanakop+ 3;}
		            else if(tarow.compareTo(hanakow) > 0)   tarop = tarop+3;
		            else {
		                hanakop=hanakop+1;
		                tarop=tarop+1;
		            }
		        }
		 
		        System.out.println(tarop + " " + hanakop);
		    }

}



Measured memory_bytes: 29600
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    A.sort()
    A_max = A[-1]
    B = min(A,key=lambda x:abs(x-A_max/2))
    print(A_max, B)
if __name__ == '__main__':
    main()

Measured memory_bytes: 59372
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    int m1,d1,m2,d2;
    scanf("%d %d %d %d", &m1, &d1, &m2, &d2);
    if(m1 != m2) printf("1\n");
    else printf("0\n");
    return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

constexpr bool isPrime(const int &n) {
  if (n == 1) return false;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}

void solve() {
  int n;
  while (cin >> n, n) {
    int c = 0;
    for (int i = 2; i * 2 <= n; i++) {
      c += isPrime(i) && isPrime(n - i);
    }
    cout << c << endl;
  }
}

Measured memory_bytes: 2972
#include<bits/stdc++.h>
#define FastIO1 ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define si(n) scanf("%d",&n)
#define sl(n) scanf_s("%lld",&n)
#define nsl(n) scanf_s("%lld\n",&n)
#define nsi(n) scanf("%d\n",&n)
#define repz(i,a,n) for(int i=a;i<n;i++)
#define repo(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for (int i=n;i>=a;i--)
#define stlfor(it,stl) for(auto &it:stl)
#define pb push_back
#define mp make_pair
namespace FastIO {
	const int SIZE = 1 << 16;
	char buf[SIZE], obuf[SIZE], str[60];
	int bi = SIZE, bn = SIZE, opt;
	int read(char* s) {
		while (bn) {
			for (; bi < bn && buf[bi] <= ' '; bi++);
			if (bi < bn) break;
			bn = fread(buf, 1, SIZE, stdin);
			bi = 0;
		}
		int sn = 0;
		while (bn) {
			for (; bi < bn && buf[bi] > ' '; bi++) s[sn++] = buf[bi];
			if (bi < bn) break;
			bn = fread(buf, 1, SIZE, stdin);
			bi = 0;
		}
		s[sn] = 0;
		return sn;
	}
	template<typename T>
	bool read(T& x) {
		int n = read(str), bf;
		if (!n) return 0;
		int i = 0; if (str[i] == '-') bf = -1, i++; else bf = 1;
		for (x = 0; i < n; i++) x = x * 10 + str[i] - '0';
		if (bf < 0) x = -x;
		return 1;
	}
};
using namespace FastIO;
using namespace std;
typedef long long ll;
typedef long double db;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll a, ll b,ll mod) { ll ans = 1; while (b) { if (b & 1) ans = (ans * a)%mod ; b >>= 1; a = (a * a)%mod; }return ans; }
ll qmul(ll a, ll b, ll mod) { ll ans = 0; while (b > 0) { if (b & 1)ans = (ans + a) % mod; b >>= 1; a = (a + a) % mod; }return ans; }
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
string hack = { "NB" };
int hack1 = 0;
int hack2 = hack1 + 666;
const int maxn = 2e5 + 5;
int  x[maxn], y[maxn];
int findp(int x,int *pre) { return pre[x] == x?pre[x] : pre[x] = findp(pre[x],pre); }
void init(int n,int *pre) {
	for (int i = 1; i <= n; i++) {
		pre[i] = i;
	}
}
void unite(int x, int y,int *pre)
{
	int p1 = findp(x, pre);
	int p2 = findp(y, pre);
	if (p1 != p2) {
		pre[p1] = p2;
	}
}
bool same(int x, int y,int *pre) { return findp(x,pre) == findp(y,pre); }
void NB() {
	map<pair<int, int>, int> mapp;
	int n, k, l;
	FastIO::read(n); FastIO::read(k); FastIO::read(l);
	init(n, x);
	init(n, y);
	while (k--) {
		int X, Y;
		FastIO::read(X); FastIO::read(Y);
		unite(X, Y, x);
	}
	while (l--) {
		int X, Y;
		FastIO::read(X); FastIO::read(Y);
		unite(X, Y, y);
	}
	repo(i, 1, n) {
		findp(i, x);
		findp(i, y);
	}
	pair<int, int>temp;
	repo(i, 1, n) {
		temp = make_pair(x[i], y[i]);
		mapp[temp]++;
	}
	repo(i, 1, n) {
		temp = make_pair(x[i], y[i]);
		cout << mapp[temp] << " ";
		if (i == n)cout << '\n';
	}
}
int main() {
	FastIO1
	NB();
	return 0;
}

Measured memory_bytes: 16464
S=input()
flag=False
while True:
    if S[-5:] == 'dream' or S[-5:] == 'erase':
        S = S[:-5]
    elif S[-6:] == 'eraser':
        S = S[:-6]
    elif S[-7:] == 'dreamer':
        S = S[:-7]
    else:
        break

if len(S)==0:
    print('YES')
else:
    print('NO')




Measured memory_bytes: 3188
def main():
    N, K = map(int, input().split())
    mx = (N-1) * (N-2) // 2
    if K > mx:
        print(-1)
        return
    M = N - 1 + (mx - K)
    print(M)
    for i in range(2, N+1):
        print(1, i)
        M -= 1
    for i in range(2, N+1):
        for j in range(i+1, N+1):
            if M <= 0:
                return
            print(i, j)
            M -= 1

if __name__ == "__main__":
    main()


Measured memory_bytes: 44656
#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 <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 998244353
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#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)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
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[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,Pll> a,pair<ll,Pll> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se.fi>b.se.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //-------------------------------
    int n;cin>>n;
    n%=10;
    if(n==3)cout<<"bon"<<endl;
    else if(n==0||n==1||n==6||n==8)cout<<"pon"<<endl;
    else cout<<"hon"<<endl;
    //-------------------------------  
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------






















































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

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    long a, b, k, idx = 0;
    cin >> a >> b >> k;
    // c = 出力すべきまでの値
    long c = min(a + k - 1, b);

    for(int i = a; i <= c; i++)
        cout << i << endl;

    if(c == b)
        return 0;

    long d = max(c + 1, b - (k - 1));
    for(int i = d; i <= b; i++)
        cout << i << endl;
}

Measured memory_bytes: 3596
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		String input = sc.next();
		
		long result = 0;
		int currentWhite = 0;
		for (int i = 0; i < input.length(); i++) {
		    char color = input.charAt(i);
		    if (color == 'W') {
		        result += (i - currentWhite);
		        currentWhite++;
		    }
		}
		System.out.println(result);
    }
}

Measured memory_bytes: 28144
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

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

  int n; cin >> n;
  vector<int> d(n); rep(i, n) cin >> d[i];
  sort(all(d));

  int h = n / 2;
  int x = d[h - 1];
  int y = d[h];

  print(y - x);

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

vector<pair<char,int>> RunLengthEncoder_ForString(string v){
    vector<pair<char,int>> RLE;
    int cnt = 1;
    for(int i = 0; i < (int)v.size(); ++i){
        if(i == (int)v.size()-1){
            RLE.push_back(make_pair(v[i], cnt));
            continue;
        }
        if(v[i] == v[i+1])cnt++;
        else{
            RLE.push_back(make_pair(v[i],cnt));
            cnt = 1;
        }
    }
    return RLE;
}

int main() {
    int N,K;
    string S;
    cin>>N>>K;
    cin>>S;
    auto T = RunLengthEncoder_ForString(S);
    ll ans = 0;
    rep(i,(int)T.size()){
        ans += T[i].second-1;
    }
    ans = min((ll)N-1,ans + 2 * K);
    cout<<ans<<endl;
}

Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll a,b,k;
	cin>>a>>b>>k;
	cout<<a-min(a,k)<<" "<<max(0ll, b-max(k-a,0ll));
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <vector>
int dfs(int start, vector<vector<int>> &edges, vector<int> &dp){
  if(dp[start]!=-1){
   return dp[start];
  }
  int ans=0;
  for(int i=0;i<edges[start].size();i++){
         ans=max(ans,dfs(edges[start][i],edges,dp)+1);
  	}
  dp[start]=ans;
  return ans;
  
}
int main() {
	// your code goes here
  int n,m;
  cin>>n>>m;
  vector<vector<int>> edges (n+1);
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    edges[x].push_back(y);
    
  }
  int ans=0;
  vector<int> dp (n+1 , -1);
  for(int i=1;i<=n;i++){
    
  ans=max(ans,dfs (i,edges,dp));  
  }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11876
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 7 * 17 * (1 << 23) + 1;
const ll inf = 1e18;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a, b;
	cin >> a >>b;
	if(a>9||b>9) return cout << -1, 0;
	cout << a*b;
}


Measured memory_bytes: 256
program main
  implicit none
  integer(8) :: n, sni
  read(*, *) n
  sni = nint(n ** 0.5_8)
  if (sni ** 2 <= n) then
    write(*, "(i0)") sni ** 2
  else
    write(*, "(i0)") (sni - 1) ** 2
  end if
end program main


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll ans1,ans2;
int main(void){
    ll n; cin>>n;
    ans1=n;
    ans2=1;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            ans1=i;
            ans2=n/i;
        }
    }
    cout<<ans1+ans2-2<<endl;
    
}


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

using namespace std;

const int N = 1e5+5;

int n;
int a[N];
int b[N];
int c[N];

int main(){
    scanf("%d " , &n);
    for(int i = 1; i <= n; i++)
        scanf(" %d" , &a[i]);
    for(int i = 1; i <= n; i++)
        scanf(" %d" , &b[i]);
    for(int i = 1; i <= n; i++)
        scanf(" %d" , &c[i]);


    sort(a + 1 , a + n + 1);
    sort(c + 1 , c + n + 1);
    long long ans = 0;
    for(int i = 1; i <= n; i++){
        int mid = b[i];

        auto it = lower_bound(a + 1 , a + n + 1 , mid) - a - 1;
        auto jt = n - (upper_bound(c + 1 , c + n + 1 , mid) - c) + 1;

        //cout << it << " " << jt << "\n";
        ans += 1LL * it * jt;
    }
    printf("%lld\n" , ans);
}
/*
    1 2 2 2 3 4 5

    4

    11 - 6 = 5
    1 2 3 4 5 6 7 8 9 10 11
    2 2 3 3 4 5 5 5 6 6 7
*/



Measured memory_bytes: 4992
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long people = sc.nextLong();
		long minCapacity = 0;
		for (int i = 0; i < 5; i++) {
			long capacity = sc.nextLong();
			if (minCapacity == 0) {
				minCapacity = capacity;
			} else {
				if (minCapacity > capacity) {
					minCapacity = capacity;
				}
			}
		}
		if (people <= minCapacity) {
			System.out.println(5);
		} else {
			if (people % minCapacity == 0) {
				long count = people / minCapacity + 4;
				System.out.println(count);
			} else {
				long count = people / minCapacity + 5;
				System.out.println(count);
			}
		}
		sc.close();
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
int main(){
    int h,w;
    scanf("%d %d",&h,&w);
    int i;
    for(i=1;i<=h;i++){
        char s[w];
        scanf("%s\n",s);
        printf("%s\n",s);
        printf("%s\n",s);
    }
    return 0;
}


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

int main(){
	int N;
	cin >> N;
	int a[100];
	bool ans = true;
	for(int i=0;i < N;i++){
		cin >> a[i];
		if(a[i]%2 ==0&&a[i]%3 !=0&&a[i]%5!=0){
			ans = false;
		}
		
	}

	if(ans ){
		cout << "APPROVED" << endl;
	}
	else{
		cout << "DENIED" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N;
  cin >> N;
  string S;
  cin >> S;
  int count = 0;
  int x = 0;
  rep(i, S.size())
  {

    if (S.at(i) == 'I')
    {
      count++;
    }
    else
    {
      count--;
    }
    x = max(x, count);
  }
  cout << x << endl;
  return 0;
}

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

int main()
{
  int n;
  cin >> n;
  bool z = false;

  vector<int64_t> a(n);
  for (auto&& e : a) {
    cin >> e;
    if (e == 0) z = true;
  }

  if (z) {
    cout << 0 << endl;
    return 0;
  }

  int64_t ans = 1;
  const int64_t c = 1'000'000'000'000'000'000;

  for (int i = 0; i < n; i++) {
    if (log(ans) + log(a[i]) - log(c) - 0.01 < 0) {
      ans *= a[i];
      if (ans > c) {
        ans = -1;
        break;
      }
    } else {
      ans = -1;
      break;
    }
  }
  cout << ans << endl;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};



int main()
{
  string s; cin >> s;
  reverse(ALL(s));
  int n = s.size();
  rep(i, n) {
    if(s[i] == 'r') {
      if(s.substr(i, 6) == "resare") {
        i+=5;
        continue;
      }
      else if(s.substr(i, 7) == "remaerd") {
        i += 6;
        continue;
      }
      else {
        cout << "NO" << endl;
        return 0;
      }
    }
    else if(s.substr(i, 5) == "esare" || s.substr(i, 5) == "maerd") {
      i += 4;
      continue;
    }
    else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 3692
n, a, b = map(int, input().split())
s = str(input())
pass_cnt = 1
kaigai = 0
for i in range(n):
    if(s[i] == "c"):
        # print("No", " それ以外")
        print("No")
    elif(pass_cnt <= (a+b)):
        if(s[i] == "a"):
            # print("Yes", " a pass_cnt= ", pass_cnt)
            print("Yes")
            pass_cnt += 1
        else:
            kaigai += 1
            if(kaigai <= b):
                # print("Yes", " b kaigai= ", kaigai)
                print("Yes")
                pass_cnt += 1
            else:
                print("No")
    else:
        print("No")


Measured memory_bytes: 70680
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import defaultdict
from math import gcd

n = int(readline())
data = list(map(int,read().split()))
mod = 1000000007

it = iter(data)
a_b = defaultdict(lambda :[0,0])
a0 = 0
b0 = 0
ab0 = 0
ans = 0
for a,b in zip(it,it):
    if(a==b==0):
        ab0 += 1
        continue
    if(a*b==0):
        if(a==0):
            a0 += 1
        if(b==0):
            b0 += 1
    else:
        if(a/b > 0):
            a = abs(a)
            b = abs(b)
            gcd_num = gcd(a,b)
            a_b[(a//gcd_num,b//gcd_num)][0] += 1
        else:
            a = abs(a)
            b = abs(b)
            gcd_num = gcd(a,b)
            a_b[(b//gcd_num,a//gcd_num)][1] += 1

exp2 = [1] * (n+1)
for i in range(n):
    exp2[i+1] = exp2[i] * 2
    exp2[i+1] %= mod


ans += (ans+1) * ( exp2[a0]-1  + exp2[b0]-1)
ans %= mod

for key,val in a_b.items():
    ans += (ans+1) * ( exp2[val[0]]-1  + exp2[val[1]]-1)
    ans %= mod

ans += ab0
ans %= mod

print(ans)

Measured memory_bytes: 159512
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m = list(map(int, input().split()))
ab = [tuple(map(int, input().split())) for _ in range(m)]
from heapq import heappop as hpp, heappush as hp
h = []
for i,(a,b) in enumerate(ab):
    hp(h, (a,i,0))
ans = 0
m = -1
while h:
    val,ind,c = hpp(h)
    if c==0:
        hp(h, (ab[ind][1],ind,1))
    else:
        if m>=0 and ab[ind][0]<=m<val:
            pass
        else:
            m = ab[ind][1]-1
            ans += 1
#             print(val,ind,c)
print(ans)

Measured memory_bytes: 104308
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n, m = map(int,input().split())
    A = list(map(int,input().split()))
    s = sum(A)
    cnt = 0
    for a in A:
        cnt += 4 * m * a >= s
    print("Yes" if cnt >= m else "No")
resolve()

Measured memory_bytes: 38384
s = input()
n = len(s)
interval = n - 7
flag = False
start = 0
end = interval
for i in range(n-interval):
    news = s[0:start] + s[end:]
    if news == 'keyence':
        print('YES')
        flag = True
        break
    start+=1
    end+=1
if not flag:
    print('NO')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
template <typename T> 
using lim = numeric_limits<T>;
template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using indexed_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    ll a;
    string s;
    cin >> a >> s;
    s.erase(s.find('.'),1);
    int b = stoi(s);
    cout << a*b/100 << "\n";
}

Measured memory_bytes: 3672
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int[] A = new int[3];
  sc.scan(A[0], A[1], A[2]);

  sort(A);
  reverse(A);

  int max = A[0] * 10 + A[1];

  writeln(max + A[2]);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
 
using namespace std;
 
int main(){
int A[3];
 
cin >> A[0] >> A[1] >> A[2];
 
sort(A,A+3);
 
cout << A[0]  << " "<< A[1] << " " <<A[2] << endl;
 
}


Measured memory_bytes: 3148
#include <cstdio>

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

	for (i = 1; i < n+1; i++) {
		printf("%d ", hash[i]);
	}
	return 0;
}


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

ll GCD(ll m, ll n){

    if(n==0)return m;
    ll tmp;
    while(m%n != 0){
         tmp = n;
         n = m % n;
         m = tmp;
    }
   return n;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll a[n];
    for (ll i = 0; i < n; ++i) cin >> a[i];

    ll left[n] = {0};
    ll right[n] = {0};

    for(ll i = 1; i < n+1; ++i){
        left[i] = GCD(left[i-1], a[i-1]);
        right[i] = GCD(right[i-1], a[n-i]);
    }

    ll max_gcd = -1;
    for(ll i = 0; i < n; ++i){
        max_gcd = max(max_gcd, GCD(left[i], right[n-i-1]));
    }
    cout << max_gcd << endl;
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(void)
{
	int N,x,y,z,answer[10001],i;
	scanf("%d",&N);
	for(i=1;i<=N;i++){
		answer[i]=0;
	}
	for(x=1;x*x<N;x++){
		for(y=1;x*x+y*y<N;y++){
			for(z=1;x*x+y*y+z*z<N;z++){
				if(x*x+y*y+z*z+x*y+y*z+z*x<=N)answer[x*x+y*y+z*z+x*y+y*z+z*x]++;
			}
		}
	}
	for(i=1;i<=N;i++)printf("%d\n",answer[i]);
	return 0;
}

Measured memory_bytes: 1684
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    string t = s.substr(0, (s.size() - 1) / 2);
    string t2 = s.substr((s.size() + 3) / 2 - 1, s.size() - (s.size() + 3) / 2 + 1);
    int flag = 0;
    for(int i = 0; i < t.size(); i++){
        if(t[i] != t[t.size() - 1 - i]) flag = 1;
    }
    for(int i = 0; i < t2.size(); i++){
        if(t2[i] != t2[t2.size() - 1 - i]) flag = 1;
    }
    for(int i = 0; i < s.size(); i++){
        if(s[i] != s[s.size() - 1 - i]) flag = 1;
    }

    if(flag == 0) cout << "Yes" <<endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Node root = null;
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
		    String type = sc.next();
		    if (type.equals("insert")) {
		        if (root == null) {
		            root = new Node(sc.nextInt());
		        } else {
		            insert(sc.nextInt(), root);
		        }
		    } else if (type.equals("find")) {
		        if (find(sc.nextInt(), root)) {
		            sb.append("yes").append("\n");
		        } else {
		            sb.append("no").append("\n");
		        }
		    } else {
		        ArrayList<Integer> inList = new ArrayList<>();
		        ArrayList<Integer> preList = new  ArrayList<>();
		        get(root, inList, preList);
		        for (int x : inList) {
		            sb.append(" ").append(x);
		        }
		        sb.append("\n");
		        for (int x : preList) {
		            sb.append(" ").append(x);
		        }
		        sb.append("\n");
		    }
		}
		System.out.print(sb);
	}
	
	static class Node {
	    int key;
	    Node left;
	    Node right;
	    
	    public Node(int key) {
	        this.key = key;
	    }
	}
	
	static boolean find(int key, Node x) {
	    if (x == null) {
	        return false;
	    }
	    if (x.key == key) {
	        return true;
	    } else if (x.key > key) {
	        return find(key, x.left);
	    } else {
	        return find(key, x.right);
	    }
	}
	
	static void get(Node x, ArrayList<Integer> inList, ArrayList<Integer> preList) {
	    preList.add(x.key);
	    if (x.left != null) {
	        get(x.left, inList, preList);
	    }
	    inList.add(x.key);
	    if (x.right != null) {
	        get(x.right, inList, preList);
	    }
	}
	
	static void insert(int key, Node x) {
	    if (x.key > key) {
	        if (x.left == null) {
	            x.left = new Node(key);
	        } else {
	            insert(key, x.left);
	        }
	    } else {
	        if (x.right == null) {
	            x.right = new Node(key);
	        } else {
	            insert(key, x.right);
	        }
	    }
	}
}



Measured memory_bytes: 208208
#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 2e5 + 123;	
int n , m ,  k;
int op[N] , val[N];
vector < int > gr[N];
void dfs(int v , int par = -1 , int x = 0){
	x += op[v];
	val[v] = x;
	for(auto to : gr[v])
		if(to != par)
			dfs(to , v , x);
}
main(){
	
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n >> m; 
	for(int  i =1 ; i < n; i++){
		int u , v;
		cin >> u >> v;
		gr[u].pb(v);
		gr[v].pb(u);
	}
	for(int i = 1; i <= m; i++){
		int x , y;
		cin >> x >> y;
		op[x] += y;
	}
	dfs(1);
	for(int i = 1 ; i <= n; i++)
		cout << val[i] << ' ';

}

Measured memory_bytes: 23552
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{	
	string s,t;
	cin >> s;
	if (s == "Sunny") {
		t = "Cloudy";
	}
	else if (s == "Cloudy") {
		t = "Rainy";
	}
	else if(s == "Rainy"){
		t = "Sunny";
	}
	cout << t << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD1 998244353
#define MOD2 1000000007
#define INV_10 299473306
#define INF 1000000000
#define PI 3.14159265358979323846
using namespace std;
bool  b[1000005];
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n, nb=0;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a+n);
	for(int i = 0; i < n; i++)
	{
		int j=i;
		while(j < n && a[j]==a[i])
			j++;
		if(j-i > 1)
			b[a[i]]=1;
		if(!b[a[i]])
			nb++;
		for(int k = 2; k*a[i] <= 1000000; k++)
			b[k*a[i]]=true;
		i=j-1;
	}
	cout << nb << '\n';
}

Measured memory_bytes: 5416
#include<stdio.h>

int main(void)
{
  int N,K,result,i,ope1,ope2;
  result=1;

  scanf("%d",&N);
  scanf("%d",&K);

  for(i=0;i<N;i++){
    ope1=result*2;
    ope2=result+K;
    if(ope1>ope2)
      result=ope2;
    else
      result=ope1;
  }
  printf("%d\n",result);

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,q;
  cin>>n>>q;
  while(q--){
    int a,b;
    cin>>a>>b;
    a--;b--;
    if(n==1){
      cout<<min(a+1,b+1)<<endl;
      continue;
    }
    while(a!=b){
      while(a>b){
        a=(a-1)/n;
      }
      while(a<b){
        b=(b-1)/n;
      }
    }
    cout<<a+1<<endl;
  }



}

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

using Graph=vector<vector<int>>;
using ll=long long;
const int INF=1e9;
int main(){
    int n,m;
    int abc[3];
    cin>>n>>m>>abc[0]>>abc[1]>>abc[2];
    Graph g(n);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        u--,v--;
        g[u].push_back(v);
    }
    vector<int> d(n,INF);
    d[n-1]=0;
    for(int loop=0;loop<n;loop++){
        vector<int> dnext=d;
        for(int x=0;x<n;x++){
            if(d[x]<INF) continue;
            for(int i=0;i<3;i++){
                vector<vector<int>> used(n,vector<int>(abc[i]+1));
                function<bool(int,int)> dfs=[&](int v,int rest){
                    if(rest==0) return d[v]<INF;
                    if(used[v][rest]) return false;
                    used[v][rest]=true;
                    for(int to:g[v]) if(dfs(to,rest-1)) return true;
                    return false;
                };
                if(!dfs(x,abc[i])) break;
                if(i==2){
                    dnext[x]=loop+1;
                }
            }
        }
        d=dnext;
    }
    if(d[0]>=INF){
        cout<<"IMPOSSIBLE"<<endl;
    }
    else{
        cout<<d[0]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3180
# coding: utf-8


def main():

    seiji_numbers_list = list(map(int, input().split(' ')))
    
    if (len(seiji_numbers_list) - len(set(seiji_numbers_list))) == 1:
        print('Yes')
    else:
        print('No')

    return 0


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <cstdio>
#include <algorithm>

using namespace std;

namespace io
{
	const int maxb = 1 << 15;
	char b[maxb], *s = b, *t = b;
	bool Getchar(char &ch)
	{
		return ch = s == t && (t = (s = b) + fread(b, 1, maxb, stdin)) == b ? 0 : *s ++;
	}
}

int Getint()
{
	using namespace io;
	char ch;
	while (Getchar(ch) && (ch < '0' || ch > '9'));
	int s = ch - '0';
	while (Getchar(ch) && ch >= '0' && ch <= '9')
		s = s * 10 + ch - '0';
	return s;
}

const int maxn = 1e5 + 10;

int x[maxn];

int main()
{
	int N = Getint(), L = Getint(), T = Getint();
	int t = T / L;
	T %= L;
	int sa = Getint(), sw = Getint();
	int sx = x[0] = sw & 1 ? (sa + T) % L : (sa + L - T) % L;
	int del = 0;
	if (sw & 1)
	{
		for (int i = 1; i < N; ++ i)
		{
			int a = Getint(), w = Getint();
			x[i] = w & 1 ? (a + T) % L : (a + L - T) % L;
			if (w == sw) continue;
			a -= sa;
			del += T * 2 > a;
			del += T * 2 > a + L;
			del += 2 * t;
		}
	}
	else
	{
		for (int i = 1; i < N; ++ i)
		{
			int a = Getint(), w = Getint();
			x[i] = w & 1 ? (a + T) % L : (a + L - T) % L;
			if (w == sw) continue;
			a = L - (a - sa);
			del += T * 2 >= a;
			del += T * 2 >= a + L;
			del += 2 * t;
		}
		del = -del;
	}
	sort(x, x + N);
	int pos;
	for (int i = 0; i < N; ++ i)
		if (x[i] == sx)
		{
			pos = i;
			break;
		}
	pos = ((pos - del) % N + N) % N;
	for (int i = pos; i < N; ++ i) printf("%d\n", x[i]);
	for (int i = 0; i < pos; ++ i) printf("%d\n", x[i]);
	return 0;
}


Measured memory_bytes: 1536
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>

using namespace std;

int main() {
	int n;
	while (cin >> n&&n != 0) {
		vector<int> milk;
		int a;
		for (int i = 0; i < n; i++) {
			cin >> a;
			milk.emplace_back(a);
		}
		sort(milk.begin(), milk.end());
		long long j[10001];
		j[0] = 0;
		for (int i = 1; i < n; i++) {
			j[i] = milk[i-1] + j[i - 1];
		}
		long long ans = 0;
		for (int i = 0; i < n; i++) {
			ans += j[i];
		}
		cout << ans << endl;
	}
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N), b(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i] >> b[i];
    }
    int count = 1;
    int flag = 0;
    for (int i = 0; i < N - 1; i++)
    {
        if (a[i] == b[i] && a[i + 1] == b[i + 1])
        {
            count++;
        }
        else
        {
            count = 1;
        }
        if (count >= 3)
        {
            flag = 1;
        }
    }
    if (flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 2992
n = int(input())
b = list(map(int, input().strip().split()))


num = 0
for j in range(100):
    count = 0
    for i in range(n):
        if b[i] % 2 == 0:
            count = 1 + count


    if count == n:
        b = [c/2 for c in b]
        num = 1 + num

print(num)

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

int main(){
  long long int n,m;
  cin >> n >> m;
  long long int c=n/m;
  long long int d=(n+m/2)/m;
  if(m%2==1){
    cout << c*c*c << endl;
  }
  else{
    cout << c*c*c+d*d*d << endl;
  }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main()
{
    ll n, m;
    cin >> n >> m;
    ll ans;
    if (n >= 2 && m >= 2) {
        ans = (n - 2) * (m - 2);
    } else {
        ans = max(n - 2, 1LL) * max(m - 2, 1LL);
    }
    cout << ans << endl;
    return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))

int compare_int(const void *a,const void *b){
	return *(long long*)a-*(long long*)b;
}

int main(){
	int n,i;
	long long a[100000],ans=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%lld",&a[i]);
	qsort(a,n,sizeof(long long),compare_int);
	if(n%2==0){
		for(i=0;i<n;i++){
			if(i<n/2){
				if(i==n/2-1)ans-=a[i];
				else ans-=2*a[i];
			}
			else{
				if(i==n/2)ans+=a[i];
				else ans+=2*a[i];
			}
		}
	}else{
		long long ans2=0;
		for(i=0;i<n;i++){
			if(i<n/2){
				ans-=2*a[i];
			}
			else{
				if(i<=n/2+1)ans+=a[i];
				else ans+=2*a[i];
			}
		}
		for(i=0;i<n;i++){
			if(i<=n/2){
				if(i>=n/2-1)ans2-=a[i];
				else ans2-=2*a[i];
			}
			else{
				ans2+=2*a[i];
			}
		}
		ans=max(ans,ans2);
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    map<string, int> m;
    int N, M;
    cin >> N;
    for(int i = 0; i < N; i++){
        string s; cin >> s;
        if(m.find(s) == m.end()) m[s] = 1;
        else m[s] += 1;
    }
    cin >> M;
    for(int i = 0; i < M; i++){
        string s; cin >> s;
        if(m.find(s) == m.end()) m[s] = -1;
        else m[s] -= 1;
    }

    int res = 0;
    for(auto x: m) res = max(res, x.second);
    cout << res << '\n';
    return 0;

}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int x,y,box;
	scanf("%d %d",&x,&y);
	
	for(;;){
		if(x%y==0) break;//yが最大公約数
		box=x%y;//ユークリッドの互除法
		x=y;
		y=box;
	}
	printf("%d\n",y);
	
	return 0;
}


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

using namespace std;

int main(){
  int a;
  int b;
  cin >> a >> b;
  char s[a];
  char t[b];
  for(int i=0;i<a;i++){
    s[i]= '0'+b;
  }
  for(int i=0;i<b;i++){
    t[i]= '0'+a;
  }
  if(strcmp(s,t) <= 0){
    for(int i=0;i<a;i++){
      cout << s[i];
    }
    cout << endl;
  }
  else{
    for(int i=0;i<b;i++){
      cout << t[i];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque



def divisor(n): #nの約数を全て求める
    i = 1
    table = set()
    while i * i <= n:
        if n%i == 0:
            table.add(i)
            table.add(n//i)
        i += 1
    return table

def main():
    num_a, num_b = map(int, input().split())
    yakusuu_a = divisor(num_a)
    yakusuu_b = divisor(num_b)

    yakusuu = yakusuu_a & yakusuu_b
    yakusuu = list(yakusuu)
    yakusuu.sort()
    ans = set()
    for ele in yakusuu:
        for ele2 in ans:
            if ele2 == 1:
                continue
            if ele % ele2 == 0:
                break
        else:
            ans.add(ele)

    print(len(ans))




if __name__ == '__main__':
    main()


Measured memory_bytes: 40684