akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
const int ALPHABET_SIZE = 26;
 
// trie node
struct TrieNode {
    struct TrieNode* children[ALPHABET_SIZE];
 
    // isEndOfWord is true if the node represents
    // end of a word
    bool isEndOfWord;
};
 
// Returns new trie node (initialized to NULLs)
struct TrieNode* getNode(void)
{
    struct TrieNode* pNode = new TrieNode;
 
    pNode->isEndOfWord = false;
 
    for (int i = 0; i < ALPHABET_SIZE; i++)
        pNode->children[i] = NULL;
 
    return pNode;
}
 
// If not present, inserts key into trie
// If the key is prefix of trie node, just
// marks leaf node
void insert(struct TrieNode* root, string key)
{
    struct TrieNode* pCrawl = root;
 
    for (int i = 0; i < key.length(); i++) {
        int index = key[i] - 'a';
        if (!pCrawl->children[index])
            pCrawl->children[index] = getNode();
 
        pCrawl = pCrawl->children[index];
    }
 
    // mark last node as leaf
    pCrawl->isEndOfWord = true;
}
 
// Returns true if key presents in trie, else
// false
bool search(struct TrieNode* root, string key)
{
    struct TrieNode* pCrawl = root;
 
    for (int i = 0; i < key.length(); i++) {
        int index = key[i] - 'a';
        if (!pCrawl->children[index])
            return false;
 
        pCrawl = pCrawl->children[index];
    }
 
    return (pCrawl != NULL && pCrawl->isEndOfWord);
}
 
// Returns true if root has no children, else false
bool isEmpty(TrieNode* root)
{
    for (int i = 0; i < ALPHABET_SIZE; i++)
        if (root->children[i])
            return false;
    return true;
}
 
// Recursive function to delete a key from given Trie
TrieNode* remove(TrieNode* root, string key, int depth = 0)
{
    // If tree is empty
    if (!root)
        return NULL;
 
    // If last character of key is being processed
    if (depth == key.size()) {
 
        // This node is no more end of word after
        // removal of given key
        if (root->isEndOfWord)
            root->isEndOfWord = false;
 
        // If given is not prefix of any other word
        if (isEmpty(root)) {
            delete (root);
            root = NULL;
        }
 
        return root;
    }
 
    // If not last character, recur for the child
    // obtained using ASCII value
    int index = key[depth] - 'a';
    root->children[index] =
          remove(root->children[index], key, depth + 1);
 
    // If root does not have any child (its only child got
    // deleted), and it is not end of another word.
    if (isEmpty(root) && root->isEndOfWord == false) {
        delete (root);
        root = NULL;
    }
 
    return root;
}
 
 
 
int main()
{
    
    int  n ; 
    cin>> n ; 
        TrieNode* arr = new TrieNode() ; 
        
        int count =0 ; 
        for(int  i = 0 ;i < n ;i++)
        {
            string s ;
            
            cin>>s ; 
            if(search (arr , s))
            continue ; 
            else
            {
                count++ ;
                insert( arr, s) ; 
                
            }
        }
        cout<<count <<endl ;
 
    
}

Measured memory_bytes: 303368
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
	int N;
	cin >> N;
	vector<int> W(N);
	for(int i = 0; i < N; i++) cin >> W[i];

	int S1 = 0, S2 = 0;
	for(int i = 0; i < N; i++) S2 += W[i];

	int res = INF;
	for(int i = 0; i < N-1; i++){
		S1 += W[i];
		S2 -= W[i];
		res = min(res, abs(S1-S2));
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll N; cin >> N;    
    ll ans = 0;
    rep(i, 1, N+1){
        ll t = N/i;
        ans += (i*t*(t+1))/2;
    }
    prt(ans);
}



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

int main() {
  int N,L; cin >>N>>L;
  vector<string> S(N);
  for(int i=0;i<N;i++){
    cin>>S.at(i);
  }
  sort(S.begin(),S.end());
  for(int i=0;i<N;i++){
    cout<<S.at(i);
  }  
  cout<<endl;
  return 0;
}

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

#A
def A():
    s = S()
    d = 0
    ans = 0
    k = 0
    for i in s:
        if i == "R":
            if d == 0:
                k = 1
            d += 1
            d %= 4
            if d == 0 and k:ans += 1
        else:
            if d == 0:
                k = 0
            d -= 1
            d %= 4
    print(ans)
    return

#B
def B():
    while 1:
        a,b,d = LI()
        if a == b == d == 0:
            quit()
        ans = []
        l = []
        m = float("inf")
        for x in range(-50000,50001):
            if (d-a*x)%b == 0:
                y = (d-a*x)//b
                k = abs(x)+abs(y)
                if k < m:
                    m = k
        for x in range(-50000,50001):
            if (d-a*x)%b == 0:
                y = (d-a*x)//b
                k = abs(x)+abs(y)
                if k == m:
                    ans.append((abs(x),abs(y)))
                    l.append(a*abs(x)+b*abs(y))
        print(*ans[l.index(min(l))])
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    B()



Measured memory_bytes: 8280
n = int(input())
a_list = list(map(int, input().split()))

ans = 0
r = 0
s_sum = 0
x_sum = 0
for l in range(n):  # しゃくとり法
    while r < n and x_sum & a_list[r] == 0:  # bitが立っているところが複数無ければ(s_sum+a_list[r] == x_sum^a_list[r] でもよい)
        s_sum += a_list[r]
        x_sum ^= a_list[r]
        r += 1
    ans += r - l  # rからlはbitが重ならないためすべてOK
    s_sum -= a_list[l]  # 範囲狭めた分を忘れない
    x_sum ^= a_list[l]  # XORの逆元は自分自身

print(ans)

# bitが複数立っている場所があるとxorはandに比べて答えが小さくなる
# 逆に、bitが複数立っている場所がなければxorとandは等価
# よって、bitが複数立っているのを検知した時点でそれより先は探索しなくてよく、
# 境界部分までは一致していることが保証される


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

int main() {
	int sum = 0;
	rep(i, 10) {
		int a; cin >> a;
		sum += a;
	}
	cout << sum << endl;
}

Measured memory_bytes: 3088
// Example program
#include <bits/stdc++.h>

using namespace std;

int main()
{
  string n;
  cin >> n;
  
  int sum = 0;
  for(char& c : n) {
      int ic = c - '0';
      sum = (sum + ic) % 9;
  }
  
  cout << (sum == 0 ? "Yes" : "No") << endl;
}


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

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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

typedef long long ll;

#define MAX_N 10000

struct Edge {
    int to;
    int weight;
    Edge(int t, int w)
        : to(t)
        , weight(w)
    {
    }
};
using Graph = vector<vector<int>>;
using Graph_e = vector<vector<Edge>>;

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

    const int size = 4;

    for (int temp = 0; temp < (1 << size - 1); temp++) {
        int sum = s[0] - '0';
        string ans;
        ans += s[0];

        for (int i = 0; i < size - 1; i++) {
            int t = s[i + 1] - '0';
            if (temp & (1 << i)) {
                sum += t;
                ans += '+';
                ans += s[i + 1];
            } else {
                sum -= t;
                ans += '-';
                ans += s[i + 1];
            }
        }
        ans += "=7";

        if (sum == 7) {
            cout << ans << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	deque<int> q;
	rep(i, n){
		int a; cin >> a;
		if(i % 2) q.push_front(a);
		else q.push_back(a);
	}
	vi ans(all(q));
	if(n % 2) reverse(all(ans));
	rep(i, n) cout << ans[i] << (i==n-1?"\n":" ");
	
	
	return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b;cin>>a>>b;
  if(a*b<=0)cout<<"Zero"<<endl;
  else if(a>0)cout<<"Positive"<<endl;
  else if((b-a)%2!=0)cout<<"Positive"<<endl;
  else cout<<"Negative"<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/python
# -*- Coding: utf-8 -*-


N, M = map(int, input().split())

listA =[]

for i in range(N):
    listA.append(list(map(int, input().split())))

money = 0
listA = sorted(listA)

for i in range(len(listA)):
    if M == 0:
        break

    if listA[i][1] > M:
        money += listA[i][0] * M
        M = 0
    else:
        M -= listA[i][1]
        money += listA[i][0] * listA[i][1]

print(money)


Measured memory_bytes: 28656
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;

long long n;

long long x[101];
long long y[101];
long long h[101];
long long f;
long long tt;
long long hai[101][101][101];
int main()
{
	tt=-1;
	cin>>n;
	rep(i,n)
	{
		cin>>x[i]>>y[i]>>h[i];
		if(h[i]!=0)rep(j,101)rep(k,101)
		{
			if(tt==-1)tt=i;
			hai[i][j][k]=h[i]+abs(x[i]-j)+abs(y[i]-k);
		}
	}
	rep(j,101)rep(k,101)
	{
		f=1;
		rep(i,n)
		{
			if(h[i]!=0&&hai[i][j][k]!=hai[tt][j][k])f=0;
		}
		if(f)
		{
			f=1;
			rep(i,n)
			{
				if(max(hai[tt][j][k]-abs(j-x[i])-abs(k-y[i]),(long long)0)!=h[i])f=0;
			}
			if(f==1&&hai[tt][j][k]>=1)cout<<j<<" "<<k<<" "<<hai[tt][j][k]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 8192
# AtCoder Beginner Contest 113-C
if __name__ == "__main__":
    N, M = map(int, input().split())
    city_list = []
    for i in range(M):
        city_list.append(list(map(int, input().split())))
    pref = {}
    pref_sort = {}
    for i in range(M):
        key = city_list[i][0]
        val = city_list[i][1]
        if str(key) in pref:
            pref[str(key)].append(val)
        else:
            pref[str(key)] = [val]
    ans = {}
    for key, val in pref.items():
        val.sort()
        for i in range(len(val)):
            ans[(key, val[i])] = str(key).zfill(6) + str(i+1).zfill(6)
    for key, val in city_list:
        print(ans[str(key), val])

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

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

  if(S=="SUN")
  cout << "7";
  if(S=="MON")
  cout << "6";
  if(S=="TUE")
  cout << "5";
  if(S=="WED")
  cout << "4";
  if(S=="THU")
  cout << "3";
  if(S=="FRI")
  cout << "2";
  if(S=="SAT")
  cout << "1";
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,m,q;
	int ans=0;
	cin >>n>>m>>q;
	VVi dis(n+2,Vi(n+2,0));
	int l,r;
	rep(i,m){
		cin>>l>>r;
		//l--;
		//r--;
		dis[l][r]++;
		//dis[l][l]++;
		//dis[l][r+1]--;
		//dis[r+1][l]--;
		//dis[r+1][r+1]++;
	}
	rep(i,n+1){
		rep(j,n+1){
			if(j!=0){
				dis[i][j]+=dis[i][j-1];
			}
		}
	}
	rep(i, n+1){
		
		rep(j, n+1){
			if (i != 0)
			{
				dis[i][j] += dis[i - 1][j];
			}
		//	clog<<dis[i][j]<<" ";
		}
	//	clog<<endl;
	}
	rep(i,q){
		cin>>l>>r;
		//l--;
		//r--;
		cout<<dis[r][r]-dis[l-1][r]-dis[r][l-1]+dis[l-1][l-1]<<endl;
	}
}
/*
  a----b en
a 01 -1 
- 00 01
- -1
-
b
st
*/

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

using namespace std;

int solve(int A, int B, int K)
{
	for (int x = 1000; x > 0; --x) {
		if (A % x == 0 && B % x == 0) {
			if (--K == 0) {
				return x;
			}
		}
	}
	return -1;
}

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

	cout << solve(A, B, K) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#define ll long long
using namespace std;
const ll mod=1e9 +7;
int n,m;
ll K,xx,yy,a,s;
int mp[1010][1010];
ll aa[3][3],bb[3][3],ss[3][3];
bool bx,by;
ll power(ll x,ll k)
{
    ll sss=1;
    while (k)
    {
        if (k%2) sss=sss*x%mod;
        x=x*x%mod;
        k/=2;
    }
    return sss;
}
void init()
{
    aa[1][1]=ss[1][1]=s;
    aa[1][2]=ss[1][2]=1;
    aa[2][1]=ss[2][1]=0;
    aa[2][2]=ss[2][2]=a;
}
void square_mul()
{
    for (int i=1;i<=2;++i)
        for (int j=1;j<=2;++j)
        {
            bb[i][j]=0;
            for (int k=1;k<=2;++k)
                bb[i][j]=(bb[i][j]+aa[i][k]*ss[k][j]%mod)%mod;
        }
    for (int i=1;i<=2;++i)
        for (int j=1;j<=2;++j)
        ss[i][j]=bb[i][j];
}
void square_self()
{
    for (int i=1;i<=2;++i)
        for (int j=1;j<=2;++j)
        {
            bb[i][j]=0;
            for (int k=1;k<=2;++k)
                bb[i][j]=(bb[i][j]+aa[i][k]*aa[k][j]%mod)%mod;
        }
    for (int i=1;i<=2;++i)
        for (int j=1;j<=2;++j)
        aa[i][j]=bb[i][j];
}
void square_power(ll k)
{
    --k;
    while (k)
    {
        if (k%2) square_mul();
        square_self();
        k/=2;
    }
}
int main()
{
    scanf("%d%d%lld",&n,&m,&K);
    char ch[1010];
    for (int i=1;i<=n;++i)
    {
        scanf("%s",ch+1);
        for (int j=1;j<=m;++j)
            if (ch[j]=='#') 
                mp[i][j]=1,++s;
    }
    for (int i=1;i<=n;++i)
        if (mp[i][1]&&mp[i][m])
            ++a,bx=1;
    for (int i=1;i<=m;++i)
        if (mp[1][i]&&mp[n][i])
            ++a,by=1;
    if ((bx==1 && by==1) || K==1)
    {
        printf("1\n");
        return 0;
    }
    if (bx==0 && by==0)
    {
        printf("%lld\n",power(s,K-1));
        return 0;
    }
    if (by==1)
    {
        int mmp[1010][1010];
        swap(mmp,mp);
        swap(n,m);
        for (int i=1;i<=n;++i)
            for (int j=1;j<=m;++j)
                mp[i][j]=mmp[j][i];
    }
    for (int i=1;i<=n;++i)
        for (int j=1;j<=m;++j)
            if (mp[i][j]==1&&mp[i][j+1]==1)
                ++xx;
    yy=xx*a;
    if (K==2)
    {
        printf("%lld\n",s-xx);
        return 0;
    }
    init();
    square_power(K-2);
    xx=(xx*ss[1][1]%mod+yy*ss[1][2]%mod)%mod;
 
    printf("%lld\n",( (power(s,K-1)-xx)%mod + mod)%mod);
    return 0;
}

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

using namespace std;

int main(){
  
  long long int n, d;
  cin>>n>>d;

  long long int x[n], y[n];
  long long int cnt=0;

  for(int i=0; i<n; i++) cin>>x[i]>>y[i];

  for(int i=0; i<n; i++){
    long long int dist = x[i]*x[i] + y[i]*y[i];
  
    if(dist<=d*d) cnt++;
  }

  cout<<cnt<<endl;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int64_t>a(n);
	int tmp;
	cin>>tmp;
	a.at(0)=tmp;
	for(int i=1;i<n;++i){
		cin>>tmp;
		a.at(i)=a.at(i-1)+tmp;
	}
	int64_t ans=numeric_limits<int64_t>::max();
	for(int i=0;i<n-1;++i){
		ans=min(ans,abs(a.back()-a.at(i)*2));
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <string.h>

using namespace std;
#define ll long long int

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

	double L;
	cin>>L;
	// printf("%f\n", L);
	double a=(L*L*L);
	// printf("%.10f\n", a);
	double x=a/27;
	printf("%.10f\n", x);
	// x=x*a;
	// printf("%.10f\n", x);
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
	        String S = sc.next();
	        char[] c = S.toCharArray();
	        
	        int lcnt=0;
	        int rcnt=0;
	        int min=0;
	        for(int i=0;i<N;i++) {
	        	if(c[i]=='(')lcnt++;
	        	else lcnt--;
	        	min=Math.min(min, lcnt);
	        }
	        
	        for(int i=0;i<-min;i++) {
	        	System.out.print("(");
	        	lcnt++;
	        }
	        
	        if(lcnt>rcnt) {
        		System.out.print(S);
	        	for(int i=0;i<lcnt-rcnt;i++) {
	        		System.out.print(")");
	        	}
	        		System.out.println("");
	        } else {
	        	for(int i=0;i<rcnt-lcnt;i++) {
	        		System.out.print("(");
	        	}
	       		System.out.print(S);
	      		System.out.println("");

	        }
	         
	 }
	 

}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
 
#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// type alias
using VI = std::vector<int>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PSI = std::pair<std::string, int>;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

signed main() {
  solve();
  return 0;
}

void solve() {
  int n;
  std::cin >> n;
  std::vector<PSI> vec(n);
  std::map<PSI, int> map;
  std::string s;
  int p;
  REP(i, n) {
    std::cin >> s >> p;
    vec.at(i) = PSI(s, -p);
    map[PSI(s, -p)] = i+1;
  }
  ASORT(vec);
  REP(i, n) {
    cout(map.at(vec.at(i)));
  }
}

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

#define ll long long
#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>
#define mp make_pair
#define pb push_back

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,d;
	cin >> n;
	d = n%10;
	if (d == 2 || d == 4 || d == 5 || d == 7 || d == 9) cout << "hon\n";
	else if (d == 0 || d == 1 || d == 6 || d == 8) {
		cout << "pon\n";
	} else cout << "bon\n";
	return 0;
}

Measured memory_bytes: 3636
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
#define int ll
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int n;
cin>>n;
int beg=1,end=1;
while(n--)
{
	int t,a;
	cin>>t>>a;
	int x=(beg-1)/t+1ll,y=(end-1)/a+1ll;
  int factor=max(x,y);
  beg=factor*t;
  end=factor*a;
}
cout<<beg+end;
}
signed main()
{
//code

fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll N, Q, A, B, M, K;
string S;
vector<vector<int>> edge;
vector<ll> c;
vector<ll> start;
vector<ll> ans;
vector<ll> counter;

void solve() {
	cin >> N;
	edge.resize(N, vector<int>());
	start.resize(N, 0);
	ans.resize(N, -1);
	rep(i, N - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		edge[a].emplace_back(b);
		edge[b].emplace_back(a);
		start[a]++;
		start[b]++;
	}
	ll maxx = 0;
	ll sum = 0;
	c.resize(N);
	rep(i, N) {
		cin >> c[i];
		sum += c[i];
		maxx = max(maxx, c[i]);
	}
	sort(c.begin(), c.end());
	ll c_cnt = 0;

	counter.resize(N, 0);

	queue<ll> Q;
	rep(i, N) {
		if (start[i] == 1) {
			Q.push(i);
			counter[i]--;
		}
	}

	while (Q.size() != 0) {
		ll P = Q.front();
		Q.pop();

		counter[P]++;

		if (counter[P] != edge[P].size() - 1) continue;

		ans[P] = c[c_cnt];
		c_cnt++;

		rep(i, edge[P].size()) {
			Q.push(edge[P][i]);
		}

	}

	cout << sum - maxx << endl;
	rep(i, N) cout << ans[i] << " ";

}

int main() {
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>
int gcd(int i, int j) {
    return j == 0 ? i : gcd(j, i % j);
}
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    printf("%lld\n", (long long)n * m / gcd(n, m));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
#define mod 1000000007
#define MAXN 2005
ll Pow(ll a, ll n) {
    if (n == 0) return 1;
    if (n % 2) return (a * Pow(a, n - 1)) % mod;
    else {
        ll k = Pow(a, n / 2);
        return (k * k) % mod;
    }
}
ll gyakusuu[MAXN + 1];
ll nCk(ll n, ll k) {
    if (k > n) return 0;
    ll ret = 1;
    for (ll i = 1; i <= k; i++) {
        ret = ret * (n - k + i) % mod;
        ret = ret * gyakusuu[i] % mod;
    }
    return ret;
}
int main() {
    for (int i = 1; i <= MAXN; i++) {
        gyakusuu[i] = Pow(i, mod - 2);
    }
    ll s; cin >> s;
    ll ret = 0;
    for (int i = 1; i <= s / 3; i++) {
        ret = (ret + nCk((s -  2 * i - 1), i - 1)) % mod;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
using namespace std;
int main() {
	char S[3];
	cin >> S[0] >> S[1] >> S[2];
	if (S[0] == S[2])cout << "Yes";
	else cout << "No";
}


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

bool used[1001][1001][1001];

int main() {
  int n, m, p[1000][3] = {}, dup = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> p[i][j];
    }
    sort(p[i], p[i] + 3);
  }
  for (int i = 0; i < n; i++) {
    if (used[p[i][0]][p[i][1]][p[i][2]]) continue;
    for (int j = 0; j < n; j++) {
      int c = 0;
      if (i == j) continue;
      if (p[i][0] == p[j][0] && p[i][1] == p[j][1] && p[i][2] == p[j][2]) {
        dup++;
        used[p[i][0]][p[i][1]][p[i][2]] = true;
      }
    }
  }
  cout << dup << endl;
}

Measured memory_bytes: 4240
// #include <bits/stdc++.h>
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>
#include<functional>
#include <bitset>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
typedef long long int lli;
// static const int MOD = 998244353;
// static const int MAX = 100005;
// static const int ls = 101;
// static const int NMAX = 5005;
// static const lli INFTY = 1000000000000;

// typedef priority_queue<int, greater<int>> RevQ;
int n;
// string s;
// lli l, r;
// lli gcd(lli a, lli b) {
//   return b ? gcd(b, a%b) : a;
// }



int main(){
  cin >> n;
  cout << pow(n,2) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define END << endl;
#define SP << " " << 
using namespace std;

int A[105],B[105],C1[105],C2[105];

int main(){
	REP(i,105){
		A[i]=B[i]=C1[i]=C2[i]=0;
	}
	int n,x,y,z,a,c=0;
	cin>>n;
	cin>>x;
	REP(i,x){
		cin>>a;
		A[a-1]=1;
	}
	cin>>y;
	REP(i,y){
		cin>>a;
		B[a-1]=1;
	
	}
	cin>>z;
	REP(i,z){
		cin>>a;
		C1[a-1]=C2[a-1]=1;
	}
	REP(i,n){
		if(A[i]==1&&C1[i]==1) C1[i]=0;
		if(B[i]==0&&C2[i]==1) C2[i]=0;
	}
	REP(i,n){
		if(C1[i]==1||C2[i]==1) c++;
	}
	cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 3096
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static final void main(String[] args) {
        String in = sc.next();
        if (in.length() < 4) {
            System.out.println("No");
            System.exit(0);
        }
        String s = in.substring(0, 4);
        if (s.contains("YAKI")) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23124
#include<iostream>
using namespace std;
int n,a,ans=0;
void add(int x){
	for(;x%2==0;x/=2)ans++;
}
int main(void){
	cin>>n;
	for(int i=0;i<n;i++){cin>>a;add(a);}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argv, char *argc[]){
    int input, loop, checker;
    
    scanf("%d", &input);
    
    for(loop=1; input>=loop; loop++){   /*入力値を超えるまで1づつ増加するloop*/
        if((loop%3) == 0){              /*loopが3で割れるなら出力、次の周回へ*/
            printf(" %d", loop);
            continue;
        }
        
        for(checker=loop; 0<checker; checker/=10){
            if(((checker%10) == 3)){    /*loopの1の桁が3なら出力、次の周回へ */
                printf(" %d", loop);    /*違ったら1の桁を捨て、1桁づつズラす */
                break;                  /*そのために10で割って、3がloopに    */
            }                           /*含まれてないか調査する             */
        }
        
    }
    
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
import functools
import fractions


N = int(input())
a = list(map(int,input().split()))
ans = 1
gcd = functools.reduce(fractions.gcd,a)
s_front = [1]*N
s_back = [1]*N
s_front[0] = a[0]
s_back[0] = a[N-1]

for i in range(N):
	if i > 0:
		s_front[i] = fractions.gcd(s_front[i-1],a[i])
		s_back[i] = fractions.gcd(s_back[i-1],a[N-i-1])
for i in range(N):
	if i == 0:
		gcd_new = s_back[N-2]
	elif i == N-1:
		gcd_new = s_front[N-2]
	else:
		gcd_new = fractions.gcd(s_front[i-1],s_back[N-i-2])
	ans = max(ans,gcd_new)
print(ans)

Measured memory_bytes: 16148
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskD {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			String inputS = in.next();
			char[] s = new char[2 * n];
			for (int i = 0; i < s.length; i++) {
				s[i] = inputS.charAt(i % n);
			}
			for (int a = 0; a < 2; a++) {
				for (int b = 0; b < 2; b++) {
					char[] ans = new char[2 * n];
					ans[0] = a == 0 ? 'S' : 'W';
					ans[1] = b == 0 ? 'S' : 'W';
					for (int i = 2; i < s.length; i++) {
						if ((ans[i - 1]) == 'S' == (s[i - 1] == 'o')) {
							ans[i] = ans[i - 2];
						} else {
							ans[i] = (char) ('S' ^ 'W' ^ ans[i - 2]);
						}
					}
					boolean ok = true;
					for (int i = 0; i < n; i++) {
						if (ans[i] != ans[i + n]) {
							ok = false;
						}
					}
					if (ok) {
						out.println(new String(Arrays.copyOf(ans, n)));
						return;
					}
				}
			}
			out.println(-1);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 26068
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> N;
  if (N<=111) cout<<111<<endl;
  else if(N<=222) cout<<222<<endl;
  else if(N<=333) cout<<333<<endl;
  else if(N<=444) cout<<444<<endl;
  else if(N<=555) cout<<555<<endl;
  else if(N<=666) cout<<666<<endl;
  else if(N<=777) cout<<777<<endl;
  else if(N<=888) cout<<888<<endl;
  else if(N<=999) cout<<999<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int W,a,b;
  cin >> W >> a >> b;
  if(a<=b){
    if(a+W>=b){
      cout << 0 << endl;}
    else{
      cout << b-a-W << endl;}
  }
  else{
    if(b+W>=a){
      cout << 0 << endl;}
    else{
      cout << a-b-W << endl;}
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char array[6];
    int count=1,i,j;
    scanf("%s",array);
   if(array[2]==array[3] && array[4]==array[5])
   {
       printf("Yes\n");
   }
   else
   {
       printf("No\n");
   }

   return 0;
}


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

constexpr int mod = 998244353;

int main()
{
    string s;
    cin >> s;
    if (s == "AAA" || s == "BBB")
        puts("No");
    else
        puts("Yes");
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9+5;
int main()
{
    int n;
    scanf("%d", &n);
    vector<int> h(n);
    vector<int> dp(n, INF);
    for(int& x : h)
        scanf("%d", &x);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j : {i+1, i+2})
        {
            if(j<n)
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
        }
    }
    cout << dp[n-1];
    //while(1);
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int n,a[111111],i=0,ans=0;
  scanf("%d",&n);
  for(;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n-1;i++){
    if(a[i]>i){
      if(i==a[a[i]-1]-1) ans++;
    }
  }
  printf("%d",ans);
}

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

using namespace std;

#define endl '\n'

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int oo = 0x3f3f3f3f;
const double eps = 1e-9;
const int maxn = 100000 + 10;

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

#ifdef MARX
	freopen("data.in", "r", stdin);
	// freopen("data.out", "w", stdout);
#endif

	int n; cin >> n;

	int x = 0;

	for (int i = 0; i < n; ++i)
	{
		int v; cin >> v;
		x ^= v & 1;
	}

	cout << (x == 0 ? "YES" : "NO") << endl;


	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  char X,Y;
  cin >> X >> Y;
  if(X>Y) cout << ">" << endl;
  else if(X<Y) cout << "<" << endl;
  else if(X=Y) cout << "=" << endl;

  return 0;
}


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

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

    int cnt[26] = {};
    for(char c : s) cnt[c-'a']++;

    int odd = 0;
    for(int i = 0; i < 26; i++) if(cnt[i]%2)    odd++, cnt[i]--;

    int n = s.length();
    if(odd > 1 || (odd == 1 && n%2 == 0) || (odd == 0 && n%2 == 1)){
        cout << 0 << endl;
    }else{
        ll ans = 1;
        for(ll i = 1; i <= n/2; i++)    ans *= i;
        for(int i = 0; i < 26; i++){
            for(int j = 1; j <= cnt[i]/2; j++){
                ans /= j;
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3200
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Contest
{
    class Program
    {
        static int Main(string[] args)
        {
            new Program().Process();

            return 0;
        }

        private CommonInput cin;

        private void Process()
        {
            cin = new CommonInput();

            int N, Q, M;

            int max;
            int result;

            int[] date;

            while (true)
            {
                N = cin.GetNextToInt();
                Q = cin.GetNextToInt();

                // ??\????????????????????¨???????????????????????????????????¨???????????¨??????????????\??????????????????
                if (N == 0 && Q == 0)
                    break;

                max = 0;
                result = 0;
                date = new int[101];

                for (int i = 0; i < N; i++)
                {
                    M = cin.GetNextToInt();

                    for (int j = 0; j < M; j++)
                    {
                        date[cin.GetNextToInt()]++;
                    }
                }

                for (int i = 1; i < 101; i++)
                {
                    if (date[i] >= Q && date[i] > max)
                    {
                        max = date[i];
                        result = i;
                    }
                }

                Console.WriteLine(result);
            }
        }
    }

    public class CommonInput
    {
        public CommonInput()
        {
            this._s = new string[0];
            this._i = 0;
        }

        public string Line { get; set; }
        private string[] _s;
        private int _i;
        private char[] _sep = { ' ' };

        public void GetLine()
        {
            this._i = 0;
            do
            {
                this.Line = Console.ReadLine();
            } while (this.Line == "");

            if (this.Line != null)
                this._s = this.Line.Split(this._sep, StringSplitOptions.RemoveEmptyEntries);
        }

        public string GetNext()
        {
            if (this._i < this._s.Length)
                return this._s[this._i++];

            this.GetLine();

            return this._s[this._i++];
        }

        public int GetNextToInt()
        {
            return int.Parse(this.GetNext());
        }

        public long GetNextToLong()
        {
            return long.Parse(this.GetNext());
        }

        public double GetNextToDouble()
        {
            return double.Parse(this.GetNext());
        }
    }
}

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

using namespace std;

int main()
{
  int n;
  cin>>n;
  string a;
  map<string,int> hash;
  while(n--)
  {
    cin>>a;
    hash[a]++;
  }
  cout<<"AC x "<<hash["AC"]<<endl;
	cout<<"WA x "<<hash["WA"]<<endl;
	cout<<"TLE x "<<hash["TLE"]<<endl;
	cout<<"RE x "<<hash["RE"]<<endl;
  return 0;
}
  

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

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

    for (int i = 1; i < N; i++) {
        cin >> A.at(i);
        A.at(i)--;
        B.at(A.at(i))++;
    }

    for (int i = 0; i < N; i++) cout << B.at(i) << endl;
    
    return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

template <typename T> T modpow(T a, T n, T mod) { // a^n % mod
    T res = 1;
    while(n > 0) {
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template <typename T> T gcd(T a, T b) {
    if(a > b) gcd(b, a);
    T r;
    while(r = a % b) {
        a = b;
        b = r;
    }
    return b;
}
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, p = 1, q;
    cin >> n;
    rep(i, n) {
        cin >> q;
        p = lcm(p, q);
    }
    cout << p << endl;
}


Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

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

    int x = 0;
    int res = 0;
    for (int i = 0; i < s.length(); i++) {
        (s[i] == 'I') ? x++ : x--;
        res = max(res, x);
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// #define debug(a) cout << "["; rep(i,a.size()) cout << a[i] << ", "; cout<<"]"<< endl;

const ll mod = 1000000007;

int main() {
    int n; cin >> n;
    vector<int> Ws(n);
    int ans = INF;
    rep(i,n) cin >> Ws.at(i);
    int sum = 0;
    rep(i,n){
        sum += Ws.at(i);
    }
    int summemo = 0;
    rep(i,n){
        summemo += Ws.at(i);
        ans = min(ans, abs(2 * summemo - sum));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>

#define ll long long
using namespace std;

int main() {
    int n;
    cin >> n;
    ll mod = 1e9 + 7;

    vector<map<string, ll>> dp(n + 1);
    dp[0][""] = 1;
    string key = "ACGT";
    for (int i = 1; i <= n; i++) {
        for (auto x:dp[i - 1]) {
            for (int j = 0; j < 4; j++) {
                string after = x.first + key[j];
                if (after.size() > 4)after = after.substr(1, 4);

                bool ok = true;
                if (after.size() >= 3) {
                    if (after.find("AGC")!=string::npos)ok = false;
                    if (after.find("ACG")!=string::npos)ok = false;
                    if (after.find("GAC")!=string::npos)ok = false;
                }
                if (after.size() >= 4) {
                    if (after[0] == 'A' && (after[1] == 'G' || after[2] == 'G') && after[3] == 'C')ok = false;
                }

                if (ok) {
                    dp[i][after] += x.second;
                    dp[i][after] %= mod;
                }
            }
        }
    }

    ll ret = 0;
    for (auto x:dp[n]) {
        ret += x.second;
        ret %= mod;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 2688
local ns = io.read()
local k = io.read("*n")
if k == 1 then
  local a = tonumber(ns:sub(1, 1))
  print(a + 9 * (#ns - 1))
elseif k == 2 then
  if #ns == 1 or ns == "10" then print(0)
  else
    local a = tonumber(ns:sub(1, 1))
    local b, bpos = 0, #ns + 1
    for i = 2, #ns do
      if ns:sub(i, i) ~= "0" then
        b, bpos = tonumber(ns:sub(i, i)), i
        break
      end
    end
    -- use 1st but not max
    local ret = (#ns - 1) * 9 * (a - 1)
    -- don't use 1st
    ret = ret + 81 * (#ns - 1) * (#ns - 2) // 2
    -- use 1st by max
    if bpos <= #ns then
      ret = ret + b + 9 * (#ns - bpos)
    end
    print(ret)
  end
else
  if #ns < 3 then print(0)
  else
    local a = tonumber(ns:sub(1, 1))
    local b, bpos = 0, #ns + 1
    for i = 2, #ns do
      if ns:sub(i, i) ~= "0" then
        b, bpos = tonumber(ns:sub(i, i)), i
        break
      end
    end
    local c, cpos = 0, #ns + 1
    for i = bpos + 1, #ns do
      if ns:sub(i, i) ~= "0" then
        c, cpos = tonumber(ns:sub(i, i)), i
        break
      end
    end
    -- don't use 1st
    ret = 729 * (#ns - 1) * (#ns - 2) * (#ns - 3) // 6
    -- use 1st but not max
    ret = ret + (a - 1) * 81 * (#ns - 1) * (#ns - 2) // 2
    -- use 1st by max
    if bpos <= #ns - 1 then
      -- don't use second
      ret = ret + 81 * (#ns - bpos) * (#ns - bpos - 1) // 2
      -- use 2nd but not max
      ret = ret + (b - 1) * 9 * (#ns - bpos)
      -- use 2nd by max
      if cpos <= #ns then
        ret = ret + c + 9 * (#ns - cpos)
      end
    end
    print(ret)
  end
end


Measured memory_bytes: 504
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();
		
		if(a<=5)
			System.out.print(0);
		else if(a<=12)
			System.out.print(b/2);
		else
			System.out.print(b);
		
		

	}

}

Measured memory_bytes: 21972