akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9+7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1e9+7

int main(){
    ll a,b,c; cin >> a >> b >> c;
    if(c-b==b-a) puts("YES");
    else puts("NO");
}


Measured memory_bytes: 256
a = list(map(int, input().split()))
a.sort()

def adder(a, index):
    cnt = 0
    while a[2] - a[index] > 1:
        a[index] += 2
        cnt += 1
    return cnt

cnt = 0
        
cnt += adder(a, 0)
cnt += adder(a, 1)

if(a[0] == a[1]):
    if(a[0] == a[2]):
        print(cnt)
    else:
        print(cnt + 1)
else:
    print(cnt + 2)

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long
// #define pow mypow

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;

int a;
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> a;
	cout << a + a*a + a*a*a << endl;
	
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;

ll int power(ll int x, ll int y, ll int p)  
{  
   ll int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
 
int main()
{
  fastio();
ll int T;
T=1;

while(T--)
{
ll int x;
cin>>x;
ll int i,j ,ans,ans1;
for(i=-1000;i<=1000;i++)
{
  for(j=-1000;j<=1000;j++)
  {
    if(i*i*i*i*i-j*j*j*j*j==x)
    {
      ans=i;ans1=j;
    }
  }

}
cout<<ans<<" "<<ans1<<endl;


}


    return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>
typedef long long ll;

using namespace std;
int fak(int x){
	if(x<1){
		return 1;
	}
	else{
		return x*fak(x-1);
	}
}
int main(){
	int n;
	cin>>n;
	int a[n],c[n];
	ll ans1=0,ans2=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		c[i]=a[i];
	}
	sort(c,c+n);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(a[i]==c[j]){
				ans1+=(j*(fak(n-1-i)));
				c[j]=9;
				sort(c,c+n);
				break;
			}
		}
	}
	for(int i=0;i<n;i++){
		cin>>a[i];
		c[i]=a[i];
	}
	sort(c,c+n);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(a[i]==c[j]){
				ans2+=(j*(fak(n-1-i)));
				c[j]=9;
				sort(c,c+n);
				break;
			}
		}
	}
	cout<<abs(ans1-ans2);
}



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

int main() {
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  
  long long Q;
  cin >> Q;
  vector<long long> B(Q), C(Q);
  for (int i=0; i<Q; i++) {
    cin >> B[i] >> C[i];
  }
  
  vector<long long> d(100000+1, 0);
  for (int i=0; i<N; i++) {
    d[A[i]]++;
  }
  
  long long sum = 0;
  for (int i=0; i<N; i++) {
    sum += A[i];
  }
  
  for (int i=0; i<Q; i++) {
    d[C[i]] += d[B[i]];
    sum = sum + (C[i] - B[i]) * d[B[i]];
    cout << sum << endl;
    d[B[i]] = 0;
  }
  
  return 0;
}

Measured memory_bytes: 6428
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = br.readLine();
		String[] nums = input.split(" ");
		int N = Integer.parseInt(nums[0]);
		int K = Integer.parseInt(nums[1]);
		int Q = Integer.parseInt(nums[2]);
		int[] decrement_scores = new int[N];
		for(int i = 0; i < N; i++){
			decrement_scores[i] = 0;
		}
		for(int i = 0; i < Q; i++){
			decrement_scores[Integer.parseInt(br.readLine())-1] += 1; 
		}

		//output Winner
		String reslut;
		for(int i = 0; i < N; i++){
			if(Q-decrement_scores[i] >= K){
				reslut = "No";
			} else {
				reslut = "Yes";
			}
			System.out.println(reslut);
		}
	}
}

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

struct Node {
	vector<int> c;
	int p, pre, low;
	bool flag = false;
};

int timer;

void dfs(vector<Node>& v, int n, int prev)
{
	//ノード n を訪問した直後の処理
	v[n].pre = v[n].low = timer;
	timer++;

	v[n].flag = true;

	int next;

	for (int i = 0; i < v[n].c.size(); i++)
	{
		next = v[n].c[i];
		if (!v[next].flag) {
			//ノード n からノード next へ訪問する直前の処理
			v[next].p = n;

			dfs(v, next, n);

			//ノード next の探索が終了した直後の処理
			v[n].low = min(v[n].low, v[next].low);
		} else if (next != prev) {
			//ノード next がBack-edge の場合の処理
			v[n].low = min(v[n].low, v[next].pre);
		}
	}
}

void articulationPoint(vector<Node>& v)
{
	timer = 1;

	// low の計算
	dfs(v, 0, -1);	// 0 == root

	set<int> ap;
	int np = 0;
	for (int i = 1; i < v.size(); i++)
	{
		int p = v[i].p;
		if (p == 0) np++;
		else if (v[p].pre <= v[i].low) ap.insert(p);
	}
	if (np > 1) ap.insert(0);
	for (set<int>::iterator it = ap.begin(); it != ap.end(); it++) cout << *it << endl;
}

int main(void)
{
	int V, E, s, t;
	cin >> V >> E;

	vector<Node> v(V);
	for (int i = 0; i < E; i++)
	{
		cin >> s >> t;
		v[s].c.push_back(t);
		v[t].c.push_back(s);
	}

	articulationPoint(v);

	return 0;
}


Measured memory_bytes: 4380
N = int(input())
A = [int(x) for x in input().split()]

val = {}
for a in A:
    if a not in val:
        val[a] = 0
    val[a] += 1

norm = sum(v * (v-1) // 2 for v in val.values())

for a in A:
    v = val[a]
    print(norm - v * (v-1) // 2 + (v-1) * (v-2) // 2)

Measured memory_bytes: 87884
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<vector>
#include<set>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
const int maxn=(int )2e5+50;
int n;
int a[maxn];
bool cz[maxn];
int ssd[maxn];
int main()
{
	int maxssd=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		
		if(cz[a[i]-1])
		{
			ssd[a[i]]=ssd[a[i]-1]+1;
		}else
		ssd[a[i]]=1;
		cz[a[i]]=true;
	}
	for(int i=1;i<=n;i++)
	maxssd=max(ssd[i],maxssd);
	cout<<n-maxssd<<endl;

}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=2e5;

int main(){
	int N;
	cin>>N;
	lli sum[MAX+1];
	sum[0]=0;
	rep1(i,N){
		lli x;
		cin>>x;
		sum[i]=sum[i-1]+x;
	}
	sort(sum,sum+N+1);
	lli ans=0;
	lli now=sum[0],same=1;
	rep1(i,N){
		if(now==sum[i]){
			ans+=same;
			same++;
		}
		else{
			same=1;
			now=sum[i];
		}
	}
	cout<<ans;
}

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

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

long long lcm(long long a, long long b) { 
  long long g = gcd(a, b);
  return a / g * b; }

int main() {
  int N;
  cin >> N;
  vector<long long> T(N);
  for (int i = 0; i < N; i++) {
    cin >> T.at(i);
  }
  long long aa = 1LL;
  for (int i = 0; i < T.size(); i++) {
    aa = lcm(T.at(i), aa);
  }
  cout << aa << endl;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

constexpr int powm(int a, int b, const int& m) {
  int c = 1;
  while (b) {
    if (odd(b)) c = (c * a) % m;
    b >>= 1;
    a = (a * a) % m;
  }
  return c;
}
struct modint {
  int v;
  modint(int a = 0)
    : v(((a % MOD) + MOD) % MOD) {
  }
  modint operator+(const modint& b) const {
    return (v + b.v) % MOD;
  }
  modint operator-(const modint& b) const {
    return (v - b.v + MOD) % MOD;
  }
  modint operator*(const modint& b) const {
    return (v * b.v) % MOD;
  }
  modint operator/(const modint& b) const {
    return (v * powm(b.v, MOD - 2, MOD)) % MOD;
  }
};
bool operator==(const modint& a, const modint& b) {
  return a.v == b.v;
}
modint& operator+=(modint& a, const modint& b) {
  return a = a + b;
}
modint& operator-=(modint& a, const modint& b) {
  return a = a - b;
}
modint& operator*=(modint& a, const modint& b) {
  return a = a * b;
}
modint& operator/=(modint& a, const modint& b) {
  return a = a / b;
}

ostream& operator<<(ostream& out, const modint& a) {
  return out << a.v;
}
istream& operator>>(istream& in, modint& a) {
  int v;
  in >> v;
  a = modint(v);
  return in;
}

void solve() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  vector<modint> factorial(h + w);
  factorial[0] = 1;
  loop(i, 1, factorial.size()) factorial[i] = modint(i) * factorial[i - 1];
  modint s = 0;
  loop(i, b, w) {
    modint x = 1;
    x *= factorial[h - a - 1 + i] / (factorial[h - a - 1] * factorial[i]);
    x *= factorial[w + a - 2 - i] / (factorial[a - 1] * factorial[w - 1 - i]);
    s += x;
  }
  cout << s << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
int search(int *,int,int);
int main(){
  int i,j,n,q,num=0;
  scanf("%d",&n);
  int S[n];
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  int T[q];
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    num += search(S,T[i],n);
  }
  printf("%d\n",num);
  return 0;
}

int search(int *S,int key,int n){
  int j;
  for(j=0;j<n;j++){
      if(key==S[j]){
	return 1;
      }
  }
  return 0;
}


Measured memory_bytes: 2088
import heapq

n,m = list(map(lambda x: int(x), input().split()))
goods = list(map(lambda x: int(x) * (-1), input().split()))

heapq.heapify(goods)

for i in range(m):
    highest = heapq.heappop(goods)
    if highest % 2 == 0:
        discount_price = highest//2
    else:
        discount_price = (highest//2) + 1
    heapq.heappush(goods, discount_price)
    
ans = 0
for p in goods:
    ans += p * (-1)
    
print(ans)

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

int main() {
  int n,m,c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for(int i=0;i<m;i++)
    cin >> b.at(i);
  vector<vector<int>> a(n,vector<int>(m));
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> a.at(i).at(j);
    }
  }
  int lsum = 0;
  int count = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      lsum += a.at(i).at(j) * b.at(j);
    }
    if( lsum + c > 0 )
      count++;
    lsum = 0;
  }
  cout << count <<endl;    
}


Measured memory_bytes: 3620
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Main {
      private static final Scanner scanner = new Scanner(System.in);
    public static void main(String[] args) {
     int n = scanner.nextInt();
      int d = scanner.nextInt();
      int x=2*d+1;int y=0;
      if(n%x==0)
        y=n/x;
      else
        y=n/x+1;
      System.out.print(y);
        

    }
}


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

int main(){
	int n;
	cin >> n;
	
	for(int i = 1; i <= n; i++){
		
		int zeikomi = i*1.08;
		if(zeikomi==n){
			cout << i << endl;
			return 0;
		}
	}
	
	cout << ":(" << endl;

	return 0;
}

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

vector<int> Adj[100005];
int N, u, v, A[100005], B[100005];

int C[100005],D[100005];
int used[100005];

void ASSIGN(int k, int num) {

	//cout << k << endl;
	C[k] = num; used[k] = 1;

	for (auto y : Adj[k]) {
		if (used[y] == 0) { ASSIGN(y, num + 1); }
	}

}

int ans;

void REC(int k, int num) {

	D[k] = num; used[k] = 1;

	for (auto y : Adj[k]) {
		if (used[y] == 0) { REC(y, num + 1); }
	}
}

int main(void) {

	
	//ifstream  ifs("path1_03");

	cin>> N >> u >> v;

	for (int i = 1; i <= N - 1; i++) {
		cin >> A[i] >> B[i];
		//cout << i << endl;
		Adj[A[i]].push_back(B[i]);
		Adj[B[i]].push_back(A[i]);
	}

	

	ASSIGN(v, 0);
	

	for (int i = 1; i <= N; i++) { used[i] = 0; }


	REC(u, 0);

	/*for (int i = 1; i <= N; i++) {
		cout << "C[" << i << "]= " << C[i] << endl;
	}*/

	for (int i = 1; i <= N; i++) {
		if (Adj[i].size() == 1) {
			if (D[i] < C[i]) { ans = max(ans, C[i] - 1); }
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10240
#include <stdio.h>

int main(void)
{
	int i,total=0,max=0;
	char s[4];
	scanf("%s",s);
	for(i=0;i<3;i++){
		if(s[i]=='R')total++;
		else{
			if(total>=max)max=total;
			total=0;
		}
	}
	if(total>max)max=total;
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)cin >> a[i];
    sort(ALL(a));

    ll ans = 0;
    rep(i, n/2)ans+=2*(a[n-1-i]-a[i]);
    if(n%2 == 0)ans+=a[n/2-1], ans-=a[n/2];
    else ans += max(a[n/2]-a[n/2+1], -a[n/2]+a[n/2-1]);
    
    cout << ans << endl;
}

Measured memory_bytes: 1024
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void calc(int sx, int sy, int tx, int ty) {

    void adv(char c, int step) { c.repeat(step).write; }
    void U(int step) { adv('U', step); }
    void D(int step) { adv('D', step); }
    void L(int step) { adv('L', step); }
    void R(int step) { adv('R', step); }

    int dx = tx - sx;
    int dy = ty - sy;

    R(dx);
    U(dy);
    L(dx);
    D(dy);

    D(1);
    R(dx + 1);
    U(dy + 1);
    L(1);
    U(1);
    L(dx + 1);
    D(dy + 1);
    R(1);

    writeln();
}

void main() {
    int sx, sy, tx, ty; scan(sx, sy, tx, ty);
    calc(sx, sy, tx, ty);
}


Measured memory_bytes: 256
s=input()
a=0
b=0
for i in range(len(s)):
    if i%2==0:
        if s[i]!="0":
            a+=1
    else:
        if s[i]!="1":
            a+=1
for i in range(len(s)):
    if i%2==1:
        if s[i]!="0":
            b+=1
    else:
        if s[i]!="1":
            b+=1
print(min(a,b))

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

typedef long long ll;

int main(){
    ll X, K, D;
    ll x, cnt;
    cin >> X >> K >> D;
    X = abs(X);
    if(X/D>K){
        cout << X-K*D << endl;
        return 0;
    }
    else{
        cnt = X/D;
        x = X-(cnt+1)*D;
    }
    if((K-cnt+1)%2) cout << abs(x+D) << endl;
    else cout << abs(x) << endl;
    return 0;
}


Measured memory_bytes: 3624
def check(h,w):
    if (h+w)%2==0:
        return'#'
    else:
        return'.'
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for h in range(H):
        for w in range(W):
            print(check(h,w),end='')
        print()
    print()


Measured memory_bytes: 7012
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner console = new Scanner(System.in);

        int totalRow = console.nextInt();
        int totalCol = console.nextInt();

        console.nextLine();

        int row = console.nextInt();
        int col = console.nextInt();

        int total = totalRow * totalCol;
        int black = (row * totalCol) + (col * totalRow) - (row * col);

        System.out.println(total - black);
    }
}


Measured memory_bytes: 35644
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt
from fractions import gcd
from itertools import permutations

def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas



N = intinput()
# S = input()
# A, B, C, D, E, F = mulinputs()
datas = list(mulinputs())
# datas = lineinputs(input)

M = 1001000
cnt = 0
l = len(datas)
# for i in range(0,N):
#     is_clear = True
#     for j in range(0,(i+1)>>1):
#         dp0 = datas[2*j] if 2*j < l else M
#         dp1 = datas[2*j+1] if 2*j < l else M
#         if dp0 < datas[i]:
#             is_clear = False
#             break
#         if dp1 < datas[i]:
#             is_clear = False
#             break
#     if is_clear:
#         cnt += 1
dmap = dict()
for i in range(1, len(datas)+1):
    dmap[datas[i-1]] = i
counter = N
for i in range(1, len(datas)+1):
    if dmap[i]-1 > counter:
        continue
    counter -= (counter - (dmap[i]-1))
    cnt +=1
    if counter <=0:
        break


# 出力
print(cnt)




Measured memory_bytes: 40024
p[]={-1,0,1,-2,2,-2,2,-2,2,-1,0,1};
P[]={-2,-2,-2,-1,-1,0,0,1,1,2,2,2};
s[]={-1,0,1,-1,0,1,-1,0,1};
S[]={-1,-1,-1,0,0,0,1,1,1};
m[10],M[10];
int D(x,y,d,n){
int i=0,j;
for(;i<12;i++)for(j=0;j<9;j++)if(
	x+p[i]==m[d]+s[j]&&y+P[i]==M[d]+S[j]&&
	0<=x+p[i]&&x+p[i]<10&&
	0<=y+P[i]&&y+P[i]<10
){
	if(d==n-1||D(x+p[i],y+P[i],d+1,n))return 1;
}
return 0;
}
main(X,Y,n,i,x,y){for(;scanf("%d%d%d",&X,&Y,&n)>2;puts(D(X,Y,0,n)?"OK":"NA"))for(i=0;i<n;i++)scanf("%d%d",m+i,M+i);exit(0);}

Measured memory_bytes: 584
N,A,B=map(int,input().split(" ")) 
if (B-A)%2==0:
    print(int(int(B-A)//2))
else:
    a1=int(min(N-A,B-1))
    a2=int(int(A-1)+1+int(B-A-1)//2)
    a3=int(int(N-B)+1+int(B-A-1)//2)
    print(min(a1,a2,a3))

Measured memory_bytes: 3064
test_case = gets.chomp.to_i
result_list_s = ["AC","WA","TLE","RE"]
result_list = []

loop {
  if test_case == 0
    break
  end
  result_list.push(gets.chomp)
  test_case -= 1
}

result_list_h = result_list.group_by(&:itself).map{ |k, v| [k, v.size] }.to_h

result_list_s.each do |i|
  if result_list_h["#{i}"].nil?
    puts "#{i} x 0"
  else
    puts "#{i} x #{result_list_h["#{i}"]}"
  end
end

Measured memory_bytes: 21920
/*
        Author: Prokash
                CSE48, JU

*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int ara[2005];
int main()
{
    FAST;
    int N,Y,taka,z=0;
    cin>>N>>Y;
    for(int x=0;x<=N;x++)
    {
        for(int y=0;x+y<=N;y++)
        {
            taka=Y-10000*x-5000*y;
        if(taka<0)
        {
            continue;
        }
        if(taka%1000!=0)
        {
            continue;
        }
        z=taka/1000;
        if(x+y+z==N)
        {
            cout<<x<<" "<<y<<" "<<z<<endl;
            return 0;
        }
    }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}

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

using namespace std;

constexpr int MAXLN = 1000000;

char N[MAXLN + 2];

int main() {
	cin >> (N + 1);
	N[0] = '0';
	int n = strlen(N);
	int dpa = 0, dpb = INT_MAX - 1;
	for(int i = n - 1; i >= 0; i--) {
		N[i] -= '0';
		int ndpa = N[i] + min(dpa, dpb + 1);
		int ndpb = 10 - N[i] + min(dpa, dpb - 1);
		dpa = ndpa; dpb = ndpb;
	}
	cout << dpa << '\n';
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fastio        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll            long long
#define fl            long double
#define pll           pair<ll,ll>
#define onebits(x)    __builtin_popcountll(x)
#define fbo(x)        find_by_order(x)
#define ook(x)        order_of_key(x)
#define pb            push_back
#define mk            make_pair
#define endl          "\n"
#define ff            first
#define ss            second
#define mt            make_tuple
#define np            next_permutation
#define pi            3.141592653589793238
#define deb(x)        cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define vll           vector<ll>
#define vp            vector<pair<ll,ll>>
#define all(x)        x.begin(),x.end()
#define rall(x)       x.rbegin(),x.rend()
#define revpq         priority_queue <int, vector<int>, greater<int>>
#define pq            priority_queue<ll>
#define ps(x,y)       fixed<<setprecision(y)<<x
const ll mod = 1e9 + 7;
const ll INF = 1e18;
const ll MAXN = 200005;
ll power(ll a, ll b) {ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) {if (b & 1)res = res * a % mod % mod; a = a * a % mod;} return res;}

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main()
{
    fastio;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll i, j, t, k, l, r, tp, n, m;
    ll h, w;
    cin >> h >> w;
    cin >> m;
    ll ch[h], cw[w];
    memset(ch, 0, sizeof(ch));
    memset(cw, 0, sizeof(cw));
    ll x[m], y[m];
    map<pair<ll, ll>, ll>mp;
    for (i = 0; i < m; i++)
    {
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
        mp[ {x[i], y[i]}]++;
        ch[x[i]]++;
        cw[y[i]]++;
    }
    ll ans = 0;
    ll mx = 0;
    for (i = 0; i < h; i++)
    {
        mx = max(ch[i], mx);
    }
    vll mh;
    for (i = 0; i < h; i++)
    {
        if (ch[i] == mx)
        {
            mh.pb(i);
        }
    }
    mx = 0;
    vll mw;
    for (i = 0; i < w; i++)
    {
        mx = max(mx, cw[i]);
    }
    for (i = 0; i < w; i++)
    {
        if (cw[i] == mx)
        {
            mw.pb(i);
        }
    }
    ll flg=0;
    for (auto x : mh)
    {
        for (auto y : mw)
        {
   			flg=0;
            tp = 0;
            tp += ch[x];
            tp += cw[y];
            if (mp[ {x, y}] > 0)
            {
                tp--;
                flg=1;
            }
            ans = max(ans, tp);
            if(flg==0)
            {
                cout<<ans<<endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 39676
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int n;
    cin >> n;
    int count[13];
    fill(count, count+13, 0);
    count[0] = 1;
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;
        count[d]++;
    }

    int ans = 0;
    for (int i = 0; i < 13; i++) {
        if (count[i] > 1 + (i != 0 && i != 12)) {
            ans = 24;
        }
    }

    for (int i = 0; i < (1 << 11); i++) {
        vector <int> d;
        d.push_back(0);
        d.push_back(24);
        if (count[12] == 1) {
            d.push_back(12);
        }

        for (int j = 1; j < 12; j++) {
            if (count[j] == 0) {
                continue;
            } else if (count[j] == 2) {
                d.push_back(j);
                d.push_back(24 - j);
            } else {
                if ((i >> (j-1)) & 1) {
                    d.push_back(j);
                } else {
                    d.push_back(24 - j);
                }
            }
        }

        int mn = 24;
        for (int j = 0; j < d.size(); j++) {
            for (int k = j+1; k < d.size(); k++) {
                mn = min(mn, abs(d[j] - d[k]));
            }
        }

        ans = max(ans, mn);
    }

    cout << ans % 24 << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int


// quoted from beet-aizu
template <typename T,typename E, typename F, typename G, typename H>
struct LazySegmentTree{
    //using F = function<T(T,T)>;
    //using G = function<T(T,E)>;
    //using H = function<E(E,E)>;
    int n,height;
    F f;
    G g;
    H h;
    T ti;
    E ei;
    vector<T> dat;
    vector<E> laz;
    LazySegmentTree(F f,G g,H h,T ti,E ei):
        f(f),g(g),h(h),ti(ti),ei(ei){}

    void init(int n_){
        n=1;height=0;
        while(n<n_) n<<=1,height++;
        dat.assign(2*n,ti);
        laz.assign(2*n,ei);
    }
    void build(const vector<T> &v){
        int n_=v.size();
        init(n_);
        for(int i=0;i<n_;i++) dat[n+i]=v[i];
        for(int i=n-1;i;i--)
            dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
    }
    inline T reflect(int k){
        return laz[k]==ei?dat[k]:g(dat[k],laz[k]);
    }
    inline void eval(int k){
        if(laz[k]==ei) return;
        laz[(k<<1)|0]=h(laz[(k<<1)|0],laz[k]);
        laz[(k<<1)|1]=h(laz[(k<<1)|1],laz[k]);
        dat[k]=reflect(k);
        laz[k]=ei;
    }
    inline void thrust(int k){
        for(int i=height;i;i--) eval(k>>i);
    }
    inline void recalc(int k){    
        while(k>>=1)
            dat[k]=f(reflect((k<<1)|0),reflect((k<<1)|1));
    }
    void update(int a,int b,E x){
        thrust(a+=n);
        thrust(b+=n-1);
        for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
            if(l&1) laz[l]=h(laz[l],x),l++;
            if(r&1) --r,laz[r]=h(laz[r],x);
        }
        recalc(a);
        recalc(b);
    }
    void set_val(int a,T x){
        thrust(a+=n);
        dat[a]=x;laz[a]=ei;
        recalc(a);
    }
    T query(int a,int b){
        thrust(a+=n);
        thrust(b+=n-1);
        T vl=ti,vr=ti;
        for(int l=a,r=b+1;l<r;l>>=1,r>>=1) {
            if(l&1) vl=f(vl,reflect(l++));
            if(r&1) vr=f(reflect(--r),vr);
        }
        return f(vl,vr);
    }
};

signed main(){
    
    int n, q; cin >> n >> q;
    auto f = [](int a, int b){ return a + b; };
    auto g = [](int a, int b){ return b != -1 ? b : a; };
    auto h = [](int a, int b){ return b != -1 ? b : a; };
    LazySegmentTree<int, int, decltype(f), decltype(g), decltype(h)> sg(f, g, h, 0, -1);
    sg.build(vector<int>(n, INT_MAX));
    
    for(int i = 0; i < q; i++){
        int com; cin >> com;
        if(!com){
            int s, t, x; cin >> s >> t >> x;
            sg.update(s, t + 1, x);
        }else{
            int idx; cin >> idx;
            cout << sg.query(idx, idx + 1) << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 7560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,i=0,t,m=0;
    cin>>a>>b>>c;
    vector<int>v;
    vector<int>v1;
    vector<int>w;
    for(int i=1;i<=a;i++)
    {
        if(a%i==0)
            v.push_back(i);
    }
    for(int j=1;j<=b;j++)
    {
        if(b%j==0)
            v1.push_back(j);
    }
    if(a>b)
    {
        while(i<v1.size())
        {
            v.push_back(v1[i]);
            i++;
        }
        sort(v.begin(),v.end());
        while(m<v.size())
        {
            if(v[m]==v[m+1])
            {
                w.push_back(v[m]);
            }
            m++;
        }
        cout<<w[w.size()-c]<<endl;
    }
    else
    {
        while(i<v.size())
        {
            v1.push_back(v[i]);
            i++;
        }
        sort(v1.begin(),v1.end());
        while(m<v1.size())
        {
            if(v1[m]==v1[m+1])
            {
                w.push_back(v1[m]);
            }
            m++;
        }
        cout<<w[w.size()-c]<<endl;
    }
}


Measured memory_bytes: 3604
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int a[3];
  std::cin >> a[0] >> a[1] >> a[2];
  sort(a,a+3);
  int b=a[2],c=a[0],d=a[1];
  int cnt=0;

  if((b%2==0 && c%2==0 && d%2==0) || (b%2==1 && c%2==1 && d%2==1)){
    while(b!=c){
      cnt++; c+=2;
    }
    while(b!=d){
      cnt++; d+=2;
    }
    std::cout << cnt << '\n';
    return 0;
  }
  else{
    cnt++;
    if((b%2 == c%2) && (b%2 != d%2)){
      b++; c++;
    }
    else if((b%2 == d%2) && (b%2 != c%2)){
      b++; d++;
    }
    else if((c%2 == d%2) && (b%2 != d%2)){
      c++; d++;
    }
    while(b!=c){
      c+=2;
      cnt++;
    }
    while(b!=d){
      d+=2;
      cnt++;
    }
  }
  std::cout << cnt << '\n';

  return 0;
}


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

struct edge {int to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
//static const int INF = 2147483647;
//static const int INf = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
static const int INF = 1000000000;
static const int NIL = -1;
static const int MOD = 1000000007;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define itn int
#define scnaf scanf
#define reutnr return
#define scamf scanf
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
//#define int ll

const int MAX = 114514;

int n,A[MAX],L[MAX];

int lis(){
    L[0] = A[0];
    int length = 1;

    for(int i=1;i<n;i++){
        if(L[length-1]<A[i]) L[length++] = A[i];
        else *lower_bound(L,L+length,A[i]) = A[i];
    }

    return length;
}

signed main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&A[i]);
    printf("%d\n",lis());
    return 0;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	vi p(a),q(b),r(c);
	rep(i,a) cin >> p[i];
	rep(j,b) cin >> q[j];
	rep(k,c) cin >> r[k];
	SORT(p);REV(p);
	SORT(q);REV(q);
	SORT(r);REV(r);
	priority_queue<int, vector<int>, greater<int> > pq,qq;	
	rep(i,x) pq.push(p[i]);
	rep(j,y) qq.push(q[j]);
	rep(k,c){
		int pi=pq.top();
		int qj=qq.top();
		if(pi<qj&&pi<r[k]){
			pq.pop();
			pq.push(r[k]);
		}
		if(pi>=qj&&qj<r[k]){
			qq.pop();
			qq.push(r[k]);
		}
	}
//	cout << endl;	
	ll ans = 0;
	while(pq.size()){
//		cout << pq.top() << " ";
		ans += pq.top();
		pq.pop();
	}
//	cout << endl;
	while(qq.size()){
//		cout << qq.top() << " ";		
		ans += qq.top();
		qq.pop();
	}
//	cout << endl;
	cout << ans << endl;
}


Measured memory_bytes: 2552
#include<stdio.h>

int main()
{
  int a,b;
  
  scanf("%d%d",&a,&b);
  
  int i,j;
  int count=0;
  
  for(i=1;i<a;i++)
  {
    for(j=1;j<=31;j++)
    {
      if(i==j)
      {
        count++;
      }
    }
  }
  
  if(a<=b)
  {
    count++;
  }
  
  printf("%d\n",count);
  
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
#define ll getchar();getchar();return 0;
	using namespace std;
	signed main(){
		int n,ans;
		cin >> n;
		for (int i = 1; i <= 100; i *= 2) {
			if (i > n) {
				ans = i;
				break;
			}
          else ans=128;
		}
		cout << ans/2 << endl;
		ll
}

Measured memory_bytes: 256
N = int(input())
s_dict = {}

for _ in range(N):
    s = input()
    if s not in s_dict:
        s_dict[s] = 1
    else:
        s_dict[s] += 1

max_ = max(s_dict.values())
ans = []

for key in s_dict.keys():
    if s_dict[key] == max_:
       ans.append(key)
    else:
        continue

ans.sort()
for i in ans:
    print(i) 


Measured memory_bytes: 32096
#include<bits/stdc++.h>
using namespace std;
#define ALL(A) A.begin(),A.end()
const long long mod=1000000007;
int main(){
    long long n,a[5];
    cin>>n;
    for(int i=0;i<5;i++)
    cin>>a[i];

    long long m=min({a[0],a[1],a[2],a[3],a[4]});
    cout<<((m+n-1)/m)+4<<endl;
    return 0;
}

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

int main() {
  int n, t;
  cin >> n >> t;
  
  pair<int, int> ans = {0, 0};

  int mn;
  cin >> mn;
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    if (ans.first < a - mn) {
      ans.first = a - mn;
      ans.second = 0;
    }
    if (ans.first == a - mn) {
      ans.second++;
    }
    mn = min(mn, a);
  }
  
  cout << ans.second << "\n";
  return 0;
}


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

using namespace std;

int main()
{
    int m;

    cin >> m;

    while(m!=0) {
        int n;
        int x,y;
        int dx,dy;
        set<pair<int,int> > target;
        set<pair<int,int> > stars;

        for(int i=0; i<m; ++i) {
            cin >> x >> y;
            target.insert({x,y});
        }

        cin >> n;

        for(int i=0; i<n; ++i) {
            cin >> x >> y;
            stars.insert({x,y});
        }

        for(set<pair<int,int> >::iterator itr_s=stars.begin(); itr_s!=stars.end(); ++itr_s) {
            int temp;
            set<pair<int,int> >::iterator itr_t=target.begin();
            dx=itr_s->first-itr_t->first; dy=itr_s->second-itr_t->second;
            ++itr_t;
            while(itr_t!=target.end()) {
                temp=stars.count({itr_t->first+dx,itr_t->second+dy});
                if(temp==0) break;
                ++itr_t;
            }
            if(temp==1) break;
        }

        cout << dx << " " << dy << endl;

        cin >> m;
    }
    return 0;
}

Measured memory_bytes: 3152
#include <stdio.h>
#include <math.h>
int main(void){
  int n,m,x,i;
  int a[110],cost[110]={0},sum1=0,sum2=0;
  scanf("%d%d%d",&n,&m,&x);
  for(i=0;i<m;i++) {
    scanf("%d",&a[i]);
    cost[a[i]]=1;
  }
  for(i=x;i<n;i++){
    if(cost[i]==1) sum1++;
  }
  for(i=x;i>0;i--){
    if(cost[i]==1) sum2++;
  }
  int ans=fmin(sum2,sum1);
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

typedef long long TI;

std::vector<TI> cdp(std::vector<TI> A, TI S, TI m, TI Mod) {
  TI N = A.size();
  auto dp = std::vector< std::vector<TI> >(N+1);
  for(TI i=0; i <= N; ++i) {
    dp[i] = std::vector<TI>(S+1, 0);
  }
  dp[0][0] = 1;
  TI t = 0;
  for(TI i = 0; i < N; ++i) {
    auto a = A[i];
    for(TI s = 0; s <= t; ++s) {
      auto n = dp[i][s];
      dp[i+1][s+a] = (dp[i+1][s+a] + n) % Mod;
      dp[i+1][s  ] = (dp[i+1][s] + m*n) % Mod;
    }
    t += a;
  }
  return dp[N];
}

int main() {
  TI Mod = 998244353;
  TI N;
  std::vector<TI> A;
  std::cin >> N;
  for(TI i=0; i<N; ++i) {
    TI a; std::cin >> a;
    A.push_back(a);
  }
  TI Z = 1;
  TI S = 0;
  for (TI i=0; i<N; ++i) { 
    Z = Z * 3 % Mod; 
    S += A[i];
  }
  auto D1 = cdp(A, S, 2, Mod);
  TI X = 0;
  for (TI s = (S+1)/2; s <= S; ++s) {
    X = (X + D1[s]) % Mod;
  }
  TI Y = 0;
  if (S % 2 == 0) {
    Y = cdp(A, S, 1, Mod)[S/2] % Mod;
  }
  auto ans = Z - 3*(X-Y);
  while (ans < 0) {
    ans += Mod;
  }
  ans %= Mod;
  std::cout << ans << std::endl;
}


Measured memory_bytes: 212864
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;

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

    int a[M],b[M]; 
    P war[M];
    for(int i=0;i<M;i++){
      cin >> a[i] >> b[i];
      war[i] = make_pair(b[i],a[i]);
    }
    sort(war, war+M);


    int ans = 1;
    int cut = war[0].first;
    int i = 1;
    while(i<M){
      if(war[i].second>=cut){
        cut = war[i].first;
        ans++;
      }
      i++;
    }

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



Measured memory_bytes: 1792
import sys;n,m=input().split();m=int(m);a=[];i=n=c=0;a=sorted(tuple(map(int,e.split()))for e in sys.stdin)
while m>0:c+=a[i][0]*a[i][1];m-=a[i][1];i+=1
print(c+m*a[~-i][0])

Measured memory_bytes: 16888
#include <iostream>

int main() {
	using namespace std;
	int n, r, hyo;
	cin >> n >> r;
	if (n < 10) {
		hyo = 100 * (10 - n) + r;

	}
	else {
		hyo = r;
	}
	cout << hyo << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
typedef long long ll;

const int MOD = 1e9+7;

ll modPow(ll a,ll b){
    ll res = 1;

    while(b){
        if(b&1){
            res = (res*a)%MOD;
        }
        a = (a*a)%MOD;
        b >>= 1;
    }
    return res;
}

ll solve(ll n){
   return ((modPow(10,n)+modPow(8,n)-2*modPow(9,n))%MOD+MOD)%MOD;
}

int main()
{
    ll n;
    cin>>n;
    
    cout<<solve(n)<<endl;
    return 0;
}

Measured memory_bytes: 3184
# coding: utf-8
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
VC = []
for i in range(N):
    VC.append(V[i] -  C[i])
ans = 0
for j in VC:
    if j > 0:
        ans+=j
print(ans)

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

using namespace std;

int tv[33][101010];

int main() {
  int n, c;
  cin >> n >> c;
  vector<int> s(n), t(n), ch(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> t[i] >> ch[i];
    ch[i]--;
  }
  for (int i = 0; i < n; i++) {
    tv[ch[i]][s[i]]++;
    tv[ch[i]][t[i]]--;
  }
  int use = 0, fr = 0;
  for (int i = 0; i < 100010; i++) {
    for (int j = 0; j < c; j++) {
      if (fr == 0 && tv[j][i] == 1) {
        use++;
      } else if (0 < fr && tv[j][i] == 1) {
        fr--;
        use++;
      }
    }
    for (int j = 0; j < c; j++) {
      if (tv[j][i] == -1) {
        fr++;
        use--;
      }
    }
  }
  cout << fr << endl;

  return 0;
}

Measured memory_bytes: 13696
#include<bits/stdc++.h>
using namespace std;
int main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
 long int n,k;
 cin>>n>>k;
 cout<<((int)(log(n)/log(k))+1);
 return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const int N = 300005;

vi adj[N];
int see[N];

int dfs(int x){
	see[x] = 1;
	int ans = 1;
	for(auto i:adj[x])
		if(!see[i])
			ans += dfs(i);
	return ans;
}

int main(){
	fastio;
	int n,m;
	cin >> n >> m;
	while(m--){
		int a,b; cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(!see[i]){
			ans = max(ans, dfs(i));	
		}
	}
	cout << ans << '\n';
	return 0;
}


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

int main()
{
	int n, m, c;
	long s = 0;
	priority_queue <int, vector<int>, greater<int> > d;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> m;
	
		for (int j = 0; j < m; j++) {
			cin >> c;
			d.push(c);
		}

		while(d.size() > i + 1)
			d.pop();
	}

	for (int i = 0; i < n; i++) {
		s += d.top();
		d.pop();
	}

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 4916
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL P = ((1LL << 30) + 1);
const LL N = 1234567891;
const LL N2 = 1000000009;

LL a[2000005],b[2000005],c[2000005],d[2000005];
LL pc[2000005],pd[2000005],pwr[2000005],pc2[2000005],pd2[2000005],pwr2[2000005];
LL n,m;

LL judge(LL l,LL r){
	return (pc[n - 1] == (pd[r] - (pd[l - 1] * pwr[r - l + 1] % N) + N) % N) && (pc2[n - 1] == (pd2[r] - (pd2[l - 1] * pwr2[r - l + 1] % N2) + N2) % N2);
}

int main(){
	ios::sync_with_stdio(false);
	pwr[0] = 1; for(LL i = 1;i <= 200000;i ++) pwr[i] = (pwr[i - 1] * P) % N;
	pwr2[0] = 1; for(LL i = 1;i <= 200000;i ++) pwr2[i] = (pwr2[i - 1] * P) % N2;
	cin >> n;
	for(LL i = 1;i <= n;i ++) cin >> a[i];
	for(LL i = 1;i <= n;i ++) cin >> b[i];
	for(LL i = n + 1;i <= (n << 1);i ++) b[i] = b[i - n];
	
	for(LL i = 1;i < n;i ++) c[i] = a[i] ^ a[i + 1];
	for(LL i = 1;i < (n << 1);i ++) d[i] = b[i] ^ b[i + 1];
	
	for(LL i = 1;i < n;i ++) pc[i] = (pc[i - 1] * P + c[i]) % N;
	for(LL i = 1;i < (n << 1);i ++) pd[i] = (pd[i - 1] * P + d[i]) % N;
	for(LL i = 1;i < n;i ++) pc2[i] = (pc2[i - 1] * P + c[i]) % N2;
	for(LL i = 1;i < (n << 1);i ++) pd2[i] = (pd2[i - 1] * P + d[i]) % N2;
	
	for(LL i = n + 1;i >= 2;i --){
		if(judge(i,i + n - 2))
			cout << (n + 1 - i) << ' ' << (a[n + 2 - i] ^ b[1]) << endl;
	}
	return 0;
} 

Measured memory_bytes: 45952
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) < (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL

struct Edge {
	int from, to;
	ll w;
};
typedef vector<vector<Edge>> Graph;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}

ll gettugibaisu(ll from, ll k) {

	ll ret = ((from + k - 1) / k) * k;

	return ret;
}

ll getmaebaisu(ll to, ll k) {

	ll ret = (to / k) * k;

	return ret;
}


signed main(void) {

	int n;
	cin >> n;
	vector<int> d(n);
	vector<pii> tl;
	REP(i, n) {
		cin >> d[i];
		if (d[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}

	REP(i, n) {
		tl.push_back({ d[i], i + 1 });
			tl.push_back({24 - d[i], -(i + 1)});
		}
	

	sort(ALL(tl));

	if (n >= 24) {
		cout << 0 << endl;
		return 0;
	}
	int Max = 0;
	int tori = pow(2, n);
	REP(i, tori) {
		int Min = 300;
		int bef = 0;
		int ar[24] = {};
		int buf = i;
		REP(j, n) {
			ar[j] = buf & 1;
			buf >>= 1;
		}

		for (auto itr : tl) {
			if (itr.second > 0) {
				if (ar[itr.second - 1] == 0) {
					Min = min(Min, itr.first - bef);
					bef = itr.first;
				}
			}
			else {
				if (ar[-itr.second - 1] == 1) {
					Min = min(Min, itr.first - bef);
					bef = itr.first;
				}
			}
		}
		Min = min(Min, 24 - bef);
		Max = max(Max, Min);
	}
	
	cout << Max << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;
#define int ll

ll n, m;
ll a[500][500];
ll b[500];

signed main()
{
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            int c;
            cin >> c;
            c--;
            a[i][c] = 1;
        }
    }
    for (int i = 0; i < m; i++)
    {
        cin >> b[i];
    }
    ll ans = 0;
    for (int i = 0; i < (1 << n); i++)
    {
        int t = 1;
        for (int j = 0; j < m; j++)
        {
            int cnt = b[j];
            for (int k = 0; k < n; k++)
            {
                if (a[j][k] && ((1 << k) & i))
                    cnt++;
            }
            if (cnt % 2 == 1)
                t = 0;
        }
        ans += t;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,s=0,max=0;
	cin>>n;
	char a;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		if(a=='I') s++;
		else s--;
		if(max<s) max=s;
	}
	cout<<max;
}

Measured memory_bytes: 256