akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include<climits>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////
#define pll pair<ll,ll>

ll N;

int main(){
    scanf("%lld",&N);

    if(N==3||N==5||N==7){
        printf("YES");
    }else{
        printf("NO");
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
bool isGreater(const std::vector<int> &a, const std::vector<int> &b) {
	auto min = a.size() > b.size() ? b.size() : a.size();
	for (auto i = 0; i < min; ++i) {
		if (a[i] > b[i]) return true;
		else if (a[i] < b[i]) return false;
	}
	return a.size() >= b.size();
}
int main() {
	int n;
	std::cin >> n;
	std::vector<int> avec(n);
	for (auto &v : avec) std::cin >> v;
	int m;
	std::cin >> m;
	std::vector<int> bvec(m);
	for (auto &b : bvec) std::cin >> b;
	if (isGreater(avec, bvec)) {
		std::cout << 0 << std::endl;
	}
	else {
		std::cout << 1 << std::endl;
	}
}


Measured memory_bytes: 3100
import sys
import numpy as np

MOD = 1000000007

def main():
    n, m = [int(x) for x in input().split()]
    pattern = [1]
    broken = -1
    brokencnt = 0
    if brokencnt < m:
        broken = int(input())
        brokencnt += 1
    for i in range(1, n + 1):
        if i == broken:
            pattern.append(0)
            if brokencnt < m:
                broken = int(input())
                brokencnt += 1
            continue
        if i == 1:
            pattern.append(pattern[i - 1])
        if i > 1:
            pattern.append((pattern[i - 1] + pattern[i - 2]) % MOD)
    print(pattern[n])


main()


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

int main()
{
    intmax_t n = 0;
    cin >> n;

    intmax_t ar[n];
    for(intmax_t i=0; i<n; i++) cin >> ar[i];

    sort(ar, ar+n);
    bool ans = false;
    for(int i=1; i<n; i++){
        if(ar[i-1]==ar[i]){ ans=true; break; }
    }
    if(ans==true) cout << "NO";
    else cout << "YES";
}

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

using namespace std;

const int N = 1000 * 100 + 7;

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

vector < ii > ladj[N];
int cor[N];

void dfs(int node, int pai, ll peso){
	cor[node] = peso%2;
	for(ii vizinho : ladj[node]){
		int ind = vizinho.first;
		if(ind == pai)continue;
		int dist = vizinho.second;
		dfs(ind, node, dist + peso);
	}
}

int main(){
	int n;
	memset(cor, -1, sizeof cor);
	scanf("%d", &n);
	for(int i = 0; i < n - 1; i++){
		int v, u, w;
		scanf("%d %d %d", &v, &u, &w);
		ladj[v].push_back({u, w});
		ladj[u].push_back({v, w});
	}
	dfs(1, -1, 0);
	for(int i = 1; i <= n; i++)
		printf("%d\n", cor[i]);
	return 0;
}

Measured memory_bytes: 8448
cat<<EOF>Source.cpp

extern "C"{
int printf (const char *__restrict __format, ...);
int scanf (const char *__restrict __format, ...) ;
}
int max(int a,int b){
	return a>b?a:b;
}
int x[100000],y[100000],x_mod_k[100000],x_div_k[100000];
char s[100000][2];
int n,k;

void add(int*cnt,int x,int t){
	if((x_div_k[x]&1)==0){
		if(t==0){
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
		else{
			cnt[k-x_mod_k[x]]++;
		}
	}
	else{
		if(t==0){
			cnt[k-x_mod_k[x]]++;
		}
		else{
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
	}
}
int ans[2000];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d%d%s",&x[i],&y[i],s[i]);
		x_mod_k[i]=y[i]%k;
		x_div_k[i]=y[i]/k;
	}
	int Max=0;
	#pragma omp parallel for num_threads(2)
	for(int i=0;i<k;i++){
		int d=max(n,k);
		int cnt[d];
		for(int j=0;j<d;j++)cnt[j]=0;
		for(int j=0;j<n;j++){
			if(s[j][0]=='B'){
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,0);
				}
				else{
					add(cnt,j,1);
				}
			}
			else{
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,1);
				}
				else{
					add(cnt,j,0);
				}
			}
		}
		for(int j=0;j<k;j++){
			if(j)cnt[j]+=cnt[j-1];
			ans[i]=max(ans[i],max(cnt[j],n-cnt[j]));
		}
	}
	for(int i=0;i<k;i++)Max=max(Max,ans[i]);
	printf("%d\n",Max);
}
EOF
g++ -Ofast Source.cpp -o Source -fopenmp -std=c++11
./Source

Measured memory_bytes: 6372
import java.util.Scanner;                                                   
class Main {
  
    public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
                int a = in.nextInt();
                int b = in.nextInt();
                double d = (double)a/(double)b;
                System.out.print((a / b)  + " " + (a % b) + " " + String.format("%.5f",d));
        }
}

Measured memory_bytes: 26292
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))
N=int(input())

i = 0
for i in range(N):
    b = int(input())
    j = 0
    while j<3:
        if A1[j]==b:
            A1[j]=-1
        j+=1
    j = 0
    while j<3:
        if A2[j]==b:
            A2[j]=-1
        j+=1
    j = 0
    while j<3:
        if A3[j]==b:
            A3[j]=-1
        j+=1


if A1[0]==A1[1]==A1[2] or A2[0]==A2[1]==A2[2] or A3[0]==A3[1]==A3[2] or A1[0]==A2[0]==A3[0] or A1[1]==A2[1]==A3[1] or A1[2]==A2[2]==A3[2] or A1[0]==A2[1]==A3[2] or A1[2]==A2[1]==A3[0]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int n, k;
	cin >> n >> k;
	veci p(n);
	rep(i, n) cin >> p[i];
	sort(all(p));
	ll sum = 0;
	rep(i, k)
	{
		sum += p[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3628
import numpy as np
from numba import njit


@njit('i8[:](i8,i8,i8[:])')
def solve(N, K, A):
    for _ in range(K):
        B = np.zeros(N + 1, dtype=np.int64)
        for i in range(N):
            a = A[i]
            B[max(0, i - a)] += 1
            B[min(N, i + a + 1)] -= 1
        A = np.cumsum(B)[:-1]
        if np.all(A == N):
            return A
    return A


N, K = map(int, input().split())
A = np.array(input().split(), dtype=int)
print(' '.join(map(str, solve(N, K, A))))

Measured memory_bytes: 137048
import scala.util.control.Breaks
object Main extends App {
  val b = new Breaks
  b.breakable {
    for (i <- 1 to 3000) {
      val Seq(x, y) = readLine().split(' ').map(_.toInt).toList.sorted
      if (x != 0 || y != 0)
        println("%d %d".format(x, y))
      else
        b.break
    }
  }
}


Measured memory_bytes: 53356
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
const long long MaxN = 1e5;

int main()
{
	int a[5],n,k,ans;
	while(~scanf("%d %d %d",&a[1],&a[2],&a[3]))
	{
		ans = 0;
		sort(a + 1,a + 4);
		n = a[2] - a[1];
		k = a[3] - a[2];
		ans += k;
		ans += n/2;
		if(n % 2 != 0) ans += 2;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    ll N;
    cin>>N;
    string S;
    cin>>S;

    ll cnt = 1;
    rep(i, N - 1) {
        if (S[i] != S[i + 1]) cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

long long  factorial(long long n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}

//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
//  int  a ,b, c, d, e, X, Y ,r;
  long long  a, b, c, d, e, X, Y;
  //  double  c;
//  int  A[200003]={};
  int  A[100003]={};
  int  B[100003]={};
  int  C[100003][11]={};

  int  flg=0;

//  char s[101][101]={};
  char s[100001]={};
  char t[101][101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p,q;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  int ans=0;
  int max=0;
  int sum=0;
  int addr=0;
  int ptn=0;
  long long  tmp=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%d", &a);
  if(a==2){
    printf("2\n");
    return 0;
  }
  else if(a%2==0) a=a+1;
  
  for(i=a;i<=110000;i+=2)
	{
		k=0;
		for(j=3;j<=sqrt(i);j+=2)
		{
			if(i%j==0)
			{
				k=1;
				break;
			}
		}

		if(k==0) {printf("%d ",i);
        break;}
	}

	printf("\n");
  
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;

vector<pii> G[100050];
vb seen;
vi dist;

void dfs(int v) {
    seen[v] = true;
    for(auto p: G[v]) {
        if(seen[p.first]) {
            if(dist[v] + p.second != dist[p.first]) {
                cout << "No" << endl;
                exit(0);
            }
        }
        else {
            dist[p.first] = dist[v] + p.second;
            dfs(p.first);
        }
    }
}

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

int N,M; cin >> N >> M;
rep(i,M) {
    int l,r,d; cin >> l >> r >> d; l--; r--;
    G[l].push_back(pii(r,d));
    G[r].push_back(pii(l,-d));
}
seen.assign(N, false);
dist.assign(N, 0);
rep(i,N) {
    if(!seen[i]) {
        dfs(i);
    }
}
cout << "Yes" << endl;
return 0;
}

Measured memory_bytes: 12032
#include <iostream>
#include <string>    
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, k, s[5001];
string str;

int main() {
	cin >> str >> k;
	n = str.size();
	
	vector<string> ss;
	set<string> used;
	
	
	for(ll i = 1; i <= min(n, k); i++){
		for(ll j = 0; j <= n-i; j++){
			if(used.find(str.substr(j, i)) == used.end()){
				ss.push_back(str.substr(j, i));
				used.insert(str.substr(j, i));
			}
		}
	}
	
	sort(ss.begin(), ss.end());
	
	cout << ss[k-1] << endl;
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<P> AB(N);

	rep(i,N)
		cin >> AB.at(i).first >> AB.at(i).second;
	sort(AB.begin(), AB.end());

	cout << AB.at(N-1).first+AB.at(N-1).second << endl;
}

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

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

	for(double i=1;i<=50000;i++){
		if((int)(i*1.08)==n){
			cout<<i<<endl;
			return 0;
		}
	}

	cout<<":("<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        List<int> l = Console.ReadLine().Split().Select(i => int.Parse(i)).ToList();
        if (l.Max() < l.Sum() - l.Max())
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}

Measured memory_bytes: 13396
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#define swap(type,a,b) { type temp = a; a = b; b = temp; }
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}

int main(void) {
	// your code goes here
	char s[200001],t[200001];
	int flag=0,i,j,len,r[27],q[27],a[200001],b[200001];
	scanf("%s",s);
	scanf("%s",t);
	len=strlen(s);
	for(i=0;i<len;i++){
		a[i]=s[i]-'a';
		b[i]=t[i]-'a';
	}
	for(i=0;i<26;i++){
		r[i]=-1;
		q[i]=-1;
	}
	for(i=0;i<len;i++){
		if(r[a[i]]>=0){
			if(r[a[i]]!=b[i]) flag=1;
		} else {
			r[a[i]]=b[i];
		}
		if(q[b[i]]>=0){
			if(q[b[i]]!=a[i]) flag=1;
		} else {
			q[b[i]]=a[i];
		}
	}
	if(flag==1) printf("No\n");
	else printf("Yes\n");
	return 0;
}


Measured memory_bytes: 2176
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	_ "sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func convertToInt(s []string, len int) []int {
	ret := make([]int, len)
	for i := 0; i < len; i++ {
		ret[i], _ = strconv.Atoi(s[i])
	}
	return ret
}

var N int
var T int

func main() {
	cols := strings.Split(nextLine(), " ")
	N, _ = strconv.Atoi(cols[0])
	T, _ = strconv.Atoi(cols[1])
	min := math.MaxInt32

	for i := 0; i < N; i++ {
		cols := strings.Split(nextLine(), " ")
		c, _ := strconv.Atoi(cols[0])
		t, _ := strconv.Atoi(cols[1])
		if t > T {
			continue
		}
		if min > c {
			min = c
		}
	}

	if min == math.MaxInt32 {
		fmt.Println("TLE")
	} else {
		fmt.Println(min)
	}
}

Measured memory_bytes: 640
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M = map(int,input().split())
uf = UnionFind(N)

for i in range(M):
         a,b = map(int,input().split())
         uf.union(a-1,b-1)
         

print(uf.group_count() - 1)


Measured memory_bytes: 12908
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
ll ok[12345678];
signed main() {
    ll n, a, cnt = 0, ans = INF;
    string s; cin >> s;
    for (int h = 97; h < 123; h++) {
        ll z = 0; string t = s; cnt = 0;
        for (int i = 0; i < s.size(); i++) {
            if ((ll)s[i] == h) { z++; }
        }
        if (z == 0) { continue; }
        while (true) {
            z = 0;
            for (int i = 0; i < t.size(); i++) {
                if ((ll)t[i] != h) { z++; }
            }
            if (z == 0) { ans = min(ans, cnt); break; }
            for (int i = 1; i < t.size(); i++) {
                if ((ll)t[i] == h) { t[i - 1] = t[i]; }
            }
            t.pop_back(); cnt++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <queue>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, begin, n) for (int i = (begin); i < (n); ++i)
#define RepItr(it, begin, end) for (auto it = (begin); it != (end); ++it)
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;
const static double PI = ::acos(-1);


int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int maxI = n / 2;

    int count = 0;
    Rep(i, maxI)
    {
        if (s[i] != s[n - 1 - i])
        {
            ++count;
        }
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long A[] = new long[N];
		for(int i = 0 ; i < N ; ++i){
			A[i] = sc.nextLong();
		}
		Arrays.sort(A);
		List<Long> cur = new ArrayList<Long>();
		int ind = 1;
		long ret = 0;
		for(int i = N - 1 ; i >= 0 ; --i){
			long a = A[i];
			if(!cur.isEmpty()){
				ret += cur.get(ind / 2);
				ind++;
			}
			cur.add(a);
		}
		System.out.println(ret);
	}
}


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

void main_()
{
    ll a, b, x;
    cin >> a >> b >> x;

    ll ans;
    if (a > 0) {
        ans = b / x - (a - 1) / x;
    } else {
        ans = b / x + 1;
    }
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define m_p make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  vector<ll> d(n);
  rep(i,n) cin >> d[i];
  sort(all(d));
  cout << d[n/2]-d[n/2-1] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n, t;
    cin >> n >> t;
    int ans = 1001;
    for (int i = 0; i < n; i++)
    {
        int cost, time;
        cin >> cost >> time;
        if (time <= t)
        {
            ans = min(ans, cost);
        }
    }
    if (ans == 1001)
    {
        cout << "TLE" << endl;
    }
    else
    {
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int cnt[13];
int X[25];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int D[51];
    rep(i, N) cin >> D[i];
    cnt[0]++;
    rep(i, N) cnt[D[i]]++;
    rep(i, 13) {
        if(cnt[i] == 2) {
            X[i]++;
            X[24 - i]++;
        }else if (cnt[i] > 2) {
            X[i] += 2;
            X[24 - i]++;
        }
    }
    vector<int> v;
    rep(i, 13) if(cnt[i] == 1) v.push_back(i);
    int size = v.size();
    sort(v.begin(), v.end());
    int ans = 0;
    rep(bit, (1 << size)) {
        int x[25];
        rep(i, 25) x[i] = X[i];
        rep(i, size){
            if (bit & (1 << i)) {
                x[24 - v[i]] = 1;
            } else {
                x[v[i]] = 1;
            }
        }
        int tmp = 24;
        rep(i, 25) {
            rep(j, 25) {
                if (i == j) continue;
                int d = abs(i - j);
                if (x[i] && x[j])
                    tmp = min(tmp, min(d, 24 - d));
                if (x[i] >= 2) tmp = 0;
            }
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  int n,m;
  cin>>n>>m;
  if(n<m)
    cout<<0<<endl;
  else
    cout<<10<<endl;
  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    ll ans = max(n-2, 0LL) * max(m-2, 0LL);
    if(n == 1) ans = max(m-2, 0LL);
    if(m == 1) ans = max(n-2, 0LL);
    if(n == 1 && m == 1) ans = 1;
    cout << ans << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);

    int l = 1;
    rep(i,n) {
        if(l == a.at(i)) l++;
    }
    if(l == 1) cout << -1 << endl;
    else cout << n-l+1 << endl;
    return 0;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using P = pair<ll,ll>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

struct BIT{
  int N;
  int bit[1000010];
  void add(int a,int w){
    for(int x = a; x < N; x+=(x&-x)) bit[x]+=w;
  }
  int sum(int a){
    int ret = 0;
    for ( int x = a; x > 0;x-=(x&-x)) ret += bit[x];
    return ret;
  }
};

int main() {
  ll N;
  string S;
  cin>>N>>S;
  int Q;
  cin>>Q;
  vector<int> D,M,C;
  vector<vector<ll>> cnt(N+1,vector<ll>(3,0));
  rep(i,N){
    if(S[i]=='D') {
      D.push_back(i);
      cnt[i+1][0]++;
    }
    if(S[i]=='M') {
      M.push_back(i);
      cnt[i+1][1]++;
    }
    if(S[i]=='C') {
      C.push_back(i);
      cnt[i+1][2]++;
    }
  }
  rep(i,N){
    rep(j,3){
      cnt[i+1][j]+=cnt[i][j];
    }
  }
  vector<ll> DMcnt(N+1,0);
  rep(i,N){
    if(S[i]=='M') DMcnt[i+1]+=cnt[i+1][0];
  }
  rep(i,N) DMcnt[i+1]+=DMcnt[i];
  rep(i,Q){
    int k;
    cin>>k;
    ll ans = 0;
    for(auto x:C){
      ll p = DMcnt[x+1]-DMcnt[max(0,x-k+1)]-cnt[max(0,x-k+1)][0]*(cnt[x+1][1]-cnt[max(0,x-k+1)][1]);
      ans += p;
    }
    cout<<ans<<endl;
  }
}

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

const int MAXN = 1e5+5;
const ll p = 1e9+7;

int n, g[505][505];

int main() {
	cin >> n;
	int sum = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			char x; cin >> x;
			if (x == '.')
				g[i][j] = 0;
			else
				g[i][j] = 1;
			sum += g[i][j];
		}
	}

	if (sum == 0) {
		cout << "-1\n";
		return 0;
	}

	int ct = 0;
	for (int j = 0; j < n; ++j) {
		bool y = 1;
		for (int i = 0; i < n; ++i)
			y &= g[i][j];
		ct += y;
	}

	int mini = 1000;
	//now we just try to make some row all black
	for (int i = 0; i < n; ++i) {
		int s = 0;
		for (int j = 0; j < n; ++j)
			s += g[i][j];
		mini = min(mini, n - s + 1);
		if (s == n)
			mini = 0;
		bool y = 0;
		for (int j = 0; j < n; ++j)
			if (g[j][i] == 1)
				y = 1;
		if (y == 1)
			mini = min(mini, n-s);
	}

	cout << mini + n - ct << endl;
}

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

#define Omar45 ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define pb push_back
#define endl '\n'
#define mod 1000000007
#define maxN 1e5
const int inf=0x3f3f3f3f;

int main() {
	Omar45
	int n; cin >> n;
    int a[n+3], b[n+3], c[n+3], dp[n-1][3], res=0;
    for (int i=0; i<n; ++i) // 0-based //
        cin >> a[i] >> b[i] >> c[i] ;
    dp[0][0]=a[0]; dp[0][1]=b[0]; dp[0][2]=c[0];
    res= max(dp[0][0], max(dp[0][1], dp[0][2]));
    for (int i=1; i<n; ++i){
        for (int j=0; j<3; ++j) {
            if (j==0) dp[i][j]= a[i] + max(dp[i-1][1], dp[i-1][2]);
            if (j==1) dp[i][j]= b[i] + max(dp[i-1][0], dp[i-1][2]);
            if (j==2) dp[i][j]= c[i] + max(dp[i-1][0], dp[i-1][1]);
            // last case //
            if (i==n-1) res = max(res, dp[i][j]);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 2560
from collections import deque
h, w = map(int, input().split())
a, b = map(int, input().split())
c, d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s = [list(input()) for i in range(h)]
now = 0
dd = [(-1, 0), (1, 0), (0, 1), (0, -1)]

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            de = deque([(i, j)])
            s[i][j] = now
            while de:
                x, y = de.popleft()
                for p, q in dd:
                    if 0 <= x + p < h and 0 <= y + q < w and s[x + p][y + q] == ".":
                        s[x + p][y + q] = now
                        de.append((x + p, y + q))
            now += 1
st = s[a][b]
en = s[c][d]
es = [set() for i in range(now)]
for i in range(h):
    for j in range(w):
        if s[i][j] != "#":
            for p in range(-2, 3):
                for q in range(-2, 3):
                    if 0 <= i + p < h and 0 <= j + q < w and s[i + p][j + q] != "#":
                        es[s[i][j]].add(s[i + p][j + q])
                        es[s[i + p][j + q]].add(s[i][j])
from heapq import heappush, heapify, heappop


def dijkstra(s):
    INF = 1 << 32
    d = [INF] * now  # 頂点sからの最短距離
    v = -1
    que = [(0, s)]
    heapify(que)
    d[s] = 0
    while que:
        p = heappop(que)
        v = p[1]
        if d[v] < p[0]:
            continue
        for e in es[v]:
            if d[e] > d[v] + 1:
                d[e] = d[v] + 1
                heappush(que, (d[e], e))
    return d[en] if d[en] < INF else -1


print(dijkstra(st))


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

int main(int argc, char *argv[])
{
    std::string s;
    int ans = 0;

    std::cin >> s;

    const int len = s.length();

    for (int i = 0; i < len / 2; i++) {
        if (s[i] != s[len - i - 1]) {
            ans++;
        }
    }

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

    return 0;
}


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

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Library
//

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int x; cin >> x;
    if(x == 3 || x == 5 || x == 7){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int n;
ll K;
vll a, b;

bool check(ll x){
    ll cnt = 0LL;
    rep(i, n){
        ll ub = x / b[i];
        cnt += max(0LL, a[i] - ub);
    }
    return cnt <= K;
}

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

    cin >> n >> K;
    a = vll(n); for(auto& e : a) cin >> e;
    b = vll(n); for(auto& e : b) cin >> e;

    sort(_all(a));
    sort(_all(b));
    reverse(_all(b));

    ll lb = 0, ub = INF;
    rep(_, 100){
        ll mid = (lb + ub) / 2;

        if(check(mid)){
            ub = mid;
        }
        else {
            lb = mid;
        }
    }

    cout << ub << endl;

    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h> 
using namespace std;                     //                       10333 ~2^13.33
using ll = long long;                    // seq 1 128 | factor   100333 ~2^16.61
using vl = vector<ll>;                   //   | grep -v ' .* '  1300111 ~2^20.31
using vvl = vector<vl>;                  //                    10300777 ~2^23.30
using pll = pair<ll,ll>;                 //                   100400999 ~2^26.58
using vb = vector<bool>;                 //                  1300400999 ~2^30.28
const ll oo = 0x3f3f3f3f3f3f3f3fLL;      //                 10200500333 ~2^33.25
const double eps = 1e-9;                 //                100200400777 ~2^36.54
#define sz(c) ll((c).size())             //               1200300700111 ~2^40.13
#define all(c) begin(c),end(c)           //              10200300500777 ~2^43.21
#define mp make_pair                     //             100200300400777 ~2^46.51
#define mt make_tuple                    //            1200300400600999 ~2^50.09
#define pb push_back                     //           10200300400600111 ~2^53.18
#define eb emplace_back                  //          100200300400600333 ~2^56.48
#define xx first                         //         1200300400500800999 ~2^60.06
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })


vector <vector <ll> > dp;
vvl directions;
string s1, s2;


ll rec(ll index_s1, ll index_s2){

    if(index_s1 == 0  || index_s2 == 0){
        return 0;
    }
    if(dp[index_s1][index_s2] != -1){
        return dp[index_s1][index_s2];
    }
    ll res ;
    if(s1[index_s1-1] == s2[index_s2-1]){
        res = rec(index_s1-1, index_s2-1) + 1; 
        directions[index_s1][index_s2] = 0;
    }
    else{
        ll left_cut = rec(index_s1-1, index_s2);
        ll right_cut = rec(index_s1, index_s2-1);
        if(left_cut > right_cut){
            res = left_cut;
            directions[index_s1][index_s2] = -1;
        }else {
            res = right_cut;
            directions[index_s1][index_s2] = 1;
        }
    }

    dp[index_s1][index_s2] = res;
    return res;

}


string reconstruct(ll index_s1, ll index_s2){
    if(index_s1 <= 0 || index_s2 <= 0) return "";
    if(directions[index_s1][index_s2] == 0){
        return reconstruct(index_s1-1, index_s2-1) + s1[index_s1-1];
    } else if(directions[index_s1][index_s2] == 1){
        return reconstruct(index_s1, index_s2-1);
    } else if(directions[index_s1][index_s2] == -1){
        return reconstruct(index_s1-1, index_s2);
    } else {
        if(s1[index_s1-1] == s2[index_s2-1]) return "" + s1[index_s1];
        //cerr << "WTF" << endl;
        return "";
    }
}

int main() {

    cin >> s1 >> s2;

    dp.assign(s1.length()+1, vector<ll>(s2.length()+1, -1));
    directions.assign(s1.length()+1, vl (s2.length()+1, -10));

    rec(s1.length(), s2.length());
    cout << reconstruct(s1.length(), s2.length()) << endl;

    return 0;
}



Measured memory_bytes: 141568
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#define nl          '\n'
#if     DEBUG
#define trace(var)  {cerr << "Line " << __LINE__ << ": " << #var << "=" << var << nl;}
#else
#define trace(var)	{}
#endif
#define fori(n)			for(int i = 0; i < n; ++i) 
#define forj(n)			for(int j = 0; j < n; ++j)
#define fork(n)			for(int k = 0; k < n; ++k)
#define forl(n)			for(int l = 0; l < n; ++l)

typedef long long ll;typedef pair<int,int> pii;typedef vector<bool> vbool;typedef vector<int> vint;typedef vector<ll> vll;typedef long double ld;typedef vector<vector<int>> vvi;

const ll N = 10010;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;

int x[11][11];
int n,d;

bool check(ll num) {
	for(ll i = 1; i*i <= num; ++i) {
		if (i*i == num) return true;
	}
	return false;
}

ll sum(int y, int z) {
	ll c = 0;
	fori(d) {
		c += (x[y][i]-x[z][i])*(x[y][i]-x[z][i]);
	}
	return c;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> d;

	fori(n) 
		forj(d)
			cin >> x[i][j];
	
	ll cur;
	fori(n) 
		for(int j = i+1; j < n; ++j) {
			if (check(sum(i,j))) ++cur;
		}
	cout << cur << nl;
	
	#if DEBUG
	cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << " s" << nl;
	#endif
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    static int n;
    static int[] A;
    static int[] B;
    static int[] C;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        A = new int[n];
        B = new int[n];
        for(int i=0; i<n; i++){
            A[i] = sc.nextInt();
        }
        CountingSort();
        StringBuilder sb = new StringBuilder();
        for(int i=0; i<n-1; i++){
            sb.append(B[i] +" ");
        }
        System.out.println(sb.toString() + B[n-1]);
    }
    public static void CountingSort(){
        C = new int[10001];
        for(int i=0; i<10001; i++){
            C[i] = 0;
        }
        for(int j=0; j<n; j++){
            C[A[j]]++;
        }
        for(int i=1; i<10001; i++){
            C[i] = C[i] + C[i-1];
        }
        for(int j=n-1; j>=0; j--){
            B[C[A[j]]-1] = A[j];
            C[A[j]]--;
        }
    }
}


Measured memory_bytes: 586364
def cmb(n, r, p):
  if (r < 0) or (n < r):
    return 0
  r = min(r, n - r)
  return fac[n] * finv[r] * finv[n-r] % p

M = pow(10,6)+10
MOD = pow(10,9)+7

fac = [-1]*(M+1); fac[0] = 1; fac[1] = 1
finv = [-1]*(M+1); finv[0] = 1; finv[1] = 1
inv = [-1]*(M+1); inv[0] = 0; inv[1] = 1
for i in range(2,M+1):
  fac[i] = fac[i-1]*i%MOD
  inv[i] = MOD - inv[MOD%i]*(MOD//i)%MOD
  finv[i] = finv[i-1]*inv[i]%MOD

#print(cmb(5, 4, MOD))


N = int(input())
A = list(map(int,input().split()))
dic = {}
for i in range(N+1):
  if A[i] not in dic:
    dic[A[i]] = i
  else:
    left = dic[A[i]]
    right = i
    break
#print(dic)
#print(left,right)

for i in range(1,N+2): #1個からN+1個選ぶ
  kosu = i
  total = cmb(N+1,kosu,MOD)
  outside = left + N-right
  dob = cmb(outside,kosu-1,MOD)
  ans = (total - dob)%MOD
  print(ans)


Measured memory_bytes: 88920
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int calcH(vector<int> xyh, int Cx, int Cy) {
	return xyh[2] + abs(xyh[0]-Cx) + abs(xyh[1]-Cy);
}

int main() {
	int N;
	cin >> N;
	vector<vector<int>> xyh(N, vector<int>(3));

	rep(i, N) {
		cin >> xyh[i][0] >> xyh[i][1] >> xyh[i][2];
	}

	int baseID = 0;
	rep(i, N) {
		if(xyh[i][2]>0) {
			baseID = i;
			break;
		}
	}


	for(int cx = 0; cx<101; cx++) {
		for(int cy = 0; cy<101; cy++){

			int tmp_H = calcH(xyh[baseID], cx, cy);
			// cout << "tmpH " << tmp_H << endl;
			if(tmp_H<=0) continue;

			bool good = true;

			for(int i=0; i<N; i++) {
				if(xyh[i][2]==0) {
					if(tmp_H - abs(xyh[i][0]-cx) - abs(xyh[i][1]-cy) >0) {
						good = false;
						continue;
					}
				} else if(tmp_H != calcH(xyh[i], cx, cy)) {
					good = false;
					break;
				} 
			}
			if(good) {
				cout << cx << ' ' << cy << ' ' << tmp_H << endl;
				return 0;
			}

		}
	}

	return 0;
}


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

using namespace std;
const int MAXN = 5e5 + 7;

inline int R()
{
	int rt = 0;
	bool isn = false;
	char ch = getchar();
	for ( ; ch < '0' || ch > '9'; ch = getchar() )
		isn = ch == '-' ? true : isn;
	for ( ; ch >= '0' && ch <= '9'; ch = getchar() )
		rt = rt * 10 + ch - '0';
	return isn ? -rt : rt;
}

char s[MAXN], r[MAXN];
int dp[MAXN], rdp[MAXN], n;

int Gao ()
{
	dp[1] = 0;
	for ( int i = 2; i <= n; ++i )
	{
		int nc = dp[i - 1];
		while ( nc && s[nc + 1] != s[i] )
			nc = dp[nc];
		dp[i] = s[nc + 1] == s[i] ? nc + 1 : 0;
	}
	if ( dp[n] == n - 1 )
		return n;
	if ( !dp[n] || n % ( n - dp[n] ) )
		return 1;
	return 2;
}

void Rn()
{
	for ( int i = 1; i <= n; ++i )
		r[i] = s[n - i + 1];
	rdp[1] = 0;
	for ( int i = 2; i <= n; ++i )
	{
		int nc = rdp[i - 1];
		while ( nc && r[nc + 1] != r[i] )
			nc = rdp[nc];
		rdp[i] = r[nc + 1] == r[i] ? nc + 1 : 0;
	}
}

int main()
{
//	freopen ( "test.in", "r", stdin );
	scanf ( "%s", s + 1 );
	n = strlen ( s + 1 );
	int ans = Gao();
	printf ( "%d\n", ans );
	if ( ans == n || ans == 1 )
		puts ( "1" );
	else
	{
		Rn();
		int cnt = 0;
		for ( int i = 1; i < n; ++i )
			if ( ( !dp[i] || i % ( i - dp[i] ) ) && ( !rdp[n - i] || ( n - i ) % ( n - i - rdp[n - i] ) ) )
				++cnt;
		printf ( "%d\n", cnt );
	}
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"-----------"<<endl;
#define ll long long
#define P pair<int,int>
#define mk make_pair
#define en endl
#define RE return 0
#define int ll

// タクシー

#define MAX 5005

P taxi[MAX];
vector<int> G[MAX];
int min_fee[MAX];
bool done[MAX];

signed main(){
  int n,k;
  cin>>n>>k;
  int a,b;
  for(int i=1; i<=n; i++){
    cin>>a>>b;
    taxi[i].first=a; taxi[i].second=b;
  }
  
  for(int i=0; i<k; i++){
    cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  for(int i=1; i<=n; i++) {
    min_fee[i]=INF;
    done[i]=false;
  }
  
  priority_queue<P,vector<P>,greater<P> > p_que;
  p_que.push(mk(0,1));
  min_fee[1]=0;
  while(!p_que.empty()){
    int from=p_que.top().second;
    int now_fee=p_que.top().first;
    p_que.pop();
    if(done[from]) continue;
    done[from]=true;
    int d[MAX];
    for(int i=1; i<=n; i++) d[i]=INF;
    d[from]=0;
    queue<P> que;
    que.push(mk(from,now_fee));
    
    while(!que.empty()){
      int at=que.front().first;
      que.pop();
      if(d[at]==taxi[from].second) break;
      for(int i=0; i<G[at].size(); i++){
        int to=G[at][i];
        if(d[to]<=d[at]) continue;
        d[to]=d[at]+1;
        min_fee[to]=min(min_fee[to], now_fee+taxi[from].first);
        que.push(mk(to,min_fee[to]));
        if(to!=1&&!done[to]) p_que.push(mk(min_fee[to],to));
      }
    }
  }
  
  cout<<min_fee[n]<<en;
}



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

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 622222

using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
vector<pii> v[N];
int a[N];
int main()
{
	int n, q;
	cin >> n >> q;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	for(int i = 1; i <= q; i ++)
	{
		int x, y;
		cin >> x >> y;
		v[y].pb(M(x, i));
	}
	vi ans (q + 1, 0);
	map<int, int> mp;
	indexed_set s;
	for(int i = 1; i <= n; i ++)
	{
		if(mp.count(a[i]))
		{
			s.erase(mp[a[i]]);
		}
		s.insert(i);
		mp[a[i]] = i;
		for(auto it : v[i])
		{
			int u = s.order_of_key(it.F-1);
			int e = *s.find_by_order(u);
			u ++;
			u -= (e > it.F-1);
			ans[it.S] = s.size() - u;
		}
	}
	for(int i = 1; i <= q; i ++)
		cout << ans[i] << '\n';
	





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 79104
s = input()
t = s[::-1]

if(s == t):
    a = s[:(len(s)-1)//2]
    b = a[::-1]
    if(a == b):
        a = s[(len(s)+3)//2-1:]
        b = a[::-1]
        if(a == b):
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    const int mod = 12;
    // cout << s[6] - '0' << endl;

    if(s[5] == '0'){
        if(s[6] - '0' > 4) puts("TBD");
        else puts("Heisei");
    }else {
        puts("TBD");
    }
    
}


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

using namespace std;


int main(){
  int x;
  int ans=0;
  cin >> x;
  while(x>=500){
    x -= 500;
    ans = ans+1000;
  }
  while(x>=5){
    x -= 5;
    ans = ans+5;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long   ll;
typedef long double ld;
const int N  = 5e5+10;
const ll mod = 1e9+7;
const ll inf = 1e18;
 
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define ub              upper_bound                 // first element >  val(itr)
#define lb              lower_bound                 // first element >= val(itr) 
#define all(x)          (x).begin(),(x).end()
#define reset(a,x)      memset(a,x,sizeof(a))       // x can be 0 or -1
#define leadzero(a)     __builtin_clz(a)            // count leading zeroes
#define trailzero(a)    __builtin_ctz(a)            // count trailing zeroes
#define bitcount(a)     __builtin_popcount(a)       // count set bits
#define iceil(n,x)      ((n)+(x)-1)/(x)
#define test            int t; cin>>t; while(t--)
#define forn(i,a,e)     for(ll i = a; i < e; i++)
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;    }
ll powm(ll base,ll exp){ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
ll modinv(ll n)    { ll ans=powm(n,mod-2); return ans; }
ll add(ll a,ll b)  { return (a%mod+b%mod)%mod;        }
ll sub(ll a, ll b) { return (a%mod+mod-b%mod)%mod;    }
ll mult(ll a,ll b) { return ((a%mod)*(b%mod))%mod;    }
ll choose2(ll n)   { ll ans=(n*(n-1))/2; return ans;  }
ll dist2(ll x1,ll y1,ll x2,ll y2){ ll ans=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1); return ans;}

int main()
{
	fast
	ll n,k;
	cin>>n>>k;

	ll a[n+1];
	forn(i,1,n+1)
	{
		cin>>a[i];
	}

	ll dp[n+1][k+1];
	ll pref[n+1][k+1];
	reset(dp,0);
	reset(pref,0);

	forn(i,0,a[1]+1)
	{
		dp[1][i]=1;
		if(i==0)
			pref[1][i]=1;
		else
			pref[1][i]=add(pref[1][i-1],dp[1][i]);
	}

	forn(i,1,n+1)
	{
		forn(j,0,k+1)
		{
			if(j-a[i]-1>=0)
			{
				dp[i][j]=add(dp[i][j],sub(pref[i-1][j],pref[i-1][j-a[i]-1]));
			}
			else
				dp[i][j]=add(dp[i][j],pref[i-1][j]);
		}

		forn(j,0,k+1)
		{
			if(j==0)
				pref[i][j]=dp[i][j];
			else
				pref[i][j]=add(pref[i][j-1],dp[i][j]);	
		}
	}

	cout<<dp[n][k];
    
	return 0;
}

Measured memory_bytes: 158080
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<set>
#include<random>
#include<stdio.h>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109311;
const long double pi = 3.1415926535897932384626433;
typedef pair<int, int> P;
struct edge { int to, cost; };

signed main() {
	string s; cin >> s;
	if (s == "ani")puts("square1001");
	else puts("e869120");
}


Measured memory_bytes: 3144
n = gets.to_i
l = gets.split(" ").map(&:to_i)
ans = 0

(0...n).each do |x|
  (x+1...n).each do |y|
    (y+1...n).each do |z|
      array = [l[x],l[y],l[z]]
      array = array.sort
        if array[0] + array[1] > array[2] && \
           array[0] != array[1] && array[1] != array[2] && array[2] != array[0]
          ans += 1
        end
    end
  end
end

puts ans

Measured memory_bytes: 14288
import sys
K = int(input())

A = [0 for _ in range(K)]

a = 0
i = 1
while True:
  a *= 10
  a += 7
  a %= K
  if A[a] > 0: # きたことのある数
    print(-1)
    sys.exit()
  if a == 0:
    print(i)
    sys.exit()
  A[a] = i
  i += 1
  
  
  

Measured memory_bytes: 48564
#include <stdio.h>
#include <math.h>
 
int main() {
  int n,i,j,l;
  double s[10020];
  double a2,m,a;
   
  while(1) {
    m=0;
    a2 = 0;
    scanf("%d" , &n);
    if(n == 0) {
      break;
    }
 
    for(i=0;i<n;i++) {
      scanf("%lf", &s[i]);
    m=m+s[i];
    //printf("m[%d] = %lf\n",i ,m);
    }
    m=m/n;
 
    for(i=0; i<n; i++) {
      a2 =a2+(s[i]-m)*(s[i]-m);
    }
    a2 = a2/n;
 
    printf("%.11lf\n",sqrt(a2));
 
  }
 
  return 0;
 
}


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

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  
  if(K>Q){
    for (int i = 0; i < N; i++) {
    cout << "Yes" << endl;
    }
  }
  
  else{
  vector<int> A(Q), B(N);
  for (int i = 0; i < Q; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < Q; i++) {
    B.at(A.at(i)-1)++;
  }
  for (int i = 0; i < N; i++) {
    if( Q-K < B.at(i) ) {
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  
  }
  
  
}

Measured memory_bytes: 1280