akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1e18;

const ll max_V=305;//制約に注意

ll d[max_V][max_V];
ll N,M;
ll nex[max_V][max_V];//経路復元
ll add_d[max_V][max_V];

//d[i][j]の入力の前にINFに初期化せよ!!!

void warshall_floyd(){
    for(ll i=0;i<N;i++){
        for(ll j=0;j<N;j++) nex[i][j]=j;
    }
    for(ll k=0;k<N;k++){
        for(ll i=0;i<N;i++){
            for(ll j=0;j<N;j++){
                if(d[i][j]>d[i][k]+d[k][j]){
                    d[i][j]=d[i][k]+d[k][j];
                }
            }
        }
    }
}

int main(){
    ll L;
    cin>>N>>M>>L;
    rep(i,N){
        rep(j,N){
            d[i][j]=INF;
            add_d[i][j]=INF;
        }
    }
    rep(i,M){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        d[a][b]=c;
        d[b][a]=c;
    }
    warshall_floyd();
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(d[i][j]<=L){
                add_d[i][j]=1;
                add_d[j][i]=1;
            }
        }
    }
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(add_d[i][j]>add_d[i][k]+add_d[k][j]){
                    add_d[i][j]=add_d[i][k]+add_d[k][j];
                }
            }
        }
    }
    int Q;
    cin>>Q;
    while(Q--){
        int s,t;
        cin>>s>>t;
        s--;t--;
        if(add_d[s][t]==INF) cout<<-1<<endl;
        else cout<<add_d[s][t]-1<<endl;
    }
}

Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {

    static final int INF = Integer.MAX_VALUE;

    static class Key {
        int cost;
        int boxes;

        public Key(int cost, int boxes) {
            this.cost = cost;
            this.boxes = boxes;
        }
    }

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

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

        Key[] keys = new Key[M];
        for (int i = 0; i < M; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int boxes = 0;
            for (int j = 0; j < b; j++) boxes += (1 << sc.nextInt() - 1);
            // System.out.println(Integer.toBinaryString(boxes));
            keys[i] = new Key(a, boxes);
        }

        int[][] dp = new int[M + 1][1 << N];
        for (int i = 1; i < 1 << N; i++) {
            dp[0][i] = INF;
        }
        for (int i = 1; i <= M; i++) {
            for (int j = 0; j < 1 << N; j++) {
                dp[i][j] = dp[i - 1][j];
            }
            Key key = keys[i - 1];
            for (int j = 0; j < 1 << N; j++) {
                int k = j | key.boxes;
                if (dp[i - 1][j] == INF) continue;
                dp[i][k] = Math.min(dp[i][k], dp[i - 1][j] + key.cost);
            }
        }

        System.out.println(dp[M][(1 << N) - 1] == INF ? -1 : dp[M][(1 << N) - 1]);
    }
}


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

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

int n, a, b;

int main() {
  cin >> n >> a >> b;
  a %= 2;
  b %= 2;
  if (a == b) puts("Alice");
  else puts("Borys");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n=0,sum=0;
  char c;
  while((c=getchar())!=EOF){
    if(c>='0'&&c<='9'){
      n*=10;
      n+=(c-('0'));
    }
    else{
      sum+=n;
      n=0;
    }
  }
  cout<<sum<<endl;
}

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

# https://atcoder.jp/contests/abc053/tasks/abc053_b

def main():
    s = raw_input()
    st = s.find('A')
    en = s[::-1].find('Z')
    print((len(s) - en) -st)

    

if __name__ == "__main__":
    main()


Measured memory_bytes: 3304
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <string>
#include <cmath>
#include <vector>
#include <list>

#include <random>
using namespace std;

int main(void) {
	int A, B, C, D, E, F;
	scanf("%d", &A);
	scanf("%d", &B);
	A *= 100;
	B *= 100;
	scanf("%d", &C);
	scanf("%d", &D);
	scanf("%d", &E);
	scanf("%d", &F);

	vector<bool> w = vector<bool>(F+1, false);
	w[A] = true;
	if (B <= F) {
		w[B] = true;
	}
	vector<bool> s = vector<bool>(F+1, false);
	s[0] = true;
	for (int i = 0; i <= F; i++) {
		if (w[i]) {
			if (i + A <= F) {
				w[i + A] = true;
			}
			if (i + B <= F) {
				w[i + B] = true;
			}
		}
		if (s[i]) {
			if (i + C <= F) {
				s[i + C] = true;
			}
			if (i + D <= F) {
				s[i + D] = true;
			}
		}
	}

	double maxRatio = -1;
	int maxWater = A;
	int maxSuger = 0;
	for (int i = 100; i < F; i += 100) {
		if (!w[i]) {
			continue;
		}
		int suger = i * E/100;
		for (int k = suger; k >= 0; k--) {
			if (!s[k]) {
				continue;
			}

			if (i + k <= F) {
				if (((double)k / i) > maxRatio) {
					maxWater = i;
					maxSuger = k;
					maxRatio = (double)k / i;
				}
				break;
			}
		}
	}

	printf("%d %d\n", maxWater+maxSuger, maxSuger);

	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        if ((i + 1) % 2 == 1 && t % 2 == 1)
        {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3628
n, y = map(int, input().split())

man = y//10000

ans = 0
for i in range(man+1):
  mansatsu = i*10000
  for j in range(n-i+1):
    temp = mansatsu + j*5000
    if y - temp == 1000*(n-(i+j)):
      print(i,j,n-(i+j))
      ans = 1
      break
  else:
    continue
  break
if ans == 0:
  print("-1 -1 -1")

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

int main()
{
	int n, m;
	cin >> n >> m;
	vector<pair<int,int>> interval;
	for(int i = 0; i < m; i++){
		int a,b;
		cin >> a >> b;
		interval.push_back(make_pair(b-1,a));
	}
	sort(interval.begin(), interval.end());
	reverse(interval.begin(), interval.end());
	int ans = 0;
	while(!interval.empty()){
		ans++;
		int r = interval.back().first;
		//cout << r << " ";
		interval.pop_back();
		for(int i = interval.size()-1; i >= 0; i--){
			if(interval[i].second <= r)
				interval.erase(interval.begin()+i);
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1400
def main():
    h,w,n=map(int,input().split())
    sr,sc=map(int,input().split())
    s=input()
    t=input()

    xl,xr,yu,yd = sc,sc,sr,sr

    for i in range(n):
        if s[i] == "L":
            xl -= 1
        if s[i] == "R":
            xr += 1
        if s[i] == "U":
            yu -= 1
        if s[i] == "D":
            yd += 1
        if xl <= 0 or xr > w or yu <= 0 or yd > h:
            return "NO"
        if t[i] == "R" and xl < w:
            xl += 1
        if t[i] == "L" and xr > 1:
            xr -= 1
        if t[i] == "D" and yu < h:
            yu += 1
        if t[i] == "U" and yd > 1:
            yd -= 1
    
    return("YES")
print(main())

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

int fromT[100001];
int fromA[100001];
vector <int>path[100001];

void path_calc(int target, int array[]) {
	for (int i = 0; i < path[target].size(); i++) {
		int next = path[target].at(i);
		if (array[next] != -1) continue;
		array[next] = array[target] + 1;
		path_calc(next, array);
	}
}

void path_calcT(int target, int array[]) {
	for (int i = 0; i < path[target].size(); i++) {
		int next = path[target].at(i);
		if (array[next] != -1) continue;
		array[next] = array[target] + 1;
		// 青木君につかまる場合はその先に行かない
		if (array[next] >= fromA[next]) continue;
		path_calc(next, array);
	}
}

int main(void) {
	int N;
	cin >> N;
	for (int i = 0; i <= N; i++) {
		fromT[i] = fromA[i] = -1;
		path[i].clear();
	}
	int u, v;
	cin >> u >> v;
	fromT[u] = fromA[v] = 0;

	for (int i = 1; i < N; i++) {
		int A, B;
		cin >> A >>B;
		path[A].push_back(B);
		path[B].push_back(A);
	}
	path_calc(v, fromA);
	path_calcT(u, fromT);

	// T > A で一番大きいところを見つける
	int catch_pos = 0;
	int Amoves = 0;
	for (int i = 1; i <= N; i++) {
		if (fromT[i]==-1) continue;
		if (fromT[i] <= fromA[i]) {
			if (Amoves < fromA[i]) {
				Amoves = fromA[i];
				catch_pos = i;
			}
		}
	}
	cout << Amoves - 1 << endl;

	return 0;
}


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


void Ex_gcd(int a,int b,int& x,int& y){
	if(!b){
		x = 1;y = 0;return;
	}
	Ex_gcd(b,a % b,y,x);
	y -= a / b * x;
}
int _,__;
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	Ex_gcd(a,b,_,__);
	printf("%d %d\n",_,__);
	return 0;
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> anys;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(anys{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

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

	cout << setprecision(20) << 2*M_PI*R << endl;

	return 0;
}


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

using ll = long long;
using ld = long double;

int main()
{
    string a,b;
    cin >> a >> b;
    
    int n = stoi(a+b);
    bool ok = false;
    
    for(int i = 1; i*1 <= n; i++)
    {
        if(i*i==n)
        {
            ok = true;
            break;
        }
    }
    if(ok)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)
#define pd(x) printf("%lf\n", x)
#define ps(x) printf("%s\n", x)
 
#define INF 1000000000000000000
#define MOD 1000000007
 
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))

int compare_long(const void *a, const void *b) {
	return *(long*)a - *(long*)b;
}
 
int main() {
	long X;
	long sum = 0;
	long i, j;
	
	sl(X);
	
	for(i=1;i<=X;i++) {
		sum += i;
		if(sum >= X) {
			break;
		}
	}
	
	pl(i);
	
	return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] v = new int[N];
        for (int i = 0; i < N; i++) {
            v[i] = sc.nextInt();
        }
        Arrays.sort(v);
        double ans = v[0];
        for (int i = 1; i < N; i++) {
            ans = (double)(ans + v[i]) / 2;
        }
        System.out.print(ans);
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}

Measured memory_bytes: 22100
#include<bits/stdc++.h>
#define MAXN 400005
#define INF 1000000000
#define MOD 998244353
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n;
string str;
void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;}
void dec(int &a,int b) {a-=b; if(a<0) a+=MOD;}
int res[MAXN];
int get_val(string str)
{
    int x=0;
    for(int i=0;i<(int)str.size();i++)
    {
        x=2LL*x%MOD;
        if(str[i]=='1') add(x,1);
    }
    return x+1;
}
bool check(string x)
{
    int m=x.size();
    string rx=x; for(int i=0;i<m;i++) rx[i]=('0'+'1'-rx[i]);
    string ss="";
    string tmp=str; for(int i=0;i<n;i++) tmp[i]=('0'+'1'-tmp[i]);
    for(int i=0;i<(2*n/m);i++)
    {
        if(i&1) ss+=rx;
        else ss+=x;
    }
    for(int i=0;i<(2*n)%m;i++)
    {
        if((n/m)&1) ss+=rx[i];
        else ss+=x[i];
    }
    return ss<=(str+tmp);
}
int get_ans(int x)
{
    if((2*n/x)%2==0) return 0;
    string t=str.substr(0,x/2);
    int ret=get_val(t);
    if(!check(t)) dec(ret,1);
    return ret;
}
int main()
{
    scanf("%d",&n);
    cin>>str;
    int ans=0;
    for(int i=1;i*i<=2*n;i++)
    {
        if(2*n%i) continue;
        res[i]=get_ans(i);
        res[2*n/i]=get_ans(2*n/i);
    }
    for(int i=1;i<=2*n;i++)
    {
        add(ans,1LL*i*res[i]%MOD);
        for(int j=2*i;j<=2*n;j+=i) if(res[j]) dec(res[j],res[i]);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 2088
import bisect
n = int(input())
ps = [0] * (1 << 16)
for i in range(1 << 16):
    temp = 0
    x = 1    
    for j in range(16):
        if (i >> j) & 1:
#                temp += (-2) ** (2 *j)
            temp += x
        x *= 4
    ps[i] = temp

pattern1 = None
pattern2 = None

for i in range(1 << 16):
    temp2 = 0
    x = 2
    for j in range(16):
        if (i >> j) & 1:
#                temp2 += (-2) ** (2 *j + 1)
            temp2 += x
        x *= 4
    n2 = n + temp2
    pattern1 = bisect.bisect_left(ps, n2)
    if pattern1 != (1 << 16) and ps[pattern1] == n2:
        pattern2 = bin(i)[2:].zfill(16)
        pattern1 = bin(pattern1)[2:].zfill(16)
        break

ans = ""
for i in range(16):
    ans += pattern2[i]
    ans += pattern1[i]
    
true_ans = ""
flag = False
for i in range(len(ans)):
    if ans[i]=="1":
        true_ans += "1"
        flag = True
    elif flag:
        true_ans += "0"

if true_ans == "":
    true_ans = "0"
        
print(true_ans)

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

int main(void){
    char a,b,c,d;
    string answer = "No";
    cin >>  a >> b >> c >> d;
    if(a ==b && b == c) answer = "Yes";
    if(b == c && c == d) answer = "Yes";

    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
class Node:
	def __init__(self, key):
		self.key = key
		self.left = self.right = self.parent = None

class BST:
	def __init__(self):
		self.root = None
	
	def insert(self, key):
		new = Node(key)
		parent = None
		current = self.root
		while current != None:
			parent = current
			if key < current.key:
				current = current.left
			else:
				current = current.right
		if parent == None:
			self.root = new
		elif key < parent.key:
			parent.left = new
		else:
			parent.right = new		
	
	def find(self, key):
		return
		
	def delete(self, key):
		return
	
	def print(self):
		self.print_in_order(self.root)
		print()
		self.print_pre_order(self.root)
		print()
		
	def print_in_order(self, node):
		if node != None:
			self.print_in_order(node.left)
			print(' ' + str(node.key), end='')
			self.print_in_order(node.right)
		
	def print_pre_order(self, node):
		if node != None:
			print(' ' + str(node.key), end='')
			self.print_pre_order(node.left)
			self.print_pre_order(node.right)		

n = int(input())
bst = BST()
for i in range(n):
	cmd = list(map(str, input().split()))
	if cmd[0] == 'print':
		bst.print()
	else:
		key = int(cmd[1])
		if cmd[0] == 'insert':
			bst.insert(key)
		elif cmd[0] == 'find':
			bst.find(key)
		else:
			bst.delete(key)



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

int N;
int A[20], B[20];
int dp[1<<20][20];
 
signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    
    rep(S, 1<<N) rep(i, N) dp[S][i] = 10000;
    rep(i, N) dp[1<<i][i] = 0;
    
    for (int S=1; S<(1<<N); S++) {
        int cnt = 0;
        rep(i, N) if ((S>>i)&1) cnt++;
        rep(i, N) {
            if (!((S>>i)&1)) continue;
            int prev;
            if ((cnt-i)%2==0) prev = B[i];
            else prev = A[i];
            int cost = 0;
            for (int j=N-1; j>=0; j--) {
                if ((S>>j)&1) {
                    cost++;
                    continue;
                }
                int now;
                if ((cnt-j)%2==0) now = A[j];
                else now = B[j];
                if (prev>now) continue;
                dp[S|(1<<j)][j] = min(dp[S|(1<<j)][j], dp[S][i]+cost);
            }
        }
    }
    
    int ans = 10000;
    rep(i, N) ans = min(ans, dp[(1<<N)-1][i]);
    if (ans==10000) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 44552
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int64_t a,b,c,d;
void solve(){
    d=c-a-b;
    if(d>0&&4*(a*b)<d*d) {
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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

    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define itn int
#define gI gi

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

int n, m, x, y, z, a[5];

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	cin >> a[1] >> a[2] >> a[3];
	sort(a + 1, a + 1 + 3);
	if ((a[1] == a[2] && a[2] != a[3]) || (a[2] == a[3] && a[1] != a[2])) cout << "Yes" << endl;
	else cout << "No" << 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++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef vector<int> VI;
typedef pair<int,int> P;

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

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

    int n,d,a;
    while(cin>>n>>d>>a,n)
    {   
        VI v(n); 
        REP(i,n) v[i]=i+1;
        
        int pos=a-1;
        while(v.size()>1){
            v.erase(v.begin()+pos);
            pos=(pos+d-1)%v.size();
        }
        cout<<v[0]<<endl;
    }
}


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

int main() {
  ll n;
  cin>>n;
  vector<ll> vec(n);
  ll sumall=0;
  rep(i,0,n){
    cin>>vec.at(i);
    sumall+=vec.at(i);
  }
  
  ll sum=0;
  
  rep(i,0,n){
    sumall-=vec.at(i);
    sum+=vec.at(i)*(sumall%1000000007);
    if(sum>=1000000007){
      sum%=1000000007;
    }
  }
  cout<<sum;
}

Measured memory_bytes: 4840
#include<algorithm>
#include<cstdio>
int n,num[200500],t=0;
int main()
{
	scanf("%d",&n);
	for(;t<n;t++)
	{
		scanf("%d",&num[t]);
	}
	std::sort(num,num+n);
	n==std::unique(num,num+n)-num?printf("YES"):printf("NO");
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
  map<int,int> a,b;
  int n,m,c;
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>c;
    a[c]++;
  }
  cin>>m;
  for(int i=0;i<m;++i){
    cin>>c;
    b[c]++;
  }
  bool ans=true;
  for(auto&e:b){
    if(e.second>a[e.first])ans=false;
  }
  if(ans)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 18944
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
int main(){
FASTIO;
ll n;
cin>>n;
pair<ll,ll> dist[n];
ll case1[n];
for(int i=0;i<n;i++){
    cin>>dist[i].ff>>dist[i].ss;
    case1[i]=dist[i].ff+dist[i].ss;
}
sort(case1,case1+n);
ll maxi=0;
for(int i=0;i<n;i++){
    ll cur=dist[i].ff+dist[i].ss;
    maxi=max(maxi,cur-case1[0]);
    maxi=max(maxi,case1[n-1]-cur);
}

ll case2[n];
for(int i=0;i<n;i++){
    case2[i]=dist[i].ff-dist[i].ss;
}
sort(case2,case2+n);
for(int i=0;i<n;i++){
    ll cur=dist[i].ff-dist[i].ss;
    maxi=max(maxi,cur-case2[0]);
    maxi=max(maxi,case2[n-1]-cur);
}
cout<<maxi<<endl;
}


Measured memory_bytes: 9916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////


#define N 2000004

ll kai[N];
ll kai2[N];
ll po(ll i,ll p){
    if(p==0)return 1;
    else{
        i=mod(i);
        if(p==1)return i;
        if(p%2==0)return po(mod(i*i),p/2);
        return mod(i*po(i,p-1));
    }
}
void calc(){
    kai[0]=1;
    kai2[0]=1;
    rep(i,1,N-1){
        kai[i]=mod(kai[i-1]*i);
    }
    kai2[N-1]=po(kai[N-1],i_5);
    for(ll i=N-2;i>=0;i--){
        kai2[i]=mod(kai2[i+1]*(i+1));
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    if(n==0)return 1;
    return mod(mod(kai[n]*kai2[n-k])*kai2[k]);
}
ll bunbo(ll n){
    return po(n,i_5);
}

int main(){fastio
    
    calc();
    
    ll x,y;cin>>x>>y;
    if((x+y)%3!=0){
        cout<<0<<endl;return 0;
    }
    ll n=(x+y)/3;
    x-=n;
    y-=n;
    if(x<0||y<0){
        cout<<0<<endl;return 0;
    }
    cout<<comb(x+y,x)<<endl;
    
    
    return 0;
}


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

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

    string ans;

    if (r < 1200) {
        ans = "ABC";
    } else if (1200 <= r and r < 2800) {
        ans = "ARC";
    } else {
        ans = "AGC";
    }

    cout << ans << endl;
}

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

constexpr long M = 2*1000+1;
int b[2000][1000];
int s[2001][1001];

inline long calc(long x, long y, long w, long h){
    return s[x+w][y+h] - s[x+w][y] - s[x][y+h] + s[x][y];
}

int main(void){
    long n, k;
    cin >> n >> k;
    for(long i=0; i<n; i++){
        int x, y;
        char c;
        scanf("%d %d %c", &x, &y, &c);
        y %= 2*k;
        if(c=='W'){
            x += k;
        }
        if(y>=k){
            y-=k;
            x+=k;
        }
        x %= 2*k;
        b[x][y]++;
    }
    /*
       for(long y=0; y<2*k; y++){
       for(long x=0; x<2*k; x++){
       cout << b[x+y*2*k] << " ";
       }
       cout << endl;
       }
       cout << endl;
       */
    s[1][1] = b[0][0];
    for(long i=1; i<2*k; i++){
        s[i+1][1] = s[i][1] + b[i][0];
    }
    for(long i=1; i<k; i++){
        s[1][i+1] = s[1][i] + b[0][i];
    }
    for(long x=1; x<2*k; x++){
        for(long y=1; y<k; y++){
            s[x+1][y+1] = b[x][y] + s[x][y+1] + s[x+1][y] - s[x][y];
        }
    }
    /*
       for(long y=1; y<M; y++){
       for(long x=1; x<M; x++){
       cout << s[x+y*M] << " ";
       }
       cout << endl;
       }
       cout << endl;
       */
    long max = 0;
    for(long x=0; x<k; x++){
        for(long y=0; y<k; y++){
            long t = calc(x, y, k, k-y);
            t += calc(0, 0, x, y);
            t += calc(x+k, 0, k-x, y);
            t = t<n/2 ? n-t : t;
            //printf("%ld %ld %ld\n", x, y, t);
            max = t>max ? t : max;
        }
    }
    cout << max;
    return 0;
}


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

int main() {
int N;
  cin >> N;
  vector<int64_t> kazu(N);
  int64_t count = 1;
  for(int i = 0; i < N; i++){
  	cin >> kazu.at(i);
    if(kazu[i] == 0){
      count = 0;
    }
  }
  if(count != 0){
  for(int i = 0; i < N; i++){
  	if(1000000000000000000/kazu[i] < count){
    	count = -1;
      break;
    }
      count = count * kazu[i];
  }
  }
  
    cout << count << endl;
  
}

Measured memory_bytes: 4052
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <set>
#include <deque>

using namespace std;

using PII = pair<int, int>;

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

	deque<int> deq0, deq1 = {-1};
	for (int i = 0; i < m; i++) {
		if (i % 2 == 0) {
			deq0.push_front(i);
			deq0.push_back(i);
		} else {
			deq1.push_front(i);
			deq1.push_back(i);
		}
	}

	vector<int> v(deq0.begin(), deq0.end());
	for (auto x: deq1) {
		v.emplace_back(x);
	}

	vector<vector<int>> v2(m);

	for (int i = 0; i < v.size(); i++) {
		if (v[i] == -1) {
			continue;
		}
		v2[v[i]].emplace_back(i+1);
	}

	for (auto v: v2) {
		cout << v[0] << " " << v[1] << endl;
	}
	return 0;
}


Measured memory_bytes: 8908
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
// ミント
const int mod = 1e9+7 ;
//998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//昆布
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}   ;
 
mint modpow(ll a,ll b){
 if(b==0) return 1 ;
 mint c= modpow(a,b/2) ;
 if(b%2==1) return c*c*a ;
 else return c*c ;
}

int main(){
  ll k ;cin>> k ;
  string s ; cin>>s ;
  ll n=s.size() ;
  ll all= n+k ;
  combination c(2000005) ;
  mint sum = modpow(26ll,all) ;
  mint ans=0 ;
  for(ll i=0;i<=n-1;i++){
    mint plus =c(all,i)*modpow(25ll,all-i) ;
    ans += plus ;

  }
  ans= sum-ans ;
   cout<<ans<<endl ;
       return 0;
  }
   

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

int main() {
    ll X, A;
    cin >> X >> A;
    cout << (X < A ? 0 : 10) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

double heron( double a, double x, double l){
  double s = (a+x+l)/2;
  return sqrt(s*(s-a)*(s-x)*(s-l));//ヘロンの公式
}

int main(void){

  double a,x,l;
  while( cin >> a >> l >> x ){
    double z = ( x + l ) / 2;
    double S = heron(l,l,a) + 2 * heron(z,z,l);
    printf("%.10f\n",S);
  }


  return 0;
}

Measured memory_bytes: 1240
N = int(input())
S = input()

west = S.count("W")
east = S.count("E")

change = east
if S[0] == "E":
    change -= 1
least = change

for i in range(1,N):
    if S[i-1] == "W":
        change += 1
    if S[i] == "E":
        change -= 1
    if change<least:
        least = change

print(least)

Measured memory_bytes: 3700
def topological_sort(V, E_in, E_from):
    '''
    V:N(node)
    E_from:
    E_in:
    '''

    # count num of pointed nodes for each nodes
    parent = [0]*V
    cnt = [0]*V
    Q = []
    for v in range(V):
        cnt[v] = len(E_in[v])
        if cnt[v] == 0:
            Q.append(v)

    while Q:
        del_node = Q.pop()
        for j in E_from[del_node]:
            cnt[j] -= 1
            if cnt[j] == 0:
                Q.append(j)
                parent[j] = del_node+1

    return parent


def main():
    N, M = map(int, input().split())
    E_in = [[] for _ in range(N)]
    E_from = [[] for _ in range(N)]
    for _ in range(N+M-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        E_from[a].append(b)
        E_in[b].append(a)

    ans = topological_sort(N, E_in, E_from)
    for s in ans:
        print(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 75040
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <set>
#include<unordered_map>


using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n, a[112];
	cin >> n;
	int ki = 0, gu = 0;
	rep(i,n){
		cin >> a[i];
		if(a[i]%2==0)
			gu++;
			else
				ki++;
	}
	ll all = 1, two = 1;
	while(n>0){
		all *= 3;
		n--;
	}
	while(gu>0){
		two *= 2;
		gu--;
	}
	cout << all - two << endl;
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

template <class InputIterator, class T>
bool contains(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// =========ここまでテンプレ============

int main()
{
    int n;
    cin >> n;
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> a;
    for (int i = 0; i < n; i++)
    {
        ll j;
        cin >> j;
        a.push(pair{j, i});
    }

    // 0埋めで初期化
    vector<vector<ll>> dp = vector<vector<ll>>(n, vector<ll>(n));

    // 配置は、act=得点が高い順に行う。両端のどちらかに必ず詰めていく。
    // dp[i][j]は、「i~jが空いてる状況で、残りを配置することで得られる最高得点」を表す
    // 最終的に欲しいのは dp[0][n-1]
    // 漸化式は、その時配置しようとしてるやつをpair{act, ind}とすると
    // dp[i][j] = max(
    // (左端に配置) act*abs(ind-i)+dp[i+1][j],
    // (右端に配置) act*abs(ind-j)+dp[i][j-1]
    // )
    // この式までは、「配置する」という順序で考えたほうがわかりやすい！
    // 表を考えるのはそのあと！

    pair<ll, int> minAct = a.top();
    a.pop();
    for (int i = 0; i < n; i++)
    {
        dp[i][i] = minAct.first * abs(minAct.second - i);
    }
    // iとjの差をkとおく
    for (int k = 1; k <= n - 1; k++)
    {
        pair<ll, int> act = a.top();
        a.pop();
        for (int i = 0; i <= n - 1 - k; i++)
        {
            int j = i + k;

            ll x = dp[i][j - 1] + act.first * abs(act.second - j);
            ll y = dp[i + 1][j] + act.first * abs(act.second - i);
            dp[i][j] = max(x, y);
            int hoge;
            hoge = 3;
        }
    }
    cout << dp[0][n - 1];
    return 0;
}


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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int &i: a) cin >> i;
	int ans = INT_MAX;
	for(int diff = -100; diff <= 100; diff++) {
		int cur = 0;
		for(int i = 0; i < n; i++) {
			cur += (a[i] - diff)*(a[i] - diff);
		}
		ans = min(ans, cur);
	}
	cout << ans;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

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

        sc.close();

        if (A + B >= 24) {
            System.out.println(A + B - 24);
        } else {
            System.out.println(A + B);
        }
    }
}

Measured memory_bytes: 21972
// 連結成分
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define NIL -1

vector<int> G[100005];
int color[100005];
int n,col;

void dfs(int r, int c);
void assign_number();

int main(){
    int m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int s,t; cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    col = 0;
    assign_number();
    
    int q;
    cin >> q;
    
    for(int i = 0; i < q; i++){
        int s,t; cin >> s >> t;
        cout << (color[s] == color[t] ? "yes" : "no") << endl;
    }
    return 0;
}

void assign_number(){
    // 未訪問の頂点を選んで探索していく
    for(int i = 0; i < n; i++){
        color[i] = NIL;
    }

    for(int i = 0; i < n; i++){
        if(color[i] == NIL){
            dfs(i,col); col++;
        }
    }
}

void dfs(int r, int c){
    // 頂点rから探索しそのグループにcの番号をふる
    stack<int> s;
    s.push(r);
    color[r] = c;

    while(!s.empty()){
        int top = s.top();
        s.pop();
        int size = G[top].size();
        for(int i = 0; i < size; i++){
            int v = G[top][i];
            if(color[v] == NIL){
                // まだ探索されていない頂点
                color[v] = c;
                s.push(v);
            }
        }
    }

}


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

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            String[] S = new String[N];
            for (int i = 0; i < N; i++)
            {
                S[i] = Console.ReadLine();
            }

            Array.Sort(S, StringComparer.OrdinalIgnoreCase);
            int[] eq = new int[N];
            eq[0] = 0;
            int max = 0;

            for (int i = 1; i < N; i++)
            {
                if (S[i].Equals(S[i - 1]))
                {
                    eq[i] = eq[i - 1] + 1;
                    if (eq[i] > max)
                    {
                        max = eq[i];
                    }
                }
                else
                {
                    eq[i] = 0;
                }
            }


            for (int i = 0; i < N; i++)
            {
                if (eq[i] == max)
                {
                    Console.WriteLine(S[i]);
                }
            }


        }
    }
}

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

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

  for(ll i=0;i<K;i++){
    if(S[i]!='1'){
			cout<<S[i]<<endl;
			return 0;
		}
  }
	cout<<'1'<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			int R = sc.nextInt();
			int ans = 0;
			while (true) {
				if (N < 1) {
					break;
				}
				N /= R;
				ans++;
			}
			System.out.print(ans);
		}
	}
}

Measured memory_bytes: 21460
import bisect

N = int(input())

A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

print(sum([bisect.bisect_left(A, b) * (N - bisect.bisect(C, b)) for b in B]))


Measured memory_bytes: 23032
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if((abs(a-b)<=d&&abs(c-b)<=d)||abs(a-c)<=d){
        printf("Yes");
    }else printf("No");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxx=1010;
const int infinity=1<<30;
int A[maxx][maxx],d[maxx];
bool flag[maxx];
int n,a,b,c;
	
int main (){
	cin>>n;
	for(int i=0;i<n;i++){
		flag[i]=false;
		d[i]=infinity;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			A[i][j]=infinity;
		}
	}
	for(int i=0;i<n;i++){
		cin>>a>>b;
		for(int j=0;j<b;j++){
			cin>>c;
			cin>>A[a][c];
		}
	}
	d[0]=0;
	while(1){
		int minv=infinity,minj=-1;
		for(int i=0;i<n;i++){
			if(flag[i]==false && d[i]<minv){
				minv=d[i];
				minj=i;
			}
		}
		if(minv==infinity) break;
		flag[minj]=true;
		for(int i =0;i<n;i++){
			if(A[minj][i]!=infinity && flag[i]==false && d[i]>=d[minj]+A[minj][i]){
					d[i]=d[minj]+A[minj][i];
			}
		}
	}
	for(int i=0;i<n;i++) cout<<i<<" "<<(d[i]==infinity ? -1 : d[i])<<endl;
	
	return 0;

}


Measured memory_bytes: 3464
#include <bits/stdc++.h>
using namespace std;
int n,m,d;
int a[1009][1009];
pair<int,int> b[1000009];
int c[1000009];
int vis[1000009];
int e(int x,int y,int xx,int yy)
{
    return abs(x-xx)+abs(y-yy);
}
int main()
{
    cin>>n>>m>>d;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            cin>>a[i][j];
            b[a[i][j]].first=i;
            b[a[i][j]].second=j;
        }
    for(int i=1;i<=n*m;i++)
    {
     //   i=2;
        if(vis[i])continue;
        int j=i;
        while(j<=n*m)
        {
            vis[j]=1;
            if(j==i){j+=d;continue;}
            c[j]=c[j-d]+e(b[j-d].first,b[j-d].second,b[j].first,b[j].second);
            j+=d;
        }
    }
    int q;
    cin>>q;
    while(q--)
    {
        int l,r;
        cin>>l>>r;
        int x=(r-l)/d;
        cout<<c[x*d+l]-c[l]<<endl;
    }
}


Measured memory_bytes: 13824
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t y,z;
  cin>>y>>z;
  if(y==1&&z==1) cout<<1<<endl;
  else if(y==1) cout<<z-2<<endl;
  else if(z==1) cout<<y-2<<endl;
  else cout<<(y-2)*(z-2)<<endl;
}

Measured memory_bytes: 3640
chomp($n=<>);
chomp($a=<>);
@a=split/ /,$a;

%hash=();
for($i=0;$i<$n;$i++){
    if($a[$i] < 400){
        $hash{1}++;
    }elsif($a[$i] < 800){
        $hash{2}++;
    }elsif($a[$i] < 1200){
        $hash{3}++;
    }elsif($a[$i] < 1600){
        $hash{4}++;
    }elsif($a[$i] < 2000){
        $hash{5}++;
    }elsif($a[$i] < 2400){
        $hash{6}++;
    }elsif($a[$i] < 2800){
        $hash{7}++;
    }elsif($a[$i] < 3200){
        $hash{8}++;
    }else{
        $hash{9}++;
    }
}

foreach ( keys %hash){
    if($hash{$_} > 0){
        $cnt++;
    }
}
if($hash{9} > 0){
    $min = $cnt - 1;
    $max = $cnt - 1 + $hash{9};
}else{
    $min = $cnt;
    $max = $cnt;
}
if($min == 0){
    $min = 1;
}

print $min." ".$max;

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
 
int main(){
  ll a,b,k;
  cin >> a >> b >>k;

  ll ta=0;
  ll ao=0;

  if(a+b < k){
    ta =0;
    ao=0;
  }else{
    if(a >= k) {
      ta = a - k;
      ao = b;
    }else{
      ta = 0;
      ao = b- (k-a);
    }
  }

  cout << ta << ' ' << ao << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Go_ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=1e3+100;


int main()
{
    Go_
    ll a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    cin>>n;
    int last=1;
    for(i=0;i<n;i++)
    {
        cin>>x;
        if(x==last) ++last;
    }
    
    if(last==1) cout<<"-1"<<endl;
    else cout<<n-(last-1)<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;
long long int H;

int main()
{
  int i;
  long long int sum;
  long long int mn;

  cin >> H;

  for(i=0, mn=1, sum=0; H>1; i++) {
    sum += mn;
    H /=2;
    mn *= 2;
  }
  printf("%lld\n", mn+sum);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)

typedef unsigned long long ull;
typedef long long ll;

const int INF = 1001001001;
const ll MOD = 1e9 + 7;

using namespace std;
using P = pair<int,int>;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

bool is_prime(ll n) {
  if (n == 2) return true;
  REP(i, 2, n) {
      if (n%i == 0)
      {
        /* code */
        return false;
      }
  }
  return true;
}


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

  ull fact = 1;
  if (n == 1) 
  {
      fact = k;
      cout << fact << endl;
      return 0;
  }
  for (ull i = n; i > 0; i--)
  {
      fact *= (i == n) ? k : k-1;
  }
  
  cout << fact << endl;
  return 0;
}

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

#define int long long
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

using namespace std;

int N;
int A[100010];
int cost[100010];
int sc[100010];

signed main()
{
    cin >> N;
    REPS(i, N) cin >> A[i];
    A[N+1] = 0;

    REPS(i, N+1) cost[i] = abs(A[i]-A[i-1]);
    REPS(i, N+1) sc[i] = sc[i-1] + cost[i];

    REPS(i, N)
    {
        int start = 0;
        int mid = i;
        int end = N+1;

        int ans = (sc[mid-1] - sc[start]) + abs(A[mid-1] - A[mid+1]) + (sc[N+1] - sc[mid+1]);
        printf("%lld\n", ans);
    }

    return 0;
}

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

int main(){
 int num, a, b, x, y;
 cin >> num;
  
 b = num % 100; 
 a = ( num -b ) / 100; 
  
 if(a > 0 && a < 13 && b > 0 && b < 13){
   cout << "AMBIGUOUS" << endl;
 }else if(b > 0 && b < 13){
   cout << "YYMM" << endl;
 }else if(a > 0 && a < 13){
   cout << "MMYY" << endl;
 }else{
   cout << "NA" << endl;
 }
  
 return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    ll n;cin>>n;
    string s;cin>>s;
    ll c[26];rep(i,0,25)c[i]=0;
    ll b=0;
    rep(i,0,n-1){
        ll k;
        rep(j,0,25){
            if(s[i]==alp[j]){
                k=j;
                break;
            }
        }
        if(c[k]==0){
            b++;
        }
        c[k]++;
    }
    ll ans=1;
    rep(i,0,25){
        ans=(ans*(c[i]+1))%i_7;
    }
    ans=(ans-1+i_7)%i_7;
    cout<<ans<<endl;
    
    return 0;
}






Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <stdint.h>
#include <cstring>
using namespace std;
int main(void) {
	int n;
	int64_t count[100001];
	cin >> n;
	for (int i = 0; i < n; i++)cin >> count[i];
	count[n] = 0;
	int64_t ans = 0;
	for (int i = 0; i < n; i++) {
		ans += count[i]/2;
		if (count[i] % 2 != 0 && count[i+1]) {
			count[i + 1] --;
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
/**
*    author:  Dooloper
*    created: 13.06.2020 21:01:53
**/

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <functional>
#include <cassert>


using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define PI 3.14159265358979323846264338327950L

int main() {
    cin.tie(0);
    ll A, V, B, W, T;
    cin>>A>>V>>B>>W>>T;
    if(abs(B-A) <= (V-W)*T){
        cout << "YES"<<endl;
    }else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
using System;

class Program{
	private static void Main()
    {
      int n = int.Parse(Console.ReadLine());
      
      string[] str = Console.ReadLine().Split(' ');
      
      for(int i = 0; i < n; i++)
      {
        Console.Write(str[0][i]);
        Console.Write(str[1][i]);
      }
      Console.WriteLine();
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	int n;
	scanf("%d",&n);
	int g=114514;
	for(int i=1;i<=n-1;i++){
		int a=i;
		int b=n-i;
		int s=0;
		while(a>0){
			s+=a%10;
			a/=10;
		}
		while(b>0){
			s+=b%10;
			b/=10;
		}
		g=min(g,s);
	}
	printf("%d\n",g);
	return 0;
}

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

lint com[52][52], v[52];
map<lint, int> cnt;

void combination(int n){
    for(int i=0;i<=n;i++) com[i][0] = 1;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++) com[i][j] = com[i-1][j] + com[i-1][j-1];
}

int main(){
    int n, a, b; cin >> n >> a >> b;
    for(int i=0;i<n;i++){
        cin >> v[i];
        
        auto it = cnt.find(v[i]);
        if(it==cnt.end()) cnt[v[i]] = 1;
        else it->second++;
    }

    sort(v, v+n); reverse(v, v+n);
    combination(n);

    if(a <= cnt[v[0]]){
        lint ans = 0;
        for(int i=a;i<=min(cnt[v[0]], b);i++) ans += com[cnt[v[0]]][i];
        cout << v[0] << '\n' << ans << endl;
        return 0;
    }

    int need = 0;
    double sum = 0;
    for(int i=0;i<a;i++){
        sum += v[i];
        if(v[i]==v[a-1]) need++;
    }

    printf("%.8lf\n%lld", sum / a, com[cnt[v[a-1]]][need]);
    return 0;
}


Measured memory_bytes: 256