akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	var n int
	min := 10000000
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	for i := -100; i < 101; i++ {
		var sum int
		for _, v := range a {
			sum += (v - i) * (v - i)
		}
		if sum < min {
			min = sum
		}
	}

	fmt.Println(min)
}

Measured memory_bytes: 512
N = int(input())

bucket = dict()

def keyGen(num,den=1):
	c2 = 0
	c5 = 0
	while num%2==0:
		c2+=1
		num/=2
	while den%2==0:
		c2-=1
		den/=2
	while num%5==0:
		c5+=1
		num/=5
	while den%5==0:
		c5-=1
		den/=5
	return (c2,c5)

def addItem(d,key1):
	if key1 in d:
		d[key1]+=1
	else:
		d[key1]=1

for _ in range(N):
	theNumber = input()
	dpoint = theNumber.find('.')
	if(dpoint>-1):
		a=int(theNumber[:dpoint])
		lenOfDen = len(theNumber[1+dpoint:])
		b=int(theNumber[1+dpoint:])
		num = a*10**lenOfDen+b
		den = 10**lenOfDen
		addItem(bucket,keyGen(num,den))
	else:
		addItem(bucket,keyGen(int(theNumber)))

s=0
for it in bucket:
	x1 = it[0]
	y1 = it[1]
	r1 = bucket[it]
	for it2 in bucket:
		x2 = it2[0]
		y2 = it2[1]
		r2 = bucket[it2]
		if x1+x2>=0 and y1+y2>=0:
			if(it<it2):
				s+=r1*r2
			elif(it==it2):
				s+=(r1*(r1-1))//2

print(s)



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

typedef long long ll;

int main(void)
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(0);
//    cout.tie(0);

    //freopen("input.txt", "r", stdin);

    int n;
    cin >> n;

    if(n >= 400 && n <= 599)
        cout << 8;
    else if(n >= 600 && n <= 799)
        cout << 7;
    else if(n >= 800 && n <= 999)
        cout << 6;
    else if(n >= 1000 && n <= 1199)
        cout << 5;
    else if(n >= 1200 && n <= 1399)
        cout << 4;
    else if(n >= 1400 && n <= 1599)
        cout << 3;
    else if(n >= 1600 && n <= 1799)
        cout << 2;
    else if(n >= 1800 && n <= 1999)
        cout << 1;

    cout << "\n";

    return 0;
}


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

#define COUT(x) cout << x << endl
#define CIN(x) cin >> x
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define EXIST(s, e) (s.find(e) != s.end())
#define SORT(c) sort(c.begin(), c.end())
#define ERASEUNIQE(v) v.erase(unique(v.begin(), v.end()), v.end())

// conversion
inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}

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

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

// container util
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()

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

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

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

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

int main(int argc, char const *argv[])
{
    int a, b;
    CIN(a), CIN(b);
    if (a > b)
    {
        COUT("a > b");
    }
    else if (a == b)
    {
        COUT("a == b");
    }

    else
    {
        COUT("a < b");
    }

    return 0;
}



Measured memory_bytes: 3084
#解説AC
n,m = map(int,input().split())
lists = []
L = []
R = []
for i in range(m):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)
ll = max(L)
rr = min(R)
ans = len(list(range(ll,rr+1)))
print(ans)

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

void solve1(){
    int a,b,c;
    cin>>a>>b>>c;
    string ans = (b-a == c-b) ? "YES": "NO";
    cout<<ans<<endl;
    return;
}

void solve2(){
    string O,E;
    cin>>O>>E;
    string ans = "";
    for(int i = 0; i < O.size();i++){
        ans += O[i];
        if(i < E.size()){
            ans += E[i];
        }
    }
    cout<<ans<<endl;

}

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

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

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){

  int n,m,k;
  ll a[200001],b[200001];

  a[0] = 0;
  b[0] = 0;
  scanf("%d%d%d",&n,&m,&k);
  for(int i = 1; i <= n; ++i){
    scanf("%lld",&a[i]);
    a[i] += a[i-1];
  }
  for(int i = 1; i <= m; ++i){
    scanf("%lld",&b[i]);
    b[i] += b[i-1];
  }

  int j = m;
  int ans = 0;
  for(int i = 0; i < n+1; ++i){
    if(a[i] > k) break;
    while(b[j] > k-a[i]) --j;
    ans = max(ans, i+j);
  }

  printf("%d",ans);

  return 0;
}


Measured memory_bytes: 4828
#include <bits/stdc++.h>
 
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
using namespace std;
 
const int INF = 1e9 + 7;
 
int main(void)
{
	FAST
	
	int ans;
	for(int i = 1; i < 6; i++)
	{
		int x; cin >> x;
		if(x == 0) ans = i;
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3644
#include <iostream>

using namespace std;

#define MAX 1500000
 
bool prime[MAX];
 
void make(){
    fill(prime,prime+MAX,true);
    prime[0] = prime[1] = false;
     
    for(int i = 2 ; i*i < MAX ; i++){
        if(prime[i]){
            for(int j = 2*i ; j < MAX ; j += i){
                prime[j] = false;
	    }
	}
    }
}
 
int main(){
    int n;
    make();
    while(cin >> n,n){
        int a,i;    
        if(prime[n]) cout << '0' << endl;
        else{
            for(i = n ; prime[i] != true ; i++);
            a = i;
            for(i = n ; prime[i] != true ; i--);
            cout << a-i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4496
#include <bits/stdc++.h>
#define int long long
using namespace std;
int k, a[15];
signed main() {
    cin >> k;
    int i = 1, zz = 1;
    while (k) {
        ++a[i];
        if (a[i] > 9 || a[i] > a[i + 1] + 1 && i + 1 <= zz || i > 1 && a[i] > a[i - 1]) {
            while (a[i] > 9 || a[i] > a[i + 1] + 1 && i + 1 <= zz || i > 1 && a[i] > a[i - 1]) ++a[++i];
            zz = max(zz, i);
            for (int j = i - 1; j; --j) a[j] = max(a[j + 1] - 1, 0LL);
            i = 1;
        }
        --k;
    }
    int now = 10;
    while (!a[now]) --now;
    for (int i = now; i >= 1; --i) cout << a[i];
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX_TOSHI       100
#define RESULT_WAR      "War"
#define RESULT_NOWAR    "No War"

int main(){
	// 初期化
	int numX = 0;
	int numY = 0;
	int valX = 0;
	int valY = 0;
	int valZ = 0;
	int valMaxX = -200;
	int valMinY =  200;
	int cntA = 0;
	int arrToshiX[MAX_TOSHI];
	int arrToshiY[MAX_TOSHI];
	int valResult = 0;
	for(cntA=0; cntA<MAX_TOSHI; cntA++){
		arrToshiX[cntA] = 0;
		arrToshiY[cntA] = 0;
	}
	
	
	// 標準入力1 --------
	scanf("%d %d %d %d", &numX, &numY, &valX, &valY);
	// 標準入力2 --------
	for(cntA=0; cntA<numX-1; cntA++){
		scanf("%d ", &arrToshiX[cntA]);
	}
	scanf("%d", &arrToshiX[cntA]);
	// 標準入力3 --------
	for(cntA=0; cntA<numY-1; cntA++){
		scanf("%d ", &arrToshiY[cntA]);
	}
	scanf("%d", &arrToshiY[cntA]);
	
	// 最小・最大算出
	for(cntA=0; cntA<numX; cntA++){
		if(arrToshiX[cntA] > valMaxX){
			valMaxX = arrToshiX[cntA];
		}
	}
	for(cntA=0; cntA<numY; cntA++){
		if(arrToshiY[cntA] < valMinY){
			valMinY = arrToshiY[cntA];
		}
	}
	
	
	for(valZ=valX; valZ<=valY; valZ++){
		// 判定1 --------
		if(valX >= valZ || valZ > valY){
			continue;
		}
		// 判定2 --------
		if(valMaxX >= valZ){
			continue;
		}
		// 判定3 --------
		if(valMinY < valZ){
			continue;
		}
		// 条件を満たすZが存在する --------
		printf(RESULT_NOWAR);
		return 0;
	}
	
	printf(RESULT_WAR);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr <<__LINE__<< ": " << #x << " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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 int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    ll ans = 0;
    rep(i, n + 1) {
        if (i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << endl;
}

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


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

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
using namespace std;
using ll = long long;
using lld = long long;

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

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

int main() {
  ll N, K;
  cin >> N >> K;
  vector<double> A(N);

  loop(0, N, i) {
    double tmp;
    cin >> tmp;
    double sum = tmp * (1+tmp) / 2;
    A[i] = sum / tmp ;
  }

  vector<double> C(N+1);
  C[0] = 0;
  loop(0, N, i) {
    C[i+1] = A[i] + C[i];
  }

  double mx = 0;
  loop(0, N-K+1, i) {
    double score = C[i+K] - C[i];
    mx = max(mx, score);
  }
  cout << fixed << setprecision(9) << mx << endl;
}

Measured memory_bytes: 6464
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

struct Node {
    int id;
    Node *parent, *left, *right;
};

int n;
Node **nodes;

inline int getheight(int id) {
    Node *node = nodes[id];
    int left_height = 0, right_height = 0;
    if (node->left) {
        left_height = 1 + getheight(node->left->id);
    }
    if (node->right) {
        right_height = 1 + getheight(node->right->id);
    }
    return left_height > right_height ? left_height : right_height;
}

int main(void) {

    scanf("%d", &n);
    nodes = new Node*[n];
    for (int i = 0; i < n; ++i) {
        nodes[i] = NULL;
    }

    for (int i = 0, id, left, right; i < n; ++i) {
        scanf("%d %d %d", &id, &left, &right);
        Node *pnode = nodes[id];
        if (pnode == NULL) {
            pnode = nodes[id] = new Node;
            pnode->id = id;
            pnode->parent = pnode->left = pnode->right = NULL;
        }
        if (left != -1) {
            Node *leftnode = nodes[left];
            if (leftnode == NULL) {
                leftnode = nodes[left] = new Node;
                leftnode->id = left;
                leftnode->parent
                    = leftnode->left = leftnode->right = NULL;
            }
            leftnode->parent = pnode;
            pnode->left = leftnode;
        }
        if (right != -1) {
            Node *rightnode = nodes[right];
            if (rightnode == NULL) {
                rightnode = nodes[right] = new Node;
                rightnode->id = right;
                rightnode->parent
                    = rightnode->left = rightnode->right = NULL;
            }
            rightnode->parent = pnode;
            pnode->right = rightnode;
        }
    }

    for (int i = 0; i < n; ++i) {

        int parent = (nodes[i]->parent ? nodes[i]->parent->id : -1);

        int sibling = -1;
        if (parent != -1) {
            Node *pnode = nodes[parent];
            if (pnode->left && pnode->left != nodes[i]) {
                sibling = pnode->left->id;
            }
            else if (pnode->right && pnode->right != nodes[i]) {
                sibling = pnode->right->id;
            }
        }

        int degree = 0;
        if (nodes[i]->left) {
            ++degree;
        }
        if (nodes[i]->right) {
            ++degree;
        }

        int depth = 0;
        Node *node = nodes[i]->parent;
        while (node) {
            ++depth;
            node = node->parent;
        }

        int height = getheight(i);

        const char *type = "internal node";
        if (nodes[i]->parent == NULL) {
            type = "root";
        }
        else if (!nodes[i]->left && !nodes[i]->right) {
            type = "leaf";
        }

        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", nodes[i]->id, parent, sibling, degree, depth, height, type);
    }

    for (int i = 0; i < n; ++i) {
        Node *node = nodes[i];
        node->parent = node->left = node->right = NULL;
        delete node;
    }

    return 0;
}

Measured memory_bytes: 1192
# abc119_a.py
# https://atcoder.jp/contests/abc119/tasks/abc119_a

# A - Still TBD /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# 文字列 Sが入力されます。これは、西暦 2019 年の実在する日付を yyyy/mm/dd の形式で表したものです。
# (例えば、2019 年 4 月 30日は 2019/04/30 と表されます。)
# Sが表す日付が 2019 年 4 月 30日またはそれ以前なら Heisei、そうでなければ TBD と出力するプログラムを書いてください。

# 制約
#     Sは西暦 2019年の実在する日付を yyyy/mm/dd の形式で表す文字列である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# S

# 出力
# Sが表す日付が 2019 年 4 月 30日またはそれ以前なら Heisei、そうでなければ TBD と出力せよ。

# 入力例 1
# 2019/04/30

# 出力例 1
# Heisei

# 入力例 2
# 2019/11/01

# 出力例 2
# TBD


def calculation(lines):
    line = lines[0]
    # N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i+1]))

    yyyymmdd = int(line.replace('/', ''))
    if yyyymmdd <= 20190430:
        result = 'Heisei'
    else:
        result = 'TBD'

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['2019/04/30']
        lines_export = ['Heisei']
    if pattern == 2:
        lines_input = ['2019/11/01']
        lines_export = ['TBD']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9260
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
  char S[2000];
  int i;
  scanf("%s", S);
  for (i = 0; S[i] != '\0'; i++);
  i--;
  if (S[i] == 's') {
    S[i + 1] = 'e';
    S[i + 2] = 's';
    S[i + 3] = '\0';
  }
  else {
    S[i + 1] = 's';
    S[i + 2] = '\0';
  }
  printf("%s", S);
}

Measured memory_bytes: 1732
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    int x,ans;
    cin >> x;
    for(int i = 31;i>=1;i--){
        if(i*i<=x){
               ans = i*i;
               break;
        }
    }
    for(int i=10;i>=1;i--){
        if(i*i*i<=x){
            ans = max(ans,i*i*i);
            break;
        }
    }
    for(int i=3;i>=1;i--){
        if(i*i*i*i*i<=x){
            ans = max(ans,i*i*i*i*i);
            break;
        }
    }
    if(128<=x){
        ans = max(ans,128);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN=1007;
const int inf=0x3fffffff;
int a[MAXN],n,pre[MAXN],cnt,flag,num,maxx=-inf;
ll ans[MAXN],cnt1,cnt2;
inline bool check_all()
{
	for(int i=1;i<=n;i++) if(a[i]>0) return 0;
	return 1;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	if(check_all()){
		int l;
		for(int i=1;i<=n;i++) if(a[i]>maxx) maxx=a[i],l=i;
		cout<<maxx<<endl<<n-1<<endl;
		for(int i=n;i>=l+1;i--) cout<<i<<endl;
		for(int i=1;i<=l-1;i++) cout<<1<<endl;
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(a[i]>0){
			if(i&1) cnt1+=a[i];
			else cnt2+=a[i];
		}
	}
	if(cnt1>cnt2){
		cout<<cnt1<<endl;
		flag=1;
	} else {
		cout<<cnt2<<endl;
		flag=2;
	}
	for(int i=flag;i<=n;i+=2) if(a[i]>0) pre[++cnt]=i;
		int now=pre[cnt];
		for(int i=n;i>=pre[cnt]+1;i--) ans[++num]=i;
		for(int i=cnt-1;i>=1;i--){
			int last=now; now=pre[i];
			int mid=last+now>>1;
			int k=last-now+1;
			while(k>1){
				ans[++num]=mid;
				mid--;
				k-=2;
			}
		}
		for(int i=1;i<=pre[1]-1;i++) ans[++num]=1;
		cout<<num<<endl;
		for(int i=1;i<=num;i++) cout<<ans[i]<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

//#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x%N;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x)%N;
		y = y >> 1;
		x = (x * x)%N;
	}
	return res;
}
double dist(ll x1,ll y1, ll x2,ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin >> n;
	ll gm = sqrt(n);
	ll ans = 0;
	rf(i, gm, 1)
	{
		if (n % i == 0)
		{
			ans += i - 1;
			ans += (n / i) - 1;
			break;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn._

object Main {
  def isMakeText(r: String, t: String): String = {
    val l = t.length

    def loop(n: Int = 0): String ={
      if(n < r.length - l) {
        val mkText = (for (i <- n until l + n) yield r(i)).mkString("")
        if (mkText == t) "Yes" else loop(n + 1)
      } else "No"
    }

    loop(0)
  }

  def main(args: Array[String]): Unit = {
    val ring = readLine() * 2
    val text = readLine()
    println(isMakeText(ring, text))
  }
}

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

int main() {
  string S;
  string H = "hi";
  cin >> S;
  for(int i = 0; i < 5; i++){
    if(S == H){
      cout << "Yes" << endl;
      break;
    }else if(i < 4){
      H += "hi";
    }else if(i == 4){
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=998244353;
const int N=1e5+5;
int gcd(int n,int m)
{
    if(n==0)
        return m;
    else
        return gcd(m%n,n);
}
int a[N];
int n,m,v,p;
int check(int mid)
{
    if(mid>n-p)
        return 1;
    int pp=a[mid]+m;
    if(pp<a[n-p+1])
        return 0;
    vector<int>ans;
    int cnt=mid+p-1;
    if(cnt>=v)
        return 1;
    int z=v-cnt;
    int x=(v-cnt)*m;
    int sum=0;
    for(int i=mid+1;i<=n-p+1;i++)
    {
        sum+=(pp-a[i]);
    }
    if(sum>=x)
        return 1;
    return 0;
}
int binsearch(int lo, int hi)
{
    int ans=n;
    while(hi>=lo)
    {
        int mid = (lo + hi)/2;
        if(check(mid))
        {
            ans=mid;
            hi = mid-1;
        }
        else
        {
            lo=mid+1;
        }
    }
    return ans;
}
int32_t main()
{
    IOS;
    
    cin>>n>>m>>v>>p;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    cout<<n-binsearch(1,n)+1<<endl;;
    


}

Measured memory_bytes: 1024
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;

    for(;sc.hasNext();){
      n = sc.nextInt();
      out.println(1 + n * (n + 1) / 2);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 15328
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		int ans = 0;
		int count = 0;
		for(int i = Math.min(A,B); i >= 1; i--) {
			if(A % i == 0 && B % i==0) {
				count++;	
				ans = i;
				if(count == K) {
					break;
				}
			}
		}
		System.out.print(ans);
	}
}

Measured memory_bytes: 35576
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long A = Integer.parseInt(sc.next());
    long B = Integer.parseInt(sc.next());
    System.out.print(A*B/gcd(A,B));
    return;
  }

  static long gcd(long a, long b){
    long max= Math.max(a,b);
    long min= Math.min(a,b);
    if(max%min==0){
      return min;
    }else{
      return gcd(max%min, min);
    }
  }  
  
}




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

using ll = long long;
const int sz = 1e5 + 10;

char c[] = { '^', '>', 'v', '<' };

bool pal( string s ) {
    for( int i=0,j=s.size()-1; i<j; i++,j-- ) {
        if( s[i] != s[j] ) return false;
    }
    return true;
}

int main() {
    #ifdef CLown1331
        freopen( "in.txt","r",stdin );
    #endif /// CLown1331
    int n, m, ans;
    while( cin >> n >> m ) {
        ans = ( n - 1 ) * ( m - 1 );
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr auto MOD = 1000000007;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;

string s;
long long n, m;

int main()
{
  cin >> n;
  VI a(n);
  for (int i = 0; i < n; ++i)
  {
    cin >> a[i];
  }
  int ans = 0;
  int iter = 0;
  int now = 0;
  for (int i = 0; i < n; i++)
  {
    if(a[i]!=now+1){
      ans++;
      continue;
    }
    now++;
  }

  if(ans==n){
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
import sys
n =  int(input())
a = [int(input()) for i in range(n)]
ln = [i for i in a if i % 10 != 0]
ln.sort()
ans = sum(a)
for i in range(n):
    if ans % 10 != 0:
        print(ans)
        sys.exit()
    elif ln != []:
        print(ans - ln[0])
        sys.exit()
    else:
        print(0)
        sys.exit()

Measured memory_bytes: 38256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head=0, tail=0, n;

void enqueue(P);

P dequeue();
int min(int ,int);



int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail = n+1;

while(head != tail){
  u = dequeue();
  c = min(q,u.t);
  u.t -= c;
  elaps += c;
  if(u.t > 0) enqueue(u);
  else{
    printf("%s %d\n",u.name,elaps);
  }


 }
  
  return 0;
}

void enqueue(P x){
  if(head == (tail + 1)%LEN){
    exit(2);
  }
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(){
  if(head == tail) exit(2);
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}
int min(int x, int y){
  int min;
  if(x<y) min = x;
  else min = y;

  return min;
}



Measured memory_bytes: 11852
while True:
    m, f, r = map(int,input().split())
    if(m == -1 and f == -1 and r == -1):break
    if(m == -1 or f == -1):
        print("F")
    elif(m + f <= 100 and m + f >= 80):
        print("A")
    elif(m + f < 80 and m + f >= 65):
        print("B")
    elif(m + f < 65 and m + f >= 50):
        print("C")
    elif(m + f < 50 and m+ f >= 30):
        if(r >= 50):
            print("C")
        else:
            print("D")
    elif(m + f <30):
        print("F")



Measured memory_bytes: 5596
# https://atcoder.jp/contests/abc060/tasks/abc060_b
a, b, c = map(int, input().split())

t = a
s = 0
while True:
    s = (t % b) % b
    t += a
    if s == c:
        print('YES')
        break
    elif s == 0:
        print('NO')
        break


Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>

struct Team{
	int index,score,rank;
	Team(){score=0;}
};

bool rank_ask(const Team &a,const Team &b){
	if(a.score>b.score)return true;
	return false;
}
bool index_ask(const Team &a,const Team &b){
	if(a.index<b.index)return true;
	return false;
}

int main(){
	int n;
	Team team[101];
	std::cin>>n;
	for(int i=0;i<n;i++)team[i].index=i;
	for(int i=0;i<(n*(n-1)/2);i++){
		int a,b,c,d;
		std::cin>>a>>b>>c>>d;
		if(c>d)team[a-1].score+=3;
		else if(c==d)team[a-1].score++,team[b-1].score++;
		else team[b-1].score+=3;
	}
	std::sort(team+0,team+n,rank_ask);
	for(int i=0,a;i<n;i++){
		a=i+1;
		team[i].rank=a;
		while(team[i].score==team[i+1].score)team[i+1].rank=a,i++;
	}
	std::sort(team+0,team+n,index_ask);
	for(int i=0;i<n;i++)std::cout<<team[i].rank<<std::endl;
	return 0;
}

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

string replaceAll(string s, string target, string replacement) {
  if (!target.empty()) {
    std::string::size_type pos = 0;
    while ((pos = s.find(target, pos)) != std::string::npos) {
      s.replace(pos, target.length(), replacement);
      pos += replacement.length();
    }
  }
  return s;
}

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

  s = replaceAll(s, "BC", "X");

  ll ans = 0;
  ll cntA = 0;
  rep(i, s.size()) {
    if (s[i] == 'X') {
      ans += cntA;
    } else if (s[i] == 'A') {
      cntA++;
    } else {
      cntA = 0;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
   
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
       	ll n;cin>>n;
       	ll a[n];
       	rep(i,n)cin>>a[i];
       	map<ll,ll> m;
       	rep(i,n){
       		m[a[i]+i]++;
       	}
       	ll ans=0;
       	rep(i,n){
       		ll x=i-a[i];
       		if(m.find(x)!=m.end()){
       			ans+=m[x];
       		}
       		if((x)==(i+a[i]))ans--;
       	}
       	cout<<ans<<endl;
    }   
    timecalculater();
    return 0;   
} 	

Measured memory_bytes: 17596
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,k,l[15],r[15],sum[200005],dp[200005],modul=998244353;
int32_t main(){
CODE_START;
cin>>n>>k;
for(ll i=1;i<=k;i++)
{
    cin>>l[i]>>r[i];
    for(ll j=l[i];j<=r[i];j++)
    {
        dp[j+1]=1;
    }
}
for(ll i=1;i<=n;i++)
{
    sum[i]+=sum[i-1];
    sum[i]%=modul;
for(ll j=1;j<=k;j++)
{
    ll s1=max(0LL,i-r[j]-1);
    ll s2=max(0LL,i-l[j]);
    ll nr=sum[s2]-sum[s1];
    //cout<<s1<<' '<<s2<<' '<<nr<<endl;
    dp[i]+=nr;
    dp[i]%=modul;
}
//cout<<endl;
sum[i]+=dp[i];
sum[i]%=modul;
}
while(dp[n]<0){
    dp[n]+=modul;
}
cout<<dp[n]<<endl;
}





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

using namespace std;

int main() {
  string S, T;
  cin >> S >> T;
  if (S == T.substr(0, T.length() - 1)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

int main() {
    string Stemp,S,T,d,der,e,eer;
    int ind=2;
    d = "maerd";
    der = "remaerd";
    e = "esare";
    eer = "resare";
    
    cin >> Stemp;
    
    S = Stemp;
    
    T = "";
    
    for (int i = 0; i < Stemp.size();i++){
        S.at(i) = Stemp.at(Stemp.size() - i-1);
    }
    

    while(ind <Stemp.size())
    {
        if (S.at(ind) == 'e')
        {
            T += d;
            ind += 5;
        }
        else if (S.at(ind) == 'm')
        {
            T +=  der;
            ind += 7;
        }
        else if (S.at(ind) == 'a')
        {
            T += e;
            ind += 5;
        }
        else if (S.at(ind) == 's')
        {
            T += eer;
            ind += 6;
        }
        else
        {
            //flag = 1;
            break;
        }
        
    }

    if(T == S){
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    //cout << T << endl;
    
        

}


Measured memory_bytes: 640
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
int p[310000];
int rev[310000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);p[i]--;
		rev[p[i]]=i;
		if(p[i]%2!=i%2){
			printf("No\n");return 0;
		}
	}
	int at=0;
	while(at<a){
		if(at==p[at]){
			at++;
			continue;
		}
		int now=at;
		int ma=1;
		int L=-100;
		int R=-100;
		while(ma){
			now+=2;
			if(p[now]==now){
				{printf("No\n");return 0;}
			}
			if(p[now]<=now&&rev[now]<=now)ma--;
			else if(p[now]>now&&rev[now]>now)ma++;
			if(p[now]<=now){
				if(L>p[now]){printf("No\n");return 0;}
				L=p[now];
			}
			if(rev[now]<=now){
				if(R>rev[now]){printf("No\n");return 0;}
				R=rev[now];
			}
			
		}

		for(int i=at+1;i<now;i+=2){
			if(i!=p[i]){
				printf("No\n");return 0;
			}
		}
		at=now+1;
	}
	printf("Yes\n");
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
ll a[1002][1002];
ll dp[1002][1002];
ll r,c;
bool safe(ll i,ll j)
{
	if(i>=1&&i<=r&&j>=1&&j<=c&&a[i][j]!=1)
		return true;
	else
		return false;
}
ll func(ll i,ll j)
{
	if(!safe(i,j))
		return 0;
	if(dp[i][j]!=-1)
		return dp[i][j];
	dp[i][j]=(func(i,j+1)%mod+func(i+1,j)%mod)%mod;
	return dp[i][j];
}
int main()
{
	int i,j;
	char ch;
	cin>>r>>c;
	for(i=1;i<=r;i++)
	{
		for(j=1;j<=c;j++)
		{
			cin>>ch;
			if(ch=='.')
				a[i][j]=0;
			else
				a[i][j]=1;
			dp[i][j]=-1;
		}
	}
	dp[r][c]=1;
	cout<<func(1,1)<<endl;
}


Measured memory_bytes: 16000
import java.util.Scanner;

public class Main {
	public static void main(String[] args){



		try (Scanner scanner = new Scanner(System.in)) {

			long num = scanner.nextInt();
			
			long distance = scanner.nextInt();
			distance = distance * distance;
			
			
			long cnt = 0;
			
			for(long i = 0; i < num; i++) {
				long x = scanner.nextInt();
				long y = scanner.nextInt();
				
				if (x * x + y * y <= distance) {
					cnt++;
				}
			}

			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 59152
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=2e5+100;
ll d[mm],sum[mm],num[mm];
ll n,m,k;
ll check(ll x,ll i)
{
//	cout<<x<<' '<<i<<' '<<sum[i]+num[x]<<endl; 
	return sum[i]+num[x];
}
int main()
{
   ll i,j,t,a,b,c,p,k,kk,l,r; 
     cin>>n>>m>>k;
     for(i=1;i<=n;i++)
     {
     	scanf("%lld",&d[i]);
     	sum[i]=sum[i-1]+d[i];
	 }
	 for(i=1;i<=m;i++)
	 {
	 	scanf("%lld",&d[i]);
		num[i]=num[i-1]+d[i];
	 }
	 p=0;
	 for(i=0;i<=n;i++)
	 {
	 	if(sum[i]<=k)
	 	p=max(p,i);
	 	l=1;r=m;
	 	while(l<=r)
	 	{
	 		ll mid=(l+r)/2;
			if(check(mid,i)<=k) 
			l=mid+1;
			else r=mid-1;
		}
		if(sum[i]+num[r]<=k)
		p=max(p,r+i);
	 }
	 cout<<p<<endl;
	 
} 

Measured memory_bytes: 7948
#include <iostream>
#include <unordered_map>
#include <string.h>
using namespace std;

/*
int main(){
    int N, M;
    cin >> N >> M;
    unordered_map<int, pair<bool, int>> m{};
    int wa_cnt = 0;
    int ac_cnt = 0;
    for(int i = 0; i < M; i++ ){
        int num;
        string result;
        cin >> num >> result;
        if(!m.count(num)==0){
            m.emplace(num, make_pair(false, 0)); 
        }

        if(m[num].first == false && result == "WA"){
            m[num].second++;
        }
        else if (m[num].first == false && result == "AC"){
            m[num].first = true;
            wa_cnt += m[num].second;
            ac_cnt++;
        }
    }
    cout << ac_cnt << " " << wa_cnt << endl;
}
*/


int main(){
    int N, M;
    cin >> N >> M;
    bool ac[100001] = {};
    int  wa[100001] = {};
    int wa_cnt = 0;
    int ac_cnt = 0;
    int num;
    string result;
    string wa_char = "WA";
    string ac_char = "AC";
    for(int i = 0; i < M; i++ ){
        cin >> num >> result;
        if(ac[num] == false && result == wa_char){
            wa[num]++;
        }
        else if (ac[num] == false && result == ac_char){
            ac[num] = true;
            wa_cnt += wa[num];
            ac_cnt++;
        }
    }
    cout << ac_cnt << " " << wa_cnt << endl;
}

Measured memory_bytes: 768
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	s := getNextString(scanner)

	ans := "No"
	if n%2 == 0 && s[0:n>>1] == s[n>>1:n] {
		ans = "Yes"
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}


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

int main() {
    int N;
    cin >> N;
    int res = N % 10;
    if ((res ==  2) || (res ==  4) || (res ==  5) || (res ==  7) || (res ==  9)) {
        cout << "hon" << endl;
    }
    else if ((res ==  0) || (res ==  1) || (res ==  6) || (res ==  8)) {
        cout << "pon" << endl;
    }
    else {
        cout << "bon" << endl;
    }
}

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

int main()
{
	int a, b;
	cin >> a >> b;
	int score=0;
	if (a > b) {
		score += a;
		a--;
	}
	else {
		score += b;
		b--;
	}
	if (a > b) {
		score += a;
		a--;
	}
	else {
		score += b;
		b--;
	}
	cout << score << endl;
}

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

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

const int MAX_M = 100000;

int N, M;
pair <int, int> p[MAX_M]; // bが先
int ans;
int islast;

void solve() {
	sort(p, p + M);
	REP(i, M) {
		if (ans && p[i].second < islast) continue;
		ans++;
		islast = p[i].first;
	}
	cout << ans << "\n";

	return;
}

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

	cin >> N >> M;
	REP(i, M) cin >> p[i].second >> p[i].first;

	solve();

	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <sstream>
using namespace std;

typedef long long int64;
const int inf = (int)1e9;

int lowerIdx(vector<int> &v, int x)
{
	return lower_bound(v.begin(), v.end(), x) - v.begin();
}

int upperIdx(vector<int> &v, int x)
{
	return upper_bound(v.begin(), v.end(), x) - v.begin();
}

void createPrimeTable(vector<int> &table, int maxNum)
{
	vector<bool> isPrime(maxNum + 1, true);

	isPrime[0] = isPrime[1] = false;

	for(int i = 2; i <= maxNum; ++i) {
		if(!isPrime[i])
			continue;
		for(int j = i * 2; j <= maxNum; j += i)
			isPrime[j] = false;
	}

	table.resize(0);
	table.reserve(sqrt(maxNum));
	for(int i = 0; i < maxNum + 1; ++i) {
		if(isPrime[i])
			table.push_back(i);
	}
}

int main()
{
	vector<int> prime;

	createPrimeTable(prime, 100000);

	while(true) {

		int m, a, b;

		scanf("%d%d%d", &m, &a, &b);
		if(m == 0)
			break;

		int pa = 0, qa = 0;

		for(int pidx = 0; prime[pidx] * prime[pidx] <= m; ++pidx) {

			int p = prime[pidx];

			int ub = prime.size() - 1;
			int lb = 0;

			// p * q <= m
			ub = min(ub, upperIdx(prime, m / p) - 1);

			// p / q <= 1
			lb = max(lb, pidx);

			// a / b <= p / q (q <= pb/a)
			ub = min(ub, upperIdx(prime, p * b / a) - 1);

			if(lb <= ub) {

				int q = prime[ub];
				if(p * q > pa * qa) {
					pa = p;
					qa = q;
				}
			}
		}

		printf("%d %d\n", pa, qa);
	}

	return 0;
}

/* ハラスメントに負けず */
/* 0完太陽にも負けず */
/* はやく人権を獲得したい */

Measured memory_bytes: 1296
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cout << v << " ";                                                          \
  }                                                                            \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int a, b;
  cin >> a >> b;
  int c = b - a;
  print(c * (c + 1) / 2 - b);
}

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

typedef long long ll;

 
int main(){
  int n;
  cin >> n;
  int ans=1;
  for(int i=0; i<10; i++){
    ans *= 2;
    if(n<ans){
      ans /= 2;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(){
	int H, W;
	cin >> H >> W;
	string T[50];
	const int dx[8] = {1,0,-1,0,1,-1,-1,1};
	const int dy[8] = {0,1,0,-1,1,1,-1,-1};
	for(int i=0; i<H; ++i){
		cin >> T[i];
	}
	for(int i=0; i<H; ++i){
		for(int j=0; j<W; ++j){
			int count = 0;
			if(T[i][j]=='.'){
				for(int n=0; n<8; ++n){
					const int ni = i + dy[n];
					const int nj = j + dx[n];
					if(ni<0 or H<=ni) continue;
					if(nj<0 or W<=nj) continue;
					if(T[ni][nj] == '#') count++;
				}
				T[i][j]=char(count + '0');
			}else{
				T[i][j]='#';
			}
		}
	}
	for (int i=0; i<H; ++i) cout << T[i] << endl;
	return 0;
}

Measured memory_bytes: 384
import math
from itertools import  accumulate
n = int(input())
tmp = n

sum = 0
a = 0
ans = []
for i in range(1,n+1):
    sum += i
    ans.append(i)
    if sum >= n:
        a = i
        break

d = sum - n
if d in ans:
    ans.remove(d)

for i in sorted(ans):
    print(i)

Measured memory_bytes: 9428
#!/usr/bin/env python3
from itertools import product
import sys


def solve(ABCD: str):
    A, B, C, D = ABCD
    for ops in product(["+", "-"], repeat=3):
        expr = "{1}{0[0]}{2}{0[1]}{3}{0[2]}{4}".format(ops, A, B, C, D)
        if eval(expr) == 7:
            print(expr + "=7")
            return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    ABCD = next(tokens)  # type: str
    solve(ABCD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    N, M = Scanner.map_int()

    class Edge():
        def __init__(self, a, b, c):
            self.from_ = a
            self.to_ = b
            self.cost_ = c
    edges = [Edge] * M
    for i in range(M):
        a, b, c = Scanner.map_int()
        a -= 1
        b -= 1
        c = -c
        edges[i] = Edge(a, b, c)
    dist = [INF] * N
    dist[0] = 0
    for loop in range(N-1):
        for i in range(M):
            e = edges[i]
            if dist[e.from_] == INF:
                continue
            if dist[e.to_] > dist[e.from_] + e.cost_:
                dist[e.to_] = dist[e.from_] + e.cost_
    ans = dist[N-1]
    negatives = [False] * N
    for loop in range(N):
        for i in range(M):
            e = edges[i]
            if dist[e.from_] == INF:
                continue
            if dist[e.to_] > dist[e.from_] + e.cost_:
                dist[e.to_] = dist[e.from_] + e.cost_
                negatives[e.to_] = True
            if negatives[e.from_]:
                negatives[e.to_] = True
    if negatives[N-1]:
        print("inf")
    else:
        print(-ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 43120
#include<iostream>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  for (int i = 0; i <= 1250; i++) {
    if ((int) (((double) i) * 0.08) == a && (int) (((double) i) * 0.1) == b) {
      cout << i;
      return 0;
    }
  }
  cout << -1;
}

Measured memory_bytes: 384