akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int A,B,C;
	cin>>A>>B>>C; 
	if(A==B&&B==C){
		cout<<"No";
	}
	else if(A!=B&&B!=C&&A!=C){
		cout<<"No";
	}
	else{
		cout<<"Yes";
	}
	return 0;
}

Measured memory_bytes: 3624
S =input()
#MMYYcheck
ans = "NA"
if 0 < int(S[0])*10+int(S[1]) < 13 :
    ans = "MMYY"
if 0<int(S[2])*10+int(S[3])<13:
    if ans == "MMYY":
         ans ="AMBIGUOUS"
    else: ans ="YYMM"
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		while(stdIn.hasNext()){
			int n = stdIn.nextInt();
			int ans = 2;
			for(int i=2;i<=n;i++){
				ans+=i;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
N, M = gets.split.map(&:to_i)
MOD = 10 ** 9 + 7

if (N - M).abs > 1
  p 0
else
  c = (1..N).inject(1) {|a, b| a * b % MOD } * (1..M).inject(1) { |a, b| a * b % MOD } % MOD
  c = c * 2 % MOD if N == M
  p c
end


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

using namespace std;

typedef pair<int, int> ii;

const int N = 222;
const int MAX = 0x3f3f3f3f;
int g[N][N];

int main()
{
    int n, m, r;
    scanf("%d %d %d", &n, &m, &r);

    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            g[i][j] = i == j ? 0 : MAX;

    int seq[r];
    for (int i = 0; i < r; i++) {
        scanf("%d", &seq[i]);
        seq[i]--;
    }
    sort(seq, seq + r);

    for (int i = 0; i < m; i++) {
        int u, v, w;
        scanf("%d %d %d", &u, &v, &w);

        u--;
        v--;
        g[u][v] = g[v][u] = w;
    }

    for (int k = 0; k < n; k++)
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);

    int ans = MAX;
    do {
        int sum = 0;
        for (int i = 1; i < r; i++)
            sum += g[seq[i - 1]][seq[i]];
        ans = min(ans, sum);
    } while (next_permutation(seq, seq + r));

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

    return 0;
}

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

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		BigInteger num = BigInteger.valueOf(n);
		BigInteger ten = BigInteger.valueOf(10);
		BigInteger nine = BigInteger.valueOf(9);
		BigInteger eight = BigInteger.valueOf(8);
		BigInteger all = ten.pow(n);
		BigInteger min = eight.pow(n);
		BigInteger half = nine.pow(n);
		BigInteger total = (all.subtract(half.add(half))).add(min);
		BigInteger mo = BigInteger.valueOf(1000000007);
		BigInteger ans = total.remainder(mo);
		System.out.println(ans);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


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

int INF = 1001001001;
int n, A, B, C;
vector<int> l(8);

int cost(int a, int b, int c, int cnt, int i) {
  if (i == n) {
    if (!(a && b && c)) return INF;
    return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt - 3);
  }
  vector<int> cand = {cost(a, b, c, cnt, i+1),
                      cost(a+l[i], b, c, cnt+1, i+1),
                      cost(a, b+l[i], c, cnt+1, i+1),
                      cost(a, b, c+l[i], cnt+1, i+1)};
  return *min_element(cand.begin(), cand.end());
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> A >> B >> C;
  for (int i = 0; i < n; i++) cin >> l[i];
  cout << cost(0, 0, 0, 0, 0) << '\n';
  return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vl a(n);
	ll m = 0;
	bool b = false;
	REP(i, n)cin >> a[i];
	REP(i, n) {
		if (a[i] % 2 == 1)b = true;
	}
	
	if (b)cout << "first" << endl;
	else cout << "second" << endl;
}

Measured memory_bytes: 1024
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


A, B = map(int, input().split())
divided_1 = min(A, B)
divided_2 = max(A, B)

divisors = make_divisors(divided_1)
cd = []
for d in divisors:
  if divided_2 % d == 0:
    cd.append(d)

res = []
for e in cd:
  flg = True
  for i in range(1, len(res)):
    r = res[i]
    if e % r == 0:
      flg = False
      break
  if flg:
    res.append(e)

print(len(res))

Measured memory_bytes: 3316
h,w = map(int,input().split())
si = [input() for i in range(h)]

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.size = [1 for _ in range(n+1)]
 
    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
 
    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
 
    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
ki = UnionFind(h*w)

vx = [0,1,0,-1]
vy = [1,0,-1,0]

for i in range(h):
    for j in range(w):
        if si[i][j] == '#':
            #print(i,j,i,j)
            for k in range(4):
                ny = i + vy[k]
                nx = j + vx[k]
                if ny >= 0 and ny < h and nx >= 0 and nx < w:
                    #print(ny,nx)
                    if si[ny][nx] == '.':
                        #print(i,j,ny,nx)
                        #print(ki.same_check(i*w+j,ny*w+nx))
                        if ki.same_check(i*w+j,ny*w+nx) == True:
                            continue
                        #print(i,j,k)
                        ki.union(i*w+j,ny*w+nx)
                        #print(ki.par)
ans = 0
#exit()


#print(ki.size)
#print(ki.par)
li = [0]*(h*w+1)
"""
for i in range(h):
    for j in range(w):
        #print(ki.find(i*w+j),1111111)
        ki.find(i*w+j)
"""
#print(ki.par)
for i in range(h):
    for j in range(w):
        if si[i][j] == '.':
            li[ki.find(i*w+j)] += 1
            #print(ki.par[i*w+h],ki.par)
#print(li)
#print(ki.par)

for i in range(h):
    for j in range(w):
        if si[i][j] == '#':
            #print(ki.size[i*w+j])
            #print(i,j)
            #tmp = 
            #print(ki.find(i*w+j))
            ans += li[ki.find(i*w+j)]
            #print(ans,i,j)
            
print(ans)

Measured memory_bytes: 66824
#include<bits/stdc++.h>
#define R register int
#define G if(++ip==ie)if(fread(ip=buf,1,SZ,stdin))
using namespace std;
const int SZ=1<<19,N=1e5+9,M=2*N;
char buf[SZ],*ie=buf+SZ,*ip=ie-1;
inline int in(){
	G;while(*ip<'-')G;
	R x=*ip&15;G;
	while(*ip>'-'){x*=10;x+=*ip&15;G;}
	return x;
}
int he[N],ne[M],to[M],f[N],a[N],b[N];
int Getf(R x){
	return x==f[x]?x:f[x]=Getf(f[x]);
}
void Dfs(R x,R op){
	a[x]=op;
	for(R y,i=he[x];i;i=ne[i])
		if((y=to[i])!=f[x])
			f[y]=x,Dfs(y,-op),a[x]+=a[y];
}
int main(){
	R n=in(),m=in(),rt=1,re=1,p=0,ans=0;
	for(R i=1;i<=n;++i)f[i]=i;
	for(R p=0,i=1;i<=m;++i){
		R x=in(),y=in();
		if(Getf(x)!=Getf(y))f[f[x]]=f[y];
		else{rt=x,re=y;continue;}
		ne[++p]=he[x];to[he[x]=p]=y;
		ne[++p]=he[y];to[he[y]=p]=x;
	}
	f[rt]=0;Dfs(rt,1);
	if(n==m){
		for(R x=re;x;x=f[x])b[++p]=a[x];
		if(p&1){
			if(a[rt]&1)return puts("-1"),0;
			for(R x=re;x;x=f[x])a[x]-=a[rt]>>1;
		}
		else{
			if(a[rt])return puts("-1"),0;
			sort(b+1,b+p+1);a[rt]=b[p>>1];
			for(R x=re;x!=rt;x=f[x])a[x]-=a[rt];
		}
	}
	else if(a[rt])return puts("-1"),0;
	for(R i=1;i<=n;++i)ans+=abs(a[i]);
	return cout<<ans<<endl,0;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repush_back(i,a,b) for(ll i=a;i>=b;i--)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
ll HRX=1e18;
ll INF=1e9+7;

const ll N=2002;
ll p[N][N];
int main()
{
  hs;
  ll n,k;
  cin>>n>>k;
  for(ll i=0;i<N;i++)
  {
    for(ll j=0;j<=i;j++)
    {
      if(j==0 || j==i)
         p[i][j]=1;
      else
        p[i][j]=(p[i-1][j-1]+p[i-1][j])%INF;
    }
  }
  for(ll i=1;i<=k;i++)
  {
    ll ans=(p[n-k+1][i]*p[k-1][i-1])%INF;
    cout<<ans<<endl;
  }
  return 0;

}


Measured memory_bytes: 30208
#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 ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;

int main(){
    int n,t,a;
    int findID = 0;
    cin>>n>>t>>a;
    vector<float> h(n),w(n);
    rep(i,n) {
        cin>>h[i];
        w[i]=abs((t-h[i]*0.006)-a);
        }
    float INF=10000000;
    float rep = INF;
    rep(i, n){
        if (rep > w[i]) {
            rep = w[i];
            findID = i+1;
        }
    }
    cout<<findID<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
#define pll pair<ll,ll>
#define pii pair<int,int>
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
 
ll gcd(ll a,ll b){ if(b==0) return a; return gcd(b,a%b) ;} 

template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}
 

 
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
 	ll n;
 	cin>>n;
 	vector<ll> vec(n,0);
 	vector<ll> data(1000001,0);
 	vector<ll> flag(1000001,0);
 	for(int i=0;i<n;i++){
 		cin>>vec[i];
 		data[vec[i]]++;
 		flag[vec[i]] = 1;
 	}   
 	sort(vec.begin(),vec.end());
 	ll cnt = 0;
 	vector<ll> chk(1000001,0);
 	for(int i=0;i<n;i++){
 		if(data[vec[i]]<2 and chk[vec[i]]==0){
 			cnt++;
 			// cout<<vec[i]<<endl;
 		}
 		if(flag[vec[i]]==1){
 			ll temp = vec[i];
 			ll mul = 1;
 			while(mul*temp<1000001){
 				chk[mul*temp] = 1;
 				// mul*temp;
 				mul++;
 			}
 			flag[vec[i]] = 0;
 		}

 	}
 	cout<<cnt<<endl;
    return 0;
}

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

int main(void)
{
    int a, b, c;
    scanf("%d%d%d", &a,&b,&c);
    if((a==b && b!=c) || (a==c && a!=b) || (b==c && b!=a))
        printf("Yes");
    else
        printf("No");
	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;
const int Mod = 1e9 + 7;
ll C[2020][2020],n,k;

int main()
{
    for(int i=0; i<=2000; i++)
    {
        for(int j=0; j<=i; j++)
        {
            if(!i || !j)  C[i][j] = 1;
            else   C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
            C[i][j]%=Mod;
        }
    }
    cin >> n >> k;
    ll Ans = 0;
    for(int i = 1 ; i<=k; i++)
    {
        ll Red = n - k - (i - 1);
        ll places = 2 + (i - 1);
        cout << (C[places + Red - 1][Red] * C[k - 1][i - 1])%Mod << '\n';
    }
    return 0;
}


Measured memory_bytes: 30336
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner (System.in);
        while(true){
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            int ans = 0;
            if(op.equals("?"))break; 
            switch(op){
                case "+":
                    ans = a+b;
                    break;
                case "-":
                    ans = a-b;
                    break;
                case "*":
                    ans = a*b;
                    break;
                case "/":
                    if(b!=0){
                        ans = a/b;
                    }
                    break;
                }
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 26388
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
	ll n,memo = 0,memo2 = 0;
	cin >> n;
	ll a[n];
	
	rep(i,0,n) cin >> a[i];
	
	ll sum = 0,sum2 = 0;
	
	rep(i,0,n){
		if(i % 2 == 0){
			if(sum + a[i] <= 0){
				
				memo += abs(1 - (sum + a[i]));
				sum = 1;
			}
			else{
				sum += a[i];
			}
		}
		else{
			if(sum + a[i] >= 0){
				
				memo += abs(-1 - (sum + a[i]));
				sum = -1;
			}
			else{
				sum += a[i];
			}
		}
		//cout << memo << "  " << sum << endl;
	}
	
	rep(i,0,n){
		if(i % 2){
			if(sum2 + a[i] <= 0){
				
				memo2 += abs(1 - (sum2 + a[i]));
				sum2 = 1;
			}
			else{
				sum2 += a[i];
			}
		}
		else{
			if(sum2 + a[i] >= 0){
				
				memo2 += abs(-1 - (sum2 + a[i]));
				sum2 = -1;
			}
			else{
				sum2 += a[i];
			}
		}
		//cout << memo << "  " << sum << endl;
	}
	
	cout << min(memo,memo2) << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3

from typing import *



# def solve(S: str) -> str:
def solve(S):
    if S[-1:] == 's':
        return S+'es'
    else:
        return S+'s'

def main():
    S = input()
    a = solve(S)
    print(a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 10192
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int t = sc.nextInt();

        int ans;
        if (n % x != 0) ans = ((n / x) + 1) * t;
        else ans = n / x * t;
        System.out.println(ans);
    }
}


Measured memory_bytes: 35824
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<numeric>
#include<limits>
#include <cstdint>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
#define ll long long int
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}

ll kai(ll x) {
	ll a = 1;
	if (x <= 0)
		return 1;
	else {
		for(ll i=0;i<x;i++)
			a = a * (i + 1);
		return a;
	}
}

ll rui(ll x, ll y) {
	ll a = 1;
	for (ll i = 0; i < y; i++)
		a = a * x;
	return a;
}
const int nmax = 150;
int cccc[nmax][nmax];
ll comb(ll n, ll k) {
	if (n < k) {
		cout << "error n<k"<<endl;
		return -1;
	}
	if (cccc[n][k] > 0)return cccc[n][k];
	if (k == 0 || n == k)return 1;
	return cccc[n][k] = comb(n - 1, k - 1) + comb(n - 1, k);
}

ll gcd(ll a, ll b)
{
	if (a%b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a%b));
	}
}

ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
int main() {
	cout.precision(20);
	ll N;
	cin >> N;
	if (N % 2 == 1) {
		cout << 0;
		return 0;
	}
	ll ans = 0;
	ll kosu = N / 2;
	ll k = 5;
		ll i = 1;
		while (1) {
			if (N >= k ) {
				ans += kosu / k;

				k = k * 5;
				i++;
			}
			else
				break;
		}
		ll jk=1;
		
	cout << ans;
}

Measured memory_bytes: 256
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
	let S = input[0][0];
	let T = input[1][0];
	
	let ans = Infinity;
	let tmp;
	for (let i = 0; i <= S.length - T.length; i++){
		tmp = 0;
		for (let j = 0; j < T.length; j++){
			if(S[i + j] !== T[j]) tmp ++;
		}
		ans = Math.min(ans, tmp);
	}

	console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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


int main(){
    while (1){
	int n;
	
	int m = 0;
	cin >> n;
	if (n == 0) break;
	n = 1000 - n;
	
	while (n >= 500){
	    m++;
	    n -= 500;
	}
	while (n >= 100){
	    m++;
	    n -= 100;
	}
	while (n >= 50){
	    m++;
	    n -= 50;
	}
	while (n >= 10){
	    m++;
	    n -= 10;
	}
	while (n >= 5){
	    m++;
	    n -= 5;
	}
	while (n >= 1){
	    m++;
	    n -= 1;
	}

	cout << m << endl;
    
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair <int,ll> pii;
typedef vector<int> vi;
ll ans;
set<string> cand;
string s,s2="AKIHABARA";
int main(void)
{
  cin >> s;
  cand.insert("AKIHABARA");
  for(int i=0;i<(1<<9);i++)
    {
      for(int k=0;k<9;k++)
	{
	  if(((i >> k) & 1) && s2[k]=='A')
	    {
	      s2.erase(s2.begin()+k);
	      cand.insert(s2);
	    }
	}
      s2="AKIHABARA";
    }
  for(auto i=cand.begin();i!=cand.end();i++)
    {
      if(s==*i)
	{
	  cout << "YES" << endl;
	  return 0;
	}
    }
  cout << "NO" << endl;
  return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define f first
#define s second
#define pb push_back
#define ipair pair<int,int>
#define INF INT_MAX
using namespace std;

int main()
{
    fast;
    int t=1;
    //cin>>t;
    while(t--)
    {
        int s,w;
        cin>>s>>w;
        if(w>=s)
            cout<<"unsafe\n";
        else
            cout<<"safe\n";
    }
    return 0;
}







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

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int x;
		scanf("%d", &x);
		if (x & 1) {
			printf("first\n"); 
			return 0;
		}
	}
	printf("second\n");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define pb(x) push_back(x)
#define int long long

int calc(int a, int b)
{
 
  int r, x, tmp;
 
  x = a * b;
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  /* 最小公倍数を出力 */
  // printf("最小公倍数 = %d\n", x/b);
 
  return x/b;
}


signed main(void) {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int ans;
  int CD = calc(C, D);

  // cout << CD << endl;
  ans = (B/C + B/D - B/CD) - ((A-1)/C + (A-1)/D - (A-1)/CD);
  cout << B-A+1-ans << endl;

  return 0;
}


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

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

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

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

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

class BMixJuice {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N, K;
        in>>N>>K;
        vc<int> P(N);
        for(auto& p : P) in>>p;
        sort(ALL(P));
        int ans = 0;
        REP(i, K) ans += P[i];
        out<<ans<<'\n';
    }
};


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


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

using namespace std;

int main()
{
	int n,x,i,count = 0;
	cin >> n >> x;
	vector<int> p(n);
	for(i = 0; i < n; i++)
		cin >> p[i];
	sort(p.begin(),p.end());

	for(i = 0; i < n; i++){
		if(i == n-1 && x - p[i] != 0)
			break;
			
		if(x - p[i] >= 0){
			x -= p[i];
			count++;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 256
ans (b:r:g:c:s:t:_) =
  let n = t - (b+r+g+c+s) - (s) - (b*5) - (r*3)
  in
    100 - (3*(b+r+g+c+s+n)) - (2*(b*5+r*3)) + (15*(b*5+r*3)) + (15*b) + (15*r) + (7*g) + (2*c)

main = do
  c <- getContents
  let i = takeWhile (/= [0,0,0,0,0,0]) $ map (map read) $ map words $ lines c :: [[Int]]
      o = map ans i
  mapM_ print o

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

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define mod (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()

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

void print(bool f)
{
    cout << (f ? "Yes" : "No") << endl;
}

void Print(bool f)
{
    cout << (f ? "YES" : "NO") << endl;
}

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

    ll cnt0 = 0, cntk = 0;
    rep(i, 1, n + 1)
    {
        if (i % k == 0)
            cnt0++;
        if (k % 2 == 0 && i % k == k / 2)
            cntk++;
    }
    ll ans = pow(cnt0, 3);
    if (k % 2 == 0)
        ans += pow(cntk, 3);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
ll n, w, wt[105], v[105], ans, sumv;
ll const inf = 1e18+5;
bool tog;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n >> w;
	for (ll i = 1; i <= n ; i++)cin >> wt[i] >> v[i];
	for (ll i=  1; i <= n; i++)sumv += v[i];
	//dp[i] stores min weight to achieve i val
	ll dp[sumv+5];
	for (ll i = 0; i<=sumv+4; i++)dp[i] = inf;
	dp[0] = 0;
	for (ll i = 1; i <= n; i++){
		for (ll j = sumv-v[i]; j >= 0; j--){
			dp[j+v[i]] = min(dp[j]+wt[i], dp[j+v[i]]); 
		}
	}
	for (ll i= 0; i<= sumv; i++){
		if (dp[i] <= w)ans = max(ans, i);
	}
	cout << ans;
}


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

const int MOD = 1e9 + 7; const long long INV2 = (MOD + 1) / 2;
int dp[3003][3003] , arr[3003] , N , Q , tms = 1;

int main(){
	cin >> N >> Q;
	for(int i = 1 ; i <= N ; ++i){
		cin >> arr[i];
		for(int j = i - 1 ; j ; --j){
			dp[i][j] = arr[j] < arr[i];
			dp[j][i] = arr[i] < arr[j];
		}
    }
	for(int i = 1 ; i <= Q ; ++i){
		int x , y; cin >> x >> y;
		for(int j = 1 ; j <= N ; ++j)
			if(j != x && j != y){
				dp[j][y] = dp[j][x] = (dp[j][x] + dp[j][y]) * INV2 % MOD;
				dp[x][j] = dp[y][j] = (dp[x][j] + dp[y][j]) * INV2 % MOD;
			}
		dp[x][y] = dp[y][x] = (dp[x][y] + dp[y][x]) * INV2 % MOD;
	}
	int sum = 0;
	for(int i = 1 ; i <= N ; ++i) for(int j = i + 1 ; j <= N ; ++j) sum = (sum + dp[i][j]) % MOD;
	for(int i = 1 ; i <= Q ; ++i) sum = (sum << 1) % MOD;
	cout << sum; return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c, res = -1;
    cin >> a >> b >> c;
    for (int i=0; i<=a+b; ++i) {
        if ((c+i*60) % (a+b) <= a) {
            res = c+i*60;
            break;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3112
import java.util.Scanner;
public class Main {
	 public static void main(String args[]){
		 Scanner std = new Scanner(System.in);
		 int a = std.nextInt();
		 int b = std.nextInt();
		 if(a>=13) {
			 System.out.println(b);
		 }
		 else if(a<=5) {
			 System.out.println("0");
		 }
		 else {
			 System.out.println(b/2);
		 }
	 }
}


Measured memory_bytes: 21844
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int q;
LL a, b;

void solve(){
    cin >> a >> b;
    if(a > b)swap(a, b);
    LL ans = 2LL * (a - 1);
    LL l = 0, r = 1e9;
    while(r - l > 1){
        LL mid = (l + r)/2;
        bool isok = true;
        for(LL x = mid/2 - 2;x <= mid/2 + 2;x++){
            if(x <= 0 || x > mid)continue;
            if((a + x) * (a + mid - x) >= a * b)isok = false;
        }
        if(isok){
            l = mid;
        }else{
            r = mid;
        }
    }
    cout << ans + l << endl;
}

int main(){
    cin >> q;
    REP(qqq, q)solve();
}

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

void chmin(int& x, int y)
{
  x = min(x, y);
}
void chmax(int& x, int y)
{
  x = max(x, y);
}

int main()
{
  int Q, H, W;
  string S[50];
  int proc = 1;
  int used[50][50] = {{}};

  cin >> Q;
  while(Q--) {
    cin >> H >> W;

    string chars = "";
    for(int i = 0; i < H; i++) {
      cin >> S[i];
      chars += S[i];
    }
    sort(chars.begin(), chars.end());
    chars.erase(unique(chars.begin(), chars.end()), chars.end());
    vector< int > x1(chars.size(), W), x2(chars.size(), 0);
    vector< int > y1(chars.size(), H), y2(chars.size(), 0);
    for(int i = 0; i < H; i++) {
      for(int j = 0; j < W; j++) {
        int pos = chars.find(S[i][j]);
        chmin(x1[pos], j);
        chmax(x2[pos], j);
        chmin(y1[pos], i);
        chmax(y2[pos], i);
      }
    }
    map< char, int > xx1, xx2, yy1, yy2;
    for(int i = 0; i < chars.size(); i++) {
      xx1[chars[i]] = x1[i];
      xx2[chars[i]] = x2[i];
      yy1[chars[i]] = y1[i];
      yy2[chars[i]] = y2[i];
    }

    bool Judge = false;

    do {
      Judge = true;
      for(int i = 0; i < chars.size(); i++) {
        for(int j = xx1[chars[i]]; j <= xx2[chars[i]]; j++) {
          for(int k = yy1[chars[i]]; k <= yy2[chars[i]]; k++) {
            if(used[j][k] == proc) continue;
            used[j][k] = proc;
            if(S[k][j] != chars[i]) {
              Judge = false;
              goto myon;
            }
          }
        }
      }
    myon: ;
      ++proc;
    } while(!Judge && next_permutation(chars.begin(), chars.end()));
    if(Judge) cout << "SAFE" << endl;
    else cout << "SUSPICIOUS" << endl;
  }
}

Measured memory_bytes: 1256
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
cnt = Counter(a)
p, q, r = cnt[1], cnt[2], cnt[3]

dp = [[[0.0] * (n + 1) for _ in range(n + 1)] for _ in range(n + 1)]

for k in range(r + 1):
    for j in range(r + q + 1):
        for i in range(n + 1):
            if not (0 < i + j + k <= n):
                continue
            tmp = 0.0
            if i > 0:
                tmp += dp[i - 1][j][k] * i
            if j > 0:
                tmp += dp[i + 1][j - 1][k] * j
            if k > 0:
                tmp += dp[i][j + 1][k - 1] * k
            tmp += n
            dp[i][j][k] = tmp / (i + j + k)

print(dp[p][q][r])


Measured memory_bytes: 254088
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const double pi = acos(-1.0);
template <class A>ostream& operator<<(ostream& o, const vector<A>& p) { o << "{"; for (int i = 0; i < (int)p.size(); ++i)o << (i > 0 ? ", " : "") << p[i]; o << "}"; return o; }
template <class A, class B>ostream& operator<<(ostream& o, const pair<A, B>& p) { o << "{" << p.first << ", " << p.second << "}"; return o; }
template <class A, class B>ostream& operator<<(ostream& o, const map<A, B>& p) { o << "{"; for (auto it = p.begin(); it != p.end(); ++it) o << (it != p.begin() ? ", " : "") << *it; o << "}"; return o; }
template <class A>ostream& operator<<(ostream& o, const set<A>& p) { o << "{"; for (auto it = p.begin(); it != p.end(); ++it) o << (it != p.begin() ? ", " : "") << *it; o << "}"; return o; }
void print() { cerr << endl; }
template <class H> void print(H&& h) { cerr << h << endl; }
template <class H, class... T> void print(H&& h, T&& ... t) { cerr << h << " "; print(forward<T>(t)...); }

int main() {
	int n, a, b; cin >> n >> a >> b;
	VI t(n); rep(i, n)cin >> t[i];
	int ans = 0;
	rep(i, n)ans += t[i] < a || b <= t[i];
	Cout(ans);
}

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

int main(){
    int K,A,B;
    cin >> A;
    if(A%10 == 3){
        cout << "bon" << endl;
    }else if(A%10 == 0 || A%10 == 1 || A%10 == 6 || A%10 == 8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
typedef long long ll;


int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));

    for(int i = 0; i < n - 1; i++){
        a[i + 1] = gcd(a[i], a[i + 1]);
    }
    cout << a[n - 1] << endl;
}



Measured memory_bytes: 1024
//Let's play :)
#include<bits/stdc++.h>
using namespace std;

#define tarzan ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long 

int rr[] = {0, 1, 1, 1, 0, -1, -1, -1};
int cc[] = {1, 1, 0, -1, -1, -1, 0, 1};

const int mod = 1e9 + 7;
const int N = 300050;

signed main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	tarzan;
	int test = 1;
	//cin >> test;
	while(test--) {
		int x, y, a, b, c;
		cin >> x >> y >> a >> b >> c;
		vector<int> red(a), green(b), invis(c);
		for(int i = 0; i < a; i++) {
			cin >> red[i];
		}
		for(int i = 0; i < b; i++) {
			cin >> green[i];
		}
		for(int i = 0; i < c; i++) {
			cin >> invis[i];
		}

		sort(red.begin(), red.end());
		sort(green.begin(), green.end());
		sort(invis.begin(), invis.end());
		int ans = 0, cnt = 0;
		for(int i = 0; i < x; i++) {
			invis.push_back(red.back());
			red.pop_back();
		}
		for(int i = 0; i < y; i++) {
			invis.push_back(green.back());
			green.pop_back();
		}
		sort(invis.begin(), invis.end());
		for(int i = 0; i < x + y; i++) {
			ans += invis.back();
			invis.pop_back();
		}
		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 6512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

vector<int>e[1000];
bool used[1000];
bool ans;

void dfs(int k,int s){
used[k]=true;
f(i,e[k].size()){
if(e[k][i]==s)ans=true;
if(!used[e[k][i]])dfs(e[k][i],s);
}
return;
}

int main(void){
int n;
scanf("%d",&n);
int x,y;
char z[10];
f(i,n){
scanf("%d",&x);
scanf("%s",z);
scanf("%d",&y);
y+=200;
if(z[0]=='l'){
e[y].push_back(x);
}
else e[x].push_back(y);

}
ans=false;
f(i,1000){
f(j,1000)used[j]=false;
dfs(i,i);
}
if(ans)printf("1\n");
else printf("0\n");


return 0;
}


Measured memory_bytes: 2732
#include<stdio.h>

int N=100;
int min(int x,int y){
  if(x<=y) return x;
  else return y;
}

int main(){
  int n,p[N+1],m[N+1][N+1],i,j,k,l;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&p[i-1]);
    scanf("%d",&p[i]);
  }

  for(i=1;i<=n;i++) m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=99999999;
      for(k=i;k<=j-1;k++){ m[i][j]= min(m[i][j] , m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);}
    }
  }
  printf("%d\n",m[1][n]);

  return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int A,B;
    cin >> A >> B;
    int now = 1;
    int res = 0;
    while(now<B){
        now+=A-1;
        res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
count = 0
flag = 0
i = 0
while(i<len(a)-1):
	if b[i]<a[i]+a[i+1]:
		count = count+b[i]
		if a[i]<b[i]:
			a[i+1] = a[i]+a[i+1]-b[i]
		flag = 0
		i += 1

	else:
		if flag == 0:
			count = count+a[i]+a[i+1]
			a[i+1] = 0
			flag = 1
			i = i + 1

		else:
			count = count + a[i+1]
			a[i+1] = 0
			i = i + 1

print(count)


Measured memory_bytes: 82020
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;

int main(){
    string s,t; cin>>s>>t;
    vb used(s.size(),false);
    for(int i = 0; i < t.size(); i++){
        if(!used[i]){
            for(int j = 0; j < t.size(); j++){
                if(s[j]==s[i] && t[j]==t[i]) used[j]=true;
                if(s[j]==s[i] && t[j]!=t[i] || s[j]!=s[i] && t[j]==t[i]){
                    cout<<"No";
                    return 0;
                }
            }
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 776
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]

ans=0
ab.sort()
m=bin(k)
# print(m)
klst=[m]
for i in range(2,len(m)):
    if m[i]=="1":
        klst.append(m[:i]+"0"+"1"*(len(m)-i-1))
for i in range(len(klst)):
    klst[i]=int(klst[i],0)
# print(klst)
for i in klst:
    tmp=0
    for j in range(n):
        a,b=ab[j]
        if a|i==i:
            tmp+=b
    ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 84776
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ors;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

void solve(ll tt) {
    string s,t;
    cin>>s>>t;
    ll mx=1001;
    repf(i,0,s.length()) {
        if(i+t.length()-1>=s.length()) break;
        ll c=0;
        repf(j,0,t.length()) {
            if(t[j]==s[i+j]) c++;
        }
        mx=min(mx,(ll)(t.length())-c);
    }
    cout<<mx<<endl;
} 

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    repf(tt,1,t+1) {
        solve(tt);
    }
}     

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

#define ll long long
#define ld long long

int main() {
    int N; cin >> N;
    vector<string> S(N);
    set<string> s;
    for (int i = 0; i < N; i++) {
        cin >> S.at(i);
        s.insert(S.at(i));
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 25124
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right
from heapq import heappush, heappop

import re
# import numpy as np
# from scipy.misc import comb

# 再帰がやばいとき
import sys
sys.setrecursionlimit(10**9)

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e30)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def c(seq):
    ans = 0
    for i in range(0, len(seq)):
        for j in range(i, len(seq)):
            if seq[i] > seq[j]:
                ans += 1
    return ans

def main():
    N, K = l_inpl()
    A = l_inpl()
    a = c(A)
    b = c(A*2)
    print((a*K+(b-2*a)*K*(K-1)//2)%MOD)

if __name__ == "__main__":
    main()


Measured memory_bytes: 41196
#include<bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define dec(i, l, r) for (int i = l; i>=r;i--)
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define pb(c) push_back(c)
#define vii vector<pair<int,int>>
#define ii pair<int,int>
#define mp(i, j) make_pair(i,j)
#define ull unsigned long long int
#define ll  long long int
#define pie 3.141592653589793238
#define inf ((ll)1e18)
#define eps 1e-14
#define mod ((int)1e9+7)
#define maxlg 18
#define maxn 1000002
#define left(i) ((i)<<1)
#define right(i) (((i)<<1)+1)
ll c[maxn],x[maxn];
int arr[maxn];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
 #endif
    int n,m;
    cin>>n>>m;
    rep (i,0,n)cin>>arr[i];
    rep (i,0,n-1) {
        int s=arr[i],t=arr[i+1];

        if (s<=t) {
            c[1] += (t-s);
            c[s+1]+=-(t-s);
            c[s+1] += t+1;
            c[t+1]-=(t+1);
            c[t+1] +=(t-s);

            x[s+1]+=1;
            x[t+1]+=-1;
        } else {
            c[t+1]+=(t+m-s );
            c[s+1]-=(t+m-s );
            c[1]+=(t+1);
            c[t+1]-=(t+1);
            c[s+1]+=(t+1+m);

            x[1]+=1;
            x[t+1]+=-1;
            x[s+1]+=1;
        }
    }

    ll ans = inf;
    rep (i,2,m+1) {
        c[i] += c[i-1];
        x[i] += x[i-1];
    }
    rep (i,1,m+1) {
        ll temp = c[i] - i*x[i];
        ans = min(temp,ans);
    }

    cout<<ans;

    return 0;
}

Measured memory_bytes: 8832
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

#define nl '\n'

int n;

using namespace std;

int main(){
    cin >> n;

    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if(i*j==n){
                cout << "Yes";
                return 0;
            }
        }
    }

    cout << "No";


}

//g++ -std=c++14 comp.cpp -o b; ./b.exe


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

int main(){
	int n;
	cin>>n;
	int t[100010],x[100010],y[100010];
	for(int i=1;i<=n;++i){
		cin>>t[i]>>x[i]>>y[i];
	}

	t[0] = 0,x[0] = 0,y[0] = 0;
	int td,xd,yd,xy;
	bool pos = true;
	for(int i=1;i<=n;++i){
		td = t[i] - t[i-1];//かかる時間
		xd = fabs(x[i] - x[i-1]);
		yd = fabs(y[i] - y[i-1]);
		xy = xd + yd;//移動距離
		if(td < xy) pos = false;
		if(td % 2 != xy % 2) pos = false;
	}

	if(pos) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 1408
# encoding:utf-8
from collections import deque

def main():
	n = int(input())
	nums = [int(input()) for _ in range(n)]
	nums.sort()
	nums = deque(nums)

	v1 = nums.popleft()
	v2 = nums.pop()
	ans = v2 - v1
	#print(v1, v2)
	
	while len(nums) > 0:
		w1 = abs(nums[-1] - v1)
		w2 = abs(nums[-1] - v2)
		w3 = abs(nums[0] - v1)
		w4 = abs(nums[0] - v2)
		max_w = max(w1, w2, w3, w4)
		
		if w1 == max_w:
			ans += w1
			v1 = nums.pop()
		elif w2 == max_w:
			ans += w2
			v2 = nums.pop()
		elif w3 == max_w:
			ans += w3
			v1 = nums.popleft()
		else:
			ans += w4
			v2 = nums.popleft()
		#print(v1, v2)
	print(ans)

	


if __name__ == '__main__':
	main()


Measured memory_bytes: 8232
#include <iostream>
#include <cstdio>
#include <vector>
#include <memory>

using namespace std;

struct Node {
  int key;
  Node* parent;
  Node* left;
  Node* right;
  
  Node(int key = -1) : key(key), parent(nullptr), left(nullptr), right(nullptr) {};
};

static vector<Node> tree;

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

  tree.resize(h + 1);

  int k;
  for (int i = 1; i < tree.size(); i++) {
    cin >> k;
    tree[i].key = k;
  }

  int parent, left, right;
  for (int i = 1; i < tree.size(); i++) {
    parent = i / 2;
    if (parent != 0) {
      tree[i].parent = &tree[parent];
    }
    left = 2 * i;
    if (left < tree.size()) {
      tree[i].left = &tree[left];
    }
    right = 2 * i + 1;
    if (right < tree.size()) {
      tree[i].right = &tree[right];    
    }
  }

  for (int i = 1; i < tree.size(); i++) {
    auto& node = tree[i];
    printf("node %d: key = %d, ", i, node.key);
    if (node.parent) {
      printf("parent key = %d, ", node.parent->key);
    }
    if (node.left) {
      printf("left key = %d, ", node.left->key);
    }
    if (node.right) {
      printf("right key = %d, ", node.right->key);
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  string S;
  cin >> S;
  cout << S.substr(0, S.size()-8) << newl;
  return 0;
}

Measured memory_bytes: 256