akhauriyash/Code-Regression huggingface dataset:
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
from collections import deque


#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
	
def count_str(m):
	tmp={}
	for i in range(10):
		if i in tmp:
			tmp[i]=1
		else:
			tmp[i]+=1
	return tmp

def is_prime(n):
	if n==1: return True

	for i in range(2,int(math.sqrt(n))+1):
		if n%i==0:
			return False
	return True

a,b=input2()

if (a+b)%2==1:
	print("IMPOSSIBLE")
else:
	print((a+b)//2)



















Measured memory_bytes: 12296
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n, m;
  cin >> n >> m;
  V a(n, 0);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    a[x-1]++;
    a[y-1]++;
  }
  for (int i = 0; i < n; i++) dump(a[i]);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int top, S[100];

int pop(){
    return S[top--];
}

void push(int x){
    S[++top]=x;
}

int main(){
  int x, a, b;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
        a=pop();
        b=pop();
        push(a+b);
    } else if ( s[0] == '-' ){
        a=pop();
        b=pop();
        push(b-a);
    } else if ( s[0] == '*' ){
        a=pop();
        b=pop();
        push(a*b);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n", pop());
  return 0;
}


Measured memory_bytes: 2080
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <utility>

#define reps(i,f,n) for(ll i=f; i<ll(n); ++i)
#define rep(i,n) reps(i,0,n)

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;

signed main()
{
    string s;
    cin >> s;
    
    int hist[3] = {};
    rep(i, s.size()){
        hist[s[i]-'a']++;
    }
    
    sort(hist, hist+3);
    hist[1] -= hist[0];
    hist[2] -= hist[0];
    cout << (hist[1] <= 1 && hist[2] <= 1 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 764
K,N = map(int,(input().split()))
a = list(map(int,(input().split())))
d = [0]*N
d[0] = abs(a[0]+K-a[N-1])
for i in range(1,N):
    d[i] = abs(a[i]-a[i-1])
print(K-max(d))

Measured memory_bytes: 77388
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<complex>
#include<stack>
#include<queue>
#include<unordered_map>
#include<map>
using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int b[300000], w[300000];

  int i;
  b[0] = 0;
  w[0] = 0;

  for (i = 1; i <= n; i++) {
    if (s[i-1] == '.') {
      w[i] = w[i-1] + 1;
      b[i] = b[i-1];
    } else {
      w[i] = w[i-1];
      b[i] = b[i-1] + 1;
    }
  }

  int ans = 10000000;

  for (i = 0; i <= n; i++) {
    ans = min(ans, b[i] + (w[n] - w[i]));
  }
  cout << ans << endl;
}


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

vector<vector<int> > a;
vector<bool> b;
map<pair<int, int>, int> m;
int ans = 0;

void dfs(int i, int c){
	int cnt = 0;
	for(unsigned j = 0; j < a[i].size(); j++){
		if(b[a[i][j]]) continue;
		++cnt; if(cnt == c) ++cnt;
		b[a[i][j]] = 1;
		m[{i, a[i][j]}] = cnt;
		dfs(a[i][j], cnt);
	}
	ans = max(ans, cnt);
}
 
signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	a.resize(n + 1);
	vector<pair<int, int> > p;
	for(int i = 0; i < n - 1; i++){
		int u, v; cin >> u >> v;
		a[u].push_back(v);
		a[v].push_back(u);
		p.push_back({u, v});
	}
	b.resize(n + 1, 0); b[1] = 1;
	dfs(1, 0);
	cout << ans << '\n';
	for(auto i : p){
		int u = i.first, v = i.second;
		if(!m[{u, v}]) swap(u, v);
		cout << m[{u, v}] << '\n';
	}
	cout << '\n';
}


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

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char[] c = s.toCharArray();
    int n = s.length();
    
    int d = 0;
    
    for(int i=0; i<n/2; i++){
      if(c[i] != c[(n-1)-i]){
        d++;
      }
    }
    
    System.out.println(d);
    
  }
}


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

int main() {
	string s; cin >> s;
	int zeroStart, oneStart; zeroStart = 0; oneStart = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (i % 2 == 0)
		{
			if (s.at(i) != '0')
			{
				zeroStart++;
			}
		} else {
			if (s.at(i) != '1')
			{
				zeroStart++;
			}
		}
	}

	oneStart = s.size() - zeroStart;
	
	cout << min(zeroStart, oneStart) << endl;
	//cout << "01:" << zeroStart << endl << "10:" << oneStart << endl;

}

Measured memory_bytes: 512
from collections import deque
import sys
read = sys.stdin.read
readline = sys.stdin.readline


def main():
    n = int(readline())

    E = [[]]
    for _ in range(n):
        u,k,*v = map(int, readline().split())
        E.append(v)

    d = [-1] * (n+1)
    
    queue = deque([1])
    d[1] = 0
    while queue:
        v = queue.popleft()
        for e in E[v]:
            if d[e] == -1:
                d[e] = d[v] + 1
                queue.append(e)

    for i in range(1, n+1):
        print(i, d[i])


if __name__ == "__main__":
    main()


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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;


const int MAX = 1000000;
const int MOD = 1000000007;

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

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	COMinit();

	int x,y;

	cin >> x >> y;
	int cnt = 0;
	while(y>0) {
		if(y*2 == x) {
			break;
		}
		x -= 1;
		y -= 2;
		cnt++;
	}
	int ans;
	if(cnt == 0) {
		ans = 1;
	}else if (y == 0 && x == 0) {
		ans = 1;
	}else if (y <= 0) {
		ans = 0;
	} else {
		ans = COM(cnt+y,y);
	}

	cout << ans << endl;

}



Measured memory_bytes: 23680
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp;
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define range(index, beg, end) for (ll index = beg; index < end; ++index)
#define times(N) for (ll i = 0; i < N; i++)
#define rev_range(N) for (ll i = N-1; i >= 0; i--)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

ll powMod(ll a, ll n, ll mod){
    if(n == 0) return 1;
    if(n%2 == 0)
        return powMod(a, n/2, mod) * powMod(a, n/2, mod) % mod;
    else
        return a * powMod(a, n-1, mod)% mod;
}

ll ncrMod(ll n, ll r, ll mod){
    ll x=1, y=1;
    for(ll i = 1; i <= r; ++i){
        x *= n-i+1;
        x %= mod;
        y *= i;
        y %= mod;
    }
    return x * powMod(y, mod-2, mod) % mod;
}

struct Sell {
    int a, b, c;
};

int main() {
    int A, B, M;
    cin >> A >> B >> M;

    constexpr int MAX = 100000;
    int price_freezer[MAX], price_range[MAX];
    Sell sell[MAX];

    int price_freezer_min = MAX, price_range_min = MAX;

    times(A) {
        cin >> price_freezer[i];
        price_freezer_min = min(price_freezer_min, price_freezer[i]);
    }
    times(B) {
        cin >> price_range[i];
        price_range_min = min(price_range_min, price_range[i]);
    }
    times(M) {
        cin >> sell[i].a >> sell[i].b >> sell[i].c;
    }

    int min_price = price_range_min + price_freezer_min;

    times(M) {
        int price = price_freezer[sell[i].a -1] + price_range[sell[i].b -1] - sell[i].c;
        min_price = min(min_price, price);
    }

    cout << min_price;

    return 0;
}



Measured memory_bytes: 2176
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        
        String[] input = lines[0].split("/");
        int y = Integer.parseInt(input[0]);
        int m = Integer.parseInt(input[1]);
        int d = Integer.parseInt(input[2]);
        
        if (y<2019)  {
            System.out.println("Heisei");
        }
        else if (y==2019 && m<=4 && d<=30){
            System.out.println("Heisei");
        }
        else {
            System.out.println("TBD");
        }
    }
    
    private static String[] getStdin() {
        Scanner scanner = new Scanner(System.in);
        ArrayList<String> lines = new ArrayList<>();
        while (scanner.hasNext()) {
            lines.add(scanner.nextLine());
        }
        return lines.toArray(new String[lines.size()]);
    }
}

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

int main() {
  int K;
  string S;
  cin >> K >> S;
  
  if (S.size() <= K) {
    cout << S << endl;
  } else {
    cout << S.substr(0, K) + "..." << endl;
  }
  
  return 0;
}

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

int main() {
int x[5];
for (int i = 0; i < 5; i++) {
    cin >> x[i];
}
for (int i = 0; i < 5; i++) {
    if (x[i] == 0) cout << i + 1 << endl;
}
return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<map>
using namespace std;
#define MAXN 200000
#define INF 2000000000
#define LL long long
int n,ans;
int a[MAXN+5];
map<int,int> Dic;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        Dic[a[i]]++;
    }
    sort(a+1,a+n+1);
    for(int i=n;i>=1;i--)
    {
        LL p=1;bool F=0;
        if(Dic[a[i]]==0)continue;
        while(p<=INF)p*=2;
        while(!F&&p>1)
        {
            p/=2;
            if(p-a[i]>=0)
            {
                if(p-a[i]==a[i])
                {if(Dic[a[i]]>1)ans++,Dic[a[i]]-=2,F=1;}
                else
                {if(Dic[p-a[i]]>=1)ans++,Dic[a[i]]--,Dic[p-a[i]]--,F=1;}
            }
        }
    }
    printf("%d",ans);
}


Measured memory_bytes: 29824
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
typedef long long LL;

int n, K, dp[5][105][3];
char str[105];

int dfs(int m, int use, int limit) {
    if(use > K) return 0;
    if(m > n) return use == K;
    if(dp[use][m][limit] != -1) return dp[use][m][limit];
    int up = limit == 1? str[m]-'0':9; int ans = 0;
    for(int i = 0; i <= up; ++i)
        ans += dfs(m+1, use+(i!=0), limit&&i==up); 
    return dp[use][m][limit] = ans;
}

void run_case() {
    cin >> (str+1) >> K;
    n = strlen(str+1);
    memset(dp, -1, sizeof(dp));
    cout << dfs(1, 0, 1);
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    //cout.setf(ios_base::showpoint);cout.precision(8);
    run_case();
    cout.flush();
    return 0;
}


Measured memory_bytes: 256
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main _ =
    let N = read int
    let A = reada int

    let ans = Array.zeroCreate N
    for i in 0..N-1 do
        ans.[A.[i] - 1] <- i + 1

    ans
    |> Array.iter (fun i -> printf "%d " i)
    printfn ""
    0


Measured memory_bytes: 26828
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var array = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();

            var commit = new bool[n];
            var arrayMultiple = new int[n];
            for (var i = 0; i < n; i++)
            {
                commit[i] = false;
                arrayMultiple[i] = array[i] * 2;
                if (array[i] == 0) commit[i] = true;
            }

            var total = 0;

            // commitが全部trueになるまでループする
            while (commit.Any(v => v == false))
            {
                var start = int.MaxValue;
                var end = n;

                for (var i = 0; i < n; i++)
                {
                    if (array[i] + 1 <= arrayMultiple[i])
                    {
                        start = i;
                        break;
                    }
                }

                for (var i = start+1; i < n; i++)
                {
                    if (commit[i])
                    {
                        end = i;
                        break;
                    }
                }

                var min = int.MaxValue;
                for (var i = start; i < end; i++)
                {
                    min = Math.Min(arrayMultiple[i] - array[i], min);
                }

                for (var i = start; i < end; i++)
                {
                    array[i] += min;
                }
                total += min;

                for (var i = start; i < end; i++)
                {
                    if (array[i] == arrayMultiple[i])
                    {
                        commit[i] = true;
                    }
                }

            }
            Console.WriteLine(total);
        }
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end());
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)

int n, cnt;
string s;

int main() {
  cin >> n >> s;
  REP(i, n) if (s[i] == 'R') cnt++;
  if (cnt * 2 > n) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //ライブラリ全読み込み
using namespace std; //std:を省略できる

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    a<b&&b<c ? cout <<"Yes"<< endl:cout <<"No"<< endl;
    return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,count = 0;

    scanf("%d",&n);

    long long int num[n];

    for(int i = 0;i < n;i++)
        scanf("%lld",&num[i]);

    if(n < 3)
        printf("%d\n",count);
    else
    {
        for(int i = 0;i < n - 2;i++)
        {
            for(int j = i + 1;j < n - 1;j++)
                for(int k = j + 1;k < n;k++)
                    if((num[i] != num[j]&&num[i] != num[k]&&num[j] != num[k])&&(num[i] + num[j] > num[k]&&num[i] + num[k] > num[j]&&num[k] + num[j] > num[i]))
                        count++;
        }

        printf("%d\n",count);
    }

    return 0;
}

Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589
#define endl "\n"
#define int long long
#define ld long double
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define fr(i,a,b) for (int i = (a); i < (b); ++i)

const int Nmax = 1e5;
vector<int> gr[Nmax];
vector<int> topsort;
vector<bool> used(Nmax, false);

void dfs(int u){
    used[u] = true;
    for(int v : gr[u]){
        if(!used[v]){
            dfs(v);
        }
    }
    topsort.push_back(u);
}

void solve(){
    int n, m;
    cin >> n >> m;
    fr(i, 0, m){
        int x, y;
        cin >> x >> y;
        x--; --y;
        gr[x].push_back(y);
    }
    fr(i, 0, n){
        if(!used[i]) dfs(i);
    }
    reverse(all(topsort));
    vector<int> v_to_i(n), dp(n, 0);
    fr(i, 0, n) v_to_i[topsort[i]] = i;
    fr(i, 0, n){
        for(int v : gr[topsort[i]]){
            dp[v_to_i[v]] = max(dp[v_to_i[v]], dp[i] + 1);
        }
    }
    int ans = 0;
    fr(i, 0, n) ans = max(dp[i], ans);
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int t;
    t = 1;
    //cin >> t;
    while(t--) {solve();}
    return 0;
}


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

int main() {

  double a,b,c;
  double S,L2, L, h;

  scanf("%lf %lf %lf",&a,&b,&c);

  S = 0.5*a*b*sin(c*3.14159265359/180);
  L2 = a*a+b*b-2*a*b*cos(c*3.1415926359/180);
  L = sqrt(L2)+a+b;
  h = 2*S/a;

  printf("%.11lf\n%.11lf\n%.11lf\n",S ,L,h); 

  return 0;
}


Measured memory_bytes: 2044
#include <stdio.h>
int main(void){
    int n, i;
    int ac=0, wa=0, tle=0, re=0;
    char s[32];
    scanf("%d", &n);
    for(i=1;i<=n;i++){
        scanf("%s", s);
        if(s[0]=='A'){
            ac++;
        }else if(s[0]=='W'){
            wa++;
        }else if(s[0]=='T'){
            tle++;
        }else{
            re++;
        }
    }
     printf("AC x %d\n", ac);
     printf("WA x %d\n", wa);
     printf("TLE x %d\n",tle);
     printf("RE x %d\n",re);
    
}


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

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;//先に割り算をして掛けられる数を小さくして掛け算を行う
}

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

    cout << lcm(a,b) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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++)
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int a, b, c, d, e;
  int ans = 0;
  rep(i, N) {
    int I = i + 1;
    a = I % 10;
    b = (I - a) % 100 / 10;
    c = (I - a - b * 10) % 1000 / 100;
    d = (I - a - b * 10 - c * 100) % 10000 / 1000;
    e = (I - a - b * 10 - c * 100 - d * 1000) % 100000 / 10000;
    if(A <= a + b + c + d + e && a + b + c + d + e <= B) {
      ans += I;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double a, b, mean_d;
  int mean_i, i;
  cin >> a >> b;
  mean_d = (a+b)/2;
  mean_i = (a+b)/2;
  i = mean_d - mean_i + 0.999;
  cout << mean_i+i << endl;
}

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

using namespace std;

int main() {
    string S;
    cin >> S;
    int A[26];
    for(int i = 0; i < sizeof(A) / sizeof(A[0]); i++) {
        A[i] = false;
    }
    for(int i = 0; i < (int) S.size(); i++) {
        A[S[i] - 'a'] = true;
    }
    for(int i = 0; i <  sizeof(A) / sizeof(A[0]); i++) {
        if(!A[i]) {
            cout << (char) ((int)'a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        auto low = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        auto up = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        ans += low * up;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4468
#include<stdio.h>
int main(void){
    double q, x, key;
    scanf("%lf", &q);
    while ( 1 ) {
        x = q / 2;
        key = 0.00001 * q;
        while ( 1 ) {
            x = x - ( x * x * x - q ) / ( 3 * x * x );
            if ( ( x * x * x - q ) * ( x * x * x - q ) < key * key) break;
        }
        printf("%.6lf\n", x);
        scanf("%lf", &q);
        if ( q == -1 ) break;
    }
    return 0;
}

Measured memory_bytes: 1736
# C - H and V
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    H, W, K = map(int, readline().split())
    C = [line.decode() for line in readlines()]
    res = 0
    for bit in range(1 << (H + W)):
        cnt_black = sum(
            C[i][j] == "#" and not (bit >> i) & 1 and not (bit >> (j + H)) & 1
            for i in range(H)
            for j in range(W)
        )
        if cnt_black == K:
            res += 1
    print(res)


if __name__ == "__main__":
    main()


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

int main(){
    long long tmp1,tmp2,N,ans;
    cin >> N;
    tmp1 = long(pow(N,0.5));
    for(long i=tmp1;i>=1;--i){
        if(N%i==0){
            tmp2=i;
            break;
        }
    }
    cout << tmp2 + N/tmp2 - 2 << endl;
}


Measured memory_bytes: 384
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 
 using namespace std;
 
 char arr[3][10000];
 
 int w,x,y,z;
 
 bool judge(char a)
 {
   for(int j=0;j<3;j++)
   { 
     //cout<<i<<"    "<<i<<endl;
     if((arr[j][0]==a)&&(arr[j][1]==a)&&(arr[j][2]==a)) 
     { 
       //cout<<a<<endl;
       //cout<<arr[j][i]<<" "<<arr[j][i+1]<<" "<<arr[j][i+2]<<endl;
       w++;
       return true;
     }
   }   
   for(int j=0;j<3;j++)
   { 
     if((arr[0][j]==a)&&(arr[1][j]==a)&&(arr[2][j]==a)) 
     {
       x++;
       return true;
     }
   }
   if((arr[0][0]==a)&&(arr[1][1]==a)&&(arr[2][2]==a))
   { 
     y++;
     return true;
   }
   if((arr[2][0]==a)&&(arr[1][1]==a)&&(arr[0][2]==a))
   {
     z++;
     return true;
   }
   return false;
 } 
 
 int main()
 {
   string s;
   int total;
   char win;
   w=0,x=0,y=0,z=0;
   while(cin>>s)
   {
     int count=0;
     for(int i=0;i<3;i++)
     {
       for(int j=0;j<3;j++)
       {
         arr[i][j]=s[count++];        
       }        
     }       
     //cout<<i<<endl;
     if(judge('o')) win='o';
     else if(judge('x')) win='x';
     else win='d';
     //cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
     cout<<win<<endl;        
   }
   /*
   cout<<total<<endl;
   for(int i=0;i<3;i++)
   {
     for(int j=0;j<total;j++)
     {
       cout<<arr[i][j];        
     }        
     cout<<endl;
   }
   */        
   //while(1);
   return 0;
 }

 
  

Measured memory_bytes: 3044
#include <iostream>
#include <string>

int main (int argc, char *argv[])
{
	while(true)
	{
		std::string str;
		getline(std::cin, str);
		int sum = 0;
		for(int i = 0; i < (int)str.size(); ++i)
		{
			sum += str[i] - '0';
		}
		if(sum != 0)
		{
			std::cout << sum << std::endl;
		}
		else
		{
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3164
#include <stdio.h>

int main()
{
	char S[4];
	int J = 0;

	scanf("%s", &S);

	for (int i = 0; i < 4; ++i) {
		for (int j = 0; j < 4; ++j) {
			if (S[i] == S[j] && i != j) ++J;
		}
	}

	if (J == 4) printf("Yes");
	else printf("No");
}


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

int main() {
    int a, b;
    char op;
    
    while(1){
        cin >> a >> op >> b;
        if(op == '?') break;
        
        if(op == '+') cout << a+b <<endl;
        else if(op == '-') cout << a-b <<endl;
        else if(op == '*') cout << a*b <<endl;
        else if(op == '/') cout << a/b <<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
int main (){
	int n;
	cin >> n;
	int l[1000], r[1000];
	int ans = 0;
	for (int i = 0; i < n; i++){
		cin >> l[i] >> r[i];
		ans += r[i]-l[i]+1;
	}
	cout << ans << endl;
	return 0;
}


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

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}

template<class T> T sum(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    T ans = T();
    for(typename vector<T>::iterator t = begin; t != end; t++) ans += *t;
    return ans;
}

template<class T> T min(const vector<T>& v) {
    return *min_element(v.begin(), v.end());
}

template<class T> T min(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *min_element(begin, end);
}

template<class T> T max(const vector<T>& v) {
    return *max_element(v.begin(), v.end());
}

template<class T> T max(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *max_element(begin, end);
}

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

    int N = next<int>(), M = next<int>();

    auto D = next<vector<int>>(N);
    vector<long long> pyon(N+1, INT_MAX);
    pyon[0] = 0;

    times(M, j) {
        int C = next<int>();
        downto(N, 1, i) {
            pyon[i] = min(pyon[i], pyon[i-1] + D[i-1] * C);
        }
        #ifdef debug
            cout << pyon ln;
        #endif
    }

    cout << pyon[N] ln;

    return 0;
}

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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = ReadSplit();
            var N = r[0].ToInt();
            var M = r[1].ToInt();

            var l = new Dictionary<int, ACWA>();
            for (int i = 0; i < N; i++)
            {
                l.Add(i, new ACWA() { AC = 0, WA = 0 });
            }
            for (int i = 0; i < M; i++)
            {
                var r2 = ReadSplit();
                var p = r2[0].ToInt() - 1;
                var s = r2[1];
                if (l[p].AC > 0) continue;
                if (s == "AC")
                {
                    l[p].AC = 1;
                }
                else
                {
                    l[p].WA += 1;
                }
            }
            WriteRead(l.Sum(x => x.Value.AC).ToString() + " " + l.Where(x => x.Value.AC == 1).Sum(x => x.Value.WA).ToString());
        }

        public class ACWA
        {
            public int AC { get; set; }
            public int WA { get; set; }
        }

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

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }
    }
}


public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }
}



Measured memory_bytes: 29768
n = int(input())
L = sorted(list(map(int, input().split())), reverse=True)
L.append(0)

def is_ok(arg):
    # 条件を満たすかどうか？問題ごとに定義
    judge = L[i] < L[j] + L[arg]
#    print(judge, i, j, arg, L[i], L[j], L[arg])
    return judge

def meguru_bisect(ng, ok):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

count = 0
for i in range(n):
    for j in range(i+1, n):
        k = meguru_bisect(n+1, j)
        if k > j:
            #print(i, j, k, L[i], L[j], L[k])
            count += k - j
print(count)


Measured memory_bytes: 68764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 const int AMAX = 100000;
 ll cnt[AMAX + 1];

 int main(void) {
 int N;
 ll K;
 cin >> N >> K;

 for (int i = 0; i < N; ++i) {
 int A, B;
 cin >> A >> B;
 cnt[A] += B;
 }

 for (int ans = 1; ans <= AMAX; ++ans){
 if (K <= cnt[ans]) {
 cout << ans << endl;
 break;
 }
 K -= cnt[ans];
 }

 return 0;
 }


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] d = new int[m];
		for (int i = 0; i < m; i++) {
			d[i] = sc.nextInt();
		}
		int[][] dp = new int[m+1][n+1];
		for (int i = 0; i <= m; i++) {
			for (int j = 1; j <= n; j++) {
				dp[i][j] = Integer.MAX_VALUE; 
			}
		}
		dp[0][0] = 0;
		
		for (int i = 0; i < m; i++) {
			for (int j = 1; j <= n; j++) {
				
				int di = d[i];
				if (j >= di)
					dp[i+1][j] = Math.min(dp[i][j], dp[i+1][j-di] + 1);
				else
					dp[i+1][j] = dp[i][j];
			}
		}
		System.out.println(dp[m][n]);
	}
}

Measured memory_bytes: 26268
#include <cstdio>
#include <vector>
#pragma warning(disable : 4996)
using namespace std;
int n, m, a[200009], b[200009], e[400009], c[100009], s[100009], cnt, col[100009];
bool dfs(int pos) {
	bool ret = true; cnt++;
	for (int i = c[pos]; i < c[pos + 1]; i++) {
		if (col[e[i]] == col[pos]) ret = false;
		if (col[e[i]] == 0) {
			col[e[i]] = 3 - col[pos];
			if (!dfs(e[i])) ret = false;
		}
	}
	return ret;
}
int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d %d", &a[i], &b[i]);
		c[--a[i]]++; c[--b[i]]++;
	}
	for (int i = 0; i < n; i++) s[i + 1] = s[i] + c[i]; c[0] = 0;
	for (int i = 0; i < n; i++) c[i + 1] = s[i + 1];
	for (int i = 0; i < m; i++) e[s[a[i]]++] = b[i], e[s[b[i]]++] = a[i];
	int c0 = 0, c1 = 0, c2 = 0;
	for (int i = 0; i < n; i++) {
		if (col[i] == 0) {
			col[i] = 1; cnt = 0;
			bool res = dfs(i);
			if (cnt == 1) c0++;
			else if (!res) c1++;
			else c2++;
		}
	}
	printf("%lld\n", 1LL * (c1 + c2) * (c1 + c2) + 1LL * c2 * c2 + 1LL * n * n - 1LL * (n - c0) * (n - c0));
	return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 100005
using namespace std;
int n,in[M],fr[M],bk[M];
int main()
{
    while (~scanf("%d", &n)) {
        REP(i,1,n) scanf("%d", &in[i]);
        fr[0] = bk[n+1] = 0;
        REP(i,1,n) fr[i] = __gcd(fr[i-1], in[i]);
        for (int i=n; i>=1; i--) bk[i] = __gcd(bk[i+1], in[i]);

        int ans = fr[n];
        REP(i,1,n) {
            ans = max(ans, __gcd(fr[i-1], bk[i+1]));
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define llong long long
int n;
int s;
int pos[100100];
llong w[100100];
int main()
{
    scanf("%d%d",&n,&s);
    for(int i=1;i<=n;++i)scanf("%d%lld",&pos[i],&w[i]);
    int l=1,r=n;
    llong ans=0;
    int las=-1;//0为向左,1为向右
    while(233)
    {
        if(pos[r]<s||pos[l]>s)break;
        if(w[l]<w[r])
        {
            if(las!=1)ans+=pos[r]-pos[l];
            w[r]+=w[l];l++;
            las=1;
        }
        else
        {
            if(las!=0)ans+=pos[r]-pos[l];
            w[l]+=w[r];r--;
            las=0;
        }
    }
    ans+=max(abs(pos[r]-s),abs(pos[l]-s));
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

const int N = 10;

int h, w, k;
char b[N][N];

int solve() {
    int ans = 0;
    for (int i = 0; i < 1 << h; ++i) {
        for (int j = 0; j < 1 << w; ++j) {
            int cnt = 0;
            for (int r = 0; r < h; ++r) {
                for (int c = 0; c < w; ++c) {
                    if (i >> r & 1) continue;
                    if (j >> c & 1) continue;
                    cnt += b[r][c] == '#';
                }
            }
            if (cnt == k) ans++;
        }
    }
    return ans;
}

int main() {
    scanf("%d%d%d", &h, &w, &k);
    for (int i = 0; i < h; ++i) scanf("%s", b[i]);
    printf("%d\n", solve());
    return 0;
}

Measured memory_bytes: 3188
#include<stdio.h>
#include<string.h>
int main(){
int i,n,j;
char s[2000];
scanf("%d\n",&n);
for(i=0;i<n;i++){
fgets(s,1010,stdin);
for(j=0;j<strlen(s);j++){
if(s[j]=='H' && s[j+1]=='o' && s[j+2]=='s' && s[j+3]=='h' && s[j+4]=='i' && s[j+5]=='n' && s[j+6]=='o'){
s[j+6]='a';
}
}
printf("%s",s);
}
return 0;
}


Measured memory_bytes: 2096
fun main() = Thread(null, ::abc169b, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc169b() {
    readLine()
    val aList = readLine()!!.split(' ').map { it.toLong() }

    if (0 in aList) return println(0)

    var answer = 1L

    for (a in aList) {
        try {
            answer = Math.multiplyExact(answer, a)
        } catch (e: Exception) {
            return println(-1)
        }
    }

    val max = 1000000000000000000L

    if (answer > max) return println(-1)

    println(answer)
}


Measured memory_bytes: 63256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	while(cin>>n,n) 
	{
		int in[n];
		for(int i = 0; i < n; ++i)
		{
			cin>>in[i];
		}
		int sum=0;
		long long ans=0;
		sort(in,in+n);
		for(int i = 1; i < n; ++i)
		{
			sum+=in[i-1];
			ans+=sum;
		}
		cout<<ans<<endl;
	}
  return 0;
}

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
vector<string> S;
string T;

int main()
{
	cin >> N;
	S.assign(N,"");
	FOR(i,0,N){
		cin >> S [i];
	}
	cin >> T;

	int x = 0,y = 1;
	FOR(i,0,N){
		string a = S [i],z = S [i];
		FOR(j,0,a.size()){
			if(a [j] == '?'){
				a [j] = 'a';
				z [j] = 'z';
			}
		}
		if(a < T && z < T){
			x++;
		}
		if(a <= T && T <= z){
			y++;
		}
	}

	for(int i = x + 1;i <= x + y;i++){
		printf("%d%s",i,i == (x + y) ? "\n" : " ");
	}

	return 0;
}


Measured memory_bytes: 896
import java.util.*;
import java.io.*;
class Main {
    public static void main(String args[] ) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[] = br.readLine().split(" ");
        int num = Integer.parseInt(str[0]);
        int height = Integer.parseInt(str[1]);
        String str2[] = br.readLine().split(" ");
        long count=0;
        for(int i=0;i<str2.length;i++)
        {
            if(Integer.parseInt(str2[i])>=height)
                count++;
        }
        System.out.println(count);
   }
}

Measured memory_bytes: 31964
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <math.h>
using namespace std;

int main(){
  int N;  
  cin >> N;
  vector<int> A(N),B(N),C(N-1);
  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 - 1; i++){
    cin >> C[i];
  }

  unsigned long long ans = 0;
  int pre_index = -2;
  for(int i = 0; i < N; i++){
    ans += B[A[i]-1];
    if(A[i] == pre_index + 1){
      ans += C[pre_index-1];
    }
    pre_index = A[i];
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
using namespace std;
int n,x[100],y[100];
long h[100],g[101][101][2];

int dfs(int cx,int cy){
  long hh;
  for(int i=0;i<n;i++)
    if(h[i]!=0)
      hh=h[i]+(long)abs(cx-x[i])+(long)abs(cy-y[i]);
  for(int k=0;k<n;k++)
    if(g[x[k]][y[k]][0]==hh-(long)abs(cx-x[k])-(long)abs(cy-y[k])||(g[x[k]][y[k]][0]==0&&hh-(long)abs(cx-x[k])-(long)abs(cy-y[k])<=0));
    else
      return 0;
  printf("%d %d %ld\n",cx,cy,hh);
}

int main(){
  
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d %d %ld",&x[i],&y[i],&h[i]);
    g[x[i]][y[i]][0]=h[i];
    g[x[i]][y[i]][1]=1;
  }
  for(int i=0;i<=100;i++)
    for(int j=0;j<=100;j++)
      dfs(i,j);
}

Measured memory_bytes: 256
l = list(map(int,input().split()))
N = l[0]
A = l[1] 
B = l[2]
C = l[3]
D = l[4]
S = input()
S_list = list(S)

if B < C < D :
    count = 0
    for i in range(A, D-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    else : 
        print('Yes')
elif C < B < D :
    count = 0
    for i in range(A, C-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    for j in range(B, D-1):
        if S_list[j] == S_list[j+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    else :
        print('Yes')
elif B < D < C:
    count = 0
    for i in range(A, C-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1

    cou = 0
    for i in range(B-2, D-1):
        if S_list[i] == S_list[i+1] == S_list[i+2] == '.' :
            cou += 1
    if cou >= 1 and count < 1 :
        print('Yes')  
    else:
        print('No') 


Measured memory_bytes: 4984
#include<iostream>
int main() {
	int a,b,c,j=0;
	std::cin>>a>>b>>c;
	for(int i=a,j=1;j<=1000;i+=a,++j)
	if(i%b==c){
	std::cout<<"YES"<<std::endl;
	return 0;
	}
	std::cout<<"NO"<<std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mod = 1000000007;
void solve()
{
	int n;
	cin >> n;
	unordered_map<int, int> a1, a2;
	vector<pair<int, int>> arr(n);
	for (int c = 0; c < n; c++)
	{
		cin >> arr[c].first >> arr[c].second;
		a1[arr[c].first + arr[c].second] = 1;
		a2[arr[c].first - arr[c].second] = 1;
	}
	vector<int> as, bs;
	for (auto it = a1.begin(); it != a1.end(); it++)
		as.push_back(it->first);

	for (auto it = a2.begin(); it != a2.end(); it++)
		bs.push_back(it->first);
	sort(as.begin(), as.end());
	sort(bs.begin(), bs.end());

	int maxi = 0;
	for (int c = 0; c < n; c++)
	{
		int a1 = arr[c].first + arr[c].second;
		int a2 = arr[c].first - arr[c].second;
		maxi = max(maxi, max(a1 - as[0], a1 - as[as.size() - 1]));
		maxi = max(maxi, max(as[0] - a1, as[as.size() - 1] - a1));
		maxi = max(maxi, max(a2 - bs[0], a2 - bs[bs.size() - 1]));
		maxi = max(maxi, max(bs[0] - a2, bs[bs.size() - 1] - a2));
	}
	cout << maxi << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	//cin >> t;
	t = 1;
	for (int tt = 1; tt <= t; tt++)
	{

		solve();
	}
	return 0;
}

Measured memory_bytes: 23960
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = 998244353;
const long long INF_LL = 1e18+11; const int INF_int = 1e9+11;
#define ll long long
#define mp std::make_pair
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto x:a) cout << x << " ";cout << endl;
struct union_find{
    vector<int> par; 
    vector<int> size;
    //1からnまで初期化:par[i] = i(1<=i<=n)
    union_find(int n){
        par.push_back(0);
        size.push_back(1);
        for(int i = 1;i<=n;i++){
            par.push_back(i);
            size.push_back(1);
        }
    }
    int root(int a){
        if (par[a] == a) return a;
        par[a] = root(par[a]);
        return root(par[a]);
    }
    void unite(int a,int b){
        if (root(a) == root(b)) return;
        size[root(b)]+=size[root(a)];
        par[root(a)] = root(b);
    }
    bool same(int a,int b){
        return (root(a) == root(b));
    }
    //頂点aが含まれる木の大きさ(頂点数)
    int treesize(int a){
        return size[root(a)];
    }
};
int main(){
    int n,m;
    cin >> n >> m;
    union_find tree(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        tree.unite(a,b);
    }
    int ans = 0;
    rep(i,n){
        ans = max(tree.treesize(i+1),ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 10908
#include<stdio.h>
#include<string.h>
 
int main()
{
    char n[202];
    char s[202];
    int h,m,j,i=0,len=0;
     
     
    while(1){
         
        scanf("%s",n);
        if(n[0]=='-') break;
        len = strlen(n);
         
        scanf("%d",&m);
         
        for(j=0;j<m;j++){
            scanf("%d",&h);
         
 
        strncpy(s,n+h,len-h+1);
        strncat(s,n,h);
         
        strcpy(n,s);
        }
         
        puts(n);
    }
     
     
     
    return 0;
}
    


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define INF 1e9+5
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define forn(i,a,b) for(ll i=a;i<(ll)b;i++)
#define ff first
#define ss second
int check(string s)
{
	int n=s.length();
	for(int i=0;i<n/2;i++)
	{
		if(s[i]!=s[n-i-1])
			return 0;
	}
	return 1;
}
int32_t main()
{
	IOS;
	double n;
	cin>>n;
	cout<<(setprecision)(9)<<(n*n*n)/27<<"\n";
	return 0;
}

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

def gcd(a, b):
    while b != 0:
        t = a%b
        a = b
        b = t
    return a

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

    if arr==[]:
        arr.append(m)

    return arr

d = gcd(n[0],n[1])

c = factorization(d)


print(len(c))


Measured memory_bytes: 3188
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

last = 30
score = 0
for i in range(n):
    score += b[a[i] - 1]
    if last + 1 == a[i]:
        score += c[last - 1]
    last = a[i]
print(score)

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

typedef long long ll;

const int size = 1e5 + 5;
ll dp[101][size];

int main()
{
	int n, W;
	std::cin >> n >> W;
	std::vector<int> ws(n + 1);
	std::vector<int> vs(n + 1);
	ll sum = 0;
	for (int i = 1; i <= n; ++i)
	{
		std::cin >> ws[i] >> vs[i];
		sum += vs[i];
	}
	for (int i = 0; i <= n; ++i)
	{
		for (int j = 0; j <= sum; ++j)
		{
			dp[i][j] = std::numeric_limits<int>::max();
		}
	}
	dp[0][0] = 0;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 0; j <= sum; ++j)
		{
			dp[i][j] = dp[i - 1][j];
			if (vs[i] <= j)
			{
				dp[i][j] = std::min(dp[i][j], dp[i - 1][j - vs[i]] + ws[i]);
			}
		}
	}
	int ans = 0;
	for (int i = sum; i > 0; --i)
	{
		if (dp[n][i] <= W)
		{
			ans = i;
			break;
		}
	}
	std::cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 82532
#include <stdio.h>
 
int main(void) {
	int a, b;
	scanf("%d%d", &a, &b);
	if (a>b) {
		printf("a > b\n");
	}
	if (a<b) {
		printf("a < b\n");
	}
	if (a==b) {
		printf("a == b\n");
	}
	return 0;
}

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

//Compiler version g++ 6.3.0

int main()
{
    long long int n,a=0,b=0,c=0,d=0;
    string s;
    cin>>n;
    while(n--){
      cin>>s;
      if(s== "AC"){
        a++;
      }
      else if(s == "WA"){
        b++;
      }
      else if(s == "TLE"){
        c++;
      }
      else{
        d++;
      }
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;
    return 0;
}

Measured memory_bytes: 3620