akhauriyash/Code-Regression huggingface dataset:
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
ans = []
BC_ans = []
for eb in B:
    for ec in C:
        BC_ans.append(eb+ec)
BC_ans.sort(reverse=True)
BC_ans = BC_ans[:K]
for ea in A[:K]:
    for ebc in BC_ans:
        ans.append(ea+ebc)
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])
    
    



Measured memory_bytes: 144332
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.nextLine());
        if (N < 1000) {
            System.out.println("ABC");
        } else{
            System.out.println("ABD");
        }
    }
}


Measured memory_bytes: 22228
#include<iostream>
#include<string>
#include<stack>

using namespace std;

int main(void) {
	string x;
	stack<char> sta;

	cin >> x;

	for (int i = 0; i < x.size(); i++) {
		if (x[i] == 'S') {
			sta.push('S');
		}
		else {
			if (!sta.empty()) {
				if (sta.top() == 'S') {
					sta.pop();
					continue;
				}
			}
			sta.push('T');
		}
	}

	cout << sta.size() << endl;

	return 0;
}

Measured memory_bytes: 644
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#include <cmath>
#include <ctime>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <list>
#include <deque>
#include <numeric>
#include <set>
#include <climits>
#include <utility>
#include <map>
#include <float.h>
typedef long long ll;
typedef unsigned long long ull;
inline int max( int x, int y ){ return x > y ? x : y ; }
inline int min( int x, int y ){ return x < y ? x : y ; }
inline ll max( ll x, ll y ){ return x > y ? x : y ; }
inline ll min( ll x, ll y ){ return x < y ? x : y ; }
inline ull max( ull x, ull y ){ return x > y ? x : y ; }
inline ull min( ull x, ull y ){ return x < y ? x : y ; }
int GCD( int a, int b ) { return b ? GCD( b , a%b ) : a; }
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PIV 3.14159265358979323846
#define MAXN 100
typedef pair<ll, ll> P;
const int MAX_V = 400+1;

int main(){
	
	int a, b, c, d;
    cin >> a >> b;
    c = a + b;
    d = a;
    cout << floor((c-3)/(d-1)); 
	return 0;
}









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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;

int32_t main()
{
	IOS;
	int n,k,q;
	cin >> n >> k >> q;
	mi mp;
	rep(i,1,q)
	{
		int x;
		cin >> x;
		mp[x]++;
	}	
	rep(i,1,n)
	{
		int x= mp[i] - q + k;
		if(x<=0)
		{
			cout << "No" << endl;
		}
		else
		{
			cout << "Yes" << endl;
		}
	}
	
}


Measured memory_bytes: 6912
<?php
list($h, $w) = ints();
echo str_repeat('#', $w + 2) . PHP_EOL;
for ($i = 0; $i < $h; ++$i) {
    $a = strs();
    echo '#' . implode('', $a) . '#' . PHP_EOL;
}
echo str_repeat('#', $w + 2) . PHP_EOL;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int a[n+1]={0};
    int b[n+1]={0};
    int c[n]={0};
    for(int i=1;i<=n;i++)
        {cin>>a[i];}
    for(int i=1;i<=n;i++)
    {cin>>b[i];}
    for(int i=1;i<n;i++)
        {cin>>c[i];}
    int sum=0;
    for(int i=1;i<n;i++)
    {
        if((a[i+1]-a[i])==1)
            sum+=(b[a[i]]+c[a[i]]);
        else
            sum+=b[a[i]];
    }
    sum+=b[a[n]];
    cout<<sum;

}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int n,k,t;
  scanf("%d%d",&n,&k);
  char str[n+2];
  scanf("%s",str);
  t=str[k-1];
  t=t+32;
  str[k-1]=(char)t;
  printf("%s",str);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define INF 1<<30
#define MAX_V 100

int n;
int M[MAX_V][MAX_V];
bool added[MAX_V];
int d[MAX_V], p[MAX_V];

int prim(){
  for(int i = 0; i < n; i++){
    d[i] = INF;
    added[i] = false;
  }

  d[0] = 0; p[0] = -1;

  while(true){
    int minCost = INF, u;
    for(int i = 0; i < n; i++){
      if(!added[i] && d[i] < minCost){
        minCost = d[i];
        u = i;
      }
    }

    if(minCost == INF) break;

    added[u] = true;

    for(int i = 0; i < n; i++){
      if(!added[i] && M[u][i] != -1 && M[u][i] < d[i]){
        d[i] = M[u][i];
        p[i] = u;
      }
    }
  }
  
  int sum = 0;
  for(int i = 0; i < n; i++){
    if(p[i] != -1) sum += M[i][p[i]];
  }

  return sum;
}

int main(void){
  cin >> n;
  for(int i = 0; i < n; i++) for(int j = 0; j < n; j++){
    cin >> M[i][j];
  }
  cout << prim() << endl;
  return 0;
}

Measured memory_bytes: 1200
s = list(input())
count = 0
answer = 0

for i in range(len(s)):
	if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
		count += 1
	else:
		count = 0
	if count > answer:
			answer = count

print(answer)

Measured memory_bytes: 61908
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let n: usize = buf.trim().parse().unwrap();

    println!("0");
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();

    let mut start = buf.trim().to_string();
    if start == "Vacant" {
        return;
    }

    let mut begin = 0;
    let mut end = n;
    for _ in 0..19 {
        let mid = (begin + end) / 2;
        println!("{}", mid);

        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let current = buf.trim().to_string();
        if current == "Vacant" {
            return;
        }

        if begin + 1 == mid {
            begin = mid;
        } else if (mid - begin) % 2 == 0 && current == start || (mid - begin) % 2 == 1 && current != start {
            begin = mid;
            start = current;
        } else {
            end = mid;
        }
    }
}


Measured memory_bytes: 3856
N = int(input())
V = list(map(int, input().split()))

V_ODD = [v for i,v in enumerate(V) if i%2==1]
V_EVEN = [v for i,v in enumerate(V) if i%2==0]

import collections

V_ODD_SORTED = sorted(list(zip(collections.Counter(V_ODD).values(), collections.Counter(V_ODD).keys())), reverse=True)
V_EVEN_SORTED = sorted(list(zip(collections.Counter(V_EVEN).values(), collections.Counter(V_EVEN).keys())), reverse=True)

ans_list = []

if V_ODD_SORTED[0][1] == V_EVEN_SORTED[0][1]:
    if len(V_ODD_SORTED) > 1:
        tmp = len(V)//2 - V_ODD_SORTED[1][0]
        tmp += len(V)//2 - V_EVEN_SORTED[0][0]
        ans_list.append(tmp)
        
    if len(V_EVEN_SORTED) > 1:
        tmp = len(V)//2 - V_ODD_SORTED[0][0]
        tmp += len(V)//2 - V_EVEN_SORTED[1][0]
        ans_list.append(tmp)

    if len(V_ODD_SORTED) == 1 and len(V_EVEN_SORTED) == 1:
        ans_list.append(len(V)//2)
        
else:
    tmp = len(V)//2 - V_ODD_SORTED[0][0]
    tmp += len(V)//2 - V_EVEN_SORTED[0][0]
    ans_list.append(tmp)
    
print(min(ans_list))

Measured memory_bytes: 28100
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  bool odd = N & 1;

  vector<int> as(N), bs(N);
  F0R(i, N) {
    cin >> as[i] >> bs[i];
  }

  sort(rng(as));
  sort(rrng(bs));
  int h = N / 2;

  if (odd) {

    cout << (bs[h] - as[h] + 1);
  }
  else {

    i64 high = bs[h] + bs[h - 1];
    i64 low = as[h] + as[h - 1];

    cout << (high - low + 1);
  }
}
#endif


Measured memory_bytes: 4780
#include <iostream>

using namespace std;

void k(int a, int* b)
{
	bool flag[10] = {};
	bool isFirst = true;

	for (int i = 9; i >= 0; i--)
	{
		if (a - b[i] >= 0)
		{
			a = a - b[i];
			flag[i] = true;
		}
	}

	for (int i = 0; i < 10; i++)
	{
		if (flag[i])
		{
			if (isFirst)
			{
				isFirst = false;
			}
			else
			{
				cout << " ";
			}
			cout << b[i];
		}
	}
	cout << endl;
}
int main()
{
	int a;
	int weights[10];

	weights[0] = 1;
	for (int i = 1; i < 10; i++)
	{
		weights[i] = weights[i - 1] * 2;
	}

	while (cin >> a)
	{
		k(a, begin(weights));
	}

	return 0;
}


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

using namespace std;

int longestDfs(int src, vector<vector<int> >& g,vector<int>& memo)
{
    if(memo[src]!=-1)
        return memo[src];

    if(g[src].empty())
        return 0;
    int res=0;
    for(int v: g[src])
        res=max(res,1 + longestDfs(v,g,memo));
    memo[src]=res;
    return res;
}
int main()
{
    int n,m,u,v,i,res,source;
    scanf("%d %d",&n,&m);
    vector<vector<int> > g(n,vector<int>());
    vector<int> inDeg(n,0);
    while(m--)
    {
        scanf("%d %d",&u,&v);
        g[u-1].push_back(v-1);
        inDeg[v-1]++;
    }
    vector<int> sourceNodes;
    for(i=0;i<n;i++)
        if(inDeg[i]==0)
           sourceNodes.push_back(i);
    res=0;
    while(!sourceNodes.empty())
    {
        vector<int> memo(n,-1);
        source=sourceNodes.back();
        sourceNodes.pop_back();
        res=max(res,longestDfs(source,g,memo));
    }
    printf("%d\n",res);

    return 0;
}


Measured memory_bytes: 15628
/*
    If they say
    Who cares if one more light goes out?
    In a sky of a million stars
    It flickers, flickers
    Who cares when someone's time runs out?
    If a moment is all we are
    We're quicker, quicker
    Who cares if one more light goes out?
    Well I do
*/

#include<bits/stdc++.h>
using namespace std;

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) ((a) / gcd(a,b)) * (b)
#define all(x)  x.begin(),x.end()

#define ll long long
#define ull unsigned long long
#define VI vector<int>
#define VLL vector<ll>
#define VS vector<string>
#define MPII map<int, int>
#define SET set<int>
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io   ios_base::sync_with_stdio(false);cin.tie(0),cout.tie(0);

ll MOD = 1e9+7;

ll add(ll a, ll b)
{
    a+=b; a%=MOD;
    if(a<0) a+=MOD;
    return a;
}
ll mult(ll a, ll b)
{
    if(a>MOD) a%=MOD;
    if(b>MOD) b%=MOD;
    ll ans=(a*b)%MOD;
    if(ans<0) ans+=MOD;
    return ans;
}
ll pw(ll a, ll b)
{
    ll r=1;
    while(b){
        if(b&1) r=mult(r,a);
        a=mult(a,a);
        b>>=1;
    }
    return r;
}

void solve(){
    ll n;
    cin>>n;
    ll a,b;
    cin>>a>>b;
    if((a+n >= b && a<=b)|| (b+n >= a && a>=b)){cout<<0<<endl;return;}
    (a<=b) ? cout<<abs(b-(a+n))<<endl : cout<<abs(a-(b+n))<<endl;
}

int main(){
    fast_io;
    ll t, k=0;
    t=1;;
    while(t--){
        //k++;
        //cout<<"Case "<<k<<": ";
        solve();
    }
}



Measured memory_bytes: 3604
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log,cos,pi #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    X,Y,a,b=MI()
    a%=12
    A = 360 * (a + b/60)/12
    B = 360 * b/60
    theta = min(abs(A-B),360-abs(A-B)) ##角度
    # print(theta)
    theta /= 180
    theta *= pi
    ans = X**2 + Y**2 - 2*X*Y*cos(theta)
    ans = sqrt(ans)
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 10028
#include <iostream>
using namespace std;
const int mod = 1000000007;
int n, a[100009], c[100009], X, fact[100009], inv[100009], factinv[100009], ret[100009];
int coeff(int x, int y) {
	if (y < 0 || x < y) return 0;
	return 1LL * fact[x] * factinv[y] % mod * factinv[x - y] % mod;
}
int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n + 1; i++) cin >> a[i], c[a[i]]++;
	fact[0] = 1;
	for (int i = 1; i <= n + 1; i++) fact[i] = 1LL * fact[i - 1] * i % mod;
	inv[1] = 1;
	for (int i = 2; i <= n + 1; i++) inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod;
	factinv[0] = 1;
	for (int i = 1; i <= n + 1; i++) factinv[i] = 1LL * factinv[i - 1] * inv[i] % mod;
	for (int i = 1; i <= n + 1; i++) {
		if (c[i] == 2) {
			int p1 = -1, p2 = -1;
			for (int j = 1; j <= n + 1; j++) {
				if (a[j] == i) {
					if (p1 == -1) p1 = j;
					else p2 = j;
				}
			}
			X = n - p2 + p1;
		}
	}
	for (int i = 1; i <= n + 1; i++) ret[i] = coeff(n + 1, i);
	for (int i = 1; i <= X + 1; i++) {
		ret[i] -= coeff(X, i - 1);
		if (ret[i] < 0) ret[i] += mod;
	}
	for (int i = 1; i <= n + 1; i++) cout << ret[i] << endl;
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
int main() {
  ll N,X,M;
  cin >> N >> X >> M;
  vector<ll> seq;
  map<ll,ll> mp;
  ll cnt = 1;
  seq.push_back(X);
  mp[X] = 1;
  ll now = X;
  ll len = 0;
  ll roops = 0;
  ll num = 0;
  while (0 == 0) {
    cnt++;
    now *= now;
    now %= M;
    seq.push_back(now);
    if (mp[now] != 0) {
      len = cnt - mp[now];
      roops = mp[now];
      num = now;
      break;
    } else {
      mp[now] = cnt;
    }
  }
  ll ans = 0;
  if (N <= cnt) {
    for (int i = 0; i < N; i++) {
      ans += seq[i];
    }
    
  } else {
    for (int i = 0; i < mp[num] - 1; i++) {
      ans += seq[i];
    }
    ll roopsum = 0;
    vector<ll> R(1);
    R[0] = 0;
    for (int i = mp[num] - 1; i < cnt - 1; i++) {
      roopsum += seq[i];
      R.push_back(R[(int)R.size() - 1] + seq[i]);
    }
    ans += ((N - mp[num] + 1) / len) * roopsum;
    ans += R[((N - mp[num] + 1) % len)];
    
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7572
#include <iostream>

//https://atcoder.jp/contests/abc075/tasks/abc075_b

using namespace std;

int main(){
    int H,W;
    cin >> H >> W;

    char cha[H][W];

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> cha[i][j] ;
        }
    }

    

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            
            if(cha[i][j] == '.'){ // 周囲の爆弾を探索
                int tmp = 0;
                for(int k=i-1;k<i+2;k++){
                    if( k<0 || k>=H) continue;
                    for(int l=j-1;l<j+2;l++){
                        if(l<0 || l>W-1) continue;
                        if(cha[k][l] == '#'){
                            tmp++;
                        }
                    }
                }
                cout << tmp;
            } else {
                cout << '#';
            }

        }
        cout << endl;
    }


}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <set>
using namespace std;
using ll = long long;

const long long BASE_NUM = 1000000007;

int main()
{
  // 整数の入力
  ll H,W,M;
  cin >> H >> W >> M;
  vector<ll> row_bomb_counts(H,0);
  vector<ll> column_bomb_counts(W,0);
  set<pair<ll,ll>> bombs;
  for(int i = 0;i < M;i++){
    ll h,w;
    cin >> h >> w;
    h--;
    w--;
    row_bomb_counts[h]++;
    column_bomb_counts[w]++;
    bombs.insert({h,w});
  }
  vector<pair<ll,ll>> row_bomb_count_pairs;
  vector<pair<ll,ll>> column_bomb_count_pairs;
  for(int i = 0;i < H;i++){
    row_bomb_count_pairs.push_back({row_bomb_counts[i],i});
  }
  for(int i = 0;i < W;i++){
    column_bomb_count_pairs.push_back({column_bomb_counts[i],i});
  }
  sort(row_bomb_count_pairs.begin(),row_bomb_count_pairs.end(),greater<pair<ll,ll>>());
  sort(column_bomb_count_pairs.begin(),column_bomb_count_pairs.end(),greater<pair<ll,ll>>());
  while(row_bomb_count_pairs.front().first != row_bomb_count_pairs.back().first){
    row_bomb_count_pairs.pop_back();
  }
  while(column_bomb_count_pairs.front().first != column_bomb_count_pairs.back().first){
    column_bomb_count_pairs.pop_back();
  }
  bool has_no_set = false;
  for(auto rp:row_bomb_count_pairs){
    for(auto cp:column_bomb_count_pairs){
      // cout << rp.second << "," << cp.second << endl;
      if (bombs.find({rp.second,cp.second}) == bombs.end()){
        has_no_set = true;
        break;
      }
    }
  }
  if (has_no_set){
    cout << row_bomb_count_pairs.front().first + column_bomb_count_pairs.front().first << endl;
  }else{
    cout << row_bomb_count_pairs.front().first + column_bomb_count_pairs.front().first - 1<< endl;
  }
  return 0;
}


Measured memory_bytes: 43760
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main()
{
    cin.tie(0);
    int64_t n, y;
    cin >> n >> y;

    for (int64_t sy = 0; sy <= n; sy++) {
        for (int64_t gsy = 0; sy + gsy <= n; gsy++) {
            int64_t imy = n - sy - gsy;

            int64_t tot = sy * 1000 + gsy * 5000 + imy * 10000;

            if (tot == y) {
                cout << imy << " " << gsy << " " << sy << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;

    return 0;
}


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

void Main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    int b = 0;
    for (int i = 0; i < n; i++) b ^= a[i];

    for (int i = 0; i < n; i++){
        if(i != 0) cout << " ";
        cout << (b ^ a[i]);
    }
    cout << endl;
  
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


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

ll n,k;
ll f(ll x)
{
	return abs(n - k * x);
}


int main()
{
	cin >> n >> k;
  	ll x1 = n / k, x2 = (n / k) + 1;
  	cout << min(f(x1), f(x2)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int n,m,k,f=0,ax=0,bx=0,kx=0; cin>>n>>m>>k;
  long long int a[n],b[m];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if((kx+a[i]<=k)&&f==0) {ax++; kx+=a[i];} 
    else f=1;
  }
  
  f=0;
  for (int i = 0; i < m; i++) {
    cin >> b[i];
    if((kx+b[i]<=k)&&f==0) {bx++; kx+=b[i];} 
    else f=1;
  }
  if(bx==m){
    cout<<n+m<<endl;
    exit(0);
  }
  long long int ma=ax+bx;
  while(ax!=0){
    ax--; kx-=a[ax];
    while(bx<m&&kx+b[bx]<=k){
      kx+=b[bx]; bx++;
    }
    ma=max(ma,ax+bx);
  }    
  cout<<ma<<endl;  
}

Measured memory_bytes: 6684
#include <bits/stdc++.h>
using namespace std;
int main(){
  long int n;
  cin >> n;
  long long int asum = 0;
  long long int bsum = 0;
  vector<long long int> a(n);
  vector<long long int> b(n);
  vector<long long int> c(n);
  for(int i = 0;i < n;i++){
    cin >> a[i] >> b[i];
    asum += a[i];
    bsum += b[i];
    c[i] = a[i] + b[i];
  }
  sort(c.begin(),c.end());
  reverse(c.begin(),c.end());
  for(int i = 0;i < n;i++){
    if(i % 2 == 0) bsum -= c[i];
    else asum -= c[i];
  }
  long long answer = (asum - bsum)/2;
  cout << answer << endl;
}

Measured memory_bytes: 2560
package main

import (
	"sort"
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n, k := scanInt(), scanInt64()

	as := scanInts(n)
	fs := scanInts(n)

	sort.Ints(as)
	sort.Ints(fs)

	l,r := int64(-1), int64(1<<62-1)

	for r-l > 1 {
		mid := (l+r)/2
		c := int64(0)
		for i := 0; i < n; i++ {
			ll, rr := int64(0), int64(as[i]+1)
			for rr-ll>1 {
				midmid := (ll+rr)/2
				if midmid*int64(fs[n-1-i]) > mid {
					rr = midmid
				} else {
					ll = midmid
				}
			}
			c += int64(as[i])-ll
		}

		if c <= k {
			r = mid
		} else {
			l = mid
		}
		// fmt.Println(l,r)
	}

	fmt.Println(r)

}


Measured memory_bytes: 7704
import java.util.*;

public class Main {
    static int ret = 0;
    static boolean[] arrived;
    static int N;
    static boolean[][] matrix;

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

        N = sc.nextInt();
        int M = sc.nextInt();

        arrived = new boolean[N];

        matrix = new boolean[N][N];
        for (int i = 0; i < M; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;

            matrix[a][b] = true;
            matrix[b][a] = true;
        }

        arrived[0] = true;
        dfs(0);

        System.out.println(ret);
    }

    public static void dfs(int node) {
        if (allNodeArrived()) {
            ret++;
            return;
        }

        for (int i = 0; i < N; i++) {
            if (matrix[node][i] && !arrived[i]) {
                arrived[i] = true;
                dfs(i);
                arrived[i] = false;
            }
        }

        return;
    }

    public static boolean allNodeArrived() {
        for (int i = 0; i < N; i++) {
            if (!arrived[i]) return false;
        }

        return true;
    }
}

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

int main() {
    
    vector<int> a(90001);
    rep(i, 90000) {

        int b[5];
      	int tmp = i + 10000;
        rep(i, 5) {
            b[4-i] = tmp % 10;
            tmp /= 10;
        }
      	//rep(i, 5) cout << b[i];
      
      	//cout << endl;

        if(b[0]==b[4] && b[1]==b[3]) a.at(i) = 1;
        
    } 

    int c, d;
    cin >> c >> d;
    int ans = 0;

    for(int i = c - 10000; i <= d - 10000; i++) {
        if(a.at(i) == 1) ans++;
    }

    cout << ans << endl;

  	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
	public static void main (String[] args){
		int men=0, len=0;
		
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		
		men = a*b;
		len = a*2+b*2;
		
		System.out.println(men+" "+len);
	}
}

Measured memory_bytes: 17156
#include <iostream>

using namespace std;

main(){
  int n,d,x,r=0;
  cin>>n>>d>>x;
  long long A[100];
  for(int i = 0;i<n;i++){
    cin>>A[i];
    for(int j = 1;j<=d;j+=A[i]){
      r+=1;
    }
  }
  
  cout<<r+x<<endl;
  return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
int main(){
  long n,ans=1,a; cin>>n;
  bool ok=true;
  
  rep(i,n){
    cin>>a;
    if(a==0){cout<<0;return 0;}
    else if(long(1e+18)/a<ans){ok=false;ans=1;}
    else ans*=a;
  }
 
  cout<<(ok?ans:-1)<<endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define rep(i,e) for(int i=0;i<(e);++i)

#define MAX 250000
vector<int> prime(MAX, 1);

void sieve() {
  prime[0] = prime[1] = 0;
  for(int i=4;i<MAX;i+=2){
    prime[i] = 0;
  }
  for(int i=3;i<sqrt(MAX)+1;i+=2){
    if(prime[i]==1){
      for(int j=i*2;j<MAX;j+=i) prime[j] = 0;
    }
  }
}

int main() {
  sieve();
  vector<int> s(MAX);
  int cur = 0;
  rep(i, MAX){
    if(prime[i]==1) cur++;
    s[i] = cur;
  }
  int n;
  while(cin >> n){
    if(n==0) return 0;
    cout << s[n*2]-s[n] << endl;
  }
  return 0;
}


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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int main(){
    int S;
    cin >> S;
    const int MX = 1e8;
    int s = 0, r = 1, ld = 1, llim = 10, rd = 1, rlim = 10;
    int64_t ans = 0;

    for(int l=1; l<MX; l++){
        if(l == llim){
            ld++;
            llim *= 10;
        }
        while(s < S){
            s += rd;
            r++;
            if(r == rlim){
                rd++;
                rlim *= 10;
            }
        }
        if(s == S) ans++;
        s -= ld;
    }

    for(int i=1; i*i<=S; i++) if(S%i == 0){
        vector<int> ds;
        if(i > 8) ds.push_back(i);
        if(S/i > 8 && i < S/i) ds.push_back(S/i);
        for(int d : ds){
            int64_t len = S/d;
            int64_t total = 9 * power_mod(10, d-1) % MOD;
            add(ans, total - len + 1 + MOD);
        }
    }

    for(int x=9; 2*x<S; x++){
        int64_t lmin = (x+1) * (S/(x+1) + 1) - S;
        int64_t rmin = S - x * (S%x ? S/x : S/x-1);
        int64_t lmax = (S - (x+1)*rmin) / x;
        if(lmin <= lmax) add(ans, (lmax - lmin) / (x+1) + 1);
    }

    cout << ans << endl;
    return 0;
}


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

int main() {
	int a, b, res; char op;
	while(true) {
		cin >> a >> op >> b;
		switch (op) {
			case '+': res = a + b; break;
			case '-': res = a - b; break;
			case '*': res = a * b; break;
			case '/': res = a / b; break;
			case '?': goto end;
		}
		cout << res << '\n';
	}
end:
	return 0;
}


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

using namespace std;

typedef long long LL;

int N;
int A,B,H[100010];

bool check(LL T)
{
	LL cnt = 0;
	for (int i=1;i<=N;i++)
	{
		if (T * LL(B) >= LL(H[i])) continue;
		cnt += ((H[i] - T*LL(B)) / LL(A-B)) + ((H[i] - T*LL(B)) % LL(A-B) != 0);
	}
	return cnt <= T;
}

int main()
{
	scanf("%d%d%d",&N,&A,&B);
	for (int i=1;i<=N;i++)scanf("%d",&H[i]);
	int L = 0, R = 1000000000;
	while(L != R-1)
	{
		int mid = (L+R)>>1;
		if (check(mid))
			R = mid;
		else
			L = mid;
	}
	printf("%d\n",R);
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;


int main(){
    long long int n;
    cin>>n;
    while(n!=0){
        long long int a,b,c,d,e,f,g,h,i;
        cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;
        cout<<n-a-b-c-d-e-f-g-h-i<<endl;
        cin>>n;
    }
   return 0;
}



Measured memory_bytes: 3004
#include <cstdio>
#include <algorithm>

using namespace std;
int n, tmp, ct;

int main()
{
    scanf("%d", &n);
    for(int i = 1; i<= n; ++i)
    {
        scanf("%d", &tmp);
        if(tmp&1) ++ct;
    }
    if(ct&1)
    {
        printf("NO\n");
        return 0;
    }
    printf("YES\n");
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int a = scanner.nextInt();
		    int b = scanner.nextInt();
		    int c = scanner.nextInt();
		    int count = 1;
		    
		    if( b != a ) 
		    {
		    	count++;
		    	if( c != b && c != a) // a !=  b != c != a 
		    	{
		    		count++;
		    	}
		    }
		    else //a=b 
		    {
		    	if( c != b ) 
		    	{
		    		count++;
		    	}
		    }
		    System.out.println(count);
		    
		    
		    scanner.close(); }
		  }

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
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;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,m;
    cin>>n>>m;
    cout<<(n+m-3)/(m-1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void){
    int x,y,z;
    scanf("%d %d %d",&x,&y,&z);
    if(x<=y){
        if(y<=z){
            printf("%d %d %d\n",x,y,z);
        }
        else{
            if(x<z){
                printf("%d %d %d\n",x,z,y);
            }
            else{
                printf("%d %d %d\n",z,x,y);
            }    
        }
    }
    else{
        if(x<=z){
            printf("%d %d %d\n",y,x,z);
        }
        else{
            if(y<z){
                printf("%d %d %d\n",y,z,x);
            }
            else{
                printf("%d %d %d\n",z,y,x);
            }    
        }
    }    
    return 0;
}


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

int dp[110][20000];
int main(){

  int n;
  cin>>n;

  dp[0][0] = 1;
  int ans = 0;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    for(int j=0;j<N;j++){
      dp[i+1][j] |= dp[i][j];
      dp[i+1][j+a] |= dp[i][j];
    }
  }

  for(int i=0;i<N;i++) if(dp[n][i] && i%10) ans = i;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 7552
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D: Islands War
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_M = 100000;

/* typedef */

typedef pair<int,int> pii;

/* global variables */

pii rs[MAX_M];

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  for (int i = 0; i < m; i++) {
    int ai, bi;
    scanf("%d%d", &ai, &bi);
    ai--, bi--;
    rs[i] = pii(ai, bi);
  }
  sort(rs, rs + m);

  int pa = 0, pb = 0, cnt = 0;
  for (int i = 0; i < m; i++) {
    int &ra = rs[i].first, &rb = rs[i].second;
    if (pb <= ra) {
      if (pb > 0) cnt++;
      pa = ra, pb = rb;
    }
    else if (pa < rb && ra < pb)
      pa = max(pa, ra), pb = min(pb, rb);
  }
  if (pb > 0) cnt++;

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


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

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

  string s;
  cin >> s;

  int n = s.size();
  for (int i = 0; i < n; i++) {
    if(s[i] == '?') s[i] = 'D';
  }

  for (auto it : s) {
    cout << it;
  }
  cout << '\n';
}

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

class Program
{
	//Main
	static void Main(string[] args)
	{
		//読み込む
		string S = Console.ReadLine();
		char[] Sarr = S.ToCharArray();
		int Slen = S.Length;

		string T = Console.ReadLine();
		char[] Tarr = T.ToCharArray();
		int Tlen = T.Length;

		//解答候補を格納するリスト
		List<string> ansList = new List<string>();

		//S>=Tは最低条件
		if(Slen >= Tlen){
				//Sの一文字目から順に、Tを当てはめて検証
				int times = Slen - Tlen + 1;

				//ループ処理で検索
				for(int i=0; i<times; i++){
						//各文字について検索
						bool found = false;
						char[] ans = new char[Slen];
						Array.Copy(Sarr, ans, Slen);

						for(int j=0; j<Tlen; j++){
								//元々一致している場合
								if(Sarr[i+j] == Tarr[j]){
										//最後の文字だった場合
										if(j == Tlen-1){
												found = true;
										}
										//次の文字へ
										continue;
								}
								//?の場合
								else if(Sarr[i+j] == '?'){
										//?の部分を書き換える
										ans[i+j] = Tarr[j];

										//最後の文字だった場合
										if(j == Tlen-1){
												found = true;
										}
										//次の文字へ
										continue;
								}
								//その他の場合、可能性は無いので、次へ
								else{
										break;
								}

							}

							//見つかっていた場合、リストに加える
							if(found){
									for(int k=0; k<Slen; k++){
											if(ans[k] == '?'){
													ans[k] = 'a';
											}
									}
									string s = new string(ans);
									ansList.Add(s);
							}
						}
				}


			//答えの候補がある場合
			if(ansList.Count() > 0){
					//ソート
					ansList.Sort(StringComparer.Ordinal);

					//最初の答えを出力
					Console.WriteLine(ansList[0]);
			}
			//答えがない場合
			else{
					Console.WriteLine("UNRESTORABLE");
			}
		}
	}



Measured memory_bytes: 11220
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int q; cin >> q;
	priority_queue<int> f;
	priority_queue<int, vector<int>, greater<int>> g;
	ll x = 0, add = 0;
	rep(i, 0, q) {
		int t; cin >> t;
		if (t == 1) {
			int a, b; cin >> a >> b;
			add += b;
			if (f.size() <= g.size()) {
				f.push(a);
				x++; add -= a;
			}
			else {
				g.push(a);
				x--; add += a;
			}
			while (!f.empty() && !g.empty() && f.top() > g.top()) {
				add += f.top() * 2; add -= g.top() * 2;
				int p = f.top();
				f.pop(); f.push(g.top());
				g.pop(); g.push(p);
			}
		}
		else {
			printf("%d %lld\n", f.top(), 1LL * x * f.top() + add);
		}
	}
	return 0;
}

Measured memory_bytes: 3452
# include <iostream>
# include <string>
# include <algorithm>
# include <vector>
# include <cstring>
# include <stdio.h>
# include <map>
# include <queue>

# define ll long long
# define pii pair<int,int>
# define FOR(a,b) for(int a=1; a<=b; a++)
# define REP(a,b) for(int a=0; a<b; a++)
# define FORU(a,b,c) for(int a=b; a<=c; a++)
# define FORD(a,b,c) for(int a=b; a>=c; a--)

using namespace std;

ll N;
deque<int> dq;
int cur=0;

void construct(ll x){
    if(x==1) return;
    if(x & 1){
        construct(x-1);
        dq.push_front(++cur);
    }
    else{
        construct(x/2);
        dq.push_back(++cur);
    }
}

int main(){

    ios :: sync_with_stdio(false);
    cin >> N;
    construct(N+1);

    cout << 2*((int)dq.size()) << endl;
    REP(i,dq.size()) cout << dq[i] << " ";
    FOR(i,cur) cout << i << " ";
    cout << endl;

    return 0;
}

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

ans=0
for i in range(1,int(m**0.5)+2):
    if m%i==0 :
        a=m//i
        if min(a,i)>=n :
            ans=max(ans,max(a,i))
        elif max(a,i)>=n :
            ans=max(ans,min(a,i))
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll num,temp;
    cin>>num;
    vector<char> arr;
    while(num > 0)
    {
        int temp = num%26;
        if(temp == 0)
        {
            arr.push_back('z');
            num = (num/26) - 1;
        }
        else{
            arr.push_back(temp  - 1 + 'a');
            num = num/26;
        }
    }
    for(int i = arr.size() - 1;i>= 0;i--)
        cout<<arr[i];
    return 0;
}

Measured memory_bytes: 3572
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#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 FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

/* BIT: RAQ対応BIT
    初期値は a_1 = a_2 = ... = a_n = 0
    ・add(l,r,x): [l,r) に x を加算する
    ・sum(i): a_1 + a_2 + ... + a_i を計算する
    計算量は全て O(logn)
*/
template <typename T>
struct BIT {
    int n;             // 要素数
    vector<T> bit[2];  // データの格納先
    BIT(int n_) { init(n_); }
    void init(int n_) {
        n = n_ + 1;
        for (int p = 0; p < 2; p++) bit[p].assign(n, 0);
    }

    void add_sub(int p, int i, T x) {
        for (int idx = i; idx < n; idx += (idx & -idx)) {
            bit[p][idx] += x;
        }
    }
    void add(int l, int r, T x) {  // [l,r) に加算
        add_sub(0, l, -x * (l - 1));
        add_sub(0, r, x * (r - 1));
        add_sub(1, l, x);
        add_sub(1, r, -x);
    }

    T sum_sub(int p, int i) {
        T s(0);
        for (int idx = i; idx > 0; idx -= (idx & -idx)) {
            s += bit[p][idx];
        }
        return s;
    }
    T sum(int i) { return sum_sub(0, i) + sum_sub(1, i) * i ; }
};


signed main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    ll n,q;cin>>n>>q;
    BIT<ll> row(n);
    row.add(1,n+1,n);
    BIT<ll> column(n);
    column.add(1,n+1,n);
    ll d,r;d=n;r=n;
    ll ans=0;
    REP(_,q){
        ll x,y;cin>>x>>y;
        if(x==1){
            ans+=column.sum(y)-column.sum(y-1)-2;
            //cout<<column.sum(y)-column.sum(y-1)-1<<endl;
            if(y<r){
                row.add(1,d,(y-row.sum(1)));
                r=y;
            }
        }else{
            ans+=row.sum(y)-row.sum(y-1)-2;
            //cout<<row.sum(y)-row.sum(y-1)-1<<endl;
            if(y<d){
                column.add(1,r,(y-column.sum(1)));
                d=y;
            }
        }
    }
    cout<<(n-2)*(n-2)-ans<<endl;
}

Measured memory_bytes: 9588
#00:50
n = int(input())
s = input()
cnt = 0
for i in range(n)[::-1]:
  if s[i] == ')':
    cnt += 1
  elif cnt != 0:
    cnt -= 1
pre = '(' * cnt
cnt = 0
for i in range(n):
  if s[i] == '(':
    cnt += 1
  elif cnt != 0:
    cnt -= 1
pst = ')' * cnt
print(pre + s + pst)

Measured memory_bytes: 3064
#include <stdio.h>

main()
{
  int height[10];
  int i,j;
  int dumy=0;

  for(i = 0 ; i < 10 ; i++)
    {
      scanf("%d",&height[i]);
    }
  
  for(i = 0 ; i < 10 ; i++)
    {
      for(j = i + 1 ; j < 10 ; j++)
	{ 
	  if(height[i] < height[j])
	    {
	      dumy = height[i];
	      height[i] = height[j];
	      height[j] = dumy;
	    }
	}
    }
  
  for(i = 0 ; i < 3 ; i++)
    {
      printf("%d\n",height[i]);
    }
  return 0;
}

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

int main()
{
    long long int n,k,counter=0;
    cin>>n>>k;
    for(;;)
    {
        if(n<k)
            break;
        n=n/k;
        counter++;
    }
    cout<<counter+1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define rep(i, j, k) for(i=j; i<k; i++)
#define sep(i, j, k) for(i=j; i>k; i--)
const int N = 3e3+5, inf = 1e9+7;
int n, k, i, j;
int A[N], dp[N][N];

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int i, j, a, b, ans = 0;
    cin>>n;
    rep(i, 1, n+1) cin>>A[i];
    for (int l = 0; l < n; ++l)
        for(int i=1; i+l<=n; i++){
        j = i+l;
        if(i==j) dp[i][j] = A[i];
        else dp[i][j] = max(A[i]-dp[i+1][j], A[j]-dp[i][j-1]);
    }
    cout<<dp[1][n];
}

Measured memory_bytes: 70016
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in); 
        int s = stdIn.nextInt();
        int h = s / 3600;
        s = s - h*3600;   
        int m = s / 60;
        s = s - m * 60; 
        System.out.println(h+ ":" + m + ":" + s);
    }
}


Measured memory_bytes: 26404
S = input()[::-1]
MOD = 10**9+7
dp = [1,0,0,0,0,0,0,0,0,0,0,0,0]
p = 1
for i, s in enumerate(S):
    nx = [0,]*13
    if s == '?':
        for k in range(10):
            q = (k*p)%13
            for j, d in enumerate(dp):
                nx[(j+q)%13] += d
    else:
        q = (int(s)*p)%13
        for j, d in enumerate(dp):
            nx[(j+q)%13] += d
    dp = [n % MOD for n in nx]
    p = (10*p)%13
print(dp[5])

Measured memory_bytes: 43884
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
  ll n,w;
  cin>>n>>w;
  map<ll,ll>m;
  ll i;
  ll a[n];
  ll b[n];
   
  for(i=0;i<n;i++)
  {
   
    cin>>a[i]>>b[i];
   
  }
  //sort(a,a+n);
 ll dp[w+1]={0};
  for(i=0;i<n;i++)
  {
    for(ll j=w;j>=0;j--)
    {
      if(a[i]>j)
        continue;
      else
      {
        dp[j]=max(dp[j],dp[j-a[i]]+b[i]);
      }
    }
  }
  cout<<dp[w];
  
  
  
  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111


	vi morty(310000);
	int n;
	int x;
	int x1;
	bool ok(int explosions){
		int tmp = 0;
		FOR(i,0,n){
			if(morty[i]-x1*explosions<=0)continue;
			tmp+=((morty[i]-x1*explosions)+(x-x1)-1)/(x-x1);
		}
		//out(explosions,tmp);
		if(tmp<=explosions)return 1;
		else return 0;
	}

	void solve(){

		in(n);
		in(x);
		in(x1);
		FOR(i,0,n)in(morty[i]);
		int ll = 1;
		int rr = 1e9;
		while(ll+1<rr){
			int mid  = (ll+rr)/2;
			if(ok(mid))rr = mid;
			else ll = mid;
		}
		if(ok(ll))out(ll);
		else out(rr);








	}	























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
const ll INF = 2e9+10;

struct edge{
    int to, next;
}G[maxn << 1];
int tot, head[maxn];
void addEdge(int u, int v){G[tot] = {v, head[u]};head[u] = tot++;};
int n, s, t, vis[2][maxn];
void dfs(int u, int fa, int x){
    for(int i = head[u];i != -1;i = G[i].next)
        if(G[i].to != fa)
            vis[x][G[i].to] = vis[x][u] + 1, dfs(G[i].to, u, x);
}
int main(){
    #ifdef Irene
    freopen("in.txt", "r", stdin);
    #endif // Irene
    ios_base::sync_with_stdio(false);

    cin >> n >> s >> t;
    int u, v;
    for(int i = 1;i <= n;i++)head[i] = -1;
    for(int i = 1;i < n;i++){
        cin >> u >> v;
        addEdge(u, v);
        addEdge(v, u);
    }
    dfs(s, -1, 0);
    dfs(t, -1, 1);
    int ans = 0;
    for(int i = 1;i <= n;i++)
        if(vis[0][i] < vis[1][i])
            ans = max(ans, vis[1][i] - 1);
    cout << ans << "\n";
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
string a,b="CODEFESTIVAL2016";
int c;
signed main()
{
	cin>>a;
	rep(i,16){
		if(a[i]!=b[i]){
			c++;
		}
	}
	cout<<c;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  string s;
  cin>>s;
   bool ans = true;
  int n = s.size();
  for(int i = 0; i < n; i += 2){
    if(s[i] != 'h' || s[i + 1] != 'i')ans = false; 
  }
  if(ans)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}
int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 256