akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

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

	if(red >= 3200)
		cout << s;
	else
		cout << "red";
	return 0;
}

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

using namespace std;



int main() {
  int n;
  cin >> n;
  for (int i = 0; 4*i <= n; ++i) {
    if ((n-4*i)%7==0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a == c) cout << 0 << endl;
    else cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 256
class UnionFind():

    def __init__(self, n):
        # 頂点の値が0から始まる前提なので注意
        self.par = [i for i in range(n)]

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)

        if x == y:
            return
        
        self.par[x] = y
        return


def main():
    N, M = map(int, input().split())
    p = list(map(lambda x: int(x)-1, input().split()))

    uf = UnionFind(N)
    for i in range(M):
        x, y = map(int, input().split())
        uf.unite(x-1, y-1)
    
    ans = 0
    for i in range(N):
        if uf.same(i, p[i]):
            ans += 1
    
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13940
fun main() {
    val n = readInt()
    val list = mutableListOf<Long>()
    for (i in 1..n) {
        if (i % 3 == 0 || i % 5 == 0) {
           continue
        }
        list.add(i.toLong())
    }
    val ans: Long = list.sum()
    println(ans)
}

private fun read() = readLine()!!

private fun readInt() = read().toInt()

private fun readLong() = read().toLong()

private fun readDouble() = read().toDouble()

private fun readListString() = read().split(" ")

private fun readListInt() = readListString().map { it.toInt() }

private fun readListLong() = readListString().map { it.toLong() }

private fun readListDouble() = readListString().map { it.toDouble() }

private fun readMatrixString(n: Int): List<List<String>> {
    val matrix = mutableListOf<List<String>>()
    for (i in 0 until n) {
        val list = readListString()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixInt(n: Int): List<List<Int>> {
    val matrix = mutableListOf<List<Int>>()
    for (i in 0 until n) {
        val list = readListInt()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixDouble(n: Int): List<List<Double>> {
    val matrix = mutableListOf<List<Double>>()
    for (i in 0 until n) {
        val list = readListDouble()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixLong(n: Int): List<List<Long>> {
    val matrix = mutableListOf<List<Long>>()
    for (i in 0 until n) {
        val list = readListLong()
        matrix.add(list)
    }
    return matrix
}



Measured memory_bytes: 58744
import sys
input = sys.stdin.readline

n = int(input())

a_ord = ord('a')

s = ["a"]

ans = []

def dfs(s):
    max_ord = a_ord
    for i in s:
        max_ord = max(max_ord, ord(i))
    for i in range(a_ord, max_ord + 2):
        t = s[:]
        t.append(chr(i))
        if len(t) == n:
            ans.append("".join(t))
        else:
            dfs(t)
if n == 1:
    print('a')
else:
    dfs(s)
    ans.sort()
    for w in ans:
        print(w)

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

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    
    for(int i = 0; i < s.size(); i++)
    {
        if(s == t)
        {
            cout << "Yes" << endl;
            return 0;
        }
        else
        {
            s.insert(s.begin(), s[s.size() - 1]);
            s.pop_back();
        }
    }
    
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){
  int n = 0;
  int x[8] = {};
  int y[8] = {};
  double sum = 0;
  double oh = 0;
  int i = 0;
  int j = 0;
  scanf("%d",&n);
  for(i=0;i < n;i++){
    scanf("%d %d",&x[i],&y[i]);
  }
  
  for(i=0;i < n;i++){
    for(j=0;j < n;j++){
      sum += sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
    }
  }
  oh = sum / n;
  printf("%lf",oh);
  return 0;
}

int bikkuri(int n){
  if(n <= 1){
    return 1;
  }else{
    return n * bikkuri(n-1);
  }
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline


def main():
    a, b, c = map(int, input().split())

    y = (c - (a+b))**2 - 4*a*b
    if c-(a+b) > 0 and y > 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<string,int> P;
int main(){
  	int N;
    cin >> N;
    bool judge = false;

    for(int i=0;i<N;i++){
      char ch;
      cin >> ch;
      if(ch=='Y') judge = true;
    }

    if(judge){
      cout << "Four" <<endl;
    }else{
      cout << "Three" <<endl;
    }


  return 0;
}






Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y;
    return 0;
}




Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())

p_list = list(map(int, input().split()))
q_list = list(map(int, input().split()))
r_list = list(map(int, input().split()))

p_list.sort()
p_list.reverse()
q_list.sort()
q_list.reverse()
r_list.sort()
r_list.reverse()


total = sum(p_list[:X]) + sum(q_list[:Y])

x = X - 1
y = Y - 1
c = 0
while c < C:
	changed = False
	if y >= 0 and (x < 0 or p_list[x] >= q_list[y]):
		if q_list[y] < r_list[c]:
			total += r_list[c] - q_list[y]
			y -= 1
			c += 1
			changed = True
	if c >= C:
		break
	if x >= 0 and (y < 0 or p_list[x] <= q_list[y]):
		if p_list[x] < r_list[c]:
			total += r_list[c] - p_list[x]
			x -= 1
			c += 1
			changed = True
	if not changed:
		break

print(total)


Measured memory_bytes: 22720
#include<stdio.h>


int a[50];
int n;

int solve(int i,int m)
{

  if(m==0) return 1;
  if(i>=n) return 0;

  int res=solve(i+1,m) || solve(i+1,m-a[i]);
  return res;
  return 0;
}
  

int main()
{
  int i,q,M;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&a[i]);
    }

  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&M);
      if(solve(0,M)) printf("yes\n");
      else printf("no\n");
    }
  return 0;
}



  



Measured memory_bytes: 2104
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (H, W): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let A: Vec<Vec<char>> = (0..H).map(|_| {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    }).collect();

    const INF: i64 = 1_000_000_000;
    let mut q = std::collections::VecDeque::new();
    let mut dp = vec![vec![INF; W]; H];
    for i in 0..H { for j in 0..W { if A[i][j] == '#' { q.push_back((0, i, j)); dp[i][j] = 0;} } }
    while let Some((d, i, j)) = q.pop_front() {
        if i + 1 < H && dp[i + 1][j] > d + 1 {
            dp[i + 1][j] = d + 1;
            q.push_back((d + 1, i + 1, j));
        }
        if i >= 1 && dp[i - 1][j] > d + 1 {
            dp[i - 1][j] = d + 1;
            q.push_back((d + 1, i - 1, j));
        }
        if j + 1 < W && dp[i][j + 1] > d + 1 {
            dp[i][j + 1] = d + 1;
            q.push_back((d + 1, i, j + 1));
        }
        if j >= 1 && dp[i][j - 1] > d + 1 {
            dp[i][j - 1] = d + 1;
            q.push_back((d + 1, i, j - 1));
        }
    }
    let ans = (0..H).map(|i| (0..W).map(|j| dp[i][j]).max().unwrap()).max().unwrap();

    println!("{}", ans);
}

Measured memory_bytes: 40948
from collections import defaultdict


def check(ai, ratemax, d):
    if 1 <= ai <= 399:
        d[0] += 1
    elif 400 <= ai <= 799:
        d[1] += 1
    elif 800 <= ai <= 1199:
        d[2] += 1
    elif 1200 <= ai <= 1599:
        d[3] += 1
    elif 1600 <= ai <= 1999:
        d[4] += 1
    elif 2000 <= ai <= 2399:
        d[5] += 1
    elif 2400 <= ai <= 2799:
        d[6] += 1
    elif 2800 <= ai <= 3199:
        d[7] += 1
    else:
        ratemax += 1
    return ratemax


def main():
    N, *a = map(int, open(0).read().split())
    d = defaultdict(lambda: 0)
    ratemax = 0
    for ai in a:
        ratemax = check(ai, ratemax, d)
    print(len(d) if len(d) else 1, len(d) + ratemax)
    return


main()


Measured memory_bytes: 3316
n, k = map(int,input().split())

s = []

for i in range(1,n+1):
    cnt = i
    j = 1
    while cnt < k:
        cnt = cnt *2
        j += 1
    s.append(j-1)

total = 0
for i in range(len(s)):
    p = (1/n)*(1/2)**s[i]
    total = total + p

print(total)


Measured memory_bytes: 3864
import bisect
s = input()
t = input()
d = {}
if set(t) <= set(s):
    for c in set(s):
        d[c] = []
    for i,c in enumerate(s):
        d[c].append(i)
    ret = 0
    for i,c in enumerate(t):
        if i==0:
            loc = d[t[0]][0]
        else:
            nx_idx = bisect.bisect_right(d[c], loc)
            if nx_idx == len(d[c]):
                ret += 1
                nx_idx = 0
            nx_loc = d[c][nx_idx]
            loc = nx_loc
    print(ret*len(s) + loc + 1)
else:
    print(-1)


Measured memory_bytes: 7668
import sys
import socket
from collections import Counter

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


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


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


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    N = read_int()
    s = []
    for i in range(N):
      S = read_str()
      s.append(S)
    s.sort()
    s.append('')

    res = []
    M = -1
    m = 1
    for i in range(1, N+1):
      if s[i-1] == s[i]:
        m += 1
      else:
        if m == M:
          res.append(s[i-1])
        if m > M:
          M = m
          res = [s[i-1]]
        m = 1
    print(*res, sep='\n')


def main2():
    N = read_int()
    s = []
    for i in range(N):
      S = read_str()
      s.append(S)

    d = dict()
    for i in range(N):
      if s[i] not in d:
        d[s[i]] = 0
      d[s[i]] += 1
    # print(d)

    M = -1
    for key, value in d.items():
      if value > M:
        M = value
    # print(M)

    res = []
    for key, value in d.items():
      if value == M:
        res.append(key)
    res.sort()
    print(*res, sep='\n')



def main3():
    N = read_int()
    s = []
    for i in range(N):
      S = read_str()
      s.append(S)

    d = Counter(s)
    
    M = -1
    for key, value in d.items():
      if value > M:
        M = value
    # print(M)

    res = []
    for key, value in d.items():
      if value == M:
        res.append(key)
    res.sort()
    print(*res, sep='\n')


main3()


Measured memory_bytes: 36216
//  Created by liszt on 2019/07/21.
#include<bits/stdc++.h>
using namespace std;

int main(){
    long long l,r,r1,res=INT_MAX; cin>>l >>r;
    r1=min(r,l+2019);
    
    for(auto i=l;i<r1;i++){
        for(auto j=i+1;j<=r1;j++){
            res=min(res,i*j%2019);
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#define MAX 45

#include <stdio.h>
int fib(int);

int main(int argc, char const *argv[]) {
  int n;

  scanf("%d",&n);

  printf("%d\n",fib(n));

  return 0;
}

int fib (int n){
  int f[MAX] ={0};
  int i;

  f[0] = 1;
  f[1] = 1;
  for (i = 2; i <=n; i++) {
    f[i] = f[i-2] + f[i-1];
  }
  return f[n];
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define ll long
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int x;
	cin >> x;
	if (x >= 30) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3592
n=int(input())

room=[[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]

for _ in range(n):
    b,f,r,v=map(int,input().split())
    room[b-1][f-1][r-1]+=v


for i, b in enumerate(room):
    for f in b:
        for r in f:
            print(" {}".format(r),end="")
        print()
    if i< 3:
        print("#"*20)


Measured memory_bytes: 5624
MOD = 2019  # これなにげに3の倍数だからいつも見たいなMODの演算が通用しない笑
L, R = list(map(int, input().split()))

# このコーナーケースに注意
if (R - L) >= MOD:
    print(0)
    exit()

# Lをなるべく0に近づける
L %= MOD
# RをなるべくLに近づけてみる
R %= MOD
if R <= L:
    R += MOD

# print(L, R)
ans = 2019
for i in range(L, R+1):  # i<jが成り立つ範囲に注意
    for j in range(i + 1, R + 1):
        ans = min(ans, (i * j) % MOD)
print(ans)


Measured memory_bytes: 3068
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int L = scan.nextInt();
		int R = scan.nextInt();
		int d = scan.nextInt();
		scan.close();
		int count = 0;
		for (int i = L; i <= R; i++) {
			if (i % d == 0) {
				count += 1;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 35732
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Split(bufio.ScanWords)
	L := readInt()
	R := readInt()
	res := 2019

	if R-L >= 2019 {
		res = 0
	} else {
		for i := L; i < R; i++ {
			for j := i + 1; j < R+1; j++ {
				res = min(res, (i*j)%2019)
			}
		}
	}
	fmt.Println(res)
}

/*-----------------------------------------*/

func checkError(err error) {
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}

func read() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	res, err := strconv.Atoi(read())
	checkError(err)
	return res
}

func min(a int, b int) int {
	return int(math.Min(float64(a), float64(b)))
}

func max(a int, b int) int {
	return int(math.Max(float64(a), float64(b)))
}

func pow(a int, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func sqrt(a int) float64 {
	return math.Sqrt(float64(a))
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main(){
    int n,a[205]={0},b[205]={0},c[205]={0},ans[205]={0};
    int cuta=0,cutb=0,cutc=0;
    cin >>n;
    for(int i=0;i<n;i++){
        cin >>a[i]>>b[i]>>c[i];
    }
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
          if(a[i]==a[j]){
            a[j]=0;
            cuta++;
          }
          if(b[i]==b[j]){
            b[j]=0;
            cutb++;
          }
          if(c[i]==c[j]){
            c[j]=0;
            cutc++;
          }
        }
        if(cuta>0){cuta=0; a[i]=0;}
        if(cutb>0){cutb=0; b[i]=0;}
        if(cutc>0){cutc=0; c[i]=0;}
    }
    for(int i=0;i<n;++i){
        ans[i]=a[i]+b[i]+c[i];
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1164
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        int n=Integer.parseInt(br.readLine());
        long arr[]=new long[n];
        String str[]=br.readLine().split(" ");
        for(int i=0;i<n;i++)
        arr[i]=Long.parseLong(str[i]);
        TreeMap<Long,Integer> tmap=new TreeMap<>();
        for(int i=0;i<n;i++)
        tmap.put(arr[i],tmap.getOrDefault(arr[i],0)+1);
        n--;
        long ans=0;
        long tk=tmap.lastKey();
        tmap.put(tk,tmap.get(tk)*2-1);
        while(n>0)
        {
            long lk=tmap.lastKey();
            int val=tmap.get(lk);
            if(2*val-1<=n)
            {
                ans+=lk*val;
                n-=val;
            }
            else
            {
                ans+=lk*n;
                n=0;
            }
            tmap.remove(lk);
            if(tmap.size()>0)
            {
                long k=tmap.lastKey();
                tmap.put(k,tmap.get(k)*2);
            }
        }
        pw.println(ans);
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 76020
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  sort(p.begin(),p.end());
  int ans=0;
  rep(i,k) ans+=p[i];
  cout << ans;
}

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

using namespace std;

int main(){
    // modulo[i][j] : i桁目までの数字に余りがjになるものが存在するか？
    long long modulo_f[2019] = {};
    long long modulo[2019] = {};
    string s; cin >> s;
    int i = 0;
    long long ans = 0;
    for(auto c : s){
        int cv = c - '0';
        if(i == 0){
            modulo[cv] = 1;
        }else{
            modulo[cv] = 1;
            for(int k = 0; k < 2019; k++){
                modulo[(k * 10 + cv) % 2019] += modulo_f[k];
            }
        }
        ans += modulo[0];
        i++;
        for(int j = 0; j < 2019; j++){
            modulo_f[j] = modulo[j];
            modulo[j] = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3720
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

struct UF{
    const int node_num;
    vector<int> parent;
    vector<int> size;

    UF(int N) : node_num(N), parent(N), size(N, 1) {
        for(int i = 0; i < N; ++i) parent[i] = i;
    }

    //xの根を得る
    int root(int x){
        if(parent[x] == x) return x;
        return parent[x] = root(parent[x]);
    }

    //xが属する木とyが属する木を一つに合わせる
    void unite(int x, int y){
        int root_x = root(x);
        int root_y = root(y);
        if(root_x == root_y) return;
        parent[root_y] = root_x;
        size[root_x] += size[root_y];
    }

    //xとyが属する木が同じならtrueを返す
    bool same(int x, int y){
        int root_x = root(x);
        int root_y = root(y);
        return root_x == root_y;
    }

    //xと同じ木に属する要素の数を返す
    int same_size(int x){
        int root_x = root(x);
        return size[root_x];
    }
};

int main(){
    Stream io;
    
    int x, y;
    io.read(x, y);
    UF uf(12 + 1);
    uf.unite(1, 3);
    uf.unite(1, 5);
    uf.unite(1, 7);
    uf.unite(1, 8);
    uf.unite(1, 10);
    uf.unite(1, 12);
    uf.unite(4, 6);
    uf.unite(4, 9);
    uf.unite(4, 11);
    string ans = "No";
    if(uf.same(x, y)) ans = "Yes";
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
cards = [input().split() for i in range(n)]

taroScore = 0
hanakoScore = 0

for i in range(n):
    sortedCards = sorted(cards[i])
    if cards[i][0] == cards[i][1]:
        taroScore += 1
        hanakoScore += 1
    elif cards[i][0] == sortedCards[0]:
      hanakoScore += 3
    else:
        taroScore += 3

print(taroScore, hanakoScore)


Measured memory_bytes: 5712
n,m = map(int,input().split())
cdl = []
for _ in range(n):
    a,b = map(int,input().split())
    cdl.append((a,b))
abl = []
for _ in range(m):
    c,d = map(int,input().split())
    abl.append((c,d))

for c,d in cdl:
    ans = -1
    l = float("inf")
    for idx, (a,b) in enumerate(abl):
        dist = abs(a-c) + abs(b-d)
        if dist < l:
            ans = idx + 1
            l = dist
    print(ans)
        
   

Measured memory_bytes: 3064
N, M = map(int, input().split())
F = [[] for _ in range(N)]
P = [0] * N
for i in range(M):
    A, B = map(int, input().split())
    F[A-1].append(B-1)
    F[B-1].append(A-1)
c=0
l = []
for i in range(N):
    if P[i] == 0:
        c+=1
        l.append(i)
        while len(l)>0:
            p=l.pop()
            P[p] = c
            for j in F[p]:
                if P[j] == 0:
                    l.append(j)
print(c-1)


Measured memory_bytes: 82228
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

ans = 0


def main():
    def dfs(u, visited):
        visited[u] = True
        cnt = 0

        for v in edge[u]:
            if not visited[v]:
                cnt += dfs(v, visited)
                visited[v] = False

        if visited.count(True) == n:
            return 1

        return cnt

    from collections import defaultdict
    n, m = map(int, readline().split())
    edge = defaultdict(list)

    for i in range(m):
        a, b = map(int, readline().split())
        edge[a].append(b)
        edge[b].append(a)

    ans = dfs(1, [False] * (n + 1))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 73800
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

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

signed main(){
    string S; cin>>S;
    int ans = 0;
    REP(i,S.size()-1){
        if(S[i]!=S[i+1]) ans ++;
    }
    Out(ans);
}

Measured memory_bytes: 512
//package com.regular.arc069;


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long M = sc.nextLong ();

        long ans = 0;
        if(N>=M/2){
            ans = M/2;
        }
        else{
            ans = N + (M-2*N)/4;
        }

        System.out.println(ans);


        sc.close();

    }

}


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

void solve()
{
    string a, b;
    cin >> a >> b;
    string s = a + b;
    int tmp = 0;
    rep(i, s.size())
    {
        tmp *= 10;
        tmp += s[i] - '0';
    }
    bool ok = false;
    rep(i, 2000)
    {
        // cout << i * i << " " << endl;
        if (tmp == i * i)
            ok = true;
    }
    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n);
#define DEBUG printf("%s\n","debug")
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
vector<ll> V;
int N,A,B;


ll ncr[51][51] = {};
ll comb(int n,int r){
	if (ncr[n][r] != 0) return ncr[n][r];
	if (ncr[n][n-r] != 0) return ncr[n][n-r];
	if (n<r) return 0;
	if ((n==r) or (r == 0)) return 1;
	return ncr[n][r] = comb(n-1,r-1)+comb(n-1,r);
}

int main(){

	SCD3(N,A,B);

	
	REP(i,N){
		ll v;
		scanf("%lld",&v);
		V.PB(v);
	}
	
	sort(V.begin(),V.end(),greater<ll>());
	
	V.PB(0);
	double ans1 = 0;
	ll sum1 = 0;
	
	REP(i,A){
		sum1 += V[i];
	}
	
	ans1 = (double)sum1 / A;
	printf("%lf\n",ans1);
	
	
	int count = 0;
	ll vai = V[A-1];
	int vaiup = 0;
	
	REP(i,V.size()){
		if (V[i] == vai) {
			count++;
		}
		
		if (V[i] > vai){
			vaiup++;
		}
		
	}

	
	ll ans2 = 0;
	
	if (V[0] != V[A-1]){
		ans2 = comb(count,A-vaiup);
	} else {
		FORq(i,A,B){
			ans2 += comb(count,i);
		}
	}

	PRINTLLD(ans2);
	
	return 0;
}


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

int main()
{
    int ans=0;
    char a[5],b[5];
    string hoge; 
    cin>>a>>b;

    for(int i=(int)strtol(a,NULL,10);i<=(int)strtol(b,NULL,10);i++)
    {
        hoge=to_string(i);
        if(hoge[0]==hoge[4]&&hoge[1]==hoge[3]) ans++;
    }
    cout<<ans<<endl;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

bool comp(LLP a, LLP b){
    return a.first + a.second == b.first + b.second ? a.first > b.first : a.first + a.second > b.first + b.second;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    vector< LLP > v(n);
    rep(i, n){
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end(), comp);

    lint ans = 0;
    rep(i, n){
        if(i % 2 == 0){
            ans += v[i].first;
        }else{
            ans -= v[i].second;
        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 1792
const main = (inputs) => {
  var mod = 1000000007;

  var N = inputs[0].split(" ")[0]-0;
  var M = inputs[0].split(" ")[1]-0;
  var ana = {};
  for(var i=1;i<=M;i++){
    ana[inputs[i]] = true;
    if(i>1 && inputs[i] - inputs[i-1] == 1) {console.log(0);return;}
  }
  var map = {
    0: 1,
    1: (ana[1]?0:1)
  };
  for(var i=2;i<=N;i++){
    if(ana[i]) continue;
    map[i] = (map[i-1]||0) + (map[i-2]||0);
    map[i] = map[i]%mod;
  }
  console.log(map[N]);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));


Measured memory_bytes: 17228
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

/*******************************************************/

int main() {
  int n; cin >> n;
  vll a(n); Loop(i, n) cin >> a[i];
  int state = 0;
  int ans = 1;
  Loop1(i, n - 1) {
    if (state == 0) {
      if (a[i] == a[i - 1]) state = 0;
      else if (a[i] > a[i - 1]) state = 1;
      else state = 2;
    }
    else if (state == 1) {
      if (a[i] == a[i - 1]) state = 1;
      else if (a[i] > a[i - 1]) state = 1;
      else {
        state = 0; ans++;
      }
    }
    else {
      if (a[i] == a[i - 1]) state = 2;
      else if (a[i] < a[i - 1]) state = 2;
      else {
        state = 0; ans++;
      }
    }
  }
  cout << ans << endl;
}

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

int main()
{
  int n;
  cin >> n;
  set<int> s;
  for (int i = 1; i <= 9; i++)
  {
    for (int j = 1; j <= 9; j++)
    {
      s.insert(i * j);
    }
  }
  if (s.count(n))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;
const int N=1e5+5;

int calc(int x,int y){
	if(x<y) return 0;
	if(x==y) return 1;
	int ans1=1,ans2=1;
	y=min(x-y,y);
	for(int i=x;i>=x-y+1;i--) ans1*=i;
	for(int i=1;i<=y;i++) ans2*=i;
	return(ans1/ans2); 
}

int32_t main(){
	IOS;
	string s; cin>>s;
	int n=s.length();
	int k; cin>>k;
	int ans=0;
	int res=0;
	for(int i=0;i<n;i++){
		char x=s[i];
		for(int j=0;j<(int)(x-'0');j++){
			if(j==0) ans+=calc(n-i-1,k-res)*pow(9,k-res);
			else ans+=calc(n-i-1,k-(res+1))*pow(9,k-res-1);
			//cout<<j<<" "<<ans<<" "<<calc(n-i-1,k-res-1)<<endl;
		}
		if(s[i]!='0') res++;
		if(res==k){
			ans++;
			break;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        int x,i=0;
        
        Scanner scan = new Scanner(System.in);
        
        while(i<10000){
            i++;
            x = scan.nextInt();
            
            if(x == 0){
                break;
            }else {
                System.out.println("Case "+i+": "+x);
            }
            
        }
    }
}


Measured memory_bytes: 41180
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	char s[5];
	for(int i=0;i<4;i++){
		cin>>s[i];
	}
	if(s[0]==s[1] && s[1]==s[2])cout<<"Yes"<<endl;
	else if (s[1]==s[2] && s[2]==s[3] )cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;

int main(){
	int r;
	cin>>r;
	double pi=2*acos(-1);
	double res=pi*r;
	cout<<fixed<<setprecision(20)<<res;
	
	
	
	
	
	
	
}

Measured memory_bytes: 3776
(n,_),*t=[t.split()for t in open(0)]
n=int(n)
for i in range(10**(n-1)-(n<2),10**n):
  i=str(i)
  for s,c in t:
    if i[int(s)-1]!=c:
      break
  else:
    print(i)
    break
else:
  print(-1)

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

int main(){
  string s, t;
  cin >> s >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  if(s < t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}

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

using namespace std;

int main(void) {

        int in; 

        vector<int> list;

        for(int i=2;i<=123456;i++) {
                bool sosu = true;
                for(int &n: list) {
                        if(i%n==0) {
                                sosu = false;
                                break;
                        }   
                }   
                if(sosu) {
                  list.push_back(i);
                }   
                    
        }   

        while(cin >> in && in) {

                int count=0;
                for(int i=in+1;i<=2*in;i++) {
                        bool sosu = true;
                        for(int &n: list) {
                                if(n>=i) break;
                                if(i%n==0) {
                                        sosu = false;
                                        break;
                                }   
                        }   
                        if(sosu) count++;
                }   
                cout << count << endl;
        }   
            
        return 0;
}

Measured memory_bytes: 3128
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define REP(i,a,b) for(long long int i=a ; i<b ; i++)
#define mp make_pair
#define INF 1000000000000000000
#define mod 1000000007
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define vi vector<ll>
#define vd vector<ld>
#define vvi vector<vi>
#define vvd vector<vd>
#define vpi vector<pi>
#define vpd vector<pd>
#define us unordered_set<ll>
#define um unordered_map<ll,ll>
#define sortA(a) sort(a.begin(),a.end())
#define sortD(a) sort(a.begin(),a.end(),greater<ll>())
#define all(a) a.begin(),a.end()
#define N 100005


#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define in insert
#define fbo find_by_order
#define ook order_of_key


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

ll powmod(ll x,ll y)
{
	if(x==0)
		return 0;
	if(y==0 || x==1)
		return 1;
	if(y%2==0)
		return powmod((x*x)%mod,y/2)%mod;
	return (x*powmod(x,y-1)%mod)%mod;
}
void print1D(vi a)
{
	for(ll i=0;i<a.size();++i)
	{
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
void print2D(vector<vi> a)
{
	for(ll i=0;i<a.size();++i)
	{
		for(ll j=0;j<a[i].size();++j)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
}
void solve()
{
	string s,t;
	cin>>s>>t;
	ll n=s.size(),m=t.size();
	vvi dp(n+1,vi(m+1));
	for(ll i=1;i<=n;++i)
	{
		for(ll j=1;j<=m;++j)
		{
			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			if(s[i-1]==t[j-1])
			{
				dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
			}
		}
	}
	// debug(dp);
	string ans="";
	ll i=n,j=m;
	while(dp[i][j]!=0)
	{
		if(dp[i][j]==dp[i-1][j])
		{
			i--;
		}
		else if(dp[i][j]==dp[i][j-1])
		{
			j--;
		}
		else
		{
			ans+=s[i-1];
			i--;j--;
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
	ll t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 70784
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();

        int n = s.length;
        int m = t.length;

        int min = m;
        for(int i=0; i+m-1<n; i++) {
            int a = 0;
            for(int j=0; j<m; j++) {
                if(s[i+j] != t[j]) {
                    a++;
                }
            }
            min = Math.min(min, a);

        }

        System.out.println(min);

    }



}

Measured memory_bytes: 35616
# arr=input().strip().split(' ')
arr=[int(i) for i in input().strip().split(' ')]
if 1 not in arr:
	print(1)
if 2 not in arr:
	print(2)
if 3 not in arr:
	print(3)
if 4 not in arr:
	print(4)
if 5 not in arr:
	print(5)


Measured memory_bytes: 8980
n = int(input())
a = list(map(int, input().split()))
flag = 0
for i in range(n):
    if a[i]%2 != 0:
        continue
    elif a[i]%2 == 0:
        if a[i]%3 == 0 or a[i]%5 == 0:
            continue
        else:
            flag = 1
            print("DENIED")
            break
if flag==0:
    print("APPROVED")
        


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ll long long
#define w cout 
#define e '\n'

using namespace std;

const int N = 1e6 + 5;
ll dd[N] ;

int main(){
	ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
	ll n , we ; 
	cin >> n >> we;
	for(int i = 0 ; i < n ;i ++) {
		ll ww , vv; cin >> ww >> vv;
		for(int j = we ; (j - ww)>= 0 ; j --) {
			dd[j] = max(dd[j] , dd[j - ww] + vv);
 		}
	}

	w << *max_element(dd , dd + N);
}

/*
3 8
3 30
4 50
5 60*/

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

using namespace std;
#define ll long long int

int main()
{
    int N;
    cin >> N;
    int a;
    int A[N];
    int max = 0;

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

    for (int j = 0; j < N; j++)
    {
        for (int i = 0; i < N; i++)
        {
            a = abs(A[j] - A[i]);
            if (max <= a)
                max = a;
        }
    }

    cout << max;

    return 0;
}


Measured memory_bytes: 3596
/**
 *    author:  FromDihPout
 *    created: 2020-05-26
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    set<int> seen;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (seen.count(x)) {
            cout << "NO" << '\n';
            return 0;
        }
        seen.insert(x);
    }
    cout << "YES" << '\n';
    return 0;
}

Measured memory_bytes: 9600
m=1e9+7,P[2][3333];*p,*q;
c,i;
f(j){
	q[j]=~c?*p-p[j]:p[j];
	j<i&&f(j+1);
	q[j]=(1L*q[j]+q[j+1]+m)%m;
}
main()
{
	P[0][0]=1;
	for(gets(&c);c=getchar()%3-1;f(0))p=P[i%2],q=P[++i&1];
	printf("%d",*q);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    int A, B;
    cin >> A >> B;
    cout << 6 - A - B << endl;


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define in(s,x) s.find(x) != s.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<pair<int,int>> VPII;
const ll mod=1000000007;
const ll INF= 1LL<<60-1;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
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; }
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}

// head


int m,n,k,res,tmp,tmp2,tmp3,h,x,y;
VI a;
deque<PII> que;
string s;
//VI b;
vector<PII> g[2100600];
int b[2100000] = {};
int c[210000] = {};
int rui[2100][2100];
int dp[2200][2200];



signed main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>m;
  rep(i,0,n){cin>>b[i];}
  rep(i,0,m){cin>>c[i];}
  dp[0][0] = 1;
  rep(i,0,n+3){dp[i][0] = 1;}
  rep(i,0,m+3){dp[0][i] = 1;}
  rep(i,0,n){
    rep(j,0,m){
          if(b[i] == c[j]){dp[i+1][j+1] += dp[i][j];}
          dp[i+1][j+1] += dp[i+1][j]+dp[i][j+1]-dp[i][j]+mod;
          dp[i+1][j+1]%=mod;
    }
  }
  cout << dp[n][m]%mod << '\n';
}


Measured memory_bytes: 88576
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (int i=a;i>=b;i--)
using namespace std;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
char s[6666666];
int tot,now,n,son[6666666][2],m,d[6666666];
LL l,ans;
void add(){
	now=0;
	FOR(i,0,m-1){
		if (!son[now][s[i]-'0']) son[now][s[i]-'0']=++tot,d[tot]=d[now]+1;
		now=son[now][s[i]-'0'];
	}
}
LL cal(LL x){
	if (x==0) return 0ll;
	LL t=1;
	while (x%2==0) t<<=1,x/=2;
	return t;
}
int main(){
	cin>>n>>l;
	FOR(i,1,n){
		scanf("%s",s);
		m=strlen(s);
		add();
	}
	FOR(i,0,tot)
		if ((son[i][0]!=0) ^ (son[i][1]!=0)) ans^=cal(l-d[i]);
	if (ans) puts("Alice"); else puts("Bob");
	return 0;
}


Measured memory_bytes: 6784
N, K = input().split()
N, K = int(N), int(K)



li = [int(input()) for i in range(N)]
li.sort()
min_val = 10e10
for i in range(N-K+1):
    val = li[K + i - 1] - li[i]
    if val < min_val:
        min_val = val
print(int(min_val))

Measured memory_bytes: 7484
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,H;
	while(cin>>N>>H) {
		vector<PII> AB(N);
		REP(i, N) cin>>AB[i].FI>>AB[i].SE;
		sort(ALLR(AB));
		VI bs;
		REP(i, N) if(AB[0].FI<=AB[i].SE) bs.PB(AB[i].SE);
		sort(ALLR(bs));
		ll ans=0;
		REP(i, bs.size()) {
			if(0<H) {
				H-=bs[i];
				ans++;
			}
		}
		if(0<H) {
			ans += (H+AB[0].FI-1)/AB[0].FI;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 2936