akhauriyash/Code-Regression huggingface dataset:
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int visited[51][51];
vector<pair<int,int> > arr[51][51];

void bfs(pair<int,int> x){
    queue<pair<int,int> > q;
    q.push(x);
    visited[x.fi][x.se]=1;
    while(!q.empty()){
        pair<int,int> u=q.front();
        q.pop();
        int a=u.fi;
        int b=u.se;
        for(int i=0;i<arr[a][b].size();i++){
            pair<int,int> node=arr[a][b][i];
            if(visited[node.fi][node.se]==0){
                q.push(node);
                visited[node.fi][node.se]=visited[a][b]+1;
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int h,w;
    cin>>h>>w;
    vector<string> s(h+2);
    string k="";
    for(int i=0;i<w+2;i++){
        k="#"+k;
    }
    s[0]=k;
    for(int i=1;i<=h;i++){
        cin>>s[i];
        s[i]="#"+s[i]+"#";
    }
    s[h+1]=k;
    // 1 index 1,1->h,w
    int count=0;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j]=='.'){
                count+=1;
            }
            if(s[i][j]=='.' && s[i][j+1]=='.'){
                arr[i][j].pb(mp(i,j+1));
            }
            if(s[i][j]=='.' && s[i][j-1]=='.'){
                arr[i][j].pb(mp(i,j-1));
            }
            if(s[i][j]=='.' && s[i+1][j]=='.'){
                arr[i][j].pb(mp(i+1,j));
            }
            if(s[i][j]=='.' && s[i-1][j]=='.'){
                arr[i][j].pb(mp(i-1,j));
            }
        }
    }
    bfs(mp(1,1));
    if(visited[h][w]>0)
        cout<<count-visited[h][w]<<endl;
    else{
        cout<<-1<<endl;
    }
    return 0;
}


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

N, C = MAP()
xv = [LIST() for _ in range(N)]

#左回り用
energy_left_1 = [0]
energy_left_2 = [0]
tmp_v = 0
for x, v in xv:
	tmp_v += v
	energy_left_1.append(tmp_v-x)
	energy_left_2.append(tmp_v-2*x)

#右周り用
energy_right_1 = [0]
energy_right_2 = [0]
tmp_v = 0 
for x, v in xv[::-1]:
	y = C-x
	tmp_v += v
	energy_right_1.append(tmp_v-y)
	energy_right_2.append(tmp_v-2*y)

energy_left_1_acc = list(accumulate(energy_left_1, max))
energy_left_2_acc = list(accumulate(energy_left_2, max))
energy_right_1_acc = list(accumulate(energy_right_1, max))
energy_right_2_acc = list(accumulate(energy_right_2, max))

ans = -INF
for i in range(N+1):
	ans = max(ans, energy_left_1_acc[i]+energy_right_2_acc[N-i])
	ans = max(ans, energy_left_2_acc[i]+energy_right_1_acc[N-i])
print(ans)

Measured memory_bytes: 48264
class uf:

    def __init__(self, n):
        self.table = [-1] * (n + 1)
        self.size = [1] * (n + 1)

    def merge(self, r1, r2):
        self.table[r1] = r2
        self.size[r2] += self.size[r1]
        self.size[r1] = 0

    def find_root(self, k):
        path = []
        curr = k
        while self.table[curr] != -1:
            path.append(curr)
            curr = self.table[curr]
        self.defrag(curr, path)
        return curr, path

    def defrag(self, r, p):
        for i in p:
            self.table[i] = r


def solve(string):
    n, m, *ab = map(int, string.split())
    ab = ab[::-1]
    ans = [n * (n - 1) // 2]
    table = uf(n)
    for _b, _a in zip(ab[::2], ab[1::2]):
        r_a, _ = table.find_root(_a)
        r_b, _ = table.find_root(_b)
        if r_a == r_b:
            ans.append(ans[-1])
            continue
        ans.append(ans[-1] - table.size[r_a] * table.size[r_b])
        table.merge(r_a, r_b)
    return "\n".join([str(a) for a in ans[:-1][::-1]])


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(m)])))


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

int main()
{
	unsigned long long N;
	cin >> N;
	char C[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	vector<unsigned long long> V;
	
	unsigned long long R, tmp;
	
	while(N > 0)
	{
		tmp = N;
		N = tmp / 26;
		R = tmp % 26;
		//cout << R;
		if(R > 0)
		{
			V.push_back(R-1);
		}
		else
		{
			V.push_back(25);
			N = N - 1;
		}
	}
	
	for(int i = V.size() - 1; i>=0; i--)
	{
		cout << C[V[i]];
	}
	
	return 0;
}

Measured memory_bytes: 3628
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

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

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

r = I()

if r<1200:
    print("ABC")
elif r<2800:
    print("ARC")
else:
    print("AGC")

Measured memory_bytes: 77016
while True:
    n = input()

    if n == "0000":
        break
    if n.count(n[0]) == 4:
        print("NA")
        continue

    cnt = 0
    while n != "6174":
        n, l = sorted(list(n)), sorted(list(n), reverse=True)
        n = str(int("".join(l)) - int("".join(n))).zfill(4)
        cnt += 1

    print(cnt)

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

int main() {
  string S;
  cin >> S;
  int ans = 0;
  int A = S.size();
  for (int i = 0; i < (A / 2); i++) {
    if (S.at(i) != S.at(A - i - 1)) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int x,y,a,b,c;
int p[100010],q[100010],r[100010];
signed main(){
    cin>>x>>y>>a>>b>>c;
    rep(i,a)cin>>p[i];
    rep(i,b)cin>>q[i];
    rep(i,c)cin>>r[i];
    sort(r,r+c,greater<int>());
    sort(p,p+a,greater<int>());
    sort(q,q+b,greater<int>());
    int sum=0;
    priority_queue<int,vector<int>,greater<int>>que;
    rep(i,x)que.push(p[i]);
    rep(i,y)que.push(q[i]);
    rep(i,c){
        if(que.top()<r[i]){
            que.pop();
            que.push(r[i]);
        }
        else break;
    }
    while(!que.empty()){
        sum+=que.top();
        que.pop();
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 6516
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const int maxn=100;
char s[maxn];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	for(int i=1;i+8<=n;i++) printf("%c",s[i]);
	return 0;
}

Measured memory_bytes: 128
n,q = (int(i) for i in input().split())
now,x = 1,[0 for i in range(n+2)]
x[2] = 1
for i in range(q):
	a,b = (int(j) for j in input().split())
	if a==now or b==now: now=(a+b)-now
	if x[a]==1 and x[b]==1: pass
	elif x[a]==1: x[a],x[b] = 0,1
	elif x[b]==1: x[a],x[b] = 1,0
	x[now+1],x[now-1] = 1,1
x[now] = 1
print(sum(x[1:n+1]))

Measured memory_bytes: 4784
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), long(input_raw[1])]

    ans = 0
    for i in range(1, int(math.sqrt(M)) + 2):
        if M % i == 0:
            j = M/i
            if M/i >= N:
                ans = max(ans, i)
            if M/j >= N:
                ans = max(ans, j)
    print ans




if __name__ == '__main__':
    main()


Measured memory_bytes: 30956
s = list(input())
k = int(input())

for i in range(len(s)):
        if ord("z")-ord(s[i])+1<=k:
                k -= (ord("z")-ord(s[i])+1)%26
                s[i] = "a"
if k: s[-1] = chr((ord(s[-1])+k-ord("a"))%26+ord("a"))
print("".join(s))

Measured memory_bytes: 4152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = pow(10, 9) + 7; //10e9 + 7


int main() {
  string S, ans;
  cin >> S;

  
  if(S == "Sunny") ans = "Cloudy";
  else if(S == "Cloudy") ans = "Rainy";
  else if(S == "Rainy") ans = "Sunny";
  
  cout << ans << endl;
  
}


Measured memory_bytes: 256
import heapq

def score(init, cand):
    
    score = [0] * (n+1)
    score[0] = sum(init)
    hp = init
    heapq.heapify(hp)
    
    for i,ai in enumerate(cand):
    
        if hp[0] < ai:
            min_a = heapq.heappop(hp)
            score[i+1] = score[i] + (ai - min_a)
            heapq.heappush(hp, ai)
        else:
            score[i+1] = score[i]
    
    return score
    
n = int(input())
a = list(map(int,input().split()))
minus_a = [-x for x in a[::-1]]

former_score = score(a[:n],a[n:2*n])
latter_score = score(minus_a[:n],minus_a[n:2*n])[::-1]

ans = max(x+y for x,y in zip(former_score,latter_score))

print(ans)

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

Measured memory_bytes: 596
#include<cstdio>
using namespace std;
#define N 100005
#define INF (1 << 30)
struct card
{
	char suit;
	int value;
};
typedef struct card card;

card L[N / 2], R[N / 2];
card a[N], b[N];
int n;

void _merge(int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i<n1; ++i)
		L[i] = a[left + i];
	for (int i = 0; i<n2; ++i)
		R[i] = a[mid + i];
	L[n1].value = R[n2].value = INF;
	int i = 0, j = 0;
	for (int k = left; k<right; k++)
	{
		if (L[i].value <= R[j].value)
			a[k] = L[i++];
		else
			a[k] = R[j++];
	}
}
void mergesort(int n, int left, int right)
{
	int mid;
	if (left + 1<right)
	{
		mid = (left + right) >> 1;
		mergesort(n, left, mid);
		mergesort(n, mid, right);
		_merge(left, mid, right);
	}
}
int _partition(int n, int p, int r)
{
	card x = b[r];
	int i = p - 1;
	for (int j = p; j<r; j++)
	{
		if (b[j].value <= x.value)
		{
			i++;
			card t = b[i];
			b[i] = b[j];
			b[j] = t;
		}
	}
	card t = b[i + 1]; b[i + 1] = b[r]; b[r] = t;
	return i + 1;
}
void quicksort(int n, int p, int r)
{
	int q;
	if (p<r)
	{
		q = _partition(n, p, r);
		quicksort(n, p, q - 1);
		quicksort(n, q + 1, r);
	}
}
int main()
{
	int stable = 1;
	scanf("%d", &n);
	for (int i = 0; i<n; ++i)
	{
		char str[3];
		int x;
		scanf("%s %d", str, &x);
		a[i].suit = b[i].suit = str[0];
		a[i].value = b[i].value = x;
	}
	mergesort(n, 0, n);
	quicksort(n, 0, n - 1);
	for (int i = 0; i<n; ++i)
	{
		if (a[i].suit != b[i].suit) stable = 0;
	}
	if (stable) printf("Stable\n");
	else printf("Not stable\n");
	for (int i = 0; i<n; ++i)
	{
		printf("%c %d\n", b[i].suit, b[i].value);
	}
	return 0;
}

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

int main() {
  int count = 0;
  int judge = 0;
  int N;
  cin >> N;
  vector<int> vec(N); 
  for (int i = 0; i < N; i++) 
  {
    cin >> vec.at(i);
  }
  for (int i = 1; i < N; i++)
  {
    if(vec.at(i-1) >= vec.at(i))
    count += vec.at(i-1) - vec.at(i);
    else
    count = 0;
    if(count >= 2)
      judge = 1;
  }
  if (judge == 1)
  cout << "No" << endl;
   if (judge ==0)
  cout << "Yes" << endl;
  
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<ctime>
#include<unordered_map>
#include<iostream>
using namespace std;
typedef long long ll;
ll pn[105],cnt,n,mod,sigma,a[200005],ans;
int pp[40]= {9643,9649,9661,9677,9679,9689,9697,9719,9721,9733,9739,9743,9749,9767,9769,9781,9787,9791,9803,9811,9817,9829};
ll Multi(ll x,ll y,ll p) {
	ll z=(long double)x/p*y;
	ll res=(unsigned ll)x*y-(unsigned ll)z*p;
	return (res+p)%p;
}
ll Power(ll x,ll y,ll z) {
	ll ret=1;
	while(y) {
		if(y&1)ret=Multi(ret,x,z);
		x=Multi(x,x,z),y>>=1;
	}
	return ret;
}
bool Miller_Rabbin(ll n) {
	if(n==2)return 1;
	if(n<2)return 0;
	ll m=n-1;
	int k=0;
	while(m%2==0)k++,m/=2;
	for(int i=1; i<=5; i++) {
		ll kk=rand()%(n-1)+1,x=Power(kk,m,n),y=0;
		for(int j=1; j<=k; j++) {
			y=Multi(x,x,n);
			if(y==1&&x!=1&&x!=n-1)return 0;
			x=y;
		}
		if(y!=1)return 0;
	}
	return 1;
}
inline ll gcd(ll a,ll b) {
	if(b==0)return a;
	if(a==0)return b;
	return gcd(b,a%b);
}
ll ABS(ll x) {
	return x<0?-x:x;
}
inline ll Pollard_Rho(ll x,ll c) {
	if(!c)c=rand();
	ll s=0,t=0;
	int stp=0,goal=1;
	ll val=1;
	for(goal=1;; goal<<=1,s=t,val=1) {
		for(stp=1; stp<=goal; ++stp) {
			t=(Multi(t,t,x)+c)%x;
			val=Multi(val,ABS(t-s),x);
			if((stp%127)==0) {
				ll d=gcd(val,x);
				if(d>1)return d;
			}
		}
		ll d=gcd(val,x);
		if(d>1)return d;
	}
}
unordered_map<ll,bool> is;
void FindDivisor(ll n) {
	if(n==1)return ;
	if(Miller_Rabbin(n)) {
		if(!is[n])pn[++cnt]=n,is[n]=1;
		return ;
	}
	ll p=n,x=0;
	while(p>=n)p=Pollard_Rho(n,pp[x++]);
	while(n%p==0)n/=p;
	FindDivisor(p),FindDivisor(n);
}
unordered_map<ll,ll> t;
void DFS(int now,ll x,ll nowt) {
	if(now>cnt)return a[++a[0]]=x,t[x]=nowt,void();
	DFS(now+1,x,nowt);
	ll tmpn=n;
	while(tmpn%pn[now]==0) {
		DFS(now+1,x*=pn[now],nowt*(1-pn[now]));
		tmpn/=pn[now];
	}
}
int main() {
	srand(time(0));
	cin>>n>>sigma,mod=1000000007;
	FindDivisor(n);
	DFS(1,1,1);
	for(int i=1; i<=a[0]; i++) {
		if(a[i]%2==1&&(n/a[i])%2==0)continue;
		ans=(ans+(a[i]%2?a[i]:a[i]/2)%mod*Power(sigma,(a[i]+1)/2,mod)%mod*(t[n/a[i]]%mod+mod))%mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <cmath>
#include <string.h>
#include <queue>
#include <functional>

#define NMAX 1000001
#define MOD 1000000007
#define INF 2000000000
#define PI 3.1415926535
#define EPS 1.e10-6

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) > 0 ? (a) : (-a))

typedef unsigned long long ull;
typedef long long ll;

using namespace std;

int x;

bool isPrime(int x)
{
	if (x < 2)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;

	for (int i = 3; i * i <= x; i += 2)
		if (x % i == 0)
			return false;
	return true;
}

int main()
{
	cin >> x;
	do {
		if (isPrime(x))
		{
			cout << x << '\n';
			exit(0);
		}
	} while (x++);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <unordered_map>

using namespace std;

bool check(int N)
{
  unordered_map<string, bool> words;
  string prev = "";
  for (int i = 0; i < N; ++i) {
    string word;
    cin >> word;
    if (words.find(word) != words.end()) return false;
    if (prev != "" and prev[prev.size()-1] != word[0]) return false;
    words[word] = true;
    prev = word; 
  }
  return true;
}

int main()
{
  int N;
  cin >> N;
  cout << (check(N) ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class ARegistration {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        string S, T;
        in>>S>>T;
        int n = LEN(S);
        if(LEN(T)!=LEN(S)+1){
            out<<"No\n";
            return;
        }
        REP(i, n){
            if(S[i]!=T[i]){
                out<<"No\n";
                return;
            }
        }
        out<<"Yes\n";
    }
};


int main() {
	ARegistration solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
/*-----------------------*/
#define FAST        ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define endl        "\n"
#define ff          first
#define ss          second
#define cc(x)       cout<<#x<<"="<<x<<" ";
#define CC(x)       for(auto xx: x) cout<<xx<<" ";
#define ee          cout<<"\n";
#define ll          long long
#define ull         unsigned long long
#define pii         pair<ll,ll>
#define mp          make_pair
#define all(x)      x.begin(),x.end()
#define ps(x)       push(x)
#define psb(x)      push_back(x)
#define psf(x)      push_front(x)
#define pp          pop()
#define ppb         pop_back()
#define ppf         pop_front()
#define OK          cout<<"Ok"<<"\n";
#define TESTS       ll test;cin>>test;for(ll   tcase=1;tcase<=test;tcase++)
/*------------------------*/
#define MAX int(1e5)
int dp[2][10000+9];
int value[1000+9],weight[1000+9];


int main()
{
    FAST
    int h,d;
    cin>>h>>d;
    cout<<h/d+1*(h%d!=0)<<endl;

    return 0;
}


Measured memory_bytes: 256
x=1
y=1
list=[]
while x>0:
    if x ==0 and y == 0:
        break
    x,y = map(int,input().split())
    list.append([x,y])

list.remove([0,0])

for L in list:
    ans = 0
    for i in range(1,L[0]-1):
        for j in range(i+1,L[0]):
            for k in range(j+1,L[0]+1):
                if L[1]== i + j+ k:
                    ans += 1
                else:
                    pass
    print(ans)

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

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

    //デカイのが後(昇順)
    sort(d.begin(), d.end());

    int ans = d[d.size() / 2] - d[(d.size() / 2)-1];

    cout << ans;

        return 0;
}

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

struct UnionFind
{
    vector<int> par;
    vector<int> sizes;

    UnionFind(int N) : par(N), sizes(N, 1)
    {
        for (int i = 0; i < N; i++)
        {
            par[i] = i;
        }
    }
    int root(int x)
    {
        if (par[x] == x)
        {
            return x;
        }
        else
        {
            return par[x] = root(par[x]);
        }
    }
    int size(int x)
    {
        return sizes[root(x)];
    }
    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
        {
            return;
        }
        par[ry] = rx;
        sizes[rx] += sizes[ry];
    }
    bool same(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    long long N, M;
    cin >> N >> M;
    vector<pair<int, int>> AB(M);
    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        AB[i].first = a - 1;
        AB[i].second = b - 1;
    }
    vector<long long> ans(M);
    UnionFind uf(N);
    ans[M - 1] = N * (N - 1) / 2;
    for (int i = M - 1; i > 0; i--)
    {
        if (uf.same(AB[i].first, AB[i].second))
        {
            ans[i - 1] = ans[i];
        }
        else
        {
            long long asize = (long long)uf.size(AB[i].first);
            long long bsize = (long long)uf.size(AB[i].second);
            uf.unite(AB[i].first, AB[i].second);
            ans[i - 1] = ans[i] - asize * bsize;
        }
    }

    for (int i = 0; i < M; i++)
    {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3712
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
count = 10
num = 0
num1 = 0


def f(x):
    return x + 10 - (x%10)


list1 = [a,b,c,d,e]
for i in range(len(list1)):
    if count > list1[i] % 10 and list1[i]%10 != 0:
        count = list1[i]%10
        num = i

for j in range(len(list1)):
    if j == num:
        num1 += list1[j]
    elif list1[j]%10==0:
        num1 += list1[j]        
    else:
        num1 += f(list1[j])
    
print(num1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y first
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 1<<19;

int arr[maxn];
int best[maxn];
int nd[maxn];
int res[maxn];

void merge(int a, int b)
{
	int x = best[a], y = nd[a];
	if(arr[x]> arr[best[b]])
	{
		nd[b] = best[b];
		best[b] = x;
	}
	else if(nd[b] == -1 || arr[x]> arr[nd[b]])
	{
		nd[b] = x;
	}
	if(y == -1) return;
	if(arr[y]> arr[best[b]])
	{
		nd[b] = best[b];
		best[b] = y;
	}
	else if(nd[b] == -1 || arr[y]> arr[nd[b]])
	{
		nd[b] = y;
	}
}

int main()
{
	int n; scanf("%d", &n);
	for(int i = 0; i< (1<<n); i++)
		scanf("%d", arr+i);
	for(int i = 0; i< (1<<n); i++)
	{
		best[i] = i;
		nd[i] = -1;
	}
	for(int bit = 0; bit< n; bit++)
	{
		for(int x = 0; x< (1<< n); x++)
		{
			if(x & (1<<bit))
				continue;
			merge(x, x | (1<<bit));
		}
	}
	for(int i = 1; i< (1<< n); i++) 
	{
		res[i] = arr[best[i]]+arr[nd[i]];
		//printf("(%d) (%d)\n", best[i], nd[i]);
		res[i] = max(res[i], res[i-1]);
		printf("%d\n", res[i]);
	}
}

Measured memory_bytes: 10240
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<ll> vec(4);
    vec.at(0) = a * c;
    vec.at(1) = a * d;
    vec.at(2) = b * c;
    vec.at(3) = b * d;
    ll ans = -1'000'000'000'000'000'000;
    rep(i,4){
        ans = max(ans, vec.at(i));
    }
    cout << ans << endl;
    return 0;
}


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

typedef pair<ll, ll> P;

bool In(ll x, ll y){
	for(int i = 0; i < 30; i++){
		if((x >> i & 1) && !(y >> i & 1)) return false;
	}
	return true;
}

ll A[100000];
ll B[100000];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N, K;
	cin >> N >> K;

	for(int i = 0; i < N; i++){
		cin >> A[i] >> B[i];
	}

	ll ans = 0;
	int s = 0;
	for(int i = 30; i >= 0; i--){
		if((K >> i & 1) == 0) continue;
		ll sum = 0;
		ll k = s | ((1 << i) - 1);
		//cout << k << endl;
		for(int j = 0; j < N; j++){
			if(In(A[j], k)) sum += B[j];
		}
		ans = max(ans, sum);
		s |= 1 << i;
	}
	ll sum = 0;
	for(int j = 0; j < N; j++){
		if(In(A[j], K)) sum += B[j];
	}
	ans = max(ans, sum);
	cout << ans << endl;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
    cin>>a[i];}
    int dp[n];
    dp[n-1]=0;
    dp[n-2]=abs(a[n-1]-a[n-2]);
  for(int i=(n-3);i>=0;i--){
  dp[i]=INFINITY;
  for(int j=1;j<=k;j++){
  if(i+j>=n)
  break;
dp[i]=min(abs(a[i+j]-a[i])+dp[i+j],dp[i]);

  }}
  cout<<dp[0];


    return 0;}


Measured memory_bytes: 4368
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#define pb push_back
#define fi first
#define se second
#define PAD 400
#define SIZE 500333
#define MAXV 222
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;

ll n, c, k, t[100011], ret;

int main () {
	scanf("%lld%lld%lld",&n,&c,&k);
	for(int i=0;i<n;i++)	scanf("%lld",t+i);
	sort(t,t+n);
	for(int i=0;i<n;) {
		ll ht = t[i] + k, cnt = 0;
		while(i < n && ht >= t[i] && cnt < c ) {
			cnt++;
			i++;
		}
		ret++;
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, bool> M;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
    ll h, w, n, all, a[112345], b[112345], ans[10] = {0};
    map<P, bool> mp, pos;
    cin >> h >> w >> n;

    REP(i, n)
    {
        cin >> a[i] >> b[i];

        a[i]--, b[i]--;

        pos[P(a[i], b[i])] = true;
    }

    all = (h - 2) * (w - 2);

    REP(i, n)
    {

        for (int j = -2; j <= 0; j++)
        {
            if (j + a[i] < 0 || a[i] + j + 2 >= h)
                continue;

            for (int k = -2; k <= 0; k++)
            {
                if (k + b[i] < 0 || b[i] + k + 2 >= w)
                    continue;

                if (mp[P(a[i] + j, b[i] + k)])
                    continue;

                all--;

                mp[P(a[i] + j, b[i] + k)] = true;

                int num = 0;

                for (int l = 0; l <= 2; l++)
                {
                    for (int m = 0; m <= 2; m++)
                    {
                        if (pos[P(a[i] + j + l, b[i] + k + m)])
                            num++;
                    }
                }

                ans[num]++;
            }
        }
    }

    ans[0] = all;

    REP(i, 10)
    cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 214272
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}



int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/


/*
 * 最大公約数計算
 */
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

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

	cin >> N;
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		int a, b;
		cin >> a >> b;
		int sa = b - a + 1;
		ans += sa;
	}
	
		cout << ans << endl;
	return 0;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define deb(x) cout << #x << " : " << x << endl

int main(){
    
    ll n , k;
    cin >> n >> k;
    
    vector<ll> dp(n,1e18);
    dp[0]=0;
    ll i,j;
    ll h[n];
    for(i=0;i<n;i++){
        cin >> h[i];
    }
    for(i=0;i<n;i++){
        for(j=1;j<=k;j++){
            if((i+j)<n){
                dp[i+j]=min(dp[i+j], dp[i] + abs(h[i]-h[j+i]));
            }
        }

    }

    cout << dp[n-1] << endl;
    
}



Measured memory_bytes: 4812
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;
void init();
#ifdef DEBUG_BUILD
#define DBG(expr) cout << #expr << " = " << expr << endl;
#endif
#define ECHO(expr) cout << expr << endl;
#define REP(var, num) for(ll var = 0; var < num; var++)
#define REP_FROM(var, from, num) for(ll var = from; var < num; var++)
#define MAX_OF(type) numeric_limits<type>::max()
#define MIN_OF(type) numeric_limits<type>::min()
#define SORT(vec) sort(vec.begin(), vec.end())
#define REVERSE(vec) reverse(vec.begin(), vec.end())
#define ALL(vec) vec.begin(), vec.end()
typedef signed long long ll;
typedef unsigned long long ull;

class Edge {
public:
    ll dst, cost;
    Edge(ll dst, ll cost) : dst(dst), cost(cost) {}
};

static const ll UNREACHABLE = MAX_OF(ll) / 10;
class Dijkstra {
    ll num_nodes;
    vector<vector<Edge> > edges;

public:
    Dijkstra(ll num_nodes) :
        num_nodes(num_nodes),
        edges(num_nodes, vector<Edge>()) {}

    void add_unidirect_edge(ll src, ll dst, ll cost) {
//        cout << "ADD: " << src << " -> " << dst << " (" << cost << ")" << endl;
        edges[src].emplace_back(dst, cost);
    }

    void add_bidirect_edge(ll node1, ll node2, ll cost) {
        add_unidirect_edge(node1, node2, cost);
        add_unidirect_edge(node2, node1, cost);
    }

    // Returns the minimal costs (or `UNREACHABLE`) to each nodes and the route.
    pair<vector<ll>, vector<ll> > search(ll start) {
        vector<ll> costs(num_nodes, UNREACHABLE);
        vector<ll> prev(num_nodes, -1);
        priority_queue<pair<ll, ll> > qs;
        costs[start] = 0;
        qs.push(make_pair(0, start));
        while (!qs.empty()) {
            auto q = qs.top();
            qs.pop();
            ll node = q.second;
            for (auto& e: edges[node]) {
                if (costs[e.dst] > costs[node] + e.cost) {
                    costs[e.dst] = costs[node] + e.cost;
                    prev[e.dst] = node;
                    qs.push(make_pair(-costs[e.dst], e.dst));
                }
            }
        }

        return make_pair(costs, prev);
    }
};

int main() {
    init();
    ll n, m, s, t;
    cin >> n >> m >> s >> t;
    Dijkstra snuke(n + 1);
    Dijkstra yen(n + 1);
    REP(i, m) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        yen.add_bidirect_edge(u, v, a);
        snuke.add_bidirect_edge(u, v, b);
    }

    auto costs_s = yen.search(s).first;
    auto costs_t = snuke.search(t).first;

    vector<ll> spent(n+1);
    REP_FROM(i, 1, n + 1) {
        spent[i] = costs_s[i] + costs_t[i];
    }

	for (int i = n - 1; i > 0; i--)
		spent[i] = min(spent[i], spent[i + 1]);

    REP_FROM(i, 1, n + 1) {
        ECHO(1000000000000000 - spent[i]);
    }

    return 0;
}

void init() {
#ifdef INPUT_FILE
    if (!freopen(INPUT_FILE, "r", stdin)) {
        perror("freopen");
        exit(1);
    }
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
}

Measured memory_bytes: 20800
#include <stdio.h>
#include <stdlib.h>

int main(void){
	int k;
	long long int lun[1000000];
	scanf("%d",&k);
	long long int s=11;
	int t;
	for(int i=1; i<=9; i++){
		lun[i-1]=i;
	}
	int i=8;
	int j=0;
	while(j<=k){
		long long int x=lun[j++];
		if(x%10==0){
			lun[++i]=10*x;
			lun[++i]=x*10+1;
		}else if(x%10==9){
			lun[++i]=10*x+8;
			lun[++i]=10*x+9;
		}else{
			lun[++i]=x*10+x%10-1;
			lun[++i]=10*x+x%10;
			lun[++i]=x*10+x%10+1;
		}
		/*t=s;
		while(t>0){
			if(t/10==0) break;
			if(abs(t%10-t/10%10)>1) break;
			if(t/10<10){
				lun[i]=s;
				i++;
				break;
			}
			t/=10;
		}
		s++;*/
	}
	/*for(int i=0; i<k-1; i++){
		printf("%lld\n",lun[i]);
	}*/
	printf("%lld\n",lun[k-1]);
	return 0;
}


Measured memory_bytes: 3200
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b=INTM()
    if a%3==0 or b%3==0 or (a+b)%3==0:
        print('Possible')
    else:
        print('Impossible')
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

ll n, m;
vector<P> vp;

int main(){
	while (cin >> n >> m&&n + m){
		vp.clear();
		REP(i, n){
			ll d, p;
			cin >> d >> p;
			vp.push_back(P(p, d));
		}
		sort(ALL(vp), greater<P>());
		ll ans = 0;
		REP(i, vp.size()){
			if (m - vp[i].second < 0){
				if (m <= 0){
					ans += vp[i].first*vp[i].second;
				}
				else{
					ans += vp[i].first*(vp[i].second - m);
					m -= vp[i].second;
				}
			}
			else{
				m -= vp[i].second;
			}
		}
		cout << ans << endl;
	}
}

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

/*
   AtCoder contest code
   coder : yoichidon
 */

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

        int eatPoison = Math.min(poison, anti+delAnti+1);
        System.out.println(delAnti+eatPoison);


    }
}


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

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

    int a = count(s.begin(),s.end(),'a');
    int b = count(s.begin(),s.end(),'b');
    int c = count(s.begin(),s.end(),'c');

    a==1&&b==1&c==1?cout<<"Yes":cout<<"No";
    return 0;
}

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    k = int(input())
    s = input()[:-1].decode()
    if len(s) <= k:
        print(s)
    else:
        print(s[0:k], '...', sep='')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 61668
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int t1 = 0, x1 = 0, y1 = 0;
		int t2, x2, y2, t, c;
		
		for(int i=0; i<n; i++) {
			t2 = scan.nextInt();
			x2 = scan.nextInt();
			y2 = scan.nextInt();
			t = t2 -t1;
			c = Math.abs((x2+y2)-(x1+y1));
			if(t >= c) {
				if(t%2 != c%2) {
					System.out.println("No");
					scan.close();
					return;
				}
			} else {
				System.out.println("No");
				scan.close();
				return;
			}
			t1 = t2;
			x1 = x2;
			y1 = y2;
		}
		scan.close();
		System.out.println("Yes");
	}

}

Measured memory_bytes: 87312
#include <iostream>
#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 n,m; cin >> n >> m;
    vpl v(m);
    rep(i,m) cin >> v[i].second >> v[i].first;
    sort(all(v));
    vl cut;
    rep(i,m){
        if(cut.empty()){
            cut.push_back(v[i].first);
            continue;
        }
        if(v[i].second >= cut.back()) cut.push_back(v[i].first);
    }
    cout << cut.size() << endl;
}

Measured memory_bytes: 1792
n, k = map(int, input().split())
d = [0]*k
a = [0]*k

for i in range(k):
    d[i] = int(input()) 
    a[i] = list(map(int, input().split()))

ans = [0]*100

for i in range(k):
    for j in range(d[i]):
        ans[a[i][j]-1] = 1

print(n-sum(ans))

Measured memory_bytes: 9240
S = input()

ans = "AC"

w = "BDEFGHIJKLMNOPQRSTUVWXYZ"
cnt = 0
for i, s in enumerate(S):
    if i == 0:
        if s != "A":
            ans = "WA"
            break
    elif 2 <= i <= len(S) - 2:
        if s == "C":
            cnt += 1
        elif s in w:
            ans = "WA"
            break
    else:
        if s in w:
            ans = "WA"
            break
if cnt != 1:
    ans = "WA"

print(ans)





Measured memory_bytes: 3060
#include <iostream>
#include<stdio.h>
#include <math.h>
using namespace std;


int main(){
	string S;
	cin >>S;
	int count=0;
	for(int i=0;i<3;i++){
		if(S[i]=='o'){
			count++;
		}
	}

	cout<<700+100*count<<endl;
	return 0;

}


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

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

using namespace std;

long long increment(long long x) {
  if (x < 10) {
    return x + 1;
  }
  long long a = x % 10;
  long long b = x / 10 % 10;
  if (a + 1 < 10 && a + 1 <= b + 1) {
    return x + 1;
  }
  long long res = increment(x / 10);
  if (res % 10 == 0) {
    return res * 10;
  }
  return res * 10 + (res % 10 - 1);
}

int main() {
  int K;
  cin >> K;

  long long x = 0;
  for (int i = 0; i < K; ++i) {
    x = increment(x);
  }
  cout << x << endl;
}


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

template <class A = std::string>
class Z_algorithm
{
    const A key;
    const size_t len;
    std::vector<size_t> z;
    bool is_built;
  public:
    Z_algorithm(const A &_key) : key(_key), len(_key.size()), is_built(false) {}

    const std::vector<size_t> &build()
    {
        assert(len);
        is_built = true;
        z.assign(len, 0);
        for(size_t i{1}, j{0}; i != len; ++i)
        {
            if(z[i - j] + i < z[j] + j)
            {
                z[i] = z[i - j];
            }
            else
            {
                size_t k{z[j] + j > i ? z[j] + j - i : 0};
                while(k + i < len && key[k] == key[k + i]) ++k;
                z[i] = k;
                j = i;
            }
        }
        z.front() = len;
        return z;
    }

    size_t size() const { return len; }
    size_t operator[](size_t i) const { return build(), z[i]; }

    std::vector<size_t> pattern_search(const A &str) const
    {
        A tmp(key);
        tmp.insert(end(tmp), begin(str), end(str));
        Z_algorithm other(tmp);
        const auto &nz = other.build();
        std::vector<size_t> res(nz.begin() + len, nz.end());
        for(size_t &x : res) if(x > len) x = len;
        return res;
    }
};

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

    int n; cin>>n;
    vector<int> a(n),b(n);
    for(int i=0; i<n; ++i)
    {
        cin>>a[i];
    }
    for(int i=0; i<n; ++i)
    {
        cin>>b[i];
    }
    vector<int> aa(n*2),bb(n);
    for(int i=0; i<n; ++i)
    {
        bb[i]=b[i]^b[(i+1)%n];
    }
    for(int i=0; i<n*2; ++i)
    {
        int ii=i%n;
        aa[i]=a[ii]^a[(ii+1)%n];
    }

    Z_algorithm<decltype(bb)> z(bb);

    auto pref(z.pattern_search(aa));

    for(int k=0; k<n; ++k)
    {
        if(pref[k]==bb.size())
        {
            cout << k << " " << (b[0]^a[k]) << "\n";
        }
    }
}

Measured memory_bytes: 17520
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	int N=sc.nextInt();
	int a[]=new int[N];
	for(int i=0;i<N;i++) {
		a[i]=sc.nextInt();
}
	int ans=0;
	int breakNum=0;
	int now=1;
	for(int i=0;i<N;i++) {
		if(a[i]==now) {
			ans+=breakNum;
			breakNum=0;
			now++;
		}else {
			breakNum++;
		}
}
	ans+=breakNum;
	if(N==breakNum) {
		System.out.println(-1);
	}else {
		System.out.println(ans);
	}

}
}

Measured memory_bytes: 74280
fn main() {
    let nk = read_vec::<i32>();
    let n = nk[0];
    let k = nk[1];
    let v = read_vec::<i32>();

    println!("{}", solve(n, k, v));
}

fn solve(n: i32, k: i32, v: Vec<i32>) -> i32 {
    let mut dp = vec![0; n as usize];

    for i in 1..n {
        let mut min = i32::max_value();
        for j in i-k..i {
            if j < 0 {
                continue;
            }

            let cost = (v[i as usize] - v[j as usize]).abs() + dp[j as usize];
            if cost < min {
                min = cost;
            }
        }
        dp[i as usize] = min;
    }

    dp[(n as usize) - 1]
}

#[test]
fn test1() {
    let n = 5;
    let k = 3;
    let v = vec![10, 30, 40, 50, 20];
    assert_eq!(30, solve(n, k, v));
}

#[test]
fn test2() {
    let n = 3;
    let k = 1;
    let v = vec![10, 20, 10];
    assert_eq!(20, solve(n, k, v));
}

#[test]
fn test3() {
    let n = 2;
    let k = 100;
    let v = vec![10, 10];
    assert_eq!(0, solve(n, k, v));
}

#[test]
fn test4() {
    let n = 10;
    let k = 4;
    let v = vec![40, 10, 20, 70, 80, 10, 20, 70, 80, 60];
    assert_eq!(40, solve(n, k, v));
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}



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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli dp[(1LL<<15)];

signed main(){

	lli n,m;
	cin>>n>>m;

	REP(i,0,(1LL<<15)){
		dp[i]=INF;
	}
	dp[0]=0;

	REP(i,0,m){
		lli a,b;
		cin>>a>>b;
		lli bit=0;
		REP(j,0,b){
			lli c;cin>>c;c--;
			bit |= (1LL<<c);
		}
		REP(j,0,(1LL<<15)){
			dp[j|bit] = min(dp[j|bit],dp[j]+a);
		}
	}
	if(dp[(1LL<<n)-1]==INF)cout<<-1<<endl;
	else cout<<dp[(1LL<<n)-1]<<endl;

	return 0;
}

Measured memory_bytes: 512
n = int(input())
robo = [0] * n
for i in range(n):
    x, l = map(int, input().split())
    robo[i] = (x - l, x + l)
robo.sort(key=lambda x: x[1])

max_r, cnt = -float('inf'), 0
for l, r in robo:
    if  max_r <= l:
        cnt += 1
        max_r = max(max_r, r)
print(cnt)

Measured memory_bytes: 18216
#include <iostream>
using namespace std;
int main(){
  int a,b,c; cin >>a>>b>>c;
  if ((a==b) and (b==c)) cout << 1 << endl;
  else if ((a==b) or (a==c) or (b==c)) cout << 2 << endl;
  else cout << 3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e18;
const double PI=3.1415926535897932;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod


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

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define f first
#define s second

using namespace std;

typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef long long ll;

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    cout << (n + 999) / 1000 * 1000 - n << '\n';
    return 0;
}


Measured memory_bytes: 3664