akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

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

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int b_s(vector<llint>& a, llint key) {
	int left = -1;
	int right = a.size();
	while (right - left > 1) {
		int mid = left + (right - left) / 2;
		if (a[mid] > key)right = mid;
		else left = mid;
	}
	return right;
}
int main() {
	int h, w, k;
	cin >> h >> w >> k;
	whei(char) a(h, hei(char)(w));
	rep(i, 0, h)rep(j, 0, w)cin >> a[i][j];
	int ans = 0;
	rep(i, 0, (1 << h)) {
		map<int, int> z;
		rep(l, 0, h) {
			if (i & (1 << l))z[l] = 1;
		}
		rep(j, 0, (1 << w)) {
			map<int, int> y;
			rep(l, 0, w)if (j & (1 << l))y[l] = 1;
			int sum = 0;
			rep(I, 0, h) {
				rep(J, 0, w) {
					if (z[I] && y[J] && a[I][J] == '#')sum++;
				}
			}
			if (sum == k)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	A, B := getStdinInt2()
	if A-(B*2) > 0 {
		fmt.Printf("%d\n", A-(B*2))
	} else {
		fmt.Printf("%d\n", 0)
	}
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntU64() uint64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return uint64(rtn)
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func getStdinIntArrU64() []uint64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]uint64, len(list))
	for idx, val := range list {
		r, _ := strconv.ParseInt(val, 10, 64)
		rtn[idx] = uint64(r)
	}
	return rtn
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
func abs64(n int64) int64 {
	if n < 0 {
		return -n
	}
	return n
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
char S[8 * 100015];
const int START = 400000;
int sp = 400000;
int ep = 400000;
int Q, F, opt, state; // state:0 똑바로, state:1 바뀐상태
char mark;
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);


	cin >> S + START >> Q;
	for (int i = sp; S[i]; i++)
		ep = i;
	ep += 1;


	while (Q--) {

		cin >> F;
	
		if (F == 1) {
			if (state == 0) state = 1;
			else state = 0;
		}
		else {
			cin >> opt >> mark;
			if ((opt == 1 && state == 0) || (opt == 2 && state == 1)) {
				sp--;
				S[sp] = mark;
			}
			if ((opt == 2 && state == 0) || (opt == 1 && state == 1)) {
				S[ep] = mark;
				ep++;
			}
		}
	}

	if (state == 0)
		cout << S + sp << "\n";
	else {
		for (int i = ep - 1; i >= sp; i--)
			cout << S[i];
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 896
#include <iostream>

int main()
{
    int N = 0;
    std::cin >> N; // hold a number
    for (int i = 1; i < 10; ++i)
        if (N % i == 0 && N / i < 10) {
            std::cout << "Yes" << std::endl;
            return 0;
        }

    std::cout << "No" << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <numeric>
#include <bitset>
#include <complex>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#include <cassert>
using namespace std;

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)round(x))<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

int main() {
  int N, D;
  string s;
  bool changed[1002];

  while (cin >> N >> s >> D) {
    memset(changed, 0, sizeof(changed));

    // ?????????????????????0???1????????????
    for (int i = 0; D > 0 && i < N; i++) {
      if (changed[i]) continue;
      if (s[i] == '1') continue;
      s[i] = '1';
      changed[i] = true;
      D--;
    }
    
    // ?????????????????????1???0????????????
    for (int i = N - 1; D > 0 && i >= 0; i--) {
      if (changed[i]) continue;
      if (s[i] == '0') continue;
      s[i] = '0';
      changed[i] = true;
      D--;
    }

    cout << s << endl;
  }
}

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

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    int re = 0;
    int len = 0;
    int h0=0,h1=0;
    while(n--)
    {
        scanf("%d",&h1);
        if(h1>h0)
        {
            if(len>re)
                re = len;
            len = 0;
        }
        else
            len++;
            h0 = h1;
    }
    if(len>re)
        re = len;
    cout << re << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000000

void maxHeapify(int);

int A[MAX+1];
int H;

int main(){
  int i;
  scanf("%d", &H);
  for(i = 1; i <= H; i++){
    scanf("%d", &A[i]);
  }
  for(i = H / 2; i >= 1; i--){
    maxHeapify(i);
  }
  for(i = 1; i <= H; i++){
    printf(" %d", A[i]);
  }
  printf("\n");
  return 0;
}


void maxHeapify(int i){
  int l, r, largest, swap;
  l = 2 * i;
  r = 2 * i + 1;
  if(l <= H && A[l] > A[i]){
    largest = l;
  }
  else{
    largest = i;
  }
  if(r <= H && A[r] > A[largest]){
    largest = r;
  }
  if(largest != i){
    swap = A[largest];
    A[largest] = A[i];
    A[i] = swap;
    maxHeapify(largest);
  }
}



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

int main()
{
    int n, a, b, p1, p2;
    cin >> n >> a >> b;
    p1 = n * a;
    p2 = b;
    if (p1 < p2)
    {
        cout << p1 << endl;
    }
    else
    {
        cout << p2 << endl;
    }
}


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

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

  string result;

  if(b == "A"){
    result = "T";
  }
  if(b == "T"){
    result = "A";
  }
  if(b == "C"){
    result = "G";
  }
  if(b == "G"){
    result = "C";
  }
  
  cout << result << endl;
}

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

int i,j,n,from,to,mark[4][4][4][4][4][4][4][4][4][4],q[2000000][10],ss[10];
char sss[15];

void check(int k,int cc1,int cc2){
	int i,cc;
	int *mk;
	cc=6-q[from][k]-q[from][k-1];
	for(i=0;i<10;i++)q[to][i]=q[from][i];
	q[to][k]=cc1;q[to][k-1]=cc2;

	mk=&mark[q[to][0]][q[to][1]][q[to][2]][q[to][3]][q[to][4]][q[to][5]][q[to][6]][q[to][7]][q[to][8]][q[to][9]];
	cc=mark[q[from][0]][q[from][1]][q[from][2]][q[from][3]][q[from][4]][q[from][5]][q[from][6]][q[from][7]][q[from][8]][q[from][9]]+1;

	if(*mk==0){
		*mk=cc;
		to++;
	}else{
		if(*mk>cc)*mk=cc;
	}
}

int main(){
	for(i=1;i<4;i++){
		mark[i][i][0][0][0][0][0][0][0][0]=1;
		mark[i][i][i][0][0][0][0][0][0][0]=1;
		mark[i][i][i][i][0][0][0][0][0][0]=1;
		mark[i][i][i][i][i][0][0][0][0][0]=1;
		mark[i][i][i][i][i][i][0][0][0][0]=1;
		mark[i][i][i][i][i][i][i][0][0][0]=1;
		mark[i][i][i][i][i][i][i][i][0][0]=1;
		mark[i][i][i][i][i][i][i][i][i][0]=1;
		mark[i][i][i][i][i][i][i][i][i][i]=1;
	}
	for(i=0;i<27;i++){
		for(j=0;j<2+i/3;j++){
			q[i][j]=i%3+1;
		}
	}

	from=0;to=27;
	while(from<to){
		for(i=1;i<10 && q[from][i]>0;i++){
			if(q[from][i]==q[from][i-1]){
				check(i,(q[from][i])%3+1,(q[from][i]+1)%3+1);
				check(i,(q[from][i]+1)%3+1,(q[from][i])%3+1);
			}
		}
		from++;
	}

	while(scanf("%s",sss)){
		if(sss[0]=='0')break;
		for(i=0;i<10;i++){
			if(sss[i]=='r')ss[i]=1;
			else if(sss[i]=='g')ss[i]=2;
			else if(sss[i]=='b')ss[i]=3;
			else break;
		}
		for(;i<10;i++){
			ss[i]=0;
		}

		j=mark[ss[0]][ss[1]][ss[2]][ss[3]][ss[4]][ss[5]][ss[6]][ss[7]][ss[8]][ss[9]];
		if(j==0)printf("NA\n"); else printf("%d\n",j-1);
	}

	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define EPS 0.0000000001
#define pb push_back
#define space " "
#define ar array
#define pi pair<int,int>
#define ff first
#define ss second

void solve() {
    string s, t;
    cin >> s >> t;
    int n = (int) s.size();
    int m = (int) t.size();
    int ans = INT_MAX;
    for (int i = 0; i + m - 1 < n; i++) {
        int res = 0;
        int idx = 0;
        while (idx < m){
            res += (s[i + idx] != t[ idx]);idx++;}

        ans = min(ans, res);
    }
    cout << ans << endl;
}

int main() {
//    freopen("input.txt" , "r" , stdin) ;
//    freopen("output.txt" , "w" , stdout) ;
    int q = 1;
    // cin >> q;
    while (q--) {
        solve();
    }
    return 0;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int K; cin >> K;
    ll A[K]; rep(i, K) cin >> A[i];
    if(A[K-1] == 2){
        ll u, d, b1, b2;
        u = d = b1 = b2 = 2;
        for(int i = K-1; i >= 0; i--){
            u = b1+A[i]-1;
            d = b2;
            if(i == 0) break;
            if(u - (u % A[i-1]) < d){
                cout << -1 << endl;
                return 0;
            }
            b1 = u - (u % A[i-1]);
            if(d % A[i-1] > 0) b2 = d + (A[i-1] - (d % A[i-1]));
            else b2 = d;
        }
        cout << d << " " << u << endl;
    }
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<cmath>
#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;
int main() {
	int a, b;
	char op;
	while (1) {
		cin >> a >> op >> b;
		if (op == '?')break;
		if (op == '+')cout << a + b << endl;
		if (op == '-')cout << a - b << endl;
		if(op == '*')cout << a*b << endl;
		if (op == '/')cout << a / b << endl;
	}
	

	return 0;
}

Measured memory_bytes: 1164
import collections

k, t = [int(x) for x in input().split()]
a = collections.Counter(dict(enumerate([int(x) for x in input().split()])))

last = None
ans = 0
for i in range(k):
    mc = a.most_common(2)

    if len(mc) == 1 or mc[1][1] == 0 or mc[0][0] != last:
        now = mc[0][0]
    else:
        now = mc[1][0]

    ans += last == now
    a[now] -= 1
    last = now

print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;


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

	int N, M, Q;
	int L[201010], R[201010], ans[201010];
	cin >> N >> M >> Q;
	REP(i, N) {
		L[i] = i - 1;
		R[i] = i + 1;
	}
	L[0] = N - 1;
	R[N - 1] = 0;
	REP(i, N)ans[i] = 1;
	int bat = 0;
	REP(i, M) {
		int a;
		cin >> a;
		if (a % 2 == 0) {
			REP(j, a)bat = R[bat];
		}
		else {
			REP(j, a)bat = L[bat];
		}
		ans[bat] = 0;
		int l = L[bat];
		int r = R[bat];
		R[l] = r;
		L[r] = l;
		bat = r;
	}
	REP(i, Q) {
		int a;
		cin >> a;
		cout << ans[a] << endl;
	}
	
	return 0;
}




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

int N,a[100];

bool check(int k)
{
   int sum=0;
   for(int i=0;i<N;i++){
      sum+=a[i];
      if(sum<k) return false;
      sum-=k;
   }
   return true;
}


signed main()
{
   cin>>N;
   for(int i=0;i<N;i++){
      cin>>a[i];
   }

   int ok=1,ng=1000;
   while(ng-ok>1){
      int mid=(ok+ng)/2;
      if(check(mid)) ok=mid;
      else ng=mid;
   }
   cout<<ok<<endl;
}




Measured memory_bytes: 3100
#include <vector>
#include <iostream>
using namespace std;
vector<int> MAX(vector<int> v1, vector<int> v2) {
	int s1 = 0, s2 = 0;
	for(int i = 0; i < v1.size(); i++) s1 += v1[i];
	for(int i = 0; i < v2.size(); i++) s2 += v2[i];
	if(s1 > s2) return v1;
	return v2;
}
int n, x, m, l[10], r[10], s[10]; vector<int> ret, v;
void rec() {
	if(v.size() == n) {
		for(int i = 0; i < m; i++) {
			int sum = 0;
			for(int j = l[i] - 1; j < r[i]; j++) {
				sum += v[j];
				if(sum > s[i]) return;
			}
			if(sum < s[i]) return;
		}
		ret = MAX(ret, v); return;
	}
	v.push_back(-1);
	for(int i = 0; i <= x; i++) v.back()++, rec();
	v.pop_back();
}
int main() {
	scanf("%d%d%d", &n, &x, &m);
	for(int i = 0; i < m; i++) scanf("%d%d%d", &l[i], &r[i], &s[i]);
	rec();
	if(ret.size() == 0) printf("-1\n");
	else {
		for(int i = 0; i < n; i++) {
			if(i) printf(" ");
			printf("%d\n", ret[i]);
		}
	}
}

Measured memory_bytes: 3260
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
    ll n,a,b;
    cin>>n>>a>>b;
    ll count=0;
    ll p=n/(a+b);
    count+=(p*a);
    ll q=n%(a+b);
    count+=min(q,a);
    cout<<count;
    return 0;
}

Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
count = 0
for i in range(N) :
    sum = 0
    A = list(map(int, input().split()))
    for j in range(M) :
        sum += A[j] * B[j]
    if sum + C > 0 :
        count += 1
print(count)


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    ll ans = 0;
    for (int i = 1; i < N; i++) {
        if (A[i-1] > A[i]) {
            ans += A[i-1]-A[i];
            A[i] = A[i-1];
        }
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4048
#include<iostream>
#include<vector>
#include<climits>
#include<cmath>

int main(){
	int n;
	std::vector<int> hList;
	std::vector<long long> dpList;

	std::cin>>n;
	hList.resize(n);
	dpList.resize(n, LLONG_MAX);

	for(int i=0; i<n; i++)
		std::cin>>hList[i];
	
	dpList[0]= 0;

	for(int i=0; i<n-1; i++){
		dpList[i+1]= std::min(dpList[i]+std::abs(hList[i]- hList[i+1]), dpList[i+1]);

		if(i< n-2)
			dpList[i+2]= std::min(dpList[i]+std::abs(hList[i]- hList[i+2]), dpList[i+2]);
	}


	std::cout<< dpList[n-1]<<std::endl;

	return 0;
	
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl
int main(){
    int N; cin>>N;
    int d[N];
    forin(d, N); sort(d, d+N);
    cout<<d[N/2]-d[N/2-1]<<endl;
}


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

public class Main {
    
    public static boolean solve(String s){
    	Set<String> possible = new HashSet<String>();
    	possible.add("KIHBR");
    	possible.add("KIHBRA");
    	possible.add("KIHBAR");
    	possible.add("KIHBARA");
    	possible.add("KIHABR");
    	possible.add("KIHABRA");
    	possible.add("KIHABAR");
    	possible.add("KIHABARA");
    	possible.add("AKIHBR");
    	possible.add("AKIHBRA");
    	possible.add("AKIHBAR");
    	possible.add("AKIHBARA");
    	possible.add("AKIHABR");
    	possible.add("AKIHABRA");
    	possible.add("AKIHABAR");
    	possible.add("AKIHABARA");
    	
    	return possible.contains(s);
    	
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String given = sc.next();
        
        System.out.println(solve(given) ? "YES" : "NO");
        
    }
}

Measured memory_bytes: 21972
# --------- D -----------
MOD = 10**9 + 7
S = int(input())
dp = [0] * (S+1)

dp[0] = 1

for i in range(1, S+1):
    for j in range(0, (i-3)+1):
        dp[i] = dp[i] + dp[j]
        dp[i] = dp[i] % MOD
print(dp[S])

Measured memory_bytes: 9112
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

set<ll> st;
void fun(ll pos,ll last,ll cur)
{
	if(pos==0) return ;
	st.insert(cur);
	if(last>0) fun(pos-1,last-1,cur*10+last-1);
	if(last<9) fun(pos-1,last+1,cur*10+last+1);
	fun(pos-1,last,cur*10+last);
	return ;
}

int solve()
{
	ll k;cin>>k;
	rep(i,0,10) fun(11,i,0);
	vi num(st.begin(), st.end());
	cout<<num[k]<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;
int H, W;
bool field[105][105];
string S[105];
bool reach[105][105];


int main() {
    cin >> H >> W;
    for(int h = 0; h < H; h++) {
        cin >> S[h];
    }
    for(int h = 0; h < H; h++) {
        for(int w = 0; w < W; w++) {
            if((h&1) & (w & 1)) continue;
            if(h % 2 == 0 and w % 2 == 0) {
                if((h + w) % 4 == 0) {
                    if(S[h][w] == '6') field[h][w] = true;
                } else {
                    if(S[h][w] == '1') field[h][w] = true;
                }
            } else {
                if(h % 4 == 1) {
                    if(S[h][w] == '2') field[h][w] = true;
                }
                if(h % 4 == 3) {
                    if(S[h][w] == '5') field[h][w] = true;
                }
                if(w % 4 == 1) {
                    if(S[h][w] == '3') field[h][w] = true;
                }
                if(w % 4 == 3) {
                    if(S[h][w] == '4') field[h][w] = true;
                }
            }
        }
    }
    reach[0][0] = true;
    queue<i_i> que;
    que.push({0, 0});
    int dh[4] = {1, -1, 0, 0};
    int dw[4] = {0, 0, 1, -1};
    while(!que.empty()) {
        auto now = que.front();
        que.pop();
        int nowh = now.first;
        int noww = now.second;
        for(int i = 0; i < 4; i++) {
            int newh = nowh + dh[i];
            int neww = noww + dw[i];
            if(newh < 0 or newh >= H) continue;
            if(neww < 0 or neww >= W) continue;
            if(!field[newh][neww]) continue;
            if(reach[newh][neww]) continue;
            que.push({newh, neww});
            reach[newh][neww] = true;
        }
    }
    if(reach[H-1][W-1]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3220
# Edit: 2014/09/14
# Lang: Python3
# Time: .00s

if __name__ == "__main__":

    n = int(input())
    # print("n:",n)
    hl = []

    for i in range(n):
        hl.append(int(input()))
    # print(hl)

    # hl = [5, 5]
    # hl = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
    # hl = [1,2,3,4,5]
    # hl = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

    i = 0
    d = 0
    ans = 1

    hl = sorted(hl, reverse=True)

    for i, h in enumerate(hl):  # return index, value
        #d = i // 4
        a = h - d
        if a < 0:
            a = 0
        ans += a
        if i % 4 == 3:
            d += 1
    print(ans)
    #print(type(ans))

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

int main()
{
    int h, w;
    while (true)
    {
        cin >> h >> w;
        if (h == 0 && w == 0)
        {
            break;
        }
        for (int i = 0; i != h; ++i)
        {
            for (int j = 0; j != w; ++j)
            {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3088
const double = Float64
const int = Int64
const vint = Vector{int}
const vdouble = Vector{double}

int(x) = parse(int,x)

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  a = readline()

  if a[1]=='7' || a[2]=='7' || a[3]=='7'
    println("Yes")
  else
    println("No")
  end
end

main()

Measured memory_bytes: 201552
#include <bits/stdc++.h>
#define int long long
using namespace std;
int dp[3001][3001];
int pr[3003];
int fun(int l, int r){
	if(l==r)
		return dp[l][r] = pr[r]-pr[l-1];
	if(dp[l][r]!=0)
		return dp[l][r];
	
	return dp[l][r] = max( pr[r] - pr[l-1] - fun(l+1,r) , pr[r] - pr[l-1] - fun(l,r-1));
}
main(){
	int n;
	
	cin>>n;
	
	for(int i=1;i<=n;i++){
		cin>>pr[i];
		pr[i]+=pr[i-1];
	}
	
	cout<<2*fun(1,n) - pr[n]<<endl;

}

Measured memory_bytes: 70144
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int inf = 1e9+7;
const int N = 1e6+9;

void solve() {
    int a, b, n;
    string s;
    cin>>s;
    if(isupper(s[0])) cout<<"A";
    else cout<<"a";
}
int main() {
    ios_base::sync_with_stdio(0);
    int T=1 ,cas=0;
    while(T--) {
        solve();
    }
    return 0;
}

// ll, reset, 1, bottom

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main{
    public static void main(String[] args) throws java.io.IOException{
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        String result = "No";
        // X  の条件について
        if ((0<=x-r)&(W>=x+r)) {
            // Yの条件について
            if ((y-r>=0)&(y+r<=H)){
                result = "Yes";
            }
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 17356
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	string s, t; cin >> s >> t;
	int a, b; cin >> a >> b;
	string u; cin >> u;
	if (s == u)--a;
	if (t == u)--b;
	cout << a << " " << b << endl;
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        doit(args, new Scanner(System.in), System.out);
    }

    static void doit(String[] args, Scanner scanner, PrintStream out) {
        int n = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            double x1 = scanner.nextDouble();
            double y1 = scanner.nextDouble();
            double x2 = scanner.nextDouble();
            double y2 = scanner.nextDouble();
            double x3 = scanner.nextDouble();
            double y3 = scanner.nextDouble();
            
            double a2 = x2 - x1;
            double b2 = y2 - y1;
            double a3 = x3 - x1; 
            double b3 = y3 - y1;
            double det = a2 * b3 - a3 * b2;
            double c2 = a2 * a2 + b2 * b2;
            double c3 = a3 * a3 + b3 * b3;
            double ap = 0.5 * (b3 * c2 - b2 * c3) / det;
            double bp = 0.5 * (a2 * c3 - a3 * c2) / det;

            double xp = ap + x1;
            double yp = bp + y1;
            double r = Math.sqrt(ap * ap + bp * bp);
            out.println(String.format("%.3f %.3f %.3f", xp, yp, r));
        }
    }
}

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

using namespace std;

typedef long long ll;
const int Nmax = 303;

int ans, i, j, k, K, N, dp[Nmax][Nmax][Nmax];
char a[Nmax];

int main()
{
  //  freopen("input", "r", stdin);
  //  freopen("output", "w", stdout);
    cin.sync_with_stdio(false);

    cin >> (a+1) >> K;
    N = strlen(a+1);

    for(i=N; i; --i)
        for(j=i; j<=N; ++j)
            for(k=0; k<=K; ++k)
            {
                if(i == j) dp[i][j][k] = 1;
                    else if(a[i] == a[j]) dp[i][j][k] = 2 + dp[i+1][j-1][k];
                        else
                        {
                            dp[i][j][k] = max(dp[i+1][j][k], dp[i][j-1][k]);
                            if(k) dp[i][j][k] = max(dp[i][j][k], dp[i+1][j-1][k-1] + 2);
                        }
            }

    for(i=0; i<=K; ++i) ans = max(ans, dp[1][N][i]);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 108416
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int d = scanner.nextInt();

		if(a*b > c*d){
			System.out.println(a*b);
		}else{
			System.out.println(c*d);
		}
	}
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
template<typename T> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}


int main(void){
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    rep(i,N)cin >> a[i];
    sort(a.begin(), a.end());
    ll sum = 0;
    rep(i, K)sum += a[i];
    cout << sum << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <math.h>
#include <iomanip>

const long double PI = (acos(-1));

using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);


    double side, height, volume;

    cin >> side >> height >> volume;

    double answer;
    if(side * side * height / 2.0 <= volume)
    {
        answer = atan(2 * (side *side* height - volume) / (side * side * side));
    }
    else
    {
        answer = PI / 2 - atan(2 * volume / (side * height * height));
    }

    // convert to degress


    cout << setprecision(10) << answer * 180.0 / PI;

}


Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int a,b,s,ss;
	while(1)	{
		scanf("%d",&a);
		if(a==-1)	break;
		if(a<=10){
			s=1150;
		}
		else if(a<=20){
			s=1150+125*(a-10);
		}
		else if(a<=30){
			s=1150+1250+140*(a-20);
		}
		else {
			s=1150+1250+1400+160*(a-30);
		}
		ss=4280-s;
		printf("%d\n",ss);
	}
	return 0;
}

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

#define ll long long 
#define ull unsigned long long
#define all(c) c.begin(),c.end()
#define pb push_back

using namespace std;

int n;

int main(){

	cin >> n;
	vector<int>arr(n),dp(n,0);
	for(int i = 0 ; i < n ; ++i ){
		cin >> arr[i];
	}
	dp[0]=0;
	dp[1] = abs(arr[1]-arr[0]);
	for(int i = 0 ; i < n-2 ; ++i ){
		dp[i+2] = min(dp[i]+abs(arr[i+2]-arr[i]),dp[i+1]+abs(arr[i+2]-arr[i+1])); 
	}
	cout << dp.back() << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 100010
using namespace std;
ll a,b,m,pa[N],pb[N],ans;
vector<ll> va,vb;
int main(){
	ll i,x,y,z;
	cin>>a>>b>>m;
	for(i=0;i<a;i++)
	{
		cin>>pa[i];
		va.push_back(pa[i]);
	}
	for(i=0;i<b;i++)
	{
		cin>>pb[i];
		vb.push_back(pb[i]);
	}
	sort(va.begin(),va.end());
	sort(vb.begin(),vb.end());
	ans=va[0]+vb[0];
	for(i=0;i<m;i++)
	{
		cin>>x>>y>>z;
		x--;
		y--;
		ans=min(ans,pa[x]+pb[y]-z);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3828
//keep trying :)
#include <bits/stdc++.h>
#define float long double
#define int long long
#define ll long long
#define PB push_back
#define MP make_pair
#define ss second
#define ff first
#define PI 3.14159265
#define inf 9*(1e18)
#define fastrack ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
void PT(int a);
void PT1(int a);
const int M = 5*(1e5) + 7, mod = 1e9 + 7;

signed main(){
    fastrack;
    //int tt; cin >> tt; while(tt--)
    {
        int n, m, k;
        cin >> n >> m >> k;
        vector <int> a(n + 1), b(m + 1);
        for(int i = 1; i <= n; i++)
            cin >> a[i];
        for(int i = 1; i <= m; i++)
            cin >> b[i];
        for(int i = 1; i <= n; i++)
            a[i] = a[i] + a[i - 1];

        for(int i = 1; i <= m; i++)
            b[i] = b[i] + b[i - 1];
        b.PB(inf);
        int ans = 0;
        for(int i = 0; i <= n; i++){
            if(a[i] > k)
                break;
            int temp = k - a[i];
            //cout << temp << "\n";
            int idx = lower_bound(b.begin(), b.end(), temp) - b.begin();
            //cout << idx << " " << b[idx] << "\n";
            if(b[idx] > temp)
                idx--;
            //cout << idx << "\n";
            ans = max(ans, idx + i);
        }
        cout << ans << "\n";
    }
    return 0;
}

void PT(int a){
    cout << a << "\n";
}

void PT1(int a){
    cout << a << " ";
}


Measured memory_bytes: 7948
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll l, r; cin >> l >> r;
  ll c = 2019;
  if(((l+c-1)/c)*c <= r){
    cout << 0 << endl;
    return 0;
  }
  ll ans = c;
  l %= c; r %= c;
  FOR(i, l, r) FOR(j, i+1, r+1){
    ll tmp = i*j % c;
    ans = min(tmp, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
li = [0 for i in range(N)]

for i in range(N):
    li[A[i]-1] += 1

ans = 0
for i in range(N):
    ans += li[i] * (li[i]-1) // 2
for i in A:
    i2 = i-1
    print(ans - li[i2] * (li[i2]-1) // 2 + (li[i2]-1) * (li[i2]-2) // 2)

Measured memory_bytes: 87788
#include<cstdio>
#include<vector>
using namespace std;
typedef long long ll;
const int maxn=100000;
int n,m,a[maxn+10],cnt; ll tot,ans,maxv;
vector<int> ins[maxn+10],del[maxn+10];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	for(int i=1;i<n;++i){
		if(a[i]<=a[i+1]){
			if(a[i+1]==m) ++cnt,tot+=m-a[i]-1;
			ans+=a[i+1]-a[i];
		}else{
			if(a[i]!=m) ++cnt,tot+=m-a[i]-1;
			ans+=a[i+1]+m-a[i];
		}
		ins[a[i]==m?1:a[i]+1].push_back(i);
		del[a[i+1]==m?1:a[i+1]+1].push_back(i);
	}
	for(int i=1;i<=m;++i){
		for(int j=0;j<del[i].size();++j){
			int e=del[i][j];
			tot-=a[e]<=a[e+1]?a[e+1]-a[e]-1:m-a[e]+a[e+1]-1;
			--cnt;
		}
		tot+=cnt;
		for(int j=0;j<ins[i].size();++j) ++cnt;
		maxv=max(maxv,tot);
	}
	printf("%lld",ans-maxv);
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define tam 410000
#define offset 8010
using namespace std;
typedef long long  ll;
typedef pair<int,int> ii;
typedef pair<ll,ii> iii;
typedef pair<map<ll,ll> ,ll> mi;
typedef pair<ii,ii> iiii;
typedef vector<ll> vi;
const ll MOD=1e9+7;
vector<int> grafo[tam];
int sum[tam],ans[tam];
void dfs(int num,int pa,int tot)
{
    tot+=sum[num];
    ans[num]=tot;
    for(int v:grafo[num])
    {
        if (v==pa)continue;
        dfs(v,num,tot);
    }
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n,m;
    cin>>n>>m;
    int iz,der;
    forr(i,0,n-1)
    {
        cin>>iz>>der;
        grafo[iz].pb(der);
        grafo[der].pb(iz);
    }
    int valor;
    forr(i,0,m)
    {
        cin>>iz>>valor;
        sum[iz]+=valor;
    }
    dfs(1,1,0);
    forr(i,1,n+1)
    cout<<ans[i]<<' ';
}


Measured memory_bytes: 29824
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=100005;
int n;
int a[N];
int cnt[3],tot=0;
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+n+1);
	for(int i=n;i>=1;i--){
		if(a[i]==a[i-1]){
			cnt[++tot]=a[i];
			i--;
			if(tot==2) break;
		}
	} 
	printf("%lld\n",cnt[1]*cnt[2]);
	exit(0);
}

Measured memory_bytes: 1024
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
b = na()

ans = 0
for i in range(n):
    q = 999999999
    if i > 0:
        q = min(q, b[i-1])
    if i < n-1:
        q = min(q, b[i])
    ans += q
print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;
import java.lang.Math;

// ALDS1_1_C
public class Main {
	boolean primeJudge(int a) {
		double sqrt = Math.sqrt(a) + 1;
		if (a < 2) return false;
		if (a == 2) return true;
		if (a % 2 == 0) return false;
		for (int i = 3; i < sqrt; i+=2) {
			if (a % i == 0) return false;
		}
		return true;
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		for (int i = 0; i < n; i++) {
			if (primeJudge(sc.nextInt())) count++;
		}
		System.out.println(count);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 41776
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	const ll mx = 7568791;
	while (1) {
		ll m, n; scanf("%lld %lld", &m, &n);
		if (m == 0 && n == 0) break;
		vector<bool> flag(mx, false);
		ll now = m;
		for (ll i = 0; i < n; i++) {
			while (now < mx && flag[now]) {
				now++;
			}
			for (ll j = 1; j * now < mx; j++) {
				flag[now * j] = true;
			}
		}
		while (now < mx && flag[now]) {
			now++;
		}
		printf("%lld\n", now);
	}
	return 0;
}


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

int main(){
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);
	cout << a[0] + a[1] + a[2]*10 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<sstream>
#include<cmath>
#include<cstring>
#include <algorithm>
 using namespace std;
 struct fan
{
	int a;
	int b;
};
bool compare(fan zuo, fan you)
{
	return zuo.b<=you.b;
}

int main()
{
	fan range[100001];
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x, l;
		scanf("%d %d",&x,&l);
		range[i].a=x-l;
		range[i].b=x+l;
	}
	sort(range+1, range+n+1, compare);
	int count=1;
	int tem=range[1].b;
	for(int i=2;i<=n;i++)
	{
		if(range[i].a>=tem)
		{
			count++;
			tem=range[i].b;
		}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}
long long gcd(long long a,long long b){
  if(b==0){
    return a;
  }
  return gcd(b,a%b);
}
long long lcm(long long a,long long b){
  long long g=gcd(a,b);
  return a/g*b;
}








int main(){
  long long N;
  cin>>N;
  long long T[N];
  long long ans=1LL;
  for(int i=0;i<N;i++){
    cin>>T[i];
    ans=lcm(ans,T[i]);
  }
  
    
  cout<<ans<<endl;


}



  
  

Measured memory_bytes: 256
object Main {
  val offset: Int = 'a' - 'A'

  def main(args: Array[String]): Unit = {
    val toggled = io.StdIn.readLine().map { c =>
      if ('A' <= c && c <= 'Z') {
        (c + offset).toChar
      } else if ('a' <= c && c <= 'z') {
        (c - offset).toChar
      } else
        c
    }
    println(toggled)
  }
}

Measured memory_bytes: 43684
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
using namespace std;

int main(){
    int N,M,K[40],A[40][40],ans=0;
    map<int,int> mp;
    cin>>N>>M;
    for(int n=1;n<=N;++n){
        cin>>K[n];
        for(int k=1;k<=K[n];++k){
            cin>>A[n][k];
            mp[A[n][k]]+=1;
        }
    }
    for(int m=1;m<=M;++m){
        if(mp[m]==N)++ans;
    }
    
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  REP1(i, 9) REP1(j, 9) cout << i << "x" << j << "=" << i * j << endl;
  return 0;
}


Measured memory_bytes: 3088
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int x = fs.nextInt();
		int a = fs.nextInt();
		int b = fs.nextInt();
		
		if(b <= a) {
			System.out.println("delicious");
		}else if(b <= a+x) {
			System.out.println("safe");
		}else {
			System.out.println("dangerous");
		}
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 21204
# もし周上にあれば必ず面積は元の半分位にできる。
# その時の分割方法は、対角頂点の同じだけの距離の場所なので、１通り
# 長方形内にある時、長方形の中心点を通ることができるならば、かならず半分にできる。
# また、中心点を通らないと半分にはできない。
# つまり、中心点h/2,w/2にx,yがある時のみ1、それ以外は0
def main():
  h,w,x,y =map(int,input().split())
  if h/2 == x and w/2 == y:
    print(h*w/2,1)
  else:
    print(h*w/2,0)
main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
int pa[maxn],sz[maxn],val[maxn];
struct edge{
    int u,v,w;
    bool operator <(const edge &x)const {
        return w>x.w;
    }
    void read(){
        scanf("%d%d%d",&u,&v,&w);
    }
}e[maxn];
int fi(int x){
    return pa[x]==x?x:pa[x]=fi(pa[x]);
}
bool Merge(int x,int y){
    x=fi(x);
    y=fi(y);
    if(x==y){
        if(val[x]<sz[x]){
            val[x]++;
            return true;
        }
        return false;
    }
    else{
        if(val[x]+val[y]+1>sz[x]+sz[y])return false;
        if(sz[x]<sz[y])swap(x,y);
        sz[x]+=sz[y];
        val[x]+=(val[y]+1);
        pa[y]=x;
    }
    return true;
}

/*
Note:
    At first, Turning grid into bipartite graph
    Notice that we must assign each number from both sides to each row and column
    Claim 1: There are no triple multiple loops
    Claim 2: If the number of node is not greater than the number of edges we can assign such thing
*/
int n,r,c;

int main(){
    scanf("%d%d%d",&n,&r,&c);
    for(int i=1;i<=n;i++){
        e[i].read();
        e[i].v+=r;
        pa[e[i].u]=e[i].u;
        pa[e[i].v]=e[i].v;
        sz[e[i].u]=1;
        sz[e[i].v]=1;
    }
    sort(e+1,e+1+n);
    //for(int i=1;i<=n;i++)
       // e[i].print();
    long long ans=0;
    for(int i=1;i<=n;i++){
        if(Merge(e[i].u,e[i].v)){
            ans+=e[i].w;
        }
    }
    printf("%lld\n",ans);
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 6016
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
  int A, B; cin >> A >> B;

  int ans = 0;
  if (6 <= A && A <= 12) {
    ans = B/2;
  } else if (13 <= A) {
    ans = B;
  }

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


Measured memory_bytes: 256