akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

const int H = 10, W = 5;

int board[H][W];

int main(){
	int h, score, inc;
	while(cin >> h, h){
		inc = 1;
		score = 0;
		for(int i = 0;i < h;++i){
			for(int j = 0;j < W;++j){
				cin >> board[i][j];
			}
		}
		while(inc){
			int c, k;
			inc = 0;
			for(int i = 0;i < h;++i){
				for(int j = 0;j < W;++j){
					c = 0;
					for(int k = j;k < W && board[i][j] == board[i][k];++k){
						++c;
					}
					if(c >= 3){
						inc += board[i][j] * c;
						for(int k = j;k < j + c;++k){
							board[i][k] = 0;
						}
					}
					j += (c - 1);
				}
			}
			for(int i = 1;i < h;++i){
				for(int j = 0;j < W;++j){
					if(!board[i][j]){
						for(int k = i - 1;0 <= k;--k){
							board[k + 1][j] = board[k][j];
						}
						board[0][j] = 0;
					}
				}
			}
			score += inc;
		}
		cout << score << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import std.stdio,std.string,std.conv,std.math;

int main()
{
	double x,h;
	while((x = readln.chomp.to!int) != 0 && (h = readln.chomp.to!int) != 0)
	{
		double sum = 0;
		sum += x*x;
		double half = x/2;
		sum += 2*x*sqrt(half*half+h*h);
		writefln("%.8f",sum);
	}
	return 0;
}

Measured memory_bytes: 1112
using System;
using System.Linq;
public class c
{
  public static void Main()
  {
    int[] a=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    Array.Sort(a);
    string ans="NO";
    if(a[0]==5&&a[1]==5&&a[2]==7)ans="YES";
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 11348
<?php
  $n = trim(fgets(STDIN));
  $a = explode(" ", trim(fgets(STDIN)));
  $ans = gcd($a[0], $a[1]);
  for($i=2; $i<$n; $i++){
      $ans = gcd($ans,$a[$i]);
  }
  echo $ans;
  
  function gcd($m, $n){
    if($n > $m) list($m, $n) = array($n, $m);
     
    while($n !== 0){
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    return $m;
}

Measured memory_bytes: 12792
// AtCoder template
// 見た奴全員saba!
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)




// segment-tree
// Tはモノイドの台集合
template<typename T>
class segment_tree{
private:
    using F = function<T(T,T)>;
    int leafnum;             // 葉の数
    const T m1;                 // 単位元
    const F f;
    vector<T> seg; // ノードの値を持つ配列
    int bilower(int x){
        int ret = 1;
        while(ret < x) ret <<= 1;
        return ret;
    }

    T _query(int a, int b, int k, int l, int r){
        // [a, b)の区間に対するクエリについて
        // ノード k （区間 [l, r) 担当）が答える
        if (r <= a || b <= l) return m1; // 区間が被らない場合は 単位元 を返す
        if (a <= l && r <= b) return seg[k]; // ノード k の担当範囲がクエリ区間 [a, b)             
        else{ // に完全に含まれる
            T r1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子に値を聞く
            T r2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子に値を聞く
            return f(r1, r2); // 左右の子の値の f を取る
        }
    }

public:
    
    //constructor
    //nodenumは配列の要素数、 はモノイドの単位元
    segment_tree(int nodenum, const T m, const F fun):m1(m),f(fun){
        leafnum = bilower(nodenum);
        seg = vector<T> (2*leafnum, m);
    }

    // i 番目の葉の値を x に変える
    void update(int i, T x){    
        i += leafnum - 1; // i 番目の葉のノード番号
        seg[i] = x;
        while (i > 0) {
            i = (i - 1) / 2; // ノード i の親ノードの番号に変える
            seg[i] = f(seg[i * 2 + 1], seg[i * 2 + 2]); // 左右の子の f を計算しなおす
        }
    }

    //指定した区間の最小値を求める
    //引数a,bで指定した半開区間[a,b)の中の最小値を求める
    //_query(a,b,0,0,leafnum)として呼び出す、最期の引数に注意（leafnumはメンバ変数になっているのでそれを呼び出せばよい）
    T query(int a, int b){
        return _query(a, b, 0, 0, leafnum);
    }
};

// 最大公約数を求める
// 計算量O(logn)
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

int main(){
    int n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    segment_tree<ll> seg(n, 0LL, gcd);
    rep(i,n) seg.update(i, a[i]);
    ll ans = 0LL;
    rep(i,n){
        ll now = gcd(seg.query(0,i), seg.query(i+1,n+1));
        ans = max(ans, now);
    }
    cout << ans << endl;
}

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

ll solve() {
    string S;
    ll K;
    cin >> S >> K;
    ll n0 = 1;
    vector<ll> l;
    char c = S[0];
    for ( int i = 1; i < S.size(); i++ ) {
        if ( S[i] == c ) n0++;
        else {
            l.push_back(n0);
            n0 = 1;
            c = S[i];
        }
    }
    if ( n0 > 0 ) l.push_back(n0);
    ll ans = 0;
    if ( S[0] != S[S.size()-1] ) {
        for ( int n : l ) {
            ans += n/2;
        }
        ans *= K;
    } else if ( l.size() > 1 ) {
        for ( int i = 1; i < l.size() -1; i++) {
            ans += l[i]/2;
        }
        ans *= K;
        ans += (l[0]+l[l.size()-1])/2 * (K-1);
        ans += l[0]/2;
        ans += l[l.size()-1]/2;
    } else {
        ans = (l[0]*K)/2;
    }

    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int solve(int n, vector< vector<int> >&v)
{
	ll i,j,k,ans=-1;
	
	vector<ll> dp(3);
	for(int j=0;j<3;++j)
		dp[j]=v[0][j];
	vector<ll> temp(3);
	for(int i=1;i<n;++i)
	{
		temp[0]=(dp[1]+v[i][0])>(dp[2]+v[i][0])?(dp[1]+v[i][0]):(dp[2]+v[i][0]);
		temp[1]=(dp[0]+v[i][1])>(dp[2]+v[i][1])?(dp[0]+v[i][1]):(dp[2]+v[i][1]);
		temp[2]=(dp[0]+v[i][2])>(dp[1]+v[i][2])?(dp[0]+v[i][2]):(dp[1]+v[i][2]);
		dp=temp;
	}
	for(i=0;i<3;++i)
	{
		ans=ans>dp[i]?ans:dp[i];
	}
	return ans;
}


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

	vector<vector<int> >v(N);
	for(int i=0;i<N;++i)
	{
		vector<int> t(3);
		v[i]=t;
	}
	for(int i=0;i<N;++i )
	{
		for(int j=0;j<3;++j)
			cin>>v[i][j];
	}

	cout<<solve(N, v)<<endl;

}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

ll gcd(ll a,ll b) {
  if(b==0) {
    return a;
  }
  else {
    return gcd(b,a%b);
  }
}

int main() {
  ll n;
  cin >> n;
  vec a(n);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  vec est(1e3+1);
  vec prime;
  for(ll i=2;i<=1e3;i++) {
    if(est[i]==0) {
      prime.push_back(i);
      for(ll j=2;j*i<=1e3;j++) {
        est[j*i]=1;
      }
    }
  }
  ll f=0;
  ll tmp=a[0];
  for(ll i=0;i<n;i++) {
    tmp=gcd(a[i],tmp);
  }
  if(tmp!=1) f=2;
  if(f!=2) {
    for(ll tmp:prime) {
      ll cnt=0;
      for(ll i=0;i<n;i++) {
        if(a[i]%tmp==0) cnt++;
        while(a[i]%tmp==0) a[i]/=tmp;
      }
      if(cnt>1) f=1;
    }
    vector<ll> al(1e6+1);
    for(ll i=0;i<n;i++) {
      if(a[i]==1) continue;
      if(al[a[i]]) f=1;
      al[a[i]]++;
    }
  }
  if(f==0) {
    cout << "pairwise coprime" << endl;
  }
  else if(f==1) {
    cout << "setwise coprime" << endl;
  }
  else {
    cout << "not coprime" << endl;
  }
}


Measured memory_bytes: 18692
#include <stdio.h>
#include <algorithm>

using namespace std;

#define MAXN 100000

int main() {
    int N, C, K;
    int T[MAXN];
    int ans = 0;
    int bus = -1, cnt;
    int i;
    
    scanf("%d %d %d", &N, &C, &K);
    for(i = 0; i < N; i++) scanf("%d", &T[i]);
    
    sort(T, T + N);
    
    for(i = 0; i < N; i++) {
        if(bus >= 0 && cnt < C && T[i] <= bus) cnt++;
        else {
            bus = T[i] + K;
            cnt = 1;
            ans++;
        }
    }
    
    printf("%d", ans);
    
    return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>
#include <string>

using namespace std;

const char zero = '0';
const char *GREATER = "GREATER";
const char *LESS = "LESS";
const char *EQUAL = "EQUAL";

int main()
{
    char A[101];
    char B[101];
    if (scanf("%s%s", A, B) < 2) return 0;

    string strA(100, zero);
    string strB(100, zero);

    int len = strlen(A);
    int j = 0;
    for (int i = 100 - len ; i < 100; i++)
    {
        strA[i] = A[j];
        j++;
    }

    len = strlen(B);
    j = 0;
    for (int i = 100 - len ; i < 100; i++)
    {
        strB[i] = B[j];
        j++;
    }

    printf("%s\n", strA > strB ? GREATER : strA < strB ? LESS : EQUAL);
    return 0;
}


Measured memory_bytes: 256
def main():
    N, M, *A = map(int, open(0).read().split())

    C = [0, 1, 4, 4, 3, 4, 5, 2, 6, 5]

    dp = [0] * N + [-1] * 6
    for i in range(N):
        dp[i + 1] = max(dp[i - C[a]] * 10 + a for a in A)

    print(dp[N])

if __name__ == '__main__':
    main()

Measured memory_bytes: 14388
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int ok=1;
    ll n,k,ans=0;
    cin>>n>>k;
    while(ok&&n!=0){
        ll nn=pow(2,n);
        if(k==2*nn-1){
            ans+=nn;
            ok=0;
        }
        else if(k==1){
            ok=0;
        }
        else if(k==4*nn-3){
            ok=0;
            ans+=2*nn-1;
        }
        else if(k<2*nn-1){
            k-=1;
            n-=1;
        }
        else if(k>2*nn-1){
            k=k-2*nn+1;
            n-=1;
            ans+=nn;
        }
    }
    cout<<ans+(n==0)<<endl;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
h,w,k=map(int,input().split())
q=h-1
a=[list(input())[:-1] if i!=q else list(input()) for i in range(h)]
b=[0 for i in range(h)]
for i in range(h):
    b[i]=a[i].count("#")
res=[[0 for i in range(w)]for i in range(h)]
def ch(i,j):
    global res,b
    if i==0:
        pass
    else:
        if res[i-1][j]==0:
            res[i-1][j]=res[i][j]
            # if res[i][j]==7:
            #     print("def",i,j)
            #     print(res[i][j])
            #     print(b)
            #     print(b[i-1])
            if b[i-2]==0:
                ch(i-1,j)
cnt=1
my=False
my2=False
for i in range(h):
    if b[i]==0:
        continue
    lf=False
    for j in range(w):
        # if cnt==7:
        #     print(i,j)
        #print(i,j,a[i][j])
        if lf:
            if a[i][j]=="#":
                cnt+=1
            #my=True
            res[i][j]=cnt
            if b[i-1]==0:
                ch(i,j)
        else:
            if a[i][j]=="#":
                if my2:
                    cnt+=1
                res[i][j]=cnt
                my2=True
                if b[i-1]==0:
                    ch(i,j)
                lf=True

#for i in range(h):
    #print(*res[i])

#print("-----------")

for i in range(h):
    ch2=True
    for j in range(w):
        if ch2 and res[i][j]!=0:
            break
        ch2=False
        if res[i][j]!=0:
            for k in range(j):
                res[i][k]=res[i][j]
            break

# for i in range(h):
#     print(*res[i])

#print("-----------")

if b[-1]==0:
    cnt=0
    for i in range(1,h+1):
        if b[-1*i]==0:
            cnt=i
        else:
            break
    for i in range(cnt,0,-1):
        pre=-1*i
        for j in range(w):
            res[pre][j]=res[pre-1][j]

for i in range(h):
    print(*res[i])

Measured memory_bytes: 8264
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<P,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

int main(){
    ll N;
    cin >> N;
    vector<ll> t(N+1,0);
    vector<ll> x(N+1,0);
    vector<ll> y(N+1,0);
    for(ll i=1;i<=N;i++)cin>>t[i]>>x[i]>>y[i];
    bool ans=1;
    for(ll i=1;i<=N;i++){
        if(abs(x[i]-x[i-1])+abs(y[i]-y[i-1])<=t[i]-t[i-1]
        &&(abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2==(t[i]-t[i-1])%2)continue;
        ans=0;
    }
    if(ans)print("Yes")
    else print("No")

    return 0;
}

Measured memory_bytes: 2560
#!/usr/bin/env python3

import sys
import math

DEBUG = False

def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep = " "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return

def f(x, a, b):
    return math.floor(a * x / b) - a * math.floor(x / b)

def main():
    a, b, n = read_list(int)
    if n < b:
        print(f(n, a, b))
        return
    print(f(b - 1, a, b))


if __name__ == "__main__":
    main()


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

int main(){
    int a, b;
    cin >> a >> b;

    string ans = "";
    if (a <= b)
    {
        for (int i = 0; i < b; i++)
        {
            ans += to_string(a);
        }
    }else{
        for (int i = 0; i < a; i++)
        {
            ans += to_string(b);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 9223372036854775807
#define MOD 998244353
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll> a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi>b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //-------------------------------
    int x;cin>>x;
    cout<<LCM(x,360)/x<<endl;
    //-------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------








































Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll N;
    cin >> N;
    ll T[N];
    ll A[N];
    for (int i = 0; i < N; ++i) {
        cin >> T[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    bool isDecided[N];
    ll maxHeight[N];
    for (int i = 0; i < N; ++i) {
        isDecided[i] = false;
        maxHeight[i] = -1;
    }
    isDecided[0] = true;
    maxHeight[0] = T[0];
    for (int i = 1; i < N; ++i) {
        if(T[i-1] != T[i]){
            isDecided[i] = true;
        }
        maxHeight[i] = T[i];
    }

    if(isDecided[N - 1]){
        if(maxHeight[N - 1] != A[N - 1]){
            cout << 0 << endl;
            return 0;
        }
    }
    isDecided[N - 1] = true;
    if(maxHeight[N - 1] < A[N - 1]){
        cout << 0 << endl;
        return 0;
    }
    maxHeight[N - 1] = A[N - 1];
    for (int i = 1; i < N; ++i) {
        if(A[N - i] != A[N - i - 1]){
            isDecided[N - i - 1] = true;
            if(maxHeight[N - i -1] < A[N - i - 1]){
                cout << 0 << endl;
                return 0;
            }
            maxHeight[N - i - 1] = A[N - i - 1];
        }else{
            maxHeight[N - i - 1] = min(maxHeight[N - i - 1],A[N - i - 1]);
        }

    }
    ll count = 1;
    ll MOD = 1000000007;
    for (int i = 0; i < N; ++i) {
        if(isDecided[i]){
            continue;
        }
        count = (count * maxHeight[i]) % MOD;
    }
    cout << count << endl;
}


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

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int a,b,h,m;
   double ha,hm,an,x,z;
   cin >> a >> b >> h >> m;
   ha=h*30.0+m/10.0;
   hm=m*6.0;
   an=abs((11*m-60*h)/2.0);
   z=a*a;
   z+=b*b;
   z-=((double)(2*a*b)*cos(an*acos(-1)/180.0));
   x=sqrt(z);
   cout << fixed << setprecision(20) << x << "\n";
}


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define int long long

typedef pair<int, int> ii;

const int mod = 1e9 + 7;

int x, y;

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> x >> y;
    cout << x + y / 2;
}


Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(n-2):
  dp[i+2]=min(dp[i]+abs(h[i+2]-h[i]),dp[i+1]+abs(h[i+2]-h[i+1]))
print(dp[n-1])


Measured memory_bytes: 13928
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll k, ans, mod=1e9+7, fac[2000005], inv[2000005], finv[2000005];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 2000005; i++){
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
main() {
	string s;
	cin >> k >> s;

	COMinit();

	function<ll(ll,ll)> mpow = [&](ll a, ll b) {
		return (b ? (b%2 ? mpow(a,b-1)*a%mod : mpow(a*a%mod,b/2)%mod) : 1);
	};
	
	auto com = [&](ll a, ll b) {
		return fac[a]*finv[b]%mod*finv[a-b]%mod;
	};

	for (int i = 0; i <= k; i++) {
		ll num = (mpow(26,i)*mpow(25,k-i)%mod * (com(s.size()+k-1-i,s.size()-1))%mod)%mod;
		ans = (ans + num) % mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 51220
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#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(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define Endl endl

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); }
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * ceil_(a, b)); }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

int get_num(string &a) {
  int ret = 0;
  for (auto &i : a)
    if (i == '(') ret++;
  return ret;
}

class FBracketSequencing {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i, N) cin >> S[i];
    vector<vector<int>> a(N, vector<int>(3, -INF));
    rep(i, N) {
      a[i][2] = i;
      int L = 0, R = 0;
      rep(j, S[i].size()) {
        if (S[i][j] == '(') {
          L++;
        } else {
          R++;
        }
        a[i][0] = max(a[i][0], R - L);
      }
      a[i][1] = -(L - R);
    }
    vector<vector<int>> first;
    vector<vector<int>> second;
    vector<vector<int>> third;
    rep(i, N) {
      if (a[i][0] <= 0 and -a[i][1] >= 0) {
        first.emplace_back(a[i]);
      } else if (a[i][0] > 0 and -a[i][1] >= 0) {
        second.emplace_back(a[i]);
      } else {
        a[i][0] = -(-a[i][1] + a[i][0]);
        third.emplace_back(a[i]);
      }
    }
    string ans{};
    rep(i, first.size()) ans += S[first[i][2]];
    sort(ALL(second));
    sort(ALL(third));
    rep(i, second.size()) ans += S[second[i][2]];
    rep(i, third.size()) ans += S[third[i][2]];
    int L = 0;
    int R = 0;
    rep(i, ans.size()) {
      if (ans[i] == '(') {
        L++;
      } else {
        R++;
      }
      if (R > L) {
        cout << "No" << endl;
        return;
      }
    }
    if (L == R) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
};


signed main() {
  FBracketSequencing solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 146608
def main():
    n = int(input())
    inlis = list()
    for _ in range(n-1):
        c, s, f= map(int, input().split())
        inlis.append([c, s, f])

    anslis = []

    for j in range(n-1):
        tmp = 0
        for i in range(j,n-1):
            c, s, f= inlis[i][0], inlis[i][1], inlis[i][2]
            if tmp < s:
                tmp = s
            
            amari = tmp % f
            if amari != 0:
                tmp += f - amari

            tmp += c
            #print(j, c, s, f, amari, tmp)
        anslis.append(tmp)
    anslis.append(0)
    
    for k in anslis:
        print(k)
    


if __name__ == "__main__":
    main()


Measured memory_bytes: 74412
#include<cstdio>
using namespace std;
const int maxn=1005;
int n,m,A,B,a[maxn],b[maxn];
char ans[maxn][maxn];
int main(){
	scanf("%d%d%d%d",&n,&m,&A,&B);
	for (int x=0;x<=n;x++){
		int y=x*(A+A-m)-(A*n-B*m);
		if(y%(B+B-n)) continue;
		y/=B+B-n;if(y<0||y>m) continue;
		for (int i=1;i<=x;i++) a[i]=A;
		for (int i=n;i>x;i--) a[i]=m-A;
		for (int i=1;i<=y;i++) b[i]=B;
		for (int i=m;i>y;i--) b[i]=n-B;
		for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
		if(a[i]&&b[j]) ans[i][j]='1',a[i]--,b[j]--;
		else ans[i][j]='0';
		for (int i=1;i<=n;i++) puts(ans[i]+1);
		return 0;
	}
	puts("-1");return 0;
}

Measured memory_bytes: 2176
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
#define testP	 cout << "------------------ test ------------------" << endl;	// 動作確認テスト
#define testX(x) cout << "testout : " << x << endl;	// テストアウト
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// ------------------ ベクター表示 ------------------ //
void printVec(vector<int>& vec) {
	cout << "";
	for (auto it = vec.begin(); it != vec.end(); it++) cout << *it << " ";
	cout << endl;
}

// ------------------ ベクター合計 ------------------ //
int sumVec(vector<int> v) {
	int sum = 0;
	for (size_t i = 0; i < v.size(); i++) sum += v[i];
	return sum;
}

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	double N, D; cin >> N >> D;
	cout << (int)ceil(N / (D * 2 + 1)) << endl;

	return 0;
}


Measured memory_bytes: 3712
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
using namespace std;
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
inline int rd(){
	int res=0,sign=1;char ch;
	while((ch=getchar())<'0'||ch>'9')if(ch=='-')sign=-1;res=res*10+ch-48;
	while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;
	return res*sign;
}
string a; 
int main(){
    cin>>a;
    int s=a.length();
    for(int i=1;i<=s;i++)cout<<"x";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>

int main() {
	long long int n,m,sum=0,add=0;
	std::cin >> n>>m;

	std::map<long long int, long long int> mp;

	for (int i = 0; i < n; i++) {
		int g,p;
		std::cin >> g >> p;

		//mp[g] = p;
		mp[g] = mp[g]+p;
	}

	//std::cout << mp[2] << std::endl;

	for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
		sum += (itr->first)*(itr->second);
		//std::cout << (itr->first)<<" "<<(itr->second) << std::endl;
		//std::cout << sum << std::endl;

		add += (itr->second);

		if (add > m) {
			sum = sum - ((add - m)*(itr->first));
			break;
		}
	}
	 



	std::cout << sum << std::endl;
	return 0;
}

Measured memory_bytes: 6528
N = int(input())
S = [i for i in input()]

flg = 0
idx = 0
for i in S:
    if i == '#':
        flg = 1
        break
    idx += 1

if flg == 1:
    a = S[idx+1:].count('.')
    b = S[idx:].count('#')
    if S[-1] == '#':
        for ct in range(1, N+1):
            if S[-ct] == '.':
                break
        b -= ct-1
    ans = min(a, b)
else:
    ans = 0

count_blk = []
count_wht = []

ct_blk = 0
ct_wht = 0
for i in S:
    if i == '#':
        ct_blk += 1
    else:
        ct_wht += 1
    count_blk.append(ct_blk)
    count_wht.append(ct_wht)

for i in range(N):
    ans = min(ans, count_blk[i] + ct_wht - count_wht[i])

print(ans)


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

int main() {
  int N;
  cin>>N;
  int a=N;
  int ANS=0;
  for(int i=1;i<N;i++){
    a=N-i;
  
  //約数列挙
  int ans = 1;
  for (int i = 2; i <= sqrt(a); i++) {
    int cnt = 0;
    while (a % i == 0) {
      cnt++;
      a /= i;
    }
    ans *= (cnt + 1);
    if (a == 1) break;
  }
  if (a != 1) ans *= 2;
    ANS+=ans;
  }
  cout<<ANS<<endl;
}

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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<int>A(N);
	
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	bool nyukoku = true;

	for (int i = 0; i < N; i++) {
		if (A[i] % 2 == 0) {
			if (A[i] % 3 == 0 || A[i] % 5 == 0) {
				
			}
			else {
				nyukoku = false;
			}
		}
	}
	if (nyukoku == true) {
		cout << "APPROVED" << endl;
	}
	else if(nyukoku == false){
		cout << "DENIED" << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int A[3];
	int order[100001];
	int ans[100001];
	bool flag=1;
	scan(N>>A[0]>>A[1]>>A[2]);
	rep(i,N){
		string s;
		scan(s);
		if(s[0]=='A'&&s[1]=='B') order[i]=0;
		else if(s[0]=='B'&&s[1]=='C') order[i]=1;
		else order[i]=2;
	}
	rep(i,N){
		if(A[order[i]]==0&&A[(order[i]+1)%3]==0){
			flag=0;
			prin("No");
			return 0;
		}
		else if(A[order[i]]==1&&A[(order[i]+1)%3]==1){
			int ijo1=0;
			rep(i,3) ijo1+=(A[i]>=1);
			if(ijo1==3){
				A[order[i]]--;
				A[(order[i]+1)%3]++;
				ans[i]=(order[i]+1)%3;
			}
			else{
				if(i==N-1){
					A[order[i]]--;
					A[(order[i]+1)%3]++;
					ans[i]=(order[i]+1)%3;
				}
				else{
					if((order[i+1]-order[i]+3)%3==1){
						A[order[i]]--;
						A[(order[i]+1)%3]++;
						ans[i]=(order[i]+1)%3;

					}
					else if((order[i+1]-order[i]+3)%3==2){
						A[order[i]]++;
						A[(order[i]+1)%3]--;
						ans[i]=order[i];

					}
					else{
						A[order[i]]--;
						A[(order[i]+1)%3]++;
						ans[i]=(order[i]+1)%3;

					}
				}
			}
		}
		else{
			if(A[order[i]]>=A[(order[i]+1)%3]){
				A[order[i]]--;
				A[(order[i]+1)%3]++;
				ans[i]=(order[i]+1)%3;
			}
			else{
				A[order[i]]++;
				A[(order[i]+1)%3]--;
				ans[i]=order[i];
			}
		}
	}
	prin("Yes");
	rep(i,N){
		printf("%c\n",'A'+ans[i]);
	}
	return 0;
}


Measured memory_bytes: 4508
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
string S;
map<pair<string,string>,int> L,R;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S;
	for(int mask=0;mask<1<<N;mask++) {
		string a,b;
		FOR(i,N) {
			if(mask&(1<<i)) a+=S[i];
			else b+=S[i];
		}
		L[{a,b}]++;
	}
	ll ret=0;
	for(int mask=0;mask<1<<N;mask++) {
		string a,b;
		FOR(i,N) {
			if(mask&(1<<i)) a+=S[2*N-1-i];
			else b+=S[2*N-1-i];
		}
		ret+=L[{a,b}];
	}
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 91904
#include<iostream>
#include<algorithm>
#include<set>

int const MAXG = 80;
int const MAXAB = 80;
int const MAXS = MAXAB*MAXG;
int AB[MAXG][MAXG], H, W, M;

bool dp[MAXG][MAXG][MAXS+1];

void calc(int fh, int fw, int th, int tw) {
  for(int s = 0; s <= (fh+fw+1)*MAXAB; ++s) if(dp[fh][fw][s]) {
    int sum = s + AB[th][tw];
    if(sum <= MAXS) dp[th][tw][sum] = true;
    int diff = s - AB[th][tw];
    diff = std::max(diff, -diff);
    if(diff <= MAXS) dp[th][tw][diff] = true;
  }
}

int main() {
  std::cin >> H >> W;
  for(int h = 0; h < H; ++h) for(int w = 0; w < W; ++w) std::cin >> AB[h][w];
  for(int h = 0; h < H; ++h) for(int w = 0; w < W; ++w) {
    int a = AB[h][w], B; std::cin >> B;
    a -= B;
    AB[h][w] = std::max(a, -a);
  }
  std::fill_n(dp[0][0], MAXG*MAXG*MAXS, false);
  dp[0][0][AB[0][0]] = true;
  for(int w = 1; w < W; ++w) calc(0, w-1, 0, w);
  for(int h = 1; h < H; ++h) {
    calc(h-1, 0, h, 0);
    for(int w = 1; w < W; ++w) {
      calc(h-1, w, h, w);
      calc(h, w-1, h, w);
    }
  }
  int ans = H*W*80;
  for(int i = 0; i < ans; ++i) if(dp[H-1][W-1][i]) ans = i;
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 40320
#include <bits/stdc++.h>
using namespace std;
#define MAX 50

int n, ans = 0, now = 0;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int x; cin >> x;
		if (x >= now) ans ++;
		now = max(now, x);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def calc(x: Int): Int = if (x == 1) (1) else (calc(x / 2) * 2)

  def solve(sc: => Scanner): Unit = {
    val N, M = sc.nextInt
    var A = Set(0)
    var B = Set(N - 1)
    for (i <- 0 until M) {
      val x, y = sc.nextInt - 1
      if (x == 0) {
        A += y
      } else if (x == N - 1) {
        B += y
      } else if (y == 0) {
        A += x
      } else if (y == N - 1) {
        B += x
      }
    }
    if ((A & B).size != 0) (println("POSSIBLE")) else (println("IMPOSSIBLE"))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 127504
import sys
input=sys.stdin.readline
n,a,b=map(int,input().split())
c=a-b
h_list=[int(input()) for i in range(n)]
l=1
r=(max(h_list)+b-1)//b
while r-l>1:
    m=(l+r)//2
    count=0
    for i in h_list:
        if i<=b*m:
            pass
        else:
            count+=((i-b*m)+c-1)//c
    if count<=m:
        r=m
    else:
        l=m
print(r)









Measured memory_bytes: 43996
//~#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//~#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//~#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=998244353;

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

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

void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

template<typename T>
vector<pair<T,int>> getvec(int n){
  vector<pair<T,int>>a(n);
  for(int i=0;i<a.size();i++){
    cin>>a[i].F;
    a[i].S=i;
  }
  return a;
}

void clr(auto &a,int n){
  a.clear();
  a.resize(n);
}

void unq(auto &a){
  sort(all(a));
  a.resize(unique(all(a))-a.begin());
}

const int N=300005;	

void solve(){
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5]){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}	
}


signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //~cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}
 


Measured memory_bytes: 256
/*
  A - Three-letter acronym
  <http://abc059.contest.atcoder.jp/tasks/abc059_a>
*/

#include <stdio.h>

int main(int argc, char const *argv[]) {

  char s1[11], s2[11], s3[11];
  scanf("%s %s %s", s1, s2, s3);
  printf("%c%c%c", s1[0]+'A'-'a', s2[0]+'A'-'a', s3[0]+'A'-'a');

  return 0;
}


Measured memory_bytes: 128
/*
h1, h2, h3, ....., hn-1, hn

1, 2, 3, ......, n-1, n

hi + hj = j - i; j>i

hi + i = j - hj

arr1 = {h1+1, h2+2, h3+3, ....., hn+n}
arr2 = {1-h1, 2-h2, 3-h3, ....., n-hn}

arrf[][0] = {{i, hi+i}, {j, hj+j}, {}}
arrf[][1] = {{i, i-hi}, {j, j-hj}, {}}

*/

#include <bits/stdc++.h>

#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

vector<int> arrf[2][500005];
ll revmp[500005];

int main(){
	int n;
	vector<ll> a;
	map<ll, int> mp;
	cin>>n;
	a.assign(n+1, 0);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int cnt = 0;
	for(int i=0;i<n;i++){
		ll sum = a[i]+i+1;
		ll diff = i+1-a[i];
		if(mp.count(sum) == 0){
			revmp[cnt] = sum;
			mp[sum] = cnt++;
		}
		arrf[0][mp[sum]].pb(i+1);
		if(diff >= 0){
			if(mp.count(diff) == 0){
				revmp[cnt] = diff;
				mp[diff] = cnt++;
			}
			arrf[1][mp[diff]].pb(i+1);
		}
	}
	for(int i=0;i<cnt;i++){
		sort(arrf[0][i].begin(), arrf[0][i].end());
		sort(arrf[1][i].begin(), arrf[1][i].end());
	}
	/*for(int i=0;i<cnt;i++){
		cout<<i<<" "<<revmp[i]<<":\n"<<"==sum==\n";
		for(int j=0;j<arrf[0][i].size();j++){
			cout<<arrf[0][i][j]<<" ";
		}
		cout<<"\n==diff==\n";
		for(int j=0;j<arrf[1][i].size();j++){
			cout<<arrf[1][i][j]<<" ";
		}
		cout<<"\n";
	}*/
	ull ans = 0;
	for(int i=0;i<cnt;i++){
		for(int j=0;j<arrf[0][i].size();j++){
			int idx = upper_bound(arrf[1][i].begin(), arrf[1][i].end(), arrf[0][i][j])-arrf[1][i].begin();
			ull tmp = arrf[1][i].size()-idx;
			ans += tmp;
		}	
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 50984
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<cmath>
#include<cstdio>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;


const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i ;
	}

}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	if (k == 0) return 1;
	return n * COM(n - 1, k - 1) / k;
}



int main() {
	COMinit();
	ll i, j, k, l, m, n, sum, flag, cc,N,M,X,A,B;
	sum = 0;
	flag = 0;
	cin >> N >> M;
	vector<ll>x(M);
	vector<ll>y(M);
	vector<ll>kosu(N+1);
	kosu[1] = 1000000;
	ll ans = 1;
	ll inf = 1000000;
	REP(i, 2, N + 1) {
		kosu[i] = 1;
	}
	
	REP(i, 0, M) {
		cin >> x[i] >> y[i];
	}
	REP(i, 0, M) {
		if (kosu[x[i]] > inf) {
			kosu[x[i]]--;
			if (kosu[y[i]] >= inf) {
				kosu[y[i]]++;
			}
			else {
				kosu[y[i]] += inf;
				ans++;
			}
			
		}
		else if (kosu[x[i]] == inf) {
			kosu[x[i]] =0;
			ans--;
			if (kosu[y[i]] >= inf) {
				kosu[y[i]]++;
			}
			else {
				kosu[y[i]] += inf;
				ans++;
			}

		}
		else {
			kosu[x[i]]--;
			kosu[y[i]]++;
		}
	}
	output(ans);
	return 0;
}

Measured memory_bytes: 10496
#include <stdio.h>

int main(void)
{
 int a, b;
 int S, L;

 scanf("%d%d", &a, &b);

 S = a * b;
 L = a * 2 + b * 2;

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

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

int main() {
	int N; cin >> N; int A;
	int count = 1; int ans = 1;
	for (int i = 0; i < N; i++) {
		cin >> A;
		if (A == 1) { count++; }
		else { count = 1; }
		if (count > ans) { ans = count; }
	}
	cout << ans << endl;
	return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

vector<long long>pf;
void PrimeFactor(long long n){
    pf.push_back(1);
    for(long long i=2; i<=sqrt(n); i++){
        ll j=i;
        while(n % j == 0) {
            pf.push_back(j);
            n /= j;
            j*=i;
        }
        while(n%i==0)n/=i;
        if(n==1)break;
    }
    if(n!=1)pf.push_back(n);
}

int main(){
    ll n;
    cin>>n;
    PrimeFactor(n);
    /*rep(i,0,pf.size()){
        cout<<pf.at(i)<<endl;
    }*/
    set<int> s;
    rep(i,0,pf.size()){
        s.insert(pf.at(i));
    }
    cout<<s.size()-1<<endl;

return 0;
}

Measured memory_bytes: 3764
import java.util.*;

public class Main {
    static int n;
    static int [][] all;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        all = new int[n][n];
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            Arrays.fill(all[i], -1);
            for (int j = 0; j < a; j++) {
                all[i][sc.nextInt() - 1] = sc.nextInt();
            }
        }
        int[] arr = new int[n];
        Arrays.fill(arr, -1);
        System.out.println(search(0, arr));
    }
    
    static int search(int idx, int[] arr) {
        if (idx >= n) {
            return 0;
        }
        int ans = Integer.MIN_VALUE;
        if (arr[idx] != 1) {
            int[] next = (int[])(arr.clone());
            next[idx] = 0;
            ans = search(idx + 1, next);
        }
        if (arr[idx] != 0) {
            int[] next = (int[])(arr.clone());
            next[idx] = 1;
            boolean flag = true;
            for (int i = 0; i < n; i++) {
                int x = all[idx][i];
                if (x != -1) {
                    if (next[i] != -1 && next[i] != x) {
                        flag = false;
                        break;
                    }
                    next[i] = x;
                }
            }
            if (flag) {
                ans = Math.max(ans, search(idx + 1, next) + 1);
            }
        }
        return ans;
        
    }
}


Measured memory_bytes: 27176
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
#define mp make_pair
#define fi first
#define se second
#define All(x) (x).begin(),(x).end()
const ll mod=1e9+7;
ll last[100001];
inline ll fpow(ll a,ll x){
	if(a==0) return 0;
	register ll _ans=1;
	for(register ll i=x;i>0;(i>>=1),(a*=a)){
		if(a>mod) a%=mod;
		if(i&1)_ans*=a,_ans%=mod;
	}
	return _ans;
}
int main(){
	//ios::sync_with_stdio(0);
	ll n,k,ans=0;
	cin>>n>>k;
	for(register ll p=k,*lptr=&last[k];p>=1;--p,--lptr){
		ll fo=k/p; 
		register ll res=fpow(fo,n);
		for(register ll j=fo*p;j>p;j-=p){
			if(res<last[j])res+=mod;
			res-=last[j];
		}
		*lptr=res;
	}
	for(register ll p=k,*lptr=&last[k];p>=1;--p,--lptr){
		ans=(ans+(*lptr)*p)%mod;
	}
	cout<<ans;
}


Measured memory_bytes: 4364
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll N;
    cin >> N;
    ll sum=0;
    rep(i,N){
        sum+=i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

int const inf = 1<<30;
int dp[1000005][2];

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

    string s; cin >> s;
    reverse(s.begin(), s.end());
    s += '0';
    int n = s.size();
    rep(i, n+1) rep(j, 2) dp[i][j] = inf;
    dp[0][0] = 0;

    rep(i, n) rep(j, 2) {
        int x = s[i]-'0';
        x += j;
        rep(a, 10) {
            if(a < x) chmin(dp[i+1][1], dp[i][j] + a + 10+a-x);
            else chmin(dp[i+1][0], dp[i][j] + a + a - x);
        }
    }

    cout << dp[n][0] << endl;

    
    return 0;
}

Measured memory_bytes: 9116
#include<bits/stdc++.h>
#define N 100005
using namespace std;

typedef long long ll;

string itos(int x){
  string res;
  while(x)res+=x%10+'0',x/=10;
  reverse(res.begin(),res.end());
  return res;
}

ll dp[N][11];

int main(){

  while(1){
    
    ll a,b,p;

    cin>>a>>b>>p;

    if(!a&&!b&&!p) break;
    
    vector<string> v;
  
    for(int i=a;i<=b;i++) v.push_back(itos(i));
  
    ll n=b-a+1;
  
    sort(v.begin(),v.end());
  
    v.push_back("");
  
    memset(dp,0,sizeof(dp));
  
    for(int i=0;i<n;i++) dp[i][v[i].size()]=1;
  
    for(int i=0;i<n;i++){
    
      ll A=0;
      for(int j=0;j<v[i].size();j++) A=(A+dp[i][j])%p;
      dp[i][v[i].size()]=(dp[i][v[i].size()]+A)%p;
    
      for(int j=0;j<11;j++){
      
	if(v[i+1].size()==j) dp[i+1][j]=(dp[i+1][j]+(dp[i][j]*2)%p)%p;
	else dp[i+1][j]=(dp[i+1][j]+dp[i][j])%p;
      
      }
    
    }
  
    ll ans=0;
  
    for(int i=0;i<11;i++) ans=(ans+dp[n][i])%p;
  
    cout<<ans<<endl;
  } 
  return 0;
}

Measured memory_bytes: 17076