akhauriyash/Code-Regression huggingface dataset:
N, C, K = map(int,input().split())
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
time = T[0]
index = 0
buses = 1
passenger = 0
while index < N:
    if T[index] > time+K:
        buses += 1
        time = T[index]
        passenger = 0
    if passenger == C:
        buses += 1
        time = T[index]
        passenger = 0
    passenger += 1
    index += 1
if passenger == 0:
    print(str(buses-1))
else:
    print(str(buses))

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

int gcd(int x, int y) {
    int r;
    if (x < y) {
        swap(x, y);
    }
    while (y > 0) {
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main() {
    int a, b;
    cin >> a >> b;
    cout << gcd(a, b) << endl;
    
    return 0;
}


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

ll a[2005],b[2005][2005],n,x,ans=9e18;
int main()
{
    scanf("%lld%lld",&n,&x);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
    for(int i=1;i<=n;i++)
    {
        b[i][i]=a[i];
        for(int j=i+1;j<=n;j++)
        {
            b[i][j]=min(b[i][j-1],a[j]);
        }
    }
    for(ll i=0;i<n;i++)
    {
        ll temp=i*x;
        for(ll j=1;j<=n;j++)
        {
            int k=j-i;
            if(k<=0)
            {
                temp+=min(b[k+n][n],b[1][j]);
            }
            else temp+=b[k][j];
        }
        ans=min(ans,temp);
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 31104
#include <stdio.h>
#include <limits.h>

int main()
{
    int h,n;
    int a[1000],b[1000];
    scanf("%d%d",&h,&n);
    for(int i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);

    int dp[20001];for(int i=0;i<=20000;i++) dp[i]=-1;
    dp[0]=0;
    for(int i=0;i<h;i++)
    {
        if(dp[i]==-1)continue;
        for(int j=0;j<n;j++)
        {
            if(dp[i+a[j]]==-1)dp[i+a[j]]=dp[i]+b[j];
            else if(dp[i+a[j]]>dp[i]+b[j])dp[i+a[j]]=dp[i]+b[j];
        }
    }
    int min=INT_MAX;
    for(int i=h;i<=10000;i++)
    {
        if(dp[i]==-1)continue;
        else if(dp[i]<min)min=dp[i];
    }
    printf("%d\n",min);
}

Measured memory_bytes: 1784
import math
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
hand=[[] for _ in range(k)]
for i in range(len(t)):
    hand[i%k].append(t[i])

def janken(str):
    if str == "r":
        return p
    elif str == "s":
        return r
    else:
        return s

counter=0

for ha in hand:
    dp=[janken(ha[0])]
    if len(ha) == 1:
        counter += dp[0]
        continue

    if ha[0]==ha[1]:
        dp.append(dp[0])
    else:
        dp.append(janken(ha[0])+janken(ha[1]))
    
    for i in range(2,len(ha)):
        if ha[i-1] != ha[i]:
            dp.append(dp[i-1]+janken(ha[i]))
        elif ha[i] != ha[i-2]:
            dp.append(dp[i-1])
        elif dp[i-2] == dp[i-1]:
            dp.append(dp[i-1]+janken(ha[i]))
        else:
            dp.append(dp[i-1])
    counter += dp[-1]
            

print(counter)

Measured memory_bytes: 13436
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int N,K,i,ans;
deque<int> l(50);
inline void solve(){
  IN2(N,K);
  INS(i,N,l);
  sort(RALL(l));
  REP(i,K)ans+=l[i];
  OUT(ans);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
from scipy.sparse.csgraph import floyd_warshall
import numpy as np

N, M = map(int, input().split(" "))
graph = np.zeros((N, N))
edges = []
ans = 0
for l in range(M):
    a, b, c = map(int, input().split(" "))
    a = a - 1
    b = b - 1
    graph[a][b] = c
    graph[b][a] = c
    edges.append((a, b, c))
d = floyd_warshall(graph)
for e in edges:
    if e[2] > d[e[0], e[1]]:
        ans += 1
print(ans)


Measured memory_bytes: 25708
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int n, k;
    long long ans = 0;
    cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; i++) cin >> h[i];
    sort(h, h+n);
    for (int i = 0; i < n - k; i++) ans += h[i];
    cout << ans << endl;
}

Measured memory_bytes: 1024
k, q = map(int, input().split())
d = [int(x) for x in input().split()]

for _ in range(q):
    n, x, m = map(int, input().split())
    z = 0
    last = x
    ans = 0

    for i in range(k):
        dnum = (n-1-i+(k-1))//k
        last += d[i]%m * dnum
        if d[i]%m == 0:
            z += dnum
        
    ans = (n-1) - (last//m - x//m) - z
    print(ans)

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

#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back

const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll GetDigit(ll num) {return log10(num)+1;}

int main(){
    ll h, n;
    cin >> h >> n;
    ll a[n];
    for(ll i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);

    for(ll i = 0; i < n; i++){
        h -= a[i];
    }
    if(h <= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}


inline int addmod(int x ,int y){return (x%mod + y%mod)%mod;}
inline int submod(int x ,int y){return (x%mod - y%mod + mod)%mod;}
inline int mulmod(int x ,int y){return (x%mod *1LL* y%mod)%mod;}
inline int nextSubMask(int i , int mask) {return (i-1)&mask;} /// returns next smallest submask

void we_r_done(){cout<<"NO"; exit(0);}

void debug(bool ok , string mssg)
{
    if(ok)return;
    cout<<mssg;
    exit(0);
}

int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;

    int n,k;
    scn2(n,k);

    int a[n];

    for(int i=0; i<n; i++) scn(a[i]);

    sort(a,a+n);

    vector<int>d;

    for(int i=0; i<n; i++) d.pb(abs(k-a[i]));

    sort(atoz(d));

    int g = d[0];
    for(int i=1; i<d.size(); i++) g = __gcd(g, d[i]);
    cout<<g;


    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0 , -1};
struct mint {
  int x; // typedef long long ll;
  mint(int x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(int t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct UnionFind {
    vector<int> par, size;
    UnionFind(int x) {
        par.resize(x);
        size.resize(x, 1);
        for(int i = 0; i < x; i++) {
            par[i] = i;
        }
    }
    int find(int x) {
        if (par[x] == x)
            return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int consize(int x) {
        return size[find(x)];
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (size[x] < size[y]) {
            par[x] = y;
            size[y] += size[x];
        } else {
            par[y] = x;
            size[x] += size[y];
        }
    }
};
signed main() {
    int N;
    cin >> N;
    int ans = 0;
    int cnt = 0;
    for(int i = 0; i < N-1; i++) {
        int u,v;
        cin >> u >> v;
        cnt+=min(u,v)*(N-max(u,v)+1);
    }
    for(int i = 1; i <= N; i++) {
        ans+=i*(N-i+1);
    }
    cout << ans-cnt << endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int x, y;
	std::cin >> x >> y;
	if(y % 2 == 0 && x * 2 <= y && y <= x * 4) std::cout << "Yes\n";
	else std::cout << "No\n";
}

Measured memory_bytes: 3652
-module('Main').
-export([main/1]).

calc("maerd" ++ S) -> calc(S);
calc("remaerd" ++ S) -> calc(S);
calc("esare" ++ S) -> calc(S);
calc("resare" ++ S) -> calc(S);
calc([]) -> true;
calc(_) -> false.

solve() ->
    [S] = input("~s"),
    SRev = lists:reverse(S),
    io:format("~s~n", [case calc(SRev) of
        true -> "YES";
        false -> "NO"
    end]),
    ok.

main(_) ->
    solve(),
    halt().

input(Pat) ->
    {ok, L} = io:fread("", Pat),
    L.


Measured memory_bytes: 41236
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
  llong N;
  cin >> N;
  map<llong, int> m{};
  for(int i=0; i<N; ++i){
    llong a;
    cin >> a;
    if(m[a]==0) m[a] = 1;
    else{
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 12800
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

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

using namespace std;
typedef long long int ll;

int N;
string s[100000];
int main(void){
    cin >> N;
    rep(i,N) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }
    sort(s,s+N);

    ll count=0;
    int i = 0, j = 1;
    while(i<N){
        ll a = 0;
        if(j == N-1){
            if(s[i] != s[j]) a=j-i;
            else a=j-i+1;
            j++;
        }
        else if(s[i] != s[j]){
            a=j-i;
            i=j;
            j++;
        }else{
            j++;
            continue;
        }
        if(a > 1) {
            count += a*(a-1)/2;
        }
        if (j > N-1) break;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 8960
aList = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1,
         14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(aList[int(input())-1])


Measured memory_bytes: 2940
package main

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

func main() {
	sc := NewScanner()
	X := sc.NextInt()
	k := X / 100
	m := X % 100
	if k >= 20 {
		fmt.Println(1)
		return
	}
	if m <= k*5 {
		fmt.Println(1)
		return
	}
	fmt.Println(0)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
N, M = map(int, input().split())
ab = []
for _ in range(N):
    ab.append(tuple(map(int, input().split())))
cd = []
for _ in range(M):
    cd.append(tuple(map(int, input().split())))


for person in ab:
    x, y = person
    m = 10 ** 9
    togo = 0
    for i, checkpoint in enumerate(cd):
        cx, cy = checkpoint
        dist = abs(x - cx) + abs(y - cy)
        if dist < m:
            m = dist
            togo = i
            #print(x, y, cx, cy)
    print(togo + 1)


Measured memory_bytes: 39280
#include <stdio.h>
#include <string.h>

int main(){
	char s,t[5];
	t[4] = '\0';
	int flag = 0;
	int flag2 = 0;//dream**=1, erase*2, dreamer3
	int ret,ret2;
	while(1){
		ret = scanf("%c",&s);
		if(ret == EOF || s == '\n') break;
		if(s == 'd'){
			ret2 = scanf("%c%c%c%c",&t[0],&t[1],&t[2],&t[3]);
			if(ret2 == EOF || strcmp(t,"ream") != 0) flag = 1;
			flag2 = 1;
		}else if(s == 'e'){
			if(flag2 == 0 || flag2 == 3 || flag2 == 2){
				ret2 = scanf("%c%c%c%c",&t[0],&t[1],&t[2],&t[3]);
				if(ret2 == EOF || strcmp(t,"rase") != 0) flag = 1;
				flag2 = 2;
			}else if(flag2 == 1){//(~dream)e
				ret2 = scanf("%c",&t[0]);
				if(ret2 == EOF || t[0] != 'r') flag = 1;
				else flag2 = 3;// -> (~dreamer)(~) or (~dreamer)ase(r)(~)
			}else flag = 1;
		}else if(flag2 == 2 && s == 'r') flag2 = 0;
		else if(flag2 == 3 && s == 'a'){
			ret2 = scanf("%c%c",&t[0],&t[1]);
			if(ret2 == EOF || t[0] != 's' || t[1] != 'e') flag = 1;
			else flag2 = 2;
		}
		else flag = 1;
		
		if(flag == 1) break;
	}
	
	if(flag == 0) printf("YES\n");
	else printf("NO\n");
	
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
using namespace std;

int n,m,l,r;
long long a[100010],b[100010],ans,ans1;

int main()
{
	scanf("%d",&n);l=1;r=n;
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	for (int i=2;i<n;i++) b[i]=2;
	b[1]=b[n]=1;
	for (int i=1;i<=n;i++)
		if (i&1) b[i]=-b[i];
	for (int i=2;i<n;i++)
	{
		if (b[i]>0) ans+=a[r--]*b[i];
		else ans+=a[l++]*b[i];
	}
	if (b[1]==b[n]) ans+=a[l]*b[1]+a[r]*b[n];
	else ans+=a[r]-a[l];
	for (int i=1;i<=n;i++) b[i]=-b[i];
	l=1;r=n;
	for (int i=2;i<n;i++)
	{
		if (b[i]>0) ans1+=a[r--]*b[i];
		else ans1+=a[l++]*b[i];
	}
	if (b[1]==b[n]) ans1+=a[l]*b[1]+a[r]*b[n];
	else ans1+=a[r]-a[l];
	printf("%lld\n",max(ans,ans1));
	return 0;
}

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

using namespace std;

int main() {
	int X;
	cin >> X;
	int num500 = X / 500;
	int num5 = (X - 500 * num500) / 5;
	int ans = num500 * 1000 + num5 * 5;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include <string> 
using namespace std;

int main(){
	float x1,x2,x3,x4,y1,y2,y3,y4;
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
			scanf("%f %f %f %f %f %f %f %f",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		if( ((y1-y2)==0&&(y3-y4)!=0&&(x1-x2)==0&&(x3-x4)!=0) || ((x1-x2)!=0&&(x3-x4)==0&&(y1-y2)==0&&(y3-y4)!=0)){
			
				printf("NO\n");
		}
			else if((y1-y2)*(x3-x4)==(x1-x2)*(y3-y4)){
				printf("YES\n");
			}
			else{
				printf("NO\n");
			}
		}
	
	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x, b, t, candy=0;
    cin>>x>>b>>t;
    int time=x;
    while(time<=t)
    {
        candy+=b;
        time+=x;
    }
    cout<<candy;
}


Measured memory_bytes: 3580
s = str( input() )
t = str( input() )

def compare( s, t ):
    count = 0
    for i in range( len( s ) ):
        if s[ i ] != t[ i ]:
            count += 1
    return count

ans = 10 ** 10
for i in range( len( s ) - len( t ) + 1 ):
    ans_i = compare( s[ i : i + len( t ) ], t )
    if ans_i < ans or i == 0:
        ans = ans_i

print( ans )

Measured memory_bytes: 9068
s=int(input())
s1=s//100
s2=s-s1*100
if 0<s1<=12 and 0<s2<=12:
    print("AMBIGUOUS")
elif 0<s1<=12:
    print("MMYY")
elif 0<s2<=12:
    print("YYMM")
else:
    print("NA")

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

int main()
{
    int h,w; cin>>h>>w;
    int n; cin>>n;

    int num = 0 ;
    if(h>w)
    {
        num = ceil((double)n/(double)h);

    }
    else
    {
        num = ceil((double)n/(double)w);
    }
    cout<<num<<endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    T, A = map(float, input().split())
    H = list(map(float, input().split()))

    diff = list()
    for i in range(N):
        diff.append(abs((T-H[i]*0.006)-A))
    print(diff.index(min(diff))+1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main()
{
    char mozi[1003] = {0};
    scanf("%s",mozi);
    for(int i = 0;i < 1000;i++){
        if(mozi[i] == 0)break;
        mozi[i] -= 3;
        if(mozi[i] < 65)mozi[i] += 26;
        printf("%c",mozi[i]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 1100
s = input()
a = list(s)
#print(len(s))
bad_count = 0

for i in range(len(s)):
 # print(a[2 * i: 2* i + 1:1])
 # print(a[2 * i + 1 : 2 * i + 1 + 1 : 1])
 # print(i)
  if(i % 2 == 1):		# EVEN
    if a[i] == "R":
      bad_count += 1
    #  print("ODD",bad_count)
  else:
    if a[i] == "L":	# ODD
      bad_count += 1
    #  print("EVEN",bad_count)

#print(bad_count)

if bad_count == 0:    
  print("Yes")
else:
  print("No")
  

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    cout << (n + 1000 - 1) / 1000 * 1000 - n << '\n';

    return 0;
}


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

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

 int matrix_a[n][m];
 int matrix_b[m][l];
 long long matrix_c[n][l];

 int a_num=0;
 for( int i=0; i<n; i++ ){
  for( int j=0; j<m; j++ ){
    cin >> a_num;
    matrix_a[i][j] = a_num;
  }
 }

 int b_num=0;
 for( int i=0; i<m; i++ ){
  for( int j=0; j<l; j++ ){
    cin >> b_num;
    matrix_b[i][j] = b_num;
  }
 }

 for( int i=0; i<n; i++ ){
  for( int j=0; j<l; j++ ){
   matrix_c[i][j] = 0;
   for( int k=0; k<m; k++ ){
    matrix_c[i][j] += matrix_a[i][k]*matrix_b[k][j];
   }
  }
 }

 for( int i=0; i<n; i++ ){
  for( int j=0; j<l; j++ ){
    if( j!=l-1 ){
      cout << matrix_c[i][j] << " ";
    }else{
      cout << matrix_c[i][j];
    }
  }
  cout << endl;
 }

 return 0;
}


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

int main(){
	string s;
	while(getline(cin,s)){
		if(s.size()==1 && s[0]=='.')break;
		stack<int>st;
		bool suc=true;
		for(int i=0;i<s.size();i++){
			if(s[i]=='[')st.push(0);
			if(s[i]=='(')st.push(1);
			
			if(s[i]==']'){
				if(st.empty())suc=false;
				else if(st.top()==1)suc=false; 
				else if(st.top()==0)st.pop();
			}
			if(s[i]==')'){
				if(st.empty())suc=false;
				else if(st.top()==0)suc=false;
				else if(st.top()==1)st.pop();
			}
			
		}
		
		if(!st.empty())suc=false;
		if(suc)cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
}

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

using namespace std;
using ll = long long;

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

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

  int a[m];
  vector<vector<int>> c(m);
  rep(i, m) {
    int x;
    cin >> a[i] >> x;
    rep(j, x) {
      int y;
      cin >> y;
      --y;
      c[i].push_back(y);
    }
  }

  ll dp[m + 1][1 << n];
  const int INF = 1001001001;
  rep(i, m + 1) rep(j, 1 << n) dp[i][j] = INF;
  rep(i, m + 1) dp[i][0] = 0;

  rep(i, m) {
    rep(j, 1 << n) {
      int nj = j;
      for (auto v : c[i]) {
        nj |= (1 << v);
      }
      dp[i + 1][nj] = min(dp[i + 1][nj], dp[i][j] + a[i]);
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      // if (dp[i + 1][nj] < 0) dp[i + 1][nj] = INF;
      // if (dp[i + 1][j] < 0) dp[i + 1][j] = INF;
    }
  }

  int ans = dp[m][(1 << n) - 1];
  if (ans >= INF || ans < 0) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 32384
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int g[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    int x, y;
    cin >> x >> y;
    if (g[x] == g[y]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main()
{
	int N;
	cin>>N;
	int ans=0;
	int flag=0;
	for (int i=1;i<=N;i++)
	{
		int p;
		cin >> p;
		if (p==i)
		{
			ans++;
			flag++;
			if (flag==2)
			{
				ans--;
				flag=0;
			}
		}
		else
			flag=0;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/

#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;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 200005
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp, marked;
set<ll> s;
string S = "";
ll cases;

void precompute() {
	fei(i, 1, 1000000, 1) {
		if(mp[i]) {
			if(mp[i] >= 2) {
				marked[i]++;
			}			
			for(int j = 2; i * j <= 1000000; j++) {
				marked[i * j]++;
			}
		}
	}
}

int main() {
	go;
    cin >> N;
    fi(i, 0, N, 1) {
    	cin >> arr[i];
    	mp[arr[i]]++;
    }
    precompute();
    ll cnt = 0;
    fi(i, 0, N, 1) {
    	if(!marked[arr[i]]) {
    		cnt++;
    	}
    }
    cout << cnt << "\n";
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 83792
fun main(args: Array<String>) {
    val N = nextInt()
    val S = Array(N) { nextInt() }.sorted()
    val M = S.filter { it % 10 != 0 }
    var ans = S.sum()
    if (ans % 10 == 0 && M.size > 0) ans -= M[0]
    println(if (ans % 10 == 0) 0 else ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }
fun listOfLong(offset: Long = 0L) = listOfString().map { it.toLong() + offset}


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

int main() {
  string s;
  cin >> s;
  int len = s.length();
  int cnt = 0;
  for (int i = 0; i < len / 2; ++i)
    if (s[i] != s[len - i - 1]) cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {

	string s;
	int ans_1 = 0, ans_2 = 0;

	cin >> s;

	for (int i = 0; i < s.length()/2; i++) {
		ans_1 += (static_cast<int>(s[2*i]-'0') ^ 0) + (static_cast<int>(s[2*i+1] - '0') ^ 1);
		ans_2 += (static_cast<int>(s[2*i]-'0') ^ 1) + (static_cast<int>(s[2*i+1] - '0') ^ 0);
		//cout << static_cast<int>(s[i]-'0') << endl;
	}

	if (s.length() % 2 == 1) {
		ans_1 += static_cast<int>(s[s.length()-1] - '0') ^ 0;
		ans_2 += static_cast<int>(s[s.length()-1] - '0') ^ 1;
	}

	if (ans_1 < ans_2) {
		cout << ans_1 << endl;
	} else {
		cout << ans_2 << endl;
	}

	return 0;
}

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

int n;
bool flg[22][22];

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

int main(){
  while(cin >> n, n){
    memset(flg, 0, sizeof(flg));
    for(int i = 0; i < n; i++){
      int x, y;
      cin >> x >> y;
      flg[x][y] = true;
    }

    int m;
    cin >> m;

    int x = 10;
    int y = 10;

    while(m--){
      char dch;
      int d;
      int k;
      cin >> dch >> k;

      if(dch == 'N') d = 0;
      if(dch == 'E') d = 1;
      if(dch == 'S') d = 2;
      if(dch == 'W') d = 3;

      for(int i = 0; i < k; i++){
        x += dx[d];
        y += dy[d];

        if(flg[x][y]){
          flg[x][y] = false;
          n--;
        }
      }
    }

    cout << (n == 0 ? "Yes" : "No") << endl;
  }
}

Measured memory_bytes: 0
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANNOT ASSIGN A VALUE OF 10^18 IT WILL ASSIGN A LOWER VALUE THAN THAT!!!
//NOTE THAT MEMSET CANT FILL THE DOUBLE VALUES;
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 2000000000000000005
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long

 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>

 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){int g = gcd(a, m); { return power(a, m-2, m);}}

  
void solve()
{
    
    string s;cin>>s;
    ll n = s.length();
    ll dp[n+3][2];
    memset(dp,0,sizeof dp);
    dp[0][0]=1;
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='0')
        {
            (dp[i+1][1]+=dp[i][1]*3)%=MOD;
            (dp[i+1][0]+=dp[i][0])%=MOD;
        }
        else
        {
            ((dp[i+1][1])+=dp[i][1]*3)%=MOD;
            (dp[i+1][1]+=dp[i][0])%=MOD;
            (dp[i+1][0] = 2*dp[i][0])%=MOD;
        }
    }
    cout<<(dp[n][0]+dp[n][1])%MOD<<endl;
}

signed main()
{
   
    Need_for_speed(activated);
//satisfy
//    {
//   solve();
//   }
   
    solve();
    return 0;
}


Measured memory_bytes: 2000
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
   int a,b;cin>>a>>b;
   cout<<(a%3==0 || b%3==0 ||(a+b)%3==0?"Possible":"Impossible");
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MAX 10000001

static bool gosei[MAX];

void a() {
	for (int i = 2; i <= sqrt(MAX); i++)
		if (gosei[i] == false) {
			for (int j = 2, k = 0; (k = i*j) <= MAX; j++)
				gosei[k] = true;
		}
}

int c(int a) {
	if (a % 2 == 0)return 0;
	for (int i = 3; i <= sqrt(a); i += 2)
		if (a%i == 0)
			return 0;
	return 1;
}

int main() {
	a();
	int b = 0;
	for (int a; cin >> a;) {
		if (a < MAX) {
			if (!gosei[a])b++;
		}
		else
			b += c(a);
	}
	cout << b << endl;
	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  int x[m];
  for (int i = 0; i < m; i++) {
    cin >> x[i];
  }

  if (n >= m) {
    // 最初からすべてのMiにコマを配置する。
    cout << 0 << endl;
    return 0;
  }

  sort(x, x + m);
  ll dif[m - 1];
  for (int i = 0; i < m - 1; i++) {
    dif[i] = (x[i + 1] - x[i]);
  }
  sort(dif, dif + (m - 1), greater<ll>());

  ll ans = x[m - 1] - x[0];
  // 長い区間を除外していく
  for (int i = 0; i < n - 1; i++) {
    ans -= dif[i];
  }

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

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

        String s;
        int[] counter = new int[26];
        char temp;
        while(scanner.hasNext()){
        s = scanner.nextLine();
        for(int i = 0; i < s.length(); i++){
            temp = s.charAt(i);
            if(temp >= 'A' && temp <= 'Z'){
                int index = temp - 'A';
                counter[index]++;
            }
            else if(temp >= 'a' && temp <= 'z'){
                int index = temp - 'a';
                counter[index]++;
            }
        }
        }
        for(int i = 0; i < 26; i++){
            System.out.println((char)(i+'a') + " : "+ counter[i]);
        }

    }
}



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

int main(){
 int a,b;
 char op;
 while(true){
  cin>>a>>op>>b;
  if(op=='+'){
    cout<<a+b<<'\n';
  }
  if(op=='-'){
    cout<<a-b<<'\n';
  }
  if(op=='*'){
    cout<<a*b<<'\n';
  }
  if(op=='/'){
    cout<<a/b<<'\n';
  }
  if(op=='?'){
    break;
  }
 }
 return 0;
}

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

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

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

//---------------------------------------------------------------------------------------------------

struct Edge {
    int from, to;
    i64 cost;
    Edge() {}
    Edge(int t, i64 c) : from(-1), to(t), cost(c) {}
    Edge(int f, int t, i64 c) : from(f), to(t), cost(c) {}

    bool operator<(const Edge& r) const {
        return cost < r.cost;
    }
    bool operator>(const Edge& r) const {
        return cost > r.cost;
    }
};

using Vertex = vector<Edge>;
using Graph  = vector<Vertex>;

// 無向
void link(Graph& g, int from, int to, int cost = 1) {
    g[from].push_back(Edge(from, to, cost));
    g[to].push_back(Edge(to, from, cost));
    return;
}

// 有向
void connect(Graph& g, int from, int to, int cost = 1) {
    g[from].push_back(Edge(from, to, cost));
    return;
}

vector<i64> dijkstra(const Graph& g, int start) {
    const auto inf = numeric_limits<i64>::max();
    vector<i64> dist(g.size(), inf);

    using Pi = pair<i64, int>;
    priority_queue<Pi, vector<Pi>, greater<Pi>> que;
    dist[start] = 0;
    que.push(make_pair(0, 0));
    while (!que.empty()) {
        const auto e    = que.top();
        const auto cost = e.first;
        const auto from = e.second;
        que.pop();
        if (dist[from] < cost) continue;

        for (const auto& e : g[from]) {
            const auto next_cost = e.cost + cost;
            if (chmin(dist[e.to], next_cost)) {
                que.push(make_pair(next_cost, e.to));
            }
        }
    }

    return dist;
}

//---------------------------------------------------------------------------------------------------

signed main() {
    int N;
    cin >> N;
    Graph G(N);
    rep(i, 0, N) {
        int u, k;
        cin >> u >> k;
        rep(j, 0, k) {
            int v, c;
            cin >> v >> c;
            connect(G, u, v, c);
        }
    }
    auto dist = dijkstra(G, 0);
    rep(i, 0, N) {
        cout << i << " " << dist[i] << "\n";
    }
}



Measured memory_bytes: 11900
N,M =  list(map(int, input().split()))
LR = [list(map(int, input().split())) for _ in range(M)]
left = 0
right = N -1 

for l,r in LR:
    left = max(left,l -1)
    right = min(right,r -1)

if left > right:
    print(0)
else:
    print( right - left +1)


Measured memory_bytes: 27332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC167C()
{
	int N, M, X;
	cin >> N >> M >> X;
	vi C(N);
	vvi A(N, vi(M));
	for (int i = 0; i < N; ++i)
	{
		cin >> C[i];
		for (int j = 0; j < M; ++j)
			cin >> A[i][j];
	}

	int ans = 1000000000;
	for (int k = 0; k < (1 << N); ++k)
	{
		vi B(M);
		int sum = 0;
		for (int i = 0; i < N; ++i)
		{
			if (!(k & (1 << i)))
				continue;
			for (int j = 0; j < M; ++j)
			{
				B[j] += A[i][j];
			}
			sum += C[i];
		}
		bool isOk = true;
		for (int j = 0; j < M; ++j)
		{
			if (B[j] < X)
			{
				isOk = false;
				break;
			}
		}
		if (isOk)
		{
			ans = min(sum, ans);
		}
	}
	if (ans == 1000000000)
	{
		cout << "-1" << endl;
		return;
	}
	cout << ans << endl;
}

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


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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end



int main(){
   int n,x; cin>>n>>x;
   int m=2*n-1;
   if(x==1 or x==m){
      puts("No"); return 0;
   }
   puts("Yes");
   vector<int> res(m); iota(ALL(res),1);
   swap(res[x-1],res[n-1]); swap(res[0],res[n-2]); swap(res.back(),res[n]);
   rep(i,0,m)cout<<res[i]<<" ";
   return 0;
}

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

bool is_acgt(string t) {
    for (auto iter = begin(t); iter != end(t); ++iter) {
        if (*iter != 'A' && *iter != 'C' && *iter != 'G' && *iter != 'T') {
            return false;
        }
    }
    return true;   
}


int main() {
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            if (is_acgt(s.substr(i, j - i + 1))) {
                ans = max(ans, j - i + 1);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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


#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16

// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

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

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

vi a(200005);

void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U; 
    // int a,b;
    cin>>n;
    vi a(n);
    rep(i,0,n)
    {
        cin>>a[i];
    }
    t=a[0];
    rep(i,1,n)
    {
        t^=a[i];
    }
    // t=a[0]^a[2]^a[3]^a[1];
    rep(i,0,n)
    {
        u=t^a[i];
        cout<<u<<" ";
    }
}


signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 6328
#include <iostream>
#include <vector>
using namespace std;
int main(){
  vector<char> A_c, B_c, C_c, ans_c;
  vector<int> A_l, B_l, C_l, ans_l;
  char c_ = '!';
  int l;
  while(cin >> c_, c_ != '$'){
    cin >> l;
    A_c.push_back(c_);
    A_l.push_back(l);
  }
  c_ = '!';
  while(cin >> c_, c_ != '$'){
    cin >> l;
    B_c.push_back(c_);
    B_l.push_back(l);
  }
  c_ = '!';
  while(cin >> c_, c_ != '$'){
    cin >> l;
    C_c.push_back(c_);
    C_l.push_back(l);
  }
  int a = A_c.size(), b = B_c.size(), c = C_c.size();
  bool g = false;
  for(int i = 0; i < a; ++i){
    bool f = true;
    for(int j = 0; j < b; ++j){
      if(g || i + j >= a){
        f = false;
        break;
      }
      if((A_c[i+j] != B_c[j]) ||
         (j > 0 && j < b - 1 && A_l[i+j] != B_l[j]) ||
         ((j == 0 || j == b-1) && A_l[i+j] < B_l[j])){
        f = false;
        break;
      }
    }
    if(f){
      g = true;
      if(B_l.size() > 1 && A_l[i] - B_l[0] > 0){
        ans_c.push_back(A_c[i]);
        ans_l.push_back(A_l[i] - B_l[0]);
      }
      for(int j = 0; j < c; ++j){
        if(ans_c.size() > 0 && ans_c.back() == C_c[j])
          ans_l.back() += C_l[j];
        else{
          ans_c.push_back(C_c[j]);
          ans_l.push_back(C_l[j]);
        }
      }
      if(A_l[i+b-1] - B_l.back() > 0){
        if(ans_c.size() > 0 && ans_c.back() == A_c[i+b-1])
          ans_l.back() += A_l[i+b-1] - B_l.back();
        else{
          ans_c.push_back(A_c[i+b-1]);
          ans_l.push_back(A_l[i+b-1] - B_l.back());
        }
      }
      i += b - 1;
    }else{
      if(ans_c.size() > 0 && ans_c.back() == A_c[i])
        ans_l.back() += A_l[i];
      else{
        ans_c.push_back(A_c[i]);
        ans_l.push_back(A_l[i]);
      }
    }
  }
  for(int i = 0; i < ans_c.size(); ++i){
    cout << ans_c[i] <<  " " << ans_l[i] << " ";
  }
  cout << "$" << endl;
  return 0;
}



Measured memory_bytes: 3180
A,B,C_AB,X,Y = map(int, input().split())
if A+B >= 2*C_AB:
  print(2*C_AB*(min(X,Y)) + min(A,2*C_AB)*(X-min(X,Y)) + min(B,2*C_AB)*(Y-min(X,Y)))
else:
  print(A*X+ B*Y)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

int n;
string s;
map<string, int> mp;
int cnt;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s;
        mp[s]++;
        cnt = max(cnt, mp[s]);
    }

    for (auto x:mp) {
        if (x.second == cnt) cout << x.first << endl;
    }

    return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main(){
    int n;
    cin>>n;
    if(n<1200)cout<<"ABC"<<endl;
    else if(n<2800)cout<<"ARC"<<endl;
    else cout<<"AGC"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:

};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;

    string res;
    for (int i = 0; i < n; ++i) {
        res += s[i];
        res += t[i];
    }
    cout << res << "\n";

    return 0;
}

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

int main()
{
  int r, d, x;
  cin >> r >> d >> x;
  int buf;
  for (int i = 0; i < 10; i++)
  {
    if (i == 0)
    {
      buf = r * x - d;
    }
    else
    {
      buf = r * buf - d;
    }

    cout << buf << endl;
  }
}


Measured memory_bytes: 3588