akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("test.txt","r",stdin);
	string s,t;
	cin>>s;
	cin>>t;
	ll n=s.length();
	ll m=t.length();
	ll dp[n+1][m+1];
	for(ll i=0;i<=n;i++)
		dp[i][0]=0;
	for(ll i=0;i<=m;i++)
		dp[0][i]=0;
	string fin;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=m;j++)
		{
			int x=s[i-1];
			int y=t[j-1];
			if(x==y)
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
		}
	}
	ll index=dp[n][m];
	char c[index+1];
	c[index]='\0';
	ll i=n,j=m,idx=index-1;
	while(i>0&&j>0){
		ll x=s[i-1];
		ll y=t[j-1];
		if(x==y)
		{
			c[idx]=s[i-1];
			i--,j--,idx--;
		}
		else if(dp[i-1][j]>dp[i][j-1])
			i--;
		else
			j--;
	}
	cout<<c<<endl;


}

Measured memory_bytes: 70656
x, y = map(int, input().split())
ans = 0

score = {3:100000, 2:200000, 1:300000}
if x in score.keys():
  ans += score[x]
if y in score.keys():
  ans += score[y]
if x == 1 and y == 1:
  ans += 400000

print(ans)

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

int main()
{
    int n, x, y, res = -1, ans;


    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &x, &y);
        if (x > res) {
            res = x;
            ans = y;
        }
    }
    printf("%d\n", res + ans);
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, s: "List[str]"):
    count_AB = 0
    count_endswith_A = 0
    count_startswith_B = 0
    count_BA = 0
    for ss in s:
        count_AB += ss.count('AB')
        if ss.endswith('A') and ss.startswith('B'):
            count_BA += 1
            continue
        if ss.endswith('A'):
            count_endswith_A += 1
        if ss.startswith('B'):
            count_startswith_B += 1
    count_pair = min(count_endswith_A, count_startswith_B)
    if count_pair > 0:
        print(count_AB + count_pair + count_BA)
    elif count_endswith_A > 0 or count_startswith_B > 0:
        print(count_AB + count_BA)
    elif count_BA > 0:
        print(count_AB + count_BA - 1)
    else:
        print(count_AB)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [ next(tokens) for _ in range(N) ]  # type: "List[str]"
    solve(N, s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 41820
N = int(input())
a = [int(i) for i in input().split()]

ave = sum(a) / N

min = abs(a[0] - ave)
min_num = 0


for i in range(1, N):
    if min > abs(a[i] - ave):
        min_num = i
        min = abs(a[i] - ave)

print(min_num)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int s = 0;
  rep(i,n) s += a[i];
  cout<< s - *max_element(all(a))/2 <<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
using namespace std;
const int xmax=2e5+5;
char str[xmax];
vector<char> s;

int main(){
	char temp=0;s.clear();
	scanf("%s",str);
	
	int len=strlen(str);
	for(int i=0;i<len;i++){
		temp=str[i];
		if(s.empty()) {
			s.push_back(temp);continue;
		}
		if(temp=='S') s.push_back(temp);
		else if(temp=='T'){
			if(s.back()=='S'){
				s.pop_back();
			}
			else if(s.back()=='T'){
				s.push_back(temp);
			}
		}
	}
		
	cout<<s.size();
	
	return 0;
}

Measured memory_bytes: 768
s = list(input())
for i in s:
    if i == 'E' and 'W' not in s:
        print('No')
        break
    elif i == 'W' and 'E' not in s:
        print('No')
        break
    elif i == 'S' and 'N' not in s:
        print('No')
        break
    elif i == 'N' and 'S' not in s:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	vector<int> x(3);
  for (int i = 0; i < 3; i++) {
       cin >>x[i];
	}
	sort(x.begin(), x.end());
	
	cout << (x[2]*10+x[1])+x[0] << endl;

	return 0;
}

Measured memory_bytes: 256
/*
ID: hafiz.i1
TASK: milk2
LANG: C++
*/
#include<bits/stdc++.h>

#define ll long long
#define debug(x) cout<<x<<"DE"<<endl;

using namespace std;



int main()
{
//    freopen("milk2.in", "r", stdin);
//    freopen("milk2.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    double y=0.0;
    ll j;string s;
    for(int i=1;i<=n;i++){double b=1.0;
        cin>>b>>s;
        if(s=="BTC")b=(b*380000.0);
        y+=b;
    }
    cout<<fixed<<setprecision(8)<<y;
}


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

int charToInt(char c) {
  return (int)c - (int)'0';
}
int j;
void showSoro(string str) {
  string num = "00000";
  for(int i = 0; i < str.length(); i++) {
    num[i+5-str.length()] = str[i];
  }

  for(int i = 0; i < 5; i++) {
    if(charToInt(num[i]) >= 5) cout << ' ';
    else                       cout << '*';
  }
  cout << endl;
  for(int i = 0; i < 5; i++) {
    if(charToInt(num[i]) >= 5) cout << '*';
    else                       cout << ' ';
  }
  cout << endl;
  cout << "=====" << endl;

  for(int l = 0; l < 5; l++) {
    for(int i = 0; i < 5; i++) {
      if(charToInt(num[i]) % 5 == l) cout << ' ';
      else                           cout << '*';
    }
    cout << endl;
  }
}

int main() {
  string str;
  bool flag = false;
  while(cin >> str) {
    if(flag) cout << endl;
    showSoro(str);
    flag = true;
  }
  return 0;
}

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

#define llint long long int

using namespace std;

llint mod_pow(llint a, llint n, llint p){
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        llint d = mod_pow(a, n / 2, p);

        return (d * d) % p;
    } else {
        return (a * mod_pow(a, n - 1, p)) % p;
    }
}
int main(){
    llint N, K;

    cin >> N >> K;

    llint p = 1000000000 + 7;
    vector<llint> count(K + 1, 0);

    count[1] = mod_pow(K, N, p);

    for(int i = 2; i <= K; i ++){
        count[i] = mod_pow(K / i, N, p);
    }
    for(int i = K; i >= 1; i --){
        for(int j = 2 * i; j <= K; j += i){
            count[i] -= count[j];
            count[i] %= p;
        }
    }
    llint ans = 0;

    for(int i = 1; i <= K; i ++){
        ans += i * count[i];
        ans %= p;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4048
input=STDIN.gets.split(" ").reverse
stack=[]
until input.empty? do
  tmp = input.pop
  case tmp
  when '+' then
    stack.push(stack.pop + stack.pop)
  when '-' then
    stack.push(-1*(stack.pop - stack.pop))
  when '*' then
    stack.push(stack.pop * stack.pop)
  else
    stack.push(tmp.to_i)
  end
end

p stack.pop

Measured memory_bytes: 8684
#include<bits/stdc++.h>
const int N=1003;
using namespace std;
int n,tp,x[N],y[N];
bool d,ux[40],uy[40];
inline void cal(int x,bool*c){
	bool fl=x<0;
	if(fl)x=-x;
	c[30]=c[31]=1;
	for(int i=1;i<=30;i++)
	c[i-1]=x>>i&1;
	if(fl)
	for(int i=0;i<31+d;i++)
	c[i]^=1;
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",x+i,&tp);
		y[i]=x[i]-tp,x[i]+=tp;
		if(!i)d=x[i]&1;
		if(x[i]&1^d||y[i]&1^d)
		return puts("-1"),0;
	}
	printf("%d\n",31+d);
	for(int i=0;i<30;i++)
	printf("%d ",1<<i);
	printf("%d",(1<<30)-1);
	puts(d?" 1":"");
	for(int i=0;i<n;i++){
		cal(x[i],ux),cal(y[i],uy);
		for(int j=0;j<31+d;j++)
		putchar(ux[j]?uy[j]?'R':'U':(uy[j]?'D':'L'));
		puts("");
	}
}

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

// LIS and LDS
// A + B <= N+1, AB >= N are necessarily and sufficient
vector<long long> LISLDS(long long N, long long A, long long B)
{
    vector<long long> res;
    for (long long i = B - 1; i >= 0; --i)
        res.push_back(i);

    if (A == 1)
        return res;

    long long rem = N - B; // 残りの追加する数
    long long p = rem / (A - 1); // patterns
    long long r = rem % (A - 1); // 残り

    long long b = r;
    long long c = A - 1 - r;

    for (int i = 0; i < b; ++i)
    {
        int size = (int)res.size();
        for (int j = 0; j < p + 1; ++j)
        {
            res.push_back(size + p - j);
        }
    }
    for (int i = 0; i < c; ++i)
    {
        int size = (int)res.size();
        for (int j = 0; j < p; ++j)
        {
            res.push_back(size + p - 1 - j);
        }
    }

    return res;
}

int main()
{
    long long N, A, B;
    cin >> N >> A >> B;
    if (A + B > N + 1 || A * B < N)
        cout << -1 << endl;
    else
    {
        vector<long long> res = LISLDS(N, A, B);
        for (int i = 0; i < res.size(); ++i)
        {
            cout << res[i] + 1;
            if (i != (int)res.size() - 1)
                cout << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 6384
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		int x3 = x2 - (y2 - y1);
		int y3 = y2 + (x2 - x1);
		int x4 = x3 - (x2 - x1);
		int y4 = y3 - (y2 - y1);
		System.out.println(x3+" "+y3+" "+x4+" "+y4);
	}
}

Measured memory_bytes: 21844
<?php
  list($a,$b,$c,$x,$y) = explode(" ", trim(fgets(STDIN)));

  $ans = [];
  $ans[] = $a*$x+$b*$y;
  $ans[] = 2*$c*max($x,$y);
  if($x>$y){
    $ans[] = 2*$c*$y+$a*($x-$y);
  }else{
    $ans[] = 2*$c*$x+$b*($y-$x);
  }

  echo min($ans);


Measured memory_bytes: 16112
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
using namespace std;
char a[10][10];
int main(){
	for(int i=1;i<=3;i++) scanf("%s",a[i]+1);
	printf("%c%c%c\n",a[1][1],a[2][2],a[3][3]);
}

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

int main() {
int n,l;
cin >> n >> l;
int sum1 = 0;
for(int i = 1; i <= n; i++){
  sum1 += l + i -1;
}
  
int ans;
  int t = 10000;
for(int i = 1; i <= n; i++){
  
  int sum2 = sum1 - (l + i - 1);
  int x = abs(sum2-sum1); 
  if(t >= x) ans = i;
  t = x;
}
cout << sum1 - (l + ans - 1) << endl;

}
  


Measured memory_bytes: 256
H,W=map(int,input().split())
S=[list(input()) for i in range(H)]
Iplus=[[-1 for j in range(W)] for i in range(H)]
Iminus=[[-1 for j in range(W)] for i in range(H)]
Jplus=[[-1 for j in range(W)] for i in range(H)]
Jminus=[[-1 for j in range(W)] for i in range(H)]
for j in range(W):
    if S[0][j]==".":
        Iplus[0][j]=0
for i in range(1,H):
    for j in range(W):
        if S[i][j]==".":
            Iplus[i][j]=Iplus[i-1][j]+1
        else:
            Iplus[i][j]=-1
for j in range(W):
    if S[-1][j]==".":
        Iminus[-1][j]=0
for i in range(H-1)[::-1]:
    for j in range(W):
        if S[i][j]==".":
            Iminus[i][j]=Iminus[i+1][j]+1
        else:
            Iminus[i][j]=-1
for i in range(H):
    if S[i][0]==".":
        Jplus[i][0]=0
for j in range(1,W):
    for i in range(H):
        if S[i][j]==".":
            Jplus[i][j]=Jplus[i][j-1]+1
        else:
            Jplus[i][j]=-1
for i in range(H):
    if S[i][-1]==".":
        Jminus[i][-1]=0
for j in range(W-1)[::-1]:
    for i in range(H):
        if S[i][j]==".":
            Jminus[i][j]=Jminus[i][j+1]+1
        else:
            Jminus[i][j]=-1
ans=0
for i in range(H):
    for j in range(W):
        tmp=Iplus[i][j]+Iminus[i][j]+Jplus[i][j]+Jminus[i][j]+1
        if ans<tmp:
            ans=tmp
            #print(i,j,tmp)
#print(Iplus[2][5],Iminus[2][5],Jplus[2][5],Jminus[2][5])
print(ans)
#for line in Jminus:
#    print(line)
    

Measured memory_bytes: 313608
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int a[1000000];
int main()
{
	int n,s=0;
	scanf("%d",&n);
	int i,j;
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	int min=a[0];
	for(i=0;i<n;i++)
	{
		int p=1;
		
		if(a[i]>min)
		p=0;
		
		if(p==1)
		s++;
		
		if(min>a[i])
		min=a[i];
	} 
	printf("%d",s); 
}


Measured memory_bytes: 896
N = int(input())
a = 0
result = 0
for i in input():
    if i == "A":
        a = 1
    elif i == "B" and a == 1:
        a = 2
    elif i == "C" and a == 2:
        result += 1
        a = 0
    else:
        a = 0
print(result)


Measured memory_bytes: 2940
namespace Diverta2.B
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using static System.Console;

    public struct Point
    {
        public int X { get; set; }
        public int Y { get; set; }

        public static Point operator -(Point p1, Point p2) => new Point { X = p1.X - p2.X, Y = p1.Y - p2.Y };
    }

    public class Program
    {
        public static void Main()
        {
            var l = ReadInputAsInt();
            var p = ReadLinesAsPoints(l).ToList();

            WriteLine(Solve(
                l, p
                ));
        }

        public static int Solve(int n, List<Point> p)
        {
            if (n == 1) return 1;
            var distanceValues = new Dictionary<Point, int>();

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

                    var distance = p[i] - p[j];
                    if (distanceValues.ContainsKey(distance))
                    {
                        distanceValues[distance] += 1;
                    }
                    else
                    {
                        distanceValues.Add(distance, 1);
                    }
                }
            }
            return n - distanceValues.Select(kv => kv.Value).Max();
        }

        static int ReadInputAsInt() => int.Parse(ReadLine());

        static IEnumerable<Point> ReadLinesAsPoints(int lines)
        {
            for (int i = 0; i < lines; i++)
            {
                var line = ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
                yield return new Point { X = line[0], Y = line[1] };
            }
        }
    }
}


Measured memory_bytes: 15532
N,M=map(int,input().split(" "))
wars=[list(map(int,input().split(" ")))for _ in range(M)]

wars.sort(key=lambda x:x[1])

count=0
before=0

for ai,bi in wars:
    if before>ai:
        continue
        
    before=bi
    count=count+1

print(count)

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

i64 sigma(int n) { return n * (1 + n) / 2; }

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

  int a, b;
  cin >> a >> b;

  int i = 2;
  while (true) {
    if (sigma(i) - b == sigma(i-1) - a) {
      cout << sigma(i) - b << "\n";
      return 0;
    }
    ++i;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);

int main()
{
	fast
	string s;
	cin>>s;
	ll n=s.length(),c=0;
	for(ll i=0;i<n;i++)
	{
		if(i%2 && s[i]=='i')
			c++;
		else if(i%2==0 && s[i]=='h')
		c++;
	}
	if(c==n && n%2==0)
		cout<<"Yes\n";
	else
		cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
    ll t, n;
    while (cin >> t) {
        if (t == 0) break;
        cin >> n;
        ll tmp = 0;
        rep(i, n) {
            ll a, b;
            cin >> a >> b;
            tmp += b-a;
        }
        if (tmp >= t) {
            cout << "OK" << endl;
        } else {
            cout << t-tmp << endl;
        }
    }
}


Measured memory_bytes: 3116
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()

typedef tree<pair<ll,ll> ,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth smallest: " << *A.find_by_order(k-1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

ll r, c, dp[1005][1005], mod = 1e9 + 7;      // Number of paths from i, j to r - 1, c - 1
vector<string>a;

ll rec(ll i, ll j)
{
	if(a[i][j] == '#') return 0;
	if(i == r - 1 && j == c - 1) return 1;
	if(dp[i][j] != -1) return dp[i][j];
	ll ans = 0;
	if(i < r - 1)
		ans = (ans + rec(i + 1, j)) % mod;
	if(j < c - 1)
		ans = (ans + rec(i, j + 1)) % mod;
	return dp[i][j] = ans;
}

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

 	cin >> r >> c;
 	for(int i=0;i<r;i++)
 	{
 		string b;
 		cin >> b;
 		a.pb(b);
 	}   
 	memset(dp, -1, sizeof(dp));
 	cout << rec(0, 0) << endl;
    return 0;
}

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

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

  if((a==5 && b==5 && c==7) || (a==5 && b==7 && c==5) || (a==7 && b==5 && c==5))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
  char s[10],t[10],u[10];
  int a,b;
  scanf("%s%s%d%d%s",s,t,&a,&b,u);
  if(strcmp(s,u)==0)
    printf("%d %d",a-1,b);
  else
    printf("%d %d",a,b-1);
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define foreach(i,a) for(auto &i:a)
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}

void solve(){
  // input
  ll n,q; cin>>n>>q;
  vector<tuple<ll,ll,ll>> STX(n);
  rep(i,n){
    ll s,t,x; cin>>s>>t>>x;
    STX[i]=make_tuple(s,t,x);
  }
  vector<ll> D(q);
  rep(i,q){
    cin>>D[i];
  }

  // preparation
  vector<tuple<ll,ll,ll>> I;
  rep(i,n){
    ll s,t,x;
    tie(s,t,x)=STX[i];
    I.emplace_back(s-x,0,x); // 0 -> insert
    I.emplace_back(t-x,1,x); // 1 -> delete
  }
  rep(i,q){
    I.emplace_back(D[i],2,i); // 2 -> query
  }
  sort(I.begin(),I.end());
  
  // calculation
  vector<ll> ans(q);
  multiset<ll> S{INF};
  foreach(tup,I){
    ll t,q,x;
    tie(t,q,x)=tup;
    // cerr<<t<<' '<<q<<' '<<x<<endl;
    if(q==0){
      S.insert(x);
    }else if(q==1){
      S.erase(S.find(x));
    }else{
      ans[x]=*S.begin();
    }
  }

  // output
  foreach(x,ans){
    if(x==INF) x=-1;
    cout<<x<<"\n";
  }
}

Measured memory_bytes: 34020
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
typedef long long ll; 
int arr[2005], idx[2005], del[2005], n, k, q, ans = 1e9; 
std::set<int> se; 
inline int query(int pos)
{
	int res = 0; 
	for (; pos; pos -= pos & -pos)
		res += del[pos]; 
	return res; 
}
inline void modify(int pos)
{
	for (; pos <= n; pos += pos & -pos)
		del[pos]++; 
}
int main()
{
	// freopen("ARC098-E.in", "r", stdin); 
	scanf("%d%d%d", &n, &k, &q); 
	for (int i = 0; i < n; i++)
	{
		scanf("%d", arr + i); 
		idx[i] = i; 
	}
	std::sort(idx, idx + n, [&] (const int &x, const int &y) { return arr[x] < arr[y]; }); 
	for (int i = 0; i + q <= n; i++)
	{
		int cnt = 0; 
		memset(del, 0, sizeof(del)); 
		for (int j = i; j < n; j++)
		{
			int x = idx[j]; 
			auto l = se.lower_bound(x), r = l; 
			int lp = -1, rp = n; 
			if (l != se.begin())
				lp = *--l; 
			if (r != se.end())
				rp = *r; 
			if (rp - lp - 1 - (query(rp) - query(lp + 1)) >= k)
			{
				modify(x + 1); 
				cnt++; 
			}
			if (cnt >= q)
			{
				ans = std::min(ans, arr[idx[j]] - arr[idx[i]]); 
				break;
			}
		}
		se.insert(idx[i]); 
	}
	printf("%d\n", ans);
	return 0; 
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#define END "\n"
#define REP(i, a, b) for (int i = a; i < b; ++i)

using namespace std;  
typedef long long ll;

int main () {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n, count = 0;
    double x, y, d;
    cin >> n >> d;
    while(n--) {
        cin >> x >> y;
        if (sqrt(x*x + y*y) <= d) count++;
    }
    cout << count;
    return 0;
}


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

using namespace std;

int main(void)
{
	std::vector<int> d(10000);
	int x, cnt = 0;
	
	while(1)
	{
		std::cin >> x;
		
		if( x == 0 ) break;
		else d[cnt] = x;
		
		cnt++;
	}
	
	for(int i = 0; i < cnt; i++)
	{
		std::cout << "Case" << " " << i + 1 << ": " << d[i] << std::endl;
	}
	
	return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll; 
int main() {
	int N;
	cin >> N;
	char S[51] = {};
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	int R = 0;
	for (int i = 0; i < N-2; i++) {
		if (S[i] == 'A' && S[i+1]=='B' && S[i+2]=='C') {
			R++;
		}
	}
	cout << R << endl;



	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
	int t[4];
	int min = 0, sec;
	int sum;
	int i;
	
	sum = 0;
	
	for (i = 0; i < 4; i++){
		scanf("%d", &t[i]);
		sum += t[i];
	}
	
	if (sum >= 60){
		min = sum / 60;
		sec = sum % 60;
	}
	else {
		sec = sum;
	}
	
	printf("%d\n", min);
	printf("%d\n", sec);
	
	return (0);
}

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

int main() {
  double a,b,c,d;
  cin >>a >>b>>c>>d;
  a=ceil(a/d);
  c=ceil(c/b);
  if(a>=c){
    cout <<"Yes"<<endl;
  }else{
    cout <<"No"<<endl;
  }
}


Measured memory_bytes: 3724
# -*- coding: utf-8 -*-

import sys

sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
INF=float('inf')

class BIT:
    # n+1で初期化すること
    def __init__(self, n):
        # 0-indexed
        nv = 1
        while nv < n:
            nv *= 2
        self.size = nv
        self.tree = [0] * nv

    # [0, i]を合計する
    def sum(self, i):
        s = 0
        i += 1
        while i > 0:
            s += self.tree[i-1]
            i -= i & -i
        return s

    # 値の追加：添字, 値
    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i-1] += x
            i += i & -i

    # 区間和の取得 [l, r)
    def get(self, l, r=None):
        # 引数が1つなら一点の値を取得
        if r is None: r = l+1
        res = 0
        if r: res += self.sum(r-1)
        if l: res -= self.sum(l-1)
        return res

N,Q=MAP()
bit=BIT(N+1)
for _ in range(Q):
    com,x,y=MAP()
    if com==0:
        bit.add(x, y)
    else:
        print(bit.get(x, y+1))



Measured memory_bytes: 8404
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = Input.NextLong();
            int a = (int)Math.Sqrt(N);

            for (; N % a != 0; a--) {}

            Console.WriteLine(F(a, N / a));
        }

        static long F(long a, long b) {
            return (long)Math.Max(Math.Log10(a), Math.Log10(b)) + 1;
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k,n;
  cin>>k>>n;
  int arr[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];

    
  }
 
  
  
  int max=INT_MIN;
  int z;
  for(int i=1;i<n;i++)
  {
    z=abs(arr[i]-arr[i-1]);
    if(z>max)
    {
      max=z;
      
      
    }
  }
    int x=k-arr[n-1]+arr[0];
    if(x>max)
      max=x;
    cout<<(k-max)<<endl;

    
  }

  
  
  
  


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

vector<vector<int>> v;
vector<bool> vis;

int cc(int cur) {
	if (vis[cur])
		return 0;

	vis[cur] = true;
	int c = 1;

	for (auto e: v[cur])
		c += cc(e);
	
	return c;
}

int main() {

	IOS

	int n, m;
	cin >> n >> m;

	v.resize(n+1);
	vis.resize(n+1, false);

	int x, y;

	for (int i = 0; i < m; i++) {
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}

	int c = 0, mx = 0;
	for (int i = 1; i <= n; i++) {
		c = cc(i);
		mx = max(c, mx);
	}

	cout << mx;

	return 0;
}

Measured memory_bytes: 20252
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x;cin>>x;
    int ans=x;
    bool key=true;

    while(key){
        int i;
        for(i=2;i<ans;i++){
            if(ans%i==0){
                ans++;
                break;
            }
        }
        if(i==ans){
            key=false;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x),end()
typedef long long ll;
using namespace std;
int main(){
    string S;
    cin >> S;
    cout << ((S == "ARC") ? "ABC" : "ARC") << endl;
}


Measured memory_bytes: 3636
n = gets.to_i
peoples = []
n.times do
  a = gets.to_i
  tms = []
  a.times do
    tms.push(gets.split.map(&:to_i))
  end
  peoples.push(tms)
end

max = 0

[0, 1].repeated_permutation(n) do |bits|
  i = 0
  everyoneHonest = true
  bits.each do |bit|
    if bit == 1
      tms = peoples[i]
      tms.each do |tm|
        if bits[tm[0] - 1] != tm[1]
          everyoneHonest = false
          break
        end
      end
    end
    if everyoneHonest == false
      break
    end
    i += 1
  end
  if everyoneHonest
    max = [max, bits.count(1)].max
  end
end

print max

Measured memory_bytes: 3964
using System;
using System.Collections.Generic;
class Program
    {
        static void Main(string[] args)
        {
            string[] s1 = Console.ReadLine().Split(' ');
            int w = int.Parse(s1[0]), h = int.Parse(s1[1]), x = int.Parse(s1[2]), y = int.Parse(s1[3]);
            double s = (double)w * h / 2.0;
            if (x * 2 == w && y * 2 == h) Console.WriteLine(s + " " + 1);
            else Console.WriteLine(s + " " + 0);
            
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 11092
x = int(input())
depo = 100
for i in range(1,10000):
    depo = int(depo * 1.01)
    #print(depo)
    if depo >= x:
        print(i)
        break

### C++と同じく、実行は、Opt + Ctl + N

'''
# -*- coding: utf-8 -*-
# get a integer
a = int(input())
# get two integers separated with half-width break
b, c = map(int, input().split())
# get a string
s = input()
# output
print('{} {}'.format(a+b+c, s))
'''


Measured memory_bytes: 9164
#include <iostream>
#include <algorithm>
#include <string>

bool is_pal(std::string s)
{
  size_t l = s.size();
  std::reverse(s.begin() + ((l + 1) / 2), s.end());
  return std::equal(s.begin(), s.begin() + (l / 2), s.begin() + ((l + 1) / 2), s.end());
}

int main()
{
  std::string s;
  std::cin >> s;
  size_t l = s.size();
  if (is_pal(s) && is_pal(s.substr(0, (l / 2))) && is_pal(s.substr(l - (l / 2))))
  {
    std::cout << "Yes";
  }
  else
  {
    std::cout << "No";
  }
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; string S;
    cin >> N >> S;
    int right = 0, left = 0;
    for(int i = 0; i < N; i++) {
        char s = S.at(i);
        if(s=='(') left++;
        if(s==')') {
            if(left>0) left--;
            else right++;
        }
    }
    
    string l, r;
    for(int i = 0; i < right; i++) l += '(';
    for(int i = 0; i < left; i++) r += ')';
    cout << l << S << r << endl;
}


Measured memory_bytes: 256
/*
    Problem 20
    https://atcoder.jp/contests/abc077/tasks/arc084_a
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 1000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
vector<int> a, b, c;
int n;
/* function */
int bin1(int x) {
    int ok = 0;
    int ng = n+2;
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (a[mid] < x) ok = mid;
        else ng = mid;
    }
    return ok;
}
int bin2(int x) {
    int ok = n+1;
    int ng = -1;
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (x < c[mid]) ok = mid;
        else ng = mid;
    }
    return ok;
}
/* main */
int main(){
    cin >> n;
    a.resize(n);
    b.resize(n);
    c.resize(n);

    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) cin >> c[i];

    a.push_back(-1), a.push_back(INF);
    c.push_back(-1), c.push_back(INF);
    sort(a.begin(), a.end());
    sort(c.begin(), c.end());

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += (ll)bin1(b[i]) * (ll)(n+1 - bin2(b[i]));
    }
    cout << ans << '\n';
}

Measured memory_bytes: 4796
let n, m, g, c = Scanf.scanf " %d %d" @@ fun a b -> a, b, Array.make a [], ref 0
let f v u = g.(v - 1) <- u - 1 :: g.(v - 1)
let es = Array.init m @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> f a b; f b a; [a - 1; b - 1]
let rec h v e vs = vs.(v) <- true; incr c; List.(iter (fun u -> if not (vs.(u) || mem v e && mem u e) then h u e vs) g.(v))
let _ = Array.(fold_left (fun b e -> c := 0; h 0 e @@ make n false; if !c < n then b + 1 else b) 0 es) |> Printf.printf "%d\n"

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

class UnionFind {
public:
	vector<int>par, rank, node;
	UnionFind(int n) :par(n), rank(n, 0),node(n,1) {
		for (int i = 0;i < n;i++)par[i] = i;
	}
	void init(int n) {
		for (int i = 0;i < n;i++) {
			par[i] = i;
			rank[i] = 0;
			node[i] = 1;
		}
	}

	int find(int x) {
		return par[x] == x ? x : par[x] = find(par[x]);
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}

	void unite_tree(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (rank[x] == rank[y])rank[x]++;
		}
	}
	int root_size(int x){
		return rank[find(x)];
	}

	int size(int x) {
		return node[find(x)];
	}

	void unite_node(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (size(x) < size(y))swap(x, y);
		node[x] += node[y];
		par[y] = par[x];
	}
};

int main(void){
    ll n,m;
    cin>>n>>m;
    vector<ll>ans(m);
    ll t = n*(n-1)/2;
    vector<ll>a(m),b(m);
    for(ll i=0;i<m;i++)cin>>a[i]>>b[i];
    UnionFind uf = UnionFind(n+1);
    ll q=0;
    for(int i=m-1;i>=0;i--){
        ans[i]=t-q;
        ll p1 = uf.find(a[i]);
        ll p2 = uf.find(b[i]);
        if(p1 == p2){
            uf.unite_node(a[i],b[i]);
            continue;
        }
        else{
            p1=uf.size(a[i]);
            p2=uf.size(b[i]);
            if(p1==1 && p2==1)q++;
            else{
                if(p1==1)q=q-p2*(p2-1)/2+(p1+p2)*(p1+p2-1)/2;
                else{
                    if(p2==1)q=q-p1*(p1-1)/2+(p1+p2)*(p1+p2-1)/2;
                    else{
                        q=q-p1*(p1-1)/2-p2*(p2-1)/2+(p1+p2)*(p1+p2-1)/2;
                    }
                }
            }
            uf.unite_node(a[i],b[i]);
        }
    }
    for(ll i=0;i<m;i++)cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 4864
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
W = [list(map(int, input().split())) for i in range(m)]

vmin = min(A) + min(B)
for i in range(m):
    v = A[W[i][0]-1] + B[W[i][1]-1] - W[i][2]
    vmin = min(vmin, v)

print(vmin)


Measured memory_bytes: 82156
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int n;cin>>n;
	rep(i,n){
		string s;
		cin>>s;
		if(s.size()==1){
			cout<<0<<endl;
			continue;
		}
		int t;
		convert(s,t);
		vint v(4000000,0);
		v[t]=1;
		int ans=0;
		while(1){
			int M=0;
			if(s.size()==1){
				break;
			}
			reep(i,1,s.size()){
				int x,y;
				convert(s.substr(0,i),x);
				convert(s.substr(i),y);
				M=max(M,x*y);
			}
			if(v[M]){
				ans=-1;
				break;
			}
			v[M]=1;
			convert(M,s);
			ans++;
		}
		cout<<ans<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

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

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef vector<vector<pair<long long,long long>>> vvpl;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
/*ios_base::sync_with_stdio(false);cin.tie(0);*/

ll gcd(ll n,ll m){
    if (n==0)return m;
    return gcd(m%n,n) ;
}

long long fast_exp(long long n,long long k){
    if(k == 0)
        return 1;
    if(k==1)
        return n;

    long long temp = fast_exp(n,k>>1);

    if((k&1)==1)
        return (n*temp*temp)%SIZE;
    return (temp*temp)%SIZE;

}

int main() {
   ll n;
   cin >>n;
   vi vec(n);
    for (int i = 0; i <n ; ++i) {
        cin>> vec[i];
    }
    sort(BEND(vec));
    double sum = (vec[0]+vec[1])/2.0;
    for (int i = 2; i <n ; ++i) {
        sum = (sum + vec[i])/2.0;
    }
   printf("%.10lf",sum);

    return 0;
}



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

#pragma warning(disable:4996)
using namespace std;

typedef int Value1;
typedef int Value2;
const Value1 Zero1(10000000);
const Value2 Zero2(0);

struct Node {
	Value1 sum;//更新された値. この値を参照する時は評価が完全に完了しているようにする.
	Value2 lazy;	//遅延されている値を保存している
	Node() :sum(Zero1) {
		lazy = Zero2;
	}
};
struct lazy_segtree {
	int N;
	vector<Node>dat;
	lazy_segtree(int n) :N(1) {
		while (N < n) N *= 2;
		dat.resize(2 * N);
		for (int i = N - 1; i >= 1; --i) {
			update_node(i);
		}
	}

	Value2 lazy_connect(const Value2 l, const Value2 r) {
		return l+r;
	}

	void lazy_func(const int k, const int a, const int b) {
		dat[k].sum+=dat[k].lazy;
	}

	Value1 connect(const Value1 l, const Value1 r) {
		return min(l,r);

	}

	// inlineつけないと大変なことになるよ!(遅い)
	inline void lazy_evaluate_node(int k, int a, int b) {
		lazy_func(k, a, b);
		if (k < N) { // 2*k(左の子番号) < 2*N (節点の数) のイメージで. 末端ノードじゃなきゃ伝搬するのと等価.
			dat[2 * k].lazy = lazy_connect(dat[2 * k].lazy, dat[k].lazy);	//次は君が伝搬してね☆って感じ.
			dat[2 * k + 1].lazy = lazy_connect(dat[2 * k + 1].lazy, dat[k].lazy);
		}
		dat[k].lazy = Zero2;
	}

	inline void update_node(int k) { // kの子が既に評価されていることが前提. 末端以外のときしか呼び出さないような位置に書くのでif文要らない.
		dat[k].sum = connect(dat[2 * k].sum, dat[2 * k + 1].sum);

	}

	// update(l,r,v) := [l,r)を更新する. 区間は0-indexed.
	void update(int l, int r, Value2 v, int k = 1, int a = 0, int b = -1) {
		if (b == -1)b = N;
		if (l < 0 || r < 0)assert(false);
		lazy_evaluate_node(k, a, b); 	// とりあえず辿ったノードは都合がいいので伝搬しとけ精神.

		if (b <= l || r <= a) //[a,b)と[l,r)が交差している場合
			return;
		if (l <= a && b <= r) { // [l,r)が[a,b)を完全に含んでいる場合
			dat[k].lazy = lazy_connect(dat[k].lazy, v);
			lazy_evaluate_node(k, a, b); //一回遅延評価しとかないと都合悪いので.
			return;
		}

		int m = (a + b) / 2;
		update(l, r, v, 2 * k, a, m);
		update(l, r, v, 2 * k + 1, m, b);
		update_node(k);
	}
	//get(l,r) := [l,r)に対するクエリの答えを得る. 区間は0-indexed.
	Value1 get(int l, int r, int k = 1, int a = 0, int b = -1) {
		if (b == -1)b = N;

		if (l < 0 || r<0)assert(false);
		lazy_evaluate_node(k, a, b); // とりあえず辿ったノードは都合がいいので伝搬しとけ精神.

		if (b <= l || r <= a) //[a,b)と[l,r)が交差している場合
			return Zero1;

		if (l <= a && b <= r) { // [l,r)が[a,b)を完全に含んでいる場合
			return dat[k].sum;
		}

		int m = (a + b) / 2;
		Value1 vl = get(l, r, 2 * k, a, m);
		Value1 vr = get(l, r, 2 * k + 1, m, b);
		update_node(k);
		return connect(vl, vr);
	}
};
int main() {
	string ast;cin>>ast;
	bool ok=false;
	for (int l = 0; l <= ast.size(); ++l) {
		for (int r = l; r <= ast.size(); ++r) {
			string left=ast.substr(0,l);
			string right=ast.substr(r,ast.size()-r);
			string answer=left+right;
			if (answer == "keyence") {
				ok=true;
			}
		}
	}
	if (ok) {
		cout<<"YES"<<endl;
	}
	else {
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back

using namespace std;

int x,y;

int main()
{
    cin >> x;
    for (int i=1;i<10;i++)
    {
        for (int j=1;j<10;j++)
        {
            if (i*j==x)
            {
                cout << "Yes\n";return 0;
            }
        }
    }
    cout << "No\n";
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n=int(input())\n"
"c=10**18\n"
"for a in range(1,n):\n"
"    b=n-a\n"
"    c=min(c,sum(map(int,str(a)))+sum(map(int,str(b))))\n"
"print(c)\n"
"\"";
  system(s);
  return 0;
}            

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

#define pb push_back
#define fi first
#define se second
#define eb emplace_back

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int N = 1000007, inf = 0x3f3f3f3f;

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

	char c; cin >> c;

	if(c >= 'a' and c <= 'z') cout << 'a' << endl;
	else cout << "A" << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

ll Mod = 1e9 + 7;
int main()
{
    int N;
    cin >> N;

    cout << "ABC" << N << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int c;
int main() {
	int x, y;
	cin >> x >> y;
	if (x == y && x == 2) {
		cout << "Yes" << endl;
	}
	else if ((x == 4 || x == 6 || x == 9 || x == 11) && (y == 4 || y == 6 || y == 9 || y == 11)) {
		cout << "Yes" << endl;
	}
	else if ((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <atcoder/dsu>

int main() {
  int N, M;
  std::cin >> N >> M;
  atcoder::dsu d(N);
  for (int i = 0; i < M; i++) {
    int Ai, Bi;
    std::cin >> Ai >> Bi;
    d.merge(Ai - 1, Bi - 1);
  }
  std::cout << d.groups().size() - 1 << std::endl;
}


Measured memory_bytes: 8260
#include<stdio.h>
#include<math.h>

int main(void)
{
	int a, b, sum, out;
	while(scanf("%d %d",&a,&b) != EOF)
	{
		sum = a + b;
		out = (int)log10((float)sum) + 1;
		printf("%d\n",out);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

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

  int ans;
  for(int i = 1; i*i <= n; i++)
    ans = i*i;
  
  cout << ans << endl;
}

Measured memory_bytes: 3560
I=input;R=range;n=int(I())
lf=[int(I()[::2],2) for _ in R(n)]
lp=[list(map(int,I().split())) for _ in R(n)]
print(max(sum(p[bin(i&f).count('1')] for f,p in zip(lf,lp)) for i in R(1,1024)))

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

const int INF = 1e9;

int N;
int v [29][51];

int main() {

  cin >> N;

  for(int i = 0; i < N; i++) {
    string S;
    cin >> S;

    for(int j = 0; j < S.length(); j++) {
      v[S[j] - 'a'][i]++;
    }
  }

  for(int i = 0; i < 29; i++) {
    int mmin = INF;
    for(int j = 0; j < N; j++) {
      mmin = min(mmin,v[i][j]);
    }
    char tmp = i + 'a';
    for(int k = 0; k < mmin; k++) cout <<tmp;
  }

  return 0;
}
  
  


Measured memory_bytes: 256
def judge(s):
    l=len(s)
    if l%2 ==0 and s[:l//2]==s[l//2:]:
        return True
    else:
        return False
s=input()
for i in reversed(range(1,len(s))):
    ns=s[:i]
    if judge(ns):
        print(len(ns))
        exit(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
typedef long long int lli;

long long int min(long long int a,long long int b){
  if(a<b)
    return a;
  else
    return b;
}
typedef pair<lli,lli> pii;
typedef vector<int> vi;


void solve(){
  int n;
  cin>>n;
  vi a(n),b(n);
  for(int i = 0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());

  int meda = (n%2==0)?(a[(n-1)/2]+a[(n-1)/2+1]):(a[(n-1)/2]);
  int medb = (n%2==0)?(b[(n-1)/2]+b[(n-1)/2+1]):(b[(n-1)/2]);

  cout<<medb-meda+1;

}


int main(){
  int t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}

Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,D;
    cin>>N>>D;
    cout<<(N+2*D)/(2*D+1)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#define PI 3.141592653589;
#include<stdio.h>
using namespace std;
int main()
{
	double r;
	cin >> r;
	double a = r*r*PI; 
	double b = r * 2 * PI;
	printf("%lf %lf\n", a, b);

	return 0;
}


Measured memory_bytes: 3292
inputed_info = input()

A = int(inputed_info[0:inputed_info.find(" ")])
inputed_info = inputed_info[inputed_info.find(" ")+1:]
B = int(inputed_info[0:inputed_info.find(" ")])
inputed_info = inputed_info[inputed_info.find(" ")+1:]
C = int(inputed_info)

C_after = C - A + B

if C_after > 0:
	print(C_after)
else:
	print('0')


Measured memory_bytes: 3060
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
#include <climits>

using namespace std;

int main()
{
    int numm[30] = { 0 };
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        numm[s[i] - 'a'] += 1;

    }

    for (int i = 0; i < 26; i++)
    {
        if (numm[i]%2 != 0)
        {
            cout << "No";
            return 0;

        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 3548