akhauriyash/Code-Regression huggingface dataset:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
A = sorted(A,reverse = True)
total = sum(A)
cnt = 1
for i in range(n):
    total -= A[i]
    if 2 * total >= A[i]:
        cnt += 1
    else:
        break
print(cnt)


Measured memory_bytes: 16788
#pragma region include
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 4e18;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

int main() {
    int N; input(N);
    vector<int> p(N); input(p);
    int cnt = 0;
    REP(i,N) {
        if (p[i] != i + 1) {
            cnt++;
        }
    }
    if (cnt == 2 || cnt == 0) {
        puts("YES");
    }
    else {
        puts("NO");
    }
    getchar(); getchar();
}

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

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector < long long > a(n), dp(n, 1e17);
	for ( int i = 0; i < n; i++ ) {
		cin >> a[i];
	}
	dp[0] = 0;
	for ( int i = 1; i < n; i++ ) {
		for ( int j = 1; j <= k; j++ ) {
			if ( j <= i ) {
				dp[i] = min( dp[i], dp[i - j] + abs( a[i] - a[i - j] ) );
			}
		}
	}
	cout << dp[n - 1];  
}

Measured memory_bytes: 1792
#include <bits/stdc++.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++)
typedef long long ll;

int main() {
    int N;
    cin >> N;
    int ans = 0;
    int tmp;
    for (int i = 0; i < N; i++){
        cin >> tmp;
        ans += tmp - 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int x,y;
int group[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};


int main(){
    cin>>x>>y;
    cout<<(group[x]==group[y]?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int finding = 1;
	for (int i = 0; i < n; ++i) {
		if (a[i] == finding) {
			++finding;
		}
	}
	int cnt = finding - 1;
	cout << (n - cnt == n ? -1 : n - cnt) << '\n';
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  ll n,k;cin >>n>>k;
  vector<ll> h(n);
  for(int i=0;i<n;++i)cin >> h[i];
  sort(all(h),greater<ll>());
  ll out = 0;
  for(int j=k;j<n;++j) out += h[j];
  cout << out << endl;
  return 0;
}


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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000000
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
  int n;
  cin >> n;
  int a[n];
  REP(i, n) cin >> a[i];
  REP(i, n) a[i] -= (i+1);
  sort(a, a+n);
  ll ans = 0;
  REP(i, n) ans += abs(a[i] - a[n/2]);
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

string s;
ll ans = 0;
int main() {
	cin >> s;
	REP(i, (s.size() + 1) / 2) {
		if (s[i] != s[s.size() - 1 - i])ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int x,a,b; cin >> x >> a >> b;
  cout << (abs(x-a) < abs(x-b) ? 'A' : 'B') << endl;
  return 0;
}


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

int paint(int A[6][6], int B[6][6], int nr, int nc) {
    int blackToRed{0};

    for (int i=0; i<nr; ++i) {
        for (int j=0; j<nc; ++j) {
            if (A[i][j] && B[i][j]) {
                ++blackToRed;
            }
        }
    }
    return blackToRed;
}

int main() {
    int numRows, numCols, blackLeft;
    cin >> numRows >> numCols >> blackLeft;

    int squares[6][6];
    int totalBlack{0};

    string squareInput;
    char black = '#';

    for (int i=0; i<numRows; ++i) {
        cin >> squareInput;
        for (int j=0; j<numCols; ++j) {
            if (squareInput[j] == black) {
                squares[i][j] = 1;
                ++totalBlack;
            }
            else squares[i][j] = 0;
        }
    }

    int numWaysToPaint{0};

    for (int r=0; r<1<<numRows; ++r) {
        int toPaintTemp[6][6];
        // initialize 
        for (int i=0; i<numRows; ++i) {
            for (int j=0; j<numCols; ++j) {
                toPaintTemp[i][j] = 0;
            }
        }

        // paint Row(s)
        for (int rshift=0; rshift<numRows; ++rshift) {
            if (r>>rshift&1) {
                for (int t=0; t<numCols; ++t) toPaintTemp[rshift][t] = 1;
            }
        }
        for (int c=0; c<1<<numCols; ++c) {
            // copy toPaintTemp
            int toPaint[6][6];
            for (int i=0; i<numRows; ++i) {
                for (int j=0; j<numCols; ++j) {
                    toPaint[i][j] = toPaintTemp[i][j];
                }
            }
            
            // Paint Col(s)
            for (int cshift=0; cshift<numCols; ++cshift) {
                if (c>>cshift&1) {
                   for (int t=0; t<numRows; ++t) toPaint[t][cshift] = 1;
                }
            }

            // count numbers of black being painted red
            int paintedRed = paint(squares, toPaint, numRows, numCols);
            if ((totalBlack - paintedRed) == blackLeft) ++numWaysToPaint;
        }
    } 
   
    cout << numWaysToPaint << endl;

    return 0;
}

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

    using namespace std;
    template <typename T>
    void debug(string t, T input) {
        cout<<t<<"-> "<<input<<"\n";
    }
    template <typename T>
    void debug(int i,string t, T input) {
        cout<<"Case#"<<i<<" "<<t<<"-> "<<input<<"\n";
    }

    int main(){
        long long a[4000];
        a[0]=100;
        long long k;
        cin>>k;
        for(int i=1;i<=4000;i++){
            a[i]=a[i-1]+(0.01*a[i-1]);
            if(a[i]>=k){
                cout<<i;
                return 0;
            }
        }
        return 0;
    }


Measured memory_bytes: 3544
#include <stdio.h>
#include <string.h>
#define N 1000

void cm(char a[] , char b[]);
int max(int a , int b);
int c[N+1][N+1];

int main()
{
	char a[N];
	char b[N];
	int i , n;
	scanf("%d",&n);
	for(i = 1; i <= n; i++)
	{
		scanf("%s%s",a+1,b+1);
		a[0]=b[0]= ' ';
		cm(a,b);
	}
}

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

void cm(char  a[]  , char b[])
{
	int i , j;
	int m1,m2;
	m1 = strlen(a)-1;
	m2 = strlen(b)-1;
	int ma = 0;
	for(i=0;i<m1;i++)
	{
		c[0][i]=0;
	}
	for(j=0;j<m2;j++)
	{
		c[0][j]=0;
	}
	for(int i = 1; i <=m1; i++)
	{
		for(int j = 1; j<=m2; j++)
		{
			if(a[i]==b[j])
			{
				c[i][j]=c[i-1][j-1]+1;
			}
			else{
				c[i][j]=max(c[i-1][j],c[i][j-1]);
			}
			ma = max(ma,c[i][j]);
				
		}
	}
	printf("%d\n",ma);
}


Measured memory_bytes: 5712
package main

import "fmt"

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

	cnt := 0
	for x := 0; x <= k; x++ {
		for y := 0; y <= k; y++ {
			r := s - x - y
			if r >= 0 && r <= k {
				cnt++
			}
		}
	}

	fmt.Println(cnt)
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

ll a,b,k;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>a>>b>>k;

    ll ans1 = max(0LL,a-k);
    k = max(0LL,k-a);
    ll ans2 = max(0LL,b-k);
    cout << ans1 << " " << ans2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << - 1 << endl;}
void unhap() {cout << ":(" << endl;}

//幅優先探索(グリッド)
//{i, j}:始点
//visit:1:訪問済み
//task:訪問予定
//pushしたマスは訪問済みにすること
ll bfs(ll h, ll w, vector<string> &grid, vector<vector<int>> &dark) {
  vector<vector<ll>> visit(h, vector<ll>(w, 0));
  queue<vector<ll>> task;
  for (int i = 0; i < dark.size(); i++) {
    task.push({dark.at(i).at(0), dark.at(i).at(1)});
    visit.at(dark.at(i).at(0)).at(dark.at(i).at(1)) = 1;
  }
  ll depth = 0;
  while (task.size() > 0) {
    ll sz = task.size();
    for (ll i = 0; i < sz; i++) {
      ll y = task.front().at(0), x = task.front().at(1);
      if (y + 1 < h && grid.at(y + 1).at(x) == '.' && visit.at(y + 1).at(x) == 0) {
        task.push({y + 1, x});
        visit.at(y + 1).at(x) = 1;
      }
      if (y - 1 >= 0 && grid.at(y - 1).at(x) == '.' && visit.at(y - 1).at(x) == 0) {
        task.push({y - 1, x});
        visit.at(y - 1).at(x) = 1;
      }
      if (x + 1 < w && grid.at(y).at(x + 1) == '.' && visit.at(y).at(x + 1) == 0) {
        task.push({y, x + 1});
        visit.at(y).at(x + 1) = 1;
      }
      if (x - 1 >= 0 && grid.at(y).at(x - 1) == '.' && visit.at(y).at(x - 1) == 0) {
        task.push({y, x - 1});
        visit.at(y).at(x - 1) = 1;
      }
      task.pop();
    }
    depth++;
  }
  return depth - 1;
}

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  for (int i = 0; i < h; i++) cin >> grid.at(i);
  vector<vector<int>> dark(0);
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      if (grid.at(i).at(j) == '#') dark.push_back({i, j});
  cout << bfs(h, w, grid, dark) << endl;
}

Measured memory_bytes: 119332
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    ll n;
    cin >> n;
    map<string, ll> mp;
    REP(i,n){
        string s;
        cin >> s;
        sort(ALL(s));
        mp[s]++;
    }
    ll ans = 0;
    for (auto tmp : mp){
        ll x = tmp.second;
        ans += x * (x - 1) / 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11136
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE BangPatterns      #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    [n,a,b] <- map read.words <$> getLine :: IO [Int]
    xs <- U.unfoldrN n (B.readInt.B.dropWhile isSpace) <$> B.getLine
    print $ solve a b xs

solve :: Int -> Int -> U.Vector Int -> Int
solve a b xs = go 0 $ U.toList xs
  where
    go !res (x:y:xs) = go (res + min ((y-x)*a) b) (y:xs)
    go res _ = res

Measured memory_bytes: 3068
#include<iostream>
using namespace std;
string s;
int main(){
cin>>s;
for(int i=0;i<s.size();i++)
if(s[i]=='C') for(int j=i+1;j<s.size();j++)
if(s[j]=='F'){
cout<<"Yes";
return 0;}
cout<<"No";}

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

long long maxA, maxB, maxC;

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

    for (int i = 1; i <= n; ++i) {
        long long prevA = maxA, prevB = maxB, prevC = maxC;
        long long tempA, tempB, tempC;
        cin >> tempA >> tempB >> tempC;

        maxA = max(prevB, prevC) + tempA;
        maxB = max(prevA, prevC) + tempB;
        maxC = max(prevA, prevB) + tempC;
    }

    cout << max(maxA, max(maxB, maxC));
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
int main(){
    int S, h, m, s;
    std::cin >> S;
    h = S / 3600 % 24;
    m = S / 60 % 60;
    s = S % 60;
    std::cout << h << ":" << m << ":" << s << std::endl;
    return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(){
    string s, t;
    cin >> s >> t;
    vector<int> sC(26, 0), tC(26, 0);
    rep(i, s.size()){
        sC[s[i]-'a']++;
        tC[t[i]-'a']++;
    }
    sort(all(sC));
    sort(all(tC));
    rep(i, 26){
        if (sC[i]!= tC[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3900
main(n,x,y){
	scanf("%d%*d",&n);
	for(;~scanf("%d%d",&x,&y);){
		if(x>n/2)
			x=n+1-x;
		if(y>n/2)
			y=n+1-y;
		x=x<y?x:y;
		x+=2;
		printf("%d\n",x%3+1);
	}
}

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

int main(){
  int n,k;
  string s;
  cin>>n>>s>>k;
  char c;
  c=s.at(k-1);
  for(int i=0;i<n;i++){
    if(s.at(i)!=c)
      s.at(i)='*';
  }
  cout<<s<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1LL<<59

int main(){
    ll i,j;
    string s;
    cin>>s;
    ll n=s.size();
    string now="aaa";
    ll ans=0;
    while(i<n){
        if(now.size()==1&&now[0]==s[i]){
            i+=2;
            now="aaa";
            ans++;
        }
        else {
            now=s[i];
            i+=1;
            ans++;
        }
        if(i>n) ans--;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    string s,t;
    cin >> s >> t;
    ll res = 0;
    rep(i,s.length())if(s[i] != t[i])res++;
    cout <<res << endl;
    return 0;
}

Measured memory_bytes: 3852
#include <iostream>
#include <sstream>
#include <string>
#include <cstdlib>
using namespace std;

int main() {
  int ans=0;
  stringstream ss;
  char x;
  while(cin.get(x)) {
    if((x >= '0') && (x <= '9')) {
      ss << x;
    }
    else {
      ans += atoi(ss.str().c_str());
      ss.str("");
      ss.clear(stringstream::goodbit);
    }
  }
  cout << ans << endl;
}

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

#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long int lli;

int main()
{
    fio;
    int n;
    cin>>n;
    double p[n];
    for(int i=1;i<=n;i++) cin>>p[i];
        // cout<<endl;
    double dp[n+1][n+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++) dp[i][j] = 0;
    }
    dp[0][0] = 1;
    for(int i=1;i<=n;i++) dp[i][0] = dp[i-1][0] * (1 - p[i]);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(j > i) continue;
            if(j == i)
            {
                // cout<<"i "<<i<<" j "<<j<<endl;
                dp[i][j] = dp[i-1][j-1] * p[i];
            }
            if(j < i)
            {
                dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]);
            }
        }
    }
    // for(int i=0;i<=n;i++)
    // {
    //     for(int j=0;j<=n;j++) cout<<"i "<<i<<" j "<<j<<" dp[i][j] "<<dp[i][j]<<endl;
    // }
    double ans = 0;
    for(int i = n - n/2; i<=n;i++) ans += dp[n][i];
    cout<<fixed<<setprecision(10)<<ans<<endl;
    cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s" << "\n";
    return 0;
}

Measured memory_bytes: 70656
// Gaurav Aggarwal
 
/*
useful stl
array<ll,size> ar;         //size(),front(),back(),fill(),empty()
deque<ll> d                //push_back(),push_front(),pop_front(),pop_back()
vector<ll> v(size,val);    //push_back(),*max_element(v.begin(),v.end()),accumulate(v.begin(),v.end(),0)
stack<ll> g;               //push(),pop(),top(),size(),empty()         LIFO
queue<ll> q;               //push(),size(),front(),back(),empty()      FIFO
priority_queue<ll> pq
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> ipair;
typedef pair<long,long> lpair;
typedef pair<double,double> pdd;
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884 
#define debug1(a) cout<<a<<"\n";
#define debug2(a,b) cout<<a<<" "<<b<<"\n";
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define debug_arr(a,n) {for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}}
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define beg_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {a[i] = 0;}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

// void dfs(int s, int a) {
//     a[s] = 1;
//     for(int b: graph[s]) {
//         if(!a[s])
//             dfs(b,a);
//     }
// }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  
 
    // int n,a,b,c,d;
    // if(c >= d) {
    //     for(int i=c-1;)
    // }
    string s;
    cin>>s;
    int n = s.size();
    ll ans = 0;

    int count = 0;
    for(int i=0;i<n-1;++i) {
        // cout<<i<<" "<<count<<"\n";
        if(s[i] == 'A')
            ++count;
        else {
            if(s[i] == 'B') {
                if(s[i+1] == 'C') {
                    ans += count;
                    ++i;
                }
                else {
                    count = 0;
                }
            }
            else {
                count = 0;
            }
        }
    }
    cout<<ans<<"\n";
    return 0;
}

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

int main() {

	string s; cin >> s;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		string t = s.substr(i);
		for (int j = 0; j < t.size(); j++) {
			string u = t.substr(0, j + 1);
			int tmp = u.size();
			bool acgt = true;
			for (int k = 0; k < u.size(); k++) {
				if (u[k] == 'A' || u[k] == 'C' || u[k] == 'G' || u[k] == 'T') {}
				else {
					acgt = false;
				}
			}			
			if (acgt) ans = max(ans, tmp);
		}		
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);
#define debug(x) cerr << #x << " = " << x << "\n" ;

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int n ;
int cnt = 0 ;

int main(){
 cin >> n ;
 forn( int , i , 1 , n + 1 ){
    int c = i ;
    int cn = 0 ;
    while( c ){
        c /= 10 ;
        cn++ ;
    }
    if( cn % 2 ) cnt++ ;
 }

 cout << cnt ;


 return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define p pair<vector<int>,int>
#define PP pair<P,P>
using namespace std;
vector<int> bom;
vector<int> con;
int n,a,b,c,ans;

void solve(int now, P f, P s, P t){
    if(now==n){
        if(f.second==0 || s.second==0 || t.second==0) return;
        int mp=abs(f.first-a)+abs(s.first-b)+abs(t.first-c)+10*(f.second-1+s.second-1+t.second-1);
        ans=min(ans,mp);
        return;
    }
    solve(now+1,f,s,t);
    solve(now+1,P(f.first+bom[now],f.second+1),s,t);
    solve(now+1,f,P(s.first+bom[now],s.second+1),t);
    solve(now+1,f,s,P(t.first+bom[now],t.second+1));
}

int main(){
    cin >> n >> a >> b >> c;
    rep(i,n){
        int l; cin >> l;
        bom.push_back(l);
    }

    ans=INF;
    solve(0,P(0,0),P(0,0),P(0,0));
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
int math(int a,int b);
int main(void){
    int A=0;
    int B=0;
    int ans=0;
    scanf("%d %d",&A,&B);
    ans=math(A,B);
    printf("%d",ans);
    return 0;
}

int math(int a,int b){
    int ANS=0;
    if(b%a==0){
        ANS=a+b;
    }else{
        ANS=b-a;
    }
    return ANS;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        while(true){
            int cardCount = sc.nextInt();
            int cutCount = sc.nextInt();
            if (cardCount == 0 && cutCount == 0) {
                break;
            }

            char[] cards = new char[cardCount];
            for (int i = 0; i < cards.length; i++) {
                cards[i] = (char) (cards.length - i);
            }
            String cardsString = new String(cards);

            int indexStart, cutCardCount, indexEnd;
            String firstCards, midCards, lastCards;
            for (int i = 0; i < cutCount; i++) {
                indexStart = sc.nextInt() - 1;
                cutCardCount = sc.nextInt();
                
                indexEnd = indexStart + cutCardCount;

                firstCards = cardsString.substring(0, indexStart);
                midCards = cardsString.substring(indexStart, indexEnd);
                lastCards = cardsString.substring(indexEnd);

                cardsString = midCards + firstCards + lastCards;
            }

           System.out.println((int)cardsString.charAt(0));

        }
        
        sc.close();
    }
}


Measured memory_bytes: 37524
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define pii pair<int,int>
using namespace std;
const ll mod = 1e9 + 7;
const int maxn = 200100;
ll n, k;

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

ll dp[maxn];

int main() {
	cin>>n>>k;

    ll result = 0LL;
    for(int i=k;i>=1;i--) {
        dp[i] = power(k/i, n);

        for(int j=2*i;j<=k;j+=i) {
            dp[i] = dp[i] + mod - dp[j];
            if(dp[i] > mod) dp[i] -= mod;
        }
        result += (1LL * i * dp[i]) % mod;
        result %= mod;

    }
    cout<<result;
}

Measured memory_bytes: 4380
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,A,B=get_i
val=N/(A+B)
r=N% (A+B)
r=min(r,A)
puts val*A+r

Measured memory_bytes: 3836
#include <iostream>
    #include <algorithm>
    #include <vector>
    #include <map>
    #include <set>
    #include <string>
    #include <cmath>
    #include <iomanip>
    #include <queue>
    #include <unordered_map>
    #include <unordered_set>
    #include <bitset>
    #include <cassert>
    #include <cstring>
    #include <climits>
     
    using namespace std;
     
    #define FOR(i, a, b) for (int i = (a); i < (b); i++)
    #define rep(i, n) FOR(i, 0, n)
    #define SORT(c) sort((c).begin(), (c).end())
    #define mp make_pair
    #define fi first
    #define se second
    #define pb push_back
     
    typedef long long ll;
    typedef pair<int, int> P;
    typedef vector<int> V;
    typedef map<int, int> M;
     
    constexpr ll INF = 1e18;
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = 3.14159265358979323846;
    constexpr int di[] = {0, 0, 1, -1};
    constexpr int dj[] = {1, -1, 0, 0};
     
    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        ll k, a, b;
        cin >> k >> a >> b;
        if(b-a<=2||k<a+1){
            cout << k + 1 << endl;
        }
        else{
            ll sum = 1;
            for (int i = 0; i < k;i++){
                if(sum>=a&&i<k-1){
                    sum -= a;
                    sum += b;
                    i++;
                }
                else
                    sum++;
            }
            cout << sum << endl;
        }
        return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int B=1<<9,M=100000,N=1<<18|2;
int w[N],v[N],dp[B+2][M+2],q[20],V[N],W[N];
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int n=read();
	For(i,1,n){
		w[i]=read(); v[i]=read();
		if(i<B){
			memcpy(dp[i],dp[i/2],sizeof(dp[i]));
			Rep(j,M,v[i])dp[i][j]=max(dp[i][j-v[i]]+w[i],dp[i][j]);
		}
	}
	int Q=read();
	while(Q--){
		int t=read(),vv=read(),tot=0,ans=0;
		for(;t>=B;t/=2){
			q[tot++]=t;
		}
		For(i,0,(1<<tot)-1){
			For(j,0,tot-1)if(i>>j&1){
				V[i]=V[i^(1<<j)]+v[q[j]];
				W[i]=W[i^(1<<j)]+w[q[j]];
			}
			if(V[i]<=vv)ans=max(ans,dp[t][vv-V[i]]+W[i]);
		}
		writeln(ans);
	}
}


Measured memory_bytes: 205332
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

int main()
{
    int x,y,z,K;
    cin >> x >> y >> z >> K;
    vector<long int> a(x), b(y), c(z);
    for(int i=0; i<x; i++){
        cin >> a[i];
    }
    for(int i=0; i<y; i++){
        cin >> b[i];
    }
    for(int i=0; i<z; i++){
        cin >> c[i];
    }
    sort(a.begin(), a.end(), greater<long int>());
    sort(b.begin(), b.end(), greater<long int>());
    sort(c.begin(), c.end(), greater<long int>());

    vector<long int> ab(x*y);
    for(int i=0; i<x; i++){
        for(int j=0; j<y; j++){
            ab[j+i*y]=a[i]+b[j];
        }
    }
    sort(ab.begin(), ab.end(), greater<long int>());
    vector<long int> abc(K*z);
    for(int i=0; i<min(K, x*y); i++){
        for(int j=0; j<z; j++){
            abc[j+i*z]=ab[i]+c[j];
        }
    }
    sort(abc.begin(), abc.end(), greater<long int>());
    for(int i=0; i<K; i++){
        cout << abc[i] << endl;
    }
    
    

    return 0;
}

Measured memory_bytes: 31616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		for(int i=0; i<n; i++){

			String a = br.readLine();
			String b = br.readLine();

			BigInteger bg =new BigInteger(a).add(new BigInteger(b));
			if(String.valueOf(bg).length() >80){
				System.out.println("overflow");
			}else {
				System.out.println(bg);
			}

		}
	}



}

Measured memory_bytes: 24560
import heapq
#import itertools
import math
import numpy as np
#import sys

#N = int(input())
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A = list(np.array(A) * -1)

heapq.heapify(A)
#print(HA)
for i in range(M) :
    v = heapq.heappop(A)
    v = math.floor(-1 * v / 2) * -1
    heapq.heappush(A, v)

print(sum(A) * -1)



Measured memory_bytes: 23120
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<ll(n); i++)

int main(){

    static const double pi = 3.141592653589763;

    double rh, rm, h, m;
    double angh, angm;
    double anghm;
    double distance;

    cin >> rh >> rm >> h >> m;

    angh  = ((h * 60.0 + m) * 1.0) / 2.0;
    angm  = m * 6.0;
    anghm = abs(angh - angm);
    if(anghm >= 180.0){anghm = 360.0 - anghm;}
    anghm = anghm / 180.0 * pi;


    distance = sqrt(rh*rh*1.0 + rm*rm*1.0 - 2.0*rh*1.0*rm*1.0*cos(anghm));

    printf("%.20f\n", distance);

    return 0;
}


Measured memory_bytes: 3472
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  string S;
  cin>>S;
  bitset<26> A;
  string ans="yes";
  rep(i,0,S.size()){
    int X=S[i]-'a';
    if(A.test(X)){
      ans="no";
      break;
    }
    A.set(X);
    }
  cout<<ans;
  }


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int h, w, i, j;
  cin >> h >> w;
  char s[h+2][w+2];
  for(i=1; i<h+1; i++)
    for(j=1; j<w+1; j++)
      cin >> s[i][j];
  for(i=1; i<h+1; i++)
    for(j=1; j<w+1; j++)
      if(s[i][j]=='#'&&s[i+1][j]!='#'&&s[i-1][j]!='#'&&s[i][j-1]!='#'&&s[i][j+1]!='#'){
        cout <<"No";
        return 0;
      }
  cout << "Yes";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long N;
    cin >> N;

    vector<string> S;
    string temp;
    for (int i =0; i<N ; i++) {
        cin >> temp;
        S.push_back(temp);
    }
 
    sort(S.begin(), S.end());
    S.erase(unique(S.begin(), S.end()), S.end());

    cout << S.size() << endl;
 
    return 0;
}


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

bool is_kai(const string str){
    string str2 = str;
    reverse(str2.begin(), str2.end());
    if( str == str2 ){
        return true;
    }else{
        return false;
    }
}


// ------------------------

void solve() {
    string S; cin >> S;
    int N = S.size();
    if( is_kai(S) ){
        string S2 = S.substr(0, (N-1)/2 );
        if( is_kai(S2) ){
            string S3 = S.substr(((N+3)/2)-1);
            if( is_kai(S3) ){
                cout << "Yes" << endl;
                return;
            }
        }
    }
    cout << "No" << "\n";
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b, c; cin >> a >> b >> c;
    int disA, disB;
    disA = b - a > 0 ? b - a : a - b;
    disB = c - a > 0 ? c - a : a - c;
    cout << (disA > disB ? "B" : "A") << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int num1, num2;
    cin>>num1>>num2;
    if ( num1>num2 && num1!=1 && num2!=1){
        cout<<"Alice";
    }
    else if (num2 >num1 && num1!=1 && num2!=1 ){
        cout<<"Bob";
    }
    else if (num1==1 && num2!=1){
        cout<<"Alice";
    }
    else if (num2==1 && num1!=1){
        cout<<"Bob";
    }
    else{
        cout<<"Draw";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;

int main()
{
ll n;
string s;
cin >> n>>s;
ll a=0,b=0;
rep(i,n){
    if(s[i]=='('){a++;}
    else{a--;if(a<0)a=0;}
}
rep(i,n){
    if(s[n-1-i]==')'){b++;}
    else{b--;if(b<0)b=0;}
}
rep(i,a){
    s=s+')';
}
rep(i,b){
    s='('+s;
}

cout << s << endl;
return 0;
}

Measured memory_bytes: 256
import copy
n = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


soinsuu = factorization(n)

ans = 0
kouho = []
for aa in soinsuu:
    for i in range(aa[1]):
        kouho.append(aa[0]**(i+1))

dame = [1]
while True:
    flag = False
    kouho.sort()
    for i in range(len(kouho)):
        if kouho[i] in dame:
            continue
        else:
            flag = True
            waruyatu = copy.deepcopy(kouho[i])
            dame.append(waruyatu)
            for j in range(len(kouho)):
                if kouho[j]%waruyatu == 0:
                    kouho[j] = kouho[j]//waruyatu
            ans += 1
            break
    if not flag:
        break

print(ans)


Measured memory_bytes: 9620
#include <bits/stdc++.h>
using namespace std;
const long long MOD=1e9+7;
long long sum(long long a, long long b){
	return (a+b)*(b-a+1)/2%MOD;
}
int main(){
	long long n, k;
	cin >> n >> k;
	
	long long ans=0;
	for(int i=k; i<=n+1; ++i){
		ans += (sum(n-i+1,n)-sum(0, i-1)+1)%MOD;
		ans %= MOD;
	}

	cout << (ans>=0 ? ans : ans+MOD) << endl;
}

Measured memory_bytes: 3636
n = gets.chomp.to_i
s = gets.chomp.split("")
max_count = 0

(n-1).times do |i|
    front = []
    back  = []
    count = 0

    s.each_with_index do |str,j|
        if i >= j
            front << str
        else
            back  << str
        end
    end
    front.sort!.uniq!
    back.sort!.uniq!
    front.each do |x|
        if back.include?(x)
            count = count + 1
        end
    end

    if max_count < count
        max_count = count
    end
end
puts max_count

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

using namespace std;

int main(){
    long long int n,sum = 0;
    cin >> n;
    vector<long long int>va(n+1);
    vector<long long int>vb(n);

    for(int i = 0;i < n+1;i++)
        cin >> va[i];
    for(int i = 0;i < n;i++)
        cin >> vb[i];
    
    for(int i = 0;i < n;i++){
        if(va[i]-vb[i] <= 0){
            sum += va[i];
            vb[i] -= va[i];
            if(va[i+1]-vb[i] <= 0){
                sum += va[i+1];
                va[i+1] = 0;
            }else{
                va[i+1] -= vb[i];
                sum += vb[i];
            }
        }else{
            sum += vb[i];
        }
        
    }

    cout << sum << endl;


    return 0;
}

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

int main(){
    string o,e;
    cin >> o >> e;
    rep(i,o.size()){
        cout << o[i];
        if(i != e.size())cout << e[i];
    }
}

Measured memory_bytes: 256
#include <stdio.h>

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


Measured memory_bytes: 2120
from collections import deque


def bfs(s):
    d = [-1] * n
    p = [-1] * n
    dq = deque([s])
    d[s] = 0

    while dq:
        u = dq.popleft()
        for v in adj[u]:
            if d[v] == -1:
                d[v] = d[u] + 1
                p[v] = u
                dq.append(v)

    return d, p


n, takahashi, aoki = map(int, input().split())
takahashi -= 1
aoki -= 1
ab = [list(map(int, input().split())) for _ in range(n - 1)]

adj = [[] for _ in range(n)]
for a, b in ab:
    a -= 1
    b -= 1
    adj[a].append(b)
    adj[b].append(a)

depth, par = bfs(takahashi)
aoki_move = depth[aoki] // 2 + 1
root = aoki
for _ in range(aoki_move):
    child = root
    root = par[root]

adj[child].remove(root)
adj[root].remove(child)

depth2, par2 = bfs(root)

aoki_move += max(depth2) - 1
print(aoki_move)


Measured memory_bytes: 50212
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int q;
  cin>>q;
  while(q--){
    int n,d;
    cin>>n>>d;
    priority_queue<int,vi,greater<int>> q;
    q.push(d);
    rep(i,n-1){
      int x=q.top(); q.pop();
      q.push(127);
      q.push(127^x);
    }

    int sum=0;
    while(q.size()){
      sum+=q.top();
      q.pop();
    }

    cout<<sum<<endl;
  }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int a[10001];
int tb[100][100];
const int dx[]={1,0},dy[]={0,1};
int main(){
    int h,w,n;
    cin>>h>>w>>n;
    rep(i,n) cin>>a[i];
    int cur=0,dr=1;
    int i=0,j=0;
    while(cur!=n){
        tb[i][j]=cur+1;
        if(--a[cur]==0) ++cur;
        if(j+dx[0]*dr==w||j+dx[0]*dr==-1){
            i+=dy[1];dr*=-1;
        }
        else j+=dx[0]*dr;
    }
    rep(i,h){
        rep(j,w) cout<<tb[i][j]<<" ";
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 384