akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<string.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
#define MAX 200000
#define NIL -1

int N;
string S;


ll ans;
int R[4000],G[4000],B[4000];



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

	cin >> N;
	cin >> S;

	FOR(i, 0, N) {
		if (S[i] == 'R')R[i]++;
		if (S[i] == 'G')G[i]++;
		if (S[i] == 'B')B[i]++;
		if (i != 0) {
			R[i] += R[i - 1];
			G[i] += G[i - 1];
			B[i] += B[i - 1];
		}
	}

	FOR(j, 1, N-1) {
		FOR(k, j+1, N) {
			if (S[j] == S[k])continue;

			if (S[j] != 'R'&&S[k] != 'R')ans += R[j - 1];
			if (S[j] != 'G'&&S[k] != 'G')ans += G[j - 1];
			if (S[j] != 'B'&&S[k] != 'B')ans += B[j - 1];

			int i = j * 2 - k;
			if (i >= 0) {
				if (S[i] != S[j] && S[i] != S[k])ans--;
			}


		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3216
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect, heapq
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

data = [(a,i) for i,a in enumerate(A)]
data.sort(reverse = True)

dp = [[0] * (n+1) for i in range(n+1)]
for i in range(n):
  for l in range(i+1):
    r = i-l
    dp[l+1][r] = max(dp[l+1][r], dp[l][r] + data[i][0] * abs(data[i][1] - l))
    dp[l][r+1] = max(dp[l][r+1], dp[l][r] + data[i][0] * abs(data[i][1]-(n-1-r)))  

ans = 0
for i in range(n):
  ans = max(ans,dp[i][n-i])
print(ans)


Measured memory_bytes: 101064
N = int(input())
li = list(map(int,input().split()))
lia = li[:]
lia.sort()
index1 = int(N/2)
index2 = int((N-2)/2)
ave1 = lia[index2]
ave2 = lia[index1]
for i in range(N) :
    if li[i] <= ave1 :
        print(ave2)
    else :
        print(ave1)

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

    const int MOD = 1000000007;
    const double PI = acos(-1); 

    //long long
    using ll = long long;

    //出力系
    #define print(x) cout << x << endl
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

    //for
    #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

    //最大公約数（ll）
    ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

    //素因数分解
    vector<pair<ll, int>>factorize(ll n){
      vector<pair<ll, int>> res;
      for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
          n /= i;
          res.back().second++;
        }
      }
    if(n != 1) res.emplace_back(n, 1);
    return res;
    }



  // // 二分探索(最小値を出す問題は疑う)
  // bool C(ll x){
  //     ll res = 0;
  //     for(int i = 0; i < N; ++i){
  // 		res += max(0ll, A[i]-x/F[i]);
  //     }
  //     return res <= K;
  // }

  //   ll binary_search(ll ok, ll ng){
  //     while(abs(ok - ng) > 1){
  //       ll mid = (ok + ng) / 2;
  //       if(C(mid)) ok = mid;
  //       else ng = mid;
  //     }
  //     return ok;
  //   }


  int main(){
    int C[3][3];
    REP(i, 3)REP(j, 3){
      int x;
      cin >> x;
      C[i][j] = x;
    }

  int pos = 0;
  for(int k = 0; k <= C[0][0]; k++){
    int b1 = C[0][0] - k;
    int b2 = C[0][1] - k;
    int b3 = C[0][2] - k;
    int a2 = C[1][0] - b1;
    int a3 = C[2][0] - b1;
    if(a2 + b2 == C[1][1] && a3 + b2 == C[2][1] && a2 + b3 == C[1][2] && a3 + b3 == C[2][2]) {
      yes;
      return 0;
    }
  }
  no;
  }

Measured memory_bytes: 256
import math

def is_prime(n):
    if n == 1: return True

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

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

A, B = map(int, input().split())
div1 = make_divisors(A)
# print(div1)
div2 = make_divisors(B)
nums = list(set(div1).intersection(set(div2)))
# print(nums)
nums = [x for x in nums if is_prime(x)]
# print(nums)
cnt = len(nums)
if cnt > 1:
    print(cnt)
else:
    print(1)

Measured memory_bytes: 5260
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>

#define rep(i,n) for(int (i)=0;i < (n);(i)++)
#define ll long long
#define INF 9223372036854775807

using namespace std;

// input
int a[3][3];
int N;

bool check() {
  if(a[0][0] == a[0][1] && a[0][1] == a[0][2]) {
	return true;
  } else if(a[1][0] == a[1][1] && a[1][1] == a[1][2]) {
	return true;
  } else if(a[2][0] == a[2][1] && a[2][1] == a[2][2]) {
	return true;
  } else if(a[0][0] == a[1][0] && a[1][0] == a[2][0]) {
	return true;
  } else if(a[0][1] == a[1][1] && a[1][1] == a[2][1]) {
	return true;
  } else if(a[0][2] == a[1][2] && a[1][2] == a[2][2]) {
	return true;
  } else if(a[0][0] == a[1][1] && a[1][1] == a[2][2]) {
	return true;
  } else if(a[0][2] == a[1][1] && a[1][1] == a[0][2]) {
	return true;
  }

  return false;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  rep(i,3) cin >> a[i][0] >> a[i][1] >> a[i][2];
  cin >> N;
  rep(i,N) {
	int cell;
	cin >> cell;
	rep(i,3) rep(j,3) if(a[i][j] == cell) a[i][j] = -1;
  }

  if(check()) {
	cout << "Yes" <<endl;
  } else {
	cout << "No" << endl;
  }
}



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

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

signed main() {
    ll N,T;
    cin>>N>>T;
    ll k = 0, ans = 0;
    rep(i,0,N) {
        ll t;
        cin>>t;
        ll sta = max(k, t);
        ll fin = t + T;
        ans += fin-sta;
        k = fin;
    }
    cout<<ans<<endl;
    return 0;
}


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

int N;
std::string v;

  int wcountl = 0;
  int rcountl = 0;
  int wcountr = 0;
  int rcountr = 0;

int what() {
  int wcl = wcountl;
  int rcl = rcountl;
  int wcr = wcountr;
  int rcr = rcountr;
  int swp = std::min(wcl, rcr);
  int cst = swp;
  wcl -= swp;
  rcr -= swp;
  cst += wcl;
  cst += rcr;
  return cst;
}

int main() {
  std::cin >> N;
  std::cin >> v;


  for (int i = 0; i < v.size(); ++i) {
    wcountr += (v[i] == 'W');
    rcountr += (v[i] == 'R');
  }
  int best = what();
  for (int piv = 0; piv <= v.size(); ++piv) {
    if (v[piv] == 'W') {
      wcountl++;
      wcountr--;
    } else {
      rcountl++;
      rcountr--;
    }
    best = std::min(best, what());
  }
  printf("%d\n", best);
}


Measured memory_bytes: 3764
const processData = (lines) => {
    const [D, T, S] = lines[0].split(' ').map(x => +x)

    console.log(D/S <= T ? 'Yes' : 'No')    
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    processData(lines)
})


Measured memory_bytes: 29900
n=int(input())
a=[0]*n
b=[0]*n
for i in range(n):
    a[i],b[i]=map(int,input().split())

a=sorted(a)
b=sorted(b)

if n%2!=0:
    ans=b[(n-1)//2]-a[(n-1)//2]+1
else:
    ans=(b[n//2-1]+b[n//2])-(a[n//2-1]+a[n//2])+1

print(ans)

Measured memory_bytes: 26844
import java.util.Scanner;

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

            boolean[] isBeki = new boolean[X + 1];
            isBeki[1] = true;
            bLoop: for (int b = 2; b < Math.sqrt(X) + 1; b++) {
                for (int n = b * b;; n *= b) {
                    if (n > X) {
                        continue bLoop;
                    }
                    isBeki[n] = true;
                }
            }

            for (int i = X; i >= 1; i--) {
                if (isBeki[i]) {
                    System.out.println(i);
                    return;
                }
            }
        }
    }
}


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

using namespace std;

int main() {
	int a[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	int n; cin >> n;
	vector<int> b(n);
	for (int &x : b) cin >> x;

	bool ans[3][3] = { false };

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (a[j][k] == b[i]) {
					ans[j][k] = true;
				}
			}
		}
	}

	bool c = false;
	if (ans[0][0] && ans[0][1] && ans[0][2]) c = true;
	if (ans[1][0] && ans[1][1] && ans[1][2]) c = true;
	if (ans[2][0] && ans[2][1] && ans[2][2]) c = true;

	
	if (ans[0][0] && ans[1][0] && ans[2][0]) c = true;
	if (ans[0][1] && ans[1][1] && ans[2][1]) c = true;
	if (ans[0][2] && ans[1][2] && ans[2][2]) c = true;

	if (ans[0][0] && ans[1][1] && ans[2][2]) c = true;
	if (ans[0][2] && ans[1][1] && ans[2][0]) c = true;

	if (c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a[] = new int[3];
        for (int i = 0; i < 3; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(a);
        if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 25044
N = int(input())
judge = ["AC", "WA" , "TLE", "RE"]
res = [0, 0, 0, 0]
for i in range(N):
  s = input()
  if s == judge[0]:
    res[0] += 1
  elif s == judge[1]:
    res[1] += 1
  elif s == judge[2]:
    res[2] += 1
  elif s == judge[3]:
    res[3] += 1
print("AC x {}".format(res[0]))
print("WA x {}".format(res[1]))
print("TLE x {}".format(res[2]))
print("RE x {}".format(res[3]))

Measured memory_bytes: 9224
import sys
from collections import defaultdict
input = sys.stdin.readline


dic = defaultdict(list)
n, m = map(int, input().split())
for i in range(m):
    pref, year = map(int, input().split())
    dic[pref].append([year, i])

cities = [0]*m


for i in range(1, n+1):
    dic[i].sort(reverse=True)
    count = 0
    while dic[i]:
        year, no = dic[i].pop()
        count += 1
        cities[no] = str(i).zfill(6) + str(count).zfill(6)

for city in cities:
    print(city)

Measured memory_bytes: 85852
import sys
x,n=map(int,input().split())
p=list(map(int,input().split()))

if n==0:
    print(x)
    sys.exit()

for i in range(110):
    if (x-i) not in p:
        print(x-i)
        sys.exit()
    if (x+i) not in p:
        print(x+i)
        sys.exit()

Measured memory_bytes: 9188
import java.util.Scanner;
class Main{
	public static void main(String args[]){
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext()){	
			int a = scanner.nextInt();//一つ目の数字を取り出す
			int b = scanner.nextInt();//スペース後の２つ目の数字を取り出す
			int ans = a+b;
			if(ans<10){
				System.out.println("1");
			}
			if(ans<100 && ans>9){
				System.out.println("2");
			}
			if(ans<1000 && ans>99){
				System.out.println("3");
			}
			if(ans<10000 && ans>999){
				System.out.println("4");
			}
			if(ans<100000 && ans>9999){
				System.out.println("5");
			}
			if(ans<1000000 && ans>99999){
				System.out.println("6");
			}
			if(ans<10000000 && ans>999999){
				System.out.println("7");
			}
		}
	}
}


Measured memory_bytes: 20428
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+12;
long long a[N];
int main()
{
	int n;
	scanf("%d",&n);
	int tot=0;
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]),a[i]-=i;
	sort(a+1,a+n+1);
	long long ans=0;
	for(int i=1;i<=n;i++) ans+=abs(a[i]-a[(1+n)/2]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

char str1[3002], str2[3002];
int dp[3001][3001], prv[3001][3001];
char ans[3001];
int main() {
    scanf("%s%s", &str1[1], &str2[1]);
    int len1 = strlen(&str1[1]), len2 = strlen(&str2[1]);
    reps(i, len1) reps(j, len2) {
        dp[i][j] = max({dp[i - 1][j], dp[i][j - 1], (str1[i] == str2[j]) ? dp[i - 1][j - 1] + 1 : 0});
        if (dp[i][j] == dp[i - 1][j]) {
            prv[i][j] = 0;
        } else if (dp[i][j] == dp[i][j - 1]) {
            prv[i][j] = 1;
        } else {
            prv[i][j] = 2;
        }
    }
    int ci = len1, cj = len2, ck = dp[len1][len2];
    while (ck != 0) {
        if (prv[ci][cj] == 0) {
            ci--;
        } else if (prv[ci][cj] == 1) {
            cj--;
        } else {
            ans[--ck] = str1[ci];
            ci--;
            cj--;
        }
    }
    printf("%s\n", ans);
    return 0;
}

Measured memory_bytes: 73968
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	string str;cin>>str;
	int n=str.size(),gen=1,ans=1;
	while(gen<n){
		if(str[gen-1]!=str[gen]){gen++;ans++;}
		else if(gen+3<=n){gen+=3;ans+=2;}
		else{ans+=n-gen-1;gen=n;}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
an=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in an:
  x=c
  for j in range(m):
    x+=i[j]*b[j]
  if(x>0):
    ans+=1
print(ans)

Measured memory_bytes: 3060
S = input()

flag = True

for i in range(len(S)):
    if (i+1) % 2 == 0:
        if S[i] == 'R':
            flag = False
    else:
        if S[i] == 'L':
            flag = False

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


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, k;
    cin >> n >> k;

    double ans = 0.0;
    exrep(i, 1, n) {
        ll p = 1;
        ll x = i;
        while(x < k) {
            x *= 2;
            p *= 2;
        }
        ans += 1.0/(double)p;
    }
    ans *= 1.0/(double)n;
    
    exout(ans);
    re0;
}

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

#define INF 1.0E+8

int main() {
	int n;
	cin >> n;
	int t, a;
	cin >> t >> a;
	vector<int> h(n);
	for(int i = 0; i < n; i++) cin >> h.at(i);

	int ans;
	double tmp_diff = INF;
	for(int i = 0; i < n; i++) {
		double diff = fabs(a - (t - h.at(i) * 0.006));
		if(diff < tmp_diff) {
			ans = i + 1;
			tmp_diff = diff;
		}
	}

	cout << ans << endl;

 	return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
#include <math.h>
//#include <vector>
//#include <string>
typedef long long LL;
using namespace std;

int main(){
    LL n;
    LL m;
    LL ans;
    LL ans_l=1;
    LL ans_h;
    LL tmp;
    cin >> n >> m;
    ans_h=m;

    tmp=(LL)sqrt(m);
    if(m/n<tmp){
        tmp=m/n;
    }
    for(int i=2; i<=tmp; i++){
        if(m%i==0 && i>ans_l){
            ans_l=i;
        }
    }
    tmp=(LL)sqrt(m);
    if(tmp>=n){
        for(int i=n; i<=tmp; i++){
            if(m%i==0 && i<ans_h){
                ans_h=i;
            }
        }
    }
    ans_h=m/ans_h;
    ans=max(ans_l, ans_h);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=2e5+9;
const ll MOD=998244353;

ll fact[N],invfact[N];
ll pow(ll a,ll n){
  if(n==0)  return 1;
  if(n==1)  return a;
  ll temp=pow(a,n/2);
  temp*=temp;temp%=MOD;
  if(n&1) temp*=a;temp%=MOD;
  return temp;
}
void pre(){
  fact[0]=1;
  for(int i=1;i<N;i++){
    fact[i]=fact[i-1]*i%MOD;
  }
  for(int i=0;i<N;i++){
    invfact[i]=pow(fact[i],MOD-2);
  }
}

ll ncr(ll n,ll r){
  return fact[n]*invfact[r]%MOD*invfact[n-r]%MOD;
}

signed main(){
  fastio
  pre();
  ll n,m,k;
  cin>>n>>m>>k;
  ll ans=0;
  for(int i=0;i<=k;i++){
    // cout<<i<<" "<<n-1-i<<"\n";
    ans+=m*ncr(n-1,i)%MOD*pow(m-1,n-1-i)%MOD;
    ans%=MOD;
  }
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 6776
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;cin>>n;
  	float ans=1.0;
  	ans*=2.0;
  	ans*=3.14;
  	ans*=(n*1.0);
  	cout<<ps(ans,2)<<endl;
    return 0;
}

Measured memory_bytes: 3804
import sys
import itertools

N=input()
P=tuple( map(int, sys.stdin.readline().split()) )
Q=tuple( map(int, sys.stdin.readline().split()) )

L=list( itertools.permutations(range(1,N+1)) )
L.sort()

for i,x in enumerate(L):
    if x==P: a=i
    if x==Q: b=i

print abs(a-b)


Measured memory_bytes: 37660
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_C
{
    class C081
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]), K = int.Parse(s[1]);
            List<int> A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();

            var dic = A.ToLookup(x => x)
                .ToDictionary(x => x.Key, x => (x.Count()))
                .OrderByDescending(x => x.Value);

            int c = 0;
            int counter = 0;
            foreach(var p in dic)
            {
                if (counter >= K) break;
                c += p.Value;
                counter++;           
            }
            int mustChange = N - c;
            Console.WriteLine(mustChange);
        }


    }
}


Measured memory_bytes: 51908
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

const int mod = 998244353;

int mul(int a, int b)
{
    return (LL)a * b % mod;
}

int binpow(int a, int n)
{
    int res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = mul(res, a);
        a = mul(a, a);
        n >>= 1;
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    VI d(n);
    FOR(i, 0, n)
        cin >> d[i];
    VI cnt(n);
    int depth = 0;
    for (auto x : d)
    {
        cnt[x]++;
        depth = max(depth, x);
    }
    LL ans = (cnt[0] == 1 && d[0] == 0);
    FOR(i, 1, depth + 1)
    {
        ans = mul(ans, binpow(cnt[i - 1], cnt[i]));
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3988
#include<stdio.h>

int main(){
   int W,H,x,y,r;
   scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
   if(0<=x-r && 0<=y-r && x+r<=W && y+r<=H)
      printf("Yes\n");
   else
      printf("No\n");
   return 0;
}



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

using namespace std;

int main()
{
  int a[3], b[3];
  cin >> a[0] >> b[0] >> a[1] >> b[1] >> a[2] >> b[2];
  
  int m[4][4] = {0};
  m[a[0] - 1][b[0] - 1] = 1;
  m[b[0] - 1][a[0] - 1] = 1;
  m[a[1] - 1][b[1] - 1] = 1;
  m[b[1] - 1][a[1] - 1] = 1;
  m[a[2] - 1][b[2] - 1] = 1;
  m[b[2] - 1][a[2] - 1] = 1;

  int vis[4] = {};
  int pos = 0;
  vis[0] = 1;
  for(int i = 0;i < 4;i++){
    for(int j = 0;j <4 ;j++) {
      if(m[pos][j] == 1 && vis[j] != 1) {
        pos = j;
        vis[j] = 1;
        break;
      }
    }
  }

  if (vis[0] + vis[1] + vis[2] + vis[3] == 4) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

ll lcm(ll a, ll b){
    ll g = gcd(a, b);
    return (a / g) * b;
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    ll a,b;
    cin >> a >> b;
    cout << lcm(a,b) << endl;
    return 0;
}

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

int main(){
    string S;
    cin >> S;
    //3つの間にマイナスとプラスを入れてみる　false true
    string ans = "";
    for(int tmp = 0; tmp < (1 << 3); tmp++){
        bitset<3> s(tmp);
        string marks = "";
        for(int i = 0; i < 3; i++){
            if(s.test(i)) marks.push_back('+');
            else marks.push_back('-');
        }
        int sum = S[0] - 48;
        for(int i = 0; i < 3; i++){
            if(marks.at(i) == '+'){
                sum += S[i + 1] - 48;
            }else{
                sum -= S[i + 1] - 48;
            }
        }
        if(sum == 7){
            ans = {S[0], marks.at(0), S[1], marks.at(1), S[2], marks.at(2), S[3]};
        }
    }
    cout << ans << "=7" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

int main(){
  int a, b;
  cin >> a >> b;
  int ans;
  ans = (b - 1 + a - 2) / (a - 1);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int l=s.length();
    int p=(l-1)/2;
    int q=0;

    for(int i=0;i<p/2;i++)
    {
       if(s[i]==s[p-1-i])
q++;
    }
    int t=(l+3)/2;
    int c=0;
    for(int i=0;i<p;i++)
    {
        if(s[i]!=s[l-i-1])
            c=1;
    }
    if(c==0&&q==p/2)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int S = sc.nextInt();
	        int N = S/3;
	        long ans=0;
	        for(int i=1;i<=N;i++) {
	        	ans=(ans+factorial(i-1+S-3*i)*modinv(factorial(i-1))%mod* modinv(factorial(S-3*i)%mod) )%mod;
	        }
	        
	        
	        System.out.println(ans);
		 }
		 
		 
			public static long factorial(long n) {
				long tmp = 1;
				for (long i=n;i>0;i--) {
					tmp = (tmp*i)%mod;
				}
				return tmp;
			}
		 
			public static long pow(long a,long n) {
			    long res=1;
			    while (n>0) {
			        if ((n-n/2*2)==1) {
			            res=(res*a)%mod;
			        }
			        a=(a*a)%mod;
			        n>>=1;
			    }
			    return res;
			}
		 
			public static long modinv(long n) {
				return pow(n, mod-2);
			}
		 
			public static long nCr(long n, long r) {
				if(n<r) {
					return 0;
				} else {
					return factorial(n) * modinv(factorial(n-r)) % mod * modinv(factorial(r)) % mod;
				}
			}		 
	}

Measured memory_bytes: 35680
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
    //Seiranchan!
    int h,w;
    cin >> h>>w;

    vector<string> vec(h);
    REP(i,h) cin >> vec[i];

        REP(i,w+2) cout << '#';
    cout << endl;

    REP(i,h){
        cout << '#'<< vec[i] << '#' <<endl;
    }

    REP(i,w+2) cout << '#';
    cout << endl;

}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

inline int read()
{
	int res = 0; bool bo = 0; char c;
	while (((c = getchar()) < '0' || c > '9') && c != '-');
	if (c == '-') bo = 1; else res = c - 48;
	while ((c = getchar()) >= '0' && c <= '9')
		res = (res << 3) + (res << 1) + (c - 48);
	return bo ? ~res + 1 : res;
}

const int N = 105;

int n, a, b, c1, c2, c3;

int main()
{
	n = read(); a = read(); b = read();
	while (n--)
	{
		int x = read();
		if (x <= a) c1++;
		else if (x <= b) c2++;
		else c3++;
	}
	std::cout << std::min(c1, std::min(c2, c3)) << std::endl;
	return 0;
}

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


int main(){
	int k;
	int a,b;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++){
		if(i%k==0){
			cout<<"OK"<<endl;
			return 0;
		}
	}
	cout<<"NG"<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	set<int> a;
	a.insert(n);
	for(int i=2;;i++){
		if(n%2==0)
			n/=2;
		else
			n=n*3+1;
		a.insert(n);
		if(i!=a.size()){
			cout<<i;
			return 0;
			}
		}
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    
    int count = 0;
    while(A <= B){
      A *= 2;
      count++;
    }
    System.out.println(count);
  }
}

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

int p;
int ppow(int a) {
	int b = p - 2, res = 1;
	while (b) {
		if (b & 1)res = (res*a) % p;
		a = (a*a) % p;
		b >>= 1;
	}
	return res;
}
int o2(string&s, int&i);
int o3(string&s, int&i);
int num(string&s, int&i, int p);
int o1(string&s, int&i) {
	int v = o2(s, i);
	if (v == -1)return -1;
	while (s[i] == '+' || s[i] == '-') {
		char op = s[i++];
		int v2 = o2(s, i);
		if (v2 == -1)return -1;
		if (op == '+')(v += v2) %= p;
		else v = (v + p - v2) % p;
	}
	return v;
}
int o2(string&s, int&i) {
	int v = o3(s, i);
	if (v == -1)return -1;
	while (s[i] == '*' || s[i] == '/') {
		char op = s[i++];
		int v2 = o3(s, i);
		if (v2 == -1)return -1;
		if (op == '*')(v *= v2) %= p;
		else if (v2 == 0)return -1;
		else v = (v*ppow(v2)) % p;
	}
	return v;
}
int o3(string&s, int&i) {
	if (isdigit(s[i]))return num(s, i, p);
	i++; int res = o1(s, i); i++;
	return res;
}
int num(string&s, int&i, int p) {
	int n = 0;
	while (isdigit(s[i]))n = (n * 10 + s[i++] - '0') % p;
	return n;
}
int main() {
	string s;
	while (getline(cin, s), s != "0:") {
		int i = 0; p = num(s, i, INT_MAX);
		string t;
		for (i++; i < s.size(); i++) {
			if (s[i] != ' ')t += s[i];
		}
		i = 0;
		int ret = o1(t, i);
		if (ret == -1)puts("NG");
		else cout << t << " = " << ret << " (mod " << p << ")" << endl;
	}
}

Measured memory_bytes: 3196
package main

import "fmt"

func main() {
	var k int
	fmt.Scan(&k)

	ans := 0
	for i := 1; i <= k; i++ {
		for j := 1; j <= k; j++ {
			for l := 1; l <= k; l++ {
				ans += gcd(i, gcd(j, l))
			}
		}
	}
	fmt.Println(ans)
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

Measured memory_bytes: 1776
#!/usr/bin/env python3
import sys


def solve(S: str):
    ans = 0
    prev = ""
    now = ""
    
    for i in S:
        now += i 
        if now == prev:
            prev = ""
        else:
            prev = now
            now = ""
            ans += 1
    print(ans)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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





int main(){
	vector<int>a(5);
	for(int i= 0;i<5;i++)cin>>a[i];

	int k=0;
	cin>>k;

	string ans = "Yay!";
	for(int i=1;i<5;i++){
		if(a[i]-a[0]>k)ans=":(";
	}
	cout<<ans;

}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define INF 2000
#define white 0
#define gray 1
#define black 2
int prim();
int a[N][N];
int n;
int main(){

  int i,j;
  int sum;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      scanf("%d",&a[i][j]);
    }
  }

  sum = prim();
  
  printf("%d\n",sum);

  return 0;
}

int prim(){
  int u=0;
  int d[N],pi[N],color[N];
  int i;
  int min,sum=0;
  
  for(i=0; i<n; i++){
    d[i] = INF;
    pi[i] = -1;
    color[i] = white;
  }

  d[u] = 0;

  while(1){
    min = INF;
    u = -1;

    for(i=0; i<n; i++){
      if(color[i] != black && min > d[i]){
	min = d[i];
	u = i;
      }
    }
    
    if(min==INF) break;

    color[u] = black;

    for(i=0; i<n; i++){
      if(a[i][u] != -1){
	if(color[i] != black && a[i][u]<d[i]){
	  if(d[i]>a[u][i]){
	    d[i] = a[u][i];
	    pi[i]=u;
	    color [i] = gray;
	  }
	}
      }
    }
  }
      
  for(i=0; i<n; i++){
    if(pi[i] != -1){
      sum += a[i][pi[i]];
    }
  }

  return sum;
}

Measured memory_bytes: 636
N, K = gets.chomp.split(' ').map(&:to_i)
As = gets.chomp.split(' ').map(&:to_i)

map = [0]

i = 0
now = 1
loop_num_s = 0
loop_num_e = 0

loop do
  if map[As[now-1] - 1] == nil && i < K
    map[As[now-1] - 1] = i + 1
    now = As[now-1]
  elsif map[As[now-1] - 1] == nil && i >= K
  	puts now
    break
  else
    loop_num_s = map[As[now-1] - 1]
    loop_num_e = i + 1
    x = (K - loop_num_s) % (loop_num_e - loop_num_s)
    puts map.index(loop_num_s + x) + 1
    break
  end
  i = i + 1
end

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

int main(){
long long N;
long long sum{};
cin >> N;
for(long long i{}; i<=N; i++){
	if(i%3==0 && i%5==0){
	}else if(i%3==0){
	}else if(i%5==0){
		}else{
			sum+=i;
		}
}

cout << sum;





}


Measured memory_bytes: 3612
<?php
$array_data=array();
$array_temp=array();
$input=trim(fgets(STDIN));

while($input<>""){
	$array_data[]=$input;
	$input=trim(fgets(STDIN));
}


foreach($array_data as $val){

	$array_temp[]=explode(" ",$val);
}


$mymax=-1000000;
$mymin= 1000000;
$mysum=0;
for($i=0;$i<$array_temp[0][0];$i++){


	$mysum+=$array_temp[1][$i];

	if($mymax<$array_temp[1][$i]){

		$mymax=$array_temp[1][$i];

	}

	if($mymin>$array_temp[1][$i]){

		$mymin=$array_temp[1][$i];

	}


}


printf("%d %d %d\n" ,$mymin,$mymax,$mysum);

Measured memory_bytes: 17132
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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;
}

int main(void) {
    int A, B;
    cin >> A >> B;

    cout << max(max(A + B, A - B), A * B) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

template<typename Monoid>
struct SegmentTree {
    using F = function<Monoid(Monoid, Monoid)>;
    vector<Monoid> data;
    int n;
    const F f;
    const Monoid M;
    SegmentTree(int x, const F f, const Monoid &M) : f(f), M(M) {
        n = 1;
        while(n<x) n <<= 1;
        data.resize(2*n,M);
    }
    void set(int k, const Monoid &p) {
        data[k+n] = p;
    }
    void build() {
        for(int k = n-1; k > 0; --k) {
            data[k] = f(data[2*k + 0], data[2*k + 1]);
        }
    }
    void update(int k, const Monoid &p) {
        k += n;
        data[k] = p;
        while (k >>= 1) {
            data[k] = f(data[k*2], data[k*2 + 1]);
        }
    }
    Monoid query(int a, int b) {
        Monoid L = M, R = M;
        for(a += n, b += n; a<b; a >>= 1, b >>= 1) {
            if(a&1) L = f(L, data[a++]);
            if(b&1) R = f(data[--b], R);
        }
        return f(L,R);
    }
    Monoid operator[](const int &k) const {
        return data[k+n];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    vector<int> p(n);
    SegmentTree<int> segmin(n, [](int a,int b){return min(a,b);}, INT_MAX);
    SegmentTree<int> segmax(n, [](int a,int b){return max(a,b);}, INT_MIN);
    REP(i,n) {
        cin >> p[i];
        segmin.update(i,p[i]);
        segmax.update(i,p[i]);
    }
    vector<int> cnt(n);
    REP(i,n-1) {
        cnt[i+1] = cnt[i] + (p[i]>p[i+1]);
    }
    int ans = 1;
    int s = (cnt[k-1]-cnt[0]>0);
    REP(i,n-k) {
        int x = segmin.query(i,i+k+1);
        int y = segmax.query(i,i+k+1);
        if((s || cnt[i+k]-cnt[i+1]>0) && (p[i]!=x || p[i+k]!=y)) {
            if(cnt[i+k]-cnt[i+1]==0) s = 0;
            ++ ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;

int main(){
    int n,findID;
    cin>>n;
    rrep(i,100){
        if(n<pow(2,i)){
            findID = i-1;
            break;
        }
    }
    cout<<pow(2,findID)<<endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<tuple<string,int,int>> K;
  for(int i=0;i<N;i++){
    string S;
    int P;
    cin >> S >> P;
    K.push_back(make_tuple(S,100-P,i+1));
  }
  sort(K.begin(),K.end());
  
  for(int i=0;i<N;i++){
    cout << get<2>(K.at(i)) << endl;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1e18;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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; }


int main() {
    int n, m; cin >> n >> m;
    vector<vector<pll>> G(n);
    vector<ll> dist(n, INF);
    rep(i, m){
        ll a, b, c; cin >> a >> b >> c; a--; b--;
        G[a].push_back(pll(b, c));
        G[b].push_back(pll(a, -c));
    }

    queue<int> que;
    bool fg = true;
    rep(i, n){
        if(dist[i] != INF) continue;
        que.push(i); dist[i] = 0;
    while(!que.empty()){
        int num = que.front(); que.pop();
        for(auto edge: G[num]){
            int to = edge.first, cost = edge.second;     
            if(dist[to] == INF){
                dist[to] = dist[num] + cost;
                que.push(to);
            }else if(dist[to] != dist[num] + cost){
                fg = false;
                break;
            }
        }
        if(!fg) break;
    }
    }

    if(fg) cout << "Yes" << ln;
    else cout << "No" << ln;
}

    

Measured memory_bytes: 13824
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    if(a == 1) a = 14;
    if(b == 1) b = 14;
    
    if(a > b) cout << "Alice" << endl;
    else if(a < b) cout << "Bob" << endl;
    else cout << "Draw" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <fstream>
#include <unordered_map>
#include <vector>
#include <numeric>
#include <algorithm>

int main() {
	std::string str;
	std::cin>> str;
	std::cin>> str;
	int a = 0;
	int b = 0;
	for (int i = 0; i < str.length(); i++) {
		if (str[i] == '(') {
			a++;
		}
		else if (str[i] == ')') {
			if (a <= 0)
				b++;
			else {
				a--;
			}
		}
	}
	std::string aa(b, '(');
	std::string bb(a, ')');
	std::cout << aa << str << bb << std::endl;
}


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


int main(){
    double R;
    double lpi = 3.141592653589793238462643383279;

    //input
    cin >> R;

    cout << 2 * R * lpi << endl;

    return 0;
}


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

int main() {
	// your code goes here
	std::map<long long int,long long int> ms;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		long long int a,b;
		cin>>a>>b;
		ms[b]+=a;
	}
	long long int s=0;
	string ans="Yes";
	for(map<long long int,long long int>::iterator it=ms.begin();it!=ms.end();it++){
		s+=(*it).second;
		if((*it).first<s){
			ans="No";
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 12800
n,m=[int(x) for x in input().split()]
a=[]
b=[]
for i in [0]*n:
    a.append(input())
for i in [0]*m:
    b.append(input())
def check(x,y):
    for i in range(m):
        if a[y+i][x:x+m] != b[i]:
            return False
    return True
from itertools import product
for i,j in product(range(n-m+1),range(n-m+1)):
    if check(i,j):
        print("Yes")
        import sys
        sys.exit()
print("No")

Measured memory_bytes: 38512
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define f first
#define s second
#define ff find_first_of
#define fl find_last_of
#define all(s) (s).begin(),(s).end()
#define rall(s) (s).rbegin(),(s).rend()
#define bs(x) (bitset<18>(x)).to_string()
#define sep ios::sync_with_stdio(0),cin.tie(0)
using namespace std;
typedef long long ll;
int main()
{
    sep;
    string s;
    cin>>s;
    cout<<(s[2]==s[3] and s[4]==s[5] ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
//#include <tuple>
#include <set>
#include <string.h>
#include <functional>

#define X first
#define Y second
#define MP make_pair
//#define MT make_tuple
#define REP(i, a, n) for(int (i) = (a); (i) < (n); ++(i))
#define FOR(i, n) REP(i, 0, n)
typedef long long ll;
using namespace std;
const int MAX = 101;

template<class T, class U>
void convert(T &t, U &u)
{
	stringstream ss;
	ss << t;
	ss >> u;
}

int main()
{
	int n;
	while (cin >> n && n){
		map<char, char> tb;
		FOR(i, n){
			char a, b; cin >> a >> b;
			tb[a] = b;
		}

		int m; cin >> m;
		string ans;
		FOR(j, m){
			char t; cin >> t;
			if (tb.count(t)) ans.push_back(tb[t]);
			else ans.push_back(t);
		}

		cout << ans << endl;
 	}

	return 0;
}

Measured memory_bytes: 1332
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//AKIBA
//
int main(){
  ll A,B,K;
  cin >> A >> B >> K;

  if(B - A + 1 <= 2 * K)
  {
    //全出力
    for(ll i = A; i <= B; ++i)
    {
      cout << i << endl;
    }
  }
  else
  {
    for(ll i = A; i <= A + K - 1; ++i)
    {
      cout << i << endl;
    }
    for(ll i = B - (K - 1); i <= B; ++i)
    {
      cout << i << endl;
    }
  }
  
  return 0;
}



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

int main() {
 double a,b,d;
 int c;
 cin >> a >> b;
  c = (a + b)/2; //切り捨て
  d = (a + b)/2; //小数点以下あり
  if(d-c>0){cout << c+1  << endl;}
    else { cout << c << endl;}
    

}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
  int n,a,gs,ok;
  scanf("%d",&n);
  gs=ok=0;
  for(int i=0;i<n;i++){
    scanf("%d",&a);
    if(a%2==0){          //goosoo
    gs++;
     if(a%3==0||a%5==0){
       ok++;
     }
    }
  }
  if(gs==ok){
    printf("APPROVED");
  }else{
    printf("DENIED");
  }
  return 0;
}

Measured memory_bytes: 1720
def getinputdata():

    array_result = []    
    array_result.append(input().split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

s= arr_data[0][0]

sumdata=sum(list(map(int, list(s))))

print("Yes" if int(s) % sumdata==0 else "No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
vector<int>e[N];
int dep[N],md[N],fa[N],n,s,t;
void dfs(int u,int f)
{
	dep[u]=md[u]=dep[f]+1,fa[u]=f;
	for(auto v:e[u])
		if(v!=f)
			dfs(v,u),md[u]=max(md[u],md[v]);
}
int main()
{
	scanf("%d%d%d",&n,&s,&t);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
	dfs(t,0);
	int ans=0,x=s;
	while(1)
	{
		if(dep[s]-dep[x]>=dep[x]-dep[t])
			break;
		ans=max(ans,md[x]-1);
		x=fa[x];
	}
	printf("%d\n",ans-1);
	return 0;
}

Measured memory_bytes: 12032
n = int(input())
A = list(map(int,input().split()))
cnt = 0
ans = "APPROVED"
for i in A:
    if i%2 ==1:
        continue
    if i%2 ==0:
        if (i%3 != 0) and (i%5 != 0):
            cnt += 1
if cnt != 0:
    ans = "DENIED"
print(ans)


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

using namespace std;

typedef long long ll;

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;
}

const ll MOD = 1000000007;

ll solve(const int N, const int K, const vector<vector<int> > &edges, int cur, int prev) {
    ll acc = 1;
    if (prev == -1) {
        for (int i = 0; i < (int) edges[cur].size() + 1; i++) {
            acc = (acc * (K - i)) % MOD;
        }
    } else {
        for (int i = 0; i < (int) edges[cur].size() - 1; i++) {
            acc = (acc * (K - 2 - i)) % MOD;
        }
    }
    for (int i = 0; i < (int) edges[cur].size(); i++) {
        if (edges[cur][i] == prev) continue;
        acc = (acc * solve(N, K, edges, edges[cur][i], cur)) % MOD;
    }
    return acc;
}

int main(void) {
    int N, K;
    cin >> N >> K;

    vector<vector<int> > edges(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }

    int start;
    int max_edges = 0;
    for (int i = 0; i < N; i++) {
        if (max_edges < (int) edges[i].size()) {
            max_edges = (int) edges[i].size();
            start = i;
        }
    }

    ll ans = solve(N, K, edges, start, -1);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
using pl = pair<ll,ll>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;


int main(int argc,char* argv[])
{
    ll n,t,mi=INF,c,x;
    cin>>n>>t;
    rep(i,n){
        cin>>c>>x;
        if(x<=t&&c<mi)mi=c;
    }
    if(mi==INF)cout<<"TLE"<<endl;
    else cout<<mi<<endl;
    return 0;
}


Measured memory_bytes: 256