akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
#define rep(i, n) for(int i = 0; i < n; i++)
const int inf9 = 1e9; const lint inf18 = 1e18;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ double y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); } double euclidean(double first, double second){ return sqrt(first * first + second * second); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + ","; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint P(int n, int r){ if(r < 0 || n < r) return 0; return (fact[n] * inv[n - r] % mod); } lint C(int p, int q){ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }
inline int at(lint i, int j){ return (i >> j) & 1; }

int main(){
    int H, A;
    cin >> H >> A;
    cout << (H + A - 1) / A << endl;
}





Measured memory_bytes: 256
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <map>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 1; i < (n); i++)

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    int k = n;
    rep(i, n) {
        k--;
        for (int j = 1; j * j <= k; j++) {
            if (k % j == 0 && k / j == j)ans++;
            else if (k % j == 0)ans += 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3196
# coding: utf-8
# Your code here!
import collections

H,W=map(int,input().split())

table=[]
for _ in range(10):
    table.append(list(map(int,input().split())))

cost=[[0]*10 for _ in range(10)]

dp=[table[i][1] for i in range(10)]

#print(dp)
for n in range(10):
    temp=dp[:]
    for i in range(10):
        for j in range(10):
            temp[i]=min(table[i][j]+dp[j] if j!=i else temp[i],temp[i])
    dp=temp[:]
#print(dp)

c=collections.Counter("")
for _ in range(H):
    c+=collections.Counter(list(map(int,input().split())))

#print(c)
ans=0
for item in c.items():
    if item[0]==-1:
        continue
    else:
        ans+=dp[item[0]]*item[1]

print(ans)

Measured memory_bytes: 3572
N, M, C = (int(i) for i in input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
result = 0
for i in range(N):
        if (sum([x * y for (x, y) in zip(A[i], B)]) + C) > 0:
                result += 1
print(result)

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

using ll = long long;

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

	ll a;
	double b;
	cin >> a >> b;
	ll b2 = round(b * 100);
	cout << a * b2 / 100 << endl;

	return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};


//-----------------------------------------------------------------------------

int n;
int cnt[100000];

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

	cin>>n;
	ll a[n+1],b[n+1],c[n];
	REP(i,n) cin>>a[i];
	REP(i,n) cin>>b[i];
	REP(i,n) cin>>c[i];
	b[n]=INF;a[n]=INF;
	sort(a,a+n),sort(b,b+n),sort(c,c+n);
	int j=0;
	REP(i,n) {
		//if(b[i]<=a[j]) continue;
		while(a[j]<b[i]&&j<n) j++;
		cnt[i]=j;
	}
	ll sum=0;
	ll tmp=0;
	j=0;
	REP(i,n) {
		//if(c[i]<=b[j]) continue;
		while(b[j]<c[i]&&j<n) tmp+=cnt[j++];
		sum=sum+tmp;
	}
	cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 2944
N = int(input())
L = []
for _ in range(N):
    l = list(map(int,input().split()))
    L.append(l)
L = sorted(L,key=lambda x:(x[1],x[0]))
time = 0
for x in L:
    time += x[0]
    if time > x[1]:
        print("No")
        quit()
print("Yes")


Measured memory_bytes: 67820
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
const int N = 2e2+ 10, mod = 1e9 + 7;

void solve() {
	int n, k;
	cin >> n >> k;
	vector<int> p(n), a(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		--p[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll ans = -1e18;
	for (int i = 0; i < n; i++) {
		ll s = 0;
		vector<ll> mx(n + 1, -1e18);
		int j = p[i];
		int len = 0;
		vector<bool> ind(n + 1);
		while (!ind[j]) {
			s += a[j];
			mx[len+1] = max (s, mx[len]);
			ind[j] = 1;
			j = p[j];
			len++;
		}
		if (s < 0) {
			ll r = min(k, len);
			ans = max(ans, mx[r]);
			// cout << s << "\n";
			continue;
		}
		mx[0] = 0;
		ll q = k/len;
		ll r = k % len;
		if (q) {
			ans = max(ans, s*(q - 1) + mx[len]);
		}
		// cout << q <<  " " << r << " " << s << '\n';
		ans = max(s*q + mx[r], ans);
	}
	cout << ans;
}

int main() {
	int tt = 1;
	// cin >> tt;
	for (int tc = 1; tc <= tt; tc++) {
		solve();
	}
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	long N,K;cin>>N>>K;
	N = N % K;
	cout<<min(N , K-N)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int N, H, W;
  scanf("%d%d%d", &N, &H, &W);

  int ans = 0;
  for (int i = 0; i < N; i++) {
    int A, B;
    scanf("%d%d", &A, &B);
    if (H <= A && W <= B) {
      ans++;
    }
  }

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
a,b=map(int,input().split())
if (a>0 and b>0):
	print("Positive")
elif (a>=0 and b<=0) or (a<=0 and b>=0):
	print("Zero")
elif (a<0 and b<0 and (a+b)%2==0):
	print("Negative")
else:
	print("Positive")

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] prices = new int[4];
        for (int i = 0; i < 4; i++) {
            prices[i] = sc.nextInt();
        }
        int[] counts = new int[4];
        for (int i = 0; i < 4; i++) {
            counts[i] = sc.nextInt();
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; ; i++) {
            int x = i * counts[0];
            for (int j = 0; ; j++) {
                int y = x + j * counts[1];
                for (int k = 0; ; k++) {
                    int z = y + k * counts[2];
                    int l = 0;
                    if (z < n) {
                        l = (n - z + counts[3] - 1) / counts[3];
                    }
                    min = Math.min(min, i * prices[0] + j * prices[1] + k * prices[2] + l * prices[3]);
                    if (z >= n) {
                        break;
                    }
                }
                if (y >= n) {
                    break;
                }
            }
            if (x >= n) {
                break;
            }
        }
        System.out.println(min);
    }
}



Measured memory_bytes: 26264
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (ll i = 0; i < n; i++)
#define forr(i,a,b) for (ll i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef vector<ll> vl;
typedef vector<ii> vii;

const ll MX = 300005;
const ll inf = 2e18;

#define ptr nodo*
#define tam 1234
char resp[tam][tam];
int main () 
{
    vector<string> v4;
    v4.pb("bbio");
    v4.pb("ppio");
    v4.pb("omqq");
    v4.pb("omcc");
    vector<string> v5;
    v5.pb("..cnk");
    v5.pb("..cnk");
    v5.pb("bbuuq");
    v5.pb("mmi.q");
    v5.pb("qqibb");    
    vector<string> v6;
    v6.pb("..cctr");
    v6.pb("...ktr");
    v6.pb("..ck.h");
    v6.pb("bbc..h");
    v6.pb("mmf.gg");
    v6.pb("qqfee.");

    vector<string> v7;
    v7.pb("....gca");
    v7.pb("....gca");
    v7.pb("....vks");
    v7.pb("....vks");
    v7.pb("bbaa.jj");
    v7.pb("mmzzf..");
    v7.pb("qqoof..");
    vector<vector<string> > vvs;
    vvs.pb(v4);
    vvs.pb(v5);
    vvs.pb(v6);
    vvs.pb(v7);
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    int N=n;
    if (n==2)
        cout<<"-1";
    else
    {
        if (n==3)
        cout<<"a..\na..\n.bb\n";
        else
        {
            forr(i,0,n)
            forr(j,0,n)
            resp[i][j]='.';
            int x,y;
            x=y=0;
            while(n>7)
            {
                forr(i,0,4)
                forr(j,0,4)
                resp[y+i][x+j]=v4[i][j];
                x+=4,y+=4;
                n-=4;
            }
            n-=4;
            int m=vvs[n].size();
                forr(i,0,m)
                forr(j,0,m)
                resp[y+i][x+j]=vvs[n][i][j];
            forr(i,0,N)
            {
                forr(j,0,N)
                cout<<resp[i][j];
                cout<<endl;
            }
        }
    }
   
}

Measured memory_bytes: 2432
#include<stdio.h>
int main(void) {
	int a, b, N, s, f, i, flag = 0;
	scanf("%d%d", &a, &b);
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%d%d", &s, &f);
		if (flag == 0) {
			if (a <= s && b <= s)flag = 0;
			else if (a >= f&& b >= f)flag = 0;
			else flag = 1;
		}
	}
	printf("%d\n", flag);
	return 0;
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int N, M, K, H, W, L, R, X;
//string S, T;

signed main(){
  int A, B, C, D; cin >> A >> B >> C >> D;
  int ans = max(A*B, C*D);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
int main(void){
  char m[101];
  int i,j,l,cnt=0,flag=0;
  scanf("%s",m);
  l=strlen(m);
  for(i=0;i<l;i++){
    for(j=0;j<l;j++){
      if(m[i]==m[j]){
        cnt++;
      }
    }
    if(cnt%2==1){ 
      flag=1;
    }            
  }
  if(flag==0){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back

double a;

double f(int n) {
    if(n == 1) return a;
    if(n % 2 == 0)
        return f(n-1) * 2.0;
    else
        return f(n-1) / 3.0;
}

int main() {
    while(cin >> a) {
        double ans = 0;
        for(int i=1; i<=10; i++) ans += f(i);
        printf("%.20lf\n", ans);
    }

    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

string a[]={"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};

int main(){
	string s;
	cin >> s;
	for(int i=0; i<7; i++){
		if(s==a[i]) cout << i+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	while(1){
		c=c-b;
		if(c<=0){
			printf("Yes\n");
			break;
		}
		a=a-d;
		if(a<=0){
			printf("No\n");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1660
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

#ifdef DEBUG
#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }

// DEGUG
template <class T>
void _dump(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void _dump(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  _dump(s, forward<Tail>(tail)...);
}
// }}} End

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

  VAR(int, N);
  vector<int> a(N);
  rep(i, N) IN(a[i]);

  VAR(int, M);
  vector<int> b(M);
  rep(i, M) IN(b[i]);

  OUTL((b > a) ? 1 : 0);

  return 0;
}



Measured memory_bytes: 3188
import math
import fractions
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a,b):
    if(b<=-1):
        return [0 for i in range(a)]
    else:
        return [[0 for i in range(b)] for i in range(a)]

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

#a = list(map(int, input().split()))

#################################################
#################################################
#################################################
#################################################


h,w = list(map(int, input().split()))

cost = []

for i in range(10):
    cost.append(list(map(int, input().split())))

#print(cost)

INF = 1e9
costs = [[INF for i in range(10)] for j in range(10)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])

#print(cost)
            
needs=[0 for i in range(10)]

for i in range(h):
    row = list(map(int, input().split()))
    for k in row:
        if(k!=-1): needs[k]+=1

ans = 0
for i in range(10):
    ans += needs[i]*cost[i][1]
    #print(i,cost[i][1])

print(ans)


Measured memory_bytes: 78652
from scipy.sparse import*
(N,M,R),r,*t=[map(int,i.split())for i in __import__("sys").stdin]
a,b,c=zip(*t)
l=csgraph.dijkstra(csr_matrix((c,(a,b)),[N+1]*2),0)
print(min(sum(int(l[i][j])for i,j in zip(a[:-1],a[1:]))for a in __import__("itertools").permutations(r)))

Measured memory_bytes: 34644
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1000000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
  int n;
  string s;
  cin >> n >> s;
  int c = 0;
  REP(i, n){
    if(s[i] == '(') c++;
    else{
      if(c == 0) cout << "(";
      else c--;
    }
  }
  cout << s;
  REP(i, c) cout << ")";
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int V = Integer.parseInt(sc.next());
		int E = Integer.parseInt(sc.next());
		ArrayList<ArrayList<Integer>> edge = new ArrayList<ArrayList<Integer>>();
		for (int i=0;i<V;i++) {
			ArrayList<Integer> add = new ArrayList<Integer>();
			edge.add(add);
		}
		int[] indegree = new int[V];
		for (int i=0;i<E;i++) {
			int s = Integer.parseInt(sc.next());
			int t = Integer.parseInt(sc.next());
			edge.get(s).add(t);
			indegree[t]++;
		}
		ArrayList<Integer> ans = new ArrayList<Integer>();
		ArrayDeque<Integer> queue = new ArrayDeque<Integer>();
		for (int i=0;i<V;i++) {
			if (indegree[i]==0) {
				queue.add(i);
				ans.add(i);
			}
		}
		int flag = 0;
		// cycle detection
		if (queue.isEmpty()) {
			flag=1;
		}
		int cnt = 0;
		while(!queue.isEmpty()) {
			Integer rem = queue.remove();
			for (Integer i : edge.get(rem)) {
				indegree[i]--;
				if (indegree[i]==0) {
					queue.add(i);
					ans.add(i);
				}
			}
			cnt++;
			// cycle detection
			if (cnt>V) {
				flag=1;
				break;
			}
		}
		// cycle detection
		if (cnt!=V) {
			flag=1;
		}
		System.out.println(flag);
		// System.out.println(ans);
		// for (int i=0;i<V;i++) {
			// System.out.println(ans.get(i));
		// }
	}

}
	



Measured memory_bytes: 30868
#include "bits/stdc++.h"
using namespace std;

int main(){
  
  int H,W,K;
  string* c;
  cin >> H >> W >> K;
  c = new string[H];
  for(int i=0;i<H;i++)
    cin >> c[i];
  
  int result = 0;
  for(int hbit=0;hbit<(1<<H);hbit++){
    for(int wbit=0;wbit<(1<<W);wbit++){
      
      int sum=0;
      for(int i=0;i<H;i++){
        if((1<<i)&hbit)
          continue;
        for(int j=0;j<W;j++){
          if((1<<j)&wbit)
            continue;
          else if(c[i].at(j) == '#')
            sum++;
        }
      }
      
      if(sum == K)
        result++;
    }
  }
  
  cout << result;
  delete[] c;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

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

    vector<long long int> D(N);
    for( int i = 0; i < N; ++i ) cin >> D[i];

    long long int M;
    cin >> M;

    vector<long long int> T(M);
    for( int i = 0; i < M; ++i ) cin >> T[i];


    if( N < M ){
        cout << "NO" << endl;
        return 0;
    }


    sort(D.begin(), D.end());
    sort(T.begin(), T.end());


    if( T[0] < D[0] || D.back() < T.back() ){
        cout << "NO" << endl;
        return 0;
    }


    int j = 0;
    for( int i = 0; i < M; ++i ){
        for( ; j < N; ){
            //cout << "D[" << j << "]=" << D[j] << "  T[" << i << "]=" << T[i] << endl;
            if( D[j] == T[i] ){ ++j; break; }
            else if( D[j] < T[i] ){ ++j; continue; }
            else if( D[j] > T[i] ){
                cout << "NO" << endl;
                return 0;
            }
        }
        //if( j == N ){
        //cout << "NO" << endl;
        //return 0;
        //}
    }


    cout << "YES" << endl;


    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

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

    string S="qwertasdfgzxcvb";
    map<char,bool> m;
    rep(i,SZ(S)) m[S[i]]=true;
    while(true){
        string T; cin >> T;
        if(T=="#") break;
        int cnt=0;
        rep(i,SZ(T)-1){
            if(m[T[i]]^m[T[i+1]]) cnt++;
        }
        cout << cnt << "\n";
    }
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
using ll = long long;
// 座標 corrdinate と深さを保持するための構造体
struct Corr {
    ll y;
    ll x;
    ll depth;
};

int main(){
    int H,W;
    cin>>H>>W;
    int Ch,Cw,Dh,Dw;
    cin>>Ch>>Cw>>Dh>>Dw;
    vector<string> S(H);
    rep(i,H){
        cin>>S[i];
    }
    vector<vector<ll>> maps(H,vector<ll>(W,INF));

    
    maps[Ch-1][Cw-1]=0;//スタートは0回
    //0回ワープで行けるマスを全て洗い出す、
    //それらのマスから1回ワープして行けるマスのうちまだ行けてないマスを全て洗い出す
    //ワープは最大でも1000回
    deque<pair<int, int>> que;
    que.push_front(make_pair(Ch-1,Cw-1));
        int dy[4] = {0, 0, 1, -1};  // dx,dy は次の探索場所への距離を表す（４方向分）
        int dx[4] = {1, -1, 0, 0};
        int dwy[20] = {1, 1, -1, -1, 2, 2,  2, 2, 2, 1,  1, 0,  0, -1, -1, -2, -2, -2, -2, -2};  // dwx,dwy は次の探索場所への距離を表す（ワープ分）
        int dwx[20] = {1,-1, -1, 1, -2, -1, 0, 1, 2, -2, 2, -2, 2, -2, 2,  -2, -1, 0,  1,  2};
    while (que.size() != 0) {              // キューの要素がなくなったら終了
        pair<int, int> now = que.front();  // 現在の状態
        que.pop_front();
        
        for (int i = 0; i < 4; i++) {
            int ny = now.first + dy[i];                            // 次の探索場所の行番号
            int nx = now.second + dx[i];                           // 次の探索場所の列番号
            if (ny < 0 || H <= ny || nx < 0 || W <= nx) continue;  // 迷路の外に出るならスルー
            if (S[ny][nx] == '#') continue;                     // 障害物があればスルー
            if (maps[ny][nx] <= maps[now.first][now.second] ) continue; //それ以前に探索済みならスルー
            que.push_front(make_pair(ny, nx));
            maps[ny][nx] = maps[now.first][now.second];
        }
        for(int k =0;k<20;k++){
            int nwy = now.first + dwy[k];
            int nwx = now.second + dwx[k];
            if (nwy < 0 || H <= nwy || nwx < 0 || W <= nwx) continue;  // 迷路の外に出るならスルー
            if (S[nwy][nwx] == '#') continue;                     // 障害物があればスルー
            if (maps[nwy][nwx] <= maps[now.first][now.second]+1 ) continue;   //それ以前に探索済みならスルー
            que.push_back(make_pair(nwy,nwx));//このタームで行けるところは+1に塗り替え
            maps[nwy][nwx] = maps[now.first][now.second]+1;
        }
        
    }
    
    if(maps[Dh-1][Dw-1]!=INF){
        cout << maps[Dh-1][Dw-1] << endl;
    }else{
        cout << -1 << endl;
    }

    // rep(i,H){
    //     rep(j,W){
    //         if(S[i][j]!='#'){
    //         cout << maps[i][j];
    //         }else{
    //             cout << "#" ;
    //         }
    //     }
    //     cout << endl;
    // }


    return 0;
}

Measured memory_bytes: 12604
import java.util.Scanner;

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

      int max = 0;
      int count = 0;
      for (int i = 0; i < input.length(); i++) {
        if ('A' == input.charAt(i) || 'T' == input.charAt(i) || 'G' == input.charAt(i) || 'C' == input.charAt(i)) {
          count++;
          max = Math.max(max, count);
        }else {
          count = 0;
        }
      }

      System.out.println(max);
    }
  }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define mod 1000000007
#define PI 3.1415926535
using namespace std;
ll power(ll x, ll y)
{
	if (y == 0)
		return 1;
	else if (y % 2 == 0)
		return power(x, y / 2) * power(x, y / 2);
	else
		return x * power(x, y / 2) * power(x, y / 2);
}
ll modExpo(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modExpo((x*x)%mod,n/2);
    else                            
        return (x*modExpo((x*x)%mod,(n-1)/2))%mod;
}
ll sum(ll n)
{
	ll s=0;
	while(n)
	{
		s+=n%10;
		n/=10;
	}
	return s;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	auto start_time = clock();
	cerr << setprecision(3) << fixed;
#endif
	ll n;
	cin>>n;
	ll a,b;
	ll ans;
	ll mx1=INT_MIN, mx2=INT_MIN;
	ll mn1=INT_MAX, mn2=INT_MAX;
	for(ll i=0;i<n;i++)
	{
		cin>>a>>b;
		mn1=min(mn1,a+b);
		mn2=min(mn2,a-b);
		mx1=max(mx1,a+b);
		mx2=max(mx2,a-b);
	}
	ll ans1=mx1-mn1;
	ll ans2=mx2-mn2;
	ans=max(ans1,ans2);
	cout<<ans<<endl;
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}

Measured memory_bytes: 3636
n = int(input())
"""素因数分解"""
def factrize(n):
    b = 2
    while b*b <= n:
        if n % b == 0:
            return False
        b = b+1
    return True

f = [2]

for i in range(3,10**5+2,2):
    if factrize(i):
        f.append(i)

c = []

for j in f:
    if (j + 1)//2 in f:
        c.append(j)

o = []
res = 0
for k in range(10**5+1):
    if k in c:
        res += 1
    elif c == 2017:
        res += 1
    o.append(res)
    

for l in range(n):
    l,r = map(int,input().split())
    print(o[r]-o[l-1])





Measured memory_bytes: 51676
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

fn solve() {
	let s = read!(String);
	let mut flag = true;
	for (idx,c) in s.chars().enumerate(){
		if idx==0&&c!='h' {
			flag = false;
		}
		if idx==1&&c!='i' {
			flag = false;
		}
	}
	if s.len()%2!=0 {
		flag = false;
	}
	if flag {
		println!("Yes");
	}
	else{
		println!("No");
	}
	
}

fn run() {
    solve();
}


Measured memory_bytes: 8572
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B,k,i,count=0;
    cin >> k >> A >>B;
    for(i=A;i<=B;i++)
    {
       if(i%k==0)
        count=1;
    }
    if(count==1)
    {
        cout << "OK";
    }
    else
    {
        cout << "NG";
    }

}


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

bool check(long long A, long long B, long long P) {
	long long E1 = (A + P - 1) / P;
	long long E2 = B;
	if (E1 - 1LL <= E2) return true;
	return false;
}

long long get_min(long long A, long long B) {
	if (A < B) swap(A, B);
	
	long long L = 1, R = (1LL << 30), M, minx = (1LL << 30);
	for (int i = 0; i < 35; i++) {
		M = (L + R) / 2;
		bool I = check(A, B, M);
		if (I == true) { minx = min(minx, M); R = M; }
		else { L = M; }
	}
	return minx;
}

long long get_rironti(long long A, long long B, long long P) {
	long long L = 0, R = (1LL << 30), M, maxn = 0;
	for (int i = 0; i < 35; i++) {
		M = (L + R) / 2;
		long long B1 = A - P * M;
		long long B2 = B - M;
		bool ok = false;
		if (B1 < 0 || B2 < 0 || B1 * P < B2) ok = true;

		if (ok == false) { maxn = max(maxn, M); L = M; }
		else { R = M; }
	}
	return maxn;
}

string query(long long A, long long B, long long C, long long D) {
	bool flag = false;
	if (A < B) { flag = true; swap(A, B); swap(C, D); C = (A + B) - C + 1; D = (A + B) - D + 1; }

	long long L = get_min(A, B);
	long long C1, C2;
	if (A > B*L) {
		C1 = B + 1; C2 = 0;
	}
	else {
		C1 = get_rironti(A, B, L);
		C2 = get_rironti(B, A, L);
	}

	long long rem1 = A - L * C1 - C2;
	long long rem2 = B - C1 - L * C2;

	string str = "";
	for (int i = C; i <= D; i++) {
		if (1LL * i <= C1 * (L + 1)) {
			if ((i - 1) % (L + 1) != L) str += "A";
			else str += "B";
		}
		else if (1LL * ((A + B) - i + 1LL) <= C2 * (L + 1)) {
			long long R = (A + B) - i + 1LL;
			if ((R - 1) % (L + 1) != L) str += "B";
			else str += "A";
		}
		else {
			long long R = 1LL * i - 1LL * (L + 1) * C1;
			if (R - 1 < rem1) str += "A";
			else str += "B";
		}
	}
	if (flag == true) {
		reverse(str.begin(), str.end());
		for (int i = 0; i < str.size(); i++) { if (str[i] == 'A') str[i] = 'B'; else str[i] = 'A'; }
	}
	return str;
}

int main() {
	long long Q; cin >> Q;
	for (int i = 1; i <= Q; i++) {
		long long p1, p2, p3, p4; cin >> p1 >> p2 >> p3 >> p4;
		cout << query(p1, p2, p3, p4) << endl;
	}
	return 0;
}

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

int main (void) {
    int N , K;
    cin >> N >> K;
    vector<int> H(N, 0);
    for (int i = 0; i < N; i++) {
        cin >> H.at(i);
    }
    sort(H.begin(), H.end());
    int minimum_diff = H.at(0) - H.at(0+K-1);
    for (int i = 1; i < N-(K-1); i++) {
        minimum_diff = max(minimum_diff, H.at(i) - H.at(i+(K-1)) );
    }
    cout << abs(minimum_diff) << endl;
    
}

Measured memory_bytes: 640
#include <iostream>
#include <set>

using namespace std;

int main()
{
    set<int> se;
    int n;
    cin >> n;

    int x;
    for (int i = 0; i < n ; i ++ )
    {
        cin >> x;
        se.insert(x);
    }

    if(se.size() != n) cout << "NO" << endl;
    else cout << "YES" << endl;

    return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if ((a < c && c < b) || (b < c && c < a)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
using namespace std;
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map> // pair
#define ll long long

int main(){

    ll N;
    ll minv = 100000000000000000;
    int pos = 0;

    cin >> N;
    for(int i=0;i<5;i++){
        ll tmp;
        cin >> tmp;
        if(minv>tmp){
            minv = tmp;
            pos = i;
        }
    }

    ll ans = 0;
    
    if(N%minv==0){
        ans = ans = long(N/minv) + (5-pos) + pos - 1;
    }else{
    ans = long(N/minv) + (5-pos) + pos;
    }
    cout << ans << endl;
    
    /*
    while(city[5]!=N){
        ll tmp0 = min(v[0],city[0]);    
        ll tmp1 = min(v[1],city[1]);    
        ll tmp2 = min(v[2],city[2]);    
        ll tmp3 = min(v[3],city[3]);    
        ll tmp4 = min(v[4],city[4]);   
        
        city[0] -= tmp0;
        city[1] += tmp0;
        
        city[1] -= tmp1;
        city[2] += tmp1;
        
        city[2] -= tmp2;
        city[3] += tmp2;
        
        city[3] -= tmp3;
        city[4] += tmp3;
        
        city[4] -= tmp4;
        city[5] += tmp4;
        
        ans++;
    }

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


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
long long mod=1000000007;
long long rj[410][410];
long long C[1100][1100];
long long dp[410][410];
long long t[410];
int p[510];
int q[510];
int main(){
	C[0][0]=1;
	for(int i=0;i<1060;i++){
		for(int j=0;j<=i;j++){
			C[i+1][j]=(C[i+1][j]+C[i][j])%mod;
			C[i+1][j+1]=(C[i+1][j+1]+C[i][j])%mod;
		}
	}
	for(int i=0;i<410;i++){
		rj[i][0]=1;
		for(int j=1;j<410;j++)rj[i][j]=rj[i][j-1]*i%mod;
	}
	int a,b;scanf("%d%d",&a,&b);
	dp[0][0]=1;
	for(int i=0;i<a;i++)scanf("%d",p+i);
	for(int i=0;i<a;i++)scanf("%d",q+i);
	for(int i=0;i<a;i++){
		
		for(int j=0;j<=b;j++){
			t[j]=0;
			for(int k=p[i];k<=q[i];k++){
				t[j]=(t[j]+rj[k][j])%mod;
			}
		}
		for(int j=0;j<=b;j++){
			if(!dp[i][j])continue;
			for(int k=0;j+k<=b;k++){
				dp[i+1][j+k]=(dp[i+1][j+k]+dp[i][j]*t[k])%mod;
			}
		}
	}
	printf("%lld\n",dp[a][b]);
}

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

vector< vector<int> > friends;
vector< vector<int> > block;
int *connect;
int *islandnum;
int island = 0;
bool *done;

void solve(int now) {
	if (done[now] == true){
		return;
	}
//	cout << "now = " << now << endl;
	done[now] = true;
	islandnum[now] = island;
	connect[island]++;
	int i, j;
	int size = friends[now].size();
	for (i = 0; i < size; i++) {
		solve(friends[now][i]);
	}
	return;
}

int main()
{
	int n, m, k;
	int a, b;
	int i, j;

	cin >> n >> m >> k;
	
	friends.resize(n + 1);
	block.resize(n + 1);
	
	int *sns = new int[n + 1];
	int *ans = new int[n + 1];
	done = new bool[n + 1];
	connect = new int[n + 1];
	islandnum = new int[n + 1];

	for (i = 0; i <= n; i++) {
		done[i] = false;
		sns[i] = 1;
		connect[i] = 0;
	}

	for (i = 0; i < m; i++) {
		cin >> a >> b;
		friends[a].push_back(b);
		friends[b].push_back(a);
		sns[a]++;
		sns[b]++;
	}
	for (i = 0; i < k; i++) {
		cin >> a >> b;
		block[a].push_back(b);
		block[b].push_back(a);
		sns[a]++;
		sns[b]++;
	}

	for (i = 1; i <= n; i++) {
		if (done[i] == false) {
			solve(i);
			island++;
		}
	}

	int size;
	int islandthis;
	for (i = 1; i <= n; i++) {
		size = block[i].size();
		islandthis = islandnum[i];
		ans[i] = connect[islandthis] - sns[i];
		for (j = 0; j < size; j++) {
			if (islandthis != islandnum[block[i][j] ] ){
//				cout << i << " / " << block[i][j] << endl;
				ans[i]++;
			}
		}
	}

	cout << ans[1];
	for (i = 2; i <= n; i++) {
		cout << " "<< ans[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 13440
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char inputline[100];
int a,b,N;
int alice,borys;

int main(){

	alice = 0;
	borys = 0;

	fgets(inputline,sizeof(inputline),stdin);
	sscanf(inputline,"%d %d %d",&N,&a,&b);

	alice = a;
	borys = b;

	for(int i=0;i<100;i++){

		if(alice + 1  !=  borys){

			alice = alice + 1;

		}
		
		else if(alice + 1 == borys){

			if(alice == 0){

				printf("Borys\n");

				return 0;

			}

			alice = alice -1;

		}

		if(borys - 1 != alice){

			borys = borys - 1;

		}

		else if(borys - 1 == alice){

			if(borys == N){
				printf("Alice\n");

				return 0;
			}

			borys = borys + 1;

		}

	}
}


Measured memory_bytes: 384
#include  "bits/stdc++.h"
//#include  <iostream>
 using namespace std;
 
#define IOS         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define mem(a,v)    memset((a), (v), sizeof (a))
#define FOR(i,a,n)  for(int i = (a); i<(n); ++i) 
#define FORE(i,a,n) for(int i = (a); i<=(n); ++i)
#define mp(a , b)   make_pair(a , b)
#define pb(a)       push_back(a)

#define anal         '\n'

#define M 1000000007 
typedef long long ll;


int main(){
     
    IOS;
    
 //   freopen("input.in", "r", stdin);
  //  freopen("output.in", "w", stdout);
    
   int n;
    cin>>n;
  
   printf("%0.3f",2*3.14*n);


 

  return  0 ;
   	    
}

Measured memory_bytes: 3784
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if (x < 1200) {
			System.out.println("ABC");
		} else {
			System.out.println("ARC");
		}
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int getLCS(char*, char*);
int C[1001][1001];

main(){
	char x[1001], y[1001];
	int q, i;

	scanf("%d", &q);
	for (i = 0; i < q; i++){
		scanf("%s%s", x, y);
		printf("%d\n", getLCS(x, y));
	}
	return 0;
}

int getLCS(char *x, char *y){
	int i, j, lenX, lenY;

	lenX = strlen(x);
	lenY = strlen(y);

	for (i = 0; i < lenX; i++){
		for (j = 0; j < lenY; j++){
			if (x[i] == y[j]) C[i + 1][j + 1] = C[i][j] + 1;
			else C[i + 1][j + 1] = ((C[i][j+1] > C[i+1][j])?  C[i][j+1] : C[i+1][j]);
		}
	}

	return C[lenX][lenY];
}

Measured memory_bytes: 4520
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = [INT() for _ in range(N)]

r = 0
cnt = 0
flags = [0] * N
flags[0] = 1
while True:
    r = A[r] - 1
    if flags[r] == 1:
        print(-1)
        break
    else:
        flags[r] += 1
        cnt += 1

    if flags[1] == 1:
        print(cnt)
        break


Measured memory_bytes: 14660
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string.h>
#include <stdlib.h>
#include <limits>
#include <iomanip>
using namespace std;

#define MAX_N 100000

int main(){

    int N, K;
    cin >> N >> K;

    vector<long> H(N, 0);

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

    sort( H.begin(), H.end(), std::greater<long>() );


    long sum_att = 0;

    for( int i = K ; i < H.size()  ; i++ ){
        sum_att += H[i];
    }

    cout << sum_att << endl;

}

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

int solve(int n, int k, vector<int>h){
  vector<int>dp(n, INF);
  dp[0] = 0;
  for (int i=0; i<n; i++){
    for (int j=i+1; j<=i+k; j++){
      if (j<n){
        dp[j] = min(
          dp[j],
          dp[i] + abs(h[j] - h[i])
        );
      }
    }
  }
  return dp[n-1];
}

int main(){
  int n,k; cin>>n>>k;
  vector<int>h(n); rep(i,n) cin>>h[i];
  cout << solve(n,k,h);
}

Measured memory_bytes: 4252
/*
author: Apoorv Singh
*/

#include <bits/stdc++.h>
using namespace std;

typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){ for (X a : v) x << a << ' '; return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const vector< pair<X, Y> >& v) {for (pair <X, Y> it : v) x << it.first << ' ' << it.second << endl; return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (pair <T, S> it : v) os << it.first << " => " << it.second << endl; return os; }

double pi = 3.14159265358979323846264338327950288419716939937510582097494459230;
int modulo = 1e9 + 7;

int fpow(int a, int n)
{
    int ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n; cin >> n;
    multiset <int> s;
    int ans = 0;
    for (int i = 1, num; i <= n; ++i)
    {
        cin >> num; num = -num;
        if (s.empty())
        {
            s.insert(num);
            ++ans; continue;
        }

        auto it = s.upper_bound(num);
        if (it == s.end())
        {
            ++ans; s.insert(num);
            continue;
        }

        s.erase(it); s.insert(num);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int N[101] = {};
	vector<int> vM;
	vM.reserve(100);
	int c = 0, k;
	while(cin >> k){
		++N[k];
		if(N[k] > c){
			c = N[k];
			vM.clear();
			vM.push_back(k);
		} else if( N[k] == c)
			vM.push_back(k);
	}
	sort(vM.begin(), vM.end());
	for(int i = 0; i < vM.size(); ++i)
		cout << vM[i] << "\n";
	return 0;
}

Measured memory_bytes: 1216