akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,m;
    cin >> n >> m;
   vector<vector<pair<ll,ll>>> graph(n);
    for(i = 0;i < n-1;++i){
        graph.at(i+1).emplace_back(0,i);
    }
    for(i = 0;i < m;++i){
        ll l,r,c;
        cin >> l >> r >> c;
        --l;    --r;
        graph.at(l).emplace_back(c,r);
    }
    ll v = n;
    ll INF = 1e14;
    priority_queue<pair<ll,ll>> pq; //優先度付きキュー
    vector<ll> vdist(v,INF); //距離
    ll top = 0; //開始点
    vdist.at(top) = 0;
    pq.emplace(0, top);
    while(!pq.empty()){
        auto x = pq.top();
        pq.pop();
        ll now = x.second;
        ll dist = -x.first;
        if(vdist.at(now) < dist) continue;
        for(i = 0;i < graph.at(now).size();++i){
            ll next = graph.at(now).at(i).second;
            ll nd = dist + graph.at(now).at(i).first;
            if(vdist.at(next) > nd){
                vdist.at(next) = nd;
                pq.emplace(-nd, next);
            }
        }
    }
    if(vdist.at(n-1) == INF) cout << -1 << endl;
    else cout << vdist.at(n-1) << endl;
    return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll a,b,c,d,e;
    string S;
    cin >> a>>b>>c>>d>>e;

    ll tmp = a + b + c + d + e;
    cout << 15 - tmp << endl;


}


Measured memory_bytes: 3596
N = int(input())
arr = map(int, input().split())
max_abs = -1
max_val = 0
max_arg = 0
for i, v in enumerate(arr):
    if abs(v) >= max_abs:
        max_abs = abs(v)
        max_arg = i
        max_val = v
print(2*N-2)
if max_val >= 0:
    for i in range(1, max_arg+1):
        print(max_arg+1, i)
    for i in range(max_arg+2, N+1):
        print(max_arg+1, i)
    for i in range(1, N):
        print(i, i+1)
else:
    for i in range(1, max_arg+1):
        print(max_arg+1, i)
    for i in range(max_arg+2, N+1):
        print(max_arg+1, i)
    for i in range(N-1, 0, -1):
        print(i+1, i)

Measured memory_bytes: 3192
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#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=;

int main(){
	int N;
	cin>>N;
	int x[100],y[100],h[100];
	rep(i,N)cin>>x[i]>>y[i]>>h[i];
	
	int hmx=1;
	rep(i,N)hmx=max(hmx,h[i]);
  
  
	int ansx,ansy,ansh;
	rep(k,2*101){
		bool fin=false;
		rep(i,101*101){
			int px=i%101,py=i/101;
			bool pyr=true;
			rep(l,N){
				if(max(hmx+k-abs(px-x[l])-abs(py-y[l]),0)!=h[l]){
					pyr=false;
					break;
				}
			}
			if(pyr){
				fin=true;
				ansx=px;
				ansy=py;
				ansh=hmx+k;
				break;
			}
		}
		if(fin)break;
	}
	cout<<ansx<<" "<<ansy<<" "<<ansh;
	
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };

        
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var cin = new Scanner();

            var input = cin.SplitRead();
            int N = input[0];
            int M = input[1];
            int Q = input[2];
            var map = new long[N, N];
            for(var i = 0; i < N; i++)
            {
                for(var j = 0; j < N; j++)
                {
                    map[i, j] = 0;
                }
            }

            for(var i = 0; i < M; i++)
            {
                var tr = cin.SplitRead();
                map[tr[0] - 1, tr[1] - 1]++;
            }

            var d = new long[N + 1, N + 1];
            for(var i = 0; i <= N; i++)
            {
                d[0, i] = 0;
                d[i, 0] = 0;
            }

            for(var i = 1; i <= N; i++)
            {
                for(var j = 1; j <= N; j++)
                {
                    d[i, j] = d[i - 1, j] + d[i, j - 1] - d[i - 1, j - 1] + map[i - 1, j - 1];
                }
            }

            for(var i = 0; i < Q; i++)
            {
                var p = cin.SplitRead();
                int l = p[0];
                int r = p[1];
                Console.WriteLine(d[r, r] - d[l - 1, r] - d[r, l - 1] + d[l - 1, l - 1]);
            }

            
            Console.Out.Flush();
        }

    }

   

    

    

    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }
}


Measured memory_bytes: 21264
import math
H = [0,0]
M = [0,0]
a, b, h, m =map(int,input().split())
mrad = -m * math.pi / 30
hrad = -(h + m/60 ) * math.pi / 6
H[0] = a * math.cos(hrad)
H[1] = a * math.sin(hrad)
M[0] = b * math.cos(mrad)
M[1] = b * math.sin(mrad)
ans = math.sqrt((H[0] -M[0])**2 + (H[1] -M[1])**2)
print(ans)

Measured memory_bytes: 9544
N,M=list(map(int,input().split()))
pref=[[] for i in range(N)]
for i in range(M):
    P,Y=list(map(int,input().split()))
    pref[P-1].append((i+1,Y))
ans=['' for i in range(M)]
for i in range(N):
    arr=sorted(pref[i],key=lambda x:x[1])
    for j,x in enumerate(arr):
        ans[x[0]-1]='{0:06d}{1:06d}'.format(i+1,j+1)
for x in ans:
    print(x)


Measured memory_bytes: 42160
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main() {
  LL L, R;
  cin >> L >> R;
  LL ans = 0;
  if (L - R < 673) {
    ans = 2018;
    for (LL i = L; i < R; i++) {
      for (LL j = i + 1; j <= R; j++) {
        ans = min(ans, (i * j % 2019));
         if(ans == 0) {
                cout << 0 << endl;
                return 0;
         }
      }
    }
  }
  cout << ans << endl;
}


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

int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, char>> a(m);
  for(auto& i : a){
    cin >> i.first >> i.second;
    i.first--;
  }
  for(int i = 0; i < 1000; i++){
    string s = to_string(i);
    if(s.size() != n) continue;
    if(any_of(a.begin(), a.end(), [&](auto p){ return s[p.first] != p.second; })) continue;
    cout << s << endl;
    return 0;
  }
  cout << -1 << endl;
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

typedef long long ll;
typedef pair<int,int> pii;

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 109, M = 1e5 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int n, cap, w[N], v[N];

ll dp[N][M];

ll solve(int i, int rem){
    if(rem < 0) return llOO;
    if(i == n)  return (rem == 0 ? 0 : llOO);

    ll &ret = dp[i][rem];
    if(~ret)    return ret;

    return ret = min(solve(i + 1, rem), w[i] + solve(i + 1, rem - v[i]));
}

int main(){
    init();

    cin >> n >> cap;
    for(int i = 0;i < n;i++)
        cin >> w[i] >> v[i];

    memset(dp, -1, sizeof dp);
    for(int i = 1e5;i >= 0;i--){
        ll ans = solve(0, i);
        if(ans <= cap)
            return cout << i, 0;
    }
}


Measured memory_bytes: 85376
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;


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

ll lcm(ll a, ll b) {
	if (a == 0 || b == 0) return 0;
	ll g = gcd(a, b);
	//先にa*bを計算するとオーバーフローする
	return (a / g) * b;
}






int main(){
	int n;
	cin >> n;
	vector<ll>v(n);
	rep(i, 0, n) {
		cin >> v[i];
	}

	ll ans = v[0];
	rep(i, 1, n) {
		ans = lcm(ans, v[i]);
	}

	cout << ans << endl;



	
	return 0;
}



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

int main() {
    int n;
    cin >> n;
    int ans = 0;
    rep(i,n) {
        int a;
        cin >> a;
        ans += a-1;
    }
    cout << ans << endl;
} 

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int i ,a[10000], c;
    
    
    for(i=0;i<10000;i++){
    	scanf("%d",&a[i]);
    	if(a[i]==0){
    		break;
    	}
    }
    c = i;
    
    for(i=0;i<c;i++){
    	printf("Case %d: %d\n",i+1 ,a[i]);
    }
    return 0;
}

Measured memory_bytes: 636
<?php
fscanf(STDIN, '%d', $X);
define('C', 72);
define('MMIN', $X);
define('MMAX', $X + C);
$a = array_pad(array(), MMAX + 1, 1);
$a[0] = 0;
$a[1] = 0;
for ($i = 2; $i <= sqrt(MMAX); $i++) {
    $l = max(2, intdiv(MMIN, $i));
    for ($j = $l; $j <= MMAX / $i; $j++) {
        $a[$i * $j] = 0;
    }
}
$mmax = 0;
$prev = null;
for ($i = MMIN; $i <= MMAX; $i++) {
    if ($a[$i] === 1) {
        echo $i;
        break;
    }
}


Measured memory_bytes: 8696
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, S: "List[str]"):
    p = []
    count = {}
    for i, s in enumerate(S):
        s = list(s)
        s.sort()
        s = ''.join(s)
        if s in count:
            count[s] += 1
        else:
            count[s] = 1
        p.append(s)
    ret = 0
    #for v in p:
    #    print(count[s])
    #    ret += len(count[s])
    for c in count.values():
        ret += c * (c - 1) // 2
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [ next(tokens) for _ in range(N) ]  # type: "List[str]"
    solve(N, s)

if __name__ == '__main__':
    main()


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

int main()
{
    int N, u, v;
    cin >> N >> u >> v;
    u--;
    v--;

    vector<vector<int>> tree(N);
    for (int i = 0; i < N - 1; i++)
    {
        int Ai, Bi;
        cin >> Ai >> Bi;
        Ai--;
        Bi--;
        tree.at(Ai).push_back(Bi);
        tree.at(Bi).push_back(Ai);
    }

    vector<int> aok(N, -1);
    aok.at(v) = 0;
    stack<pair<int, int>> s;
    s.push(make_pair(v, 0));
    while (!s.empty())
    {
        int n = s.top().first, d = s.top().second;
        s.pop();

        for (auto m : tree.at(n))
        {
            if (aok.at(m) >= 0)
            {
                continue;
            }
            aok.at(m) = d + 1;
            s.push(make_pair(m, d + 1));
        }
    }

    vector<int> tak(N, -1);
    tak.at(u) = 0;
    s = stack<pair<int, int>>();
    s.push(make_pair(u, 0));
    int res = 0;
    while (!s.empty())
    {
        int n = s.top().first, d = s.top().second;
        s.pop();

        if (aok.at(n) > d)
        {
            res = max(res, aok.at(n) - 1);
        }

        for (auto m : tree.at(n))
        {
            if (tak.at(m) >= 0)
            {
                continue;
            }
            tak.at(m) = d + 1;
            s.push(make_pair(m, d + 1));
        }
    }
    cout << res << endl;
}

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

int main(){
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  int p = min(K,A);
  if(K-A-B > 0){
    p -= min(K-A-B,C);
  }
  cout << p << endl;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
 
int main(){
    int a,b,c,buf;
    cin >> a >> b >> c;
    if(a>b){
        buf=a;
        a=b;
        b=buf;
    }
    if(b>c){
        buf=b;
        b=c;
        c=buf;
    }
    if(a>b){
        buf=a;
        a=b;
        b=buf;
    }
    cout << a << " "<< b << " " << c << endl;
     
    return 0;
}    


Measured memory_bytes: 3092
n,m,x=map(int,input().split())
a=[list(map(int, input().split())) for i in range(n)]
bb=[0]*m
c=[]
cc=0
for i in range(n):
    cc+=a[i][0]
for i in range(m):
    for j in range(n):
        bb[i]+=a[j][i+1]
if any(bb[k]< x for k in range(m)):
  print(-1)
"""
d=[[] for i in range(m)]
money=0
i=0
def func(i,):
    if i==m:
        sum
        return money
    if func(i+1,money):
        return true
"""
def dec2bin(target):
    amari=[]
    while target !=0:
        amari.append(target % 2)
        target = target //2
    if len(amari)!=n:
        while len(amari)!=n:
            amari.append(0)
    amari.reverse()
    return amari
p=[]
for j in range(2**n):
    p.append(dec2bin(j))
for i in range(2**n):
    money=0
    b=[0]*m
    for j in range(n):
        if p[i][j]==1:
            money+=a[j][0]
            for aaa in range(m):
                b[aaa]+=a[j][aaa+1]
    if all(b[l]>=x for l in range(m)):
        c.append(money)

        
if len(c)>0:
  print(min(c))

        
            


Measured memory_bytes: 69740
#include <stdio.h>

int main(void)
{
    int n;
    int num[32];
    int fish[32];
    int maxi;
    int i;

    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d %d", &num[i], &fish[i]);
    }
    maxi = 0;
    for (i = 1; i < n; i++){
        if (fish[maxi] < fish[i]){
            maxi = i;
        }
        else if (fish[maxi] == fish[i] && num[maxi] > num[i]){
            maxi = i;
        }
    }

    printf("%d %d\n", num[maxi], fish[maxi]);

    return (0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
int n,i,j,k,a[3][100005],flag0,flag1,sum0,sum1,zhan1[100005],zhan0[100005],top1,top0,b[100005];
void gb1(int u,int v){
	int mid=(u+v>>1),i=u,j=mid+1,k=u;
	if(u==v)
		return;
	gb1(u,mid);
	gb1(mid+1,v);
	while(i<=mid&&j<=v){
		if(zhan1[i]<zhan1[j]){
			b[k]=zhan1[i];
			i++;
			k++;
		}
		else{
			b[k]=zhan1[j];
			j++;
			k++;
			sum1+=mid-i+1;
		}
	}
	while(i<=mid){
		b[k]=zhan1[i];
		i++;
		k++;
	}
	while(j<=v){
		b[k]=zhan1[j];
		j++;
		k++;
	}
	for(i=u;i<=v;i++)
		zhan1[i]=b[i];
	return;
}
void gb2(int u,int v){
	int mid=(u+v>>1),i=u,j=mid+1,k=u;
	if(u==v)
		return;
	gb2(u,mid);
	gb2(mid+1,v);
	while(i<=mid&&j<=v){
		if(zhan0[i]<zhan0[j]){
			b[k]=zhan0[i];
			i++;
			k++;
		}
		else{
			b[k]=zhan0[j];
			j++;
			k++;
			sum0+=mid-i+1;
		}
	}
	while(i<=mid){
		b[k]=zhan0[i];
		i++;
		k++;
	}
	while(j<=v){
		b[k]=zhan0[j];
		j++;
		k++;
	}
	for(i=u;i<=v;i++)
		zhan0[i]=b[i];
	return;
}
int main(){
	n=read();
	for(i=0;i<=2;i++)
		for(j=1;j<=n;j++)
			a[i][j]=read()-1;
	for(j=1;j<=n;j++){
		if(a[0][j]/3==a[1][j]/3&&a[1][j]/3==a[2][j]/3&&
		(a[0][j]==a[1][j]+1&&a[1][j]==a[2][j]+1||
		 a[0][j]==a[1][j]-1&&a[1][j]==a[2][j]-1)){
			if(((a[0][j]/3)&1)&&(j&1)){
				printf("No\n");
				return 0;
			}
			else{
				if(a[0][j]%3!=0){
					if(j&1)
						flag1^=1;
					else
						flag0^=1;
				}
			}
		}
		else{
			printf("No\n");
			return 0;
		}
		if(j&1){
			top1++;
			zhan1[top1]=a[0][j]/3;
		}
		else{
			top0++;
			zhan0[top0]=a[0][j]/3;
		}
	}
	gb1(1,top1);
	gb2(1,top0);
	sum1&=1;
	sum0&=1;
	if((flag0^sum1)==0&&(flag1^sum0)==0)
		printf("Yes\n");
   	else
   		printf("No\n");
   	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
#define rep(i,n) for(int i = 0;i<n;i++)

int main(){
	int n,k;
	cin >> n >> k;
	vector<bool> sunuke(n+1,0);
	sunuke[0] = 1;

	rep(i,k){
		int d;
		cin >> d;
		rep(j,d){
			int a;
			cin >> a;
			sunuke[a] = 1;
		}
	}
	int count = 0;
	rep(i,n+1){
		if(sunuke[i] == 0)count++; 
	}
	cout << count << endl;

	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> X;
    ll normal = 0;
    for (int i = 0; i < N; ++i)
    {
        int temp;
        cin >> temp;
        X.push_back(temp);
        normal += temp;
    }
    normal = normal / N;
    ll p1 = normal;
    ll p2 = p1 + 1;
    ll ans1 = 0;
    ll ans2 = 0;
    for (int i = 0; i < N; ++i)
    {
        ans1 += (X[i] - p1) * (X[i] - p1);
    }

    for (int i = 0; i < N; ++i)
    {
        ans2 += (X[i] - p2) * (X[i] - p2);
    }

    cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int max = Math.min(a, b);
		int min =(Math.max(a, b) + Math.min(a, b)) - n;
		if(min < 0){
			min = 0;
		}
		System.out.println(max+" "+min);
		

		

		
	}
	
}



class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



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

using pint = pair<int,int>;

int n, m;

vector<int> a;
vector<pint> cb;

int main() {
    cin >> n >> m;

    a.resize(n);
    cb.resize(m);

    for (int i = 0; i < n; ++i) cin >> a.at(i);
    for (int i = 0; i < m; ++i) cin >> cb.at(i).second >> cb.at(i).first;

    sort(a.begin(), a.end());
    sort(cb.begin(), cb.end(), greater<pint>());

    int l = 0, r;
    for (int i = 0; i < m; ++i)
    {
        r = min(l + cb.at(i).second, n);

        for (int j = l; j < r; ++j)
        {
            if (a.at(j) >= cb.at(i).first) {
                r = j;
                break;
            }
            a.at(j) = cb.at(i).first;
        }
        l = r;
    }

    long int ans=0;
    for (int i = 0; i < n; ++i) ans += a.at(i);

    cout << ans << endl;
}


Measured memory_bytes: 1408
def xor(x, y):
    return (x | y) - (x & y)

def get_res(x):
    if x % 4 == 0:
        return x
    elif x % 4 == 1:
        return 1
    elif x % 4 == 2:
        return x + 1
    else:
        return 0

def main():
    A, B = map(int, input().split(' '))

    res_A = get_res(A - 1) if A > 0 else 0
    res_B = get_res(B)
    print(xor(res_A, res_B))    

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    queue<string> que;
    que.push("a");
    while(true){
        string s = que.front();
        if(s.size() == n)break;
        que.pop();
        char i = 'a';
        char r ='a'; rep(j,s.size())r = max(r,s[j]);
        while (r >= i - 1) {
            que.push(s + i);
            i++;
        }
    }
    while(!que.empty()){
        cout << que.front() << endl;
        que.pop();
    }

}


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


int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(d.begin(), d.end());
    int k = n/2;
    cout << d[k] - d[k-1] << endl;
    return 0;
}

Measured memory_bytes: 3724
import sys
from collections import deque
input = sys.stdin.readline
import numpy as np
N, K = [int(x) for x in input().split()]
h = []
for _ in range(N):
    h.append(int(input()))
h.sort()
i = 0
ans = []
while N - i >= K:
    temp = []
    temp.append(h[i])
    temp.append(h[i+K-1])
    ans.append(temp[-1] - temp[0])
    i += 1
print(min(ans))

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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

typedef long long ll;
typedef pair<int, int> ii;

int main(){

	string s, t;
	cin >> s >> t;

	SORT(s);
	SORT(t);
	reverse(t.begin(), t.end());

	cout << (s < t?"Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int num[3];
  for(int i=0;i<3;i++){
    cin>>num[i];
  }
  for(int a=0;a<2;a++){
    for(int b=a+1;b<3;b++)
    if(num[a]>num[b]){
      int tmp=num[a];
      num[a]=num[b];
      num[b]=tmp;
    }
  }
  cout<<num[0]<<" "<<num[1]<<" "<<num[2]<<"\n";
  return 0;
}

Measured memory_bytes: 3100
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

/**
   ceil(0, 2) == 0
   ceil(1, 2) == 1
   ceil(2, 2) == 1
   ceil(3, 2) == 2
   ceil(4, 2) == 2
*/
template<class T>
T ceil(T dividend, T divisor)
{
    return (dividend + (divisor - 1)) / divisor;
}

using namespace std;

int main()
{
    int64_t N, H;
    std::cin >> N >> H;

    struct K {
        int64_t a; // 何度も
        int64_t b; // 1回
    };

    std::vector<K> sw;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t a, b;
        std::cin >> a >> b;
        sw.push_back({a, b});
    }

    // 一番大きいaをみつける
    auto pos = std::max_element(std::begin(sw), std::end(sw),
                                [](auto l, auto r) {
                                    return l.a < r.a;
                                });

    auto max_a = pos->a;

    // 投げるもの決める
    // max_aより大きい物だけ残す
    auto pos2 = std::remove_if(std::begin(sw), std::end(sw), [max_a](auto e) {
            return e.b <= max_a;
        });
    sw.erase(pos2, sw.end());

    std::sort(std::begin(sw), std::end(sw),
              [](const auto& a, const auto& b) {
                  return a.b > b.b;
              });

    int64_t ans = 0;
    for (auto s: sw) {
        H -= s.b;
        ++ans;
        if (H <= 0) {
            break;
        }
    }

    if (H > 0) {
        ans += ceil(H, max_a);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 2420
//
// Created on 2020/05/12.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {

    int n;
    cin>>n;
    map<string,map<int,int>>mp;
    for (int i = 1; i <= n; ++i) {
        string city;
        int p;
        cin>>city>>p;
        mp[city][p] = i;
    }

    for (auto r : mp) {
        vector<int>output;
        for (auto p : r.second) {
            output.push_back(p.second);
        }
        for (int i = output.size()-1; i >=0 ; --i) {
            cout<<output[i]<<endl;
        }
    }


    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
neg = 0
r=0
for i in a:
  r = r + abs(i)
  if i < 0 :
     neg = neg + 1
if neg % 2 != 0:
  s = 10000000000
  for i in a:
    s = min(s,abs(i))
  r = r - 2*s
  
print(r)

  


Measured memory_bytes: 14412
#include <iostream>
#include <algorithm>
#include <deque>

using namespace std;

int H, W;
string S[2020];
int pt[2020][2020];
deque<pair<int, int> > st;

int main(int argc, const char * argv[]) {
    cin >> H >> W;
    for (int i = 0; i < H; ++i)
        cin >> S[i];

    for (int i = 0; i < H - 1; ++i) {
        string r0 = S[i];
        string r1 = S[i + 1];
        bool p = (r0[0] == r1[0]);
        pt[i][0] = 1;
        int c = 1;
        for (int j = 1; j < W; ++j) {
            if (p == (r0[j] == r1[j])) {
                c += 1;
            } else {
                p = !p;
                c = 1;
            }
            pt[i][j] = c;
        }
    }

    int max_area = (H < W) ? W : H;

    for (int j = 0; j < W; ++j) {
        st.push_back(make_pair(0, pt[0][j]));
        for (int i = 1; i < H - 1; ++i) {
            int w = pt[i][j];
            int li = i;
            while (!st.empty() && w < st.back().second) {
                pair<int, int> p = st.back();
                st.pop_back();
                li = p.first;
                int area = p.second * (i - (st.empty() ? 0 : li) + 1);
                max_area = (max_area < area) ? area : max_area;
            }
            if (st.empty() || st.back().second < w) {
                st.push_back(make_pair(li, w));
            }
        }
        while (!st.empty()) {
            pair<int, int> p = st.back();
            st.pop_back();
            int area = p.second * (H - (st.empty() ? 0 : p.first));
            max_area = (max_area < area) ? area : max_area;
        }
    }

    cout << max_area << endl;
    return 0;
}


Measured memory_bytes: 20096
#include <iostream>
#include <map>
#include <stack>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;

int M, N, LB, UB;
string NAME;
map<string, pii> p;
stack<int*> stk;

int main(void) {
  cin >> M;
  REP(i, 0, M) {
    cin >> NAME >> LB >> UB;
    p[NAME] = pii(LB, UB);
  }

  cin >> N;
  while(N--) {
    cin >> NAME;
    if(NAME == "+" || NAME == "-" || NAME == "/" || NAME == "*") {
      int *op2 = stk.top(); stk.pop();
      int *op1 = stk.top(); stk.pop();
      int *ret = new int[256];
      REP(i, 0, 256) ret[i] = 0;

      // cout << "{ ";
      // REP(i, 0, 256) if(op1[i] == 1) cout << i << " ";
      // cout << "} " << NAME << " { ";
      // REP(i, 0, 256) if(op2[i] == 1) cout << i << " ";
      // cout << "}";

      switch(NAME[0]) {
        case '+':
          REP(i, 0, 256) if(op1[i] == 1) REP(j, 0, 256) if(op2[j] == 1) ret[(i + j) % 256] = 1;
          break;
        case '-':
          REP(i, 0, 256) if(op1[i] == 1) REP(j, 0, 256) if(op2[j] == 1) ret[(i - j + 256) % 256] = 1;
          break;
        case '*':
          REP(i, 0, 256) if(op1[i] == 1) REP(j, 0, 256) if(op2[j] == 1) ret[(i * j) % 256] = 1;
          break;
        case '/':
          if(op2[0] == 1) {
            cout << "error" << endl;
            return 0;
          }
          REP(i, 0, 256) if(op1[i] == 1) REP(j, 0, 256) if(op2[j] == 1) ret[(i / j)] = 1;
          break;
      }

      // cout << " = { ";
      // REP(i, 0, 256) if(ret[i] == 1) cout << i << " ";
      // cout << "}" << endl;

      stk.push(ret);
    } else if(p.count(NAME)) {
      int *ret = new int[256];
      REP(i, 0, 256) ret[i] = 0;
      REP(i, p[NAME].fi, p[NAME].se + 1) ret[i] = 1;
      stk.push(ret);
    } else {
      int val = stoi(NAME);
      int *ret = new int[256];
      REP(i, 0, 256) ret[i] = 0;
      ret[val] = 1;
      stk.push(ret);
    }
  }
  cout << "correct" << endl;

  return 0;
}

Measured memory_bytes: 3264
#include <stdio.h>
int main(void){
  int num = 0;
  int i = 0;
  int buf[20];
  int sum = 0;
  
  scanf("%d",&num);
  
  int digit = 0;
  int tmp = num;
  while(tmp != 0){
    buf[i] = tmp % 10;
    i++;
    digit++;
    tmp = tmp / 10;
  }
  
  	for(i=0;i<digit;i++){
      sum += buf[i];
    }
  
  	if(num % sum == 0){
      printf("Yes");
    }else{
      printf("No");
    }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

ll gcd(ll a, ll b) {
  return b != 0 ? gcd(b, a % b) : a;
}

int main(){
  ll n;cin>>n;
  cout<<2*n/gcd(2,n)<<endl;
  return 0;
}

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



int main() {
int N, T, A;
cin >> N >> T >> A;
int high[2000];
for(int i = 0; i < N; i++)cin >> high[i];
double sa = 10000.000;
int ans;
for(int i = 0; i < N; i++){
double kari = T-high[i]*0.006;
double sakari;
if(kari > A) sakari = kari-A;
else sakari = A-kari;

if(sakari < sa){
ans = i;
sa = sakari;
}

}
ans++;
cout << ans << endl;

}



Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int a[7];
ll ans;
int f(int x){return (x/2)*2;}
int main(){
    for(int i=0;i<7;++i)scanf("%d",a+i);
    for(int i=0;i<10;++i){
        if(a[0]>=i&&a[3]>=i&&a[4]>=i)ans=max(ans,i*3ll+f(a[0]-i)+f(a[3]-i)+f(a[4]-i));
    }
    printf("%lld\n",ans+a[1]);
    //system("pause");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
  {
  int a,b,c,i,j=0;
  cin>>a;
  for(i=1;i<=a;i++)
  {cin>>b;
   if(i%2==1&&b%2==1)j++;
   }
  cout<<j<<endl;
  }

Measured memory_bytes: 3608
// 去吧！皮卡丘! 把AC带回来！
//      へ　　　　　／|
// 　　/＼7　　　 ∠＿/
// 　 /　│　　 ／　／								AC		AC		AC		AC
//    │　Z ＿,＜　／　　 /`ヽ						AC		AC		AC		AC
//    │　　　　　ヽ　　 /　　〉					AC		AC		AC		AC
// 　Y　　　　　`　 /　　/  /						AC		AC		AC		AC
// 　亻●　.　●　　〈　/　/						AC		AC		AC		AC
// 　()　 へ　　　　|　＼〈							AC		AC		AC		AC
// 　　>- ._　 ィ　 │ ／／							AC		AC		AC		AC
// 　 / へ　　 /　/＜| ＼＼							AC		AC		AC		AC
// 　 ヽ_/　　(_／　 │／／							AC		AC		AC		AC
// 　　 7　　　　　　　|／							AC		AC		AC		AC
// 　　 ＞―r￣￣`-―＿/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	int s=a*60+b;
	int t=c*60+d;
	int ch=t-s;
	cout<<ch-e<<endl;
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


Measured memory_bytes: 3652
import math
from collections import defaultdict

n, m = [int(i) for i in input().split()]

A = defaultdict(int)
p = 10 ** 9 + 7

if m == 1:
    print(1)
    exit()

def fact(n, p=10**9 + 7):
    f = [1]
    for i in range(1, n+1):
        f.append(f[-1]*i%p)
    return f

def invfact(n, f, p=10**9 + 7):
    inv = [pow(f[n], p-2, p)]
    for i in range(n, 0, -1):
        inv.append(inv[-1]*i%p)
    return inv[::-1]

f = fact(30+10**5)
invf = invfact(30+10**5, f)

def comb(a, b):
    return f[a] * invf[b] * invf[a-b] % p

i = 2

while m != 1 and i <= math.sqrt(m) + 1:
    while m % i == 0:
        m //= i
        A[i] += 1
    i += 1

if not A:
    print(n)
    exit()

if m != 1:
    A[m] = 1

n -= 1
ans = 1

for v in A.values():
    ans *= comb(v+n, n)
    ans %= p

print(ans)

Measured memory_bytes: 12152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
int n,m,ans = 0;
cin >> n;
vector<int> time(n);
rep(i,n){
    cin >> time.at(i);
    ans += time.at(i);
}
cin >> m;
rep(i,m){
    int a,b;
    cin >> a>> b;
    cout << ans-time.at(a-1)+ b << endl;
}
return 0;
}

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

using namespace std;

#define INF LLONG_MAX
typedef long long ll;

int M, N;
vector<ll> tw, tt;
vector<ll> c, b;

void init()
{
    tw.resize(M+2); tt.resize(M+2);
    c.resize(N); b.resize(N);
}

int solve()
{
    int dp[1<<15];
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    
    for (int i = 0; i < (1<<N); i++) {
        if (dp[i] == -1) continue;        
        for (int j = 0; j < N; j++) {
            if (i >> j & 1) continue;                        
            int ni = i | (1<<j);
            int p1 = upper_bound(tw.begin() + dp[i], tw.end(), c[j] + tw[dp[i]]) - (tw.begin()) - 1;
            int p2 = upper_bound(tt.begin() + dp[i], tt.end(), b[j] + tt[dp[i]]) - (tt.begin()) - 1;
            dp[ni] = max(dp[ni], min(p1, p2));
        }
    }

    return dp[(1<<N)-1];
}

int main()
{    
    cin >> M >> N;
    init();
    tw[0] = tt[0] = 0;
    tw[M+1] = tt[M+1] = INF;
    for (int i = 1; i <= M; i++) {
        cin >> tw[i] >> tt[i];
        tw[i] += tw[i-1];
        tt[i] += tt[i-1];
    }    
    for (int i = 0; i < N; i++) {
        cin >> c[i] >> b[i];
    }
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 4440
#include<iostream>
using namespace std;
int main()
{
    long long int x,sum=0,sum5=0;
    cin >> x;
        if(x/500>0)
        {
            sum=(x/500);
            x=x%500;

        }
        if(x/5>0)
        {
            sum5=(x/5);
        }
        cout << sum*1000+sum5*5 << endl;
    return 0;
}


Measured memory_bytes: 3516
import sys
input = sys.stdin.buffer.readline


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    # i+1番目からR番目まで足すとt以上となるような最小のRを返す
    def bisect_plus(self, i, t):
        L = i
        R = self.size
        R_prev = R
        sum_i = self.sum(i)
        while True:
            range_sum = self.sum(R) - sum_i
            if range_sum < t:
                if R == self.size:
                    return self.size + 1
                L, R = R, R_prev
            else:
                R_prev = R
                R = (L + R + 1) // 2
                if R == R_prev:
                    return R

    # L番目からi-1番目まで足すとt以上となるような最小のRを返す
    def bisect_minus(self, i, t):
        L = 1
        R = i
        L_prev = L
        sum_i = self.sum(i - 1)
        while True:
            range_sum = sum_i - self.sum(L - 1)
            if range_sum < t:
                if L == 1:
                    return 0
                L, R = L_prev, L
            else:
                L_prev = L
                L = (L + R) // 2
                if L == L_prev:
                    return L


def main():
    N, Q = map(int, input().split())
    ev = []
    x_list = []
    for _ in range(N):
        s, t, x = map(int, input().split())
        ev.append([s-x, 1, x])
        ev.append([t-x, -1, x])
        x_list.append(x)
    for _ in range(Q):
        d = int(input())
        ev.append([d, 0, 0])
    ev.sort(key=lambda p: p[0])
    x_list.sort()
    x_idx = {}
    for i in range(1, N+1):
        x_idx[x_list[i-1]] = i

    bit = Bit(N)
    x_list.append(-1)
    for pos, flag, x in ev:
        if flag == 0:
            print(x_list[bit.bisect_plus(0, 1) - 1])
        else:
            idx = x_idx[x]
            bit.add(idx, flag)


if __name__ == '__main__':
    main()


Measured memory_bytes: 138876
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long int ll;

int main(){
	int N;
	cin >> N;
	vector<int> a(N), memo(N + 1);
	for(int i = 0; i < N; i++){
		cin >> a[i];
		memo[a[i]] = i;
	}
	vector<int> memo2(N + 1), memo3(N + 1);
	stack<ll> stka, stkb;
	for(int i = 0; i < N; i++){
		while(!stka.empty() && stka.top() > a[i]){
			memo2[stka.top()] = i - 1;
			stka.pop();
		}
		stka.push(a[i]);
	}
	while(!stka.empty()){
		memo2[stka.top()] = N - 1;
		stka.pop();
	}
	for(int i = N - 1; i >= 0; i--){
		while(!stkb.empty() && stkb.top() > a[i]){
			memo3[stkb.top()] = i + 1;
			stkb.pop();
		}
		stkb.push(a[i]);
	}
	while(!stkb.empty()){
		memo3[stkb.top()] = 0;
		stkb.pop();
	}
	ll res = 0;
	for(int i = 0; i < N; i++) res += (ll)a[i] * (ll)(memo2[a[i]] - i + 1) * (ll)(i - memo3[a[i]] + 1);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4992
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(a: int, b: int):
    if a >= b:
        print(str(b)*a)
    else:
        print(str(a)*b)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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

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

bool pairCompare(const pair<int, int> &firstElof, const pair<int, int> &secondElof)
{
  return firstElof.second < secondElof.second;
}

int main()
{
  int n, m;
  cin >> n >> m;

  vector<pair<int, int>> c;
  rep(i, m)
  {
    int x, y;
    cin >> x >> y;
    c.push_back({x, y});
  }

  sort(c.begin(), c.end(), pairCompare);
  int count = 0;
  int last_removed = -1;

  for (auto i : c)
  {
    if (last_removed == -1)
    {
      last_removed = i.second - 1;
      count++;
      continue;
    }

    if (i.first <= last_removed)
      continue;

    last_removed = i.second - 1;
    count++;
    continue;
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 1400
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      	int n = sc.nextInt();
      	int r = sc.nextInt();
        int ans;
      
        if(n < 10){
          ans = r + 100 * (10 - n);
        }else{
          ans = r;
        }
        
        System.out.println(ans);
      
    }
}

Measured memory_bytes: 35672
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
	ll a;
	cin>>a;
	ll k=a/3,m=a/5,n=a/15;
	cout<<((a)*(a+1))/2-3*(k*(k+1))/2-5*(m*(m+1))/2+15*(n*(n+1))/2<<endl;
}


Measured memory_bytes: 3620
//BIRDS SET FREE
#include<bits/stdc++.h> 
using namespace std;                          //31 July 1999
#pragma GCC optimize("O3")
typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vec(i, a)  for( auto i=a.begin();i != a.end(); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define sp '\t'
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define in  freopen("input.txt","r",stdin);
#define out freopen("output.txt","w",stdout);
#define rocket in out 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...); }
typedef long double ld;
typedef std::pair<ll, ll> pii;
typedef std::vector<ll> vi;
const ll MOD = 10e9 + 7;
const ll N=10e6;
ll n_bits(ll n ) { ll x= __builtin_popcount(n) ; return x ;}
ll least_bits(ll n ) { ll x= __builtin_ffs(n) ; return x ;}
ll gcd(ll x, ll y) { ll n=__gcd(x,y); return n;}
ll binpow(ll a, ll b, ll m=MOD) 
{
    a%=m;
    ll res=1;
    while (b>0) 
    {
        if (b&1)    res=res*a%m;
        a=a*a%m,b>>=1;
    }
    return res;
}
void I(vi &v, int n)
{
    ll a;
    rep(i,0,n)    cin>>a,v.pb(a);
}
void O(vi &v, int n)
{

    rep(i,0,n)    cout<<v[i]<<" ";
    cout<<endl;
}
ll get_second( pair<string, ll> i ){ return i.second; }
int main()
{    
    #ifndef ONLINE_JUDGE
    rocket
    #endif
    fast
    ll t=1;
    //cin>>t;
    while(t--)
    {    
        ll temp = 0 , flag = 0 , diff = 0 , sum = 0 , result = 0 , ct = 0 , cnt = 0 , found = 0;
        ll a = 0 , b = 0 , c = 0 , n = 0 , m = 0 , k = 0 , x = 0 , y = 0 ; 
        set<ll> s1;
        map<ll,ll> mapp;
        vi v,v1,v2;
        string s;
        //transform( mapp.begin(), mapp.end(), v1.begin(), get_second );
        cin >> n ;
        n = n % 10 ;
        if( n == 2 || n == 7 || n == 5  || n == 4  || n == 9 ) cout << "hon" ;
        else if( n == 1 || n == 8 || n == 6  || n == 0 ) cout << "pon" ;
        else cout << "bon" ; 
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int t[110000], x[110000], y[110000];
  t[0] = x[0] = y[0] = 0;
  for(int i = 0; i < N; i++){
    cin >> t[i+1] >> x[i+1] >> y[i+1];
  }
  
  bool can = true;
  for(int i = 0; i < N; i++){
    int dt = t[i+1] - t[i];
    int dl =abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
    if(dl > dt) can = false;
    if(dl % 2 != dt % 2) can = false;
  }
  
  
  if(can == true) cout << "Yes" << endl;
  else cout << "No"<< endl;
}



Measured memory_bytes: 1408
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int n;
    int maxs = 0;
    cin >>n;
    int s[100000];
    rep(i,n){
        cin >> s[i];
    }
    int step = 0;
    rep(i,n-1){
        if(s[i]>=s[i+1]){
            step++;
        }else{            
            step = 0;
        }
        maxs = max(maxs,step);
    }
    cout << maxs << endl;
}   

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

N, K = map(int, input().split())
hN = [int(input()) for i in range(N)]

hN.sort()

ans = float('inf')
for i in range(N-K+1):
    ans = min(hN[i+K-1] - hN[i], ans)
print(ans)


Measured memory_bytes: 7384
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n;
  cin>>n;
  int a[n];
  int all_ = 1;
  REP(i,n){
    cin>>a[i];
    all_ *= 3;
  }
  int d = 1;
  REP(i,n){
    if(a[i]%2==0){
      d *= 2;
    }else{
      d *= 1;
    }
  }
  
  int ans = all_ - d;
  cout<<ans<<endl;
  
  return 0;
}


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

int main() {
  int n;
  cin>>n;
  int a[n];
  int b[n][n];
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      b[i][j] = -1;
    }
  }
  for (int i=0; i<n; i++) {
    cin>>a[i];
    for (int j=0; j<a[i]; j++) {
      int x, y;
      cin>>x>>y;
      --x;
      b[i][x] = y;
    }
  }
  int ans = 0;
  for (int i=0; i<(1<<n); i++) {
    int c[n];
    for (int j=0; j<n; j++) c[j] = -1;
    bool ok = true;
    int cnt = 0;
    for (int k=0; k<n; k++) {
      bool flag = (i >> k) & 1;
      if (flag) {
        if (c[k] == 0) {
          ok = false;
          break;
        }
        ++cnt;
        c[k] = 1;
      } else {
        if (c[k] == 1) {
          ok = false;
          break;
        }
        c[k] = 0;
        continue;
      }
      for (int l=0; l<n; l++) {
        if (b[k][l] == -1) {
          continue;
        }
        int  x = b[k][l];
        if (c[l] == -1) {
          c[l] = x;
        } else {
          if (c[l] != x) {
            ok = false;
            break;
          }
          c[l] = x;
        }
      }
      if (!ok) {
        break;
      }
    }
    if (ok) {
      ans = max(cnt, ans);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256