akhauriyash/Code-Regression huggingface dataset:
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;

// const ll MOD = (ll)1e9+7;
const ll MAX = (ll)6e3+10;

vector<ll> dp;
ll T;
multimap<ll,ll> dish;

void update(ll t,ll b) {
   vector<ll> dp1;
   dp1.resize(MAX);
   rep(j,0,MAX) dp1[j] = 0;
   rep(j,0,MAX) {
      if (dp[j]>0) dp1[j] = dp[j];
      if (j-t>=0) {
         if (j-t< T) {
            chmax(dp1[j],dp[j-t]+b);
         }
      }
   }
   swap(dp,dp1);
   return;
}

int main(void) {
   ll N;
   cin>>N>>T;
   rep(i,0,N) {
      ll a,b;
      cin>>a>>b;
      dish.insert(make_pair(a,b));
   }
   dp.resize(MAX);
   rep(i,0,MAX) dp[i] = 0;

   // rep(i,0,N) update(i);
   for (auto el:dish) update(el.first,el.second);
   ll ans = 0;
   rep(i,0,MAX) {
      // if (dp[i]>0) cout<<i<<" "<<dp[i]<<endl;
      chmax(ans,dp[i]);
   }
   cout<<ans<<endl;


   return 0;
}



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

vector<vector<int>> relations;
vector<int> visited;
int ans = 0, now = 0;

void dfs (int x) {
    visited.at(x) = 1;
    now++;
    for (auto i : relations.at(x)) {
        if (!visited.at(i)) dfs(i);
    }
}


int main() {
    int n,m;
    cin >> n >> m;
    relations.resize(n);
    visited.resize(n);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        relations.at(a).push_back(b);
        relations.at(b).push_back(a);
    }

    rep(i,n) {
        now = 0;
        dfs(i);
        ans = max(ans, now);
    }
    cout << ans << endl;
    return 0;
}


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

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

    int sum=0;

    cin >> a[0];
    for(int i=1; i<n; i++){
        cin >> a[i];
        sum += a[i];
    }
    for(int i=0; i<n; i++){
        cin >> b[i];
    }
    int _max = sum;
    for(int i=n-2; i>=0; i--){
        sum += b[i] - a[i+1];
        _max = max(_max, sum);
    }
    cout << a[0]+b[n-1]+_max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans *= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int gc(ll N){
    ll ans=N;
    rep(i,sqrt(N)+1){
      ll p=sqrt(N)+1-i;
        if(N%p==0){
            ans=p;
          break;
        }
    }
    return ans;
}
int main() {
 ll N;
 cin>>N;
 cout<<gc(N)+N/gc(N)-2<<endl;
}


Measured memory_bytes: 3628
from itertools import accumulate, chain

# 入力
N = int(input())
S = input()

# 黒色の石の個数に関する累積和を求めておく
dp = list(
    accumulate(
        chain(
            [0],
            map(lambda s: s == '#', S)
        )
    )
)

# 各iについて、左i個を白色、右N-i個を黒色にする際、色を変更する必要のある石の個数を求め、
# 最小値を解とする。
ans = min(
    dp[i] + (N - i - (dp[N] - dp[i]))
    for i in range(N + 1)
)
print(ans)


Measured memory_bytes: 11492
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;

int main(){
    int n; cin >> n;
    vector<vector<double>> dp(n+1, vector<double>(n+1, 0.0f));
    dp[0][0] = 1.0f;
    vector<double> p(n);
    for(auto& v:p){
        cin >> v;
    }
    for(int i=0; i<n; i++){
        dp[i+1][0] += dp[i][0] * (1.0f - p[i]);
        for(int j=0; j<n; j++){
            dp[i+1][j+1] += dp[i][j] * p[i];
            dp[i+1][j+1] += dp[i][j+1] * (1.0f - p[i]);
        }
    }
    double ans = 0.0f;
    for(int i=(n+1)/2; i<n+1; i++){
        ans += dp[n][i];
    }
    cout << setprecision(12);
    cout << ans << "\n";
    return 0;
}

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

struct era{
  long long int western;
  long long int based;
  string name;
};

int main()
{
  for(;;){
    struct era data[1000];
    int n,q;
    long long int year;
    struct era *e;
    e=data;
    cin>>n>>q;
    if(!(n|q)) break;
    for(int i=0;i<n;i++)
      cin>>(e+i)->name>>(e+i)->based>>(e+i)->western;
    for(int i=0;i<n-1;i++)
      for(int j=0;j<n-1;j++)
	if((e+j)->western>(e+j+1)->western){
	  int tmp1=(e+j)->western;
	  (e+j)->western=(e+j+1)->western;
	  (e+j+1)->western=tmp1;
	  int tmp2=(e+j)->based;
	  (e+j)->based=(e+j+1)->based;
	  (e+j+1)->based=tmp2;
	  string tmp3=(e+j)->name;
	  (e+j)->name=(e+j+1)->name;
	  (e+j+1)->name=tmp3;
	}
    for(int i=0;i<q;i++){
      int jud=0;
      cin>>year;
      for(int j=0;j<n;j++){
	if((e+j)->western-(e+j)->based+1<=year&&year<=(e+j)->western){
	  jud=1;
	  cout<<(e+j)->name<<" "<<year-(e+j)->western+(e+j)->based<<endl;
	}
      }
      if(!jud) cout<<"Unknown"<<endl;
    }
  }
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	vector<vector<int>>ab(m+1);
	for(int i=0;i<n;++i){
		int a,b; cin>>a>>b;
		if(a>m)continue;
		ab.at(a).emplace_back(b);
	}
	priority_queue<int>q;
	int64_t ans=0;
	for(auto&&i:ab){
		for(auto&&j:i)q.push(j);
		if(q.empty())continue;
		ans+=q.top(); q.pop();
	}
	cout<<ans<<"\n"s;
}

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

const int m = 3005; //X.length + 1
const int n = 3005; //Y.length + 1

int C[m][n];
string X , Y;

void LCS(string X , string Y){
    for(int i = 1; i <= X.size(); i++){
        for(int j = 1; j <= Y.size(); j++){
            if (X[i-1] == Y[j-1]) {
                C[i][j] = C[i-1][j-1]+1;
            }else C[i][j]= max(C[i-1][j],C[i][j-1]);
        }
    }
}

void print_LCS( int i , int j){
    if(i == 0 || j == 0) return;

    if(X[i-1] == Y[j-1]){
        print_LCS( i-1 , j - 1);
        cout<<X[i-1];
    }else if(C[i][j] == C[i-1][j]){
        print_LCS( i-1 , j );
    }else print_LCS( i , j - 1);
    
}


//  a d f j k  l  ;
int main(){
    ios::sync_with_stdio(0);
    cin>>X>>Y;
    LCS(X, Y);
    print_LCS( X.size() , Y.size());
    cout<<endl;

    return 0;
}

Measured memory_bytes: 35840
from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
a = readInts()

ans = 0

if n==1:
	print(ans)
	exit()

for i in range(1,len(a)):
	t = max(a[i],a[i-1])
	ans += max(0, t-a[i])
	a[i] = t

print(ans)


Measured memory_bytes: 33512
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] h = new int[n+1];
        int max = 0;
        for(int i = 0; i < n; i++){
            h[i] = scanner.nextInt();
            max = Math.max(max, h[i]);
        }
        int count = 0;
        for(int i = 1; i <= max; i++){
            for(int j = 0; j < n; j++){
                if(h[j] >= i && h[j+1] < i){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int a; // 入力値：３桁の整数：１か０
      int x; // １の数
      
      cin >> a ;
	  x = a / 100 + a % 100 / 10 + a % 10; 
      cout << x << endl;
      
    }


Measured memory_bytes: 256
import sys
import bisect

s = []
input()

for q in sys.stdin:
    q = q.split()
    q[1:] = list(map(int, q[1:]))
    if q[0] == '0':
        bisect.insort_left(s, q[1])
        print(len(s))
    elif q[0] == '1':
        first = bisect.bisect_left(s,q[1])
        end = bisect.bisect_right(s,q[1])
        print(end - first)
    elif q[0] == '2':
        first = bisect.bisect_left(s,q[1])
        end = bisect.bisect_right(s,q[1])
        del s[first:end]
    else:
        first = bisect.bisect_left(s,q[1])
        end = bisect.bisect_right(s,q[2])
        if first != end:
            print('\n'.join(list(map(str,[i for i in s[first:end]]))))


Measured memory_bytes: 25148
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    string S, T;
    cin >> S >> T;

    int slen = S.length();
    bool ok = (slen+1==T.length() && S==T.substr(0,slen));

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    vector<int> s(n);
    rep(i, n) cin >> s[i];

    int q;
    cin >> q;
    ll c = 0;
    rep(i, q)
    {
        int t;
        cin >> t;
        auto p = lower_bound(s.begin(), s.end(), t);

        if (p[0] == t)
        {
            c++;
        }
    }
    cout << c << endl;

    return 0;
}


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

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n, r; cin >> n >> r;
  	if(n >= 10){
  		cout << r << "\n";
    }else {
  		cout << r + 100 * (10 - n) << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
n=int(input())

lr=[]

for _ in range(n):
    x,l=map(int,input().split())
    lr.append([x+l,x-l])

lr.sort()

cnt=0
point=lr[0][1]-1

for item in lr:
    if item[1]>=point:
        cnt+=1
        point=item[0]

print(cnt)







Measured memory_bytes: 58968
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using Graph = vector<vector<int> >;
// MOD
const int MOD = 1000000007;

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int H, W;
int field[100][100];

const int dx[2] = {1, 0};
const int dy[2] = {0, 1};
const double PI=3.14159265358979323846;
bool seen[100][100];

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

    cout << 2.0*PI*r << endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll memo[100000];
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/

int main(){
    string S;
    cin >> S;
    ll s = S.size();
    ll p = 0;
    rep(i,s){
        if(S[i] == 'p')p++;
    }
    cout << s / 2 - p << endl;
}

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

int main()
{
    int a[5], b;
    int i, j, k = 0;
    for (i = 0; i < 5; i++)
    {
        scanf("%d", &a[i]);
    }
    scanf("%d", &b);
    for (i = 0; i < 5; i++)
    {
        for (j = i; j < 5; j++)
        {
            if (a[j] - a[i] <= b)
            {
                continue;
            }
            else
            {
                k++;
                break;
            }
        }
    }
    if (k == 0)
    {
        printf("Yay!\n");
    }
    else
    {
        printf(":(\n");
    }
    return 0;
}

Measured memory_bytes: 128
(n,k),a,f = [list(map(int, s.split())) for s in open(0)]

a.sort(reverse=True)
f.sort()

low = 0
high = 0
for x, y in zip(a,f):
    high = max(high, x*y)

while high != low:
    test = int((high + low) // 2)
    tmp = 0
    for x, y in zip(a,f):
        tmp += max(0, x - int(test / y))
        if tmp > k:
            low = test + 1
            break
    else:
        high = test
print(high)

Measured memory_bytes: 108860
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
#define coutv(v) for (int i = 0; i < (v).size(); ++i) cout << v[i] << ' '; cout << endl;
#define coutvv(v) for (int i = 0; i < (v).size(); ++i) {for (int j = 0; j < (v[i]).size(); ++j) cout << v[i][j] << ' '; cout << endl;}
#define debugv(v) {for (int i = 0; i < (v).size(); ++i) cerr << v[i] << ' '; cerr << endl;}
#define debugvv(v) {for (int i = 0; i < (v).size(); ++i) {for (int j = 0; j < (v[i]).size(); ++j) cerr << v[i][j] << ' '; cerr << endl;}}
#define TC int TESTCASE; cin >> TESTCASE; while (TESTCASE--)
typedef long long ll;
 



int main() {
	ll a,b,c;
	cin >> a >> b >> c;
	if (c >= a) {
		c -= a;
		a = 0;
	} else {
		a -= c;
		c = 0;
	}
	if (c > 0) {
		b -= min(c,b);
	}
	cout << a << " " << b;
}
 


Measured memory_bytes: 3560
#include <stdio.h>
#include <math.h>
int main(int argc, char **argv){
	int a, b, c;
	scanf("%d\n", &a);
	scanf("%d\n", &b);
	scanf("%d\n", &c);
	printf("%d\n", a + b + c - (int)fmax(a, fmax(b, c)));
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		A *= sc.nextInt();
		int B = sc.nextInt();
		B *= sc.nextInt();
		System.out.println(Math.max(A,B));
	}
}


Measured memory_bytes: 35568
#include "bits/stdc++.h"
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    cout << A[0] << " ";
    int ans = 0;
    int cnt = pow(10, 9);
    for (int i = 1; i < N; i++) {
        if (cnt > abs(A[0] / 2 - A[i])) {
            cnt = abs(A[0] / 2 - A[i]);
            ans = A[i];
        }
    }
    cout << ans << endl;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int3(a, b, c);

    cout << (b + min(c, a + b + 1)) << endl;

    return 0;
}


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

using namespace std;

int main(){

    long long int a,b,n;

    cin >> n;
    cin >> a;
    cin >> b;

    if((b-a) % 2 == 0){
        cout << (b-a)/2 << endl;
    }
    else if(b-a == 1){
        cout << min(a-1,n-b) +1 << endl;
    }
    else{
        cout << min(a-1,n-b)+1+(b-a-1)/2 <<endl;
    }





}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll pow(ll b, ll n)
{
    ll ans = 1;
    for(int i=0;i<n;i++) ans = ans * b;
    return ans;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll H;
    cin >> H;
    if (H == 1) cout << 1;
    else{
        int dal = 0;
    while(H != 1){
        H /= 2;
        dal++;
    }
    ll a = 0;
    for(int i = 2; i <= dal; i++){
    a += pow(2, i);
    }
    cout << a + 3;
    }
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int tenants[4][3][10];
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                tenants[i][j][k] = 0;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        tenants[b-1][f-1][r-1] += v;
    }
    for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 10; k++) {
            cout << " " << tenants[0][j][k];
        }
        cout << endl;
    }
    for (int i = 1; i < 4; i++) {
        for (int l = 0; l < 20; l++) {
            cout << "#";
        }
        cout << endl;
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                cout << " " << tenants[i][j][k];
            }
            cout << endl;
        }
    }
    return 0;
}


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

using namespace std;

int main()
{
    int n,h,w,a,b;
    cin>>n>>h>>w;
    vector<pair<int,int>>v;
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
        v.push_back({a,b});
    }
    int c=0;
    for(int i=0;i<n;i++)
    {
        if(v[i].first>=h&&v[i].second>=w)
        c++;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int deg[10];

int main(int argc, char const *argv[])
{
	for(int i = 0; i < 3; i++) {
		int p, q;
		cin >> p >> q;
		++deg[p];
		++deg[q];
	}
	int cnt = 0;
	for(int i = 1; i <= 4; i++) {
		if(deg[i] == 1) ++cnt;
	}
	cout << (cnt == 2 ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); //kosuu
        int m = sc.nextInt(); //sourceCode
        int c = sc.nextInt(); //plus
        int b[] = new int[m];
        int a[][] = new int[n][m];
        for(int i=0; i<m; i++){
            b[i] = sc.nextInt();
        }
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                a[i][j] = sc.nextInt();
            }
        }
        int cnt = 0;

        for(int i=0; i<n; i++){
            int sum = 0;
            for(int j=0; j<m; j++){
                sum += a[i][j] * b[j];
            }
            if(sum+c>0){
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 22356
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Wed Jan 16 19:08:19 2019
//
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var r, g, b string
	fmt.Scan(&r, &g, &b)
	v, _ := strconv.Atoi(r + g + b)
	if v%4 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
import java.util.*;
class Main{
	public static void main(String[] args){
    	Scanner in = new Scanner(System.in);		
      int n = in.nextInt();
      long x = in.nextLong();
      long a[] = new long[n];
      long ac[] = new long[n];
      for( int i =0;i<n;i++){
      	a[i] = in.nextLong();
        ac[i] =a[i];
      }
      for(int i = 0; i<n-1;i++){
      	if(a[i]+a[i+1]>x){
          	long dif = a[i]+a[i+1]-x;
          	if(dif<a[i+1]){
            	a[i+1]-=dif;
            }
          	else{
            	dif-=a[i+1];
              	a[i+1] = 0;
              	a[i]-=dif;
            }
        }
      }
      long sum=0;
      for(int i = 0;i<n;i++){
      	sum+=ac[i]-a[i];
      }
      System.out.println(sum);
    }
}


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

int main() {
  char c;
  cin >> c;
  
  string ans = "consonant";
  string vowel = "aeiou";
  for (int i = 0; i < vowel.size(); i++) {
    if (c == vowel.at(i)) {
      ans = "vowel";
      break;
    }
  }
  cout << ans << endl;
}


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;

const ll INF = (1LL<<60);

int main(){

    string s, t; cin >> s >> t;

    ll ans = 0;
    if(s[0] == t[0]) ans++;
    if(s[1] == t[1]) ans++;
    if(s[2] == t[2]) ans++;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
battle_number = int(raw_input())
Taro_score = 0
Hanako_score = 0

for x in xrange(battle_number):
	tcard, hcard = raw_input().split()

	if tcard > hcard:
		Taro_score += 3
	elif hcard > tcard:
		Hanako_score += 3
	elif tcard == hcard:
		Taro_score += 1
		Hanako_score += 1

print "%d %d" %(Taro_score, Hanako_score)

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

#define rep(i,n) for(int i=0; i<n; i++)

int main()
{
    int n; cin>>n; 
    string s[n]; rep(i,n) cin>>s[i];
    long long ans=0;
    rep(i,n) sort(s[i].begin(), s[i].end());
    unordered_map<string,long long>m;
    rep(i,n) m[s[i]]++;
    for(auto u:m) if(u.second>=2) ans+=((u.second)*(u.second-1)*1LL)/2;
    cout<<ans;
}

Measured memory_bytes: 17700
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    int a, b;
    cin>>a>>b;
    if((a*b)%2==0){
        cout<<"Even"<<endl;
    }else{
        cout<<"Odd"<<endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a, b;
int32_t main(){_

   cin>>n>>a>>b;

   int mi = min(n*a, b);

   cout<<mi;


   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
using namespace std;
int main(){
  int h,w,n;
  while(scanf("%d%d%d",&h,&w,&n)&&h){
    int c[1001][1001]={},a;
    c[0][0]=n-1;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	scanf("%d",&a);
	c[i+1][j]+=c[i][j]/2;
	c[i][j+1]+=c[i][j]/2;
	if(c[i][j]%2){
	  if(a)c[i][j+1]++;
	  else c[i+1][j]++;
	}
	c[i][j]+=a;
      }
    int x=0,y=0;
    while(x!=w&&y!=h){
      if(c[y][x]%2)x++;
      else y++;
    }
    printf("%d %d\n",y+1,x+1);
  }
  return 0;
}

Measured memory_bytes: 4948
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, k = ns()
    a = na()

    dp = [False for _ in range(k + 1)]

    for i in range(k + 1):
        for ai in a:
            if i + ai < k + 1:
                dp[i + ai] |= not dp[i]

    print("First" if dp[k] else "Second")


if __name__ == '__main__':
    main()


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

using namespace std;

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

const ll maxn =4e5+100;
const ll mod = 1e9+7;
const ld PI = 4 * atan((ld) 1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
#define ms(x , y) memset(x , y , sizeof x);
ll pw(ll a, ll b) {
    return (!b ? 1 : (b & 1 ? a * pw(a * a % mod, b / 2) % mod : pw(a * a % mod, b / 2) % mod));
}

int n , r;

int main(){
    migmig
    cin >> n >> r;
    if(n >= 10){
        dokme(r);
    }
    dokme(r + 100*(10 - n));


    return(0);
}


//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.


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

struct Problem {

	bool road[700][700] = {};

	void Solve() {
		UL N, M; cin >> N >> M;
		rep(i, M) {
			UL a, b; cin >> a >> b; a--; b--;
			road[a][b] = road[b][a] = true;
		}
		rep(i, N) road[i][i] = true;
		vector<int> G(N);
		vector<pair<UL, UL>> Sz;
		rep(s, N) {
			if (G[s]) continue;
			G[s] = s + 1;
			queue<UL> Q; Q.push(s);
			pair<UL, UL> sz = { 0, 0 };
			while (Q.size()) {
				UL p = Q.front(); Q.pop();
				if (G[p] > 0) sz.first++; else sz.second++;
				//rep(i, N) cout << G[i] << " "; cout << endl;
				rep(e, N) {
					if (road[p][e]) continue;
					if (G[e] == G[p]) { cout << -1 << endl; return; }
					if (G[e]) continue;
					G[e] = -G[p];
					Q.push(e);
				}
			}
			Sz.push_back(sz);
		}
		bool dp[701] = {};
		dp[0] = true;
		for (auto p : Sz) {
			bool buf[701] = {};
			for (UL j = p.first; j <= N; j++) buf[j] = buf[j] || dp[j - p.first];
			for (UL j = p.second; j <= N; j++) buf[j] = buf[j] || dp[j - p.second];
			rep(i, N + 1) dp[i] = buf[i];
		}
		UL ans = 1000000000;
		rep(i, N + 1) {
			if (dp[i]) {
				UL buf = i * (i - 1) / 2 + (N - i) * (N - i - 1) / 2;
				ans = min(ans, buf);
			}
		}
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 768
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007


    N = int(input())
    S = input().rstrip()
    t = S
    while 1:
        a = len(t)
        s = t.split('()')
        s = ''.join(s)
        if len(s)==a:
            break
        t = s
    left = s.count(')')
    right = s.count('(')
    print('('*left + S + ')'*right)

    # N = int(input())
    # S = list(input())
    # res = 0
    # for i in S:
    #     if i == ')':
    #         res += 1
    #     else:
    #         break
    # add = S[res:].count('(')-S[res:].count(')')
    # if add>=0:
    #     for _ in range(add):
    #         S.append(')')
    #     print('('*res+''.join(S))
    # else:
    #     print('('*(res-add)+''.join(S))




if __name__ == '__main__':
    main()

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

#define LL long long int

typedef struct {
    int index;
    LL value;
} tValueLL;

int cmpLL(const void *n1, const void *n2) {

    if (((tValueLL *)n1)->value > ((tValueLL *)n2)->value) {
        return 1;
    } else if (((tValueLL *)n1)->value < ((tValueLL *)n2)->value) {
        return -1;
    }

    return 0;
}


int main(void) {

    int n;
    scanf("%d", &n);
    tValueLL *a = (tValueLL *)malloc(n * sizeof(tValueLL));
    tValueLL *b = (tValueLL *)malloc(n * sizeof(tValueLL));
    for (int i = 0; i < n; i ++) {
        scanf("%lld %lld", &a[i].value, &b[i].value);
    }

    qsort(a, n, sizeof(tValueLL), cmpLL);
    qsort(b, n, sizeof(tValueLL), cmpLL);

    int ret;
    if (n % 2 == 1) {
        ret = b[(n - 1) / 2].value - a[(n - 1) / 2].value + 1;
    } else {
        ret = (b[n / 2 - 1].value + b[n / 2].value) - (a[n / 2 - 1].value + a[n / 2].value) + 1;
    }

    printf("%d", ret);

    return 0;
}


Measured memory_bytes: 11108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A;
  cin >> N >> A;
  int onecoinpart = N % 500;
  if (onecoinpart > A){
    cout << "No" << endl;
  }
  else {
   cout << "Yes" << endl; 
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define ull unsigned long long
#define mp make_pair
#define ld long double
#define PI pair<int,int>
#define fi first
#define se second
#define pol vector<poly>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
const int N=15,mod=1000000007;
struct poly{
	ull a[1<<N|2];
	poly(){
		memset(a,0,sizeof(a));
	}
	void clear(){
		memset(a,0,sizeof(a));
	}
	inline ull& operator [](int x){
		return a[x];
	}
	void fwt(int n){
		for(int i=0;i<n;i++){
			for(int j=0;j<(1<<n);j++)if(j>>i&1){
				a[j]=a[j]+a[j^(1<<i)]>=mod?a[j]+a[j^(1<<i)]-mod:a[j]+a[j^(1<<i)];
			}
		}
	}
	void ufwt(int n){
		for(int i=0;i<n;i++){
			for(int j=0;j<(1<<n);j++)if(j>>i&1){
				a[j]=a[j]>=a[j^(1<<i)]?a[j]-a[j^(1<<i)]:a[j]+mod-a[j^(1<<i)];
			}
		}
	}
}f[N+1],g[N+1];
PI Q[105];
ll v[105];
int cnt[1<<N|2];
ll ksm(ll a,int b){
	int ans=1;
	for(;b;b>>=1){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
void fft(pol &a,pol &b){
	int q=a.size()-1; 
	pol c(q+1);
	for(int i=0;i<=q;i++){
		//for(int k=0;k<(1<<q);k++)cout<<c[i][k]<<" "; puts("");
		for(int j=0;j<=i;j++){
			for(int k=0;k<(1<<q);k++){
				c[i][k]+=a[j][k]*b[i-j][k]; 
				//if(c[i][k]<0){cout<<q<<" "<<a[j][k]<<" "<<b[i-j][k]<<" "<<c[i][k]<<endl; exit(0);}
			}
		}
		for(int k=0;k<(1<<q);k++)c[i][k]%=mod;
	}
	swap(c,a);
}
void pf(pol &a){
	fft(a,a);
}
ll calc(int len){
	return (ksm(10,len)-1)*ksm(9,mod-2)%mod;
}
int main(){
	int n=read(),q=read();
	for(int i=0;i<q;i++){
		Q[i]=mp(read()-1,i);
		Q[i+q]=mp(read(),i);
	}
	sort(&Q[0],&Q[2*q]); Q[2*q].second=q;
	for(int i=0;i<2*q;i++){
		if(i==2*q-1)v[i]=ksm(10,n-Q[i].fi); else v[i]=calc(Q[i+1].fi-Q[i].fi); 
	}
	pol f(q+1);
	for(int i=0;i<(1<<q);i++){
		if(i)cnt[i]=cnt[i>>1]+(i&1);
		f[cnt[i]][i]=1;
		for(int j=0;j<2*q;j++)if(i>>Q[j].se&1){
			//if(i==3)cout<<v[j]<<" fjzzq "<<(i>>Q[j+1].se&1)<<endl;
			f[cnt[i]][i]=f[cnt[i]][i]*(v[j]+(i>>Q[j+1].se&1))%mod;
		}
		//cout<<f[cnt[i]][i]<<" "<<i<<endl;
	}
	for(int i=0;i<=q;i++)f[i].fwt(q);
	//pf(f); f[q].ufwt(q);
	pol ans=f;
	pf(f); pf(f); pf(f);
	fft(ans,f);//ans[q].ufwt(q);cout<<ans[q][(1<<q)-1]<<endl;
	ans[q].ufwt(q);
	ll an=ans[q][(1<<q)-1]*ksm(9,mod-2)%mod,t=calc(Q[0].fi);
	cout<<((9*t+1)%mod*an%mod+mod)%mod<<endl;
}

Measured memory_bytes: 20988
s = int(input())


def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3*n + 1


pre = s
result = set([s])
for i in range(1000005):
    current = f(pre)
    if current in result:
        print(i+2)
        break
    result.add(current)
    pre = current


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a = n%10;
  if(a==2 || a==4 || a==5 || a==7 || a==9){
    cout<<"hon"<<"\n";
  }
  else if(a==0 || a==1 || a==6 || a==8){
  	cout<<"pon"<<"\n";
  }
  else if(a==3){
    cout<<"bon"<<"\n";    
  }
return 0;
}

Measured memory_bytes: 3132
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
string str[1010101];
int maxs;
string st;
map<string,int> a;
int main()
{
	int s=0;
	int n,i;
	cin>>n;
	cin.get();
	for(i=0;i<n;i++){
		cin>>str[i];
	}
	sort(str+0,str+n);
//	for(i=0;i<n;i++) cout<<str[i]<<" ";
	st=str[0];s++;
	int o=0;
	maxs=s;
	for(i=1;i<=n;i++){
		if(str[i]==st){
			s++;
		}
		else{
		//	cout<<st<<" "<<s<<endl;
			a[st]=s;
			if(s>=maxs){
				maxs=s;
			}
			s=1;
			st=str[i];
			o++; 
		}
	}
	//cout<<maxs<<endl;
	for(i=0;i<=n;i++){
		if(a[str[i]]==maxs){
			cout<<str[i]<<endl;
			a[str[i]]=-1;
		}
	}
	return 0;

}


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

int main(){
    int n;
    cin >> n;
    int order=0;

    rep(i,n){
        int a;
        cin >> a;
        if(a!=i+1) order ++;
    }

    if(order<=2){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
}

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

using namespace std;

const int N = 100 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int x, a;

bool read() {
    if (!(cin >> x >> a))
        return false;

    return true;
}

void solve() {
    cout << (x >= a) * 10 << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



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

#define lld long long
#define pii pair<int,int>
#define pll pair<lld,lld>
#define pb push_back
#define next nextt
#define Inf 1000000000
#define Linf 1000000000000000000LL
#define Mod 1000000007

using namespace std;

int N,M;
lld a[300002],sum[300002],tmp[300002];
lld d[300002],d1[300002],d2[300002];
struct data{
	lld a,b;
	data(){}
	data(lld a,lld b):a(a),b(b){}
};
struct CHT{
	int cr,cf;
	data line[300002];
	void init(){
		cr = cf = -1;
	}
	lld ccw(data x,data y,data z){
		return (x.a*y.b+y.a*z.b+z.a*x.b)-(x.b*y.a+y.b*z.a+z.b*x.a);
	}
	lld f(int num,lld x){
		return line[num].a*x+line[num].b;
	}
	lld getv(lld x){
		while(cf && f(cf-1,x) >= f(cf,x)) cf--;
		return f(cf,x);
	}
	void add(lld a,lld b){
		while(cr > 0 && ccw(line[cr-1],line[cr],data(a,b)) <= 0) cr--;
		cf = min(cf,cr);
		if(cr != cf) return;
		cr++; cf++;
		line[cr] = {a,b};
	}
}cht;

void setting(lld D[]){
	cht.init();
	for(int i=1; i<=N; i++) sum[i] = sum[i-1]+a[i];
	cht.add(0,0);
	for(lld i=1; i<=N; i++){
		D[i] = max(cht.getv(i)+(i*(i+1)/2)-sum[i],D[i-1]);
		cht.add(-i,D[i]+sum[i]+(i*(i-1)/2));
	}
}

void divide(int s,int e){
	if(s == e){
		d[s] = max(d1[s-1]+d2[s+1]+1-a[s],d[s]);
		return;
	}
	int m = (s+e)>>1;
	lld res;
	divide(s,m);
	divide(m+1,e);
	cht.init();
	for(lld i=s-1; i<m; i++){
		cht.add(-i,d1[i]+sum[i]+(i*(i-1)/2));
	}
	for(lld i=m+1; i<=e; i++){
        tmp[i] = cht.getv(i)+(i*(i+1)/2)-sum[i]+d2[i+1];
	}
	res = -Linf;
	for(lld i=e; i>=m+1; i--){
        res = max(res,tmp[i]);
        d[i] = max(res,d[i]);
	}
	cht.init();
	for(lld i=m+2; i<=e+1; i++){
		cht.add(-i,d2[i]-sum[i-1]+(i*(i+1)/2));
	}
	res = -Linf;
	for(lld i=s; i<=m; i++){
        res = max(cht.getv(i)+(i*(i-1)/2)+sum[i-1]+d1[i-1],res);
		d[i] = max(res,d[i]);
	}
}

int main(){
    //freopen("input.txt","r",stdin);
	scanf("%d",&N);
	for(int i=1; i<=N; i++){
        scanf("%lld",&a[i]);
        d[i] = -a[i];
	}
	setting(d1);
	reverse(a+1,a+N+1); setting(d2); reverse(a+1,a+N+1); reverse(d2+1,d2+N+1);
	for(int i=1; i<=N; i++) sum[i] = sum[i-1]+a[i];
	divide(1,N);
	scanf("%d",&M);
	for(int i=1; i<=M; i++){
		int x; lld y;
		scanf("%d %lld",&x,&y);
		printf("%lld\n",max(d1[x-1]+d2[x+1],d[x]+a[x]-y));
	}

	return 0;
}


Measured memory_bytes: 17280
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

void maxi(int & a, int b) { a = max(a, b); }

int main() {
	string s;
	cin >> s;
	int eq = 0, smaller = -1000;
	for(char ch : s) {
		int digit = ch - '0';
		int a = -1000, b = -1000;
		
		for(int i = 0; i < 10; ++i) {
			maxi(b, smaller + i);
			if(i < digit) maxi(b, eq + i);
			if(i == digit) maxi(a, eq + i);
		}
		eq = a;
		smaller = b;
	}
	printf("%d\n", max(eq, smaller));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main()
{
    string s;
    cin >> s;

    ll cnt =  0,ln = s.size();
    for(int i = 0; i < ln-1; i++)
    {
        if(s[i] != s[i+1])
            cnt++;
    }

    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) {
        cin >> A[i];
    }

    int l = 0, r = N-1;
    ll left = A[0], right = A[N-1];
    while (l+1 < r) {
        if (left <= right) {
            l++;
            left += A[l];
        } else {
            r--;
            right += A[r];
        }
        // cout << left << right << endl;
        
    }

    cout << abs(left - right) << endl;


    //cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<stack>
#include<vector>

int main(){
    int n;
    scanf("%d",&n);
    char s[n+4];
    scanf("%s",s);
    int i;
    for(i=n-1;i>=0;i--){
        s[i+1]=s[i];
    }
    s[n+1]=s[1];
    s[n+2]=s[2];
    
    char ans1[n+4],ans2[n+4],ans3[n+4],ans4[n+4];
    int flag=0;
    
    ans1[1]='S',ans1[2]='S';
    
    for(i=2;i<=n+1;i++){
        int mark=1;
        if(s[i]=='x')mark=-mark;
        if(ans1[i-1]=='W')mark=-mark;
        if(ans1[i]=='W')mark=-mark;
        
        if(mark==1)ans1[i+1]='S';
        else ans1[i+1]='W';
    }
    if(ans1[1]==ans1[n+1] &&ans1[2]==ans1[n+2]){
        for(i=1;i<=n;i++)printf("%c",ans1[i]);
        flag=1;
    }
    
    if(flag==0){
        ans2[1]='S',ans2[2]='W';
        for(i=2;i<=n+1;i++){
            int mark=1;
            if(s[i]=='x')mark=-mark;
            if(ans2[i-1]=='W')mark=-mark;
            if(ans2[i]=='W')mark=-mark;
            
            if(mark==1)ans2[i+1]='S';
            else ans2[i+1]='W';
        }
        if(ans2[1]==ans2[n+1] &&ans2[2]==ans2[n+2]){
            for(i=1;i<=n;i++)printf("%c",ans2[i]);
            flag=1;
        }
    }
    
    if(flag==0){
        ans3[1]='W',ans3[2]='S';
        for(i=2;i<=n+1;i++){
            int mark=1;
            if(s[i]=='x')mark=-mark;
            if(ans3[i-1]=='W')mark=-mark;
            if(ans3[i]=='W')mark=-mark;
            
            if(mark==1)ans3[i+1]='S';
            else ans3[i+1]='W';
        }
        if(ans3[1]==ans3[n+1] &&ans3[2]==ans3[n+2]){
            for(i=1;i<=n;i++)printf("%c",ans3[i]);
            flag=1;
        }
    }
    
    if(flag==0){
        ans4[1]='W',ans4[2]='W';
        for(i=2;i<=n+1;i++){
            int mark=1;
            if(s[i]=='x')mark=-mark;
            if(ans4[i-1]=='W')mark=-mark;
            if(ans4[i]=='W')mark=-mark;
            
            if(mark==1)ans4[i+1]='S';
            else ans4[i+1]='W';
        }
        if(ans4[1]==ans4[n+1] &&ans4[2]==ans4[n+2]){
            for(i=1;i<=n;i++)printf("%c",ans4[i]);
            flag=1;
        }
    }
    
    
    if(flag==0)printf("-1");
    
    return 0;
}

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

map<char, int>mp1{
	{'m',1000},{'c',100},{'x',10},{'i',1}
};
map<int, char>mp2{
	{1000,'m'},{100,'c'},{10,'x'},{1,'i'}
};
int d[]{ 1000,100,10,1 };

int main() {
	int n; scanf("%d", &n);
	rep(i, n) {
		string s1, s2; cin >> s1 >> s2;
		int cnt = 0;
		int sum = 0;
		for (char c : s1) {
			if (isalpha(c)) {
				if (cnt)sum += mp1[c] * cnt;
				else sum += mp1[c];
				cnt = 0;
			}
			else cnt = c - '0';
		}
		cnt = 0;
		for (char c : s2) {
			if (isalpha(c)) {
				if (cnt)sum += mp1[c] * cnt;
				else sum += mp1[c];
				cnt = 0;
			}
			else cnt = c - '0';
		}
		string ans;
		rep(j, 4) {
			if (sum >= d[j]){
				if (sum / d[j] > 9) {
					(ans += '9') += mp2[d[j]];
					sum -= d[j] * 9;
					continue;
				}
				if (sum / d[j] > 1)ans += to_string(sum / d[j]) + mp2[d[j]];
				else ans += mp2[d[j]];
				sum %= d[j];
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3176
N, M, X = map(int, input().split())
A = [int(i) for i in input().split()]

ans = []
xx = X
num = 0
for i in range(1, 101):
    X += 1
    if A.count(X) == 1:
        num += 1

ans.append(num)
num = 0
for i in range(1, 101):
    xx -= 1
    if A.count(xx) == 1:
        num += 1

ans.append(num)
ans.sort()
print(ans[0])

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


int main(){
    int n,t;
    cin >> n >> t;
    int mi = inf;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        if(b<=t){
            mi = min(mi,a);
        }
    }
    if(mi==inf){
        cout << "TLE" << endl;
    }else{
        cout << mi << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, b) for (int i = 0; i < int(b); i++)

int w, h;
vector<vector<int>> g;

int const dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 };
int const dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
inline bool in(int x, int y){
    return 0 <= x && x < w && 0 <= y && y < h;
}

void fill(int x, int y){
    g[y][x] = 0;
    rep(i, 8){
        int xx = x + dx[i];
        int yy = y + dy[i];
        if (in(xx, yy) && g[yy][xx]) fill(xx, yy);
    }
}

int main(){
    while (cin >> w >> h, w | h){
        g.assign(h, vector<int>(w));
        rep(i, h)rep(j, w) cin >> g[i][j];
        int c = 0;
        rep(i, h)rep(j, w){
            if (g[i][j]){
                c++;
                fill(j, i);
            }
        }
        cout << c << endl;
    }
}

Measured memory_bytes: 1300
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> P;
typedef pair<ll,pair<ll,ll>> p;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
static const int MAX_SIZE = 1 << 17; //segment tree のサイズ。この実装では2べきにする必要がある。 2^17 ≒ 1.3 * 10^5

int dp[110000][2];

bool flag[110000];
int C[1000][1000];

int main(){
    bool flag=false;
    int N;
    cin>>N;
    int k;
    for(k=2;k*(k-1)<=N*2;k++){
        if(k*(k-1)==N*2){
            flag=true;
            break;
        } 
        else flag=false;
    }

    if(flag){
        cout<<"Yes"<<endl;
        cout<<k<<endl;
        int now=1;
        for(int i=1;i<=k;i++){

            for(int j=i;j<=k-1;j++){
                C[i][j]=now;
                C[j+1][i]=now;
                now++;
            }

            
        }

        for(int i=1;i<=k;i++){
            cout<<k-1;
            for(int j=1;j<=k-1;j++){
                cout<<" "<<C[i][j];
            }
            cout<<endl;

        }
    }else cout<<"No"<<endl;
}



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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (vec[i] >= k) count++;
  }
  cout << count << endl;
}

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

int main(){
  int n; cin >>n;
  vector<pair<int, int>> p(n);
  rep(i,n) {
    int a,b; cin >>a >>b;
    p.emplace_back(b,a);
  }
  sort(p.begin(), p.end());
  int sum = 0;
  bool can = true;
  for(auto v : p){
    sum += v.second;
    if(sum>v.first){
      can = false;
      break;
    }
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
#define MAX 100000000
int n,k;
int mini;
int h[100005];
int dp[100005];
int jump(int curr){
	if(curr==n) return 0;
	if(curr>n) return MAX;
	if(dp[curr]!=-1) return dp[curr];
	return dp[curr]=min((abs(h[curr]-h[curr+1])+jump(curr+1)),(abs(h[curr]-h[curr+2])+jump(curr+2)));
}
int main() {
	cin>>n;
	int temp;
	for(int i=1;i<=n;i++)
		dp[i]=-1;
	for(int i=1;i<=n;i++){
		cin>>h[i];
	}
	cout<<jump(1);
	return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
	int h, n;
	cin >> h >> n;
	vector<ll> dp(100000, 1e18);
	dp[0] = 0;
	for(int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		for(int j = 0; j < h; j++) dp[min(j + a, h)] = min(dp[j] + b, dp[min(j + a, h)]);
	}
	cout << dp[h] << endl;
}

Measured memory_bytes: 1024