akhauriyash/Code-Regression huggingface dataset:
n, m = [int(i) for i in input().split()]
city = []
pref = [0 for i in range(n)]
for i in range(m):
    p, y = [int(_) for _ in input().split()]
    pref[p-1] += 1
    city.append([p,y,i])

city.sort(key = lambda x: (x[0], x[1]))
cnt = 1
for i in range(m):
    city[i].append(cnt)
    if cnt == pref[city[i][0]-1]:
        cnt = 1
    else:
        cnt += 1
city.sort(key = lambda x: x[2])
for i in range(m):
    print(str(city[i][0]).zfill(6)+str(city[i][3]).zfill(6))

Measured memory_bytes: 36272
def all_same(a):
    return all([x==a[0] for x in a])

def gcd(a,b):
	if b==0:
		return a
	else:
		return gcd(b,a%b)

def primechecker(x):
	original=x
	primefactorization=set()
	for i in range (2,int(original**0.5)+1):
		while x%i==0:
			primefactorization.add(i)
			x=x//i
	if x>1:
		primefactorization.add(x)
	return primefactorization

primefactors=set()

N=int(input())
array=[int(x) for x in input().split()]
checklist=[]
totality=0

def pairwisecoprime(array):
	for i in array:
		for j in primechecker(i):
			if j in primefactors:
				return 0
			else:
				primefactors.add(j)
	return 1
if pairwisecoprime(array):
	print("pairwise coprime")
	exit()




for i in array:
	totality=gcd(totality,i)

if totality==1:
	print("setwise coprime")
else:
	print("not coprime")

Measured memory_bytes: 181724
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;
const ll inf = 1001001001;
const ll mod = 1000000007;

int main() {
 int n;
 cin >> n;
 ll ans1, ans2;
 vector<ll>a(n);
 vector<ll>b(n);
 rep(i, 0, n){
     cin >> a[i];
     b[i] = a[i]*2;
 }
 sort(a.begin(), a.end(), greater<ll>());
 sort(b.begin(), b.end(), greater<ll>());
 ans1 = a[0];
 ll dist = inf;
 rep(i, 1, n){
     ll tempdist = dist;
     dist=min(abs(a[i]*2-ans1), dist);
     if(tempdist > dist)ans2 = a[i];
 }
 cout << ans1 << " " <<  ans2 << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<list>
#include<vector>
#include<cmath>
#include<array>

using ll = long long;
using namespace std;

struct node_t{
    int to;
    ll cost;
};

vector<node_t> node[100000];
ll ans[100000];



void dfs(int v, int p, ll d){
    ans[v] = d;
    for(auto &e : node[v]){
        if(e.to==p)continue;
        dfs(e.to, v, d+e.cost);
    }
}

int main(void){

    int n;
    cin >> n;

    for(int i=0;i<n-1;i++){
        int from, to, d;
        cin >> from >> to >> d;
        from--; to--;

        node[from].push_back({to,d});
        node[to].push_back({from, d});
    }

    int q, k;
    cin >> q >> k;
    k--;

    dfs(k,-1,0);

    for(int i=0;i<q;i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << ans[x]+ans[y] << endl;
    }

    return 0;
}


Measured memory_bytes: 14336
def m():
    s = str(input())
    d = ["dream", "dreamer"]
    e = ["erase", "eraser"]
    i = len(s)
    while i >= 5:
        if s[i-5:i] == d[0]:
            i -= 5
            continue
        if s[i-5:i] == e[0]:
            i -= 5
            continue
        if s[i-7:i] == d[1]:
            i -= 7
            continue
        if s[i-6:i] == e[1]:
            i -= 6
            continue
        return "NO"
    return "YES"

print(m())

Measured memory_bytes: 3188
#include<stdio.h>
 
int main(void){
  int i,j,s,n,m;
  static int a[100][100],b[100],c[100];
 
  scanf("%d%d",&n,&m);
 
  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      scanf("%d",&a[i][j]);
 
  for(i=0;i<m;i++)
    scanf("%d",&c[i]);
 
  for(i=0;i<n;i++){
    s = 0;
    for(j=0;j<m;j++)
      s += a[i][j] * c[j];
    printf("%d\n",s);
  }
   
  return 0;
}


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

using namespace std;

using ll = long long int;
using vi = vector<int>;
using vvi = vector<vi>;

#define _LIBCPP_DEBUG 0
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
	int N, ans=0, min=9999999;
	cin >> N;

	int line[N];
	for (int i=0; i<N; i++) cin >> line[i];
	
	for (int p=0; p<101; p++) {
		for (int i=0; i<N; i++) {
			ans += pow(abs(line[i]-p), 2);
		}
		if (min > ans) min = ans;
		ans = 0;
	}

	cout << min << endl;
	return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
	vector<int> num(3);
	cin >> num[0] >> num[1] >> num[2];
	sort(num.begin(), num.end());

	COUT(num[0] + num[1]);

	return 0;
}

Measured memory_bytes: 256
def factorize(n):
    fct = []
    
    for i in range(2, int(n**0.5)+1):
        c = 0
        
        while n%i==0:
            n //= i
            c += 1
            
        if c>0:
            fct.append((i, c))
    
    if n>1:
        fct.append((n, 1))
    
    return fct
    
MAX = 10**5+100
MOD = 10**9+7
fact = [0]*MAX #fact[i]: i!
inv = [0]*MAX #inv[i]: iの逆元
finv = [0]*MAX #finv[i]: i!の逆元
fact[0] = 1
fact[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1
    
for i in range(2, MAX):
    fact[i] = fact[i-1]*i%MOD
    inv[i] = MOD-inv[MOD%i]*(MOD//i)%MOD
    finv[i] = finv[i-1]*inv[i]%MOD

def C(n, r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fact[n]*(finv[r]*finv[n-r]%MOD)%MOD

N, M = map(int, input().split())
fct = factorize(M)
ans = 1

for _, c in fct:
    ans *= C(N-1+c, c)
    ans %= MOD

print(ans)

Measured memory_bytes: 68100
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,cnt=0;
  string s;
  cin >> n >> s;
  for(int i=0;i<1000;i++){
    int a[3]={i/100,(i/10)%10,i%10};
    int k=0;
    for(int l=0;l<n;l++){
      if(s[l]-48==a[k]) k++;
      if(k==3){
        cnt++;
        break;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
    ll n,m,k,ans=0;
    cin>>n>>m>>k;
    
    vll a(n),b(m),c(n+1,k+1);
    rep(i,n)cin>>a.at(i);
    rep(i,m)cin>>b.at(i);
    c.at(0)=0;
    ll t=0,book=0;
    rep(i,n){
        t+=a.at(i);
        if(t>k)break;
        book++;
        c.at(book)=t;
    }
    
    ans=upper_bound(ALL(c),k)-c.begin()-1;
   
    book=0;
    t=0;
    rep(i,m){
        ll t2,book2;
        t+=b.at(i);
        book++;
        if(t>k)break;
        t2=k-t;
        book2=upper_bound(ALL(c),t2)-c.begin()-1;
        //cout<<book2<<endl;
        ans=max(ans,book+book2);
    }
    
    cout<<ans<<endl;
    
}



Measured memory_bytes: 8020
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  char s[4];
  rep(i,4){
    cin>>s[i];
  }
  bool a,b;
  if( (s[0]=='1'&&s[1]<='2')||(s[0]=='0'&&s[1]>='1')){
    a=1;
  }else{
    a=0;
  }
  if( (s[2]=='1'&&s[3]<='2')||(s[2]=='0'&&s[3]>='1')){
    b=1;
  }else{
    b=0;
  }
  if(a==1&&b==1){
    cout<<"AMBIGUOUS"<<endl;
  }
  else if(a==1&&b==0){
    cout<<"MMYY"<<endl;
  }
  else if(a==0&&b==1){
    cout<<"YYMM"<<endl;
  }
  else{
    cout<<"NA"<<endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main() {
	int x, y, z;
	int s, ans;
	scanf("%d %d", &x, &y);
	ans = 0;
	f(i, x)ans += (y + i);
	if (y > 0)ans -= y;
	else if ((x + y - 1) < 0)ans -= (x + y - 1);


	printf("%d\n", ans);


	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.lang.*;


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

        int[] A = new int[N], S = new int[N];
        for(int n=0; n<N; n++){
            A[n] = sc.nextInt();
            S[n] = A[n];
        }
        Arrays.sort(S);
        
        for(int n=0; n<N; n++){
            if(A[n] == S[N-1]) System.out.println(S[N-2]);
            else System.out.println(S[N-1]);
        }
    }
}


Measured memory_bytes: 93948
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

const int sz = 110;
const int pmax = 11;
bool visit[sz][sz][pmax][pmax][4];

#define PUSH(r, c, p, q, d) do{                 \
    r_que.push(r);                              \
    c_que.push(c);                              \
    d_que.push(d);                              \
    p_que.push(p);                              \
    q_que.push(q);                              \
    visit[r][c][p][q][d] = true;                \
  }while(0)                                     \

int main(){
  int N, M, P;
  cin >> N >> M >> P;
  vector<string> F(N + 2, string(M + 2, '#'));

  queue<int> r_que;
  queue<int> c_que;
  queue<int> d_que;
  queue<int> p_que;
  queue<int> q_que;
  
  
  int dr[4] = {1, 0, -1, 0};
  int dc[4] = {0, -1, 0, 1};
  int pm[4] = {3, 2, 1, 0};     // /
  int qm[4] = {1, 0, 3, 2};     // ＼
  memset(visit, false, sizeof(visit));
  
  REP(i, N)REP(j, M){
    cin >> F[i+1][j+1];
    if(F[i+1][j+1] == 'S') PUSH(i+1, j+1, P, P, 0);
  }

  int res = INF;
  while(!r_que.empty()){
    int r = r_que.front(); r_que.pop();
    int c = c_que.front(); c_que.pop();
    int d = d_que.front(); d_que.pop();
    int p = p_que.front(); p_que.pop();
    int q = q_que.front(); q_que.pop();
    
    if(F[r][c] == 'G') res = min(res, 2 * P - p - q);
    
    int r2 = r + dr[d];
    int c2 = c + dc[d];
    
    
    if(F[r2][c2] != '#' && !visit[r2][c2][p][q][d]){
      if(F[r2][c2] != 'S' || d != 2){
        PUSH(r2, c2, p, q, d);
      }
    }
      
    if(F[r2][c2] == '.' && p > 0 && !visit[r2][c2][p-1][q][pm[d]]){
      PUSH(r2, c2, p-1, q, pm[d]);
    }
    
    if(F[r2][c2] == '.' && q > 0 && !visit[r2][c2][p][q-1][qm[d]]){
      PUSH(r2, c2, p, q-1, qm[d]);
    }
  }
  
  cout << (res == INF ? -1 : res) << endl;
  return 0;
}

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

int main() {
  int n, i, j, cnt = 0;
  cin >> n;
  int *a = new int[n+1];
  bool *c = new bool[n+1];
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    c[i] = false;
  }
  c[1] = true; c[0] = false;
  i = 1;
  
  while (1) {
    i = a[i];
    if (c[i]) {
      cout << -1 << endl;
      delete[] a;
      return 0;
    }
    c[i] = true;
    cnt++;
    if (i == 2) {
      cout << cnt << endl;
      delete[] a;
      return 0;
    }
  }
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
//ate
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }

int main() {
    init();

    int n; string s; cin >> n >> s;
    for (char c : s) {
        int a = (c - 'A' + n) % 26;
        cout << char('A' + a);
    }
    cout << "\n";
}


Measured memory_bytes: 256
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
#include <list>
#include<numeric>
//AtCoderC++.cpp

using namespace std;


inline int ceileing(int a, int b) {return a % b == 0 ? a / b : a / b + 1;}
int main() {
	int A, B, C; cin >> A >> B >> C;
	cout << (A <= C && C <= B ? "Yes" : "No") << endl;
}


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

using namespace std;
int n,x,a[104],s[104];
int main()
{
    //freopen("B.inp","r",stdin);
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> n >> x;
    for (int i=1;i<=n;i++)
    {
        cin >> a[i];
        s[i]=s[i-1]+a[i];
        if (s[i]>x)
        {
            cout << i;
            return 0;
        }
    }
    cout << n+1;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  vector<string> S(n);
  vi T(n);
  rep(i,n){
    cin>>S[i]>>T[i];
  }
  string x; cin>>x;
  ll ans=0;
  bool flg=false;
  rep(i,n){
    if(flg)ans+=T[i];
    if(S[i]==x)flg=true;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string.h>
#include<vector>
using namespace std;

unsigned long long  i,j,k,h,w,a,b,c,d,x,y,z,ret=0;
int main(void){
  char s[5];
	cin>>s[0]>>s[1]>>s[2]>>s[3];
	if(strchr(s,'1')&&strchr(s,'9')&&strchr(s,'7')&&strchr(s,'4'))cout<<"YES";
  else cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
package main

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

const MAX = 100000

var sc = bufio.NewScanner(os.Stdin)

func read() int {
	sc.Scan()
	num, _ := strconv.Atoi(sc.Text())
	return num
}

func splitElements() []int {
	var list []int
	sc.Scan()
	if err := sc.Err(); err != nil {
		fmt.Printf("Scanner error: %q\n", err)
	}
	for _, v := range strings.Split(sc.Text(), " ") {
		num, _ := strconv.Atoi(v)
		list = append(list, num)
	}
	return list
}

func partition(A []int, p int, r int) int {
	x := A[r]
	i := p - 1
	for j := p; j < r; j++ {
		if A[j] <= x {
			i++
			A[i], A[j] = A[j], A[i]
		}
	}
	A[i+1], A[r] = A[r], A[i+1]
	return i + 1
}

func main() {
	var A []int
	// n := read()
	var n int
	fmt.Scan(&n)
	// A := splitElements()
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		//	fmt.Println(a, i)
		A = append(A, a)
	}

	q := partition(A, 0, n-1)

	for i, v := range A {
		if i != 0 {
			fmt.Print(" ")
		}
		if i == q {
			fmt.Print("[")
		}
		fmt.Print(v)
		if i == q {
			fmt.Print("]")
		}
	}
	fmt.Println()
}



Measured memory_bytes: 6048
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 03/28/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int X,Y,A,B,C; cin>>X>>Y>>A>>B>>C;
  vector<int> p(A),q(B),r(C);
  for (auto& v:p) cin>>v;
  for (auto& v:q) cin>>v;
  for (auto& v:r) cin>>v;

  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  vector<int> pq;
  for (int i = 0; i < X; i++)
    pq.push_back(p[i]);
  for (int i = 0; i < Y; i++)
    pq.push_back(q[i]);
  for (auto v : r)
    pq.push_back(v);
  sort(pq.rbegin(), pq.rend());
  ll ans = accumulate(pq.begin(), pq.begin()+X+Y, 0ll);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template<typename T> using vv = vector<vector<T>>;

ll N;
vector<ll> A;

const ll MOD = 998244353;
ll mod(ll x) {
    return x % MOD;
}

void input() {
    cin >> N;
    A.resize(N);
    for (auto& a : A)
        cin >> a;
}

ll solve() {
    ll sum = 0;
    for (auto a : A)
        sum += a;
    
    vector<ll> dp(sum+1, 0);
    dp[0] = 1;
    for (ll t = 0; t < N; t++) {
        auto a = A[t];
        for (ll n = sum; n >= a; n--)
            dp[n] = mod(mod(dp[n]*2) + dp[n-a]);
        for (ll n = a-1; n >= 0; n--)
            dp[n] = mod(dp[n]*2);
    }
    
    ll pat = 0;
    for (ll n = (sum+1)/2; n <= sum; n++) {
        pat = mod(pat + dp[n]);
    }
    
    if (sum % 2 == 0 and dp[sum/2] > 0) {
        dp.assign(sum+1, 0);
        dp[0] = 1;
        for (ll t = 0; t < N; t++) {
            auto a = A[t];
            for (ll n = sum; n >= a; n--)
                dp[n] = mod(dp[n] + dp[n-a]);
            for (ll n = a-1; n >= 0; n--)
                dp[n] = dp[n];
        }
        
        pat = mod(pat + MOD - dp[sum/2]);
    }
    
    ll ans = 1;
    for (ll i = 0; i < N; i++) {
        ans = mod(ans * 3);
    }
    ans = mod(ans + MOD - mod(pat * 3));
    return  ans;
}

int main() {
    input();
    cout << solve() << endl;
    
    return 0;
}



Measured memory_bytes: 896
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int t;
    cin >> t;
    int div[3] = {2, 3, 5};
    while(t--) {
        ll n, a, b, c, d;
        cin >> n >> a >> b >> c >> d;
        ll costt[3] = {a, b, c};
        queue<P> q;
        q.push(P(n, 0));
        map<ll, ll> mp;
        mp[n] = 0;
        ll ans = LINF;
        while(!q.empty()) {
            ll now, cost;
            tie(now, cost) = q.front();
            q.pop();
            if(mp[now] != cost) continue;
            rep(i, 3) {
                rep(j, 2) {
                    ll num = now/div[i] + j;
                    if(!num) continue;
                    ll cost_ = cost + costt[i] + abs(now-(num*div[i]))*d;
                    //cout << now << ' ' << num << ' ' << cost_ << endl;
                    if(mp.count(num) and mp[num] <= cost_) continue;
                    mp[num] = cost_;
                    
                    q.push(P(num, cost_));
                }
            }
            if(log10(d) + log10(now) < 14) {
                ans = min(ans, cost + now*d);
            }
        }
        for(P x:mp) {
            //cout << x.first << ' ' << x.second << endl;
        }
        cout << ans << '\n';
    }
}

Measured memory_bytes: 4912
#include<iostream>
#include<vector>
#include<string.h>
using namespace std;

int seiyaku_check(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	
	int a,b;
	cin >> a >> b;
	seiyaku_check(a,1,9);
	seiyaku_check(b,1,9);
	
	string s,t;
	for(int i=0;i<b;i++){
		s += to_string(a);
	}
	
	for(int i=0;i<a;i++){
		t += to_string(b);
	}
	
	if(s<=t)cout << s << endl;
	else cout << t << endl;
	
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
#define MAX_N 2000000
int pr[MAX_N];

map<int,int> prime_factor(int m){
  map<int,int> rtn;
  for(int i=2;i*i<=m;i++){
    while(!(m%i)){
      ++rtn[i];
      m/=i;
    }
  }
  if(m!=1) rtn[m]=1;
  return rtn;
}

int main(){
  int n;cin>>n;
  REP(i,n){
    int tmp;cin>>tmp;
    map<int,int> mp=prime_factor(tmp);
    for(auto p:mp) pr[p.first]++;
  }
  REP(i,MAX_N) if(pr[i]==n){
    cout<<"not coprime";
    return 0;
  }
  REP(i,MAX_N) if(pr[i]>1){
    cout<<"setwise coprime";
    return 0;
  }
  cout<<"pairwise coprime";
}

Measured memory_bytes: 7508
#!/usr/bin/env python3
# -*- Coding: utf-8 -*-

import sys
import math


input = sys.stdin.readline


def main():
    a, b, x = [int(i) for i in input().split()]

    if (a*a*b)/2 < x:
        n = (a*b-x/a)*2/a
        print(math.degrees(math.atan(n/a)))

    elif (a*a*b)/2 > x:
        n = x*2/a/b
        print(math.degrees(math.atan(b/n)))
    else:
        print(45.0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
n, m = map(int, input().split())
a = 1
b = 1
if abs(n-m) >= 2:
    print(0)
else:
    for i in range(2, n+1):
        a = (a*i) % (10**9+7)
    for j in range(2, m+1):
        b = (b*j) % (10**9+7)
    if n == m:
        print((a*b*2) % (10**9+7))
    else:
        print((a*b) % (10**9+7))

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define EPS 1e-9
#define INF 5e18
#define MOD 1000000007

#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int N;
long long arr [1000010], maxi = 0, sum = 0;

int main(){
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    cin >> N;
    for(int i = 0; i < N; i++){
        long long x; cin >> x;
        maxi = max(maxi, x);
        sum += maxi-x;
    }
    cout << sum << endl;
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mem(v,x) memset(v,x,sizeof(v))
#define N 1000005

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    double pi = acos(-1);
    int r;
    cin>>r;
    cout<<setprecision(15)<<2.0*pi*r;
	return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int n, m;
int a[110];
LL dp[110][110];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i ++)
        cin >> a[i];
    memset(dp, 0x3f, sizeof(dp));
    dp[0][0] = 0;
    for(int i = 1; i <= n; i ++)
    {
        for(int j = 0; j <= n; j ++)
        {
            dp[i][j] = dp[i - 1][j];
            if(j)
                dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + a[i]);
        }
    }
    if(dp[n][n] == m)
        return cout << n << endl, 0;
    for(int i = n - 1; i; i --)
        if(dp[n][i] <= m)
            return cout << i << endl, 0;
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = 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;
}
// End of template code!
int main() 
{
    int n, k;
    cin >> n >> k; 
    vi f(n, 0);
    int x, z;
    while(cin >> x) {
        for(int j = 0; j < x; ++j) {
            cin >> z; 
            f[(z - 1)]++;
        }
    }
    int ans = 0;
    for(int i = 0; i < n; ++i) if(f[i] == 0) ans++;;
    cout << ans << endl; 
    return 0;
}



Measured memory_bytes: 3632
#include <iostream>

using namespace std;

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

    int ans = 1;
    for (int i = 0; i < m; ++i) {
        ans *= 2;
    }

    ans *= 1800 * m + 100 * n;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int N; cin >> N;
    int l[105];
    rep(i,0,N) cin >> l[i];
    int ans = 0;
    rep(i,0,N){
        rep(j,i+1,N){
            rep(k,j+1,N){
                if(l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
                if(l[i]+l[j]>l[k] && l[j]+l[k]>l[i] && l[k]+l[i]>l[j]) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
N = int(input())
A = map(int, input().split())
s = 0
ss = 0
MOD = 10 ** 9 + 7
for v in A:
    s += v
    ss += v * v
    s %= MOD
    ss %= MOD

out = s * s - ss
out %= MOD
if out % 2 == 1:
    out += MOD
out //= 2
print(out)


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

long long int gcd(long long int A,long long int B){
  if(B>A){
    long long int T;
    T = B;
    B = A;
    A = T;
  }
  if(A%B==0)return B;
  else return gcd(B,A%B);
}

int main(){
  long long int A,B;
  cin >> A >> B;
  long long int count=1;
  long long int N=gcd(A,B);
  for(int i=2;i<int(sqrt(double(N)))+1;i++){
    if(N%i==0){
      count++;
      while(N%i==0){
        N=N/i;
      }
    }
  }
  if(N!=1)count++;
  cout << count;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (void) {
    int all_takoyaki[50] = {};
    int n, num_multi = 0;
    int over_point = 0; 

    scanf("%d", &n);
    num_multi = (n * (n-1) ) / 2;

    for (int i = 0; i < n; i++) {
        scanf("%d", &all_takoyaki[i]);
        over_point += all_takoyaki[i] * all_takoyaki[i];
    }
/*
    for (int i = 0; i < n; i++) {
        printf("%d", all_takoyaki[i]);
    }
*/

    int heal_point = 0;

    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            
            heal_point += all_takoyaki[i] * all_takoyaki[j];
//            printf("%d %d %d\n", i, j, heal_point);
            //printf("%d\n", heal_point);
        }
    }
    heal_point = heal_point - over_point;
    printf("%d", heal_point);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <iomanip>
#include <algorithm>
using namespace std;

int main() {

    long long int n, a, b;
    cin >> n >> a >> b;

    if ( a < b ) swap( a, b );

    if ( ( a - b ) % 2 == 0 ) {
        cout << ( a - b ) / 2 << endl;
        return 0;
    }
    long long int ans = n;

    ans = min( b + ( a - b - 1 ) / 2, ans );
    ans = min( n - a + 1 + ( a - b - 1 ) / 2, ans );

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {
	const ll mod = 1e9 + 7;
	ll n, k;
	cin >> n >> k;

	ll ans = 0;
	repeq(i, k, n+1) {
		ll tmp = (i * (n + n - i + 1) / 2) % mod;
		tmp -= ((i * (i - 1) / 2) % mod - 1) % mod;
		if (tmp < 0) {
			tmp += mod;
		}

		ans = (ans+tmp)%mod;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<map>
using namespace std;
string a,b,s;
int A,B;
map<string,int>M;
int main(){
  while(cin>>s){
    if(A<s.size()) A=s.size(),a=s;
    if(B<++M[s])B=M[s],b=s;
  }
  cout<<b<<" "<<a<<endl;
}



Measured memory_bytes: 3000
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  a--;
  b--;
  c--;
  d--;
  string s;
  cin >> s;
  if (c < d) {
    ll flag = 1;
    rep(i, a, c) {
      if (s[i] == '#' && s[i + 1] == '#')flag = 0;
    }
    rep(i, b, d) {
      if (s[i] == '#' && s[i + 1] == '#')flag = 0;
    }
    if (flag == 1) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else {
    ll flag = 1;
    rep(i, a, c) {
      if (s[i] == '#' && s[i + 1] == '#')flag = 0;
    }
    rep(i, b, d) {
      if (s[i] == '#' && s[i + 1] == '#')flag = 0;
    }
    ll flag1 = 0;
    rep(i, b - 1, d) {
      if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.')flag1 = 1;
    }
    if (flag == 1 && flag1 == 1) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }

  }
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include <string>
#include<iomanip>
using namespace std;
int N_MAX = 10;
typedef pair<int,int> P;
int main()
{
  double r=380000;
  int n;
  cin >> n;
  string s;
  double d;
  double res=0;
  for(int i=0;i<n;i++){
    cin >> d >> s;
    if(s.compare("JPY")==0)
      res+=d;
    else
      res+=d*r;
  }
  cout << fixed << res << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //System.setIn(Main.class.getClassLoader().getResourceAsStream("input"));
        Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = sc.nextInt();
        List<List<Integer>> adjList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            adjList.add(new ArrayList<>());
        }
        Map<Edge, Integer> edgeOrder = new HashMap<>();
        for (int i = 0; i < n-1; i++) {
            int ai = sc.nextInt();
            int bi = sc.nextInt();
            edgeOrder.put(new Edge(ai-1,bi-1), i);
            adjList.get(ai-1).add(bi-1);
        }
        int k = adjList.get(0).size();
        for (int i = 1; i < n; i++) {
            k = Math.max(adjList.get(i).size()+1, k);
        }
        int[] colors = new int[n-1];
        dfs(0, adjList, 0, colors, edgeOrder);
        System.out.println(k);
        for (int color : colors) {
            System.out.println(color);
        }
    }

    static void dfs(int node, List<List<Integer>> adjList, int color, int[] colors, Map<Edge, Integer> edgeOrder) {
        List<Integer> children = adjList.get(node);
        int i = 1;
        for(int child : children) {
            if(i == color) i++;
            int order = edgeOrder.get(new Edge(node, child));
            colors[order] = i;
            dfs(child, adjList, i, colors, edgeOrder);
            ++i;
        }
    }

    static class Edge {
        final int x;
        final int y;

        Edge(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Edge edge = (Edge) o;
            return x == edge.x &&
                    y == edge.y;
        }

        @Override
        public int hashCode() {
            return Objects.hash(x, y);
        }
    }
}


Measured memory_bytes: 103604
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}

signed main(void) {
    int in;
    cin >> in;
    int n = 1;
    while(!((n-1)*n < 2*in && 2*in <= n*(n+1)))n++;
    string s = "";
    rep(i,n)s = ")" + s + "(";
    int t = n*(n+1)/2-in;
    swap(s[n], s[n-t]);
    cout << s << endl;
}



Measured memory_bytes: 3392
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;

double offset(int lr, int rr) {
	return sqrt((lr+rr)^^2.-(lr-rr)^^2);
}

void main() {
	while(!stdin.eof()) {
		auto s = array(map!(a => to!int(a))(readln().strip().split()));
		if(s.empty())
			break;
		int n = cast(int)s.length-1;
		int l = s[0];
		int [] r = s[1..$];
		double[][] dp = new double[][](1L<<12,n);
		for(int i; i < 1<<n; ++i){
			for(int j; j < n; ++j){
				dp[i][j] = l+100;
			}
		}
		for(int i; i < n; ++i){
			dp[1<<i][i] = r[i];
		}
		for(int i = 1; i < 1<<n; ++i){
			for(int j; j < n; ++j) {
				if(i & 1<<j)
					continue;
				for(int k; k < n; ++k) {
					if(i & 1<<k) {
						dp[i|1<<j][j] = min(dp[i|1<<j][j], dp[i][k]+offset(r[k],r[j]));
					}
				}
			}
		}
		for(int i; i < n; ++i){
			dp[(1<<n)-1][i] += r[i];
		}
		if(reduce!(min)(dp[(1<<n)-1]) > l)
			writeln("NA");
		else
			writeln("OK");
	}
}

Measured memory_bytes: 4652
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll A[200010];
    rep(i,0,N) cin >> A[i];
    ll zero = 0;
    vector<ll> plus, minus;
    rep(i,0,N){
        if(A[i] == 0) zero++;
        else if(A[i] > 0) plus.push_back(A[i]);
        else minus.push_back(A[i]);
    }
    sort(plus.begin(), plus.end());
    sort(minus.begin(), minus.end());

    ll zero_cnt = N*(N-1)/2 - (N-zero) * (N-zero-1) / 2;
    ll lv = -1e18+1, rv = 1e18+1;
    ll nplus = plus.size(), nminus = minus.size();

    while(rv - lv > 1){
        ll mid = (rv + lv) / 2;
        ll res1 = 0, res2 = 0;
        rep(i,0,nplus){
            ll v = plus[i];
            if(mid >= 0){
                ll target = mid / v;
                ll pos = upper_bound(plus.begin(), plus.end(), target) - plus.begin();
                if(v <= target) pos--;
                res1 += pos;
            }
            if(mid >= 0){
                res2 += nminus;
            }else{
                ll target = - (-mid + v - 1) / v;
                ll pos = upper_bound(minus.begin(), minus.end(), target) - minus.begin();
                res2 += pos;
            }
        }

        rep(i,0,nminus){
            ll v = minus[i];
            if(mid >= 0){
                ll target = (-1) * (mid / -v);
                ll pos = lower_bound(minus.begin(), minus.end(), target) - minus.begin();
                if(v >= target) pos++;
                res1 += nminus - pos;
            }
            if(mid >= 0){
                res2 += nplus;
            }else{
                ll target = (-mid + abs(v) - 1) / abs(v);
                ll pos = lower_bound(plus.begin(), plus.end(), target) - plus.begin();
                res2 += nplus - pos;
            }

        }

        ll res = (res1 + res2) / 2;
        if(mid >= 0) res += zero_cnt;

        if(res >= K){
            rv = mid;
        }else{
            lv = mid;
        }
    }
    print(rv);

}

Measured memory_bytes: 3956
#include <iostream>
#include <limits.h>
using namespace std;

int beau = 1000000009;

int main() {
	int n, a[200020], m;
	cin >> n;
	m = n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	if (n % 2 == 0) {
	    while (m > 0) {
	        cout << a[m] << " ";
	        m -= 2;
	    }
	    m = 1;
	    while (m < n - 1) {
	        cout << a[m] << " ";
	        m += 2;
	    }
	    cout << a[n - 1];
	}
	else {
	    while (m > 0) {
	        cout << a[m] << " ";
	        m -= 2;
	    }
	    if (n > 1) m = 2;
      	else m = 0;
	    while (m < n - 1) {
	        cout << a[m] << " ";
	        m += 2;
	    }
	    if (n > 1) cout << a[n - 1];
	}
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define dd double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 1000000007
#define tc(t) 			int t;cin >> t;while(t--)
#define for0(i , n)		for(int i=0;i<n;i++)
#define loop(i , a, b)	for(int i=a;i<=b;i++)
#define endl '\n'

int n;
int a[101];
vector<vector<int>>dp(101,vector<int>(100005,-1));

int candies(int ind,int left){
	if(left==0) return 1;
	if(ind==0||left<0) return 0;

	int &ans=dp[ind][left];
	if(ans!=-1)return ans;

	ans=candies(ind,left-1);
	ans=(ans+candies(ind-1,left))%mod;
	ans=(ans-candies(ind-1,left-a[ind-1]-1)+mod)%mod;
	return ans;
}


signed main() {

	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif

	int k;
	cin>>n>>k;
	for0(i,n)cin>>a[i];

	cout<<candies(n,k);

	return 0;
}

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

void fastInputOutput(){ios_base::sync_with_stdio(false);cin.tie(NULL);}

ll GCD(ll a, ll b){ll gcd, g;g = __gcd(a, b);return g;}
ll gcd(ll a, ll b){if(b == 0){return a;}else{return gcd(b, a%b);}}
ll extended_gcd(ll a, ll b, ll *x, ll *y){if(a == 0){*x = 0;*y = 1;return b;}ll x1, y1;ll d = extended_gcd(b%a, a, &x1, &y1);*x = y1-(b/a)*x1;*y = x1;return d;}
ll LCM(ll a, ll b){ll gcd, g;g = __gcd(a, b);return (a/g)*b;}
ll PowFun(ll base, ll power){ll ans = 1;for(int i = 1; i <= power; i++){ans *= base;}return ans;}
/*This is better power function here used binary exponentiation*/
ll MadeFun(ll b, ll p){if(p == 0){return 1;}else if(p%2 == 0){return MadeFun(b*b, p/2);}else{return b*MadeFun(b*b, (p-1)/2);}}


const ll INF_LONG = 1LL<<61;
const unsigned int inf_int = 1<<31;
const ll mod = 1e9+7;
double phi = acos(-1);
void Solve()
{
    int n; cin >> n;
    unsigned long long res = 1;
    unsigned long long a[n+5] = {};
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    bool ok = true;
    unsigned long long di = 1000000000000000000;
    long double test = 1;
    for(int i = 1; i <= n; i++)
    {
        res *= a[i];
        test *= a[i];
    }
    if(test > di)
    {
        cout << "-1" << endl;
    }
    else
    {
        cout << res << endl;
    }
}
int main()
{
    fastInputOutput();
    Solve();
    return 0;
}


Measured memory_bytes: 4480