akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int>pii;
typedef vector<int>vi;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fi first
#define se second
#define de(x) cout<<#x<<"="<<x<<"\n"
#define dd(x) cout<<#x<<"="<<x<<" "
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lowbit(a) ((a)&-(a))
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
const int N=4e5+5;
vi pos[N];
int n , m ;
struct segTree{
	int mx[N<<2],b[N<<2],add[N<<2];
	void Build(int l ,int r,int rt){
		add[rt] = 0;
		if(l == r){ mx[rt] = r - m - 1;return;}
		int m = ( l + r)/2;
		Build(l,m,rt<<1);
		Build(m + 1, r,rt<<1|1);
		mx[rt] = max(mx[rt<<1],mx[rt<<1|1]);
		
	}
	void upd(int L,int R,int c,int l,int r,int rt){
		if( L <= l && r <= R){
			add[rt] += c;
			return ;
		}
		int m = ( l + r)/2;	
		if(L <= m)upd(L,R,c,l,m,rt<<1);
		if(R  > m)upd(L,R,c,m + 1,r,rt<<1|1);
		mx[rt] = max(mx[rt<<1] + add[rt<<1],mx[rt<<1|1] + add[rt<<1|1]);
	//	dd(l),dd(r),de(mx[rt]+add[rt]);
	}
	int qry(int L,int R,int l ,int r,int rt){
		if(L > R)return -n - 1;
		if(L <= l && r <= R){
			return mx[rt] + add[rt];
		}
		int m = ( l + r)/2;
		int ans = -1e8;
		if(L <= m )ans = max(ans,qry(L,R,l,m,rt<<1));
		if(R  > m )ans = max(ans,qry(L,R,m + 1,r,rt<<1|1));
	//	dd(l),dd(r),dd(ans),de(add[rt]);
		return ans + add[rt];
	}
}sg;
int main()
{
	cin>>n>>m;
	int l , r;
	rep(i , 1 , n + 1){
		cin>>l>>r;	
		pos[l].pb(r);	
	}
	sg.Build(1 , m + 1, 1);
	
	int ans = 0;
	rep(i , 0 , m + 1){
		for(auto v:pos[i]){
			sg.upd(1,v,1,1,m + 1,1);
		//	de(v);
		}
	//	dd(i),dd(sg.mx[1] + sg.add[1]),de(sg.qry(i + 1,m + 1,1,m + 1,1));
		if(i)sg.upd(1,i,1,1,m + 1,1);
		ans = max(ans,sg.qry(1,m + 1,1,m + 1,1) - i );
		
		
	}
//	ans = max(ans,n - m);
	cout<<ans<<"\n";
	return 0;
}



Measured memory_bytes: 21760
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
int main() {
    int N;
    cin >> N;
    for (int i = 0;i < 9;i++){
        if(N <= 111*(i + 1)){
            cout << 111*(i + 1) << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
R = 3
r = [ list(map(int, input().split(' '))) for i in range(R) ]

def check():
  for y in range(R):
    f = True
    for x in range(R):
      if r[y][x] != 0:
        f = False
        break
    if f:
      return True
 
  for x in range(R):
    f = True
    for y in range(R):
      if r[y][x] != 0:
        f = False
        break
    if f:
      return True
 
  f = True
  for p in range(R):
    if r[p][p] != 0:
      f = False
      break
  if f:
    return True
 
  f = True
  for p in range(R):
    if r[R-1-p][p] != 0:
      f = False
      break
  return f
 
N = int(input())
for i in range(N):
  v = int(input())
  
  for y in range(R):
    for x in range(R):
      if r[y][x] == v:
        r[y][x] = 0
 
print('Yes' if check() else 'No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ri register int
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> poly;
#define pb push_back
#define fi first
#define se second
const int rlen=1<<18|1;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
inline int read() {
  int ans=0;
  char ch=gc();
  while(!isdigit(ch)) ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return ans;
}
namespace modular {
  int mod;
  inline int add(int a,int b) { return a+b<mod?a+b:a+b-mod; }
  inline int dec(int a,int b) { return a<b?a-b+mod:a-b; }
  inline int mul(int a,int b) { return (ll)a*b%mod; }
  inline void Add(int&a,int b) { a=a+b<mod?a+b:a+b-mod; }
  inline void Dec(int&a,int b) { a=a<b?a-b+mod:a-b; }
  inline void Mul(int&a,int b) { a=(ll)a*b%mod; }
  inline int ksm(int a,int p) { int ret=1;for(;p;p>>=1,Mul(a,a)) (p&1)&&(Mul(ret,a),1);return ret; }
}
using namespace modular;
const int N=5005;
int n,f[N],a[N];
int main() {
  #ifdef ldxcaicai
  freopen("lx.in","r",stdin);
  #endif
  n=read(),mod=read();
    int mid=n+1>>1;
  if(n&1) {
    for(ri i=0;i<mid-1;++i) a[i+2]=i;
    for(ri i=mid-1,ct=1;i;--i,++ct) a[mid+ct]=i;
  }
  else {
    for(ri i=0;i<mid-1;++i) a[i+2]=i;
    a[mid+1]=mid-1;
    for(ri i=mid-1,ct=1;i;--i,++ct) a[mid+1+ct]=i;
  }
  for(ri i=2;i<=n;++i) ++a[i];
  f[0]=1;
  for(ri i=2;i<=n;++i) for(ri j=a[i];j<n;++j) Add(f[j],f[j-a[i]]);
  int res=0;
  for(ri i=0;i<n;++i) Add(res,mul(f[i],n-i));
  cout<<res;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
int arr[MAXX];
void trozen()
{
	double x=1.01;
	int n;
	cin>>n;
	double ans=100.0;
	for(int i=1;i<10000000;i++)
	{
		double temp=floor((ans*x));
		ans=temp;
		//cout<<temp<<" "<<x<<endl;
		if(temp>=n)
		{
			cout<<i<<endl;
			break;
		}
	}
}
int32_t main()
{
	op1;op2;op3;
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif*/
	trozen();
	return 0;
}


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

typedef long long ll;

int main(){

  int n,ans = 0;
  cin >> n;
  std::vector<ll> v(n),c(n);
  for (ll i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (ll i = 0; i < n; i++) {
    cin >> c[i];
  }
  for (ll i = 0; i < n; i++) {
    if(v[i]-c[i] > 0)
      ans += v[i]-c[i];
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(){
	int n,x;
	scanf("%d",&n);

	for(int i = 1; i<= n; i++)
	{
		if(i%3 == 0){
			printf(" %d",i);
		}else{
			x = i;
			do{
				if(x%10 == 3){
					printf(" %d",i);
					break;
				}
				x /=10;
			}while(x);
		}
	}
	printf("\n");
}



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

using namespace std;
string bus_stop = "0123456789543210123456789543210123456789543210";

void solve()
{
	int n;
	cin >> n;
	while(n--)
	{
		char s, g;
		cin >> s >> g;
		string ans1, ans2;
		bool flag = false;
		int pos = 0;
		for(int i = 0; i < bus_stop.size(); ++i)
		{
			if(!flag && bus_stop[i] == s)
			{
				flag = true;
				pos = i;
			}
			if(flag)
			{
				ans1 += bus_stop[i];
				if(bus_stop[i] == g)
				{
					break;
				}
			}
		}
		flag = false;
		for(int i = pos + 1; i < bus_stop.size(); ++i)
		{
			if(bus_stop[i] == s)
			{
				flag = true;
			}
			if(flag)
			{
				ans2 += bus_stop[i];
				if(bus_stop[i] == g)
				{
					break;
				}
			}
		}
		if(ans1.size() < ans2.size())
		{
			cout << ans1[0];
			for(int i = 1; i < ans1.size(); ++i)
			{
				cout << " " << ans1[i];
			}
			cout << endl;
		}
		else
		{
			cout << ans2[0];
			for(int i = 1; i < ans2.size(); ++i)
			{
				cout << " " << ans2[i];
			}
			cout << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1204
//============================================================================
// Name        : abc100.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cmath>
using namespace std;

inline int func001() {

	int a, b;

	cin >> a >> b;

	if ((a <= 8) && (b <= 8)) {
		cout << "Yay!";
	} else {
		cout << ":(";
	}

	return 0;

}

inline int func002() {

	int d, n;

	cin >> d >> n;

	if (n == 100)
		n += 1;

	cout << n * pow(100, d);

	return 0;

}

inline int func003() {

	int n;
	int a;
	int i, j;
	int res = 0;

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> a;
		for (j = 0; j < 31; j++) {
			if ((a & 0x1) == 0x1) {
				res += j;
				break;
			} else {
				a >>= 1;
			}
		}

	}

	cout << res;

	return 0;

}

//#define TEST 1

int main() {

#ifdef TEST
	while (1)
#endif
		func003();

	return 0;
}


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

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

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


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  PII pp,pn,np,nn;
  pp.F=pn.F=np.F=nn.F=-INF;
  pp.S=pn.S=np.S=nn.S=INF;
  
  rep(i,n){
    int a,b;
    cin>>a>>b;
    pp.F=max(a+b,pp.F);
    pp.S=min(a+b,pp.S);
    pn.F=max(a-b,pn.F);
    pn.S=min(a-b,pn.S);
    np.F=max(b-a,np.F);
    np.S=min(b-a,np.S);
    nn.F=max(-(a+b),nn.F);
    nn.S=min(-(a+b),nn.S);
    /* cout<<pp.F<<" "<<pp.S<<endl;
    cout<<pn.F<<" "<<pn.S<<endl;
    cout<<np.F<<" "<<np.S<<endl;
    cout<<nn.F<<" "<<nn.S<<endl;
    cout<<endl;*/
  }
  cout<<max(max(pp.F-pp.S,pn.F-pn.S),max(np.F-np.S,nn.F-nn.S) )<<endl;

  return 0;
}


Measured memory_bytes: 3648
#include<cstdio>
int main(){
  int x1, y1, x2, y2;
  scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
  printf("%d %d %d %d\n", x2-y2+y1, y2+x2-x1, x1-y2+y1, y1+x2-x1);
  }


Measured memory_bytes: 128
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g;
    cin>>n;
    if(n%10==n/100) Yes;
    else No;
    return 0;
}


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

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

	cout << (T / A) * B << endl;
}

Measured memory_bytes: 3636
import java.io.*;
import java.util.Arrays;
class Main{
	public static void main(String[] args) throws IOException {
		double n;
		String str;
		String[] f = new String[5];
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		str = in.readLine();
		n = Double.parseDouble(str);
		f[0] = String.format("%.6f",2*n*Math.PI);
		f[1] = String.format("%.6f",n*n*Math.PI);
		System.out.println(f[1]+" "+f[0]);
	}
}

Measured memory_bytes: 24772
#include <iostream>

using namespace std;

int main(){
    string str;
    while(cin >> str){
        int total=0;
        for(int i=0;i<str.length();i++){
            total+=str[i]-'0';
        }if(total%9==0){
            cout << "Yes" << '\n';
        }else{
            cout << "No" << '\n';
        }
    }
}

Measured memory_bytes: 3756
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

int isUnder(int T,int A){ // AがT以下で1,それ以外0
    if(A<=T) return 1;
    else return 0;
}

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    if(N%2==0) cout << N/2 -1 << nn;
    else cout << N/2 << nn;
    return 0;
}

Measured memory_bytes: 256
X,Y = map(int, input().split())

if (X+Y)%3!=0:
    print(0)
    exit()

def mcomb(n, k):
    fac = [0] * (n + 1)
    fac[0] = 1
    for i in range(1, n + 1):
        fac[i] = fac[i - 1] * i % 1000000007


    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], 1000000005, 1000000007) * pow(fac[k], 1000000005, 1000000007) % 1000000007

N = (-1*X+2*Y)//3
M = (2*X-Y)//3
print(mcomb(N+M, N)%(10**9+7))

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
using ll = long long;
using ld = long double;
using str = string;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<str>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

// Constant variables
const ld PI = (acos(-1));
const ll MOD = 1000000007;

// I/O Asynchronizing
struct __io_async{
    __io_async(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

int main() {
    int m1, m2, d1, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    cout << (m1 != m2 ? 1 : 0) << endl;

    return 0;
}


Measured memory_bytes: 256
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]


N = int(input())
S = input()
L = [None]*3
L[0] = []
L[1] = []
L[2] = []
for i in range(N):
    if S[i] == 'R':
        L[0].append(i)
    if S[i] == 'G':
        L[1].append(i)
    if S[i] == 'B':
        L[2].append(i)
cnt = 0
wa = [None]*3
for i in range(3):
    wa[i] = [0]*(N+1)
for i in range(3):
    for j in range(N):
        if S[j] == "RGB"[i]:
            wa[i][j+1] = 1
for i in range(3):
    for j in range(N):
        wa[i][j+1] = wa[i][j]+wa[i][j+1]
for x in itertools.permutations([0, 1, 2]):
    r = L[x[0]]
    g = L[x[1]]
    b = L[x[2]]
    for i in range(len(r)):
        for j in range(len(g)):
            if r[i] < g[j]:
                cnt += wa[x[2]][N]-wa[x[2]][g[j]+1]
                if len(S) > (g[j]-r[i])+g[j] and S[(g[j]-r[i])+g[j]] == "RGB"[x[2]]:
                    cnt -= 1
print(cnt)


Measured memory_bytes: 76424
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
ll a[200005];
int main(){
	cin >> n;
	repn(i,n) cin >> a[i];
	sort(a+1,a+n+1,greater<ll>());
	ll ans = 0;
	ll base = 1;
	rep(i,2*n-2) base = base*2LL%mod;
	repn(i,n){
		ans += a[i] * (i+1) % mod;
	}
	cout<<(ans%mod*base%mod+mod)%mod<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main(){
	int x,y,z;
	vector<int> a(3);
	cin >> a[1] >> a[2] >> a[0];
	sort(a.begin(),a.end());
	cout << abs(a[0]-a[1])+abs(a[1]-a[2]) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
static constexpr int N_max = 100'000;
struct Robot {
    int x, len;
    int left, right;
};

int main() {
    int n;
    cin >> n;
    auto robots = vector<Robot>(n);

    for (auto &r : robots) {
        cin >> r.x >> r.len;
        r.left = r.x - r.len;
        r.right = r.x + r.len;
    }
    sort(robots.begin(), robots.end(), [](auto a, auto b) {
        if (a.right < b.right)
            return true;
        if (a.right > b.right)
            return false;
        return a.x < b.x;
    });

    int counter = 0;
    int x_right = -2'100'000'000;
    for (int i = 0; i < n; i++) {
        auto &r = robots[i];
        if (x_right <= r.left) {
            x_right = r.right;
            counter++;
        }
    }

    cout << counter;
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
#モンスター
a = list(map(int, input().split()))
#勇者
b = list(map(int, input().split()))

#残った勇者
x=0
c=0

for n in range(0,N):
  #街n
  #倒したモンスター数
  c = c+min(b[n]+x,a[n])
  #残った勇者
  if a[n]<x:
    x=b[n]
  else:
    x=max(b[n]+x-a[n],0)
    
c = c+min(x,a[N])
#残った勇者
if a[N]<x:
  x=a[N]
else:
  x=max(x-a[N],0)

print(c)


Measured memory_bytes: 18476
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;
typedef long long ll;

 int main(){

   ll n,p;
   cin>>n>>p;

   if(n == 1)
    cout<<p<<endl;
   else {
      int a = 1;
      while(pow(a+1,n) <= p)
        a++;

      for(int i=a;i>=1;i--)
    {
        ll b = pow(i,n);

      if(p%b == 0){
        cout<<i<<endl;
        break; }
     }

   }

 return 0;
 }


Measured memory_bytes: 4032
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    X = rl().rstrip()
    
    ans = len(X)
    cnt_s = 0
    for xi in X:
        if xi == 'S':
            cnt_s += 1
        elif xi == 'T' and cnt_s:
            ans -= 2
            cnt_s -= 1
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int k;
    cin >> k;

    cout << a[--k] << endl;
}

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

int gcd3(int a,int b,int c){
    for(int i=min({a,b,c});i>=1;i--){
        if(a%i==0&&b%i==0&&c%i==0){
            return i;
        }
    }
    return 1;
}

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

    int ans=0;

    for(int i=1;i<=K;i++){
        for(int j=1;j<=K;j++){
            for(int k=1;k<=K;k++){
                ans += gcd3(i,j,k);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
//int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };

void solve() {
	int N; cin >> N;
	string S; cin >> S;
	ll ans = 0;
	int l = 0,r = N - 1;
	while (l < r) {
		if (S[l] == 'W'&&S[r] == 'R') {
			ans++;
			l++;
			r--;
		}
		else if (S[l] == 'R')l++;
		else if (S[r] == 'W')r--;
	}
	print(ans);
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 3776
package main

import (
	"fmt"
	"io"
	"os"
)

func Solve(stdin io.Reader, stdout io.Writer) {
	var n int
	_, _ = fmt.Fscan(stdin, &n)

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		var tmp int
		_, _ = fmt.Fscan(stdin, &tmp)
		arr[i] = tmp
	}

	colors := make([]int, 0, n)
	colors = append(colors, arr[n-1])
	max := arr[n-1]

	for i := n - 2; i >= 0; i-- {
		// 既に持っているcolors の最大値よりも大きい場合は新しい色を追加
		if arr[i] >= max {
			colors = append(colors, arr[i])
			max = arr[i]
		} else {
			// どこかで入れ替えられる場合，入れ替えられるもののうち最小の色を入れ替えたい
			// colorsは昇順にソートされているから二分探索を使える
			t := binarySearch(colors, arr[i])
			if t < len(colors) {
				colors[t] = arr[i]
			} else {
				colors = append(colors, arr[i])
				max = arr[i]
			}
		}
	}

	_, _ = fmt.Fprintf(stdout, "%d\n", len(colors))
}

func binarySearch(arr []int, target int) int {
	left := -1
	right := len(arr)

	for right-left > 1 {
		mid := left + (right-left)/2

		if arr[mid] > target {
			right = mid
		} else {
			left = mid
		}
	}

	return right
}

func main() {
	Solve(os.Stdin, os.Stdout)
	return
}


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

int main() {
  int a;
  cin >> a;
  cout <<  (a / 100) + ((a- 100 * (a / 100)) / 10) + ((a- 100 * (a / 100)) - 10 * ((a- 100 * (a / 100)) / 10)) << endl;
}





Measured memory_bytes: 256
Ss = input()

N = len(Ss)

anss = [0] * N
Ss += '#'
i = 0
while i < N:
    i0 = i
    while Ss[i] == 'R':
        i += 1
    iR = i-1
    numR = iR-i0+1
    iL = i
    while Ss[i] == 'L':
        i += 1
    numL = i-iL
    anss[iR] = (numR+1)//2 + numL//2
    anss[iL] = (numL+1)//2 + numR//2

print(' '.join(map(str, anss)))


Measured memory_bytes: 10484
#include<bits/stdc++.h>
using namespace std;
const int INF=2E9;
typedef pair<int,int> Pair;
int H[200100]={0};
long long S[200100]={0};

bool hantei(int l,int r){
    return S[r]-S[l-1]==(int)H[r]^H[l-1];
}

int main(){
    int N;

    cin >> N;
    int tmp;
    int maxV=0;
    for(int i=0;i<N;i++){
        scanf("%d",&tmp);
        H[i+1]=H[i]^tmp;
        S[i+1]=S[i]+tmp;
    }
    int cnt=0;
    int haita=0;
    long long SUM;
    int i=1,j=1;
    int Length=1;
    int bbn=1;
     /* しゃくとり法 */
    long long res = 0;
    int right = 0;
    int sum = 0; // AND 和
    for (int left = 0; left < N; ++left) {
        while (right < N &&  S[right+1]-S[left]==((int)H[right+1]^H[left])){
            ++right;
        }
        res += right - left;
        if (left == right) ++right;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 2560
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n,a,b,c,d = readmi()

s = read()
s = deque(s)
s.appendleft('.')

flg = True # B
if c > d:
    flg = False # A
flg2 = False
aflg = False
bflg = False

while(1):
    t = 0
    if flg:
        if b + 1 <= n and s[b + 1] != '#' and b + 1 != a and not(bflg):
            t = 1
        elif s[b + 2] != '#' and b + 2 != a and b + 2 <= n and not(bflg):
            t = 2
        else:
            bflg = True
            flg = False
            flg2 = True
        b += t
        if b == d:
            bflg = True
            flg = False
            flg2 = True
    else:
        if not(flg):
            if not(flg2):
                if b != d:
                    if b + 1 <= n and s[b - 1] == '.' and s[b + 1] == '.' and not(bflg) and not(aflg):
                        flg2 = True
                    else:
                        if b + 1 <= n and s[b + 1] != '#' and b + 1 != a and not(bflg):
                            t = 1
                        elif b + 2 <= n and s[b + 2] != '#' and b + 2 != a and not(bflg):
                            t = 2
                        else:
                            bflg = True
                            flg2 = True
                b += t
                if b == d:
                    bflg = True
                    flg2 = True
            else:
                if a != c:
                    if a + 1 <= n and s[a + 1] != '#' and a + 1 != b and not(aflg):
                        t = 1
                    elif a + 2 <= n and s[a + 2] != '#' and a + 2 != b and not(aflg):
                        t = 2
                    else:
                        aflg = True
                        flg2 = False
                a += t
                if a == c:
                    aflg = True
                    flg2 = False
    if aflg and bflg:
        if a == c and b == d:
            print('Yes')
        else:
            print('No')
        exit()

Measured memory_bytes: 7880
#include<bits/stdc++.h>
using namespace std;
#define inf 100000000000000000
#define ll long long 
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define test ll t ; cin>>t; while(t--)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	
	ll n , m , q ;
	cin>>n>>m>>q;
	ll a[n+1],b[m+1];
	ll mn = 10000000000000 ;
	ll ans;
	for(ll i=1;i<=n ;i++)cin>>a[i];
	for(ll i=1;i<=m ;i++)cin>>b[i];
	for(ll i=0;i<q;i++){
		ll p , q , r;
		cin>>p>>q>>r;
		ans=a[p]+b[q]-r;
		mn=min(ans , mn);
	}	
	sort(a+1 , a+n+1 );
	sort(b+1 , b+n+1 );
	mn = min(mn , a[1]+b[1]);
	cout<<mn<<endl;

	return 0;
}

Measured memory_bytes: 1792
import System.Exit

type Width = Int
type Height = Int
type Pattern = String

getPattern :: Width -> Height -> Pattern
getPattern w h
    | h `mod` 2 /= 0 = take w $ concat (repeat "#.")
    | otherwise      = take w $ concat (repeat ".#")

getPatterns :: Width -> Height -> [Pattern]
getPatterns w h = map (getPattern w) [1..h]

main = do
    line <- getLine
    let (h:w:[]) = map read (words line)
    case (h,w) of
        (0,0) -> exitSuccess
        _     -> mapM_ putStrLn (getPatterns w h)
    putStrLn ""
    main


Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define FD(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define pii pair<int,int>
#define reset(x,y) memset(x, y,sizeof(x))
#define MIN(x,y) if (x > (y)) x = (y)
#define MAX(x,y) if (x < (y)) x = (y)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define EL putchar('\n');
#define mod 1000000007
#define oo 1000006
int read()
{
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
void write(int x)
{
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}
int n;
int a[100],x;
map<int,ll>f[100];
void ReadInPut()
{
    n=read();
    x=read();
    F(i,1,n){a[i]=read();a[i]-=x;}
    F(i,1,n)
    {
        int v=a[i];
        for(int j=-1000;j<=1000;j++)
        {
            f[i][j]+=f[i-1][j-v];
        }
        for(int j=-1000;j<=1000;j++)
            f[i][j]+=f[i-1][j];
        f[i][v]++;
    }
    cout<<f[n][0];
}
void Solve()
{
}
main()
{
//    freopen("t.INP","r",stdin);
  //  freopen(".OUT","w",stdout);
    int sotest=1;
    //cin>>sotest;
    for(int i=1;i<=sotest;i++)
    {
        ReadInPut();
        Solve();
    }
}


Measured memory_bytes: 6784
<?php
while ($input = fgets(STDIN)){
    $array[] = trim($input);
}
$count = $array[0];
$ac    = 0;
$tle   = 0;
$wa    = 0;
$re    = 0;
for ($i=1;$i<=$count;$i++) {
    $key = $array[$i];
    switch ($key) {
        case 'AC':
            $ac ++;
            break;
        case 'TLE':
            $tle ++;
            break;
        case 'WA':
            $wa ++;
            break;
        case 'RE':
            $re ++;
            break;
        default:
            break;
    }
}

echo "AC x ".$ac."\n";
echo "WA x ".$wa."\n";
echo "TLE x ".$tle."\n";
echo "RE x ".$re."\n";
?>

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

int n;
vector<int> a;
int x, y;

int bs(int l, int r){
	while(r - l > 1){
		int mid = (l + r) / 2;
		if(a[mid] < x/2) l = mid;
		else r = mid;
	}
	if(x/2 - a[l] < a[r] - x/2) return a[l];
	else return a[r];
}

int main(){
	cin >> n;
	for(int i=0; i<n; ++i){
		int t;
		cin >> t;
		a.push_back(t);
	}
	sort(a.begin(), a.end());
	x = a[n-1];
	y = bs(0, n);
	if(x == y) y = 0;
	printf("%d %d\n", x, y);
}

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

int main(){
	int n; cin>>n;
	int ans=n%1000;
	if(ans==0) cout<<0<<endl;
	else cout<<1000-ans<<endl;
}

Measured memory_bytes: 3600
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1e9;
// const ll INF = 1e15;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


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


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

  int x, a, b;
  cin >> x >> a >> b;
  char shop = (abs(x - a) < abs(x - b)) ? 'A' : 'B';
  cout << shop << endl;
  return 0;
}

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

int main()
{
	auto& in = cin;
	int N;
	in >> N;
	int counter = 0;
	for (int i = 0; i < N; ++i) {
		int d1, d2;
		in >> d1 >> d2;
		if (d1 == d2) {
			++counter;
			if (counter >= 3) {
				cout << "Yes";
				return 0;
			}
		}
		else {
			counter = 0;
		}
	}
	cout << "No";

	return 0;
}


Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int H,W,K;
string s[10];
int main(){
	cin>>H>>W>>K;
	for(int i=0;i<H;i++)cin>>s[i];
	int ans=1e9;
	for(int mask=0;mask<(1<<H-1);mask++){
		int cnt[15]={};
		int now=__builtin_popcount(mask);
		int id;
		bool out=false;
		for(int j=0;j<W;j++){
			id=0;
			bool take=false;
			for(int i=0;i<H;i++){
				cnt[id]+=s[i][j]=='1';
				if(cnt[id]>K)take=true;
				if(mask>>i&1)id++;
			}
			if(take){
				now++;
				for(int k=0;k<=id;k++)cnt[k]=0;
				id=0;
				for(int i=0;i<H;i++){
					cnt[id]+=s[i][j]=='1';
					if(cnt[id]>K)out=true;
					if(mask>>i&1)id++;
				}
			}
		}
		if(!out&&ans>now){
			ans=now;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    int64_t x,k,d;
    cin>>x>>k>>d;
    x = abs(x);
    /*
    if(k==1){
        cout<<abs(x-d)<<endl;
        return 0;
    }*/
    if(x/d>=k){//0にたどり着けない -> いけるとこまでいく(この場合はオーバーフローの心配なし)
        cout<<x-d*k<<endl;
    }
    else{//0を越せる
        int cnt = x/d;//これで0に近づくまでの回数
        x -= cnt*d;//限界まで0に近づく(0かもしれない)
        k -= cnt;
        if(k%2==0){//今のxかさらに2回(-2*d)移動したとこ
            cout<<min(x,abs(x-2*d))<<endl;
        }
        else{//今のxから右か左に1回スライド
            //cout<<min(x+d,abs(x-d))<<endl;
            cout<<abs(x-d)<<endl;
        }
        
    }
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        ll ans = 0;
        int n; cin >> n;
        vector<int> a(n); cin >> a;
        for (int i = 1; i < n; i++) {
                if (a[i] < a[i - 1]) {
                        ans += a[i - 1] - a[i];
                        a[i] = a[i - 1];
                }
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int

typedef long long ll;
typedef pair<ll,ll> p;

ll digitSum(ll n)
{
  if(n < 10) return n;
  else return n % 10 + digitSum(n / 10);
}

int main()
{
  ll n;
  cin >> n;
  ll res = digitSum(n);
  ll digitNum = int(to_string(n).size());
  if(digitNum == 1)
  {
    cout << n << endl;
    return 0;
  }
  // cout << to_string(n)[0] - '0' << endl;

  res = max(res, ((to_string(n)[0]-'0')-1) + (digitNum-1)*9);

  cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<string>
#include<queue>
#include<set>
#include<stack>
#include<map>

using namespace std;

int main(){
    int N;
    long long A[200001];
    cin>>N;
    int le[200001],ri[200001];
    for(int i=1;i<=N;i++){
        int a;
        cin>>a;
        A[a]=i;
        le[i]=-1;
        ri[i]=-1;
    }
    long long ans=0;
    for(int a=N;a>=1;a--){
        int nle=0;
        int nri=0;
        bool lflag=false;
        bool rflag=false;
        int x=A[a];
        le[x]=x;
        ri[x]=x;
        if(x > 1 && le[x-1] != -1){
            ri[le[x-1]]=x;
            le[x]=le[x-1];
            nle=x-le[x-1];
            lflag=true;
        }
        if(x < N && ri[x+1] != -1){
            le[ri[x+1]]=x;
            ri[x]=ri[x+1];
            nri=ri[x+1]-x;
            rflag=true;
        }
        if(lflag && rflag){
            ri[le[x]]=ri[x];
            le[ri[x]]=le[x];
        }
        ans += (long long) a*(nle+1)*(nri+1);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
  
         int x1,x2,x3,x4,x5;
         cin>>x1>>x2>>x3>>x4>>x5;
        if(x1==0)
          cout<<1<<endl;
       if(x2==0)
          cout<<2<<endl;
       if(x3==0)
          cout<<3<<endl;
      if(x4==0)
          cout<<4<<endl;
      if(x5==0)
          cout<<5<<endl;
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=20005,L=205,M=998244353;
int dp[L][N],fac[N],inv[N],a[N],b[N],n,m;
int C(int x,int y){
	if (x<y)return 0;
	return fac[x]*inv[y]%M*inv[x-y]%M;
}
int ksm(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=x*x%M)
		if (y&1)(ans*=x)%=M;
	return ans;
}
void init(int y[],int len){
	for (int i=1,j=len/2;i<len-1;i++){
		if (i<j)swap(y[i],y[j]);
		int k=len/2;
		while (j>=k){
			j-=k;
			k/=2;
		}
		j+=k;
	}
}
void ntt(int y[],int len,int opt){
	init(y,len);
	for (int h=2;h<=len;h<<=1){
		int wn=ksm(3,(M-1)/h);
		if (opt==-1)wn=ksm(wn,M-2);
		for (int j=0;j<len;j+=h){
			int w=1;
			for (int k=j;k<j+h/2;k++){
				int u=y[k],v=y[k+h/2]*w%M;
				y[k]=(u+v)%M;
				y[k+h/2]=(M+u-v)%M;
				w=w*wn%M;
			}
		}
	}
	if (opt==1)return;
	int temp=ksm(len,M-2);
	for (int i=0;i<len;i++)(y[i]*=temp)%=M;
}
signed main(){
	scanf("%lld%lld",&n,&m);
	fac[0]=inv[0]=1;
	for (int i=1;i<N;i++)fac[i]=fac[i-1]*i%M,inv[i]=ksm(fac[i],M-2);
	int len=1;
	while (len<2*n+100)len<<=1;
	dp[0][0]=1;
	for (int j=1;j<=m;j++){
		memset(a,0,sizeof a);
		memset(b,0,sizeof b);
		for (int i=1;i<=n;i++)b[i]=inv[i+2];
		for (int i=0;i<=n;i++)a[i]=dp[j-1][i]*inv[i]%M;
		ntt(a,len,1);ntt(b,len,1);
		for (int i=0;i<len;i++)(a[i]*=b[i])%=M;
		ntt(a,len,-1);
		for (int i=0;i<=n;i++)dp[j][i]=a[i]*fac[i+2]%M;
		for (int i=0;i<=n;i++)(dp[j][i]+=dp[j-1][i]*(i*(i+1)/2+1))%=M;
	}
	int ans=0;
	for (int i=0;i<=n;i++)(ans+=C(n,i)*dp[m][i])%=M;
	printf("%lld\n",ans);
}


Measured memory_bytes: 30592
#include<bits/stdc++.h>
using namespace std;
const int maxn=100005;

int tot=0,to[maxn << 1],nxt[maxn << 1],hed[maxn],deg[maxn];
int cnt=0;
void add(int fa,int t){
    ++ tot; to[tot] = t; nxt[tot] = hed[fa]; hed[fa] = tot;
    deg[t] ++;
}

int vis[maxn] = {0},val[maxn],dis[maxn];
int eu[maxn],ev[maxn],n;
string s;

void solve(){
    queue <int> q;
    for(int i = 1;i <= n;i ++) if(deg[i] == 1 && s[i] == 'B') q.push(i);
    while(!q.empty()){
        int x = q.front(); q.pop();
        vis[x] = 1;
        for(int i = hed[x];i;i = nxt[i]){
            int y = to[i];
            if(!vis[y]){
                deg[y] --;
                if(deg[y] == 1 && s[y] == 'B') q.push(y);
            }
        }
    }
    memset(deg,0,sizeof(deg));
    memset(hed,0,sizeof(hed)); tot = 0;
    for(int i = 1;i < n;i ++){
        if(vis[eu[i]] || vis[ev[i]]) continue;
        add(eu[i],ev[i]);
        add(ev[i],eu[i]);
    }
    for(int i = 1;i <= n;i ++){
        val[i] = 0;
        if(vis[i]) continue;
        if((s[i] == 'B' && deg[i] % 2 == 1) || (s[i] == 'W' && deg[i] % 2 == 0)){
            val[i] = 2;
            cnt ++;
        }
    }
}

int td = 0;
int d[maxn];
void dfs(int x,int fa){
    d[x] = val[x];
    for(int i = hed[x];i;i = nxt[i]){
        int y = to[i];
        if(y == fa) continue;
        dfs(y,x);
        td = max(td,d[x] + d[y]);
        d[x] = max(d[x],d[y] + val[x]);
    }
}

int main(){
    cin >> n;
    for(int i = 1;i < n;i ++){
        cin >> eu[i] >> ev[i];
        add(eu[i],ev[i]);
        add(ev[i],eu[i]);
    }
    cin >> s; s = ' ' + s;
    solve();
    int trt = 1,ans;
    for(int i = 1;i <= n;i ++) if(!vis[i]) trt = i;
    dfs(trt,0);
    ans = tot + cnt - td;
	cout<<ans;
} 

Measured memory_bytes: 9084
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c, x;
	cin >> a >> b >> c >> x;

	int ans = 0;

	for (int i = 0; i <= a; ++i)for (int j = 0; j <= b; ++j)for (int k = 0; k <= c;++k) {
		if (500 * i + 100 * j + 50 * k == x) ans++;
	}

	dunk(ans);

	return 0;
}

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

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


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

    vector<int> L(N);
    int flg;

    for(int i=0;i<N;i++){
        cin >> L.at(i);
 //       cout << L.at(i) << endl;
    }


    for(int i=0;i<N-2;i++){
        for(int j=i+1;j<N-1;j++){
            for(int k=j+1;k<N;k++){
                if( L.at(i)+L.at(j)>L.at(k) && L.at(j)+L.at(k)>L.at(i) && L.at(k)+L.at(i)>L.at(j)
                    && L.at(i)!=L.at(j) && L.at(j)!=L.at(k) && L.at(i)!=L.at(k)) flg++;
            }
        }
    }
    cout << flg << endl;

}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 100005
 
#define PI 3.14159265358979323846264338327950
 
#define F first
#define S second
 
#define ll 	 int
 
#define mod  1000000007

map<string, int> m;

int main()
{
	FAST;
	ll n;
	cin >> n;
	ll x;
	cin >> x;
	
	ll a[n+4]; ll b[n+6];
	for(ll i = 0; i < n; i++){
		cin >> a[i];
		b[i] = abs(x - a[i]);
	}
	sort(b, b + n);
	ll m = b[0];
	for(ll i = 1; i < n; i++){
		m = __gcd(m, b[i]);
	}
	cout << m;
	return 0;
}

Measured memory_bytes: 4360
#lines = <<'EOS'
#aabc
#3
#1
#2
#1
#vwxyz
#2
#3
#4
#-
#EOS

lines = $stdin.read #.split("\n")

next_is_times=true
cards=""

lines.split("\n").each do |line|

  if line == "-" then
    puts cards if cards != ""
    exit 0
  end

  if not /\A\d+\z/ === line then
    # aabc
    puts cards if cards != ""
    cards = line
    next_is_times = true
  elsif next_is_times then
    #puts line
    next_is_times = false
  else
    # number
    shuffle = line.to_i
    cards = "#{cards.slice(shuffle, cards.length + 1)}#{cards.slice(0, shuffle)}"

    # p cards.slice(shuffle, cards.length + 1)
    # p cards.slice(0, shuffle)
    #puts "#{shuffle} => #{cards}"
    #puts cards
  end
end

Measured memory_bytes: 8652
#include<stdio.h>
int main(){
  int n,x,sum,ans;
  for(;;){
    scanf("%d %d",&n,&x);
    if(n==0&&x==0) break;
    for(int i=1;i<=n;i++){
      for(int j=i+1;j<=n;j++){
        for(int k=j+1;k<=n;k++){
          sum=i+j+k;
          if(sum==x)ans++;
        }
      }
    }
    printf("%d\n",ans);
    ans=0;
  }
}


Measured memory_bytes: 2048
import java.util.*;

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

        int R = sc.nextInt();
        String ret;

        if (R < 1200) {
            ret = "ABC";
        } else if (R < 2800) {
            ret = "ARC";
        } else {
            ret = "AGC";
        }

        System.out.println(ret);
    }
}

Measured memory_bytes: 23764