akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int n, d, s;

int main(){
    cin >> n;

    vector<int> a;
    vector<int> b;
    vector<int> c;

    for(int i = 0; i < n; i++){
        cin >> d;
        a.push_back(d);
    }
    for(int i = 0; i < n; i++){
        cin >> d;
        b.push_back(d);
        s = s + b[i];
    }
    for(int i = 0; i < n-1; i++){
        cin >> d;
        c.push_back(d);
    }

    for(int i = 0; i < n-1; i++){
        if(a[i] + 1 == a[i+1]){
            s = s + c[a[i] - 1];
        }
    }

    cout << s;

    // cout << endl;

    // for(int i = 0; i < n; i++){
    //     cout << a[i] << " ";
    // }

    // cout << endl;
    // for(int i = 0; i < n; i++){
    //     cout << b[i] << " ";
    // }

    // cout << endl;
    // for(int i = 0; i < n-1; i++){
    //     cout << c[i] << " ";
    // }




}


//g++ -std=c++14 comp.cpp; ./a.exe


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (int)(n); i++)
 
int main() {
    ll k;
    string s;
    cin>>k>>s;
    if (s.size()>k){
        s=s.substr(0,k)+"...";
    }
    cout<<s<<endl;
}

Measured memory_bytes: 3632
/*****************************************************///
/*.......................Faiyaj Bin Amin............................*///
/*...................................................................*///
/*.........................KUET CSE 2K17......................*///
/*...................................................*///
/*****************************************************///


#include<bits/stdc++.h>

#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define sf(n) scanf("%d", &n);
#define sff(n, m) scanf("%d %d", &n, &m);
#define pf(n) printf("%d", n);
#define ret return
#define rep(q, i, n) for(int q=i; q<n; q++)  /// type rep(t, 1, n+1) when t is to be iterated from 1 to n
#define rrep(q, i, n) for(int q=i; q>n; q--)
#define mems(a,x) memset(a,x,sizeof(a))
#define io ios_base::sync_with_stdio;cin.tie(0);cout.tie(0)
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define ff first
#define ss second
#define pii pair<int,int>
#define pdd pair<double, double>
#define pll pair<ll,ll>

#define watch(x) cout << (#x) << " is " << (x) << endl

#define gcd(a, b)  __gcd(a, b)
#define lcm(a, b)  ((a / __gcd(a, b) ) * b)

#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)

#define PI 2*acos(0.0)

#define mx 100005
#define MAX 1000000005
#define inf 1e9
#define INF 1e18
#define MOD 1000000007
////#define MOD 4294967296another
#define MIN 0

////
////------------------------------Graph Moves----------------------------
////const int fx[]={+1,-1,+0,+0}; // Directional
////const int fy[]={+0,+0,+1,-1};
////const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
////const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
////const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
////const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
////---------------------------------------------------------------------
////
////*------------------------------------BITMASK------------------------------------------*
////int Change(int N, int pos){return N= N^(1<<pos);}
////bool Check(int N, int pos){return (bool)(N &(1<<pos));}
////*-----------------------------------------------------------------------------------------------*

using namespace std;


ll l[2003][2003] = {0};


void buildPascal(int k)
{
    l[0][0] = 1;
    for (int i = 1; i <=k; i++)
    {
        l[i][0] = 1;
        for (int j = 1; j <=i; j++)
        {
            l[i][j] = (l[i - 1][j - 1]%MOD + l[i - 1][j]%MOD)%MOD;
        }
    }
}


int main()
{
    int k, n;
    scanf("%d %d", &n, &k);
    buildPascal(2001);

////    rep(i, 0, k+1)
////    {
////        rep(j, 0, k+1)
////        {
////            cout << l[i][j] << " ";
////        }
////        cout << endl;
////    }

    ll a, b, red;
    rep(i, 1, k+1)
    {
        red = n-k;
        a = l[red+1][i];
        b = l[k-1][i-1];
        printf("%lld\n", (a*b)%MOD);
    }

    return 0;
}


Measured memory_bytes: 30080
#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 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(){
    string s;
    cin>>s;
    int n=s.length();
    stack<char> st;
    rep(i,n){
        if(st.empty()){
            st.push(s[i]);
        }
        else{
            if(st.top()=='S'&&s[i]=='T'){//先頭がSでTを入れるとき、削除 
                st.pop();//先頭を削除
            }
            else{
                st.push(s[i]);
            }
        }
    }
    cout<<st.size()<<endl;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, int> PL;
struct UnionFind{
  vector<int> data;
  int __size;
  UnionFind(int sz) {
  data.assign(sz, -1);
  __size = sz;
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);//親は負でサイズを保存
    __size--;
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  bool same(int x, int y){
    return find(x) == find(y);
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }

  int union_count() {
    return (__size);
  }
};
int main() {
  int n, k, l;
  cin >> n >> k >> l;
  UnionFind uf1(n), uf2(n);
  rep(i,k) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    uf1.unite(a, b);
  }
  rep(i,l) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    uf2.unite(a, b);
  }
  map<P, int> mp;
  for (int i = 0; i < n; i++) {
    mp[make_pair(uf1.find(i), uf2.find(i))]++;
  }
  for (int i = 0; i < n; i++) cout << mp[make_pair(uf1.find(i), uf2.find(i))] << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 16044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 100005
const ll MOD = 1000000007;

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

	ll n;
	cin>>n;
	ll a[n];
	map<int,int> f;
	ll sum = 0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		++f[a[i]];
		sum += a[i];
	}

	ll q;
	cin>>q;
	while(q--){
		ll b,c;
		cin>>b>>c;
		if(f.count(b)){
			sum += f[b]*(c-b);
			f[c] += f[b];
			f[b] = 0;
		}

		cout<<sum<<endl;
	}
}

Measured memory_bytes: 8068
n,k,i=int(input()),1,2
v=n+1
p=print
if-n&n==n:p("No");exit()
p("Yes",v,3)
while i<n:p(1,i,i,i+1,1,v+i,v+i,n+i);i+=2;k<<=k*2<v
if~n&1:p(n,v+k,n+n,n^k)

Measured memory_bytes: 9276
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int i = 0;
        int ans = 0;
        while(true) {
            int money = i * 1000;
            if(money >= n){
                ans = money - n;
                break;
            }
            i++;
        }
		System.out.println(ans);
	}
}

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

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


Measured memory_bytes: 256
def main(N, Q, S, lr_list):
    chars = list(S)

    s_list = [0]
    for i in range(N):
        if i+1 < N and chars[i] == 'A' and chars[i+1] == 'C':
            s_list.append(s_list[i] + 1)
        else:
            s_list.append(s_list[i])

    res_list = []
    for lr in lr_list:
        l, r = lr
        l -= 1
        r -= 1
        res_list.append(s_list[r] - s_list[l])

    return res_list


if __name__ == "__main__":
    N, Q = list(map(int, input().split()))
    S = input()
    lr_list = []
    for _ in range(Q):
        lr_list.append(tuple(map(int, input().split())))
    res = main(N, Q, S, lr_list)
    for r in res:
        print(r)


Measured memory_bytes: 73048
import java.util.Scanner;

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

		int sumAll = 0;
		for (int i = 0; i < N; i++) {
			W[i] = sc.nextInt();
			sumAll += W[i];
		}

		int answer = 0;
		int id = 0;
		for (int i = 0; i < N; i++) {
			answer += W[i];
			id = i;
			if (answer > sumAll / 2.0)
				break;
		}
		if (Math.abs(sumAll - 2 * answer) > Math.abs(sumAll - 2 * (answer - W[id])))
			System.out.println(Math.abs(sumAll - 2 * (answer - W[id])));
		else
			System.out.println(Math.abs(sumAll - 2 * answer));
		sc.close();
	}
}


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

int main(void)
{
    int K, X; cin >> K >> X;

    const int Dhazi = (K-1)*(-1);

    int i = 0;
    while(1)
    {
        int result = X+(Dhazi + i);
        if(-1000000 <= result && result <= 1000000) cout << result;
        i++;
        if(i > Dhazi*(-2)) break;
        cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    string s;
    cin >> s;
    int cnt1 = 0, cnt2 = 0; //1010... , 0101...
    rep(i, s.size())
    {
        if (i % 2 == 0)
        {
            if (s[i] == '0')
                cnt1++;
            else
                cnt2++;
        }
        if (i % 2 == 1)
        {
            if (s[i] == '1')
                cnt1++;
            else
                cnt2++;
        }
    }
    cout << min(cnt1, cnt2) << endl;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

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



int main(){
    int a, b; cin >> a >> b;
    int ans=max(a+b, max(a-b, a*b));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3524
import java.util.*;

public class Main {

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

        int n = sc.nextInt();
        int[] array = new int[n];

        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }

        int[] dp = new int[n];

        for (int i = 0; i < n; i++) {
            dp[i] = Integer.MAX_VALUE;
        }

        dp[0] = 0;

        for (int i = 1; i < n; ++i) {
            dp[i] = Math.min(dp[i], dp[i - 1] + Math.abs(array[i] - array[i - 1]));
            if (i > 1) dp[i] = Math.min(dp[i], dp[i - 2] + Math.abs(array[i] - array[i - 2]));
        }

        System.out.println(dp[n - 1]);

    }
}

Measured memory_bytes: 52980
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N, W;
  cin >> N >> W;
  vector<pair<int, int>> items(N);
  rep(i, N)
  {
    cin >> items[i].first >> items[i].second;
  }
  ll w0 = items[0].first;
  vector<vector<vector<ll>>> dp(N + 1, vector<vector<ll>>(N + 1, vector<ll>(3 * N + 1, -1)));
  dp[0][0][0] = 0;

  rep(i, N) rep(cnt_i, N) rep(num_i, N * 3 + 1)
  {
    if (dp[i][cnt_i][num_i] != -1)
    {
      ll w = items[i].first;
      ll v = items[i].second;
      dp[i + 1][cnt_i][num_i] = max(dp[i + 1][cnt_i][num_i], dp[i][cnt_i][num_i]);
      dp[i + 1][cnt_i + 1][num_i + w - w0] = max(dp[i + 1][cnt_i + 1][num_i + w - w0], dp[i][cnt_i][num_i] + v);
    }
  }

  ll ans = 0;
  rep(cnt_i, N + 1) rep(num_i, N * 3 + 1)
  {
    if (w0 * cnt_i + num_i <= W)
      ans = max(ans, dp[N][cnt_i][num_i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 24832
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_VTX_MAX		100000									// 最大頂点数

// 内部変数
static FILE *szpFpI;											// 入力
static int si1QCnt[D_VTX_MAX];									// クエリ数[頂点]
static int siVCnt;												// 頂点数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 頂点数・クエリ数 - 取得
	int liQCnt;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &siVCnt, &liQCnt);

	// クエリ - 取得
	for (i = 0; i < liQCnt; i++) {
		int liNo1, liNo2;
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
		sscanf(lc1Buf, "%d%d", &liNo1, &liNo2);

		// クエリ数[頂点]
		si1QCnt[liNo1 - 1]++;
		si1QCnt[liNo2 - 1]++;
	}

	// クエリ数
	int liCnt = 0;
	for (i = 0; i < siVCnt; i++) {
		if (si1QCnt[i] % 2) {
			return -1;
		}
	}

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// データ - 初期化
	memset(si1QCnt, 0, sizeof(si1QCnt));						// クエリ数[頂点]

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// １行出力
	if (liRet == 0) {
		sprintf(lc1Buf, "YES\n");
	}
	else {
		sprintf(lc1Buf, "NO\n");
	}
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

using namespace std;

#define forn for (ll i = 0; i < n; i++)
#define form for (ll j = 0; j < m; j++)
#define NO cout << "NO\n";
#define YES cout << "YES\n";
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (ll i = a; i < b; i++)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

ll gcd(ll a, ll b){
    ll r;
    while (b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}


ll *calc_z(string s){
    ll n = s.size();
    ll *z = new ll[n] {0};
    ll l = 0, r = 0;
    for (ll i = 1; i < n; i++){
        if (r >= i) z[i] = min(z[i-l], r-i+1);
        while (z[i]+i < n && s[z[i]] == s[z[i]+i]) z[i]++;
        if (i + z[i] - 1 > r){
            l = i;
            r = i+z[i]-1;
        }
    }
    return z;
}

ll find_lower(ll *a, ll n, ll v){
    ll l = -1, r = n;

    while (r>l+1){
        ll m = (l+r)/2;

        if (a[m] >= v) r = m;
        else l = m;
    }
    if (r == n) return n-1;
    if (a[r] == v) return r;
    return r == 0 ? 0 : r-1;
}

string *dogs;

void init(){
}

void solve(){
    int n;
    int x = 0;
    cin >> n;
    int *a = new int[n];
    forn{
        cin >> a[i];
        x = x ^ a[i];
    }
    forn{
        cout << (x ^ a[i]) << ' ';
    }
    cout << "\n";
}

int main(){
    //init();

    ios::sync_with_stdio(0);
    cin.tie(0);

    //ll t; cin >> t; while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 4388
# include <stdio.h>

int main(){
  int n;
  int num = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++){
    int l, r;
    scanf("%d %d",&l, &r);
    num += r - l + 1;
  }
  printf("%d\n",num);
  return 0;
}


Measured memory_bytes: 128
A,B=map(int,input().split())
S=input()
L=list(S)
l=L.count('-')
if l==1:
  SS,T=S.split('-')
  if len(str(SS))==A and len(str(T))==B:
    print('Yes')
  else:
    print('No')
    
else:
  print('No')

Measured memory_bytes: 3060
#define MOD 998244353
#include <bits/stdc++.h>
#include <numeric>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
long long int power(long long int a,long long int b,long long int mod=MOD){
	long long int ans=1;
	for(long long int i=0;(1LL<<i)<=b;++i){
		ans*=(b&(1LL<<i)?a:1LL);
		ans%=mod;
		a*=a;
		a%=mod;
	}
	return ans;
}
class SegmentTree{
	vector<long long int> tree,prefix,upd;
	long long int _build(vector<long long int> &arr,long long int l,long long int r,long long int ind){
		if(l==r){
			return tree[ind]=arr[l];
		}
		else{
			return tree[ind]=((power(10,r-(l+r)/2)*_build(arr,l,(l+r)/2,2*ind+1))%MOD+_build(arr,(l+r)/2+1,r,2*ind+2))%MOD;
		}
	}
	long long int _update(int l,int r,int val,int bl,int br,int ind){
		if(r<bl||br<l){
			if(upd[ind]!=-1){
				if(bl!=br)
					upd[2*ind+1]=upd[2*ind+2]=upd[ind];
				tree[ind]=(prefix[br-bl+1]*upd[ind])%MOD;
				upd[ind]=-1;
			}
			return tree[ind];
		}
		else if(l<=bl&&br<=r){
			if(bl!=br)
				upd[2*ind+1]=upd[2*ind+2]=val;
			upd[ind]=-1;
			return tree[ind]=(prefix[br-bl+1]*val)%MOD;
		}
		else{
			if(upd[ind]!=-1){
				if(bl!=br)
					upd[2*ind+1]=upd[2*ind+2]=upd[ind];
				upd[ind]=-1;
			}
			return tree[ind]=((power(10,br-(bl+br)/2)*_update(l,r,val,bl,(bl+br)/2,2*ind+1))%MOD+_update(l,r,val,(bl+br)/2+1,br,2*ind+2))%MOD;
		}
	}
	public:
	SegmentTree(vector<long long int> arr){
		tree.resize(4*arr.size());
		upd.resize(4*arr.size(),-1);
		prefix.resize(arr.size()+1,0);
		for(int i=1; i<=arr.size(); ++i){
			prefix[i]=(prefix[i-1]*10+1)%MOD;
		}
		_build(arr,0,arr.size()-1,0);
	}
	long long int Update(int l,int r,long long int val){
		return _update(l,r,val,0,tree.size()/4-1,0);
	}
};

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

	int n,q;
	cin>>n>>q;
	SegmentTree t(vector<long long int>(n,1));
	while(q--){
		int l,r,d;
		cin>>l>>r>>d;
		cout<<t.Update(l-1,r-1,d)<<'\n';
	}
}


Measured memory_bytes: 18772
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(),(c).end())
const long long MOD = 10e9 + 7;
typedef long long ll;

int main(){
	int M, D;
	cin >> M >> D;
	int cnt = 0;
	if(D > 21){
		for(int i = 21; i <= D; i++){
			int a = i % 10;
			int b = (i - a) / 10;
			int day = a * b;
			if(a < 2 || b < 2)continue;
			else if(0 < day && day <= M)cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 384
#include <iostream>
#define int long long
using namespace std;

int n;
int a[13];
int b[13];

signed main() {
	int i;
	cin >> n;
	
	a[0] = 1;
	b[0] = 0;
	for (i = 1; i <= 12; i++) {
		a[i] = a[i - 1] * 26;
		b[i] = b[i - 1] + a[i];
	}
	
	for (i = 1; n > b[i]; i++);
	
	int len = i;
	int m = n - b[len - 1] - 1;
	
	//m¤ò26ßMÊý¤Ç
	string ans;
	for (i = 0; i < len; i++) {
		ans += (char)('a' + m % 26);
		m /= 26;
	}
	
	for (i = ans.length() - 1; i >= 0; i--) cout << ans[i];
	cout << endl;
	return 0;
}


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

int main(){
    int a,b;
    cin>>a>>b;
    int n;
    if(b/100!=0){
        n=a*1000+b;
    }else if(b/10!=0){
        n=a*100+b;
    }else{
        n=a*10+b;
    }
    for(int i=0;i*i<=n;i++){
        if(i*i==n){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

type restaurant struct {
	num   int
	name  string
	score int
}

// TODO #17 # 新ジャッジサーバになったら提出する

type SortByName [][]restaurant

func main() {
	N := nextInt()
	restaurants := make([]restaurant, N)
	for i := 0; i < N; i++ {
		restaurants[i].num = i
		restaurants[i].name = nextLine()
		restaurants[i].score = nextInt()
	}
	// 旧ジャッジサーバでは使えない
	sort.Slice(restaurants, func(i, j int) bool {
		if restaurants[i].name < restaurants[j].name {
			return true
		} else if restaurants[i].name > restaurants[j].name {
			return false
		} else {
			return restaurants[i].score > restaurants[j].score
		}
	})
	for i := 0; i < N; i++ {
		fmt.Println(restaurants[i].num + 1)
	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 1824
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int n;
struct uzi{
  int a,b,i;
  bool operator <(const uzi &t)const{
    return a<t.a;
  }
}p[N];
int L[N];
LL f[N];
const LL mod=998244353;
int t[N];
void add(int p,int d){
  for(;p<N;p+=p&-p)t[p]=max(t[p],d);
}
int ge(int p,int d){
  int res=0;
  for(;p;p-=p&-p)res=max(res,t[p]);
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin>>n;
  for(int i=1;i<=n;i++)cin>>p[i].a>>p[i].b,p[i].i=i;
  sort(p+1,p+1+n);
  auto get=[&](int x){
    int l=1,r=n,ans=1;
    while(l<=r){
      int mid=l+r>>1;
      if(p[mid].a<=x)ans=mid,l=mid+1;
      else r=mid-1;
    }
    return ans;
  };
  for(int i=n;i>=1;i--){
    L[i]=i;
    int x=get(p[i].a+p[i].b-1);
    L[i]=max(L[i],ge(x,1));
    add(i,L[i]);
  }
//  for(int i=1;i<=n;i++){
//    cout<<i<<' '<<L[i]<<endl;
//  }
  f[1]=1;
  for(int i=1;i<=n;i++){
    f[i+1]+=f[i];//不开
    f[L[i]+1]+=f[i];//开
    f[i+1]%=mod;
    f[L[i]+1]%=mod;
  }
  cout<<f[n+1]<<endl;
  return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
const int md=998244353;
int n,ans,x[205],y[205],pw[205],cc[205];
int main()
{
	pw[0]=1;
	for(int i=1;i<205;i++)pw[i]=pw[i-1]*2%md;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",&x[i],&y[i]);
	ans=(pw[n]+md-n-1)%md;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			int cnt=0;
			for(int k=1;k<=n;k++)if((x[i]-x[j])*(y[i]-y[k])==(x[i]-x[k])*(y[i]-y[j]))cnt++;
			cc[cnt]++;
		}
	}
	for(int i=2;i<=n;i++)cc[i]=cc[i]*2/i/(i-1);
	for(int i=2;i<=n;i++)ans=(ans+md-1ll*cc[i]*(pw[i]+md-i-1))%md;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
object Main extends App {
	val Array(a,b,c,d) = scala.io.StdIn.readLine.split(" ").map(_.toInt)

	if(math.abs(a-b) <= d && math.abs(b-c) <= d){
		println("Yes")
	}else if(math.abs(a-c) <= d){
		println("Yes")
	}else{
		println("No")
	}
	
}

Measured memory_bytes: 25412
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;


int zu[20][20];

int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};//UP,RIGHT,DOWN,LEFT
char pr[]={'U','R','D','L'};

main(){
	
	for(int i=0;i<13;i++){
		zu[0][i]=1;
		zu[i][0]=1;
		zu[12][i]=1;
		zu[i][12]=1;
	}
	
	for(int i=0;i<9;i++){
		if(i&1){
			for(int j=0;j<5;j++){
				char c;
				cin>>c;
				if(c-'0'){
					zu[i+2][j*2+2]=1;
					zu[i+1][j*2+2]=1;
					zu[i+3][j*2+2]=1;
				}
			}
		}else{
			for(int j=0;j<4;j++){
				char c;
				cin>>c;
				if(c-'0'){
					zu[i+2][j*2+3]=1;
					zu[i+2][j*2+2]=1;
					zu[i+2][j*2+4]=1;
				}
			}
		}
	}
	
	int x=2,y=2,d=1;
	while(true){
		int td=(d+3)%4;
		for(int i=0;i<4;i++){
			if(zu[y+dy[td]][x+dx[td]])break;
			td=(td+1)%4;
		}
		d=td;
		cout<<pr[d];
		x+=2*dx[d];
		y+=2*dy[d];
		if(x==2 && y==2)break;
	}
	cout<<endl;
}

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

using namespace std;

long long a[11];

long long calc(long long n, long long a) {
  return (n + a - 1) / a;
}

int main(void) {
  long long n;
  scanf("%lld", &n);
  for (int i = 0; i < 5; i++) {
    scanf("%lld", a + i);
  }
  for (int i = 3; i >= 0; i--) {
    a[i] = min(a[i], a[i + 1]);
  }
  long long res = 0;
  for (int i = 0; i < 5; i++) {
    // printf("%lld\n", calc(n, a[i]) + i);
    res = max(res, calc(n, a[i]) + 4 - i);
  }
  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    for i in range(3):
        if s[i] == s[i + 1]:
            print("Bad")
            return
    print("Good")
    return

#B
def B():
    n, l = LI()
    lis = [l + i for i in range(n)]
    s = sum(lis)
    a = inf
    for i in lis:
        if abs(a) > abs(i):
            a = i
    print(s-a)
    return

#C
def C():
    def gcd(a, b):
        a, b = max(a, b), min(a, b)
        while b:
            a, b = b, a % b
        return a
    def lcm(a, b):
        return a * b // gcd(a, b)
    a, b, c, d = LI()
    x = b // c - (a-1) // c
    y = b // d - (a-1) // d
    z = b // lcm(c , d) - (a-1) // lcm(c , d)
    print(b-a+1-(x+y-z))
    return

#D
def D():
    n = II()
    ab = LIR(n)
    ab.sort(key=lambda x: x[1])
    now = 0
    for a, b in ab:
        now += a
        if now <= b:
            continue
        print("No")
        return
    print("Yes")
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 83804
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;
// const int MOD = 998244353;

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

   int n, x, y;
   cin >> n >> x >> y;
   x--, y--;
   vector<int> ans(n);
   rep(sv, 0, n) {
      vector<int> dist(n, -1);
      queue<int> que;
      auto push = [&](int v, int d) {
         if (dist[v] != -1) return;
         dist[v] = d;
         que.push(v);
      };
      push(sv, 0);
      while (!que.empty()) {
         int v = que.front();
         que.pop();
         int d = dist[v];
         if (v + 1 < n) push(v + 1, d + 1);
         if (v - 1 >= 0) push(v - 1, d + 1);
         if (v == y) push(x, d + 1);
         if (v == x) push(y, d + 1);
      }
      rep(i, 0, n) ans[dist[i]]++;
   }
   rep(i, 0, n) ans[i] /= 2;
   rep(i, 1, n) cout << ans[i] << endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i!=n;i++)

using namespace std;


int main(void){
    int n;
    cin >> n;
    vector<int> v(n);
    long long a=1;
    long long ans=0;
    REP(i,n){
        cin >> v[i];
        if(v[i]!=a){
            ans++;
        }
        else{
            a++;
        }
    }
    if(a==1){
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
}


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

using namespace std;

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


Measured memory_bytes: 256
#include <stdio.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)

int main(){
	int a,b,c,x,ans=0;
	scanf("%d %d %d %d",&a,&b,&c,&x);
	FOR(i,0,a+1){
		FOR(j,0,b+1){
			FOR(k,0,c+1){
				if((500*i)+(100*j)+(50*k) == x) ans++;
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll min(ll a,ll b){
    if(a>b)
	return b;
    return a;
}

ll abs(ll a){
    if(a<0)
	return -a;
    return a;
}
const ll inf = (1e9+7);

int main(){
    int n;
    scanf("%d",&n);
    vector<int>h(n);
    for(int&x :h)
	scanf("%d",&x);

    vector<ll>d(n,inf);
    d[0]=0;
    for(int i=0;i<n;i++){
	for(int j:{i+1,i+2}){
	    if(j<n){
		d[j]=min(d[j],d[i]+abs(h[i]-h[j]));
	    }
	}
    }
    cout<<d[n-1]<<endl;
}


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

int main()
{
    int n;
    cin >> n;
    int broj_djeljivih = 0;
    for (int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        if (x % 2 != 0 or (x % 3 == 0 or x % 5 == 0))
            broj_djeljivih++;
    }
    if (broj_djeljivih == n)
        cout << "APPROVED";
    else
        cout << "DENIED";
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		// クソコード

		// 標準入力
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = br.readLine();
		int k = Integer.parseInt(br.readLine());

		ArrayList<String> list = new ArrayList<String>();
		list.add(s);
		boolean issorted = false;

		for (int i = s.length() - 1; 0 <= i; i--) {
			for (int j = (k <= s.length() - i ? k : s.length() - i); 0 < j; j--) {
				String sb = s.substring(i, i + j);
				if (list.contains(sb))
					continue;
				if (k <= list.size()) {
					if (!issorted) {
						Collections.sort(list);
						issorted = true;
					}
					if (sb.compareTo(list.get(k - 1)) < 0) {
						list.remove(k - 1);
						list.add(sb);
						Collections.sort(list);
					}
				} else {
					list.add(sb);
				}
			}
		}

		Collections.sort(list);

		System.out.println(list.get(k - 1));

	}

}

Measured memory_bytes: 23508
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n;
  cin >> n;
  ll xx = (ll)sqrt(n);
  ll ans = 0;
  ll dd = (xx)*(xx+1)*(2*xx + 1);
  dd/=6;
  for(ll i = 1; i <= xx; i++) {
  	ll pp = (i*(i + (n/i))*((n/i) + 1 - i));
  	ans+=pp;
  }
  cout << ans - dd << endl;
  return 0;
} //good night.

Measured memory_bytes: 3720
/*選択ソート*/
#include <iostream>
using namespace std;
 
int main() {
    int n,tmp,min;
    cin >> n;
    int A[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> A[i];
    }
    int count = 0;
    for (int i = 0; i < n; ++i)
    {
        min = i;
        for (int j = i; j < n; ++j)
        {
            if (A[j]<A[min])    min = j;
        }
        if (A[i] != A[min]) {
            count +=1;
            tmp = A[i];
            A[i] = A[min];
            A[min] = tmp;
        }
    }

    for (int i = 0; i < n; ++i)
    {
        cout  << A[i];
        if(i < n-1) cout << " ";
    }
    cout << endl;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	string S[3];
	rep(i, 3) cin >> S[i];
	int L[3];
	rep(i, 3) L[i] = S[i].size();

	bool dame[3][3][4020] = {};
	rep(i, 3) rep(j, 3) if (i != j) {
		rep(k, L[i]) {
			int ok = 1;
			int k2 = min(L[i] - k, L[j]);
			rep(x, k2) {
				if (S[i][k + x] != '?' && S[j][x] != '?' && S[i][k + x] != S[j][x]) {
					ok = 0;
					break;
				}
			}
			if (!ok) dame[i][j][k] = 1;
		}
	}

	int P[3] = { 0,1,2 };
	int saishou = 6000;
	rep(x, 6) {
		int i = P[0];
		int j = P[1];
		int k = P[2];

		rep(p, L[i] + 1) {
			if (!dame[i][j][p]) {
				rep(q, 4010) {
					if (!dame[j][k][q] && !dame[i][k][p + q]) {
						chmin(saishou, max({ L[i], L[j] + p, L[k] + p + q }));
						break;
					}
				}
			}
		}
		next_permutation(P, P + 3);
	}

	co(saishou);


	Would you please return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
int main(void)
{
  int N,M,A,B,count,H[100001]={0},tip[100001]={0};
  count=scanf("%d %d",&N,&M);
  rep(i,N)count=scanf("%d",&H[i]);
  rep(i,M){count=scanf("%d %d",&A,&B);A--,B--;if(H[A]<=H[B])tip[A]=1;if(H[A]>=H[B])tip[B]=1;}
  count=N;
  rep(i,N)count-=tip[i];
  return printf("%d\n",count),0;
}

Measured memory_bytes: 2484
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define per(i, a, b) for(int i = a; i >= b; i--)
typedef long long LL;
const int maxn = 1e5 + 5;
const LL mod = 1e9 + 7;

int n, k, cnt, first[maxn], ans, fa[maxn], d[maxn], g[maxn][25];
struct Edge {
	int to, next;
} e[maxn<<1];
bool vis[maxn];
struct node {
	int id, d;
} dot[maxn];

void Dfs(int u, int f) {
	fa[u] = f;
	d[u] = d[f] + 1;
	for(int i = first[u]; i; i = e[i].next) {
		int v = e[i].to;
		if(v == f) continue;
		Dfs(v, u);
	}
}

void Dfs2(int u) {
	if(vis[u]) return;
	vis[u] = 1;
	for(int i = first[u]; i; i = e[i].next) {
		int v = e[i].to;
		if(v == fa[u]) continue;
		Dfs2(v);
	}
}

bool cmp(node a, node b) {
	return a.d > b.d;
}

void add(int u, int v) {
	e[++cnt] = (Edge) {v, first[u]};
	first[u] = cnt;
}

int main() {
	cin>>n>>k;
	rep(i, 1, n) {
		int x;
		cin>>x;
		if(i == 1) {
			if(x != 1) ans++;
			continue;
		}
		add(i, x);
		add(x, i);
		g[i][0] = x;
	}
	g[1][0] = 1;
	d[0] = -1;
	Dfs(1, 0);
	rep(j, 1, 20)
	    rep(i, 1, n) 
	        g[i][j] = g[g[i][j - 1]][j - 1]; 
	rep(i, 1, n)
	    dot[i] = (node) {i, d[i]};
	sort(dot + 1, dot + n + 1, cmp);
	rep(i, 1, n) {
		if(vis[dot[i].id]) continue;
		if(dot[i].d <= k) continue;
		ans++;
		int maxd = k - 1, u = dot[i].id;
		per(i, 20, 0)
		    if(maxd >= 1<<i) {
		    	maxd -= 1<<i;
		    	u = g[u][i];
		    }
		Dfs2(u);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 21660
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <climits>
#include <cstdint>
using namespace std;

inline namespace atcoder {
    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;

    constexpr int64_t mpow(int64_t a, int64_t b, int64_t mod = 1000000007) {
        if (b <= 0) return 1; if (b == 1) return a % mod; if (b == 2) return (a * a) % mod;
        return (max(a * (b & 1), (int64_t)1) * mpow(mpow(a, b / 2, mod), 2, mod)) % mod;
    }
    constexpr int64_t mdiv(int64_t a, int64_t b, int64_t mod = 1000000007) {
        return (a * mpow(b, mod - 2, mod)) % mod;
    }
}

int main() {
    int64_t n; cin >> n;
    cout << (n * (n - 1)) / 2 << endl;
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int a[3];
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]!=a[1]) cout<<a[0];
	else cout<<a[2];
	re 0;
}

Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class Main {

  public void run() throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String in;
    while ((in = reader.readLine()) != null) {
      String[] splited = in.split(" ");
      int month = Integer.parseInt(splited[0]);
      int date = Integer.parseInt(splited[1]);

      //month???0????????????
      if (month == 0)
        break;

      Calendar cal = new GregorianCalendar(2004, month - 1, date);
      switch (cal.get(Calendar.DAY_OF_WEEK)) {
        case Calendar.SUNDAY:
          System.out.println("Sunday");
          break;
        case Calendar.MONDAY:
          System.out.println("Monday");
          break;
        case Calendar.TUESDAY:
          System.out.println("Tuesday");
          break;
        case Calendar.WEDNESDAY:
          System.out.println("Wednesday");
          break;
        case Calendar.THURSDAY:
          System.out.println("Thursday");
          break;
        case Calendar.FRIDAY:
          System.out.println("Friday");
          break;
        case Calendar.SATURDAY:
          System.out.println("Saturday");
          break;
      }
    }
  }

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

}

Measured memory_bytes: 26156
import java.io.*;

public class Main {
    public static void main(String[] args) {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        try {
            int g = 0;
            int p = 0;
            int win = 0;
            int loose = 0;

            char[] buf = new char[1];
            while (in.read(buf) == 1) {
                if (buf[0] != 'g' && buf[0] != 'p') {
                    continue;
                }
                char h = buf[0];
                if (g > p) {
                    ++p;
                    if (h == 'g') {
                        ++win;
                    }
                } else {
                    ++g;
                    if (h == 'p') {
                        ++loose;
                    }
                }
            }
            System.out.println(win - loose);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 10964
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

N = INT()
A = LIST()
A.sort()

A_max = max(A)

a = [0]*(A_max+1)

ans = 0
for x in A:
	a[x] += 1

for i in range(A_max+1):
	if a[i] == 1:
		ans += 1
	if 0 < a[i]:
		for j in range(A_max//i + 1):
			a[i*j] = 0

print(ans)



Measured memory_bytes: 117616
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
using namespace std;

int main()
{
    int n,x;
    scanf("%d%d",&n,&x);
    int num[500];
    int sum=0;
    int minn=10000000;
    for(int i=0;i<n;i++){
        scanf("%d",&num[i]);
        sum=sum+num[i];
        minn=min(minn,num[i]);
    }
    x=x-sum;
    int ans=n;
    if(x>0){
        ans=ans+x/minn;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a=0, b=0, c=0;
	scanf("%d %d %d", &a, &b, &c);
	if ((a < b)&&(b < c))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

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

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

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

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<pair<T, T>>& vp) {
	for (int i = 0; i < vp.size(); ++i) {
		s << "(" << vp[i].first << "," << vp[i].second << ")" << ( i+1 == vp.size() ? "" : ",\t" );
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	while (true) {
		int c = n;
		VL k(3);
		for (int i = 0; i < 3; i++) {
			k[i] = c % 10;
			c /= 10;
		}
		if (k[0] == k[1] and k[1] == k[2]) {
			cout << n << endl;
			return 0;
		}
		n++;
	}
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; string S; cin >> N >> S;
    int ans = 0;
    F0R(i, N-2) {
        if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') {
            ans++;
        }
    }
    cout << ans << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 256
'use strict'

function main(s) {

  const spans = s.split('\n').slice(1, -1).map(l => l.split(' ').map(n => Number(n)));

  spans.sort((a, b) => a[1] - b[1]);

  let breaked = 0;
  let sum = 0;

  for (const span of spans) {
    const start = span[0];
    const end   = span[1];

    if (start >= breaked) {
      breaked = end;
      sum += 1;
    }
  }

  console.log(sum);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 52624