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

void main_()
{
    ll N;
    cin >> N;

    queue<pair<string, char>> que;
    que.emplace("a", 'a');

    while (!que.empty()) {
        auto s = que.front();
        que.pop();
        if ((ll)s.first.size() == N) {
            cout << s.first << "\n";
        } else {
            for (auto ch = 'a'; ch <= s.second; ch++) {
                que.emplace(s.first + ch, s.second);
            }
            que.emplace(s.first + (char)(s.second + 1), s.second + 1);
        }
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

int N;
int Sanba[1 << 20];
int Ret[1 << 20];
string T;
vector<int> C[1 << 20];

int power[1 << 20];
int powerru[1 << 20];
int Answer[1 << 20];

void init() {
	power[0] = 1; powerru[0] = 1;
	for (int i = 1; i <= 18; i++) power[i] = 3 * power[i - 1];
	for (int i = 1; i <= 18; i++) powerru[i] = powerru[i - 1] + power[i];
}

int main() {
	cin >> N >> T; init();
	for (int i = 0; i < T.size(); i++) {
		Sanba[i + 1] = Sanba[i];
		if (T[i] == 'S') Sanba[i + 1] += 1;
	}

	// 最初の計算
	for (int i = 1; i <= 3; i++) {
		int cur = (i - 1);
		for (int j = 0; j < T.size(); j++) {
			if (T[j] == 'S') {
				if (cur == 1) cur = 2;
				else if (cur == 2) cur = 1;
			}
			if (T[j] == 'R') {
				cur += 1;
				if (cur == 3) { C[i].push_back(j); cur = 0; }
			}
		}
		Ret[i] = cur;
	}

	// 計算
	for (int i = 1; i < powerru[N - 1]; i++) {
		for (int j = 0; j < 3; j++) {
			int nex = i * 3 + (j + 1);
			int cx = -1, cur = j;
			for (int k : C[i]) {
				int steps = Sanba[k + 1] - Sanba[cx + 1];
				if ((steps & 1) == 1) {
					if (cur == 1) cur = 2;
					else if (cur == 2) cur = 1;
				}
				cur += 1;
				if (cur == 3) { C[nex].push_back(k); cur = 0; }
				cx = k;
			}
			int steps2 = Sanba[T.size()] - Sanba[cx + 1];
			if ((steps2 & 1) == 1) {
				if (cur == 1) cur = 2;
				else if (cur == 2) cur = 1;
			}
			Ret[nex] = cur;
		}
	}

	// 答えを出力
	for (int i = powerru[N - 1]; i < powerru[N]; i++) {
		int cx = i, ans = 0, pow = N, rem = 0;
		while (cx >= 1) {
			pow -= 1;
			ans += power[pow] * Ret[cx];
			rem += power[pow] * ((cx - 1) % 3);
			cx = (cx - 1) / 3;
		}
		Answer[rem] = ans;
	}

	for (int i = 0; i < power[N]; i++) {
		if (i) printf(" "); printf("%d", Answer[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 58280
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

map<int, int> m;
int inp[200010];
signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> inp[i];
        m[inp[i]]++;
    }
    int tmpans = 0;
    for (auto iter : m)
    {
        tmpans += iter.second * (iter.second - 1) / 2;
    }
    int ans;
    REP(i, N)
    {
        ans = tmpans;
        ans -= m[inp[i]] * (m[inp[i]] - 1) / 2;
        ans += (m[inp[i]] - 1) * (m[inp[i]] - 2) / 2;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 11136
import java.math.BigInteger;
import java.security.cert.CollectionCertStoreParameters;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	int[] f;
	boolean[] cycle;
	ArrayList<Integer>[] g;
	int n;
	int[] p;

	public void run() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		p = new int[n];
		g = new ArrayList[n];
		cycle = new boolean[n];
		f = new int[n];
		for (int i = 0; i < n; ++i) {
			g[i] = new ArrayList<>();
		}
		for (int i = 0; i < n; ++i) {
			p[i] = sc.nextInt();
			--p[i];
			g[p[i]].add(i);
		}

		int v = 0;
		for (int i = 0; i < n; ++i) {
			v = p[v];
		}
		for (int i = 0; i < n; ++i) {
			cycle[v] = true;
			v = p[v];
		}
		Arrays.fill(f, -1);
		for (int i = 0; i < n; ++i) {
			if (!cycle[i] && f[i] == -1) {
				dfs(i);
			}
		}

		boolean ans = false;
		ArrayList<Integer> lis = new ArrayList<>();
		for (int dst : g[v]) {
			if (f[dst] != -1)
				lis.add(f[dst]);
		}
		ans |= solve(v, fgrundy(lis));
		ans |= solve(v, sgrundy(lis));
		System.out.println(ans ? "POSSIBLE" : "IMPOSSIBLE");
	}

	boolean solve(int v, int val) {
		int[] h = Arrays.copyOf(f, n);
		h[v] = val;
		for (int u = p[v]; u != v; u = p[u]) {
			ArrayList<Integer> lis = new ArrayList<>();
			for (int dst : g[u]) {
				lis.add(h[dst]);
			}
			h[u] = fgrundy(lis);
		}
		ArrayList<Integer> lis = new ArrayList<>();
		for (int d : g[v]) {
			lis.add(h[d]);
		}
		return fgrundy(lis) == val;
	}

	int sgrundy(ArrayList<Integer> lis) {
		lis.add(fgrundy(lis));
		return fgrundy(lis);
	}

	int fgrundy(ArrayList<Integer> lis) {
		Collections.sort(lis);
		if (lis.isEmpty() || lis.get(0) != 0)
			return 0;
		else {
			for (int i = 1; i < lis.size(); ++i) {
				if (lis.get(i - 1) + 1 < lis.get(i)) {
					return lis.get(i - 1) + 1;
				}
			}
			return lis.get(lis.size() - 1) + 1;
		}
	}

	void dfs(int cur) {
		ArrayList<Integer> lis = new ArrayList<>();
		for (int dst : g[cur]) {
			if (f[dst] == -1)
				dfs(dst);
			lis.add(f[dst]);
		}
		f[cur] = fgrundy(lis);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 109844
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 10;
int N;
int num[10];
int dig[MAXN];
int top = 3; 
bool isSubsequence()
{
	int i = 1, j = 1;
	while (i <= N && j <= 3)
	{
		if (dig[i] == num[j])
		{
			i++;
			j++;
		} else {
			i++;
		}
	}
	if (j >= 4)
	{
		return true;
	} else {
		return false;
	} 
} 
int main()
{
	cin >> N;
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++)
	{
		dig[i + 1] = s[i] - '0';
	}
	int ans = 0;
	for (int i = 0; i <= 999; i++)
	{
		top = 3;
		int n = i;
		for (int i = 3; i >= 1; i--)
		{
			num[i] = n % 10;
			n /= 10; 
		}
		if (isSubsequence())
		{
			ans++;	
		} 
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(
            new InputStreamReader(System.in));
        List<String> lists = Arrays.asList(br.readLine().split(" "));
        System.out.println(lists.stream().sorted(Comparator.naturalOrder())
            .collect(Collectors.joining(" ")));
    }
}

Measured memory_bytes: 30928
#include<bits/stdc++.h>
using namespace std;
const double pi = acos(-1);

int32_t main () {
	int n;
	cin >> n;
	vector<int> arr(n+1, 0);
	for(int i = 1; i < n; i ++) {
		int x; cin >> x;
		arr[x] ++;
	}
	for(int i = 1; i <= n; i ++) {
		cout << arr[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 4052
S = list(map(str, input()))

bool = True
i = 0
while i != len(S):
    if i%2 == 0 and S[i] == 'R' or S[i] == 'U' or S[i] == 'D':
        bool = True
        i += 1
    elif i%2 == 1 and S[i] == 'L' or S[i] == 'U' or S[i] == 'D':
        bool = True
        i += 1
    else:
        bool = False
        i = len(S)
        
if bool:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
# CGL_5_A: Point Set - Closest Pair

from operator import itemgetter
from math import sqrt


def closest_distance(ps):
    def split(i, j):
        if j - i < 2:
            return float('INF')
        mid = (i + j) // 2
        d = min(split(i, mid), split(mid, j))
        lv, rv = ps[mid][0]-d, ps[mid][0]+d
        return merge(sorted([p for p in ps[i:j] if lv <= p[0] <= rv],
                            key=itemgetter(1)), d)

    def merge(_ps, d):
        n = len(_ps)
        for i in range(n-1):
            for j in range(i+1, n):
                if d < _ps[j][1] - _ps[i][1]:
                    break
                d = min(d, distance(_ps[i], _ps[j]))

        return d

    ps.sort(key=itemgetter(0, 1))
    return split(0, len(ps))


def dot(p0, p1):
    x0, y0 = p0
    x1, y1 = p1
    return x0*x1 + y0*y1


def distance(p0, p1):
    x0, y0 = p0
    x1, y1 = p1
    return sqrt((x1-x0)**2 + (y1-y0)**2)


def run():
    n = int(input())
    ps = []

    for _ in range(n):
        x, y = [float(i) for i in input().split()]
        ps.append((x, y))

    print("{:.10f}".format(closest_distance(ps)))


if __name__ == '__main__':
    run()



Measured memory_bytes: 25476
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <limits.h>
 
#define YesNo(b) ((b) ? "Yes" : "No")
#define YESNO(b) ((b) ? "YES" : "NO")

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;


ll f(ll N)
{
    if (N % 2 == 1) return 0;
    N /= 2;

    ll c5 = 0;
    while (N >= 5)
    {
        c5 += N / 5;
        N /= 5;
    }
    return c5;
}

int main()
{
    ll N;
    cin >> N;

    cout << f(N) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define REP(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define SZ(i) int(i.size())
#define eb emplace_back
#define ALL(i) i.begin(),i.end()
#define X first
#define Y second
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"#%d: %s = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
template<typename It> ostream& _printRng(ostream &os,It bg,It ed)
{
    os<<"{";
    for(It it=bg;it!=ed;it++) {
        os<<(it==bg?"":",")<<*it;
    }
    os<<"}";
    return os;
}
template<typename T> ostream &operator << (ostream &os,vector<T> &v){return _printRng(os,v.begin(), v.end());}
template<typename T> void pary(T bg, T ed){_printRng(cerr,bg,ed);cerr<<endl;}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#define pary(...)
#endif

const int MAXN = 302;
const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;

int n, k, h[MAXN];
vector<int> H;

ll dp[MAXN][MAXN][MAXN]; // n, k, h
ll gr[MAXN][MAXN][MAXN], le[MAXN][MAXN][MAXN];

void build (int i, int j) {
    ll bst = INF;
    for (int l=0; l<SZ(H); l++) {
        bst = min(bst,dp[i][j][l]-H[l]);
        le[i][j][l] = bst;
    }
    bst = INF;
    for (int l=SZ(H)-1; l>=0; l--) {
        bst = min(bst, dp[i][j][l]);
        gr[i][j][l] = bst;
    }
}
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n >> k;
    REP (i, n) {
        cin >> h[i];
        H.eb(h[i]);
    }

    H.eb(0);
    sort(ALL(H));
    H.resize(unique(ALL(H))-H.begin());
    REP (i, n) {
        h[i] = lower_bound(ALL(H),h[i])-H.begin();
    }

    memset(dp, 0x3f, sizeof(dp));
    dp[0][0][0] =0;

    for (int i=0; i<=n; i++) {
        for (int j=0; j<=k; j++) {
            build(i,j);
        }
    }

    ll res = INF;
    for (int i=1; i<=n; i++) {
        for (int j=0; j<=k; j++) {
            for (int l=0; l<SZ(H); l++) {
                ll bst = INF;
                if (l != h[i-1]) {
                    if (j > 0) {
                        bst = min(le[i-1][j-1][l]+H[l], gr[i-1][j-1][l]);
                    }
                } else {
                    bst = min(le[i-1][j][l]+H[l], gr[i-1][j][l]);
                }
                debug(i, j, l, bst);
                dp[i][j][l] = bst;
                if (i == n) {
                    res = min(res, dp[i][j][l]);
                }
            }
            build(i,j);
        }
    }

    cout << res << endl;


}


Measured memory_bytes: 645760
class Combination:
    def __init__(self, n_max=10**6, mod=10**9+7):
        # self._n_max = n_max
        self._fac, self._finv, self._inv = [0]*n_max, [0]*n_max, [0]*n_max
        self._fac[0], self._fac[1] = 1, 1
        self._finv[0], self._finv[1] = 1, 1
        self._inv[1] = 1
        self._mod = mod
        for i in range(2, n_max):
            self._fac[i] = self._fac[i - 1] * i % self._mod
            self._inv[i] = self._mod - self._inv[self._mod%i] * (self._mod // i) % self._mod
            self._finv[i] = self._finv[i - 1] * self._inv[i] % self._mod
    def com(self, n, r):
        if n < r: return 0
        if n < 0 or r < 0: return 0
        return self._fac[n] * (self._finv[r] * self._finv[n - r] % self._mod) % self._mod

    def perm(self,n,r):
        if n < r: return 0
        if n < 0 or r < 0: return 0
        return self._fac[n] * (self._finv[n-r] % self._mod) % self._mod


MOD = 10**9+7
comb = Combination(10**6, MOD)

pls = [-1]*(10**6)
n,m = map(int, input().split())
# ans = perm(m,n)
ans = 0
for i in range(1,n+1):
    i_com = comb.com(n,i)
    pattern = comb.perm(m-i,n-i)
    if i%2 == 1:
        ans += i_com*pattern
    else:
        ans -= i_com*pattern
    ans%=MOD

ans = comb.perm(m,n)-ans
ans%=MOD

ans *= comb.perm(m,n)
print(ans%MOD)

Measured memory_bytes: 111344
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      int K = sc.nextInt(); // 合計値
      int X = sc.nextInt();

      if((500 * K) >= X){
      	System.out.println("Yes");
      } else {
      	System.out.println("No");
      }
      
   }
}

Measured memory_bytes: 23252
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val hs = readLine()!!.split(" ").map { it.toInt() }

    val inf = 1L shl 60

    val dp = Array(n) {inf}
    dp[0] = 0

    for (i in 1 until n) {
        dp[i] = Math.min(dp[i], dp[i-1] + Math.abs(hs[i] - hs[i-1]))
        if (i > 1) {
            dp[i] = Math.min(dp[i], dp[i-2] + Math.abs(hs[i] - hs[i-2]))
        }
    }
    println(dp[n-1])
}


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


struct UnionFind{
    vector<int> d;
    UnionFind(int n): d(n,-1){}
    int root(int x){
        if(d[x]<0) return x;
        return d[x]=root(d[x]);
    }
    bool unite(int x, int y){
        x=root(x);y=root(y);
        if(x==y)return false;
        if(d[x]>d[y])swap(x,y);
        d[x]+=d[y];
        d[y]=x;
        return true;
    }
    bool same(int x, int y){return root(x)==root(y);}
    int size(int x){return -d[root(x)];}
};


int main(){
    ll n,m;cin>>n>>m;
    ll a[100010],b[100010];
    rep(i,0,m){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
    }
    ll an[100010];
    ll ans=n*(n-1)/2;
    an[m-1]=ans;
    UnionFind UF(n);
    for(ll i=m-1;i>=1;i--){
        ll s1=UF.size(a[i]);
        ll s2=UF.size(b[i]);
        if(!UF.same(a[i],b[i])){
            ans-=s1*s2;
            UF.unite(a[i],b[i]);
        }
        an[i-1]=ans;
    }
    rep(i,0,m)cout<<an[i]<<endl;
}
    









Measured memory_bytes: 4096
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC068A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);

            Console.WriteLine("ABC" + a);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
int main(void)
{
  int S=IN();long array[S+1];
  rep(i,S+1){if(i<3){array[i]=0;}else if(i==3){array[i]=1;}else{array[i]=array[i-1]+array[i-3];}array[i]%=(long)1e9+7;}
  return OUT(array[S]),0;
}

Measured memory_bytes: 1496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

const ll MAX_LEVEL = 30;

vector<ll> pow3;

void init_pow3(){
    pow3.resize(MAX_LEVEL + 1);
    pow3.at(0) = 1;
    for(ll i = 1; i <= MAX_LEVEL; ++i){
        pow3.at(i) = 3 * pow3.at(i - 1);
    }
}

ll solve(ll y1, ll x1, ll y2, ll x2, ll l){
    if(l == 0){
        return abs(y1 - y2) + abs(x1 - x2);
    }

    const ll w = pow3.at(l - 1);
    const ll yi1 = y1 / w, yi2 = y2 / w;
    const ll xi1 = x1 / w, xi2 = x2 / w;

    if(yi1 == yi2 && xi1 == xi2){
        return solve(y1, x1, y2, x2, l - 1);
    }else if(yi1 != yi2 && xi1 != xi2){
        return abs(y1 - y2) + abs(x1 - x2);
    }else if(yi1 == yi2){
        assert(xi1 != xi2);
        if(yi1 % 3 != 1 || abs(xi1 - xi2) <= 1){
            return solve(y1, x1, y2, x2, l - 1);
        }else{
            ll ret = abs(x1 - x2);
            ret += min(y1 % w + y2 % w + 2, 2 * w - y1 % w - y2 % w);
            return ret;
        }
    }else{
        assert(xi1 == xi2 && yi1 != yi2);
        return solve(x1, y1, x2, y2, l);
    }
}

int main(){
    init_pow3();
    ll q;
    cin >> q;
    REP(i, q){
        ll ai, bi, ci, di;
        cin >> ai >> bi >> ci >> di;
        ai--; bi--; ci--; di--;
        cout << solve(ai, bi, ci, di, MAX_LEVEL) << endl;
    }
    return 0;
}


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

int main(){
  int n;
  int c[500];
  int s[500];
  int f[500];
  cin >> n;
  for (int i = 0; i < n-1; i++){
    scanf("%d %d %d", &c[i], &s[i], &f[i]);
  }
  for (int i = 0; i < n-1; i++){
    int t = 0;
    for (int j = i; j < n-1; j++){
      if (s[j] > t) t = s[j];
      else {
        int u = (t + f[j] - 1) / f[j];
        t = u * f[j];
      }
      t += c[j];
    }
    printf("%d\n", t);
  }
  printf("0\n");

  return 0;
}

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

using namespace std;

char s[11];

bool isATGC(char c){
  if ( c == 'A' ) return true;
  if ( c == 'T' ) return true;
  if ( c == 'G' ) return true;
  if ( c == 'C' ) return true;
  
  return false;
}

int main() {
  scanf("%s", s);
  
  int pos = 0;
  int ans = 0;
  while (pos < strlen(s)) {
    int cnt = 0;
    while (isATGC(s[pos]) && pos < strlen(s) ) {
    cnt++; 
    pos++;
    }
    
    ans = max(ans, cnt);
    pos++;
  }
  printf("%d\n", ans);

}

Measured memory_bytes: 256
def generate_lunlun(p):
    last = p % 10
    if last - 1 >= 0:
        yield p * 10 + last - 1
    yield p * 10 + last
    if last + 1 <= 9:
        yield p * 10 + last + 1

if __name__ == '__main__':
    k = int(input())
    lunlun = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    p = 0

    while len(lunlun) < k:
        for new_lunlun in generate_lunlun(lunlun[p]):
            lunlun.append(new_lunlun)
        p += 1

    print(lunlun[k-1])


Measured memory_bytes: 7164
/*Bismillahir Rahmanir Rahim*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a[100007],i,j,N,K,l;
    cin>>N>>K;
    for(i=0; i<N; i++)
        cin>>a[i];
    sort(a,a+N);
    l=a[K-1]-a[0];
    for(i=0; i<N-K+1; i++)
    {
        j=a[i+K-1]-a[i];
        if(j<l)
            l=j;
    }
    cout<<l<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int,int> Pi;
const ll inf = 1e18 + 1;
const ll limit = 1e9;

int main() {
    int k,n; cin >> k >> n;
    vector<int> a(n+1);
    for (int i = 1; i <= n; i++) cin >> a[i];
    a[0] = a[n] - k;
    int max_l = 0;
    for (int i = 1; i <= n; i++) {
        int t = a[i] - a[i-1];
        max_l = max(t,max_l);
    }
    cout << k - max_l << "\n";
}   
 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int flag=0;
  string a;
  cin>>a;
  for(int i=0;i+1<a.length();i++){
    for(int j=1+i;j<a.length();j++){
      if(a[i]==a[j]) flag=1; 
    }
  }
  if(flag==0) cout<<"yes"<<endl;
  else cout<<"no"<<endl;
  return 0;
}
   
 
      
 
  
   
  
	
	  
	  
	  
	  
	  
	  
     
  
  
  
  
  

  

 
  


 

    
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(ll i=0;i<(n);++i)
#define Fr(i,n) for(long long i=1;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n,k,x,y;
  ll ans=0;
  cin>>n>>k;
  x=n/k;
  y=0;
  if(k%2==0){
    y=(n+k/2)/k;
  }
  cout<<x*x*x+y*y*y;
}

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

int main() 
{
  int64_t a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a >= 0 && c >= 0)
  {
    cout << b*d << endl;
  }
  else if(a < 0 && c >= 0)
  {
    if(b >= 0)
    {
      cout << b*d << endl;
    }
    else
    {
      cout << b*c << endl;
    }
  }
  else if(a >= 0 && c < 0)
  {
    if(d >= 0)
    {
      cout << b*d << endl;
    }
    else
    {
      cout << a*d << endl;
    }
  }
  else if(a < 0 && c < 0)
  {
    if(b >= 0 && d >= 0)
    {
      if(a*c > b*d)
      {
        cout << a*c << endl;
      }
      else
      {
        cout << b*d << endl;
      }
    }
    else
    {
      cout << a*c << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	
	string str;

	cin>>str;bool f=true,F=false;
	for(int i=0;i<str.size();i++){
		char x=str[i];
		if(str[0]=='o'){cout<<'o'<<endl;F=true;break;}
		else{
			if(x=='x')f=false;
			else f=true;
			//cout<<i;
		}


	}
	if(F==false){
		if(f==false)cout<<'x'<<endl;
		else cout<<'o'<<endl;
	}
	return 0;
}
	

Measured memory_bytes: 1176
// In the name of Allah //
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5e5 + 10;
string s;
long long a;
int main()
{
    cin >> s;
    for (int i = 0; i < s.size(); i ++){
        a += s[i] - '0';
    }
    if (a % 9 == 0)
        return cout << "Yes" , 0;
    cout << "No";
}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int main2() {
  string S; cin >> S;

  int A = 0, B = 0;
  REP(i, S.size()) {
    if (S[i] != (i % 2 + '0')) A++;
    if (S[i] != (1 - i % 2 + '0')) B++;
  }
  cout << min(A, B) << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
using namespace std;
long long a,b,c;

int main(){
    cin >> a >> b >> c;
    long long l = a*b, r = c - a - b;
    if(r < 0)printf("No");
    else if(4 * l < r * r)printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vvi = vector<vector<int>> ;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI 3.141592653
#define rep(i, n) for(ll i = 0; i < n; i++)



int main(){
  ll x, n;
  cin >> x >> n;
  vll p(101, 0);
  rep(i, n){
    ll a; cin >> a;
    p[a] = 1;
  }


  bool f = true;
  if(p[x] == 0){cout << x << endl; f = false;}

  ll i = 1;
  while(f){
    if(x - i == 0){cout << 0 << endl; break;}
    if(p[x - i] == 0){cout << x - i << endl; break;}

    if(x + i == 101){cout << x + i << endl; break;}
    if(p[x + i] == 0){cout << x + i << endl; break;}  

    i++;
  }


   
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
using namespace std;
int main(){
    int n;
    cin >> n;
    string a,b;
    cin >> a >> b;
    bool fl = true;
    int ans = 2*n;
    for(int i = n-1;i>=0;i--){
        for(int j = 0;j<i+1;j++){
            if(a[j+n-1-i] != b[j]){
                fl = false;
                break;
            }
        }
        if(fl){
            ans = 2*n-i-1;
            break;
        }
        fl = true;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <ostream>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using ll = long long;

std::ostream& operator << (std::ostream& os, const std::vector<int>& v) {
  for (int i = 0; i < int(v.size()); ++i) {
    os << v[i];
    if (i != int(v.size()) - 1) cout << " ";
  }
  return os;
}

ll gcd(ll x, ll y) {
  if (x < y) {
    std::swap(x, y);
  }

  ll tmp;

  while (y != 0) {
    tmp = x % y;
    x = y;
    y = tmp;
  }

  return x;
}

int main() {
  ll X, Y;

  cin >> X >> Y;

  if (gcd(X, Y) == 1 && X != Y && Y != 1) {
    cout << X << endl;
  }
  else {
    if (X % Y == 0 || X == Y || Y == 1) {
      cout << -1 << endl;
    }
    else {
      cout << X << endl;
    }
  }
  cin >> X;
  return 0;
}

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

typedef vector<int> vec;

int main () {
    int N, L;
    while (cin >> N >> L, N || L) {
        vec V[2];
        V[0].resize(L + 2);
        V[1].resize(L + 2);

        for (int i = 1; i <= N; i++) {
            char d; int p;
            cin >> d >> p;
            if (d == 'R') {
                V[1][p] = i;
            } else {
                V[0][p] = i;
            }
        }
        bool flag = true;
        int ans = -1;
        int t = -1;
        for (int k = 0; k <= L; k++) {
            for (int i = 1; i <= L + 1; i++)
                V[0][i-1] = V[0][i];
            for (int i = L + 1; i > 0; i--)
                V[1][i] = V[1][i-1];
            for (int i = 1; i <= L; i++) {
                if (V[0][i] > 0 && V[1][i] > 0) {
                    int tmp = V[0][i];
                    V[0][i] = V[1][i];
                    V[1][i] = tmp;
                }
            }
            if (V[0][1] > 0) t = k + 2, ans = V[0][1];
            else if (V[1][L-1] > 0) t = k + 2, ans = V[1][L-1];
        }
        cout << t << " " << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <cstdio>
#include <deque>
#include <algorithm>
#include <string>
#include <cstring>
#include <list>
#include <stack>

using namespace std;
int a[100001];
priority_queue<int> q;
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a, a + m);
	for (int i = 1; i < m; i++) {
		q.push(abs(a[i] - a[i - 1]));
	}
	if (n >= m) {
		cout << 0 << '\n';
	}
	else {
		n -= 1;
		while (n--) {
			q.pop();
		}
		long long sum = 0;
		while (!q.empty()) {
			sum += (long long)q.top(); q.pop();
		}
		cout << sum << '\n';

	}
}


Measured memory_bytes: 1276
# -*- coding: utf-8 -*-
import numpy as np


h, w, m = map(int, input().split())

h_cnt = np.zeros(h, dtype=int)
w_cnt = np.zeros(w, dtype=int)
bom_cord = set()
for i in range(m):
    hi, wi = map(lambda x: int(x) - 1, input().split())
    bom_cord.add((hi, wi))
    h_cnt[hi] += 1
    w_cnt[wi] += 1

w_max = w_cnt.max()

h_argsort = h_cnt.argsort()[::-1]
w_argsort = w_cnt.argsort()[::-1]

bomber = 0
for hi in h_argsort:
    if h_cnt[hi] + w_max <= bomber:
        break
    
    for wi in w_argsort:
        if h_cnt[hi] + w_cnt[wi] <= bomber:
            break

        if (hi, wi) in bom_cord:
            bomber = max(bomber, h_cnt[hi] + w_cnt[wi] - 1)
        else:
            bomber = max(bomber, h_cnt[hi] + w_cnt[wi])

print(bomber)


Measured memory_bytes: 82088
#include<bits/stdc++.h>
#define LL long long
using namespace std;
inline int read(){int x;scanf("%d",&x);return x;}
const int N=2e5+5;
int n;
int a[N];
int main(){
    n=read();
    for(int i=1;i<=n;++i)a[i]=read()-i;
    sort(a+1,a+n+1);
    int num=a[(n+1)/2];
    LL ans=0;
    for(int i=1;i<=n;++i)ans+=abs(num-a[i]);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		new Main().run();
	}
	public void run(){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		int cal = scan.nextInt();
		int max = cal / a;
		int[] t = new int[n];
		for(int i = 0;i < n;i++){
			t[i] = scan.nextInt();
		}
		Arrays.sort(t);
		int tc;
		for(int k = 1,i = n-1;i >= 0;i--,k++){
			cal += t[i];
			tc = cal / (k*b + a);
			if(max <= tc){
				max = tc;
			}else{
				break;
			}
		}
		System.out.println(max);
	}
}

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

int main() {
    int r, c;
    cin >> r >> c;
    
    vector<string> s(r);
    
    for(int i = 0; i < r; i ++){
    	cin >> s[i];
	}
	
	int j;
	int rcount = 0;
	for(int i = 0;i < r; i ++){
		for(j = 0; j < c; j ++){
			if(s[i][j] == '#')
				break;
		}
		if(j == c){
			for(j = 0; j < c; j ++)
				s[i][j] = '=';
		}
	}
	
	for(int i = 0;i < c; i ++){
		for(j = 0; j < r; j ++){
			if(s[j][i] == '#')
				break;
		}
		if(j == r){
			for(j = 0; j < r; j ++){
				s[j][i] = '=';
			}
		}
	}
	
	bool enter = false;
	for(int i = 0;i < r; i ++){
		bool enter = false;
		for(int j = 0; j < c; j ++){
			if(s[i][j] != '='){
				cout << s[i][j];
				enter = true;
			}
		}
		if(enter)
			cout << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
 
int INF=1001001001001001001ll;
struct segtree{
    static const int SEG=1<<17;
    vint dat;
    segtree():dat(SEG*2,INF){}
    void update(int k,int x){
        k+=SEG-1;
        dat[k]=x;
        while(k){
            k=(k-1)/2;
            dat[k]=min(dat[k*2+1],dat[k*2+2]);
        }
    }
    int query(int a,int b,int k=0,int l=0,int r=SEG){
        if(r<=a||b<=l)return INF;
        if(a<=l&&r<=b)return dat[k];
        return min(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
    }
};
 
int N,L;
int A[100000],B[100000];
int C[100000];
 
int premin[111111];
int sufmax[111111];
 
int SA[111111];
int SC[111111];
signed main(){
    scanf("%lld%lld",&N,&L);
    rep(i,N)scanf("%lld%lld",&A[i],&B[i]);
    rep(i,N)scanf("%lld",&C[i]);
    rep(i,N)SC[i+1]=SC[i]+C[i];
    vpint vec;
    rep(i,N)vec.pb(pint(B[i]-A[i],B[i]));
    sort(all(vec));
    rep(i,N){
        A[i]=-vec[i].fi+vec[i].se;
        B[i]=vec[i].se;
    }
    rep(i,N)SA[i+1]=SA[i]+A[i]-B[i];
 
    sufmax[N]=-1001001001;
    for(int i=N-1;i>=0;i--){
        sufmax[i]=max(sufmax[i+1],A[i]);
    }
    premin[0]=1001001001;
    for(int i=1;i<=N;i++){
        premin[i]=min(premin[i-1],SA[i]-SC[i]);
    }
 
 
    int ans=INF;
    for(int i=0;i<N;i++){
        if(premin[i]<=0)break;
        if(SA[i]+sufmax[i]>=L)chmin(ans,i+1);
    }
 
 
    deque<pint>Bs;
    deque<pint>As;
    for(int i=1;i<=N;i++){
        if(A[i-1]-B[i-1]<=0)break;
        while(Bs.size()&&Bs.back().fi<=B[i-1])Bs.pop_back();
        Bs.pb(pint(B[i-1],i-1));
        while(Bs.size()>1&&Bs[1].fi+SA[i]>=L)Bs.pop_front();
 
        int t=Bs.front().se;
        if(B[t]+SA[i]<L)continue;
        if(premin[t]<=0)continue;
 
        while(As.size()&&As.back().fi>=SA[i]-SC[i-1])As.pop_back();
        As.pb(pint(SA[i]-SC[i-1],i-2));
        while(As.size()&&As.front().se<t)As.pop_front();
        if(As.size()&&As.front().fi-(A[t]-B[t])<=0)continue;
        chmin(ans,i);
    }
 
    if(ans!=INF)cout<<ans<<endl;
    else cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 10216
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N; cin >> N; assert(N % 2 == 1);
    vl A(N); REP(i, N) cin >> A[i];

    ll sum = 0;
    REP(i, N) sum += A[i];

    ll sum2 = 0;
    for(int i=1; i<=N-2; i+=2) sum2 += A[i];

    vl r(N);
    r[0] = sum - sum2 * 2;

    FOR(i, 1, N) r[i] = A[i - 1] * 2 - r[i - 1];

    cout << r[0];
    FOR(i, 1, N) cout << " " << r[i];
    cout << endl;

    return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include<tuple>
#include<stack>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tpl;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 100005

const int INF = 1e16 + 7;
const int MOD = 1e9 + 7;

int main() {

	int a, b;
	cin >> a >> b;
	cout << max(0, a - b) << endl;

	return 0;
}


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


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>

#define SIZE 100005
#define MOD 1000000007

using namespace std;

class DUnbalanced {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        string s;
        cin >> s;

        if (s.size() == 1) {
            cout << "-1 -1" << endl;
            return;
        } else if (s.size() == 2) {
            if (s[0] == s[1]) {
                cout << 1 << " " << 2 << endl;
                return;
            }
        }
        for (int i = 0; i < s.size() - 2; ++i) {
            char ss = s[i];
            if (ss == s[i + 1] || ss == s[i + 2] || s[i + 1] == s[i + 2]) {
                cout << i + 1 << " " << i + 3 << endl;
                return;
            }
        }
        cout << "-1 -1" << endl;
    }
};


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


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int h,w,d,tt,now;
int a[100100][2];
int an[100100];
int li,ri,q;
long long ans;
int main()
{
	cin>>h>>w>>d;
	for(int i=1;i<=h;++i)
		for(int j=1;j<=w;++j)
		{
			scanf("%d",&tt);
			a[tt][0]=i;
			a[tt][1]=j;
		}
	cin>>q;
	for(int i=d+1;i<=h*w;++i)
		an[i]=an[i-d]+abs(a[i-d][0]-a[i][0])+abs(a[i-d][1]-a[i][1]);
	for(int i=1;i<=q;++i)
	{
		cin>>li>>ri;
		cout<<an[ri]-an[li]<<endl;
	}
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<int> list(5);
    int k;
    for (int i = 0; i < 5; i++) {
        cin >> list[i];
    }
    cin >> k;

    int ans = false;
    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            if (list[j] - list[i] > k) {
                ans = true;
            }
        }
    }

    if (ans) {
        cout << ":(";
    } else {
        cout << "Yay!";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int sum;
string s;
int main()
{
	cin >> s;
	for(int i = 0 ; i < s.size() ; i++ ) sum = (sum + s[i] - '0') % 9;
	if(!sum) printf("Yes");
	else printf("No");
    return 0;
}

Measured memory_bytes: 3808
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <cmath>
#include <string>

using namespace std;

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

#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define ins insert
#define iter ::iterator
#define upb upper_bound
#define lwb lower_bound

#define sz(v) v.size()
#define aloc(i, a, n) i *a = new i[n]

#define for0(i,a) for(ll i = 0; i < a; i++)
#define fori(i,a,b) for(ll i = a; i < b; ++i)
#define rfor0(i,a) for(ll i = a; i >= 0; --i)
#define rfor(i,a,b) for(ll i = a; i >= b; --i)

int main(){

  int a,b;
  cin >> a >> b;
  vector<ll> monsters;
  for0(i, a){
    ll temp;
    cin >> temp;
    monsters.pb(temp);
  }
  sort(monsters.begin(), monsters.end());
  ll sum = 0;
  for0(i, a-b){
    sum+=monsters[i];
  }
  cout << sum << endl;

}


Measured memory_bytes: 2420
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//using ll=long long;
#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
 
int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
 
int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}
 
int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
 
int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//dp注意点
//問題の種類	 初期化する値	 備考
//最小化問題 	INF	
//最大化問題	    -INF	 テーブル全体で 00 以上の値しかとらないことがわかっていれば −1−1 でもいいですし、00 でもいい場合もあります
//数え上げ問題	00	
//確率問題	      00	
//Yes/No 判定問題	False
/*-------------ここまで---------------------------------------------*/
 
signed main(){
  int a,b;
  cin>>a>>b;
  for(int i=1;i<4;++i){
    if(i!=a && i!=b){
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3520
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int N, i;
  sc.scan(N, i);

  writeln(N - i + 1);
}


Measured memory_bytes: 256
#import re

N = input()
stones = input()
#pattern = 'W.*R'
#stoneslist =list(stones)
#result = re.search(pattern,stones)
#if result:
 # print (result.start())
  #print (result.end())
#print(stones[result.start()])
#stoneslist[result.start()]='R'
#stoneslist[result.end()-1]='W'

count =0
#while 'WR' in stones:
 # if stones.count('WR')>1:
  #  stoneslist =list(stones)
   # result = re.search(pattern,stones)
    #stoneslist[result.start()]='R'
    #stoneslist[result.end()-1]='W'
    #stones =str(stoneslist)
    #stones = "".join(stoneslist)
  #else:
   # stones = stones.replace('WR','RR',1)
  #count+=1
  #print(stones)

#print (stones)

red = 0
white = 0
for i in range(len(stones)):
  if stones[i] == "R":
    red +=1
for i in range(red):
  if stones[i] =='W':
    white+=1
print (white)
#print (count)

Measured memory_bytes: 9196
INF = float('inf')

N = int(input())

xConstMin, xConstMax = INF, -INF
xAscMin, xAscMax = INF, -INF
xDescMin, xDescMax = INF, -INF
yConstMin, yConstMax = INF, -INF
yAscMin, yAscMax = INF, -INF
yDescMin, yDescMax = INF, -INF
for _ in range(N):
    x, y, d = input().split()
    x, y = int(x), int(y)
    if d == 'R':
        xAscMax = max(xAscMax, x)
        xAscMin = min(xAscMin, x)
        yConstMax = max(yConstMax, y)
        yConstMin = min(yConstMin, y)
    elif d == 'L':
        xDescMax = max(xDescMax, x)
        xDescMin = min(xDescMin, x)
        yConstMax = max(yConstMax, y)
        yConstMin = min(yConstMin, y)
    elif d == 'U':
        xConstMax = max(xConstMax, x)
        xConstMin = min(xConstMin, x)
        yAscMax = max(yAscMax, y)
        yAscMin = min(yAscMin, y)
    elif d == 'D':
        xConstMax = max(xConstMax, x)
        xConstMin = min(xConstMin, x)
        yDescMax = max(yDescMax, y)
        yDescMin = min(yDescMin, y)

tms = []

t1 = max(0, xDescMax - xConstMax)
t2 = max(0, xConstMax - xAscMax)
if t1 >= t2:
    t = max(0, (xDescMax-xAscMax)/2)
    tms.append(t)
else:
    tms.append(t1)
    tms.append(t2)

t1 = max(0, xConstMin - xAscMin)
t2 = max(0, xDescMin - xConstMin)
if t1 >= t2:
    t = max(0, (xDescMin-xAscMin)/2)
    tms.append(t)
else:
    tms.append(t1)
    tms.append(t2)

t1 = max(0, yDescMax - yConstMax)
t2 = max(0, yConstMax - yAscMax)
if t1 >= t2:
    t = max(0, (yDescMax-yAscMax)/2)
    tms.append(t)
else:
    tms.append(t1)
    tms.append(t2)

t1 = max(0, yConstMin - yAscMin)
t2 = max(0, yDescMin - yConstMin)
if t1 >= t2:
    t = max(0, (yDescMin-yAscMin)/2)
    tms.append(t)
else:
    tms.append(t1)
    tms.append(t2)

ans = INF
for tm in tms:
    if tm == INF: continue

    xs = [xConstMin, xConstMax, xAscMin+tm, xAscMax+tm, xDescMin-tm, xDescMax-tm]
    ys = [yConstMin, yConstMax, yAscMin+tm, yAscMax+tm, yDescMin-tm, yDescMax-tm]

    xMin, xMax = INF, -INF
    for x in xs:
        if x == INF or x == -INF: continue
        xMin = min(xMin, x)
        xMax = max(xMax, x)

    yMin, yMax = INF, -INF
    for y in ys:
        if y == INF or y == -INF: continue
        yMin = min(yMin, y)
        yMax = max(yMax, y)

    ans = min(ans, (xMax-xMin)*(yMax-yMin))

print(ans)


Measured memory_bytes: 3316
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

from operator import itemgetter


N = int(input())


AB = [(0, 0, 0)]*N
for n in range(N):
    a, b = list(map(int, input().split()))
    AB[n] = (a, b, b-a) 
AB = tuple(sorted(AB, key = itemgetter(1)))

    
def main():
    tot = 0
    for i, ab in enumerate(AB):
        if tot <= ab[2]:
            tot+=ab[0]
        else:
            return print("No")
        #print(ab, tot)
    print("Yes")
                
                
            
            
                

    
if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
    int h,w,n,max1;
    cin>>h>>w>>n;
    max1=max(h,w);
    if(n%max1==0)cout<<n/max1;
    else cout<<n/max1+1;
    return 0;
}


Measured memory_bytes: 256
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

seq = sorted(P)

p_num = None
q_num = None

def is_same(pq, l):
    for i in range(len(pq)):
        if pq[i] != l[i]:
            return False
    return True

for index, l in enumerate(list(itertools.permutations(seq))):
    if is_same(P, l):
        p_num = index + 1
    if is_same(Q, l):
        q_num = index + 1
    if p_num is not None and q_num is not None:
        print(abs(p_num - q_num))
        exit(0)


Measured memory_bytes: 8052
x, k, d = map(int, input().split())
x = abs(x)
if k*d <= x:
    ans = x-k*d
else:
    # 残り移動回数
    count = k - x//d

    if count%2 == 0:
        ans = x%d
    else:
        ans = min(abs(x%d - d), x%d + d)
print(ans)


Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,a,b;
    cin >> x >> a >> b;
    if(a >= b)
        cout << "delicious" << endl;
    else if(b - a <= x)
        cout << "safe" << endl;
    else if(b - a > x)
        cout << "dangerous" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i;
        String str;
        while(true){
            str = sc.next();
            if(str.equals("-")){
                break;
            }
            String str1;
            String str2;
            int m;
            m = sc.nextInt();
            int h;
            for(i=0;i<m;i++){
                h = sc.nextInt();
                str1 = str.substring(0,h);
                str2 = str.substring(h);
                str = str2 + str1;
            }
            System.out.println(str);
        }
        sc.close();
    }
}


Measured memory_bytes: 26388
N, A, B = map(int, input().split())
H = sorted(int(input()) for _ in range(N))

import bisect, math
def f(ll, ul):
    if ul == ll: return ll
    cur = (ll + ul) // 2
    r = H[bisect.bisect_right(H, B * cur):]
    p = sum(math.ceil((x - B * cur) / (A - B)) for x in r)

    if p <= cur:
        return f(ll, cur)
    else:
        return f(cur + 1, ul)

print(f(0, math.ceil((H[-1]) / B)))

Measured memory_bytes: 30604