akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;

int n, q;
std::vector<int> s, t;

bool binary(int i) {
	int lb = -1, ub = n;
	while (ub - lb > 1) {
		int mid = (lb + ub) / 2;
		if (s[mid] == t[i]) {
			return true;
		}
		else if (s[mid] > t[i]) {
			ub = mid;
		}
		else {
			lb = mid;
		}
	}
	return false;
}

int main() {
	std::cin >> n;
	int a;
	for (int i = 0; i < n; i++) {
		std::cin >> a;
		s.emplace_back(a);
	}
	std::sort(s.begin(), s.end());
	std::cin >> q;
	for (int i = 0; i < q; i++) {
		std::cin >> a;
		t.emplace_back(a);
	}
	int ans = 0;
	for (int i = 0; i < q; i++) {
		if (binary(i))ans++;
	}
	std::cout << ans << std::endl;
}

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

int main()
{
    int A, B;
    string S;
    cin >> A >> B;
    cin >> S;
    for(int i = 0; i < S.size(); ++i) {
        if(i < A) {
            if((S[i] - '0') > 9 || (S[i] - '0') < 0) {
                cout << "No" << endl; return 0;
            }
        }
        else if(i == A) {
            if(S[i] != '-') {
                cout << "No" << endl; return 0;
            }
        }
        else {
            if((S[i] - '0') > 9 || (S[i] - '0') < 0) {
                cout << "No" << endl; return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int a = parseInt(sc.next());
		sc.close();
		out.println(n%500<=a?"Yes":"No");
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <string>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

long long count_inversions(string &s, int i, int j) {
	long long as = 0, ans = 0;
	for (int k = i; k < j; ++k) {
		if (s[k] == 'A') {
			++as;
		} else {
			ans += as;
		}
 	}

 	return ans;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string s;
	cin >> s;

	int sz = s.size();
	string replaced;
	for (int i = 0; i < sz - 1; ++i) {
		if (s[i] == 'B' && s[i + 1] == 'C') {
			replaced.push_back('D');
			++i;
		} else {
			replaced.push_back(s[i]);
		}
	}

	sz = replaced.size();
	long long ans = 0;
	for (int i = 0; i < sz; ++i) {
		if (replaced[i] == 'A' || replaced[i] == 'D') {
			int j = i;
			while (j < sz && replaced[j] != 'B' && replaced[j] != 'C') {
				++j;
			}

			ans += count_inversions(replaced, i, j);
			i = j - 1;
		}
	}

	cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 3856
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned int uint;
typedef unsigned long long ulint;
constexpr lint mod1 = 1e9+7;

template<typename T>
struct ST{
  using F = function<T(T, T)>;
  int size_ = 1, n_; vector<T> node; T initial; F query_, update_;
  ST(int n, T initial, F query, F update){
    while(size_ < n) size_ *= 2;
    node.resize(2*size_-1, initial);
    n_ = n;
    query_ = query;
    update_ = update;
  }
  void printnodes(){
    rep(i, node.size()) cout << node[i] << endl;
    return;
  }
  void build(vector<T> v){
    rep(i, v.size()) node[i+size_-1] = v[i];
    rrep(i, size_ - 1) node[i] = query_(node[2*i+1], node[2*i+2]);
    return;
  }
  void update(int j, T x){
    j += size_-1;
    node[j] = update_(node[j], x);
    while(j > 0){
      j = (j-1)/2;
      node[j] = query_(node[2*j+1], node[2*j+2]);
    }
    return;
  }
  T query(int l, int r){
    l += size_-1;
    r += size_-1;
    T ql = node[l], qr = node[r];
    while(l < r-1){
      if(l % 2 == 1) ql = query_(node[l], node[l+1]);
      if(r % 2 == 0) qr = query_(node[r-1], node[r]);
      l = (l-1)/2;
      r = (r-1)/2;
    }
    return query_(ql, qr);
  }
  int lb(T x){
    int tmp = 0;
    while(tmp < size_-1){
      if(x <= node[tmp*2+1]) tmp = tmp*2+1;
      else tmp = tmp*2+2;
    }
    if(node[tmp] < x) ++tmp;
    return min(tmp+1-size_, n_);
  }
  int ub(T x){
    int tmp = 0;
    while(tmp < size_-1){
      if(x < node[tmp*2+1]) tmp = tmp*2+1;
      else tmp = tmp*2+2;
    }
    if(node[tmp] <= x) ++tmp;
    return min(tmp+1-size_, n_);
  }
};

int main() {
  lint n, s = 0;
  cin >> n;
  vector<lint> a(n), b(n), c(n);
  rep(i, n) cin >> a[i]; rep(i, n) cin >> b[i]; rep(i, n) cin >> c[i];
  sort(a.begin(), a.end()); sort(b.begin(), b.end()); sort(c.begin(), c.end());
  auto f = [](lint p, lint q){return max(p, q);};
  auto g = [](lint p, lint q){return q;};
  ST<lint> sta(n, 0, f, g), stc(n, 0, f, g);
  sta.build(a); stc.build(c);
  rep(i, n) s += sta.lb(b[i]) * (n - stc.ub(b[i]));
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 7536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  string s; cin >> s;
  vector<int> scr(10, -1);
  rep(i,(int)s.size()){
    if(s[i] == 'B'){
      rep(j,10){
        if(j==0) continue;
        if(scr[j]==-1){
          scr[j-1] = -1;
          break;
        }
      }
    }
    else{
      rep(j,10){
        if(scr[j]==-1){
          scr[j] = s[i]-'0';
          break;
        }
      }
    }
  }
  rep(i,10){
    if(scr[i] != -1){
      cout << scr[i];
    }
  }
  cout << endl;
  return 0;
}


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

namespace ARC76_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            long c = 1;
            long d = 1;
            long mod = 1000000007;
            for (int i = 1; i < n + 1; i++)
            {
                c = c * i % mod;
            }
            for (int i = 1; i < m + 1; i++)
            {
                d = d * i % mod;
            }
            if (Math.Abs(m-n) > 1)
            {
                Console.WriteLine(0);
                return;
            }
            if (n == m)
            {

                Console.WriteLine(2 * c * d % mod);
            }
            else
            {

                Console.WriteLine(c * d % mod);
            }
        }
    }
}


Measured memory_bytes: 11220
import math
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
a_num = list(map(int, str(a)))
b_num = list(map(int, str(b)))
c_num = list(map(int, str(c)))
d_num = list(map(int, str(d)))
e_num = list(map(int, str(e)))
x = a
x_num = list(map(int, str(x)))
if b_num[-1] != 0 and b_num[-1] < x_num[-1]:
    x = b
x_num = list(map(int, str(x)))
if c_num[-1] != 0 and c_num[-1] < x_num[-1]:
    x = c
x_num = list(map(int, str(x)))
if d_num[-1] != 0 and d_num[-1] < x_num[-1]:
    x = d
x_num = list(map(int, str(x)))
if e_num[-1] != 0 and e_num[-1] < x_num[-1]:
    x = e
x_num = list(map(int, str(x)))
A = math.ceil(a / 10) * 10
B = math.ceil(b / 10) * 10
C = math.ceil(c / 10) * 10
D = math.ceil(d / 10) * 10
E = math.ceil(e / 10) * 10
X = math.ceil(x / 10) * 10
print(A + B + C + D + E - (X - x))

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

int main(){
    int n, k, a[100005], ilosc = 0;
    cin >> n >> k;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        if(a[i] >= k) {
            ilosc++;
        }
    }
    cout << ilosc;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
struct UnionFind{
  vector<int> parent;
  UnionFind(int n){
    parent.resize(n);
    for(int i=0;i<n;++i)parent[i]=i;
  }
  int find(int x){ return parent[x]==x?x:(parent[x]=find(parent[x]));}
  void unite(int x,int y){if(find(x)!=find(y))parent[find(y)]=find(x);}
  bool issame(int x,int y){return find(x)==find(y);}
};

using pi=pair<int,int>;
#define mp make_pair

int main(){
  int n,k,l;
  cin>>n>>k>>l;
  UnionFind Road(n),Rail(n);
  for(int i=0;i<k;++i){
    int p,q;
    cin>>p>>q;
    Road.unite(p-1,q-1);
  }
  for(int i=0;i<l;++i){
    int r,s;
    cin>>r>>s;
    Rail.unite(r-1,s-1);
  }
  map<pi,int> m;
  for(int i=0;i<n;++i) m[mp(Road.find(i),Rail.find(i))]++;
  for(int i=0;i<n;++i)cout<<m[mp(Road.find(i),Rail.find(i))]<<" ";
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
signed main(void){
    itn n; cin>>n;
    vector <int> a(n);
    vector <int> d(114514);
    rep(i,n) cin>>a[i];
    if(a[0]) {cout<<0<<endl; return 0;}
    rep(i,n){
        d[a[i]]++;
    }
    int ans = 1;
    rep(i,n){
        if(i == 0) continue;
        if(a[i] == 0) {cout<<0<<endl; return 0;}
        //cout<<a[i]<<' '<<d[a[i]-1]<<endl;
        ans *= d[a[i]-1] % 998244353;
        ans %= 998244353;
    }
    cout<<ans%998244353<<endl;
}


Measured memory_bytes: 1920
A, B = map(int, input().split())

def f(n, k):
    if n < 0:
        return 0
    if n // 2**k == 0:
        if n >= 2**(k-1):
            return n - 2**(k-1) + 1
        else:
            return 0
    else:
        return int((n // 2**k) * (2**(k-1))) + f(n-(n // 2**k)*(2**k), k)

ans = []
for k in range(1, len(bin(10**12))-1):
    b = f(B, k)
    a = f(A-1, k)
    one = b-a
    if one % 2 == 0:
        ans += '0'
    else:
        ans += '1'

ans.reverse()
print(int(''.join(ans), 2))

Measured memory_bytes: 38256
S = input()
count = 1
i = 0
initial_length = len(S)-1
l = S[0]
S = S + '&' + '%'
while i < initial_length:
    if l == S[i+1]:
        if i == initial_length-1:
            break
        elif S[i+2] == S[i+3]:
            l = S[i+3]
            i += 3
            count += 1
        else:
            l = S[i+1:i+3]
            i += 2
    else:
        l = S[i+1]
        i += 1
    count += 1
print(count)

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

using namespace std;
int main()
{
	int A1 =0;
	int A2 = 0;
	int M;
	cin >>M;
	for(int i=1;i<=M;i++){
		if(i%2==0){
			A1++;
		}
		else{
			A2++;
		}
	}

	int B1 = A1*A2;
	cout<<B1<<endl;


	return 0;
}

Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
h,w=map(int,input().split())
s=[list(input()) for _ in range(h)]
seen={}
check=[[0]*w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            seen[i*w+j]=0
if not seen:
    print(0)
    exit()
d=deque()
p=[[1,0],[-1,0],[0,1],[0,-1]]
ans=0

for j in seen:
    if seen[j]==0:
        d.append(j)
        blue=1
        white=0
        seen[j]=1    
        while d:
            i=d.pop()
            if i==0:
                f=True if s[0][0]=="#" else False
            else:
                f=True if i>0 else False
            ih=abs(i)//w
            iw=abs(i)%w
            check[ih][iw]=1
            for v in p:
                x,y=v
                if f==True and 0<=x+iw<w and 0<=y+ih<h and s[y+ih][x+iw]=="." and check[y+ih][x+iw]==0:
                    d.append(((ih+y)*w+(iw+x))*(-1))
                    white+=1
                    check[y+ih][x+iw]=1
                elif f==False and 0<=x+iw<w and 0<=y+ih<h and s[y+ih][x+iw]=="#" and check[y+ih][x+iw]==0:
                    d.append(((ih+y)*w+(iw+x)))
                    seen[((ih+y)*w+(iw+x))]=1
                    check[y+ih][x+iw]=1
                    blue+=1
        ans+=blue*white
print(ans)

Measured memory_bytes: 105888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f[100100];
ll sz[100100];
ll n,m; ll a[100100];ll b[100100];
ll find(ll x)
{
    return f[x]==x?x:f[x]=find(f[x]);
}
ll c[100100];
int main()
{
   cin>>n>>m;
    for(ll i=1;i<=n;i++)
    f[i]=i,sz[i]=1;
    for(ll i=1;i<=m;i++)
      cin>>a[i]>>b[i];
       ll ans=n*(n-1)/2;
      for(ll i=m;i>=1;i--)
      { 
          c[i]=ans;
           ll ra=find(a[i]);ll rb=find(b[i]);
            if(ra!=rb)
          {    
              ans-=sz[ra]*sz[rb];
              f[ra]=rb;
              sz[rb]+=sz[ra];
              
          }
      }
     for(ll i=1;i<=m;i++)
    cout<<c[i]<<endl;
}


Measured memory_bytes: 5248
t[5],u[5],i=4;k(d){return d>10?4:d>5?3:d>1?2:1;}main(a,b,c,d){for(;~scanf("%d.%d%d.%d",&a,&b,&c,&d);t[k(a*10+b)]++,u[k(c*10+d)]++);for(;printf("%d %d\n",t[i],u[i]),--i;);}

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

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

  if (b == 1) {
    cout << "Bob" << endl;
    return 0;
  }

  if (a > b) {
    cout << "Alice" << endl;
  } else if (a == b) {
    cout << "Draw" << endl;
  } else {
    cout << "Bob" << endl;
  }

  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int a[200002];
    for(int i = 0; i < n; i++) cin >> a[i];
    int now = 1;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(a[i] == now) now++;
        else ans++;
    }
    if(now == 1) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;
import java.util.TreeMap;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[][] bingo = new int[3][3];
    int cnt = 0;
    int ok = 0;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        bingo[i][j] = sc.nextInt();
      }
    }
    int numbers = sc.nextInt();
    for (int i = 0; i < numbers; i++) {
      int number = sc.nextInt();
      for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 3; k++) {
          if (bingo[j][k] == number) {
            bingo[j][k] = 0;
          }
        }
      }
    }
    // 横判定
    for (int i = 0; i < 3; i++) {
      cnt = 0;
      for (int j = 0; j < 3; j++) {
        if (bingo[i][j] == 0) {
          cnt++;
        }
      }
      if (cnt == 3) {
        ok++;
      }
    }
    // 縦判定

    for (int i = 0; i < 3; i++) {
      cnt = 0;
      for (int j = 0; j < 3; j++) {
        if (bingo[j][i] == 0) {
          cnt++;
        }
      }
      if (cnt == 3) {
        ok++;
      }
    }

    // 斜め判定1
    if (bingo[0][0] == 0 && bingo[1][1] == 0 && bingo[2][2] == 0) {
      ok++;
    }
    // 斜め判定2
    if (bingo[0][2] == 0 && bingo[1][1] == 0 && bingo[2][0] == 0) {
      ok++;
    }
    if (ok > 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


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

using namespace std;
#define mp make_pair
#define pb push_back
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
LL s[100005];
vector<pair<LL, LL> > all;

bool pr[2200];
vector<int> p;

const LL INF = 3e18;

map<LL, int> ma;
map<LL, LL> pp;

int main() {
    forn(i, 2200) pr[i] = true;
    pr[0] = pr[1] = false;
    forn(i, 100) if (pr[i]) {
        for (int j = i * i; j < 2200; j += i) {
            pr[j] = false;
        }
    }
    forn(i, 2200) if (pr[i]) {
        p.pb(i);
    }
    scanf("%d", &n);
    forn(i, n) scanf("%lld", s + i);
    int ans = n;
    forn(i, n) {
        LL inv = 1;
        LL rem = s[i];
        for (int j : p) {
            LL cube = (LL)j * j * j;
            while (s[i] % cube == 0) {
                s[i] /= cube;
                rem /= cube;
            }
            int cnt = 0;
            while (s[i] % j == 0) {
                s[i] /= j;
                ++cnt;
            }
            if (cnt == 1) {
                if (inv > INF / j) inv = INF;
                else inv *= j;
                if (inv > INF / j) inv = INF;
                else inv *= j;
            } else if (cnt == 2) {
                if (inv > INF / j) inv = INF;
                else inv *= j;
            }
        }
        if (s[i] > 1) {
            int lo = 2, hi = 100000, mid;
            while (lo < hi) {
                mid = (lo + hi) >> 1;
                if ((LL)mid * mid < s[i]) {
                    lo = mid + 1;
                } else {
                    hi = mid;
                }
            }
            if ((LL)lo * lo == s[i]) {
                if (inv > INF / lo) inv = INF;
                else inv *= lo;
            } else {
                if (inv > INF / s[i]) inv = INF;
                else inv *= s[i];
                if (inv > INF / s[i]) inv = INF;
                else inv *= s[i];
            }
        }
        if (inv <= 10000000000ll) {
            all.pb(mp(rem, inv));
        }
    }
    for (auto x : all) {
        ++ma[x.first];
        pp[x.first] = x.second;
    }
    int bad = 0;
    for (auto x : ma) {
        if (x.first == 1) {
            bad += 2 * (x.second - 1);
        } else {
            auto it = ma.find(pp[x.first]);
            if (it != ma.end()) {
                bad += min(x.second, it->second);
            }
        }
    }
    assert(bad % 2 == 0);
    bad /= 2;
    ans -= bad;
    cout << ans << endl;
    return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int n;
    string a,b,c;
    cin>>n>>a>>b>>c;
    int res = 0;
    for (int i=0; i<n; i++) {
	int cur=3;
	cur = min(cur, (a[i]!=b[i])+(a[i]!=c[i]));
	cur = min(cur, (b[i]!=a[i])+(b[i]!=c[i]));
	cur = min(cur, (c[i]!=a[i])+(c[i]!=b[i]));
	res += cur;
    }
    cout<<res<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define int long long
bool ex[13][1<<(12*2)];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    string s,t;
    cin>>s>>t;
    int k=t.size(),tmp=0;
    for(int j=0;j<k;j++){
      tmp*=4;
      if(t[j]=='A') tmp+=0;
      if(t[j]=='C') tmp+=1;
      if(t[j]=='G') tmp+=2;
      if(t[j]=='T') tmp+=3;
    }
    if(s=="insert") ex[k][tmp]=1;
    else cout<<(ex[k][tmp]?"yes":"no")<<endl;
  }
  return 0;
}

Measured memory_bytes: 4536
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  if(A1+A2+A3>=22){
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var a = input.split('\n');
for (var i=0;i<a.length;i++){
    var b = a[i].split(' ').map(Number);
    var h = b[0];
    var w = b[1];
    if(h === 0 && w === 0){
        break;
    }
    console.log(
            Array(w + 1).join('#') + '\n' +
            Array(h - 1).join('#' + Array(w - 1).join('.') + '#\n') +
            Array(w + 1).join('#') + '\n'
        );
}



Measured memory_bytes: 16104
N, M, X = map(int,input().split())
B = [list(map(int,input().split())) for k in range(N)]
ans = float("inf")
for k in range(2**N):
    p = 0
    t = [0]*M
    for d in range(N):
        if (k>>d)&1 == 1:
            p += B[d][0]
            for l in range(1,M+1):
                t[l-1] += B[d][l]
    if min(t) >= X:
        ans = min(ans,p)
if ans == float("inf"):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9216
#include<iostream>
#include<iomanip>

using namespace std;

int main(){
    double r,pai=3.1415926535897932384626433;
    cin>>fixed>>setprecision(20)>>r;
    cout<<fixed<<setprecision(20)<<(double)r*r*pai<<" "<<fixed<<setprecision(20)<<(double)2*r*pai<<endl;
    return 0;
}



Measured memory_bytes: 3220
use std::io::*;
use std::str::FromStr;

pub fn read<t: FromStr>() -> t {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::max;

fn main() {
    let n: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();
    let mut maxv = 0;

    for i in 1..n - 1 {
        let mut acnt: Vec<i64> = vec![0; 27];
        let mut bcnt: Vec<i64> = vec![0; 27];
        for a in 0..i {
            acnt[(s[a] as u32 - 'a' as u32) as usize] += 1;
        }
        for b in i..n {
            bcnt[(s[b] as u32 - 'a' as u32) as usize] += 1;
        }

        let mut sum = 0;
        for i in 0..27 {
            if bcnt[i] != 0 && acnt[i] != 0 {
                sum += 1;
            }
        }

        maxv = max(maxv, sum);
    }
    println!("{}", maxv);
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

char c[105][105];

int main()
{ios_base::sync_with_stdio(false);
int a,b;
cin>>a>>b;

rep(i,0,49)rep(j,0,99)c[i][j]='.';

rep(i,50,99)rep(j,0,99)c[i][j]='#';

a--;
b--;

for(int i=0;i<=49;i+=2)
{
	rep(j,0,99)
	{
		if(b)
		{
			if(i%2==j%2)
			{
				c[i][j]='#';
				b--;
			}
		}
	}
}

for(int i=99;i>=50;i-=2)
{
	rep(j,0,99)
	{
		if(a)
		{
			if(i%2==j%2)
			{
				c[i][j]='.';
				a--;
			}
		}
	}
}
ol("100 100\n");
rep(i,0,99)
{
	rep(j,0,99)
	{
		ol(c[i][j]);
	}
	on;
}
return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#include<ctype.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
#define max(a,b) a>b?a:b
int main() {
	int n, w;
	double ans;
	for (; ~fscanf(stdin, "%d%d", &n, &w), n, w; P(lf, ans + 0.01)) {
		int a[100] = {},
			s = 0,
			h = 0;
		ans = 0;
		while (n--) {
			int b;
			S(d, b);
			a[b / w]++;
			s = max(s, b / w);
			h = max(h, a[b / w]);
		}
		int i;
		for (i = 0; i <= s; i++) ans += (double)a[i] / h*(s - i) / s;
	}
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main()
{
    
    int sec;
    int min;
    int hour;
 
    scanf("%d",&sec);
    
    min = sec/60;
    hour = min /60;
    min %= 60;
    sec %= 60;
    
    printf("%d:%d:%d\n",hour,min,sec);


    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep_3(i, initial, n) for (int i = (int)(initial); i < (int)(n); ++i)
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int i = (int)(n); i > 0; i--)
#define rep_r_3(i, initial, n) for (int i = (int)(initial); i > (int)(n); i--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
	int N;
	cin >> N;
	vector<ll> A(N+1, 0), B(N, 0);

	repeat(i, N+1) {
		cin >> A[i];
	}

	repeat(i, N) {
		cin >> B[i];
	}

	ll result = 0;
	repeat(i, N) {
		if (B[i] < (A[i] + A[i+1])) {
			result += B[i];
		} else {
			result += A[i] + A[i+1];
		}

		if (B[i] > A[i]) {
			ll a = (B[i] - A[i]);
			if (a > A[i+1]) {
				A[i+1] = 0;
			} else if (a > 0) {
				A[i+1] = A[i+1] - a;
			}
		}
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
ll H;

ll dfs(ll x){
	if(x==1) return 1;
	return 2*dfs(x/2)+1; 
}

int main(){
	scanf("%lld",&H);
	printf("%lld\n",dfs(H));
	
} 

Measured memory_bytes: 256
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "random"
#include        "chrono"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          pb push_back
#define          N (int)2e5+5
#define          PI acos(-1.0)
#define          int long long 
#define          vi vector<int>
#define          mod 1000000007
#define          ld long double
#define          eb emplace_back
#define          mii map<int,int>
#define          vpii vector<pii>
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) x.rbegin(),x.rend()
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define            bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

ld a , b , h , m;

void go()
{
     cin >> a >> b >> h >> m;

     ld deg = abs( ( 0.5 * ( 60.0 * h  + m ) ) - ( 6.0 * m) );
     deg = min( deg , 360.0 - deg );

     deg *= PI;
     deg /= 180.0;

     ld ans = sqrt( a*a + b*b - 2.0*a*b* cos(deg) );

     cout << fixed << setprecision(20) << ans << endl;


}

int32_t main()
{
     FAST;     
     int t=1; 
     // cin>>t;
     test(t) go();
}

 

Measured memory_bytes: 4164
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define Rep(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define Repr(i, b, e) for(int (i) = (b) - 1; (i) >= (e); --(i))
#define Print(x) cout << (x) << endl 
#define Min2(a, b) ((a) < (b)) ? (a) : (b)
#define Max2(a, b) ((a) > (b)) ? (a) : (b)

typedef long long ll;

using namespace std;

int main(){
    int N, min, l = 0, r = 0;
    string S;
    cin >> N >> S;
    Rep(i, 0, N){
        if(S[i] == '.') r++;
        min = l + r;
    }
    Rep(i, 0, N){
        if(S[i] == '.') r--;
        else l++;
        min = Min2(min, l + r);
    }
    Print(min);
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main(void)
{
	char T[200001];
	scanf("%s",T);
	int i=0;
	while(strncmp("\0",&T[i],1)!=0) {
		if(strncmp("?",&T[i],1)==0) {
			strncpy(&T[i],"D",1);
		}
		i++;
	}
	printf("%s\n",T);
	return 0;
}

Measured memory_bytes: 1800
#include <stdio.h>

int arr[10];
int cnt=0;
long long sum=0;
long long pow(int a,int b){
  if(b==0) return a;
  else return 10*pow(a,b-1);
}
long long recursive(int start,int degree){
  if(start==cnt) return degree==0;
  long long num = recursive(start+1,0)+recursive(start+1,degree+1);
  sum+=pow(arr[start],degree)*num;
  return num;
}
int main(){
  long long i;
  scanf("%lld",&i);
  while(i>0){
    arr[cnt++]=i%10;
    i/=10;
  }
  recursive(0,0);
  printf("%lld",sum);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef ll Weight;
void add_edge(vector<vector<Weight>> &g, Weight from, Weight to, bool isDirected) {
  g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

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

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

	int n; cin >> n;
  vector<int> a(n);
	int all = 0;
	rep(i,n) { cin >> a[i]; all ^= a[i];}

	rep(i, n) {
		cout << (all ^ a[i]) << " ";
	}

	cout << endl;
}


Measured memory_bytes: 3972
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println(a * b % 2 == 1 ? "Yes" : "No");

		sc.close();

	}
}



Measured memory_bytes: 21972
s = input()
nbits = 1 << len(s) - 1
for bit in range(nbits):
    for i in range(len(s)):
        if i == 0:
            anss = s[0]
            ans = int(s[0])
            continue

        if bit & 1 << i - 1:
            anss += "+" + s[i]
            ans += int(s[i])
        else:
            anss += "-" + s[i]
            ans -= int(s[i])
    if ans == 7:
        print(anss + "=7")
        exit(0)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9+7;

vector<P> prime_factorize(ll N){
	vector<P> ans;
	for(ll a = 2; a*a <= N; a++){
		if(N%a == 0){
			ll ex = 0;
			while(N%a == 0){
				ex++;
				N /= a;
			}
			ans.push_back(P(a, ex));
		}
	}
	if(N != 1) ans.push_back(P(N, 1));
	return ans;
}

signed main(){
  ll n; cin >> n;
  
  vector<P> vec = prime_factorize(n);
  int ans= 0;
  for(int i = 0; i < vec.size(); i++){
    int x = vec[i].second;
    int num = 0;
    while(num * (num + 1) <= 2 * x) num++;
    ans += (num - 1);
  }
  cout << ans << endl;
}

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

namespace _1_7_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = "";
            var record = new List<string>();

            while ((s = Console.ReadLine()) != "-1 -1 -1")
            {
                string[] point = s.Split(' ');
                int m = int.Parse(point[0]);
                int f = int.Parse(point[1]);
                int r = int.Parse(point[2]);

                record.Add(JudgeRecord(m, f, r));
            }
            foreach (string item in record)
            {
                Console.WriteLine(item);
            }
        }
        static string JudgeRecord(int m, int f, int r)
        {
            //中間または期末、欠席のとき
            if (m == -1 || f == -1)
            {
                return "F";
            }
            //中間+期末、80以上のとき
            else if (m + f >= 80)
            {
                return "A";
            }
            //中間+期末、65以上のとき
            else if (m + f >= 65)
            {
                return "B";
            }
            //中間+期末、50以上のとき
            else if (m + f >= 50)
            {
                return "C";
            }
            //中間+期末、30以上のとき
            else if (m + f >= 30)
            {   //再試験、50以上のとき
                if (r >= 50)
                {
                    return "C";
                }
                else
                {
                    return "D";
                }
            }
            //中間+期末、30未満のとき
            else
            {
                return "F";
            }
        }
    }
}



Measured memory_bytes: 17940
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>

static std::vector<int> xor_digits;
static long long int sum, initial;
long long int smallest_value(const int digit, const long long int pile1) {
	if (digit == xor_digits.size()) {
		return pile1;
	}
	return smallest_value(digit + 1, pile1 << 1);
}
long long int smallest_sum(const int digit, const long long int pile1, const long long int pile2) {
	if (digit == xor_digits.size()) {
		return pile1 + pile2;
	}
	if (xor_digits[digit] == 0) {
		return smallest_sum(digit + 1, pile1 << 1, pile2 << 1);
	}
	else {
		return smallest_sum(digit + 1, pile1 << 1, (pile2 << 1) + 1);
	}
}
long long int greatest_sum(const int digit, const long long int pile1, const long long int pile2) {
	if (digit == xor_digits.size()) {
		return pile1 + pile2;
	}
	if (xor_digits[digit] == 0) {
		if (smallest_value(digit + 1, (pile1 << 1) + 1) <= initial) {
			return greatest_sum(digit + 1, (pile1 << 1) + 1, (pile2 << 1) + 1);
		}
		else {
			return greatest_sum(digit + 1, pile1 << 1, pile2 << 1);
		}
	}
	else {
		return greatest_sum(digit + 1, pile1 << 1, (pile2 << 1) + 1);
	}
}
long long int solve(const int digit, const long long int pile1, const long long int pile2) {
	if (xor_digits.size() == digit) {
		return (pile1 + pile2) == sum && pile1 > 0 && pile1 <= initial ? pile1 : -1;
	}
	if (xor_digits[digit] == 0) {
		const auto v = smallest_value(digit + 1, (pile1 << 1) + 1);
		const auto s = smallest_sum(digit + 1, (pile1 << 1) + 1, (pile2 << 1) + 1);
		if (v <= initial && s <= sum) {
			return solve(digit + 1, (pile1 << 1) + 1, (pile2 << 1) + 1);
		}
		else {
			return solve(digit + 1, pile1 << 1, pile2 << 1);
		}
	}
	else {
		const auto v = smallest_value(digit + 1, (pile1 << 1) + 1);
		const auto s = greatest_sum(digit + 1, (pile1 << 1) + 1, pile2 << 1);
		if (v <= initial && s >= sum) {
			return solve(digit + 1, (pile1 << 1) + 1, pile2 << 1);
		}
		else {
			return solve(digit + 1, pile1 << 1, (pile2 << 1) + 1);
		}
	}
}
std::vector<int> to_digits(long long int value) {
	std::vector<int> result(60);
	for (auto &r: result) {
		r = value & 1;
		value >>= 1;
	}
	std::reverse(result.begin(), result.end());
	return result;
}
int main() {
	int n; std::cin >> n;
	std::vector<long long int> piles(n);
	for (auto& a : piles) std::cin >> a;
	const auto grandy = std::accumulate(piles.begin(), piles.end(), 0LL, [](const long long int acc, const long long int v) {return acc ^ v; });
	const auto xor_target = grandy ^ piles[0] ^ piles[1];
	xor_digits = to_digits(xor_target);
	sum = piles[0] + piles[1];
	initial = piles[0];
	const auto result = solve(0, 0, 0);
	if (result < 0) {
		std::cout << "-1\n";
	}
	else {
		std::cout << piles[0] - result << '\n';
	}
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include<iomanip>
#include <numeric>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;

//static const ll MOD = 1000000007;

int main() {
    string S, T;
    int answer = 0;

    // input
    cin >> S >> T;

    // process
    for (int i = 0; i < 3; i++) {
        if (S[i] == T[i]) {
            answer++;
        }
    }

    cout << answer << endl;

    return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    ll x, v = 100;
    cin >> x;

    ll i = 0;
    while (true) {
        if (v >= x) {
            cout << i << endl;
            return 0;
        }
        v = v * 1.01;
        ++i;
    }

    return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<cmath>
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5+7;
typedef long long LL;
LL f[N], dist[N];
void init(int n)
{
    for(int i=0;i<=n;i++) f[i]=i;
    memset(dist,0,sizeof(dist));
    return ;
}
LL get(LL x)
{
    if(x!=f[x])
    {
        LL t=(f[x]);
        f[x]=get(f[x]);
        dist[x]+=dist[t];
    }
    return f[x];
}

int main()
{
    int n, m, c;
    scanf("%d %d", &n,&m);
    c=n+m;
    m%=3,c%=3;
    n%=3;
    if(n==0||m==0||c==0) printf("Possible\n");
    else printf("Impossible\n");
    return 0;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n = in();
    string s = in();

    int l = 0, r = 0;
    rep(i, n)
    {
        if (s[i] == '(')
        {
            ++l;
        }
        else
        {
            if (l != 0)
                --l;
            else
                ++r;
        }
    }

    string ans;
    rep(i, r) ans.pb('(');
    ans += s;
    rep(i, l) ans.pb(')');

    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<list>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
//#define __int64 long long

int n;

int main(){	
cin>>n;
	cout<<800*n-n/15*200<<endl;


	return 0;
}


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

int main(){
  int N; cin >> N;
  int a[100];
  int sum=0;
  for(int i=0; i<N; i++){
    cin >> a[i];
    sum+=a[i];
  }
  int thumb=10000;
  int frame;
  for(int i=0; i<N; i++){
    if(thumb>=abs(a[N-1-i]*N-sum)){
      thumb=abs(a[N-1-i]*N-sum);
      frame=N-1-i;
    }
  }
  cout << frame << endl;
}

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

#define mod 1000000007
#define fi first
#define se second

int n;

int a[100005];
signed main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	int x = 0;
	for(int i = 1 ; i <= n ; i ++){
		cin >> a[i];
		x ^= a[i];
	}
	cout << (x == 0 ? "Yes" : "No");
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
	char str[21];
	int l = 0, i;
	
	scanf("%s", str);
	
	while(str[l]) l++;
	
	for(i = l - 1; i >= 0; i--) printf("%c", str[i]);
	
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define nmax 100005

using namespace std;
long long n,m,ant,ans,i,x,y,d[nmax];
int main()
{
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
        cin>>x>>y;
        if(x>y)
            swap(x,y);
        if(d[x]==0)
            d[x]=y;
        d[x]=min(d[x],y);
    }
    ans=0;
    ant=n+1;
    for(i=1;i<=n;i++)
    {
        if(d[i]==0)
            continue;
        if(ant<=i)
        {
            ans++;
            ant=n+1;
        }
        ant=min(ant,d[i]);
    }
    cout<<ans+1<<'\n';
    return 0;
}


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

public class Main {
  
  static int n, k;
  static int[] arr;
  static int[][] dp;
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    n = in.nextInt();
    k = in.nextInt();
    arr = new int[n];

    for (int i = 0; i < n; ++i) {
      arr[i] = in.nextInt();
    }  
    boolean[] firstWin = new boolean[k + 1];
    // firstWin[0] = true;
    for(int i = 1; i <= k; ++i) {
      for(int j = 0;j < n; ++j) {
        if(i - arr[j] >= 0 && !firstWin[i - arr[j]]) {
          firstWin[i] = true;
        }
      }
    }
    System.out.println(firstWin[k] ? "First": "Second");
    // dp = new int[k + 1][3];

    // int winner = dp(1, k);
    // System.out.println(winner == 1 ? "First" : "Second");
  }

  static int dp(int turn, int k) {
    if (k == 0) return turn == 2 ? 1 : 2;

    if (dp[k][turn] != 0) return dp[k][turn];

    boolean winning = false;
    for (int i = 0; i < n; ++i) {
      if (arr[i] <= k) {
        int t = dp(turn == 2 ? 1 : 2, k - arr[i]);
        if (t == turn) {
          winning = true; 
          break;
        }
      }
    }

    if (winning) return dp[k][turn] = turn ;
    else return dp[k][turn] = (turn == 2 ? 1 : 2);
  }

}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;


int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	int sum = 0;
	int ans = 0;
	for (int i = 1; i <=N; i++) {
		int t=i;
		sum = 0;
		while (t>0) {
			sum += t % 10;
			t /= 10;
		}
		if (A <= sum && B >= sum) {
			ans+= i;
		}
	}
cout << ans << endl;
}

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

# define ll long long 
# define VI vector<int>
# define VLL vector<ll>
# define PII pair<int,int> 
# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ld long double
const int MxN = 200001 ; 
# define FOR(i,a,b) for(int i = a ; i < b ; ++i)
# define RFOR(i,a,b) for(int i = a ; i >= b ; --i)
const int MOD = 1e9 + 7 ; 

/* VARIABLES */
int n ;  
string s ; 
/* END OF VARIABLES */



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

	cin >> n ; 
	cin >> s ;
	ll red = 0 , wh = 0 ;  
	VLL rs(n+1) , ws(n+1) ; 
	FOR(i,0,n) {
		if(s[i] == 'R')
			red++;
		else 
			wh++;
		rs[i] = red ; 
		ws[i] = wh ; 
	}
	ll  ans = n ; 
	FOR(i,0,n) {
		ll lwhites = ws[i] ; 
		ll rred = rs[n-1] - rs[i] ; 
		ll res = min(lwhites,rred) ; 
		ans = min(ans , lwhites + rred) ; 
		lwhites -= res ; 
		rred -= res ; 
		ans = min(ans , lwhites + rred + res) ; 
		
	}
	ans = min(ans,red) ;
	ans = min(ans ,wh) ; 
	cout << ans ; 
	
	return 0 ; 
}



Measured memory_bytes: 6772