akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <iostream>
#include <bitset>
#include <map>

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define pp pair<int,int>
#define fix(n) fixed << setprecision(n)
#define gmax(a,b) __gcd(a,b)
#define gmin(a,b) a/__gcd(a,b)*b
using namespace std;


int main(){
    int k,n;cin>>n>>k;
    vi a(n);
    rep(i,n)cin>>a.at(i);
    sort(all(a));
    int j=0;
    rep(i,k){
        j+=a.at(i);
    }

cout<<j<<endl;
return 0;

}

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define for(i,a,b) for(ll i=(a);i<=(b);i++)
#define ford(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define size(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)



int main(void) {
    long double N,ans;
    cin >> N;
    ans = N *2 * 3.14159265358979323;
  
  
  

  cout << ans << "\n"; 
  return 0;
}

Measured memory_bytes: 3792
#include <iostream>


using namespace std;

int main()
{
    int A , B;
    cin>>A>>B;
    if(-100<=A&&B<=100)
    {

    long long result1 = A + B;
    int result2 = A - B;
    long long result3 = A * B;
    if(result1>=result2 && result1>=result3)
    {
        cout<<result1<<endl;
    }
    else if(result2>=result1 && result2>=result3)
    {
        cout<<result2<<endl;
    }
    else if(result3>=result1 && result3>=result2)
    {
        cout<<result3<<endl;
    }
    }
    return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int X;
  cin >> X;
  vector<int> d(X);
  rep(i, X) cin >> d[i];

  sort(all(d));
  d.erase(unique(all(d)), d.end());

  cout << d.size() << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int x;
    if(b<10)x=10*a+b;
    else if(b<100)x=100*a+b;
    else x=1000*a+b;
    for(int i=1;i<x;i++)
    {
        if(i*i==x)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Main
 */
public class Main {

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

        long L = sc.nextLong();
        long R = sc.nextLong();

        sc.close();
        
        int min = 2019;

        if(R-L > 2018){
            min = 0;
        }else{
         for(long i = L; i <= R-1; i++){
             for(long j= i+1; j <= R; j++){
                 long tmp = i*j%2019;
                 min = (int) Math.min(tmp, min);
             }
         }
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
int alpha[26] , f[26];
signed main(){
  int n;
  string s;
  vector<char> c;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    for(int j=0;j<s.size();j++){
      f[s[j]-'a']++;
    }
    for(int j=0;j<26;j++){
      if(i == 0){
        alpha[j]=100;
      }
      alpha[j]=min(alpha[j],f[j]);
      f[j]=0;
    }
  }
  
  for(int i=0;i<26;i++){
    for(int j=0;j<alpha[i];j++){
      c.push_back(i+'a');
    }
  }
  sort(c.begin(),c.end());
  
  for(int i=0;i<c.size();i++){
    cout<<c[i];
  }
  
  cout<<endl;
  return(0);
}

Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHEEM
                                      //ALLAH IS WATCHING ME

//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█


#include<bits/stdc++.h>

#define ull    unsigned long long
#define ll   long long
#define ses   "\n"

using namespace std;

//main function is here.... ....
int main(){
string s,ss,sm,sd;
cin>>s;
ss = s.substr(0,4);
int n = stoi(ss);
sm = s.substr(5,6);
sd = s.substr(8,9);
int nm = stoi(sm);
int nd = stoi(sd);
//cout<<n<<" "<<nm<<" "<<nd<<ses;
if(n<2019){
    cout<<"Heisei";
}
else if(n==2019 &&  nm<4){
      cout<<"Heisei";
}
else if(n==2019 &&  nm==4 && nd<=30){
      cout<<"Heisei";
}
else{
    cout<<"TBD";
}
}

//Alhamdulillah


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

int main(void){
    int n,m;
    scanf("%d %d",&n,&m);
    int s[m],c[m];
    for(int i = 0;i < m;i++)scanf("%d %d",&s[i],&c[i]);
    int max = 1;
    int tmp_num;
    bool isok;
    for(int c = 0;c < n;c++)max *= 10;
    for(int num = (n==1?0:(max/10));num < max;num++){
        tmp_num = num;
        isok = true;
        for(int qr = 0;qr < m;qr++){
            tmp_num = num;
            for(int dig = 0;dig < n - s[qr];dig++)tmp_num /= 10;
            if(tmp_num % 10 != c[qr]){
                isok = false;
                break;
            }
        }
        if(isok){
            printf("%d",num);
            return 0;
        }
    }
    printf("%d",-1);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a,b,c,d,n,m,x,y,z,k,h,w,sum,mi,ma,ans,s,t,l[10],r,res,tmp,itr,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<int, int> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<int,int> > VP;

int main(){
    cin>>n>>k;
    VL h(n);
    rep(i,n)cin>>h[i];
    sort(all(h));
    mi=inf;
    rep(i,n-k+1){mi=min(mi,h[k-1+i]-h[i]);d(mi);}
    p(mi);
    return 0;
}


Measured memory_bytes: 1024
#関数リスト
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())

a,b,c = MI()
K = I()

while K >= 0:
    if a >= b:
        b *= 2
        K -= 1
    elif b >= c:
        c *= 2
        K -= 1
    else:
        print("Yes")
        sys.exit()
print("No")

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

const int N = 1e5 + 9, P = 1e9 + 7;

typedef long long ll;
int n, ans;
ll a, b, s[N], sum[N], f[N];
typedef long long ll;

int main () {
	scanf("%d%lld%lld", &n, &a, &b); if (a > b) a ^= b ^= a ^= b;
	s[0] = -1e18; f[0] = sum[0] = 1;
	for (int i = 1, j = 0, k = -1; i <= n; ++i) {
		scanf("%lld", &s[i]);
		if (i > 2 && s[i] - s[i - 2] < a) return puts("0"), 0;
		while (s[i] - s[j] >= b) ++j; --j;
		if (j > k) f[i] = (sum[j] - (k == -1 ? 0 : sum[k])) % P;
		if (s[i] - s[i - 1] < a) k = i - 2;
		sum[i] = (sum[i - 1] + f[i]) % P;
	}
	for (int i = n; ~i; --i) {
		ans = (ans + f[i]) % P;
		if (i < n && s[i + 1] - s[i] < a) break ;
	}
	printf("%d\n", (ans + P) % P);
	return 0;
}

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

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

    if (a + b + 1 <= c) {
        cout << a + 2 * b + 1 << endl;
    }
    else
    {
        cout << b + c << endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define len(x) (int) (x.size())
using namespace std;
typedef long long ll;

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

    ll rest = n % (a+b);
    ll div = n / (a+b);

    ll ans = 0;
    
    if (rest < a) ans += rest;
    else ans += a;
    ans += div*a;

    cout << ans << '\n';
    
    return 0;
}

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

int foo(vector<string> s[], vector<string> t[]){
  if(s[0].size() != t[0].size() || s[1].size() != t[1].size())return false;
  //  cout<<s[0].size()<<" "<<t[0].size()<<" "<<s[1].size()<<" "<<t[1].size()<<endl;
  for(int i = 0; i < s[0].size(); i++){
    if(s[0][i] != t[0][i])return false;
  }
  for(int i = 0, count = 0; i < s[1].size(); i++){
    if(s[1][i] != t[1][i]){
      count++;
      if(count == 2)return false;
    }
  }
  return true;
}

int main(){
  while(true){
    string s1, s2, temp;
    vector<string> s[2], t[2];
    cin>>s1;

    if(s1 == ".")break;
    
    cin>>s2;

    if(s1==s2){cout<<"IDENTICAL"<<endl; continue;}
 
    for(int i = 0,f=0; i < s1.size(); i++){
      if(s1[i] == '"'|| i == s1.size()-1){
	s[f].push_back(temp);
	f = !f;
	temp.clear();
	temp+="a";
      }else temp += s1[i];
    }
    temp.clear();
    for(int i = 0,f=0; i < s2.size(); i++){
      if(s2[i] == '"'|| i == s2.size()-1){
	t[f].push_back(temp);
	f = !f;
	temp.clear();
	temp+="a";
      }else temp += s2[i];
    }

    cout<<(foo(s,t)?"CLOSE":"DIFFERENT")<<endl;;
  }
  return 0;
}



Measured memory_bytes: 3172
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int n,d,ans;
int a[12][12];
int main()
{
	scanf("%d%d",&n,&d);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=d;j++)
			scanf("%d",&a[i][j]);
	
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++)
		{
			int s=0;
			for(int k=1;k<=d;k++)
				s+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			double b=sqrt(s);
			if(int(b)==b)ans++;
		}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
int a, b;
int main() {
  cin >> a >> b;
  int l = min(a, b);
  int u = max(a, b);
  for(int i = 0; i < u; ++i) {
    cout << l;
  }
  cout << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			try{
				int N = in.nextInt();
				int count = 0;
				for(int a = 0;a < 10;a++){
					for(int b = 0;b < 10;b++){
						for(int c = 0;c < 10;c++){
							for(int d = 0;d < 10;d++){
								if(N == a + b + c + d){
									count++;
								}
							}
						}
					}
				}
				System.out.println(count);		
			}catch(Exception e){
				System.exit(0);
			}
		}
	}
}

Measured memory_bytes: 19080
import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c for j in range(b)] for i in range(a)]
def list3d(a, b, c, d): return [[[d for k in range(c)] for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10**9)
INF = 10**19
MOD = 10**9 + 7
EPS = 10**-10

N = INT()
A = LIST()
B = LIST()

C1 = Counter(A)
C2 = Counter(B)
for k, v in C1.items():
    if v > N-C2[k]:
        No()
        exit()

ans = B[ceil(N, 2):] + B[:ceil(N, 2)]

def check(A, B):
    for i in range(N):
        if A[i] == B[i]:
            return i
    return -1

def swap(x, A, B):
    for i in range(N):
        if A[x] != B[i] and A[i] != B[x]:
            B[x], B[i] = B[i], B[x]
            return True
    return False

while 1:
    res = check(A, ans)
    if res == -1:
        Yes()
        print(*ans)
        break
    else:
        if not swap(res, A, ans):
            No()
            break


Measured memory_bytes: 169004
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define fi first
#define se second
#define db double
#define U unsigned
#define P std::pair<int,int>
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#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 DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 5000+5;
LL f[MAXN][MAXN];
// 所有数字都移动肯定能有序 所以要对不移动的位置 dp
int A,B;
int n,p[MAXN];

int main(){
    scanf("%d%d%d",&n,&A,&B);
    FOR(i,1,n) scanf("%d",p+i);
    CLR(f,0x3f);f[0][0] = 0;
    FOR(i,1,n){
        FOR(j,0,n){
            if(p[i] > j){
                f[i][j] = std::min(f[i][j],f[i-1][j]+A);
                f[i][p[i]] = std::min(f[i][p[i]],f[i-1][j]);
            }
            else{
                f[i][j] = std::min(f[i][j],f[i-1][j]+B);
            }
        }
    }
    LL ans = 1e18;
    FOR(i,1,n) ans = std::min(ans,f[n][i]);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 196096
count_a=0
count_b=0

while line=gets
	a,b,c=line.chomp.split(",").map{|s| s.to_i}
	if  a==b then
		count_b+=1
	end
	if (a**2+b**2==c**2) then
		count_a+=1
	end 
end
puts count_a,count_b


Measured memory_bytes: 6840
${map$q[$_]+=$q[$N]/@$N,@{/ /,push@
$`,$' for<>;$N=$_}for($q[1]=$b=1)..<>;$e[$N]=$b+=$_/@@for@@=sort@e[@$N];a}<($~=$q[$N]*($b-1-$@[-1])/($#@||1))or$a=$~while--$N;print$a+$b

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    string s1, s2; cin >> s1 >> s2;
    if(s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;


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

	int a, b;
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
constexpr ll MOD = 998244353;

int main()
{
    int N;
    cin >> N;
    vector<int> D(N);
    rep(i, N)cin >> D[i];

    if (D[0] != 0 || count(D.begin(), D.end(), 0) != 1) {
        cout << 0 << endl;
        return 0;
    }
    map<int, int> mp;
    for (int num : D) {
        mp[num]++;
    }
    int mx = *max_element(D.begin(), D.end());
    rep(i, mx) {
        if (mp[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    ll res = 1;
    rep(i, mx) {
        rep(j, mp[i + 1]) {
            (res *= mp[i]) %= MOD;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 5376
import math , sys

N , M = list(map( int, input().split() ))

cor = 0
pen = 0

F = [False]*N
C = [0]*N

for i in range(M):
    A , B = list( input().split() )
    A = int(A)-1

    if B == "WA" and not F[A]:
        C[A]+=1

    #print(C)

    if B == "AC" and not F[A]:
        F[A] = True
        cor += 1
        pen +=C[A]
print(cor,pen)

Measured memory_bytes: 76924
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)


ll modpow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        ll h = modpow(x, n / 2);
        return h * h % MOD;
    } else {
        return x * modpow(x, n - 1) % MOD;
    }
}

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

int vector_finder(vector<int> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance(vec.begin(), itr);
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
    int N; cin >> N;
    vector<int> X(N);
    rep(i,N)  cin >> X[i];
    auto Y = X;
    sort(Y.begin(),Y.end());
    int m = N/2-1;
    int med = Y[m];
    int med_2 = Y[m+1];
    rep(i,N){
      if(X[i] <= med) cout << med_2 << endl;
      else  cout << med << endl;
    }
    return 0;
}


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


int main() {
    ll A,B,K;
    cin >> A >> B >> K;
    for (int i = 0; i < K; i++)
    {
        if(A+i <= B) cout << A+i << endl;
    }
    for (int i = 0; i < K; i++)
    {
        if(B-K+1+i > A+K-1) cout << B-K+1+i << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
//cout << fixed << setprecision(0)
int main() { 
  string s;cin >> s;
  string ans="No";
  rep(i,2){
    if(s[i]=='9')ans="Yes";
  }
  cout << ans << endl;
}


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

/* 
 * g++ -std=c++17 main.cpp -o main
 */
int main() {
  ios::sync_with_stdio(false);
  string a, b, c;
  cin>>a>>b>>c;
  int na = a.size(), nb = b.size(), nc = c.size();
  int ia = 0, ib = 0, ic = 0;
  char turn = 'a';
  while(1) {
    if (turn == 'a') {
      if (ia == na) {
        cout << "A" << endl;
        return 0;
      }
      turn = a[ia++];
    }
    if (turn == 'b') {
      if (ib == nb) {
        cout << "B" << endl;
        return 0;
      }
      turn = b[ib++];
    }
    if (turn == 'c') {
      if (ic == nc) {
        cout << "C" << endl;
        return 0;
      }
      turn = c[ic++];
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
#define PI 3.1415926535897932384626433832795
#define coutfix(i) cout << fixed << setprecision(i)
using namespace std;

int main()
{
	int64 nn;
	cin >> nn;
	long double aa, ans = 0.0;
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> aa;
		ans += 1.0 / aa;
	}
	ans = 1.0 / ans;
	coutfix(15);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3780
n=int(input())
a=[int(inp)-(i+1) for i,inp in enumerate(input().split())]
a.sort()

if n%2==1:
    b=a[int(n*0.5)]
    ans=sum([abs(x-b) for x in a])
else:
    b1=a[int(n*0.5)]
    b2=a[int(n*0.5)-1]
    ans1=sum([abs(x-b1) for x in a])
    ans2=sum([abs(x-b2) for x in a])
    ans=min(ans1, ans2)

print(ans)

Measured memory_bytes: 26180
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define MOD 1000000009
using namespace std;
typedef long long ll;
int main()
{
  int n;
  char t;
 cin >> n >> t;
char tmp = t;
int counter  = 1;
for(int i = 1; i < n ; i ++){
	cin >> t ;
  	if(t != tmp){
		tmp = t;
      	counter ++;
   	}
 }
cout << counter << endl;
//  cin >> n >> s;
//  int counter = 0;
//  char tmp;
//  REP(i,n){
//    tmp = s[i];
//	cout << i << "  " << tmp << endl;
//    for(int j = i + 1; j < n; j ++){
//      if(s[j] == tmp){
//	  
//      }else{
//		counter ++;
//		i = j - 1;
//		break;
//      }
//    }
//  }

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
typedef pair<int,int> P;
#define INF 1e9

int main(){
    int n,d;
    cin>>n>>d;
    int a = 2*d+1;
    int t = n;
    int ans = 0;
    while(t>0){
        t-=a;
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
from itertools import accumulate

N, M = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse = True)
#print(A)

ok = -1
ng = 10 ** 11
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    left, right = 0, N - 1
    cnt = 0
    while left <= N - 1 and right >= 0:
        if A[left] + A[right] >= mid:
            cnt += right + 1
            left += 1
        else:
            if right:
                right -= 1
            else:
                left += 1
    if cnt >= M:
        ok = mid
    else:
        ng = mid
#print(ok)

Acum = [0] + list(accumulate(A))
#print(Acum)

left, right = 0, N - 1
cnt = 0
answer = 0
while left <= N - 1 and right >= 0:
    if A[left] + A[right] >= ok:
        cnt += right + 1
        answer += (right + 1) * A[left] + Acum[right + 1]
        left += 1
    else:
        if right:
            right -= 1
        else:
            left += 1
        
answer -= (cnt - M) * ok
print(answer)

Measured memory_bytes: 60456
function main()
	N,K=map(x->parse(Int,x),split(readline()))
	A=map(x->parse(Int,x),split(readline()))
	vis=-ones(Int,N)
	now=1
	cnt=0
	pre=Int[]
	while vis[now]==-1
		vis[now]=cnt
		cnt+=1
		push!(pre,now)
		now=A[now]
	end
	if K<vis[now]
		println(pre[K+1])
	else
		K-=vis[now]
		K%=cnt-vis[now]
		println(pre[vis[now]+K+1])
	end
end
main()


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

string S;
int main(){
 cin >> S;
  if((S[0]==S[1] && S[1]==S[2])|| (S[1]==S[2] && S[2]==S[3]))
    cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
src = input()
a = False
b = False
c = False
d = False
for s in src:
    if s == 'N':
        a = True
    elif s == 'W':
        b = True
    elif s == 'S':
        c = True
    elif s == 'E':
        d = True
if a != c or b != d:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
int main() {
    int N;
    cin >> N;
    string result = "No";

    int quotient, remain;
    for (int i = 1; i < 10; i++) {
        quotient = N / i;
        remain = N % i;
        if (remain == 0 && quotient < 10) {
            result = "Yes";
        }
    }

    cout << result << endl;
}


Measured memory_bytes: 256
N = int(input())
t = [0] + list(map(int, input().split())) + [0]
v = [0] + list(map(int, input().split())) + [0]
for i in range(N, 0, -1):
    v[i] = min(v[i], v[i + 1] + t[i])
for i in range(1, N + 1):
    v[i] = min(v[i], v[i - 1] + t[i])
ans = 0
v_f = 0
for i in range(1, N + 1):
    v_l = min(v_f + t[i], v[i + 1], v[i])
    if 2 * v[i] - v_f - v_l <= t[i]:
        ans += (v[i] + v_f) * (v[i] - v_f) / 2 + v[i] * (t[i] - 2 * v[i] + v_f + v_l) + (v[i] + v_l) * (v[i] - v_l) / 2
    else:
        t_1 = (t[i] + v_l - v_f) / 2
        t_2 = t[i] - t_1
        ans += (2 * v_f + t_1) * t_1 / 2 + (2 * v_l + t_2) * t_2 / 2
    v_f = v_l
print('{:.10f}'.format(ans))

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



int main() {
    //input
    long long a,b,x;
    cin >> a >> b >> x;

    long long count = 0;
    if(a == 0){
        count = b / x + 1;
    }else{
        count = (b / x + 1) - ((a-1) / x + 1);
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
map<string,int>q;
int n;
string s;
string t[200000];

int main() {
cin>>n;
  for(int i=0;i<n;i++) {
  	cin>>s;
    if(!q.count(s)) {
    	q[s] = 1;
    }else q[s] ++;
  }
  int m = 0;
  map<string,int>::iterator iter;
    iter = q.begin();
    while(iter != q.end()){
        m = max(m, iter->second);
        iter++;
    }
  iter = q.begin();
  n = 0;
    while(iter != q.end()){
        if(m == iter->second) {
        	t[n ++] = iter->first;
        }
        iter++;
    }
  sort(t, t + n);
  for(int i=0;i<n;i++) {
  	cout<<t[i]<<endl;
  }
}

Measured memory_bytes: 26752
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	int a;
	cin >> a;

	cout << 24 + 24 - a << endl;

		
}

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

typedef long long LL;
const int M=3005;
const LL NINF=0x8080808080808080;
int a[M];

LL dp[M][M];
LL getdp(int l,int r)
{
	if(l==r) return a[l];
	LL &ans=dp[l][r];
	if(ans!=NINF) return ans;
	ans=max(a[l]-getdp(l+1,r),a[r]-getdp(l,r-1));
	return ans;
}

int main()
{
	int n; scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	memset(dp,0x80,sizeof(dp));
	printf("%lld\n",getdp(1,n));
	return 0;
}

Measured memory_bytes: 71040
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

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

        Deque<Integer> list = new ArrayDeque<>();

        for (int i=0; i<n; i++) {
            String str = br.readLine();

            if (str.startsWith("insert")) {
                list.addFirst(Integer.parseInt(str.substring(str.indexOf(" ")+1)));
            }else if (str.equals("deleteFirst")) {
                list.pollFirst();
            }else if (str.equals("deleteLast")){
                list.pollLast();
            }else {
                list.remove((Integer)Integer.parseInt(str.substring(str.indexOf(" ")+1)));
            }
        }
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        StringBuilder sb = new StringBuilder();
        sb.append(list.poll());
        for (Integer s : list) {
            sb.append(" ");
            sb.append(s);
        }
        bw.write(sb.toString());
        bw.newLine();
        bw.close();

        br.close();
    }
}



Measured memory_bytes: 125612
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <bitset>
#include <fstream>

#define ll long long
#define scani(x) scanf("%i", &x)
#define scanll(x) scanf("%I64d", &x)
#define scanfl(x) scanf("%f", &x)
#define scanch(x) scanf("%c", &x)
#define scans(x) scanf("%s", x);
#define printi(x) printf("%i", x);
#define printll(x) printf("%I64d", x);
#define printfl(x) printf("%f", x);
#define printch(x) printf("%c", x);
#define prints(x) printf("%s", x);
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define INFI (1 << 29)
#define INFL (1LL << 62)
#define sz(x) int(x.size())
#define fi first
#define se second
#define forn(i, n) for(ll i = 0; i < n; i++)
#define for1(i, n) for(ll i = 1; i <= n; i++)
#define ford(i, n) for(ll i = (n - 1); i >= 0; i--)
#define fori(i, n) for(ll i = n; i >= 1; i--)
#define fore(i, l, r) for(ll i = l; i <= r; i++)
#define get_bit(mask, x) (bool)(mask & (1LL << x))
#define set_bit(mask, x) (mask |= (1LL << x))
#define reset_bit(mask, x) (mask &= ~(1LL << x))
#define toggle_bit(mask, x) (mask ^= (1LL << x))

using namespace std;

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

    ll n, r = 0;

    cin >> n;

    for1(i, n)
    {
        ll d = 0, v = i;

        while(v)
        {
            v /= 10;

            d++;
        }

        r += (d % 2);
    }

    cout << r << "\n";

    return 0;
}


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



int main()
{
	long long int i, j, k, l, m, n, sum, flag,K, N, M,cnt;
	cin >> N >> K;
	if (N%K == 0) {
		cout << 0 << endl;
	}
	else
		cout << 1 << endl;
		


    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)


int main(){
	int n,l;
	cin>>n>>l;
	
	vector<pii> vec(n);
	rep(i,n){
		int a,b;
		cin>>a>>b;
		vec[i] = pii(a,b);
	}
	
	int dp[100000+1]={};
	
	rep(i,n){
		int v,w;
		tie(v,w) = vec[i];
		for(int j=100000;j>=0;j--){
			if(j-w<0)continue;
			dp[j] = max(dp[j-w]+v,dp[j]);
		}
	}
	
	int maxi = -INF;
	rep(i,l+1)maxi = max(maxi,dp[i]);
	cout<<maxi<<endl;
}

Measured memory_bytes: 3480
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long


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

    double n,k; cin >> n >> k;
    vector<double> p(n);
    for(double i = 0;i < n; i++){
        cin >> p.at(i);
    }

    vector<double> a(n);
    for(double i = 0;i < n;i ++){
        a.at(i) = (1+p.at(i)) / 2;
    }

    vector<double> b(n);
    for(double i = 0;i < k;i ++){
        b.at(0) += a.at(i);
    }
    for(double i = 1;i < n-k+1;i ++){
        b.at(i) = b.at(i-1) - a.at(i-1) + a.at(i+k-1);
    }

    double ans = 0;
    for(double i = 0;i < n-k+1;i ++){
        ans = max(ans,b.at(i));
    }

    cout << setprecision(10) << ans << endl;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#define MOD (ll)(1e9+7)
using namespace std;
int main(){
    vector<int> prime;
    prime.push_back(2);
    rep(i,3,1000){
        bool f=true;
        rep(j,prime.size()){
            if (i%prime[j]==0){
                f=false;
                break;
            }
        }
        if (f){
            prime.push_back(i);
        }
    }
    int n;
    cin>>n;
    map<int,int> mp;
    for (int i=n;i>=1;i--){
        int p=1;
        int now=i;
        for (int p:prime){
                while (now%p==0){
                    mp[p]++;
                    now/=p;
                    }
                
            p++;
        }
    }
    mp[1]=0;
    ll ans=1;
    for (auto x: mp){
        ans*=x.second+1;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
use proconio::{input,fastout};

#[fastout]

fn main() {
    input! {
        n: usize,
        d: usize,
        x: [[isize; d]; n],
    }
    let mut cnt = 0;
    for i in 0..n-1 {
        for j in i+1..n {
            let mut m = 0;
            for k in 0..d {
                m += (x[i][k] - x[j][k]).pow(2);
            }
            let mut l = (m as f64).sqrt().round() as isize;
            if l * l == m {cnt += 1;}
        }
    }
    println!("{}",cnt);
}


Measured memory_bytes: 2620
#include<bits/stdc++.h>
#define LL long long
LL n;
LL gcd(LL a ,LL b)
{
    return b == 0 ? a : gcd(b , a%b );
}
LL lcm(LL a , LL b)
{
    return a*b/gcd(a,b);
}
int main()
{
    scanf("%lld",&n);
    printf("%lld",lcm(n,2));
    return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

//O(|V|+|E|)

template<class graph_type> class bridge_and_articulation{
public:
    const int size;
    graph_type graph;
    vector<bool> used,is_art;
    vector<int> ord,low,articulations;
    vector<pair<int,int>> bridges;

    bridge_and_articulation(const graph_type &graph):graph(graph),size(graph.size()),used(size),is_art(size),ord(size),low(size){
        int k=0;
        for(int i=0; i<size; ++i) if(!used[i]) dfs(i,-1,k);
    }

    void dfs(int v,int p,int &k){ //v???????????¨???p=-1
        used[v]=true;
        ord[v]=low[v]=k++;

        int count=0;
        for(const auto &edge:graph[v]){
            const int u=edge.to;
            if(!used[u]){
                ++count;
                dfs(u,v,k);
                low[v]=min(low[v],low[u]);

                if(ord[v]<low[u]) bridges.push_back(make_pair(min(v,u),max(v,u)));
                if(p!=-1 and ord[v]<=low[u]) is_art[v]=true;
            }else if(ord[u]<ord[v]) low[v]=min(low[v],ord[u]);
        }

        if(p==-1 and count>1) is_art[v]=true;
        if(is_art[v]) articulations.push_back(v);
    }

    bool is_bridge(int u,int v)const{
        if(ord[u]>ord[v]) swap(u,v);
        return ord[u]<low[v];
    }

    bool is_articulation(int v)const{
        return is_art[v];
    }
};

struct edge{
    int to;
};

void solve(){
    int v,e;
    cin >> v >> e;
    vector<vector<edge>> graph(v);
    rep(i,0,e){
        int s,t;
        cin >> s >> t;
        graph[s].push_back(edge({t}));
        graph[t].push_back(edge({s}));
    }
    bridge_and_articulation<vector<vector<edge>>> ba(graph);
    vector<int> ans=ba.articulations;
    sort(ans.begin(),ans.end());
    for(int v:ans) cout << v << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 5156
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=l; i<=r; i++)
typedef long long ll;
using namespace std;

const int N=1000010;
char s[N];

int main(){
	scanf("%s",s+1); int n=strlen(s+1);
	if (s[1]=='0' || s[n]=='1') { puts("-1"); return 0; }
	rep(i,1,n-1) if (s[i]!=s[n-i]){ puts("-1"); return 0; }
	printf("%d %d\n",1,2); int x=2;
	rep(i,2,n-1){
		printf("%d %d\n",x,i+1);
		if (s[i]=='1') x=i+1;
	}
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    N%=10;
    if(N==3){
        cout << "bon" << '\n';
    }else if(N<2 || N==6 || N==8){
        cout << "pon" << '\n';
    }else{
        cout << "hon" << '\n';
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S;
    cin >> S;

    int N = S.length();
    int cnt_N = 0;
    int cnt_S = 0;
    int cnt_W = 0;
    int cnt_E = 0;

    for (int i = 0; i < N; i++){
        if (S[i] == 'N'){
            cnt_N++;
        }
        else if (S[i] == 'S'){
            cnt_S++;
        }
        else if (S[i] == 'W'){
            cnt_W++;
        }
        else {
            cnt_E++;
        }
    }

    if (cnt_N > 0 && cnt_S > 0){
        if (cnt_W > 0 && cnt_E > 0){
            cout << "Yes" << endl;
        }
        else if (cnt_W == 0 && cnt_E == 0){
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }

    else if (cnt_N == 0 && cnt_S == 0){
        if (cnt_W > 0 && cnt_E > 0){
            cout << "Yes" << endl;
        }
        else if (cnt_W == 0 && cnt_E == 0){
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;++i){
		int s=0,k=i;
		while(k){
			s++;k/=10;
		}
		if(s&1)ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

template<class T> inline bool chmin(T &a,T b){
    if (a>b){a=b; return true;} return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){a=b; return true;} return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W,N; cin >> H >> W >> N;
    cout << (max(H,W)+N-1)/max(H,W) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    char S[14];
    int i;
    int win = 0;
    int lose = 0;
    scanf("%s",S);
    
    for(i=0;S[i]!='\0';i++);
    
    for(i=0;S[i];i++){
        if(S[i] == 'o'){
            win ++ ;
        }
        if(S[i] == 'x'){
            lose ++ ;
        }
    }
    
    if(lose < 8){
        printf("YES\n");
    }
    if(lose >= 8){
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <stack>
#include <cstdlib>
#include <algorithm>
using namespace std;


int main() {
    int n;
    cin >> n;
    while(n--) {
        string s; cin >> s;

        stack < string > st;
        for(int i = 0; i < s.size(); i++) {
            if(s[i] == '[' && isdigit(s[i + 1])) {
                string v = "";
                i++;
                for(; s[i] != ']'; i++)
                    v += s[i];
                st.push(v);
            }
            else if(s[i] == '[') st.push("[");
            else if(s[i] == ']') {
                vector< int > v;
                while(true) {
                    string c = st.top(); st.pop();
                    if(c == "[") break;
                    v.push_back(atoi(c.c_str()));
                }
                if(s[i - 2] == ']') {
                    int sum = 0;
                    sort(v.begin(), v.end());
                    for(int j = 0; j < v.size() / 2 + 1; j++) {
                        //cout << v[j] << endl;
                        sum += v[j];
                    }
                    st.push(to_string(sum));
                } else {
                    int sum = 0;
                    sort(v.begin(), v.end());
                    for(int j = 0; j < v.size() / 2 + 1; j++) {
                        //cout << v[j] / 2  + 1 << endl;
                        sum += v[j] / 2 + 1;
                    }
                    st.push(to_string(sum));
                }
            }
        }
        cout << st.top() << endl;
    }
}



Measured memory_bytes: 3372
n=int(input())
xy_1 = [0]*n
xy_2 = [0]*n
for i in range(n):
  x,y = map(int,input().split())
  xy_1[i] = x + y
  xy_2[i] = x - y

print(max(max(xy_1) - min(xy_1), max(xy_2)-min(xy_2)))

Measured memory_bytes: 24688
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 200010
char s[MAXN];
int n,k,l,p,f;
int main()
{
	scanf("%d%d%s",&n,&k,s+1);
	p=1;
	for(l=1;l<=n*2+10;l++)
	{
		int t=(s[p]=='A');
		if(t^f) s[p]=t+'A';
		else
		{
			f^=1;
			p++;
		}
		if(l==k)
		{
			if(f)
			{
				for(int i=p;i<=n;i++)
					s[i]=(s[i]=='A')+'A';
			}
			for(int i=p;i<=n;i++)
				printf("%c",s[i]);
			for(int i=1;i<p;i++)
				if(f!=(i&1)) printf("B");
				else printf("A");
			return 0;
		}
		if(p>n) break;
	}
	if(f==0||(f&&l%2!=k%2)) printf("B");
	else printf("A");
	for(int i=2;i<=n;i++)
		if(f!=(i&1)) printf("B");
		else printf("A");
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp(a,b) make_pair(a,b)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*y/gcd(x,y);
}

int main(){
    ll N; cin>>N;
    map<ll,ll> m;
	rep(i,N){
        ll a; cin>>a;
        auto itr=m.find(a);
        if(itr!=m.end()){
            (itr->second)++;
        }
        else{
            m.insert(mp(a,1));
        }
    }
    ll cnt=0,ans=1;
    auto itr=m.end();
    --itr;
    while(itr!=--m.begin()){
        if((itr->second)>=2){
            ans*=(itr->first);
            cnt++;
            if(cnt==2){
                cout<<ans<<endl;
                return 0;
            }
            (itr->second)-=2;
        }
        else{
            --itr;
        }
    }
    if(cnt<2) cout<<0<<endl;
}

Measured memory_bytes: 6528
n,k = map(int,input().split())
from collections import deque
l = [[] for _ in range(n)]
for i in range(n-1):
    ta,tb = map(int,input().split())
    l[ta-1].append(tb-1)
    l[tb-1].append(ta-1)
c,q = k,deque([0])

while q:
    v,i = q.pop(),1
    for w in l[v]:
        c = c*(k-i-(v>0))%(10**9+7)
        l[w].remove(v)
        q.append(w)
        i+=1
print(c)



Measured memory_bytes: 22272
//C Walk on Multiplication Table
#include<bits/stdc++.h>
#include<math.h>
using namespace std;

int main()
{
  long long n,a;
  cin>>n;
  a=n+1;
  for(long long i=1;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      a=min(a,n/i+i);
    }
  }
  cout<<a-2<<endl;
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
// ここに処理を記述

	int N, M;
	cin >> N >> M;

	vector< pair<int, int> > v;
	int A, B;
	for(int i=0; i<N; i++){
		cin >> A >> B;
		v.push_back( make_pair(A, B) );
	}

	// 探索はM日後から(M-1日目の仕事から選ぶ) --> A.first <= 1となるもののうち最大報酬を選択
	// 探索が進めば，A.firstの候補が増えるがそのうち最大を選び続ける

	// A.firstに従ってソート
	sort(v.begin(), v.end());

	// その時点で実行可能な仕事を優先度付きキューに追加
	priority_queue<int> task;
	int ans = 0;
	int p = 0;
	REP(i,M){
		while(v[p].first <= i+1){
			task.push(v[p].second);
			p++;
			if(p >= v.size()) break;
		}
		// cout << task.top() << "\n";
		if(task.size() != 0){
			ans += task.top();
			task.pop();
		}
	}

	cout << ans << "\n";

return 0;
}

Measured memory_bytes: 1908
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define elif(a) else if(a)
#define INF INT_MAX
#define F first
#define S second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,t;
  cin>>s;
  cin>>t;
  for(int i=0;i<=s.size() && s!=t;i++){
    char temp=s[0];
    SFOR(j,1,s.size()){
      swap(s[j],temp);
    }
    s[0]=temp;

  }
  if(s==t) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    double n;
    cin >> n;
    printf("%.10f\n",n*n*n/27);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,a,b;
  cin>>n>>a>>b;
  int x[n];
  rep(i,n) cin>>x[i];
  int ans=0;
  int mx=(b/a);
  rep(i,n-1){
    if(x[i+1]-x[i] > mx){
      ans+=b;
    }else{
      ans+=(x[i+1]-x[i])*a;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int a[10];
int main(){
	for(int i=0;i<4;i++){
		int x; cin>>x; a[x]++;
	}
	if(a[1] == 1 && a[9] == 1 && a[7] == 1 && a[4] == 1){
		puts("YES");
	}
	else{
		puts("NO");
	}
}

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

int main(){
  int N;
  cin >> N;
  vector<vector<int>> vec;
  for(int i = 0; i < N; i++){
    int A;
    cin >> A;
    vector<int> v;
    int c = 0;
    while(A){
      if(A % 2) v.push_back(c);
      A /= 2;
      c++;
    }
    vec.push_back(v);
  }
  int s = 0, t = 0;
  ll ans = 0;
  int use[20] = {0};

  while(true){
    while(t < N){
      bool can = true;
      for(int x : vec[t]){
        if(use[x]) can = false;
      }
      if(!can) break;
      for(int x : vec[t]){
        use[x]++;
      }
      t++;
    }
    if(s == N) break;
    ans += t - s;
    for(int x : vec[s]){
      use[x]--;
    }
    s++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15532