akhauriyash/Code-Regression huggingface dataset:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

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

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

inf = 10 ** 18
mod = 10 ** 9 + 7

a,b,c,d = lr()
print(max(a*c, a*d, b*c, b*d))

Measured memory_bytes: 72692
/*author - Ashutosh Chitranshi*/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define pow2(x) ((x)*(x))
#define ll long long
#define ld long double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define mod 1000000007
#define ordered_set tree<pair<ll,ll>,null_type,less<pair<ll,ll>>,rb_tree_tag,tree_order_statistics_node_update>
#define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
#define mp make_pair
#define ff first
#define ss second
#define null NULL
#define all(c) (c).begin(),(c).end()
#define nl "\n"
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vi > vvi;
typedef vector< vl > vvl;
typedef pair< int,int > ii;
typedef pair< ll,ll> pll;
typedef map< ll,ll> mll;
typedef map< int,int> mii;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll x;
    cin >> x;
    cout << 1-x << nl;
    return 0;
}

Measured memory_bytes: 3648
#include<iostream> 
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int num,h,m,s;
	cin >> num;
	h = num / 3600;
	m = num % 3600 / 60;
	s = num % 3600 % 60;
	cout <<h<< ":"<<m<<":"<<s<<endl;
}


Measured memory_bytes: 3124
#include "bits/stdc++.h"
using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9 + 7;
const long long LLINF = 1e18;

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

    ll ans=1;
    REP(i, 0, n){
        if(i==0) ans*=k;
        else ans*=(k-1);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//#include <algorithm>
//#include <cassert>
//#include <cfloat>
#include <cmath>
//#include <cstdio>
//#include <cstdlib>
//#include <deque>
#include <iostream>
//#include <limits>
//#include <map>
//#include <queue>
//#include <set>
//#include <stack>
//#include <string>
//#include <tuple>
//#include <unordered_map>
//#include <unordered_set>
//#include <vector>
using namespace std;

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

int main() {
  int n; scanf("%d", &n);
  int a[n];
  double ave{0};
  for (int i{0}; i < n; ++i) {
    scanf("%d", &a[i]);
    ave += a[i];
  }
  ave /= n;

  int ans{0};
  double diff{fabs(ave - a[0])};
  for (int i{1}; i < n; ++i) {
    double temp = fabs(ave - a[i]);
    if (diff > temp) {
      ans = i;
      diff = temp;
    }
  }

  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 760
//om namah shivaaay//
#include <bits/stdc++.h>
#define Om_namah_Shivaay ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
 #define ll long long
 #define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
 const int N=1e5 +5;
 using namespace std;

 int32_t main()
 {
    Om_namah_Shivaay;
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a >= k) cout << k << endl;
	else if(a + b >= k) cout << a << endl;
	else cout << a - (k - a - b) << endl;
    return 0;}
		 


Measured memory_bytes: 3644
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	double a, b, h, m;
	cin >> a >> b >> h >> m;

	double ang_b = 6.0 * m;
	double ang_a = 30 * h + 30 * (m / 60.0);
	double angle = abs(ang_a - ang_b);

	printd(sqrt(a * a + b * b - 2 * a * b * cos(angle / 180 * M_PI)), 10);
}


Measured memory_bytes: 4220
import bisect
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

ans = 0
for i in range(n):
  canA = bisect.bisect_left(A, B[i])
  canC = bisect.bisect_right(C, B[i])
  ans += (canA)*(n-canC)
print(ans)

Measured memory_bytes: 105572
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
ans = [0]
l = max(k.bit_length(),1)
for i in range(l-1,-1,-1):
  if i == 0:
    x = k
  elif k & 1 << i:
    x = (k >> (i+1)) << i+1 | (1 << i)-1
  sm = 0
  for j in range(n):
    if a[j][0] | x == x:
      sm += a[j][1]
  ans.append(sm)
print(max(ans))

Measured memory_bytes: 29428
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> lpair;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll L[2010];
    rep(i,0,N) cin >> L[i];
    sort(L, L+N);
    ll ans = 0;
    ll sum[5010] = {};
    rep(i,0,N){
        sum[L[i]]++;
    }
    rep(i,0,5005) sum[i+1] += sum[i];
    rep(i,0,N){
        rep(j,0,N){
            if(i >= j) continue;
            ll min_val = abs(L[i] - L[j]);
            ll max_val = L[i] + L[j];
            if(min_val + 1 > max_val-1) continue;
            ll cnt = sum[max_val-1] - sum[min_val];
            if(min_val < L[i] && L[i] < max_val) cnt--;
            if(min_val < L[j] && L[j] < max_val) cnt--;
            ans += cnt;

        }
    }
    print(ans/3);




}


Measured memory_bytes: 256
S = input()
N = len(S)

"""
全て0にできるような〜とあるが、全て1にしてから0にしてもいいので、どっちを目指してもいい

S = 1100001111 の時
S[1] != S[2]なので、そこの左か右でひっくり返す
左：0000001111 -> 1111110000 -> 0000000000 より、K=2
右：1111110000 -> 0000000000 よりK=6

1とか0とか実際の値は重要ではなく、どっちをひっくり返すか選択を迫られた時に、長い方をひっくり返すことで、答えの減少幅を小さくできるみたいなイメージ

"""

ans = N
for i in range(N-1):
    if S[i] != S[i+1]:
        ans = min(ans, max(i+1, N-i-1))

print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(a) for(int k=head[a];k;k=e[k].ne)
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=1e6+5,M=5e3+5,INF=1e9,mod=998244353;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
int rj[N][21],lj[N][21],n,v,K,x[N],lx[N],rx[N],mn[N];
#define pw(a) (1<<(a))
int main(){
	read(n,v);while(pw(K)<=v)K++;
	rep(i,1,n)read(x[i]);	
	rep(k,0,K){
		lj[0][k]=1;
		rep(i,1,n)lj[i][k]=(x[i]-x[i-1]<=(v>>k))?lj[i-1][k]:i;
		rj[n+1][k]=n;
		repd(i,n,1)rj[i][k]=(x[i+1]-x[i]<=(v>>k))?rj[i+1][k]:i;
	}
	re(i,0,pw(K+1))rx[i]=n+1;
	re(i,0,pw(K+1))rep(j,0,K)if(!(i&pw(j))){
		gmax(lx[i|pw(j)],rj[lx[i]+1][j]);
		gmin(rx[i|pw(j)],lj[rx[i]-1][j]);
	}
	rep(i,0,n)mn[i]=n+2;
	for(int i=0;i<pw(K+1);i+=2)gmin(mn[lx[i]],rx[pw(K+1)-1-1-i]);
	repd(i,n-1,0)gmin(mn[i],mn[i+1]);
	rep(i,1,n)if(rj[i][0]+1>=mn[lj[i][0]-1])puts("Possible");else puts("Impossible");
}

Measured memory_bytes: 52352
#include <stdio.h>
#include <math.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
using namespace std;




int main(){
    while(1){
        
        
        
        
    
    int n,a[500]={};
    cin>>n;
        if(n==0){break;}
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    bool j[500][500]={};
    for(int i=2;i<=n;i+=2){
        for(int t=0;t<=n-i;t++){
            if(abs(a[t]-a[t+i-1])<=1 && (j[t+1][t+i-2] || i==2)){j[t][t+i-1]=true; continue;}
            for(int h=t+1;h<t+i-1;h++){
                if(j[t][h] && j[h+1][t+i-1]){j[t][t+i-1]=true; break;}
            }
        }
    }
    int dp[500];
    fill(dp,dp+500,1000000000);
    dp[0]=1;
    for(int i=0;i<n;i++){
        if(j[0][i]){dp[i]=0;}
    }
    for(int i=1;i<n;i++){
        dp[i]=min(dp[i],dp[i-1]+1);
        for(int t=i;t<n;t++){
            if(j[i][t]){dp[t]=min(dp[t],dp[i-1]);}
        }
    }
    
    /*
    for(int i=0;i<n;i++){
        for(int t=0;t<n;t++){
            cout<<(j[i][t]?"1":"0")<<" ";
        }
        cout<<endl;
    }
     */
    
    //for(int i=0;i<n;i++){
        cout<<n-dp[n-1]<<endl;
    //}
    
    
        
    }
    
    return 0;
}


Measured memory_bytes: 3320
n=gets.to_i
s=gets.split.map{|i|i=='0'}
t=gets.split.map{|i|i=='0'}
u=gets.split.map &:to_i
v=gets.split.map &:to_i
one=Array.new(n){[0]*n}
zero=Array.new(n){[0]*n}

n.times{|i|n.times{|j|
 s[i]?one[i][j]|=u[i]:zero[i][j]|=~u[i]
 t[j]?one[i][j]|=v[j]:zero[i][j]|=~v[j]
 if one[i][j]&zero[i][j]!=0 
  p -1
  return 
 end
}}
#p one,zero
check=->ans{
 ucheck=n.times.map{|i|s[i]?-1:0}
 vcheck=n.times.map{|j|t[j]?-1:0}
 n.times{|i|n.times{|j|
  s[i]?ucheck[i]&=ans[i][j]:ucheck[i]|=ans[i][j]
  t[j]?vcheck[j]&=ans[i][j]:vcheck[j]|=ans[i][j]
 }}
 ufail=(0...n).inject(0){|acc,i|(acc|(u[i]^ucheck[i]))}
 vfail=(0...n).inject(0){|acc,j|(acc|(v[j]^vcheck[j]))}
 (ufail | vfail) & ((1<<64)-1)
}

ans=Array.new(n){[0]*n}
n.times{|i|n.times{|j|
 ans[i][j]=one[i][j]|(~zero[i][j]&(((1<<64)-1)*((i^j)&1)))
}}
fail=check[ans]

n.times{|i|n.times{|j|
 ans[i][j]&=~fail
 ans[i][j]|=fail&((u[i]|v[j])&~zero[i][j])
}}
fail=check[ans]

n.times{|i|n.times{|j|
 ans[i][j]&=~fail
 ans[i][j]|=fail&((u[i]&v[j])|one[i][j])
}}
fail=check[ans]
if fail!=0
 p -1
 return
end

ans.each{|v|puts v.map{|x|x&((1<<64)-1)}*' '}

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

typedef long long ll;

static const int MAX = 1e6;
static const int NIL = -1;
static const ll INF = 1<<21;
static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

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

    vector<int> p(n);
    int a, b;
    for(int i=0;i<m;i++) {
        cin >> a >> b;
        if(a==1) p.at(b-1)++;
        else if(b==1) p.at(a-1)++;
        else {
            p.at(a-1)++;
            p.at(b-1)++;
        }
    }

    for(int i=1;i<n;i++) {
        if(p.at(i)%2==1) { 
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(void)
{
	int m, nmin, nmax, i, j;
	int temp1, temp2;
	int P[201];
	int s[201];
	
	while(scanf("%d %d %d",&m,&nmin,&nmax))
	{
		if(m==0&&nmin==0&&nmax==0)
		break;
		else
		{
			for(i=1;i<=m;i++)
			{
				scanf("%d",&P[i]);
				//printf("P[%d] = %d\n",i,P[i]);
			}
			j = 0;
			temp1 = 0;
			temp2 = 0;
			for(i=nmin;i<=nmax;i++)
			{
				s[j] = P[i] - P[i+1];
				if(s[j]>=temp1)
				{
					temp1 = s[j];
					temp2 = i;
				}
				j++;
			}
			printf("%d\n",temp2);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;
int main(){
    string str1;
    string str2;
    cin>>str1;
    cin>>str2;
    int k = 0;
    int l = 0;
    int gflag = 0;
    int lflag = 0;
    for(int i=0;i<str1.length();i++){
        lflag = 1;
        l = k;
        for(int j=0;j<str1.length();j++){
            l = l % str1.length();
            if(str1[j] != str2[l]){
                lflag = 0;
                break;
            }
            l++;
        }

        if(lflag == 1){
            gflag = 1;
            break;
        }

        k++;
    }

    if(gflag == 1){
        cout<<"Yes"<<endl;
    }else if(gflag == 0){
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  string S;
  int K;
  cin >> S >> K;

  if (K == 1) {
    cout << S[0] << endl;
    return;
  }

  for (int i = 0; i < min(K, (int)S.size()); i++) {
    if (S[i] != '1') {
      cout << S[i] << endl;
      return;
    }
  }

  cout << S[K - 1] << endl;
}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        StringBuilder sb = new StringBuilder(String.valueOf(sc.next()));
        boolean writeNine = false;
        for (int i = 0; i < sb.length(); i++) {
            if (writeNine) {
                sb.setCharAt(i, '9');
            } else if (i != sb.length() - 1 && sb.charAt(i + 1) != '9') {
                sb.setCharAt(i, (char) (sb.charAt(i) - 1));
                writeNine = true;
            }
        }
        System.out.println(digitSum(sb.toString()));
    }

    private static int digitSum(String num) {
        int sum = 0;
        for (int i = 0; i < num.length(); i++) {
            sum += num.charAt(i) - '0';
        }
        return sum;
    }
}

Measured memory_bytes: 23380
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 400000;

int main() {


	int N;
	cin >> N;

	int A[MAX];

	int j;
	for (int i = 1; i <= N; i++) {
		cin >> j;
		A[j] = i;
		
	}
	
	for (int i = 1; i <= N; i++) {
		cout << A[i] << " ";
	}

	

	system("PAUSE");

}

Measured memory_bytes: 1400
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2+2],R[MAX/2+2];

void merge(struct Card A[],int n,int left,int mid,int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;
  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];
  L[n1].value=R[n2].value=SENTINEL;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value) A[k]=L[i++];
    else A[k]=R[j++];
  }
}

void mergeSort(struct Card A[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[],int n,int p,int r){
  int i,j;
  struct Card t,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];A[i]=A[j];A[j]=t;
    }
  }
  t=A[i+1];A[i+1]=A[r];A[r]=t;
  return i+1;
}

void quickSort(struct Card A[],int n,int p,int r){
  int q;
  if(p<r){
    q=partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main(){
  int n,i,v;
  struct Card A[MAX],B[MAX];
  char S[10];
  int stable=1;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %d",S,&v);
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++) if(A[i].suit!=B[i].suit) stable=0;


  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) printf("%c %d\n",B[i].suit,B[i].value);

  return 0;
}





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

int vis[256];
char S[1005];

int main(){
    scanf("%s",S);
    int n = strlen(S);
    for(int i = 0; i < n; i++){
        vis[ S[i] ] = 1;
    }
    if( (vis['N'] ^ vis['S']) || (vis['E'] ^ vis['W']) )
        puts("No");
    else
        puts("Yes");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>

int main() {
	int n, k;
	std::cin >> n >> k;

	std::vector<int> values(n);
	for (auto&& e : values)
		std::cin >> e;

	int ans = 0;

	std::vector<int> use;
	use.reserve(k);
	for (int i = 0; i <= std::min(k, n); ++i) {
		for (int s = 0; s <= i && i - s <= n; ++s) {
			for (int j = 0; j < s; ++j)
				use.push_back(values[j]);
			for (int j = 0; j < i - s; ++j)
				use.push_back(values[n - 1 - j]);

			std::sort(use.begin(), use.end(), std::greater<>{});
			int a = std::accumulate(use.begin(), use.end(), 0);
			for (int j = 0; j < k - i && j < i && use[i - 1 - j] < 0; ++j)
				a -= use[i - 1 - j];

			ans = std::max(a, ans);

			use.clear();
		}
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 5001;

int n;
int x[5], y[5];
int d[5], d2[5];
int val[5], wt[5];
int cache[3][N * N];

int dp(int idx, int cur)
{
	if(cur < 0)
		return -1e15;
	if(idx == 3)
		return cur;
	int &ans = cache[idx][cur];
	if(ans != -1)
		return ans;
	ans = max(dp(idx + 1, cur), val[idx + 1] + dp(idx, cur - wt[idx + 1]));
	return ans;
}

int32_t main()
{
	IOS;
	memset(cache, -1, sizeof(cache));
	cin >> n;
	for(int i = 1; i <= 3; i++)
		cin >> x[i];
	for(int i = 1; i <= 3; i++)
		cin >> y[i];
	for(int i = 1; i <= 3; i++)
	{
		d[i] = y[i] - x[i];
		d2[i] = x[i] - y[i];
		wt[i] = y[i];
		val[i] = x[i];
	}
	int mx = n;
	for(int i = 0; x[1] * i <= n; i++)
	{
		if(d[1] < 0 && i > 0)
			break;
		for(int j = 0; x[2] * j <= n; j++)
		{
			if(d[2] < 0 && j > 0)
				continue;
			int rem = n - x[1] * i - x[2] * j;
			if(rem < 0)
				continue;
			int nxt = n + d[1] * i + d[2] * j;
			if(d[3] > 0)
			{
				int mxk = rem / x[3];
				nxt += d[3] * mxk;
			}
			mx = max(mx, nxt);
		}
	}
	n = mx;
	int ans = dp(0, n);
	cout << ans;
	return 0;
}

Measured memory_bytes: 775168
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/








char B;
string S = "ATCG", T = "TAGC";
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> B;
	rep(i, 0, 4) if (S[i] == B) {
		cout << T[i] << endl;
		return;
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 10010
#define ll long long
#define mod 998244353
#define g 3
using namespace std;

int nn, n, m, inv[N], INV, R[N*4], a[N*4], b[N*4], c[N*4], n1, L, ans;
char s1[N], s2[N];

inline int pow(int y, int x){
	int s=1, t=y;
	while(x){if(x&1)s=(ll)s*t%mod; t=(ll)t*t%mod; x>>=1;}
	return s;
}

inline void ntt(int *a, int f){
	for(int i=0; i<n1; i++)if(i<R[i])swap(a[i], a[R[i]]);
	for(int i=1; i<n1; i<<=1){
		int wn=pow(g, (mod-1)/(i*2)); if(f==-1)wn=pow(wn, mod-2);
		for(int j=0; j<n1; j+=i*2){
			int w=1;
			for(int k=0; k<i; k++){
				int x=a[j+k], y=(ll)w*a[j+k+i]%mod;
				a[j+k]=x+y; if(a[j+k]>=mod)a[j+k]-=mod;
				a[j+k+i]=x-y; if(a[j+k+i]<0)a[j+k+i]+=mod;
				w=(ll)w*wn%mod;
			}
		}
	}
	if(f==-1)for(int i=0; i<n1; i++)a[i]=(ll)a[i]*INV%mod;
}

inline void mul_poly(int *a, int *b){
	memcpy(c, b, sizeof(c));
	n1=n+1; L=0; while((1<<L)<n1*2)L++; n1=1<<L;
	for(int i=0; i<n1; i++)R[i]=(R[i/2]/2)|((i&1)<<(L-1));
	INV=pow(n1, mod-2);
	ntt(a, 1); ntt(c, 1);
	for(int i=0; i<n1; i++)a[i]=(ll)a[i]*c[i]%mod;
	ntt(a, -1);
	for(int i=n+1; i<n1; i++)a[i]=0;
}
inline void pow_poly(int *a, int *b, int x){
	while(x){
		if(x&1)mul_poly(a, b);
		mul_poly(b, b);
		x>>=1;
	}
}

int main(){
	scanf("%s%s", s1+1, s2+1); nn=strlen(s1+1);
	m=0; for(int i=1; i<=nn; i++)if(s1[i]=='1'&&s2[i]=='0')m++;
	n=0; for(int i=1; i<=nn; i++)if(s1[i]=='1'&&s2[i]=='1')n++;
	inv[0]=inv[1]=1; for(int i=2; i<=n+1; i++)inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod;
	for(int i=1; i<=n+1; i++)inv[i]=(ll)inv[i-1]*inv[i]%mod;
	memset(a, 0, sizeof(a)); a[0]=1;
	memset(b, 0, sizeof(b)); for(int i=0; i<=n; i++)b[i]=inv[i+1];
	pow_poly(a, b, m);
	ans=0; for(int i=0; i<=n; i++)ans=(ans+a[i])%mod;
	for(int i=1; i<=m; i++)ans=(ll)ans*i%mod;
	for(int i=1; i<=n; i++)ans=(ll)ans*i%mod;
	for(int i=1; i<=n+m; i++)ans=(ll)ans*i%mod;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    long long n;
    long long a[100010];
    cin >> n;
    long long sum = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        sum += a[i];
    }
    a[n + 1] = a[1];
    if((sum % ((n * (n + 1)) / 2)) != 0){
        cout << "NO" << endl;
        return 0;
    }
    int times = sum / ((n * (n + 1)) / 2);
    int check = 0;
    for(int i = 1; i <= n; i++){
        long long delta = a[i + 1] - a[i];
        if((delta - times) % n != 0){
            cout << "NO" << endl;
            return 0;
        }
        if((delta - times) > 0){
            cout << "NO" << endl;
            return 0;
        }
        check -= (delta - times) / n;
    }
    if(check == times){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> bool max_self(T & a, const T & b){ 
  return b > a ? a = b, true : false; 
}
template<class T> bool min_self(T & a, const T & b){ 
  return b < a ? a = b, true : false;    
}
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

int N, sum = 0, largest = 0;

int main(){
  FAST_IO
  cin >> N;

  for(int rep = 0, x; rep < N; ++rep){
    cin >> x;
    max_self(largest, x);
    sum += x;
  }

  if(largest < sum - largest) cout << "Yes\n";
  else cout << "No\n";

  return 0;
}


Measured memory_bytes: 3628
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//int→string
//string→int
//------------------------------------------
inline int toInt(string s) {
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}

template<class T>
inline string toString(T x) {
    ostringstream sout;
    sout << x;
    return sout.str();
}

//sqrt
//-------------------------------------------
template<class T>
inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//repetition
//------------------------------------------
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  FOR(i,0,n)
#define REPR(i, n) for(int i = n;i >= 0;i--)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main() {

    int A; cin >> A;
    int B; cin >> B;
    int C; cin >> C;
    
    
    if(A+B >=C){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}















































Measured memory_bytes: 768
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import chain
def main():
    n = int(input())
    s = tuple(input())
    cnt = 0
    cnt_ushiro = 0
    cnt_mae = 0
    for se in s:
        cnt += se == ')'
        cnt -= se == '('
        cnt_mae = max(cnt_mae, cnt)
    cnt -= cnt_mae
    if cnt < 0:
        cnt_ushiro = -cnt
    s_mae = ('(') * cnt_mae
    s_ushiro = (')') * cnt_ushiro
    r = tuple(chain(s_mae, s, s_ushiro))
    print(*r,sep="")

if __name__ == '__main__':
    main()

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

int main(){
  unsigned int n;
  long long lm2, lm1, l;
  cin >> n;

  lm2 = 2;
  lm1 = 1;
  l = 1;
  for (int i=n; i>1; i--){
    l = lm2 + lm1;
    lm2 = lm1;
    lm1 = l;
  }
  cout << l << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,c=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2==0)
      c++;
  }
  
  cout<<pow(3,n)-pow(2,c);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
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);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

map<ll,ll> M;

int main(){
  ll A;
  rep(i,6){
    cin >> A ;
    M[A]++;
    if(M[A]>2){
      cNO;
      return 0;
    }
  }
  cYES;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>

#define rep(i, a) for (int i = 0; i < a; i++)
using namespace std;


int main()
{
    int L, n = 0, m = 0;
    queue<int> bg, en, lg;

    cin >> L;

    stack<int> l;
    while (L != 0) {
        int a = L % 3;  L /= 3;
        l.push(a);
    }
    int s = l.size();
    n = s + 1;
    

    int mid = 1, large = 2;
    rep(i, s - 1) {
        rep(j, 3) { 
            bg.push(i + 1); en.push(i + 2); 
            ++m;
        }
        lg.push(0);  lg.push(mid);  lg.push(large);
        mid *= 3;  large *= 3;
    }

    int max = 1;
    rep(i, s - 1) max *= 3;
    --max;
    int delt = max + 1;

    bg.push(s), en.push(s + 1), lg.push(0);
    ++m;
    if (l.top() == 2) {
        bg.push(s), en.push(s + 1), lg.push(max + 1);
        ++m;
        max += max + 1;
    }
    l.pop();


    int st = s - 1;
    while (!l.empty())
    {
        delt /= 3;
        rep(i, l.top()) {
            bg.push(st), en.push(s + 1), lg.push(max + 1);
            ++m;
            max += delt;
        }
        l.pop();
        --st;
    }

    printf("%d %d\n", n, m);
    while (!bg.empty()) {
        printf("%d %d %d\n", bg.front(), en.front(), lg.front());
        bg.pop(), en.pop(), lg.pop();
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

int main() {
	int n, k, A[200000];
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++)
		scanf("%d", A + i);
	sort(A, A + n);
	int len = 1, S[200000];
	S[0] = 1;
	for (int i = 1; i < n; i++) {
		if (A[i] == A[i - 1])
			S[len - 1]++;
		else
			S[len++] = 1;
	}
	sort(S, S + len);
	int res = 0;
	for (int i = 0; i < max(0, len - k); i++)
		res += S[i];
	printf("%d\n", res);
}

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

int main(){
	int n,a,max,min;
	long long sum;
	cin >> n;
	max=-1000000;
	min=1000000;
	sum=0;
	for(int i=0;i<n;i++){
		cin >> a;
		if (a>max){
			max = a;
		}
		if(a<min){
			min = a;
		}
		sum=sum+a;
	}
	cout << min << " " << max << " " << sum << endl;
}

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

int main()
{
           while(true){
                       int H;
                       cin >> H;

                     if(H==0)
                           break;

                     int S[10][5];
                     for(int y=0;y<H;y++)
                             for(int x=0;x<5;x++)
                                   cin >> S[y][x];

                      int sco =0;

                      while(true){
                              bool flg = false;

                            for(int y=0;y<H;y++){
                                  int m = S[y][2];
                                   if(m==0)
                                          continue;

                                    if(S[y][0]==m && S[y][1]==m){
                                          sco += m*3; S[y][0] =
S[y][1]=S[y][2]=0; flg =true;
                                         if(S[y][3]==m){
                                             sco += m;  S[y][3] =0;
                                      if(S[y][4]==m){
                                             sco += m;  S[y][4] =0;
                                     }
                                  }
                                 }
                  else if(S[y][1]==m && S[y][3]==m){
                       sco += m*3; S[y][1] = S[y][2]=S[y][3]=0; flg =true;
                           if(S[y][4]==m){
                             sco += m; S[y][4]=0;
                      }
                  }

                  else if(S[y][3]==m && S[y][4]==m){
                        sco += m*3; S[y][2] = S[y][3]=S[y][4]=0; flg =true;
                     }
                   }

              if(!flg)
                    break;

                for(int x=0;x<5;x++){
                       for(int y=H-1;y>=0;y--){
                             if(S[y][x]!=0)
                                continue;

                        for(int y2=y-1; y2>=0;y2--){
                             if(S[y2][x]!=0){
                                 S[y][x] = S[y2][x]; S[y2][x] =0; break;

                               }
                           }
                         }
                       }
                     }
            cout << sco <<endl;
         }
  return 0;


}


Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>

using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

struct query {
	ll type;
	ll a, b;
};

vector<query> querys;
ll N,RN;
vector<pll> seg;
VLL A;

void setorder() {
	VLL temp;
	temp.reserve(N);
	for (ll n = 0; n < N; n++) {
		if (querys[n].type == 1) {
			temp.push_back(querys[n].a);
		}
	}
	sort(temp.begin(), temp.end(), [](ll a, ll b) {
		return a < b;
	});
	A.reserve(N);
	A.push_back(temp[0]);
	for (ll n = 1; n < temp.size(); n++) {
		if (temp[n] != temp[n - 1])A.push_back(temp[n]);
	}
}

//数aを追加
void add(ll a) {
	ll s = 0, e = A.size();
	while (e - s > 1) {
		ll m = (e + s) / 2;
		if (A[m] > a)e = m;
		else s = m;
	}
	ll ind = s;
	ll k = RN + ind;
	while (k != 0) {
		seg[k].first++;
		seg[k].second += a;
		k /= 2;
	}
}

pll get(ll n) {
	ll p = (n + 1) / 2;
	pll ans = pll(0, 0);
	ll k = 1;
	while (k < RN) {
		if (ans.first + seg[2 * k].first < p) {
			ans.first += seg[2 * k].first;
			ans.second += seg[2 * k].second;
			k = 2 * k + 1;
		}else k *= 2;
	}
	ll i = k + 1;
	ll sum = A[k-RN]*ans.first;
	sum -= ans.second;
	sum += (seg[1].second - ans.second);
	sum -= A[k - RN] * (n - ans.first);
	return pll(A[k - RN], sum);
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> N;
	querys.reserve(N);
	for (ll n = 0; n < N; n++) {
		ll t;
		cin >> t;
		if (t == 1) {
			ll a, b;
			cin >> a >> b;
			querys.push_back({ t,a,b });
		}
		else querys.push_back({ t,0,0 });
	}
	setorder();
	RN = 1;
	while (RN < A.size())RN *= 2;
	seg.resize(RN * 2, pll(0, 0));
	ll B = 0,n = 0;
	for (ll q = 0; q < N; q++) {
		auto que = querys[q];
		if (que.type == 1) {
			B += que.b;
			add(que.a);
			n++;
		}
		else {
			pll ans = get(n);
			cout << ans.first << " " << ans.second + B << "\n";
		}
	}
	return 0;
}

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

int main() {
  int n,m;
  cin>>n>>m;
  string vec[n],vecb[m];
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  for(int i=0;i<m;i++){
    cin>>vecb[i];
  }
  int a=0;
  for(int i=0;i<n-m+1;i++){
    for(int j=0;j<n-m+1;j++){
      for(int k=0;k<m;k++){
        for(int l=0;l<m;l++){
          if(vec[i+k][j+l]!=vecb[k][l]){
            a++;
          }
        }
      }
      if(a==0){
        cout<<"Yes"<<endl;
        return 0;
      }
      a=0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
    int i =0;
    char s[100000]  =  {0};
    int c = 0;
    int len = 0;
    scanf("%s",s);
    while(s[i]){
        len++;
        i++;
    }
    for(i=0;i<len-1;i++){
        if(s[i] != s[i+1])
            c++;
    }

    printf("%d\n",c);

    return 0;
}

Measured memory_bytes: 256
import sys,bisect
 
from sys  import stdin,stdout
 
from bisect import bisect_left,bisect_right,bisect,insort,insort_left,insort_right
 
from math import gcd,ceil,floor,sqrt
 
from collections import Counter,defaultdict,deque,OrderedDict
 
from queue import Queue,PriorityQueue
 
from string import ascii_lowercase
 
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 998244353
mod = 10**9+7
 
def isPrime(n):
    
    if (n <= 1) :return False
    if (n <= 3) :return True
    if (n%2 == 0 or n%3 == 0):return False
    for i in range(5,ceil(sqrt(n))+1,6):
        if (n%i==0 or n%(i+2)==0):
            return False
    return True
 
 
def st():
    return list(stdin.readline().strip())
 
def inp():
    return int(stdin.readline())
 
def li():
    return list(map(int,stdin.readline().split()))
 
def mp():
    return map(int,stdin.readline().split())
 
def pr(n):
    stdout.write(str(n)+"\n")
    
def DFS(dictionary,vertex,visited):
    visited[vertex]=True
    stack=[vertex]
    print(vertex)
    while stack:
        a=stack.pop()
        for i in dictionary[a]:
            if not visited[i]:
                print(i)
                visited[i]=True
                stack.append(i)
 
 
def BFS(dictionary, vertex,visited):
    visited[vertex]=True
    q=deque()
    q.append(vertex)
    while q:
        a=q.popleft()
        for i in dictionary[a]:
            if not visited[i]:
                visited[i]=True
                q.append(i)
                print(i)
 
                
 
 
def soe(limit):
    l=[1]*(limit+1)
    l[0]=0
    l[1]=0
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0
    
    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime
 
def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)
                
def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a
 
def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r
    
def solve():
    n=input()
    s=sum(list(map(int,str(n))))
    if s%9==0:
        pr('Yes')
    else:
        pr('No')
 
    
 
 
 
 
for _ in range(1):
    solve()
    

Measured memory_bytes: 12172
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
int main() {
    int n; cin >> n;
    int a[2][n];
    rep(i, n) cin >> a[0][i];
    rep(i, n) cin >> a[1][i];
    int dp[2][n];
    rep(i, 2) rep(j, n) dp[i][j] = 0;
    dp[0][0] = a[0][0];
    rrep(i, 1, n) dp[0][i] = dp[0][i - 1] + a[0][i];
    dp[1][0] = dp[0][0] + a[1][0];
    rrep(i, 1, n) dp[1][i] = max(dp[1][i - 1] + a[1][i], dp[0][i] + a[1][i]);
    cout << dp[1][n - 1] << endl;
    return 0;
    
    
}


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

int main(){
    string s;
    cin >> s;
    if(s=="SUN")
    cout << 7 << endl;
    else if(s=="MON")
    cout << 6 << endl;
    else if(s=="TUE")
    cout << 5 << endl;
    else if(s=="WED")
    cout << 4 << endl;
    else if(s=="THU")
    cout << 3 << endl;
    else if(s=="FRI")
    cout << 2 << endl;
    else
    {
        cout << 1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
if x >= 0 and y >= 0:
  if x <= y:
    print(y-x)
  else:
    if y == 0:
      print(abs(y-x)+1)
    else:
      print(abs(y-x)+2)
elif x < 0 and y >= 0:
  print(min(y+abs(x), abs(y-abs(x))+1))
elif x >= 0 and y < 0:
  print(abs(abs(y)-abs(x))+1)
else:
  if x <= y:
    print(abs(abs(y)-abs(x)))
  else:
    print(abs(abs(y)-abs(x))+2)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
int main(void){
    
    string S1, S2, S3;
    cin >> S1 >> S2 >> S3;
    
    if(S1[S1.size()-1] == S2[0] && S2[S2.size()-1] == S3[0])
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

}

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


int a ;

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

std::string S;

int main() {
  std::cin >> S;

  if( S.back() != 's' )
    S += 's';
  else if( S.back() == 's' )
    S = S+"es";

  std::cout << S << endl;

  return 0;
}

Measured memory_bytes: 3604
def f(a, b):
	if len(a) != len(b):
		return 'GREATER' if len(a) > len(b) else 'LESS'
	for u,v in zip(a,b):
		if int(u) < int(v):
			return 'LESS'
		elif int(u) > int(v):
			return 'GREATER'
	return  'EQUAL'

print f(raw_input(), raw_input())

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

using namespace std;

typedef long long ll;

const long long MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  string s;
  cin >> s;
  int K;
  cin >> K;
  vector<string> dict;
  for (int i = 1; i <= K; ++i) {
    for (int j = 0; j < s.size() - i + 1; ++j) {
      dict.push_back(s.substr(j, i));
    }
  }
  sort(dict.begin(), dict.end());
  dict.erase(unique(dict.begin(), dict.end()), dict.end());
  cout << dict[K - 1] << endl;
}

Measured memory_bytes: 1660