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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

vector<ll> divs;
void make_divs(ll n)
{
  divs.clear();
  vector<ll> ldiv, udiv;
  ll i = 1;
  while(i * i <= n) {
    if(n % i == 0) {
      ldiv.push_back(i);
      if(i != n / i) {
	udiv.push_back(n / i);
      }
    }
    i += 1;
  }
  rep(i, (ll)ldiv.size()) divs.push_back(ldiv[i]);
  for(ll i = udiv.size() -1; i >= 0; i--) divs.push_back(udiv[i]);
}


void solve()
{
  ll N; cin >> N;
  vector<ll> a(N); rep(i, N) cin >> a[i];
  map<ll, ll> llm;
  set<ll> ldivs;
  rep(i, 2) {
    make_divs(a[i]);
    rep(i, divs.size()) ldivs.insert(divs[i]);
  }
  rep(i, N) {
    for(auto j = ldivs.begin(); j != ldivs.end(); j++) {
      if(a[i] % *j == 0) llm[*j] ++;
    }
  }
  ll ans;
  for(auto itr : llm) {
    if(itr.second >= N - 1) ans = itr.first;
  }
  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 4028
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct edge {int u, v, cost; };

bool comp(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}

class UnionFind {
 public:
    int g_num;
    vector<int> rank, par;

    UnionFind() {}
    UnionFind(int size) {
        rank.resize(size, 0);
        par.resize(size, 0);
        for (int i = 0; i < size; i++) {
            par[i] = i;
            rank[i] = 0;
        }
        g_num = size;
    }

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

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        g_num--;
        if (rank[x] > rank[y]) {
            par[y] = x;
        } else {
            par[x] = y;
            if (rank[x] == rank[y]) rank[y]++;
        }
    }

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

    int group_num() {
        return g_num;
    }
};

int main(void) {
    int V, E;
    cin >> V >> E;
    UnionFind uf(V);
    vector<edge> es;
    for (int i = 0; i < E; i++) {
        int u, v, cost;
        cin >> u >> v >> cost;
        es.push_back(edge {u, v, cost});
    }
    sort(es.begin(), es.end(), comp);
    int res = 0;
    for (auto e: es) {
        if (!uf.same(e.u, e.v)) {
            uf.unite(e.u, e.v);
            res += e.cost;
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 2800
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	string c1;
	string c2;
	string a, b;
	cin >> c1 >> c2;
	a = c1, b = c2;
	reverse(begin(c1), end(c1));
	reverse(begin(c2), end(c2));
	if (a == c2 && b == c1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
package main
import "fmt"
func main(){
    var a, b, c int
    m := make(map[int]int, 3)
    
    fmt.Scanf("%d %d %d", &a, &b, &c)
    m[a] = 1
    m[b] = 1
    m[c] = 1

    fmt.Println(len(m))
}


Measured memory_bytes: 512
n = int(input())
R = {}
for i in range(n): R[i] = 0
for _ in range(n*(n-1)//2):
	a, b, c, d = map(int, input().split())
	if c>d:
		R[a-1] += 3
	elif c==d:
		R[a-1] += 1
		R[b-1] += 1
	else:
		R[b-1] += 3

rank, temp = 1, -1
ranks = []
R = sorted(R.items(), key=lambda x:-x[1])
#print(R)
for i in range(len(R)):
	if temp!=R[i][1]:
		rank = i+1
		ranks.append([R[i][0], i+1])
	else:
		ranks.append([R[i][0], rank])
	temp = R[i][1]

ranks = sorted(ranks)
for i in ranks:
	print(i[1])



Measured memory_bytes: 5624
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

LL N;

int main(void) {
    cin >> N;

    cout << N * (N - 1) / 2 << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{

  public static void main(String args[]){

    Scanner s=new Scanner(System.in);
    int N=s.nextInt();
    int ans[]={0,0,0,0};
    for(int i=0;i<N;i++){
      String str=s.next();
      switch(str){
        case "AC": ans[0]+=1; break;
        case "WA": ans[1]+=1; break;
        case "TLE": ans[2]+=1; break;
        case "RE": ans[3]+=1; break;
      }
    }
    System.out.println("AC x "+ans[0]);
    System.out.println("WA x "+ans[1]);
    System.out.println("TLE x "+ans[2]);
    System.out.println("RE x "+ans[3]);
  }  
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string s;
  cin >> s;
  
  int K; 
  cin >> K;

  for(int i = 0; i < s.length(); i++){
    
    if(s[i] == 'a') continue;
    if(int('z'-s[i])+1 <= K){
      K -= (int('z'-s[i])+1);
      s[i] = 'a';
    }
  }

  if(K > 0){

    K = K % 26;

    char last_char;

    last_char = ((int(s[s.length()-1]-'a') + int(K)) % 26) + 'a';

    s[s.length()-1] = last_char;


  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 592
#include <stdbool.h>
#include <stdio.h>
int main() {
    int n, ans = 0, max = 0;
    char s[101];
    bool chn[26];
    scanf("%d%s", &n, s);
    for (int i = 1; i < n; i++) {  //区切るとこ
        ans = 0;
        for (int j = 0; j < 26; j++) {
            chn[j] = false;
        }
        for (int j = 0; j < i; j++) {
            chn[s[j] - 'a'] = true;
        }
        for (int j = i; j < n; j++) {
            if (chn[s[j] - 'a']) {
                chn[s[j] - 'a'] = false;
                ans++;
            }
        }
        if (ans > max) {
            max = ans;
        }
    }
    printf("%d\n", max);
    return 0;
}

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

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for (int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clar(a, b) memset((a), (b), sizeof(a))
#define debug(...) fprintf(stderr, __VA_ARGS__)
template <typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template <typename T> inline T sqr(const T &a) { return a * a; }
typedef long long LL;
typedef long double LD;
void procStatus() {
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}
LL read() {
	LL x = 0, flag = 1;
	char ch = getchar();
	for (;!isdigit(ch); ch = getchar()) if (ch == '-') flag *= -1;
	for (;isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
	return x * flag;
}
void write(LL x) {
	if (x < 0) putchar('-'), x = -x;
	if (x >= 10) write(x / 10);
	putchar(x % 10 + '0');
}

const int Maxn = 4e5 + 9;
int n, V, a[Maxn];

void Init() {
	n = read(), V = read();
	rep (i, 1, n) a[i] = read();
}

int pon[20][Maxn];
int len[Maxn], lef[Maxn], rig[Maxn];

int uppfind(int pos, int step) {
	int l = 1, r = len[step], ans = pon[step][r];
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (pon[step][mid] > pos) ans = pon[step][mid], r = mid - 1;
		else l = mid + 1;
	}
	return ans;
}

int lowfind(int pos, int step) {
	int l = 1, r = len[step], ans = pon[step][l];
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (pon[step][mid]< pos) ans = pon[step][mid], l = mid + 1;
		else r = mid - 1;
	}
	return ans + 1;
}

void Solve() {
	int cnt = 0;
	while ((1 << cnt) <= V) ++cnt;
	rep (i, 0, cnt) {
		len[i] = 1;
		rep (j, 1, n) {
			pon[i][len[i]] = j;
			if (j != n && a[j + 1] - a[j] > (V >> i)) ++len[i];
		}
		pon[i][len[i] + 1] = n + 1;
	}
	if (len[0] > cnt + 1) {
		rep (i, 1, n) puts("Impossible");
		return ;
	}
	rep (i, 0, (1 << cnt) - 1) lef[i] = 0, rig[i] = n + 1;
	rep (i, 0, (1 << cnt) - 1) {
		rep (j, 0, cnt - 1) {
			if ((i >> j) & 1) continue;
			chkmax(lef[i ^ (1 << j)], uppfind(lef[i], j + 1)); // find a pointer bigger exclusively than f[i]
			chkmin(rig[i ^ (1 << j)], lowfind(rig[i] - 1, j + 1)); // find a pointer lower exclusively than f[i]
		}
	}
	rep (i, 1, len[0]) {
		int l = pon[0][i - 1] + 1, r = pon[0][i];
		int flag = 0;
		rep (j, 0, (1 << cnt) - 1) 
			if (lef[j] >= l - 1 && rig[(1 << cnt) - 1 - j] <= r + 1) {
				flag = 1;
				break;
			}
		rep (j, l, r) puts(flag ? "Possible" : "Impossible");
	}
}

int main() {
//	freopen("bosky.in", "r", stdin);
//	freopen("bosky.out", "w", stdout);

	Init();
	Solve();	

#ifdef Qrsikno
//	procStatus();
	debug("\nRunning time: %.3lf(s)\n", clock() * 1.0 / CLOCKS_PER_SEC);
#endif
	return 0;
}


Measured memory_bytes: 38656
import java.awt.Point;
import java.util.LinkedList;
import java.util.Scanner;
 
public class Main {
     
	static int W, H;
	static int[][] map;
	static int[][] check;
	
	static void bfs(int sx, int sy)
	{
		LinkedList<Point> queue = new LinkedList<Point>();
    	queue.offer(new Point(sx, sy));
    	
    	while (!queue.isEmpty()) {
			Point p = queue.poll();
			
			if( !((0 <= p.x) && (p.x < W)) ) continue;
			if( !((0 <= p.y) && (p.y < H)) ) continue;
			if(check[p.y][p.x] == 1) continue;
			if(map[p.y][p.x] == 0) continue;
			
			check[p.y][p.x] = 1;
			
			queue.offer(new Point(p.x - 1, p.y - 1));
			queue.offer(new Point(p.x - 1, p.y));
			queue.offer(new Point(p.x - 1, p.y + 1));
			queue.offer(new Point(p.x    , p.y - 1));
			queue.offer(new Point(p.x    , p.y + 1));
			queue.offer(new Point(p.x + 1, p.y - 1));
			queue.offer(new Point(p.x + 1, p.y));
			queue.offer(new Point(p.x + 1, p.y + 1));
		}
	}
	
    static void start()
    {
    	check = new int[H][W];
    	for (int y = 0; y < H; y++) {
			for (int x = 0; x < W; x++) {
				check[y][x] = 0;
			}
		}
    	
    	int count = 0;
    	for (int y = 0; y < H; y++) {
			for (int x = 0; x < W; x++) {
				if(map[y][x] == 0) continue;
				if(check[y][x] == 1) continue;
				count++;
				bfs(x, y);
			}
		}
    	
    	System.out.println(count);
    }
     
    public static void main(String[] args)
    {
        Scanner sca = new Scanner(System.in);
        
        while(true)
        {
        	W = sca.nextInt();
        	H = sca.nextInt();
        	if(W == 0) break;
        	
        	map = new int[H][W];
        	for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					map[y][x] = sca.nextInt();
				}
			}
            
            start();
        }
        
    }
}

Measured memory_bytes: 48336
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int n;
    vector<int> v, c;
    cin >> n;

    for (int i = 0; i < n; i++) {
        int j;
        cin >> j;
        v.emplace_back(j);
    }

    for (int i = 0; i < n; i++) {
        int j;
        cin >> j;
        c.emplace_back(j);
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (v[i] > c[i]) {
            ans += v[i] - c[i];
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
L = []
R = []
for i in range(m):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)
count = min(R) - max(L) + 1
if count <= 0:
    print(0)
else:
    print(count)

Measured memory_bytes: 11020
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  int l = 0, r = 0;
  int k = 0;
  string prev = "";
  int n = s.size();
  while(l < n) {
    r = l+1;
    while(r < n && s.substr(l, r-l) == prev) r++;
    if(prev != s.substr(l, r-l)) k++;
    prev = s.substr(l, r-l);
    l = r;
  }
  cout << k << "\n";
  return 0;
}


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

using namespace std;

typedef pair<int, int> P;

int main(){
    int N;
    int ans = 0;
    P A[100000];
    cin >> N;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        A[i] = P(a, i);
    }
    sort(A, A+N);
    for(int i = 0; i < N; i++){
        if(i%2 != A[i].second%2) ans++;
    }
    cout << ans/2 << endl;
}

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

int main() {
    int x;
    cin >> x;
    vector<long long> mul(325);
    for(int i = 1; i <= 31; i++){
        for(int j = 2; j <= 10; j++){
            mul[i*10+j] = pow(i,j);
        }
    }
    sort(mul.begin(), mul.end());
    int maxi = 0;
    for(int i = 0; i < 325; i++){
        if(mul[i] <= x){
            maxi = mul[i];
        } else {
            cout << maxi;
            break;
        }
    }
}

Measured memory_bytes: 640
from collections import deque


def calc(t, r, s, p):
    if t == "r":
        return p
    elif t == "s":
        return r
    else:
        return s


n, k = map(int, input().split())
r, s, p = map(int, input().split())
T = input()
d = deque()
ans = 0
for i, t in enumerate(T):
    if i < k:
        ans += calc(t, r, s, p)
        d.append(t)
    else:
        x = d.popleft()
        if x == t:
            d.append(0)
        else:
            ans += calc(t, r, s, p)
            d.append(t)
print(ans)


Measured memory_bytes: 10064
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int n, k;
    cin >> n >> k;
    int ans = 0;
    forn(i, n) {
        int v;
        cin >> v;
        ans += min(2 * v, 2 * (k - v));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//Name: Smart Calculator
//Level: 2
//Category: 構文解析
//Note:

/**
 * オーソドックスな四則演算の構文解析。
 *
 * オーダーは O(|S|)。
 */
#include <iostream>
#include <string>
#include <cctype>
#include <cstdlib>

using namespace std;

typedef string::const_iterator Iterator;

void skip(Iterator &it, char c) {
    if(*it != c) {
        cout << "Expected " << c << " but got " << *it << endl;
        cout << "Parse error near: ";
        while(*it) {
            cout << *it;
            ++it;
        }
        cout << endl;
        abort();
    }
    ++it;
}

long long factor(Iterator&);
long long term(Iterator&);

long long number(Iterator &it) {
    long long val = 0;
    while(isdigit(*it)) {
        val *= 10;
        val += *it - '0';
        ++it;
    }
    return val;
}

long long expr(Iterator &it) {
    long long lhs = term(it);
    while(*it == '+' || *it == '-') {
        const char op = *it;
        skip(it, op);
        const long long rhs = term(it);
        if(op == '+') lhs += rhs;
        else lhs -= rhs;
    }
    return lhs;
}

long long term(Iterator &it) {
    long long lhs = factor(it);
    while(*it == '*' || *it == '/') {
        const char op = *it;
        skip(it, op);
        const long long rhs = factor(it);
        if(op == '*') lhs *= rhs;
        else lhs /= rhs;
    }
    return lhs;
}

long long factor(Iterator &it) {
    if(*it == '(') {
        skip(it, '(');
        const long long val = expr(it);
        skip(it, ')');
        return val;
    } else {
        return number(it);
    }
}

bool solve() {
    string line;
    cin >> line;
    Iterator it = line.begin();
    cout << expr(it) << endl;
    return true;
}

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

    int N;
    cin >> N;
    while(N--) solve();
    return 0;
}

Measured memory_bytes: 1204
#!python3

LI = lambda: list(map(int, input().split()))

# input
X = int(input())


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def main():
    g = gcd(X, 360)
    v = X // g
    ans = 360 * v // X
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using PL = pair<ll,ll>;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
constexpr int INF = (1 << 29);
constexpr ll INF_ = (1LL << 58);
constexpr ld EPS = (1e-10);
constexpr ld PI_ = 3.141592653589793238;//46264338327950288
constexpr ld E_ = 2.71828182845904523;//5360287471352
constexpr ll MOD = 1000000007;
//// functions (integer)_________________________________
ll modpow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a % m;
		a = a * a%m; n >>= 1;
	}
	return res;
}
long long modinv(long long a, long long p, long long mod){
  return modpow(a,p-2,mod);
}
////-----------------------------------------------------



int main(){
  int N; set<ll>P; map<ll,ll> B;
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  vector<ll> A(N);
  RPT(i,0,N){
    ll a; cin >> A[i];
  }
  sort(A.begin(),A.end());

  FOR(i,2,1000003){
    bool ynprime = true;
    for(auto &xx : P){
      ll x = xx;
      if(i % x == 0){ ynprime = false; break; }
      if( x*x > i ) break;
    }
    if(ynprime) P.insert(i);
  }

  RPT(i,0,N){
    ll ttl = A[i];
    set<ll>::iterator it = P.find(A[i]);
    if(it!=P.end()){
      ttl = 1;
      if(B[A[i]]<1) B[A[i]] = 1;
    }
    for(auto &xx : P){
      auto x = xx;
      ll cnt = 0;
      if(x > A[i] || ttl == 1) break;
      while(ttl % x == 0){
        ttl /= x;
        cnt++;
      }
      if(cnt){
        if(B[x]<cnt) B[x] = cnt;
      }
    }
    if(ttl != 1) {
      P.insert(A[i]);
      B[A[i]] = 1;
    }
  }

  ll L=1, Ainv = 0;
  for(auto x : P){
    if(B[x] != 0)L = ((L * (modpow(x,B[x],MOD))%MOD)) % MOD;
  }
  RPT(i,0,N){
    Ainv = (Ainv + ((modpow(A[i],MOD-2,MOD)%MOD)%MOD) ) % MOD;
  }
  ll ans = (Ainv * L) % MOD;
  //ll ans = (Ainv % MOD);
  cout << ans << endl; 
  //cout << L << endl << Ainv << endl;for(auto x: P) if(B[x]) cout << x << "^" << B[x] << " ";
  return 0;
}

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

int main(){
  int N, Q;
  cin >> N >> Q;
  vector<int> tree(200100);
  vector<int> ans(200100);
  rep(i, N - 1){
    int a, b;
    cin >> a >> b;
    tree.at(b-1) = a; 
  }
  
  rep(i, Q){
    int p, x;
    cin >> p >> x;
    ans.at(p-1) += x;
  }
  
  cout << ans.at(0) << ' ';
  
  for(int i = 1; i < N; i++){
    int upper = tree.at(i);
    ans.at(i) += ans.at(upper - 1);
    cout << ans.at(i) << ' ';
  }
  
  /* 
  
  rep(i, Q){
    int a, b;
    cin >> a >> b;
  }  

  for(int i = N ; i > 0; i--){
    for(int j : tree[i - 1]){
      tree2[i - 1].push_back(j);
      for(int k : tree2[j - 1]) tree2[i - 1].push_back(k);
    }
  }
  
  
  rep(i, Q){
    int temp1, temp2;
    cin >> temp1 >> temp2;
    ans[temp1 - 1] += temp2;
    for(int j : tree2[temp1 - 1]) ans[j - 1] += temp2;
  }
  
  rep(i, N) cout << ans[i] << ' ';
  
  */
  
}

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

int main() {
  char c;
  cin >> c;

  // ここにプログラムを追記
  string result = "consonant";
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
      result = "vowel";
  }

  cout << result << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	vector<long long> v;
	for(int i=1;i<=n;i++){
		long long x;
		cin>>x;
		if(x==0){
			cout<<0;
			return 0;
		}
		v.push_back(x);
	}
	long long prod=1, INF=1e18;
	for(int i=0;i<n;i++){
		if(prod>INF/v[i]){
			cout<<-1;
			return 0;
		}
		prod*=v[i];
		assert(prod<=INF);
	}
	cout<<prod;
}


Measured memory_bytes: 4228
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int n;
    cin>>n;
    int res = 1;
    int cnt = 0;
    rep2(i,1,n+1){
        int tmp = 0;
        int t=i;
        while(t%2==0){
            tmp++;
            t/=2;
        }
        if(tmp>cnt){
            res=i;
            cnt = tmp;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG

#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <vector>
#include <chrono>
#include <cmath>

#define int long long

using namespace std;


signed main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  priority_queue<int> p, q, r;

  for (int i = 0; i < A; i++) {
    int t;
    cin >> t;
    p.push(t);
  }
  for (int i = 0; i < B; i++) {
    int t;
    cin >> t;
    q.push(t);
  }
  for (int i = 0; i < C; i++) {
    int t;
    cin >> t;
    r.push(t);
  }

  priority_queue<int> t;
  for (int i = 0; i < X; i++) {
    t.push(p.top());
    p.pop();
  }
  for (int i = 0; i < Y; i++) {
    t.push(q.top());
    q.pop();
  }
  for (int i = 0; i < C; i++) {
    t.push(r.top());
    r.pop();
  }

  int ans = 0;
  for (int i = 0; i < X + Y; i++) {
    ans += t.top();
    t.pop();
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8816
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> a(n);
  for(int i = 0; n > i; i++){
    cin>>a[i];
  }
  int ret = 0;
  for(int i = 0; n-1 > i; i++){
    if(a[i]==i+1){
      swap(a[i],a[i+1]);
      ret++;
    }
  }
  if(a[n-1] == n)ret++;
  cout << ret << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  vector<int> vec(4);
  ll n;
  cin >> n;
  rep(i,n){
    string b;
    cin >> b;
    if(b == "AC"){
      vec[0]++;
    }
    if(b == "WA"){
      vec[1]++;
    }
    if(b == "TLE"){
      vec[2]++;
    }
    if(b == "RE"){
      vec[3]++;
    }
  }
  cout << "AC x " << vec[0] << endl;
    cout << "WA x " << vec[1] << endl;
    cout << "TLE x " << vec[2] << endl;
    cout << "RE x " << vec[3] << endl;
    
  
  return 0;
}




Measured memory_bytes: 3628
using System;
namespace CodeForcesPractice
{
    class Program
    {
        
        public static int[] IntInput(string Line, int NumParam)
        {
            string[] RetArr = new string[NumParam];
            RetArr = Line.Split(' ');
            int[] arr = new int[NumParam];
            for (int i = 0; i < NumParam; i++)
            {
                arr[i] = Convert.ToInt32(RetArr[i]);
            }
            return arr;
        }
        

        public static int Multiply()
        {
            int[] arr = IntInput(Console.ReadLine(), 2);
            int ans = arr[0] * arr[1];
            return ans;
        }

        
    static void Main(string[] args)
        {
            Console.WriteLine(Multiply()); 
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 17952
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<par<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    string s;
    cin>>s;
    rep(i,8){
        int sum=s[0]-'0';
        rep(j,3){
            if((i>>j)&1){
                sum+=s[j+1]-'0';
            }
            else{
                sum-=s[j+1]-'0';
            }
        }
        if(sum==7){
            rep(j,3){
                cout<<s[j]<<((i>>j)&1?'+':'-');
            }
            cout<<s[3]<<"=7"<<endl;
            return;
        }
    }    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  vi a(N);
  rep(i, N) cin >> a[i];
  ll sum = 0;
  rep(i, N) {
    sum += a[i] - 1;
  }
  fin(sum);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;

const int N=1e6+5;
int n,d,x[N],y[N];

void solve()
{
    cin>>n>>d;
    int dem=0;
    for(int i=1;i<=n;i++)
    {
        cin>>x[i]>>y[i];
        if(x[i]*x[i]+y[i]*y[i]<=d*d) dem++;
    }
    cout<<dem;
}

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //int t;
    //cin>>t;
    //while(t--)
        solve();
}


Measured memory_bytes: 6760
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define INF 1000000000001
using namespace std;


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

  ll n;
  cin>>n;
  ll a[n+1],b[n+1],c[n+1];
  for(ll i=1;i<=n;i++)
  {
    cin>>a[i]>>b[i]>>c[i];
  }
  ll dp[n+1][3];
  for(ll i=1;i<=n;i++)
  {
    dp[i][0]=a[i];
  }
  for(ll i=1;i<=n;i++)
  {
    dp[i][1]=b[i];
  }
  for(ll i=1;i<=n;i++)
  {
    dp[i][2]=c[i];
  }

  for(ll i=2;i<=n;i++)
  {
    for(ll j=0;j<3;j++)
    {
      ll m=0;
      for(ll k=0;k<3;k++)
      {
        if(k!=j)
        {
          m=max(m,dp[i-1][k]+dp[i][j]);
        }
      }
      dp[i][j]=m;
    }
  }
  ll ans=0;
  for(ll i=0;i<3;i++)
  {
    ans=max(ans,dp[n][i]);
  }
  cout<<ans;


}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

signed main(){

	string s;
	cin>>s;

	string ans="CODEFESTIVAL2016";

	lli cnt=0;
	REP(i,0,s.size()){
		if(s.at(i)!=ans.at(i))cnt++;
	}

	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll tp[M],bt[M],ar[M],nd[M];

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

	ll i,n,ans = 1;

	cin >> n;
	for(i=0;i<=n;++i)
		cin >> ar[i];

	if(n == 0)
	{
		if(ar[0] != 1)
		{
			cout << -1 << "\n";
			return 0;
		}	
		else
		{
			cout << 1 << "\n";
			return 0;
		}
	}

	if(ar[0] != 0)
	{
		cout << -1 << "\n";
		return 0;
	}

	ll lim = 1e8*(n+1);
	lim = max((ll)(1e13),lim);
	
	bt[0] = 1;
	for(i=1;i<=n;++i)
	{
		bt[i] = min(lim,(bt[i-1]-ar[i-1])*2ll);
		if(bt[i]<ar[i] || bt[i] <= 0)
		{
			cout << -1 << "\n";
			return 0;
		}
	}

	tp[n] = ar[n]; 
	for(i=n;i>=1;i--)
	{
		if(min(tp[i],bt[i]) <= 0)
		{
			cout << -1 << "\n";
			return 0;
		}
		ans += min(tp[i],bt[i]);
		nd[i] = min(tp[i],bt[i]);
		tp[i-1] = min(tp[i],bt[i])+ar[i-1];
	}

	nd[0] = 1;
	for(i=1;i<n;++i)
	{
		if(ar[i]>=nd[i])
		{
			while(1)
			{
				cout << 1 << "\n";
			}
			cout << -1 << "\n";
			// cout << "g " << i << "\n";
			return 0;
		}
		if(nd[i]<nd[i-1]-ar[i-1] || nd[i]>(nd[i-1]-ar[i-1])*2)
		{
			while(1)
			{
				cout << 1 << "\n";
			}
			cout << -1 << "\n";
			// cout << "gg " << i << "\n";
			return 0;
		}
	}

	if(ar[i] != nd[i])
	{
		while(1)
		{
			cout << 1 << "\n";
		}
		cout << -1 << "\n";
		// cout << "g " << i << "\n";
		return 0;
	}
	if(nd[i]<nd[i-1]-ar[i-1] || nd[i]>(nd[i-1]-ar[i-1])*2)
	{
		while(1)
		{
			cout << 1 << "\n";
		}
		cout << -1 << "\n";
		// cout << "gg " << i << "\n";
		return 0;
	}

	cout << ans << "\n";
}

Measured memory_bytes: 6760
import java.util.*;

/**
 * @Author: Harry
 * @Date: 2019-11-12
 * @Version 1.0
 */
public class Main {

    static int arr[],t,n,arr2[];

//    static int a,b,S;


    static int ans = 0;

    public Main() {
    }

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


        while(input.hasNext()){
            n = input.nextInt();
            System.out.println(n * n);
        }



    }

















}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)a
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    int k;
    cin >> k;
    int ans = 0;
    const int MAX = 2e6;
    ll mod = 0;
    while (ans < MAX) {
        ans++;
        mod *= 10;
        mod += 7;
        mod %= k;
        if (mod == 0) break;
    }
    if (ans == MAX) {
        cout << -1;
    } else {
        cout << ans;
    }
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


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

int main() {
	int N; cin >> N;
	string S; cin >> S;
	vector<int> ans(N,0);
	for(int i = 0 ; i < N ; i++){
		if(S[i] == 'A') continue;
		for(int j = N-1 ; j > i ; j--){
			if(S[i] == S[j]){
				for(int k = i ; k < j ; k++){
					ans[k]++;
					if(S[i] == S[k] && i != k) S[k] = 'A';
				}
				S[i] = S[j] = 'A';
				break;
			}
		}
	}
	sort(ans.begin(),ans.end());
	cout << ans[N-1] << endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
r,g,b = LI()
if (g*10+b)%4 == 0:
    print("YES")
else:
    print("NO")
#B

#C
"""
f = [0]
for i in range(1,400):
    f.append(0)
for i in range(400,800):
    f.append(1)
for i in range(800,1200):
    f.append(2)
for i in range(1200,1600):
    f.append(3)
for i in range(1600,2000):
    f.append(4)
for i in range(2000,2400):
    f.append(5)
for i in range(2400,2800):
    f.append(6)
for i in range(2800,3200):
    f.append(7)
for i in range(3200,4801):
    f.append(-1)
n = I()
a = LI()
k = [1 for i in range(8)]
s = 0
t = 0
for i in a:
    if f[i] >= 0:
        if k[f[i]]:
            k[f[i]] = 0
            s += 1
    else:
        t += 1
print(max(s,1),min(s+t,n))
"""

#D
"""
n = I()
s = S()
ans = []
k = 0
for i in range(n):
    if s[i] == ")":
        k += 1
    else:
        if k > 0:
            ans += ["("]*k
            k = 0
        k -= 1
if k < 0:
    ans += [")"]*(-k)
else:
    ans = ["("]*k+ans
i = 0
if len(ans) == 0:
    for i in s:
        print(i,end = "")
else:
    while ans[i] == "(":
        i += 1
        if i == len(ans):break
    for j in range(n):
        ans.insert(i+j,s[j])
    for i in ans:
        print(i,end = "")
print()
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38512
C=[ [] for i in range(3) ]
for i in range(3):
	c1,c2,c3=map(int,raw_input().split())
	C[i].append(c1)
	C[i].append(c2)
	C[i].append(c3)

for i in range(2):
	s=set()
	for x1,x2 in zip(C[i],C[i+1]):
		s.add(x1-x2)

	if len(s)>1:
		print "No"
		quit()

C1=[[] for i in range(3)]
for i in range(3):
	C1[i].append(C[i][0]-C[i][1])
	C1[i].append(C[i][1]-C[i][2])

if C1[0]==C1[1]==C1[2]:
	print "Yes"
else:
	print "No"


Measured memory_bytes: 2696
from collections import deque
from itertools import count
Odd = deque(input())
Even = deque(input())
rtnList = lambda x: Odd if x & 1 else Even
ans = ''
for i in count(1,1):
    try:
        s = rtnList(i).popleft()
    except IndexError:
        print(ans)
        exit()
    ans += s


Measured memory_bytes: 9368
import math

N = int(input())
# a, b, x = map(lambda i: int(i), input().split(' '))

def main():
    root_n = math.sqrt(N)
    answer = -1
    for a in range(1, int(root_n) + 1):
        if N % a == 0:
            b = N // a
            v = a + b - 2
            if answer == -1 or answer > v:
                answer = v
    print(v)

main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma GCC optmize("O3")
using namespace std;
typedef long long int ll;
int main(){
	ll L,R,d;
	cin>>L>>R>>d;
	ll ris=0;
	if(L%d==0){
		ris++;
	}
	L=((L/d)*d)+d;
	while(L<=R){
		ris++;
		L+=d;
	}
	cout<<ris;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace _20190413
{
    class Program
    {
        public static void Main(string[] args)
        {
            using (var sc = new SetConsole())
            {
                var s = Console.ReadLine();
                // 初めを0
                var count1 = 0;
                for (int i = 0; i < s.Length; i++)
                {
                    var color = i % 2;
                    if (int.Parse(s[i].ToString()) != color)
                    {
                        count1++;
                    }
                }
                var count2 = 0;
                for (int i = 0; i < s.Length; i++)
                {
                    var color = (i + 1) % 2;
                    if (int.Parse(s[i].ToString()) != color)
                    {
                        count2++;
                    }
                }
                CWrite(Math.Min(count1, count2));
            }
        }

        static string[] GetArrayCharInput() => Console.ReadLine().Split();
        static int[] GetArrayIntInput() => Console.ReadLine().StringToIntArray();
        static int GetIntInput() => Console.ReadLine().ToInt();
        static void CWrite<T>(T str) => Console.WriteLine(str);
    }



    class SetConsole : IDisposable
    {
        readonly StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
        public SetConsole()
        {
            sw.AutoFlush = false;
            Console.SetOut(sw);
        }
        public void Dispose()
        {
            Console.Out.Flush();
            sw.AutoFlush = true;
            Console.SetOut(sw);
        }
    }

    static class ExtentionsLibrary
    {
        public static int[] StringToIntArray(this string str) =>
            str.Split().Select(int.Parse).ToArray();
        public static int ToInt(this string str) => int.Parse(str);
    }
}


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

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

  // A-> Bで B-A 枚増える

  ll ans;
  if (b - a <= 2 || 1 + k <= a) {
    // 叩いて増やすだけ
    ans = 1 + k;
  } else {
    ans = a;       // まずA枚になるまで叩いて増やす
    k -= (a - 1);  // 残り回数を求める
    if (k & 1) {
      // 残りが奇数なら、ABを偶数回と叩くのを1回
      ans++;
      k--;
      ans += (b - a) * (k / 2);
    } else {
      ans += (b - a) * (k / 2);
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<30;

ll inv[MAX],fac[MAX],finv[MAX];

void make(){
    
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    
    for(int i=2;i<MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll)i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
    
}

ll comb(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}

int main(){
    
    make();
    
    int N;cin>>N;
    vector<ll> A(N),B(N);
    
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    
    for(int i=0;i<N;i++){
        B[i]=fac[i]*finv[i+1]%mod;
        if(i) B[i]=(B[i]+B[i-1])%mod;
    }
    
    ll ans=0;
    
    for(int i=0;i<N;i++){
        ans+=A[i]*((B[i]+B[N-1-i]+mod-1)%mod)%mod;
        ans%=mod;
    }
    
    cout<<ans*fac[N]%mod<<endl;
    
}



Measured memory_bytes: 4096
A, B = map(int, input().split())
S = list(input())

for i in range(len(S)):
    if i <= A-1:
        if S[i] not in [str(i) for i in range(10)]:
            print('No')
            exit()
    if i == A:
        if S[i] != '-':
            print('No')
            exit()
    else:
        if S[i] not in [str(i) for i in range(10)]:
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 61996
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>

typedef long long ll;

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, x;
    cin >> k >> x;
    if(500*k >= x) cout << "Yes";
    else cout << "No";
}


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

using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  bool result = false;
  for (int i = 1; i < 4; i++) {
    int ans = a * b * i;
    if (ans % 2 == 1) {
      result = true;
    }
  }
  if (result) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(string s;cin>>s;){
		int n=s.size();
		ll res=1+ll(n-1)*n/2;
		vi cnt(26);
		for(char c:s) cnt[c-'a']++;
		rep(i,26) res-=ll(cnt[i]-1)*cnt[i]/2;
		cout<<res<<endl;
	}
}


Measured memory_bytes: 720