akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <sstream>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define rrep(i, a) RREP(i, a, 0)
#define RREP(i, a, b) for(int i = a; i >= b; --i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)
#define rrepll(i, a) RREPLL(i, a, 0)
#define RREPLL(i, a, b) for(ll i = a; i >= b; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<int, P> PP;
const double PI = 3.14159265358979323846;
const double eps = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

int m, n;
std::string strm, strn;
int dp[2001][2001][2]; //n??????i???,m??????j?????????,???????????????(I,O)?????´???????????§?????°

int main() {
	std::cin >> m >> n >> strm >> strn;

	rep(i, 2001)rep(j, 2001)rep(k, 2)dp[i][j][k] = -1;

	if(strn[0] == 'I')dp[1][0][0] = 1;
	else dp[1][0][1] = 0;

	if (strm[0] == 'I')dp[0][1][0] = 1;
	else dp[0][1][1] = 0;

	rep(i, n + 1) {
		rep(j, m + 1) {
			rep(k, 2) {
				if (dp[i][j][k] == -1) continue;
				if (k == 0) {
					if (i != n) {
						if (strn[i] == 'O')dp[i + 1][j][1] = std::max(dp[i + 1][j][1], dp[i][j][0] + 1);
						else dp[i + 1][j][0] = std::max(dp[i + 1][j][0], 1);
					}

					if (j != m) {
						if (strm[j] == 'O')dp[i][j + 1][1] = std::max(dp[i][j + 1][1], dp[i][j][0] + 1);
						else dp[i][j + 1][0] = std::max(dp[i][j + 1][0], 1);
					}
				}
				else {
					if (i != n) {
						if (strn[i] == 'I')dp[i + 1][j][0] = std::max(dp[i + 1][j][0], dp[i][j][1] + 1);
						else dp[i + 1][j][1] = std::max(dp[i + 1][j][1], 0);
					}

					if (j != m) {
						if (strm[j] == 'I')dp[i][j + 1][0] = std::max(dp[i][j + 1][0], dp[i][j][1] + 1);
						else dp[i][j + 1][1] = std::max(dp[i][j + 1][1], 0);
					}
				}
			}
		}
	}

	int ans = 0;
	rep(i, n + 1) {
		rep(j, m + 1) ans = std::max(ans, dp[i][j][0]);
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 32492
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
#define MOD 1000000007
//scanf("%d", &a) '\n'

int main() {
	string s;
	cin >> s;
	if (s == "SAT") cout << 1 << endl;
	if(s == "FRI") cout << 2 << endl;
	if(s == "THU") cout << 3 << endl;
	if(s == "WED") cout << 4 << endl;
	if (s == "TUE") cout << 5 << endl;
	if (s == "MON") cout << 6 << endl;
	if (s == "SUN") cout << 7 << endl;
}
	

Measured memory_bytes: 256
// see: http://ei1333.hateblo.jp/entry/2017/05/01/004235
// わかりやすい

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main() {
    ll N, W, w0, ans = 0;
    vector<ll> ws[4];
    cin >> N >> W;
    for (ll i = 0; i < N; i++) {
        ll w, v;
        cin >> w >> v;
        if (i == 0) w0 = w;
        ws[w - w0].push_back(v);
    }
    for(int i = 0; i < 4; i++) {
        sort(begin(ws[i]), end(ws[i]));
        ws[i].push_back(0);
        reverse(begin(ws[i]), end(ws[i]));
        for(ll j = 1; j < ws[i].size(); j++) {
            ws[i][j] += ws[i][j - 1]; // 価値の累積和
        }
    }

    for(ll i = 0; i < ws[0].size(); i++) {
        for(ll j = 0; j < ws[1].size(); j++) {
            for(ll k = 0; k < ws[2].size(); k++) {
                for(ll l = 0; l < ws[3].size(); l++) {
                    ll weight = w0 * i + (w0 + 1) * j + (w0 + 2) * k + (w0 + 3) * l;
                    if(weight <= W) {
                        ans = max(ans, ws[0][i] + ws[1][j] + ws[2][k] + ws[3][l]);
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
dict = {}
n = int(input())
cnt = 0
ans = []
for i in range(n):
    str = list(input().split())
    if str[0] == 'insert':
        dict[str[1]] = cnt
        cnt += 1
    
    if str[0] == 'find':
        if str[1] in dict:
            print("yes")
        else:
            print("no")




Measured memory_bytes: 41820
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int x;
    int n;cin>>n;
    bool ok=1;
    for(int i=1;i<=n;i++){
        cin>>x;
        if(x%2==0&&(x%3!=0&&x%5!=0)) ok=0;
    }
    if(ok) puts("APPROVED");
    else puts("DENIED");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n){
    cin>>a[i];
    a[i]--;
  }
  ll b[n];
  rep(i,0,n) b[i]=0;
  rep(i,0,n) b[a[i]]++;
  ll ans=0;
  rep(i,0,n) ans+=b[i]*(b[i]-1)/2;
  rep(i,0,n) cout<<ans-b[a[i]]+1<<endl;
}

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

 
int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i=0; i<N; i++) cin >> a.at(i);

  int64_t t = 0LL,res1 = 0LL, res2 = 0LL;
  for (int i=0; i<N; i++) {
    t += a.at(i);
    if( i%2 == 0 ) {
      if ( t <= 0 ) {
        res1 += ( 1 - t );
        t = 1;
      }      
    } else {
      if ( t >= 0 ) {
        res1 += abs( -1 - t );
        t = -1;
      }
    }
  }
  t = 0LL;
  for (int i=0; i<N; i++) {
    t += a.at(i);
    if( i%2 == 1 ) {
      if ( t <= 0 ) {
        res2 += ( 1 - t );
        t = 1;
      }      
    } else {
      if ( t >= 0 ) {
        res2 += abs( -1 - t );
        t = -1;
      }
    }
  }
  
  int64_t res = min(res1,res2);
  cout << res << endl;

}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
vector<P> p;
vi num;
int main()
{
	int n,m;
	while(cin >> n >> m&&(n||m))
	{
		p.clear();
		num.clear();
		for(int i=m;i>0;i--)
		{
			p.pb(P(0,i));
			num.pb(0);
		}
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				int t;
				cin >> t;
				p[j].fi+=t;
			}
		}
		sort(p.rbegin(),p.rend());
		for(int i=0;i<p.size();i++)
		{
			cout << 1+m-p[i].sec;
			if(i==p.size()-1)
			{
				cout << endl;
			}
			else
			{
				cout << ' ';
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1220
n , m = map(int, input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

uf = UnionFind(n)

for i in range(m):
    x , y , z = map(int, input().split())
    x-=1
    y-=1
    uf.union(x,y)

print(uf.group_count())


Measured memory_bytes: 13700
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    string s;
    cin >> s;

    ll ans = 0, ac = 0;
    REP(i, s.size()) {
        if (s[i] == 'A') {
            ac++;
        }
        else if (s[i] == 'B') {
            if (i < s.size() - 1 && s[i + 1] == 'C') {
                ans += ac;
                i++;
            } else {
                ac = 0;
            }
        } else {
            ac = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

template<typename Monoid,typename F>
class SegmentTree{
private:
    int sz;
    vector<Monoid> seg;
    const F op;
    const Monoid e;
public:
    SegmentTree(int n,const F op,const Monoid &e):op(op),e(e){
        sz = 1;
        while(sz<=n) sz <<= 1;
        seg.assign(2*sz,e);
    }
    void set(int k, const Monoid &x){
        seg[k+sz] = x;
    }
    void build(){
        for(int i=sz-1;i>0;i--){
            seg[i] = op(seg[2*i],seg[2*i+1]);
        }
    }
    void update(int k,const Monoid &x){
        k += sz;
        seg[k] = x;
        while(k>>=1){
            seg[k] = op(seg[2*k],seg[2*k+1]);
        }
    }
    Monoid query(int l,int r){
        Monoid L = e,R = e;
        for(l+=sz,r+=sz;l<r;l>>=1,r>>=1){
            if(l&1) L = op(L,seg[l++]);
            if(r&1) R = op(seg[--r],R);
        }
        return op(L,R);
    }
    Monoid operator[](const int &k)const{
        return seg[k+sz];
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    string S;
    cin >> S;
    auto op = [](int a,int b){return min(a,b);};
    int inf = 1e9;
    SegmentTree<int,decltype(op)> seg(N,op,inf);
    for(int i=0;i<=N;i++) if(S[i]=='0') seg.set(i,i);
    seg.build();
    vec<int> ans;
    int now = N;
    while(now){
        int ne = seg.query(max(now-M,0),now);
        if(ne==inf){
            cout << -1 << "\n";
            return 0;
        }
        ans.push_back(now-ne);
        now = ne;
    }
    reverse(ans.begin(),ans.end());
    int n = ans.size();
    for(int i=0;i<n;i++) cout << ans[i] << (i!=n-1? " ":"\n");
}

Measured memory_bytes: 2120
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i, _ := range a {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)

	sta := make(map[int]int, a[len(a)-1]+1)
	for _, v := range a {
		if sta[v] != 0 {
			sta[v] = 2
			continue
		}
		for i := v; i <= a[len(a)-1]; i += v {
			sta[i]++
		}
	}

	ans := 0
	for _, v := range a {
		if sta[v] == 1 {
			ans++
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 46856
#include<bits/stdc++.h>
using namespace std;
#define bs ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define pb push_back

void solve(){
	ll n,a,b,xtra=0;
	cin>>n>>a>>b;
	ll k=n/(a+b),rem=n%(a+b);
	if(rem<=a) xtra=rem;
	else xtra=a;
	cout<<k*a+xtra<<endl;

}

int main()
{
	bs;
	solve();
	// test{
	//    solve(); 
	// }
}

Measured memory_bytes: 256
n = int(input())
t = [int(i) for i in input().split()]
m = int(input())
p = []
x = []
for i in range(m):
    p_i,x_i = map(int,input().split())
    p.append(p_i)
    x.append(x_i)
s = sum(t)
for i in range(m):
    print(s - t[p[i]-1] + x[i])


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

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

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

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

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

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll n, m,d,t;
	string ans = "YES";
	map<ll, ll> md;
	in(n);
	rep(i, 0, n) {
		in(d);
		md[d]++;
	}

	in(m);
	rep(i, 0, m) {
		in(t);
		if (md[t] <= 0) {
			ans = "NO";
		}
		md[t]--;
	}
	outn(ans);
	return 0;

}


Measured memory_bytes: 12800
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int member = in.nextInt();
		int cAve = in.nextInt();
		int[] a = new int [member];
		int[] b = new int [cAve];
		int[] c = new int [member];
		for(int i = 0;i < member;i++){
			a[i] = in.nextInt();
			c[i] = 0;
		}
		for(int i = 0;i < cAve;i++){
			b[i] = in.nextInt();
		}
		for(int i = 0;i < cAve;i++){
			for(int j = 0;j < member;j++){
				if(a[j] <= b[i]){
					c[j]++;
					break;
				}
			}
		}
		int max = 1;
		for(int i = 0;i < member;i++){
			if(c[max-1] < c[i]){
				max = i+1;
			}
		}
		System.out.println(max);
	}
}

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

using namespace std;

int main(){
	// https://atcoder.jp/contests/dp/tasks/dp_h
	int n,m;
	cin >> n >> m;
	int modulo = 1e9+7;
	char str[n][m];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin >> str[i][j];

		}
	}

	long long int dp[n][m];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;

	for(int i=1;i<n;i++){
		if(str[i][0] == '.')
			dp[i][0] = dp[i-1][0];
	}
	for(int j=1;j<m;j++){
		if(str[0][j] == '.')
			dp[0][j] = dp[0][j-1];
	}

	for(int i=1;i<n;i++){
		for(int j=1;j<m;j++){
			if(str[i][j] == '.'){
				dp[i][j] = (dp[i-1][j] + dp[i][j-1])%modulo;
			}
		}
	}

	cout << dp[n-1][m-1] << endl;

	return 0;
}

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

int v(string a){
	int sum=0;
	int t=0;
	for(int i=a.size()-1;i>=0;i--){
		int o=a[i]-'0';
		if(t!=0){
			for(int k=0;k<t;k++){
				o=o*10;
			}
		}
		sum+=o;
		t++;
	}
	return sum;
}

int main(){
	string a,b,c;
	cin>>a>>b;
	c=a+b;
	int x=v(c);
	for(int i=0;i<x;i++){
		if(i*i==x){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define CIN(in) int in;cin>>in;
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  CIN(in);
  cout<<in<<":";
  loop(i,2,1e9+10){
    if(i*i>in){cout<<" "<<in;break;}
    while(in%i==0){
      cout<<" "<<i;
      in/=i;
    }
    if(in==1)break;
  }
  cout<<endl;
}
  

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll x;cin>>x;
    ll key=0;
    for(ll i=1;i*(i+1)<2*x;i++){
        key=i;
    }
    key++;

    cout<<key<<endl;
    return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  for (int i=0; i<N; i++) cin >> V[i];
  vector<int> C(N);
  for (int i=0; i<N; i++) cin >> C[i];
  vector<int> next(N);
  for (int i=0; i<N; i++) {
    next[i] = V[i]-C[i];
  }
  
  int ans = 0;
  for (int i=0; i<N; i++) {
    if (next[i] > 0) {
      ans += next[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>

using namespace std;

int digit(int n, int d) {
	int m = (int)(n/pow(10,d)) * pow(10,d);
	return (n - m)/pow(10,d-1);
}

int check_digit(int n) {
	for (int i = 3; i > 0; i--) {
		if (digit(n, i) > 0) {
			return i;
		}
	}
	return 1;
}

int main(void) {
	int A,B;
	cin >> A >> B;
	double num = sqrt((A * (pow(10,check_digit(B)))) + B);
	if (num == (int)num) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



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

int main()
{
  char b; cin >> b;
  if(b == 'A') cout << 'T' << endl;
  else if(b == 'T') cout << 'A' << endl;
  else if(b == 'C') cout << 'G' << endl;
  else cout << 'C' << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int n, a, b;
    string s;
    cin >> n >> a >> b >> s;

    int passou = 0;
    int ov = 0;
    fo(i, (int) s.size()) {
        if ( s[i] == 'c' ) {
            cout << "No\n";
            continue;
        }
        if ( s[i] == 'a' ) {
            if ( a + b > passou ) {
                cout << "Yes\n";
                passou++;
            } else {
                cout << "No\n";
            }
        } else {
            ov++;
            if ( a + b > passou and ov <= b ) {
                passou++;
                cout << "Yes\n";
            } else cout << "No\n";
        }
    }

    return 0;
}

Measured memory_bytes: 896
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unicode/utf8"
)

var debug = false

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var target string
	if sc.Scan() {
		target = sc.Text()
	}

	res := GetAnswer(target)
	fmt.Printf("%v\n", res)
}

// GetAnswer ...
func GetAnswer(target string) int {
	prt("inputs: target:%#v", target)
	tint, _ := strconv.Atoi(target)
	sqrt := math.Sqrt(float64(tint))
	dummya := int(math.Ceil(sqrt))
	a, b := 0, 0
	for i := dummya; i > 0; i-- {
		if tint%i == 0 {
			a = i
			b = tint / i
			break
		}
	}
	prt("a: %v b:%v", a, b)
	stra := strconv.Itoa(a)
	strb := strconv.Itoa(b)
	dgta := utf8.RuneCountInString(stra)
	dgtb := utf8.RuneCountInString(strb)
	prt("da: %v db:%v", dgta, dgtb)
	result := 0
	result = dgta
	if dgta < dgtb {
		result = dgtb
	}

	return result
}

func getIntArray(str string) []int {
	strarr := strings.Split(str, " ")
	intarr := []int{}
	for _, st := range strarr {
		ti, _ := strconv.Atoi(st)
		intarr = append(intarr, ti)
	}
	return intarr
}

func prt(format string, inputs ...interface{}) {
	if debug {
		fmt.Printf(format+"\n", inputs...)
	}
}

Measured memory_bytes: 640
def intSqrt(n):
    x = 1
    while True:
        x2 = (x + n // x) // 2
        if x2 ** 2 <= n and abs(x - x2) <= 1:
            break
        x = x2
    return x2

n = int(input())
print(intSqrt(n)**2)


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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x)*(x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<double>> lab(n, vector<double>(3));
    REP(i, n) {
        cin >> lab[i][0] >> lab[i][1] >> lab[i][2];
    }

    double ma = 0;
    REP(x, 1<<n) {
        if (__builtin_popcount(x) == m) {
            double val = 0;
            REP(i, n) FOR(j, i+1, n) {
                if (BIT(x, i) && BIT(x, j)) {
                    REP(k, 3) val += SQ(lab[i][k] - lab[j][k]);
                }
            }
            ma = max(ma, val);
        }
    }
    printf("%.20f\n", ma);
}

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

void Main()
{
	vector<vector<int>> w(3, vector<int>(10, 0));
	vector<vector<int>> x(3, vector<int>(10, 0));
	vector<vector<int>> y(3, vector<int>(10, 0));
	vector<vector<int>> z(3, vector<int>(10, 0));
	
	int n;
	cin >> n;
	rep(i, n){
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		if(b == 1){
			w[f-1][r-1] += v;
		}else if(b == 2){
			x[f-1][r-1] += v;
		}else if(b == 3){
			y[f-1][r-1] += v;
		}else{
			z[f-1][r-1] += v;
		}
	}
	
	rep(i, 3){
		rep(j, 10){
			cout << ' ' << w[i][j];
		}
		cout << endl;
	}
	cout << "####################" << endl;
	rep(i, 3){
		rep(j, 10){
			cout << ' ' << x[i][j];
		}
		cout << endl;
	}
	cout << "####################" << endl;
	rep(i, 3){
		rep(j, 10){
			cout << ' ' << y[i][j];
		}
		cout << endl;
	}
	cout << "####################" << endl;
	rep(i, 3){
		rep(j, 10){
			cout << ' ' << z[i][j];
		}
		cout << 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: 3172
n,m=map(int,input().split())
l=[[] for i in range(n)]
for i in range(m):
    p,y=input().split()
    l[int(p)-1].append(y.zfill(10)+str(i).zfill(6))
for i in range(n):
    l[i].sort()
s=[0]*m
for i in range(n):
    for j in range(len(l[i])):
        s[int(l[i][j][10:16])]=str(i+1).zfill(6)+str(j+1).zfill(6)
for i in s:
    print(i)

Measured memory_bytes: 30412
package main

import (
  "fmt"
)

func abs(a int) int {
  if a < 0 {
    return -a
  }
  return a
}

func max(a, b int) int {
  if a < b {
    return b
  }
  return a
}

func main() {
  var n int
  fmt.Scan(&n)
  a := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&a[i])
  }

  ans := 0
  for i, u := range a {
    for j, v := range a {
      if i != j {
        ans = max(ans, abs(u - v))
      }
    }
  }

  fmt.Println(ans)
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline
a, b, c = map(int, input().split())
t = a + b - c

ok = a * b * 2
ng = 0
while ok - ng > 1:
  m = (ok + ng) // 2
  if (a * b * 4) < (m ** 2): ok = m
  else: ng = m
if t + ok <= 0: print("Yes")
else: print("No")

Measured memory_bytes: 38512
#include <iostream>

using namespace std;

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

	long long money = 1000;
	long long stock = 0;
	long long A[200] = {0};
	for (int i = 0; i < N; ++i)
		cin >> A[i];

	// stock = money / A[0];
	// money = money % A[0];

	// for(int i = 1; i < N-1; ++i) {
	// 	if(A[i] > A[i-1]) {  // sell out all
	// 		money += stock * A[i];
	// 		stock = 0;
	// 	}

	// 	if(A[i] < A[i+1]) {  // buy as much as possible
	// 		stock = money / A[i];
	// 		money %= A[i];
	// 	}
	// }

	// money += stock*A[N-1]; // sell out all at the end of trading

	// if (money < init)
	// 	money = init;

	for (int i = 0; i < N-1; ++i) {
		stock = 0;
		if(A[i] < A[i+1])
			stock  = money / A[i];
		money += (A[i+1] - A[i]) * stock;
	}
	cout << money << endl;

	return 0;
}


Measured memory_bytes: 3536
n=int(input())
l=[]
for _ in range(n):
  s=input().split()
  l.append([int(s[0]),int(s[1])])
flag=0
for i in range(2,n):
  if l[i][0]==l[i][1] and l[i-1][0]==l[i-1][1] and l[i-2][0]==l[i-2][1]:
    flag=1
    break
if flag:
  print("Yes")
else:
  print("No")

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

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

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

int main(){
  int n;
  cin >> n;
  int v[4][14] = {};
  char s[4] = {'S', 'H', 'C', 'D'};
  rep(i,n){
    char ch ;
    int m;
    cin >> ch >> m;
    if(ch == 'S') v[0][m]++;
    if(ch == 'H') v[1][m]++;
    if(ch == 'C') v[2][m]++;
    if(ch == 'D') v[3][m]++;
  }

  rep(i, 4){
    REP(j, 14){
      if(!(v[i][j])){
        cout << s[i] << " " << j << endl;
      }
    }
  }
  

}





Measured memory_bytes: 3100
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;


signed main(){
  int N,M, ans=0,a,b,c;cin>>N;
  vector<int> times(N),drinks(N,0);
  REP(i,0,N){
    cin>>times[i];
    ans+=times[i];
  }
  cin>>M;
  REP(i,0,M){
    cin>>b>>c;
    b--;
    print(ans-times[b]+c);
  }

}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	if _, err := fmt.Scan(&n); err != nil {
		panic(err)
	}

	cards := make([]bool, 4*13)
	for i := 0; i < n; i++ {
		var mark string 
		var num int
		if _, err := fmt.Scan(&mark, &num); err != nil {
			panic(err)
		}

		var cardI int
		switch mark {
		case "S":
			cardI = 0*13 + num - 1
		case "H":
			cardI = 1*13 + num - 1
		case "C":
			cardI = 2*13 + num - 1
		case "D":
			cardI = 3*13 + num - 1
		}
		cards[cardI] = true
	}

	for i := 0; i < 4*13; i++ {
		if cards[i] {
			continue
		}

		var mark string
		var num int
		switch i / 13 {
		case 0:
			mark = "S"
		case 1:
			mark = "H"
		case 2:
			mark = "C"
		case 3:
			mark = "D"
		}
		num = i % 13 + 1

		fmt.Printf("%s %d\n", mark, num)
	}
}



Measured memory_bytes: 1100
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;

int dfs(vector<vector<pair<int,int>>> &graph, vector<int> &res, int v, int &count, int from, vector<int> &low, vector<int> &pre){
	bool flag = false;
	int con = 0;
	pre[v] = count++;
	low[v] = pre[v];
	
	for(pair<int,int> next : graph[v]){
		if(pre[next.first] == -1){
			low[v] = min(low[v], dfs(graph, res, next.first, count, v, low, pre));
			
			con++;
			if(pre[v] <= low[next.first]){
				flag = true;
			}
		} else {
			if(from == next.first){
				continue;
			}
			low[v] = min(low[v], pre[next.first]);
		}
		
	}

	if(from == -1){
		if(con >= 2) res.push_back(v);
	} else if(flag) res.push_back(v);
	
	return low[v];
}

vector<int> Articulation_Points(vector<vector<pair<int,int>>> & graph, int V){
	vector<int> res;
	
	if(V > 0){
		vector<int> low(V, -1);
		vector<int> pre(V, -1);
		int count = 0;
		dfs(graph, res, 0, count, -1, low, pre);
	}

	return res;
}


signed main(){
	
	int V, E;
	vector<vector<pair<int,int>>> G;
	vector<int> b;
	set<int> s;
	
	cin>>V>>E;
	
	G.resize(V);
	
	for(int i = 0; i < E; i++){
		int s, t;
		
		cin>>s>>t;
		
		G[s].push_back({t, 1});
		G[t].push_back({s, 1});
	}
	
	b = Articulation_Points(G, V);
	
	sort(b.begin(), b.end());
	
	for(int i = 0; i < b.size(); i++){
		cout<<b[i]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 5500
#include<stdio.h>
int main(void){
char S[5];
scanf("%s", &S);

if((S[0]==S[1]&&S[2]==S[3] &&S[0]!=S[2])||
      (S[0]==S[2]&&S[1]==S[3] && S[0]!=S[1])|| 
         (S[0]==S[3]&&S[1]==S[2] &&S[0]!=S[1])){
    printf("Yes\n");
}else {
    printf("No\n");
}
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>
#include <math.h>

using namespace std;

#define ll long long int
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecchar vector<char>
#define vecstr vector<string>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

#define Pi 3.1415926535897932384626

int main() {
	ll n,d, ans = 0,count = 0;
	string s="No";
	bool flag = false;

	cin >> n >> d;

	vecpairll point(n);

	forll(i, 0, n) {
		cin >> point[i].first >> point[i].second;
	}

	forll(i, 0, n) {
		ll buf = (ll)pow(point[i].first,2)+(ll)pow(point[i].second,2);

		if (sqrt(buf) <= (double)d)
			ans++;
	}

	cout << ans;
}


Measured memory_bytes: 6428
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;

int main(void) {
    ll r,c,k;
    cin>>r>>c>>k;
    vvl tensu(r,vl(c,0));
    rep(i,k){
        ll a,b;
        cin>>a>>b;
        a--,b--;
        cin>>tensu[a][b];
    }
    vector<vector<vector<ll> > > dp(r,vvl(c,vl(4,-inf)));
    //rep(i,10) cout<<r<<endl;
    for(ll i=0;i<r;i++) for(ll j=0;j<c;j++) for(ll l = 0;l<4;l++){
        if(i == 0 && j == 0){
            if((l == 1) && (tensu[i][j] != 0)) dp[i][j][l] = tensu[i][j];
            else dp[i][j][l] = 0;
        }
        else{
            if(i > 0){
                if(l == 0) dp[i][j][l] = max({dp[i][j][l],dp[i-1][j][l],dp[i-1][j][1],dp[i-1][j][2],dp[i-1][j][3]});
                if(l == 1 && tensu[i][j] != 0) dp[i][j][l] = max({dp[i][j][l],dp[i-1][j][0]+tensu[i][j],dp[i-1][j][1]+tensu[i][j],dp[i-1][j][2]+tensu[i][j],dp[i-1][j][3]+tensu[i][j]});
            }
            if(j > 0){
                if(l == 0) dp[i][j][l] = max(dp[i][j][l],dp[i][j-1][l]);
                else{
                    if(tensu[i][j] != 0) dp[i][j][l] = max(dp[i][j][l],dp[i][j-1][l-1]+tensu[i][j]);
                    dp[i][j][l] = max(dp[i][j][l],dp[i][j-1][l]);
                }
            }
        }
    }
    cout<<max({dp[r-1][c-1][0],dp[r-1][c-1][1],dp[r-1][c-1][2],dp[r-1][c-1][3]})<<endl;
    //cout<<max({dp[0][1][0],dp[0][1][1],dp[0][1][2],dp[0][1][3]})<<endl;
    return 0;
}


Measured memory_bytes: 706292
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        String p = sc.next();
        
        String text = s + s;
        
        if(text.contains(p)) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 26244
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int64_t f(int64_t b, int64_t n)
{
    if (n < b) {
        return n;
    }
    else {
        return f(b, n / b) + (n % b);
    }
}


int main()
{
    int64_t n, s;
    std::cin >> n >> s;

    #if 1
    if (n == s) {
        std::cout << n+1 << std::endl;
        return 0;
    }
    #endif

    for (int64_t b = 2; b*b <= n; ++b) {
        int64_t ff = f(b, n);
        if (s == ff) {
            std::cout << b << std::endl;
            return 0;
        }
    }
    int64_t ans = INT64_MAX;

    for (int64_t p = 1; p*p < n; ++p) {
        int64_t b = (n - s) / p + 1;
        if (b >= 2 && s == f(b, n)) {
            ans = std::min(ans, b);
        }
    }

    if (ans == INT64_MAX) {
        ans = -1;
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;

class Solve
{
    public Solve() { }
    public static int Main()
    {
        new Solve().calc();
        return 0;
    }
 
 
    Scanner cin;
 
    void calc()
    {
        cin = new Scanner();
        var K = cin.nextInt();
        var S = cin.next();
        var result = S.Length <= K ? S : S.Substring(0, K) + "...";
        
        Console.WriteLine(result);
    }
}
class Modulo
{
    private const int M = 1000000007;
    private readonly int[] m_facs;
    public int Mul(int a, int b)
    {
        return (int)(Math.BigMul(a, b) % M);
    }
    public Modulo(int n)
    {
        m_facs = new int[n + 1];
        m_facs[0] = 1;
        for (int i = 1; i <= n; ++i)
        {
            m_facs[i] = Mul(m_facs[i - 1], i);
        }
    }
    public int Fac(int n)
    {
        return m_facs[n];
    }
    public int Pow(int a, int m)
    {
        switch (m)
        {
        case 0:
            return 1;
        case 1:
            return a;
        default:
            int p1 = Pow(a, m / 2);
            int p2 = Mul(p1, p1);
            return ((m % 2) == 0) ? p2 : Mul(p2, a);
        }
    }
    public int Div(int a, int b)
    {
        return Mul(a, Pow(b, M - 2));
    }
    public int Ncr(int n, int r)
    {
        if (n < r) { return 0; }
        if (n == r) { return 1; }
        int res = Fac(n);
        res = Div(res, Fac(r));
        res = Div(res, Fac(n - r));
        return res;
    }
}
 
class Scanner
{
    string[] s;
    int i;
 
    char[] cs = new char[] { ' ' };
 
    public Scanner()
    {
        s = new string[0];
        i = 0;
    }
 
    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }
 
    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }
 
    public long nextLong()
    {
        return long.Parse(next());
    }
 
    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }
 
    public double nextDouble()
    {
        return double.Parse(next());
    }
 
 
    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 27392
#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
#define int int64_t
#define M 1000000007
#define PI 3.14159265358979323
#define SZ 200005
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;



int32_t main()
{
	int a,b,h,m;
	cin>>a>>b>>h>>m;

	long double hangle,mangle,theta;

	mangle=((long double)m/60)*360;

	hangle= ((long double)(h*60+m)/720)*360;

	theta=abs(mangle-hangle);

	theta*=PI;
	theta/=180;

	cout<<setprecision(15)<<sqrtl(a*a+b*b-2*a*b*cos(theta))<<"\n";
	
	return 0;
}

/*
	cin>>n;
		int a[n];
		for(i=0;i<n;i++)
		{
			cin>>a[i];
		}

	string s;
		cin>>s;

	ifstream cin("input.txt");
	ofstream cout("output.txt");
*/

Measured memory_bytes: 4184
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
private:
  vector<ll> parents;

public:
  UnionFind(ll n): parents(n, -1) {}

  bool issame(ll x, ll y) {
    return root(x) == root(y);
  }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) {
    return -parents[root(x)];
  }

  private:

  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

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

  string S;
  cin >> S;

  stack<char> stack;
  for (ll i = 0; i < N; i++) {
    char ch = S[i];

    if (ch == '(') {
      stack.push(ch);
    }

    if (ch == ')') {
      if (!stack.empty() && stack.top() == '(') {
        stack.pop();
      } else {
        stack.push(ch);
      }
    }
  }

  ll left = 0;
  ll right = 0;
  while (!stack.empty()) {
    char ch = stack.top();
    stack.pop();

    if (ch == '(') {
      right++;
    }

    if (ch == ')') {
      left++;
    }
  }

  cout << string(left, '(') << S << string(right, ')') << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a[11],n,i,cnt=0;
  while(scanf("%d",&n)!=EOF){
    if(n==0){
      cnt--;
      printf("%d\n",a[cnt]);
    }else{
      a[cnt]=n;
      cnt++;
    }
  }
  return 0;
}


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

int main() {
  double a[3];
  while(cin >> a[0] >> a[1] >> a[2] && a[0]) {
    sort(a,a+3);
    double d=sqrt(a[0]*a[0]+a[1]*a[1]);
    int n;
    cin >> n;
    while(n--) {
      double x;
      cin >> x;
      x*=2;
      if(d<x) cout << "OK" << endl;
      else cout << "NA" << endl;
    }
  }
  return 0;
}


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

int main(void)
{
	for (int i = 1; i <= 9; i++)
	{
		for (int j = 1; j <= 9; j++)
		{
			cout << i << "x" << j << "=" << i * j << endl;
		}
	}
	return 0;
}


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

#define forsn(i,s,n) for(tint i=(s);i<(tint)(n); i++)
#define forn(i,n) forsn(i,0,n)
#define dforn(i,n) for(tint i = tint(n)-1; i >= 0; i--)
#define debug(x) cout << #x << " = "  << x << endl

using namespace std;

typedef long long tint;

random_device rd;
mt19937 gen(rd());

uniform_int_distribution<tint> dis(1, 10000);

void imprimirVector (vector<tint> v)
{
	if (!v.empty())
	{ 
		tint p = tint(v.size());
		cout << "[";
		forn(i,p-1)
			cout << v[i] << ",";
		cout << v[p-1] << "]" << endl;
	}
	else
		cout << "[]" << endl;
}

int main()
{
	#ifdef ACMTUYO
		assert(freopen("entrada.in", "r", stdin));
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	tint n;
	while (cin >> n)
	{
		map<tint,tint> hist;
		
		vector<tint> a (n);
		forn(i,n)
		{
			cin >> a[i];
			hist[a[i]]++;
		}
		
		tint total = 0;
		for (const auto &p : hist)
			total += (p.second*(p.second-1))/2;
			
		forn(i,n)
		{
			tint r = hist[a[i]];
			cout << total - (r*(r-1))/2 + ((r-1)*(r-2))/2 << "\n";
		}
		
		
	}
	
	
	return 0;
}





Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
string sto;
int main()
{
	cin>>a>>b>>c;
	sto="NO";
	if(c-a==(b-a)*2)
	{
		sto="YES";
	}
	cout<<sto<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<f64>();
    let (a, b) = (line[0], line[1]);

    println!("{}", ((a+b)/2.0).ceil());
}


Measured memory_bytes: 4352
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	vector<int>v(N + 1);
	for (int i = 1; i <= N; i++)cin >> v[i];
	vector<int>w(M + 1);
	for (int i = 1; i <= M; i++)cin >> w[i];
	vector<vector<long long int>>dp(N + 1, vector<long long int>(M + 1));
	vector<vector<long long int>>sum(N + 1, vector<long long int>(M + 1));
	for (int i = 0; i <= N; i++)dp[i][0] = sum[i][0] = 1;
	for (int i = 0; i <= M; i++)dp[0][i] = sum[0][i] = 1;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			dp[i][j] = sum[i - 1][j - 1] * (v[i] == w[j]);
			sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + dp[i][j] + MOD;
			sum[i][j] %= MOD;
		}
	}
	//for (int i = 0; i <= N; i++) {
	//	for (int j = 0; j <= M; j++) {
	//		cout << i << " " << j << " " << dp[i][j] << " " << sum[i][j] << endl;
	//	}
	//}
	cout << sum.back().back() << endl;
}

Measured memory_bytes: 62976
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

vector<vector<int>> calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 10; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - '0'] = i;
	}
	return res;
}

int main() {
	IOS;
	int n;
	cin >> n;
	string s;
	cin >> s;
	auto cn = calcNext(s);
	int res = 0;
	int now = 0;
  	REP(i, 10) {
		REP(j, 10) {
			REP(k, 10) {
				now = 0;
				now = cn[now][i]+1;
				if (now > n) {
					continue;
				}
				now = cn[now][j]+1;
				if (now > n) {
					continue;
				}
				now = cn[now][k];
				if (now < n) {
					res++;
				}
			}
		}
	}
	put(res);
	return 0;
}


Measured memory_bytes: 4224
(N, K), As = readlines.map{|l| l.split.map(&:to_i)}

h = {}; h[0] = [0]
s, ans = 0, 0
As.each.with_index(1) do |a, i|
  s += a
  t = (s - i) % K
  if h.key?(t)
    j = h[t].bsearch_index{|j| i - j < K}
    ans += h[t].size - j unless j.nil?
    h[t] << i
  else
    h[t] = [i]
  end
end
puts ans

Measured memory_bytes: 37132