akhauriyash/Code-Regression huggingface dataset:
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, k, c = 1, m = 0, x = 1;
    string s;
    cin >> n >> k >> s;
    vector<ll> v;
    for (ll i = 1; i < s.size(); i++)
        if (s[i] == s[i - 1])
            c++;
        else
            m += c - 1, c = 1, x++;
    m += c - 1;
    while (x > 1 && k)
        if (x > 2)
            m += 2, k--, x -= 2;
        else
            m++, k--, x = 1;
    cout << m;
    return 0;
}

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

int main(){
    int H,W;
    cin>>H>>W;
    
    while(H!=0&&W!=0){
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(i==0 || i==(H-1) || j==0 || j==W-1) cout<<"#"<<flush;
                else cout<<"."<<flush;
            }
            cout<<endl;
        }
        cout<<endl;
        cin>>H>>W;
    }
    
}


Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  ll H;
  cin >> H;
  ll W;
  cin >> W;
  vector<vector<string>> S(H, vector<string>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> S[i][j];
      if (S[i][j]=="snuke") {
        cout << char('A'+j) << i+1 << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = []
B = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)

d = {}
for i in range(N):
    if A[i] in d:
        d[A[i]] = d[A[i]] + B[i]
    else:
        d[A[i]] = B[i]

list = sorted(d.items(), key=lambda x:x[0])

for a, b in list:
    if M - b <= 0:
        print(a)
        break
    M -= b


Measured memory_bytes: 19852
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int w,n,tre[1001][2],dp[1001][1001] = {0},x;
  for(int c = 1; cin >>w,w; c++){
    cin >>n;
    for(int i=1; i<=n; i++){
      scanf("%d,%d",&tre[i][0],&tre[i][1]);
    }
    for(int i=1; i<=n; i++){
      for(int j=1; j<=w; j++){
	dp[i][j] = dp[i-1][j];
	if(j>=tre[i][1]){dp[i][j] = max(dp[i][j],dp[i-1][j-tre[i][1]]+tre[i][0]);}
      }
    }
    for(int j=0; j<=w; j++){
      if(dp[n][j] == dp[n][w]){x = j;break;}
    }
    cout <<"Case "<<c<<":"<<endl<<dp[n][w]<<endl<<x<<endl;
  }
  return 0;
}

Measured memory_bytes: 5172
N=int(input())
ls2=[]
for i in range(N):
    A,B=map(int,input().split())
    ls1=[A,B]
    ls2.append(ls1)
ls2.sort(key=lambda x:x[1])
t=0
for i in range(N):
    t=t+ls2[i][0]
    if t>ls2[i][1]:
        print('No')
        break
    elif i==N-1:
        print('Yes')

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)
#define YES(b) cout << ((b) ? "YES" : "NO") << endl
#define Yes(b) cout << ((b) ? "Yes" : "No") << endl
#define DOUBLE(d) cout << fixed << setprecision(15) << (d) << endl

const int MAX = 55;

int N, D[MAX];

int solve() {
    vi cnt(13);
    cnt[0] = 2; cnt[12] = 1;
    REP (i, N) cnt[D[i]]++;
    REP (d, 13) if (cnt[d] > 2) return 0;

    vi dec, undec;
    dec.push_back(0);
    if (cnt[12] == 2) dec.push_back(12);
    FOR (d, 1, 12) {
        if (cnt[d] == 2) {
            dec.push_back(d);
            dec.push_back(24-d);
        } else if (cnt[d] == 1) {
            undec.push_back(d);
        }
    }

    int ret = 0;
    REP (state, 1<<undec.size()) {
        int tmp = 100;
        vi ds;
        FORE (d, dec) ds.push_back(d);
        REP (i, undec.size()) {
            if ((state >> i)&1) ds.push_back(undec[i]);
            else ds.push_back(24-undec[i]);
        }
        sort(ALL(ds));
        REP (i, N+1) {
            int diff = abs(ds[i] - ds[(i+1)%(N+1)]);
            CHMIN(tmp, min(diff, 24-diff));
        }
        CHMAX(ret, tmp);
    }
    return ret;
}

int main() {
    cin >> N;
    REP (i, N) cin >> D[i];
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N){
    for(ll i=N; i<= 999; i++){
        string s = to_string(i);
        if(s[0]==s[1]&&s[1]==s[2]){
            cout << s << endl;
            return;
        }
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
	"strings"
)

func main() {
	a, b := SInt64(), SInt64()
	var max int64
	max = Gcd(a, b)

	lis := PrimeFactors(max)
	re := map[int64]int64{}
	for _, item := range lis {
		re[item] = item
	}

	fmt.Println(len(re) + 1)
}

func Gcd(a, b int64) int64 {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func SInt64() int64 {
	var n int64
	fmt.Scan(&n)
	return n
}

func DInt() (int, int) {
	var n int
	fmt.Scan(&n)

	var m int
	fmt.Scan(&m)
	return n, m
}

func SStr() string {
	var s string
	fmt.Scan(&s)
	return s
}

// func SIntSlice(n int) []int {
// 	re := make([]int, 0, n)
// 	for i := 0; i < n; i++ {
// 		re = append(re, SInt())
// 	}
// 	return re
// }

func StrSlice() []string {
	var s string
	fmt.Scan(&s)
	return strings.Split(s, "")
}

func Min(nums ...int) int {
	if len(nums) == 0 {
		panic("function min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func Max(nums ...int) int {
	if len(nums) == 0 {
		panic("function max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

type Int64Slice []int64

func (p Int64Slice) Len() int           { return len(p) }
func (p Int64Slice) Less(i, j int) bool { return p[i] < p[j] }
func (p Int64Slice) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

type IntSlice []int

func (p IntSlice) Len() int           { return len(p) }
func (p IntSlice) Less(i, j int) bool { return p[i] < p[j] }
func (p IntSlice) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

// An IntHeap is a min-heap of ints.
type IntHeap []int

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func PrimeFactors(n int64) (pfs []int64) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := int64(3); i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
//repマクロ定義
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
//allマクロ定義
#define all(v) v.begin(),v.end()
using namespace std;

int main(){
  int D;
  cin >> D;
  switch (D) {
    case 25: puts("Christmas"); break;
    case 24: puts("Christmas Eve"); break;
    case 23: puts("Christmas Eve Eve"); break;
    case 22: puts("Christmas Eve Eve Eve"); break;
   }
}

Measured memory_bytes: 256
main = do
  [q,h,s,d] <- map read.words<$>getLine
  n <- readLn
  print $ solve q h s d n

solve q h s d n
  | d < one*2 = d * (n`div`2) + one * (n`mod`2)
  | otherwise = one * n
  where one = minimum [s,h*2,q*4]

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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Yes or No
void yesno(bool ok, string yes = "Yes", string no = "No") {
  cout << (ok ? yes : no) << endl;
}

// Paste snippets here!!

//

void solve(long long N) {
  if(N%2) cout << 2*N << endl;
  else cout << N << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long N;
  std::cin >> N;
  solve(N);
  return 0;
}


Measured memory_bytes: 3600
N, C = map(int, input().split())
d = []
c = []
t = [[0]*C, [0]*C, [0]*C]
for _ in range(C):
  d.append(list(map(int, input().split())))
for _ in range(N):
  c.append(list(map(int, input().split())))

for i in range(N):
  for j in range(N):
    t[(i+j)%3][c[i][j]-1] += 1

ans=1000*N*N

for i in range(C):
  for j in range(C):
    if i!=j:
      for k in range(C):
        if i!=k and j!=k:
          tt=0
          for l in range(C):
            tt += d[l][i]*t[0][l] + d[l][j]*t[1][l]+d[l][k]*t[2][l]
          ans = min(ans, tt)
print(ans)

Measured memory_bytes: 5492
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a,b,c,d;
	int d1,d2,d3;
	cin>>a>>b>>c>>d;
	d1=abs(a-b);
	d2=abs(b-c);
	d3=abs(a-c);
	if(d1<=d&&d2<=d) cout<<"Yes";
	else if(d3<=d) cout<<"Yes";
	else cout<<"No";
 } 

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int xit = 0;
  // for (double x = 0; x < 10; x += 0.01) {
  //   ll xi = (x + 0.001) * 100;
  //   if (xit != xi) {
  //     cerr << x << " ";
  //     cerr << xi << " ";
  //     cerr << xit << endl;
  //   }
  //   xit++;
  // }
  ll a, b;
  double bd;
  cin >> a >> bd;
  b = (bd + 0.001) * 100;
  a *= b;
  a /= 100;
  cout << a << endl;
}

Measured memory_bytes: 3736
import java.util.Comparator;
import java.util.Iterator;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        TreeMap<String, TreeMap<Integer, Integer>> restaurants = new TreeMap<>();

        int N = sc.nextInt();
        for (int i = 0; i < N; i++) {
            String city = sc.next();
            TreeMap<Integer, Integer> restaurantsInCity = restaurants.get(city);
            if (restaurantsInCity == null) {
                restaurantsInCity = new TreeMap<>(new Comparator<Integer>() {
                    public int compare (Integer m, Integer n) {
                        return m.compareTo(n) * -1;
                    }
                });
            }

            restaurantsInCity.put(sc.nextInt(), i + 1);
            restaurants.put(city, restaurantsInCity);
        }

        Iterator<String> itr = restaurants.keySet().iterator();
        while (itr.hasNext()) {
            TreeMap<Integer, Integer> resutaurantsInCity = restaurants.get(itr.next());
            Iterator<Integer> index = resutaurantsInCity.values().iterator();
            while (index.hasNext()) {
                System.out.println(index.next());
            }
        }
    }
}


Measured memory_bytes: 20816
# -*- coding: utf-8 -*-
# D - Lunlun Number
# 標準入力の取得
K = int(input())

# 求解
def get_lunlun_number_list(ln_list:list) -> list:
    lunlun_number_list = []
    for ln in ln_list:
        one_place_value = ln % 10
        lunlun_number_list.append(int(str(ln) + str(one_place_value)))
        if one_place_value != 0:
            lunlun_number_list.append(int(str(ln) + str(one_place_value-1)))
        if one_place_value != 9:
            lunlun_number_list.append(int(str(ln) + str(one_place_value+1)))

    return lunlun_number_list

lunlun_number_list = []

lunlun_number_list1 = list(range(1, 10))
lunlun_number_list.extend(lunlun_number_list1)
lunlun_number_list2 = get_lunlun_number_list(lunlun_number_list1)
lunlun_number_list.extend(lunlun_number_list2)
lunlun_number_list3 = get_lunlun_number_list(lunlun_number_list2)
lunlun_number_list.extend(lunlun_number_list3)
lunlun_number_list4 = get_lunlun_number_list(lunlun_number_list3)
lunlun_number_list.extend(lunlun_number_list4)
lunlun_number_list5 = get_lunlun_number_list(lunlun_number_list4)
lunlun_number_list.extend(lunlun_number_list5)
lunlun_number_list6 = get_lunlun_number_list(lunlun_number_list5)
lunlun_number_list.extend(lunlun_number_list6)
lunlun_number_list7 = get_lunlun_number_list(lunlun_number_list6)
lunlun_number_list.extend(lunlun_number_list7)
lunlun_number_list8 = get_lunlun_number_list(lunlun_number_list7)
lunlun_number_list.extend(lunlun_number_list8)
lunlun_number_list9 = get_lunlun_number_list(lunlun_number_list8)
lunlun_number_list.extend(lunlun_number_list9)
lunlun_number_list10 = get_lunlun_number_list(lunlun_number_list9)
lunlun_number_list.extend(lunlun_number_list10)

lunlun_number_list = sorted(lunlun_number_list)

# 結果出力
print(lunlun_number_list[K-1])

Measured memory_bytes: 14168
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

lli size[60]={0};
lli dp[60]={0};

lli calc(lli level,lli num){
	if(DEBUG)cout<<"level = "<<level<<" num="<<num<<endl;
	lli center = size[level]/2 + 1;
	if(level == 0)return 1;
	if(num == 1) return 0;
	else if(num < center)return calc(level-1,num-1);
	else if(num == center)return dp[level-1] + 1;
	else if(num == size[level])return dp[level];
	else return dp[level-1] + calc(level-1,num-center) + 1;
}

void init(){
	size[0]=1;
	dp[0]=1;
	for(lli i=1;i<60;i++){
		size[i] = 2*size[i-1]+3;
		dp[i] = 2*dp[i-1]+1;
		if(DEBUG)cout<<"i="<<i<<" size[i]="<<size[i]<<endl;
		if(DEBUG)cout<<"i="<<i<<" dp[i]="<<dp[i]<<endl;
	}
}

signed main(){

	lli n;
	lli x;
	cin>>n>>x;

	init();
	cout<<calc(n,x)<<endl;

	return 0;
}

Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
m=10000
h=list(map(int,input().split()))
for i in range(n):
  x=t-h[i]*0.006
  m=min(m,abs(x-a))

for i in range(n):
  if m==abs((t-h[i]*0.006)-a):
    print(1+i)

Measured memory_bytes: 9168
#include<iostream>
#include<algorithm>
#include<map>

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> T;




int main(){
    T m = T(1868, P(9, 8));
    T t = T(1912, P(7, 30));
    T s = T(1926, P(12, 25));
    T h = T(1989, P(1, 8));
    int a, b, c;
    while(cin >> a >> b >> c){
	T tmp = T(a, P(b, c));
	string res = "heisei";
	int rem = tmp.first - h.first + 1;
	if(tmp < m){
	    res = "pre-meiji";
	    cout << res << endl;
	    continue;
	}
	else if(tmp < t){
	    res = "meiji";
	    rem = tmp.first - m.first + 1;
	}
	else if(tmp < s){
	    res = "taisho";
	    rem = tmp.first - t.first + 1;
	}
	else if(tmp < h){
	    res = "showa";
	    rem = tmp.first - s.first + 1;
	}
	cout << res << " " << rem << " " <<b <<" "<<c<<endl;
    }
    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define loop(i ,a,b) for(int i = a;i<b;i++)
#define rloop(i,a,b) for(int i = a ; i>b;i--)
#define loopll(i,a,b) for( long long int i = a; i<b;i++)
#define rloopll(i,a,b) for(long long int i = a; i>b;i--)
#define eb emplace_back
#define pii pair<int ,int>
#define pll pair<ll ,ll>
#define mk make_pair
#define intmin INT_MIN
#define intmax INT_MAX
#define cout(x) cout<<x<<" ";
using namespace std;
void vec(vector<int> & v){

    for(int i = 0;i<v.size() ; i++){
        cout<<v[i]<< " ";
    }
    cout<<endl;
}
void vec_ll(vector<long long int> & v){

    for(int i = 0;i<v.size() ; i++){
        cout<<v[i]<< " ";
    }
    cout<<endl;
}
int parsestring(string temp){
    int num= 0;
    int digs = temp.size() - 1;
    for(int i = 0 ;i<=digs;i++){
        num += pow(10 , digs -i)*(temp[i] - '0');
    }
    return num;
}

int main(){
    ll n,d;
    cin>>n>>d;
    ll c = 0;
    for(ll i = 0;i<n;i++){
        ll x ,y;
        cin>>x>>y;
        ll temp = (x*x) + (y*y);
        if(temp <= d*d){c++;}
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
const double eps = 1e-9;

double pw2[12] = {128, 64, 32, 16, 8, 4, 2, 1, 0.5, 0.25, 0.125, 0.0625};

string to_bit(double n) {
    string s = "";
    for (int i=0; i<12; ++i) {
        double d = pw2[i];
        if (d < n + eps) {
            n -= d;
            s += "1";
        } else {
            s += "0";
        }
        if (d == 1) s += ".";
    }
    return s;
}

int main() {
    double n;
    while (cin >> n, 0 <= n) {
        if (abs(n*16 - round(n*16)) < eps && n < 256 + eps) {
            cout << to_bit(n) << endl;
        } else {
            cout << "NA" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1244
from fractions import gcd
from functools import reduce

N, X = tuple(int(i) for i in input().split())
x = [int(i) for i in input().split()]

x.append(X)
sx = sorted(x)
dx = [j - i for i, j in zip(sx[:-1], sx[1:])]

mdx = reduce(gcd, dx)

print(mdx)

Measured memory_bytes: 16268
#include <bits/stdc++.h>
using namespace std;
bool fnc(int a){
  int temp = a, sum = 0;
  for(; a > 0; a /= 10) sum = (sum * 10) + (a % 10);
  if(temp == sum) return 1;
  return 0;
}
int main(){
  int a, b, co = 0;
  cin >> a >> b;
  for(int i = a; i < b + 1; i++) if(fnc(i)) co++;
  cout << co << endl;
  return 0;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//template end

typedef pair<int,int> P;
vector<int> g[55];
map<P,int> enco;
int u[21],v[21];
bool cur[55];
bitset<55> used[21]={};
bool dfs(int v,int p,int to){
   if(v==to)return true;
   for(int nxt:g[v])if(nxt!=p){
      cur[enco[P{v,nxt}]]=1;
      if(dfs(nxt,v,to))return true;
      else cur[enco[P{v,nxt}]]=0;
   }
   return false;
}

int main(){
   int n; scanf("%d",&n);
   rep(i,0,n-1){
      int a,b; scanf("%d%d",&a,&b); a--; b--;
      g[a].push_back(b); g[b].push_back(a);
      enco[{a,b}]=enco[{b,a}]=i;
   }
   int m; scanf("%d",&m);
   rep(i,0,m){
      scanf("%d%d",&u[i],&v[i]),u[i]--,v[i]--;
      rep(j,0,n-1)cur[j]=0;
      dfs(u[i],-1,v[i]);
      rep(j,0,n-1)if(cur[j])used[i][j]=1;
   }
   int mm=1<<m; ll res=1LL<<(n-1);
   rep(mask,1,mm){
      int cnt=__builtin_popcount(mask);
      bitset<55> now=0;
      rep(i,0,m)if(mask>>i&1)now|=used[i];
      int sub=n-1-now.count();
      if(cnt&1)res-=1LL<<sub; else res+=1LL<<sub;
   }
   printf("%lld\n",res);
   return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int n;
	cin >> n;
	vector<int> a(n);
	if(n == 0) break;
	REP(i,n) cin >> a[i];
	int num;
	cin >> num;
	int l,m,h,ans;
	h = n-1;
	l = 0;
	m = (h+l)/2;
	ans = 0;
	while(l <= h){
	    if(a[m] > num){
		h = m - 1;
	    }else if (a[m] < num){
		l = m + 1;
	    }else{
		ans++;
		break;
	    }
	    m = (h+l)/2;
	    ans++;
	}
	cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <string>
#include <queue>
using namespace std;
typedef pair<string, string> P;

int main(int argc, char *argv[])
{
  int n;
  cin >> n;
  if(n%2==0){
    cout << n << endl;
  }else{
    cout << n*2 << endl;
  }
  return 0;
}


Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = System.Console.ReadLine().Trim();
            int iS = int.Parse(sS);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iC = 1;
            while (true)
            {
                if (iS == 1) { break; }
                iC += 1; 
                if (iS % 2 == 0) { iS /= 2; }
                else { iS = iS * 3 + 1; }
            }
            if (iC == 1 || iC == 2) { iC = 4; }
            else { iC += 1; }

            // 出力
            System.Console.WriteLine("{0}", iC.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


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

using namespace std;

const int N = 500;

class P{
public:
  string name;
  int wd, st;
  P(){}
  P(string name, int wd, int st) : name(name), wd(wd), st(st) {}
  bool operator < (const P& s) const {
    if(wd == s.wd) return st < s.st;
    return wd < s.wd;
  }
};

int n, m;
vector<P> data;
vector<int> f;
bool used[N];

int solve(){
  fill(used, used+n, false);
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      if(!used[j]) continue;
      if(data[f[i]].wd != data[j].wd) continue;
      if(data[f[i]].st <= data[j].st && data[j].st < data[f[i]].st + 30 ||
        data[j].st <= data[f[i]].st && data[f[i]].st < data[j].st + 30) return -1;
    }
    used[f[i]] = true;
  }
  int res = m;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(!used[j]) continue;
      if(data[i].wd != data[j].wd) continue;
      if(data[i].st <= data[j].st && data[j].st < data[i].st + 30 ||
        data[j].st <= data[i].st && data[i].st < data[j].st + 30) goto FAILED;
    }
    res++;
    used[i] = true;
    FAILED:;
  }
  return res;
}

main(){
  while(cin >> n && n){
    data.clear();
    f.clear();
    for(int i=0;i<n;i++){
      string name, time;
      int wd, st;
      cin >> name >> wd >> time;
      st = atoi(time.substr(0, (int)time.size()-2).c_str()) * 60 + atoi(time.substr((int)time.size()-2).c_str());
      data.push_back(P(name, wd, st));
    }
    sort(data.begin(), data.end());
    cin >> m;
    for(int i=0;i<m;i++){
      string in;
      cin >> in;
      for(int j=0;j<n;j++) if(data[j].name == in) f.push_back(j);
    }
    cout << solve() << endl;
  }
}

Measured memory_bytes: 1292
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int h = sc.nextInt();
		int w = sc.nextInt();
		String[] a = new String[h];

		for (int i = 0; i < h; i++) {
			a[i] = sc.next();
		}

		for (int i = 0; i < w + 2; i++) {
			System.out.print("#");
		}
		System.out.print("\n");

		for (int i = 0; i < h; i++) {
			System.out.println("#" + a[i] + "#");
		}

		for (int i = 0; i < w + 2; i++) {
			System.out.print("#");
		}

	}
}

Measured memory_bytes: 22612
// author : ayush_nishad
// Road to Expert since : 30 Aug 2020
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define all(x)  x.begin(),x.end()
#define w(x) int x;cin>>x; while(x-->0)
#define memset(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
/*
think fast
think simple
*/
void mysol()
{
	int n;cin>>n;
	cout<<(!n);
}

int32_t main()
{
    fast();
    // w(t)
    {
        mysol();
    }
    //cerr << sizeof(dp)*(1e-6) << " megabytes\n";
    return 0;
}


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

int N;
string S;
int leader[300005];

int main() {
  cin >> N >> S;
  int Es=0;
  for(int i=0; i<N; i++) {
    if(S[i] == 'E') {
      Es++;
    }
  }
  leader[0] += Es;
  for(int i=0; i<N; i++) {
    if(S[i] == 'E') leader[i+1] = leader[i] - 1;
    if(S[i] == 'W') leader[i+1] = leader[i] + 1;
  }
  for(int i=0; i<N; i++) {
    if(S[i+1] == 'E') {
      leader[i+1]--;
    }
  }
  /* rep(i, N) { */
  /*   cout << "i : " << i << " -> " << leader[i+1] << endl; */
  /* } */
  cout << *min_element(leader, leader+N+1) << endl;
  return 0;
}



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

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define FOR(i, a, b) for(int i = a;i < b;++i)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999

#define lint long long

vector<int> to[200005];
int ans[200005];

void dfs(int v, int p = -1){
  for(int u: to[v]){
    if(u == p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
}

int main()
{
  int a, b; cin >> a >> b;
  int count = 1;
  int count1 = 0; 
  REP(i,b){
    if(count >= b){
      break;
    }
    --count;
    count += a;
    ++count1;
  }
  cout << count1 << "\n";
  return 0;
}




Measured memory_bytes: 4992
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
void visit(int);
void dfs();
int n,M[N][N];
int color[N],d[N],f[N],tt;

int main(){
  int u,v,k;
  int i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
 dfs();

  return 0;
}

void visit(int u){
  int v;
  color[u] = GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(M[u][v] == 0)continue;
    if(color[v] == WHITE){
      visit(v);
    }
  }
  color[u]=BLACK;
  f[u]=++tt;
}

void dfs(){
  int u;
  
  for(u=0;u<n;u++)color[u]=WHITE;
  tt=0;

  for(u=0;u<n;u++)color[u]=WHITE;
  tt=0;
  
  for(u=0;u<n;u++){
    if(color[u]==WHITE)visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

Measured memory_bytes: 636
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	vector<int> a(5);
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	sort(a.rbegin(), a.rend());
	cout << a[0] << " " << a[1] << " " << a[2] << " " << a[3] << " " << a[4] << endl;
	return 0;
}

Measured memory_bytes: 1204
import Data.List
import Data.Array
import Data.Maybe
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8
 
getInts :: IO [Int]
getInts = (map parseInt . BS8.words) <$> BS.getLine 
    where parseInt = fst . fromJust . BS8.readInt
 
solve :: Int -> Int -> [Int] -> Int
solve n k ls = sum $ take (length v - k) v
    where v = sort $ change (sort ls)

change :: [Int] -> [Int]
change [] = []
change (x:xs) = go xs x 1
    where go [] n c = [c]
          go (x:xs) n c
            | n == x = go xs n (c+1)
            | otherwise = c : go xs x 1 
 
main :: IO ()
main = do
    [n, k] <- getInts
    ls <- getInts
    print (solve n k ls)


Measured memory_bytes: 32124
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;

signed main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    
   
    mes(max(max(a*c, a*d), max(b*c, b*d)));
}
    
    
    
    
    


Measured memory_bytes: 3640
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

pub fn bsearch<F>(ok: i64, ng: i64, pred: F) -> Option<i64>
where
    F: Fn(i64) -> bool,
{
    let orig_ok = ok;
    let mut ok = ok;
    let mut ng = ng;
    while (ok - ng).abs() > 1 {
        let mid = (ok + ng) / 2;
        if pred(mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    if ok == orig_ok {
        None
    } else {
        Some(ok)
    }
}

fn main() {
    input! {
        s: Chars,
        t: Chars
    };

    let s_len = s.len();
    let mut pos_table = HashMap::new();
    for (i, ch) in s.into_iter().enumerate() {
        pos_table.entry(ch).or_insert(Vec::new()).push(i as i64);
    }
    let keys = pos_table.keys().cloned().collect::<Vec<_>>();
    for k in keys {
        let v = pos_table.get_mut(&k).unwrap();
        for i in v.clone() {
            v.push(i + s_len as i64);
        }
    }
    let mut res = 0;
    let mut cur_pos = -1;
    for ch in t {
        let posv = match pos_table.get(&ch) {
            Some(v) => v,
            _ => {
                println!("-1");
                return;
            }
        };
        let i = bsearch(posv.len() as i64, -1, |x| {
            let p = posv[x as usize];
            cur_pos < p
        });
        if let Some(i) = i {
            let p = posv[i as usize];
            res += p - cur_pos;
            cur_pos = p % s_len as i64;
        } else {
            unreachable!();
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 5188
n=int(input())
x=list(map(int,input().split()))
a,b=x[0],sum(x)-x[0]
c=abs(a-b)
for i in range(1,n-1):
  a+=x[i]
  b-=x[i]
  c=min(c,abs(a-b))
print(c)  

Measured memory_bytes: 24828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

//cin.tie(0);ios::sync_with_stdio(false);
//cout<<fixed<<setprecision(20);



signed main(){
    ll r;cin>>r;
    cout<<r*r<<endl;
}


//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,output_format?

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

#define ll long long
const int MOD = 1e9 + 7;
#define INF 2e9

#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20)

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; }

ll n,x,t;
string s;
int main() {
    INIT();

    cin >> n >> x >> t;
    cout << (n / x + (n % x > 0 ? 1 : 0)) * t;
}


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

int main() {
  int A, B, C;
  string op;
  cin >> A >> op >> B;
  
  if (op == "+") {
	C = A + B;
  }
  if (op == "-") {
    C = A - B;
  }
  cout << C << endl;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 100010;
int X,K,Q;
int r[MC];
int t[MC] , a[MC];
int st[MC];
int amin,amax;
int ans[MC];

int main(){
	scanf("%d%d" , &X , &K);
	repp(i,1,K+1){
		scanf("%d" , r + i);
	}
	scanf("%d" , &Q);
	repp(i,0,Q){
		scanf("%d%d" , t + i , a + i);
		st[i] = i;
	}
	sort(st,st+Q,[&](const int p , const int q){return t[p] < t[q];});
	amin = 0;
	amax = X;
	int pt = 0;
	int sum = 0;
	repp(i,0,K){
		int z = (i%2?1:-1);
		while(pt < Q && t[st[pt]] < r[i+1]){
			a[st[pt]] = max(0,min(X,max(amin,min(amax,a[st[pt]]))+sum));
			ans[st[pt]] = max(0,min(X,a[st[pt]]+z*(t[st[pt]]-r[i])));
			++pt;
		}
		sum += z*(r[i+1]-r[i]);
		if(sum > X) sum = X;
		if(sum < -X) sum = -X;
		amin = max(amin,min(X,-sum));
		amax = min(amax,max(0,X-sum));
		if(amin > amax){
			if(sum > 0) amin = amax;
			else amax = amin;
		}
	}
	int z = (K%2?1:-1);
	while(pt < Q){
		a[st[pt]] = max(0,min(X,max(amin,min(amax,a[st[pt]]))+sum));
		ans[st[pt]] = max(0,min(X,a[st[pt]]+z*(t[st[pt]]-r[K])));
		++pt;
	}
	repp(i,0,Q){
		printf("%d\n" , ans[i]);
	}
	return 0;
}


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M=MI()
    A=[]
    B=[]
    
    for i in range(N):
        A.append(input())
        
    for i in range(M):
        B.append(input())
       
       
        
    def ch(a,b):
        for i in range(M):
            for j in range(M):
                if A[a+i][b+j]!=B[i][j]:
                    return False
        return True
    
     
    f=0
    for i in range(N-M+1):
        for j in range(N-M+1):
            if ch(i,j):
                f=1
                break
                
    if f==1:
        print("Yes")
    else:
        print("No")
            

main()


Measured memory_bytes: 42348
#include <iostream>
#include <algorithm>
#include <vector>

#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)

using namespace std;

vector<int> primes(int n) {
  vector<int> p(n+1, 1);
  for (int i = 2; i*i <= n; ++i)
    if (p[i])
      for (int j = i*i; j <= n; j += i)
        p[j] = 0;
  vector<int> res;
  for (int i = 2; i <= n; ++i)
    if (p[i])
      res.push_back(i);
  return res;
}

int main()
{
  auto pl = primes(109000);
  while(1){
    int n,p;
    cin>>n>>p;
    if(n==-1)break;
    auto itr=upper_bound(begin(pl),end(pl),n);
    vector<int> v;
    for(auto i=itr;i!=itr+p;++i){
      for(auto j=i;j!=itr+p;++j){
        v.push_back(*i+*j);
      }
    }
    sort(begin(v),end(v));
    cout<<v[p-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1528
#include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>
#include<bitset>
#define rep(a) for(int i = 0; i < a; i++)
using namespace std;

struct LB {
	int NumofSw;
	int sw = 0;
	bool isOnwhenOdd = 0;
};

int bitcount(int bits) {
		bits = (bits & 0x5555) + (bits >> 1 & 0x5555);
		bits = (bits & 0x3333) + (bits >> 2 & 0x3333);
		bits = (bits & 0x0f0f) + (bits >> 4 & 0x0f0f);
		bits = (bits & 0x00ff) + (bits >> 8 & 0x00ff);
		return bits;
}


int main()
{
	int N, M;
	cin >> N >> M;
	//N sw
	//M lamp

	vector<LB> LBs(M);

	int temp;
	rep(M)
	{
		cin >> LBs[i].NumofSw;
		LBs[i].sw = 0;
		for(int j = 0; j < LBs[i].NumofSw; j++)
		{
			cin >> temp;
			LBs[i].sw |= (1<<(temp-1));
		}
	}
	rep(M) { cin >> LBs[i].isOnwhenOdd; }

	int looptime = 1;
	for (int i = 0; i < N; i++) {
		looptime *= 2;
	}
	int count = 0;
	for (int i = 0; i < looptime; i++) {
		int tempcount = 0;
		for (int j = 0; j < M; j++) {
			if(bitcount(LBs[j].sw&i)%2 == LBs[j].isOnwhenOdd)tempcount++;
		}
		if (tempcount == M) count++;
	}
	cout << count << endl;
	return 0;
}

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

#define NMAX 200274

void eratos(vector<bool> &hurui){
    int i = 1;
    hurui[0] = false;
    hurui[1] = false;
    while(true){
        i++;
        while(!hurui[i]){
            i++;
        }
        if(i*i > NMAX){
            break;
        }

        for(int j=i+i; j<=NMAX; j+=i){
            hurui[j] = false;
        }
    }
    return;
}

int main(){
    int n, p;
    vector<bool> hurui(NMAX+1, true);
    eratos(hurui);

    while(true){
        cin >> n >> p;
        if(n == -1){
            break;
        }
        
        vector<int> vec(p), ans;
        int pos = n+1;
        for(int i=0; i<p; i++){
            while(!hurui[pos]){
                pos++;
            }
            vec[i] = pos++;
        }
        
        for(int i=0; i<p; i++){
            for(int j=i; j<p; j++){
                ans.push_back(vec[i] + vec[j]);
            }
        }
        sort(ans.begin(), ans.end());

        cout << ans[p-1] << endl;;
    }
  
    return 0;
}

Measured memory_bytes: 3192
import scala.io.StdIn._

object Main extends App {

  val Array(a,b) = readLine().split(" ").map(_.toInt)


  def solve(): Int = {
    for(i <- 1 to 10000)
      if(f(i, 0.08) == a && f(i, 0.1) == b) return i
    -1
  }

  def f(money: Int, tax: Double): Int =
    (money * tax).floor.toInt

  println(solve())

}



Measured memory_bytes: 54904
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

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

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;

signed main()
{
    int N, D;
    string X; cin >> N >> X >> D;

    string s = "";

    int cnt = 0;

    rep(i, X.size()) {
        if (X[i] == '0' && cnt < D) {
            s += '1';
            cnt++;
        } else {
            s += X[i];
        }
    }

    if (cnt == D) {
        cout << s << endl;
        return 0;
    }
    
    rrep(i, X.size()) {
        if (cnt == D) break;
        if (X[i] == '1') s[i] = '0', cnt++;
    }

    cout << s << endl;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
int a[3];string s;
int main(){
    cin>>s;
    for(int i=0;i<s.size();i++)a[s[i]-'a']++;
    (max({a[0],a[1],a[2]})-min({a[0],a[1],a[2]}))<=1?s="YES":s="NO";
    cout<<s<<endl;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(int argc, const char *argv[])
{
  int a, b, sum = 0;
  scanf("%d%d", &a,&b);
  sum += a > b ? a-- : b--;
  sum += a > b ? a-- : b--;
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << x2 - (y2 - y1) << " " << y2 - (x1 - x2) << " " << x1 - (y2 - y1) << " " << y1 - (x1 - x2) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________


	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x = b / c - (a - 1) / c;
	int y = b / d - (a - 1) / d;
	int e = (c * d) / __gcd(c, d);
	int z = b / e - (a - 1) / e;
	int ans = (b - a + 1) - (x + y - z);
	cout << ans << en;


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,x;
    cin >> n >> m >> x;
    
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> c(n);
    
    for(int i=0;i<n;i++) {
        cin >> c[i];
        for(int j=0;j<m;j++) cin >> a[i][j];
    }
    long long ans = 12345678;
    int all = 1<<n;
    
    for(int bit=0;bit<all;bit++){
        long long cost = 0;
        vector<int> level(m);
        for(int i=0;i<n;i++){
            if((bit>>i)&1){
                cost+=c[i];
                for(int j=0;j<m;j++){
                    level[j]+=a[i][j];
                }
            }
        }
        bool ok = true;
        for(int j=0;j<m;j++){
            if(level[j] < x) ok = false;
        }
        if(ok)ans=min(ans,cost);
    }
 
    if(ans==12345678)cout << -1;
    else cout << ans;
    
    return 0;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String[] str = sc.nextLine().split(" ");
        if(Integer.parseInt(str[0]) <= Integer.parseInt(str[1])){
            System.out.print("unsafe");
        }else{
            System.out.print("safe");
        }
    }
}


Measured memory_bytes: 35808