akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main()
{
	int m, d; cin >> m >> d;

	int res = 0;
	for (int i = 2; i < d/10; ++i) for (int j = 2; j <= 9; ++j)
	{
		if (i * j <= m) res++;
	}

	for (int j = 2; j <= d%10; ++j)
	{
		if (d/10 * j <= m) res++;
	}

	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main () {
  string S;
  cin >> S;
  int N = (int)S.size();
  if (N >= 4 && S[0] == 'Y' && S[1] == 'A' && S[2] == 'K' && S[3] == 'I') {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
// const ll MOD=998244353;

int main(){
  int N,K; cin>>N>>K;
  double ans=0;
  for(ll i=1;i<=N;i++){
    int ok=20;
    for(int j=0;j<=20;j++){
      if(i*(1<<j)>=K){
        ok=j;
        break;
      }
    }
    ans+=1.0/(1<<ok);
  }
  cout<<setprecision(20);
  cout<<ans/N<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 999999999
typedef long long ll;
using namespace std;
int main() {
    int N;
    cin >> N;
    string N_str = to_string(N);
    string N_str_ori = N_str;
    reverse(N_str.begin(), N_str.end());
    if(N_str_ori == N_str) puts("Yes");
    else puts("No");
    
}

Measured memory_bytes: 256
import math
A, B = list(map(int, input().split()))

x = [int(A // 0.08), int(B // 0.1), math.ceil((A+1) // 0.08), int(math.ceil((B+1) // 0.1))]
for i in range(min(x), max(x)+1, 1):
    if int(i * 0.08)  ==  A and B ==  int(i* 0.1):
        print(i)
        break
    if i == max(x):
        print(-1)

Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

vector< int64_t > divisor(int64_t n) {
		vector< int64_t > ret;
		for(int64_t i = 1; i * i <= n; i++) {
			if(n % i == 0){
				ret.push_back(i);
				if(i * i != n) ret.push_back(n / i);
			}
		}
		
		sort(begin(ret), end(ret));
		return (ret);
	}

int main(){
	long long int min=1000000000000;
	long long int a;
	
	cin >> a;
	vector<int64_t > v;
	
	v = divisor(a);
	
	if(v.size() % 2 == 0){
		for(int i=0;i<v.size()/2;i++){
			if(min > v[i]+v[v.size()-i-1] ){
				min = v[i]+v[v.size()-i-1];
			}
		}
	}else{
		for(int i=0;i<v.size()/2;i++){
			if(min > v[i]+v[v.size()-i-1] ){
				min = v[i]+v[v.size()-i-1];
			}
		}
		if(min > v[v.size()/2]*2){
			min = v[v.size()/2]*2;
		}
	}
	
	cout << min-2 << endl;
		
	return 0;
}

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

vector<int>data[2];
int mins;

int check(int i,int sum,int cnt,int tar)
{
  if(sum==0)
    {
      if(cnt<mins)
        mins=cnt;
      return mins;
    }
  if(sum<0 || i<0 || cnt>=mins)
    return mins;
  check(i,sum-data[tar][i],cnt+1,tar);
  check(i-1,sum,cnt,tar);
  return mins;
}

void set()
{
  int sum=0;
  int num=0;
  for(int i=1;sum<=1000000;i++)
    {
      num=i+num;
      sum+=num;
      data[0].push_back(sum);
      if(sum%2==1)
        data[1].push_back(sum);
    }
}


int main()
{
  set();
  int n;
  for(;cin>>n,n;)
    {
      int a,b;
      mins=99999999;
      a=check(data[0].size()-1,n,0,0);
      mins=99999999;
      b=check(data[1].size()-1,n,0,1);

      cout<<a<<" "<<b<<endl;
    }


}

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

int main()
{
  int N;scanf("%d",&N);
  set<string> s;
  string W;cin>>W;
  s.insert(W);char last=W[W.size()-1];
  for(int i=1;i<N;i++)
  {
    cin>>W;
    if(s.count(W)||last!=W[0]){printf("No");return 0;}
    s.insert(W);last=W[W.size()-1];
  }
  printf("Yes");
}

Measured memory_bytes: 3788
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String b = scan.next();
    if(b.contains("A")){
    	System.out.print("T");
    }
    else if(b.contains("T")){
      	System.out.print("A");
    }
    else if(b.contains("G")){
    	System.out.print("C");
    }
    else if(b.contains("C")){
    	System.out.print("G");
    }
    scan.close();
  }
}
  

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    int N,M;
    cin>>N>>M;
    if(N%2==1){
        int x=1,y=N-1;
        rep(i,M){
            cout<<x<<" "<<y<<endl;
            x++;y--;
        }
        return 0;
    }
    if(N==4){cout<<1<<" "<<2<<endl;return 0;}
    int x=1,y=N;
    if(N%4==0)y--;
    bool j=true;
    rep(i,M){
        cout<<x<<" "<<y<<endl;
        if(j){if(y-x==N/2+2){x++;j=false;}}
        x++;y--;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;
int h[100010];

int main()
{
	scanf("%d", &n);
	
	for (int i = 0 ; i < n ; i++)
		scanf("%d", &(h[i]));
		
	bool isStart = true;
	int curLength;
	int maxLength = -1;
	for (int i = 0 ; i < n ; i++)
	{
		if (isStart)
		{
			isStart = false;
			curLength = 0;
		}
		else
		{
			if (h[i] <= h[i - 1])
			{
				curLength++;
			}
			else
			{
				isStart = true;
				if (curLength >= maxLength)
					maxLength = curLength;
				i--;
			}
		}
	}
	
	if (curLength >= maxLength)
		maxLength = curLength;
	
	printf("%d\n", maxLength);

	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<iomanip>
#include<vector>
#define rep(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
using ll = long long;
const int M = 100000;

ll g(ll x,ll y){
	if(x%y==0)return x/y;
	else return x/y+1;
}


int main() {
	int n;
	ll ans=0, t[1010], a[1010],tmp;

	cin>>n;
	t[0]=a[0]=1;
	rep(i,1,n+1)cin>>t[i]>>a[i];

	rep(i,1,n+1) {
		tmp = max(g(t[i-1],t[i]),g(a[i-1],a[i]));
		t[i] *= tmp, a[i] *= tmp;
	}
	ans=t[n]+a[n];
	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

dq = deque([])

ans = 0
dq.append(A[0])

for i in range(1, N):
    ans += dq.popleft()
    dq.append(A[i])
    dq.append(A[i])
print(ans)

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

int main()
{
  int a,b;

  while(1){
    cin>>a;
    if(a==0)break;
    map<int,int> mp;
    int ans=-1;
    for(int i=0;i<a;i++){
      cin>>b;
      mp[b]++;
      if(mp[b]>(a/2))ans=b;
    }
    if(ans==-1)cout<<"NO COLOR"<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2732
process.stdin.resume();
process.stdin.setEncoding("utf8");

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

const lines = [];

reader.on("line", (line) => {
  lines.push(line);
});

let cnt = 0;

function insertionSort(A, g) {
  for (let i = g; i < A.length; i++) {
    let v = A[i];
    let j = i - g;
    while (j >= 0 && A[j] > v) {
      A[j + g] = A[j];
      j = j - g;
      cnt++;
    }
    A[j + g] = v;
  }
}

function createG(A) {
  const len = A.length;
  let prev = 1;
  const ret = [1];
  while (true) {
    prev = prev * 3 + 1;
    if (prev < len) {
      ret.push(prev);
    } else {
      break;
    }
  }
  return ret.reverse();
}

function shellSort(A) {
  cnt = 0;
  const G = createG(A);
  for (let i = 0; i < G.length; i++) {
    insertionSort(A, G[i]);
  }
  return G;
}

reader.on("close", () => {
  const n = lines[0] - 0;
  const A = lines.slice(1, n + 1).map(Number);
  const G = shellSort(A);
  console.log(G.length);
  console.log(G.join(" "));
  console.log(cnt);
  A.forEach((e) => console.log(e));
});



Measured memory_bytes: 340864
#include <cstdint>
#include <iostream>
using i8 = std::int_fast8_t;
using u8 = std::uint_fast8_t;
using i16 = std::int_fast16_t;
using u16 = std::uint_fast16_t;
using i32 = std::int_fast32_t;
using u32 = std::uint_fast32_t;
using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;
inline void fast_io() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}
template <class T>
inline void in(T &now) {
    std::cin >> now;
}
template <class T, class... Args>
void in(T &head, Args &... tail) {
    in(head);
    in(tail...);
}
template <class T>
inline void out(T now) {
    std::cout << now;
}
template <class T, class... Args>
void out(T head, Args... tail) {
    out(head);
    out(tail...);
}
template <class T>
inline void up(T &a, const T &b) noexcept {
    if (a < b) {
        a = b;
    }
}
template <class T, class... Args>
void up(T &a, const T &head, const Args &... tail) noexcept {
    up(a, head);
    up(a, tail...);
}
template <class T>
inline void down(T &a, const T &b) noexcept {
    if (b < a) {
        a = b;
    }
}
template <class T, class... Args>
void down(T &a, const T &head, const Args &... tail) noexcept {
    down(a, head);
    down(a, tail...);
}
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

i64 fast_pow_mod(i64 n, i64 level, i64 mod) {
    i64 tmp = n, ret = 1;
    while (level) {
        if (level & 1) {
            ret = (ret * tmp) % mod;
        }
        tmp = (tmp * tmp) % mod;
        level >>= 1;
    }
    return ret;
}

i64 comp(i64 a, i64 b, int p)  // composite num C(a,b)%p
{
    if (a < b)
        return 0;
    if (a == b)
        return 1;
    if (b > a - b)
        b = a - b;
    int ans = 1, ca = 1, cb = 1;
    for (i64 i = 0; i < b; i++) {
        ca = (ca * (a - i)) % p;
        cb = (cb * (b - i)) % p;
    }
    ans = (ca * fast_pow_mod(cb, p - 2, p)) % p;
    return ans;
}

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

    i64 n, a, b;
    in(n, a, b);
    i64 all = fast_pow_mod(2, n, 1E9 + 7) - 1;
    i64 ca = comp(n, a, 1E9 + 7), cb = comp(n, b, 1E9 + 7);
    if (all < ca) {
        all += 1E9 + 7;
    }
    all -= ca;
    if (all < cb) {
        all += 1E9 + 7;
    }
    all -= cb;
    out(all % i64(1E9 + 7));

    return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N = int(input())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
ans = {N}
li1 = make_divisors(N-1)[1:]
for er in li1:
    ans.add(er)
li0 = make_divisors(N)[1:-1]
for i in li0:
    n = N
    while n % i == 0:
        n /= i
    if (n-1) % i == 0:
        ans.add(i)
print(len(ans))





Measured memory_bytes: 10772
import java.util.*;
class Main
{
    static int mod = 1000000007;
    static int h, w, k;
    static int[] p;
    static long[][] dp;
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        h = sc.nextInt();
        w = sc.nextInt();
        k = sc.nextInt();
        p = new int[w + 2];
        p[0] = 1; p[1] = 1;
        for(int i = 2; i < w + 2; i++){
            p[i] = p[i-1] + p[i-2];
        }
        dp = new long[h+1][w+1];
        for(int i = 1; i <= h; i++){
            for(int j = 1; j <= w; j++){
                dp[i][j] = calc(i, j);
            }
        }
        System.out.println(dp[h][k]);
    }
    public static long calc(int height, int width){
        if(height == 1 && width == 1) return p[w - 1];
        else if(height == 1 && width == 2) return p[w-2];
        else if(height + 1< width) return 0;
        else{
            long res = 0;
            res += dp[height - 1][width] * p[width - 1] * p[w - width];
            res %= mod;
            if(width > 1){
                res += dp[height - 1][width - 1] * p[width - 2] * p[w - width];
                res %= mod;
            }
            if(width < w){
                res += dp[height - 1][width + 1] * p[width - 1] * p[w - 1 - width];
                res %= mod;
            }
            return res;
        }
    }
}

Measured memory_bytes: 23764
import itertools
n=int(input())
p=tuple([int(i) for i in input().split()])
q=tuple([int(i) for i in input().split()])

lst=list(itertools.permutations(list(range(1,n+1))))

a=lst.index(p)+1
b=lst.index(q)+1
print(abs(a-b))

Measured memory_bytes: 8052
N = input()
L = len(N)
K = int(input())

dp = [[[0]*2 for _ in range(K+1)] for _ in range(L+1)]
dp[0][0][0] = 1
for i,c in enumerate(N):
    c = int(c)
    for k in range(K+1):
        for less in range(2):
            for d in range(10):
                nk = k + (d>0)
                if nk > K: continue
                if less == 0 and d > c: continue
                nxless = not(less==0 and d==c)
                dp[i+1][nk][nxless] += dp[i][k][less]
print(sum(dp[-1][-1]))

Measured memory_bytes: 3064
import math
def solve():
    N = int(input())
    A = int(input())
    B = int(input())
    C = int(input())
    D = int(input())
    E = int(input())

    ans = 4 + math.ceil(N / min(A,B,C,D,E))
        
    print(ans)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 38512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

func init() {
	sc.Split(bufio.ScanWords)
}

func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	n := scanInt()
	arr := make([]int, n)
	numCounter := map[int]int{}
	max := 0
	for i := range arr {
		num := scanInt()
		max = Max(max, num)
		numCounter[num]++
		arr[i] = num
	}

	divisible := map[int]bool{}
	for _, e := range arr {
		for i := 2; i*e <= max; i++ {
			divisible[i*e] = true
		}
	}

	ans := 0
	for _, e := range arr {
		if !divisible[e] && numCounter[e] < 2 {
			ans++
		}
	}

	fmt.Println(ans)
}


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

int main() {
    int a, b;
    int c = 1;
    cin >> a >> b;
    for(int i = 0; a > i; i++){
        if(c < b){
            c *= 2;
        }else{
            c += b;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 256
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)
    return divisors
 
import random
def is_prime(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
 
    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True
 
import fractions
a, b = map(int,input().split())
ans = 1
gcd_div = make_divisors(fractions.gcd(a, b))
for i in gcd_div:
    if is_prime(i) == True:
        ans += 1
print(ans)

Measured memory_bytes: 6736
from sys import stdin


def a(input_string):
    one, two = input_string
    H, W = [int(x) for x in one.split()]
    h, w = [int(x) for x in two.split()]
    all_one_matrix = []
    for i in range(H):
        all_one_matrix.append([])
        for j in range(W):
            all_one_matrix[i].append(1)
    for i in range(h):
        for j in range(len(all_one_matrix[i])):
            all_one_matrix[i][j] = 0
    for i in range(len(all_one_matrix)):
        for j in range(len(all_one_matrix[i])):
            if j in range(w):
                all_one_matrix[i][j] = 0
    count_0 = 0
    for i in range(H):
        for j in range(W):
            if all_one_matrix[i][j] == 1:
                count_0 += 1
    return count_0


def main():
    input_line = stdin.readlines()
    answer = a(input_line)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>
#include <bitset>
#include <stdlib.h>


//動的計画
//最小化問題
// template<class T>
// bool chmin(T& a,T b){if(a >  b) {a = b;return true;}return false;}
template<class T> 
bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MAX_INDEX = 100010;
ll dp[MAX_INDEX];
const ll INF = 1LL << 60;

#define rep(i,N) for(int i=0;i < N;i++)
int main(){
    
    int N,K;
    cin >> N >> K;

    map<int,int> mp;
    rep(i,K){

        int d;
        cin >> d;
        rep(j,d){
            int id;
            cin >> id;
            mp[id]++;

        }
    }

    int num = 0;
    rep(i,mp.size()){
        if(mp[i] != 0) num++;
    }

    cout << N - num << endl;
    

    return 0;

}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
string s[100], t[100];
int main() {
    int n, m;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) cin >> s[i];
    scanf("%d", &m);
    for (int i = 0; i < m; i++) cin >> t[i];
    int res = 0;
    map<string, int> cnt;
    for (int i = 0; i < n; i++) {
        if (cnt.find(s[i]) != cnt.end()) {
            cnt[s[i]]++;
        } else {
            cnt[s[i]] = 1;
        }
    }
    for (int i = 0; i < n; i++) {
        int c = cnt[s[i]];
        for (int j = 0; j < m; j++) {
            if (s[i] == t[j]) c--;
        }
        res = max(res, c);
    }
    printf("%d\n", res);
}


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

int main() {
  ll a,b,k; cin>>a>>b>>k;
  if (a>=k) a-=k;
  else if (a+b>=k) b-=(k-a), a=0;
  else a=0, b=0;
  cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
using pii =pair<int,int>;

int a,b;
void input(){
    cin>>a>>b;
}
void src(){
    vector<int> c{a+b,a-b,a*b};
    cout<<*max_element(c.begin(),c.end());
    return;
}

int main(int argc,char* argv[]){
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <random>
#include <time.h>
#include <chrono>
#include <cmath>
using namespace std;

int main() {
    int N;
    double T, A, H;
    cin >> N >> T >> A;
    int ans = 0;
    cin >> H;
    double t = T - H * 0.006;
    double min = abs(t - A);
    double diff;
    for (int i = 1; i < N; ++i) {
        cin >> H;
        t = T - H * 0.006;
        diff = abs(t - A);
        if (diff < min) {
            min = diff;
            ans = i;
        }
    }
    cout << ans + 1 << endl;
    return 0;
}

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

#define start          ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define nl            endl;
#define end_            system("pause");
#define sz(v)            ((int)((v).size()))
#define sc(x)            scanf("%d",&x)
#define sc2(x,y)         scanf("%d%d",&x,&y)
#define sc3(x,y,z)       scanf("%d%d%d",&x,&y,&z)
#define sc4(x,y,z,a)     scanf("%d%d%d%d",&x,&y,&z,&a)
#define sc5(x,y,z,a,b)   scanf("%d%d%d%d%d",&x,&y,&z,&a,&b)
#define sc6(x,y,z,a,b,c) scanf("%d%d%d%d%d%d",&x,&y,&z,&a,&b,&c)
#define scl(x)           scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define lp(i,n)        for(int i=0;i<n;i++)
#define lp1(i,f,l)     for(int i=f;i<l;i++)
#define R_(s)         freopen(s, "r", stdin)
#define W_(s)        freopen(s, "w", stdout)
#define R_W R_("input.txt"),W_("output.txt")
#define PI           acos(-1)
#define INF             1<<30
#define mp(a,b) make_pair(a,b)
typedef string            S;
typedef long long         ll;
typedef pair <int, int>   pii;
typedef pair<S, int>     si;
typedef pair<int, S>     is;
typedef pair<char, int>  chi;
typedef pair<S, S>       SS;
typedef vector<pii>        vii;
typedef vector<int>       vi;
typedef vector<vi>       vvi;
typedef vector<S>        vs;
typedef vector<ll>       vll;
typedef vector<vll>     vvll;
ll pw(ll b, ll p){ if (!p) return 1; ll sq = pw(b, p / 2); sq *= sq; if (p % 2) sq *= b; return sq; }
ll gcd(ll a, ll b)  { return (b == 0 ? a : gcd(b, a % b)); }
ll sd(ll x)  { return x<10 ? x : x % 10 + sd(x / 10); }
ll lcm(ll a, ll b){ return ((a*b) / gcd(a, b)); }
vector<ll> get_divisors(ll n){vector<ll> arr;ll i=1;for(i;i*i<=n;i++){if(n%i==0)arr.push_back(i),arr.push_back(n/i);}return arr;}
int dx[4]={0 , 1 , 0 , -1};
int dy[4]={1 , 0 , -1 , 0};

int main()
{
    start;
	long long int ans=0, Q,H,S,D,N;
	cin>>Q>>H>>S>>D>>N;
	H=min(H,2*Q);
	S=min(S,2*H);
	D=min(D,2*S);
	ans=(N/2)*D+(N%2)*S;
	cout<<ans<<endl;
   // end_;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,a,n) for(ll i=a;i<n;i++)
int main(void){
    while(1){
        ll t=0,n;cin>>t;
        if(t==0)break;
        cin>>n;
        ll time=0;
        rep(i,0,n){
          ll s,f;
            cin>>s>>f;
            time+=f-s;
        }
        if(time>=t)cout<<"OK"<<endl;
        else cout<<t-time<<endl;
    }
    
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
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; }

int main()
{
  int k, n;
  cin >> k >> n;
  int a[n];

  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

  int max_distance = 0;
  for (int i = 0; i < n; ++i) {
    int next_pos = (i+1 >= n) ? k + a[0] : a[i+1];
    int distance = abs(a[i] - next_pos);
    // cout << a[i] << "|" << next_pos << "|" << distance << endl;

    chmax(max_distance, distance);
  }

  cout << k - max_distance << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main() {
    int n; cin >> n;
    map<int, int> ma;
    for(int i = 0; i < n; ++i) {
        int a; cin >> a;
        ++ma[a];
    }
    int res = 0;
    for(auto i : ma) {
        if(i.second % 2) ++res;
    }
    
    cout << res << endl;
}


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

using namespace std;

typedef long long ll;

int solve(){
    string s;
    cin >> s;
    string str = "abcdefghijklmnopqrstuvwxyz";
    int l = s.size(), ara[26] = {0};
    for(int i = 0; i < l; ++i){
        for(int j = 0; j < 26; ++j){
            if(s[i] == str[j]){
                ara[j]++;
            }
        }
    }
    for(int j = 0; j < 26; ++j){
        if(ara[j] % 2 != 0){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
 }

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n, m;
    cin >> n >> m;
    if (n == 2 || m == 2)
        cout << 0 << endl;
    else
        cout << abs(m*n - (m-2)*2 - (n-2)*2 - 4) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  int N, C, K;
  cin >> N >> C >> K;

  vector<int> t(N);
  rep(i, N) { cin >> t[i]; }
  sort(t.begin(), t.end());

  queue<int> q;
  int result = 0;
  rep(i, N) {
    while (!q.empty() && q.front() < t[i]) {
      int c = C;
      while (c > 0 && !q.empty()) {
        c--;
        q.pop();
      }
      result++;
    }
    q.push(t[i] + K);
  }
  result += (q.size() + C - 1) / C;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 640
s;
main()
{
  int N;scanf("%d",&N);
  int i=1;
  while(i<=N)
  {
    int a;scanf("%d",&a);
    if(a==i)
    {
      s++;
      scanf("%d",&a);
      i++;
    }
    i++;
  }
  printf("%d\n",s);
}

Measured memory_bytes: 128
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

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

divisors = make_divisors(M)
ans = 0
for d in divisors:
    if N*d <= M:
        ans = d

print(ans)



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

using namespace std;

const int maxn = 2e5 + 5;

int n, m, v, p;
int a[maxn];

int main() {
//	freopen("inp.txt", "r", stdin);
	
	cin >> n >> m >> v >> p;
	
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	
	int found = n - p;
	int l = 0, r = n - 1 - p;
	
	while (l <= r) {
		int M = (l + r) >> 1;
		int nxt = a[M] + m;
		if (nxt < a[n - p]) {
			l = M + 1;
			continue;
		}
		int rem = max(0, v - (p - 1) - M - 1);
		long long tot = 1ll * rem * m;
		long long cur = 0;
		for (int i = M + 1; i < n - p + 1; i++) {
			cur += nxt - a[i];
		}
//		if (M == 2) cout << cur << endl;
		if (cur < tot) {
			l = M + 1;
		} else {
			found = M;
			r = M - 1;
		}
	}
	
	cout << n - found;
		
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
#define inf 1e18+9
using namespace std;
int32_t main(){
	if(fopen("input.txt", "r"))
	freopen("input.txt", "r", stdin),
	freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	int n,p;
	cin >> n >> p;
	string st;
	cin >> st;
	if(p==2 or p==5){
		int ans=0;
		for(int i=0;i<n;i++){
			if((st[i]-'0')%p==0)
				ans+=(i+1);
		}
		cout << ans;
		return 0;
	}
	int m[p]={0};
	int ans=0;
	m[0]++;
	int f=1;
	reverse(st.begin(),st.end());
	for(int i=0;i<n;i++){
		ans=(ans+(st[i]-'0')*f)%p;
		f=(f*10)%p;
		m[ans]++;
	}
	int x=0;
	for(int i=0;i<p;i++)
		x+=m[i]*(m[i]-1)/2;
	cout << x;
}

Measured memory_bytes: 720
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <array>
#include <list>
#include <set>
#include <map>
#include <cmath>
using namespace std;

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

typedef long long ll;

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

int main() {
    int s;
    cin >> s;
    set<int> st;

    st.insert(s);
    for (int i = 0; i < 1e9; i++) {
        if (s % 2 == 0) {
            s = s / 2;
        } else {
            s = 3 * s + 1;
        }
        if (st.count(s)) {
            cout << i+2 << endl;
            return 0;
        }
        st.insert(s);
    }
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input())

def sum_inc(n):
    return int(n*(n+1)/2)

half = int(N/2)+1

each_result = [n*sum_inc(int(N/n)) for n in range(1,half)]

print(sum(each_result)+sum_inc(N) - sum_inc(half-1))

Measured memory_bytes: 206692
#include <iostream>
using namespace std;
int main(){
    int a, b, c; cin >> a >> b >> c;
    if(a + b == c) cout << "Yes" << endl;
    else if(b + c == a) cout << "Yes" << endl;
    else if(c + a == b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
def gcd(x, y):
    if x < y:# x >= y とする
        x, y = y, x
    r = x % y
    res = y if r == 0 else gcd(y, r) 
    return res

N, X = map(int, input().split())
x = list(map(int, input().split()))
x2 = [abs(i - X) for i in x]

g = x2[0]
for i in x2:
    g = gcd(g, i)
print(g)

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

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  for (char c : s) {
    cnt ^= (1 << (c - 'a'));
  }
  cout << (cnt ? "No\n" : "Yes\n");

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++){
        string buf;
        cin >> buf;
        sort(buf.begin(),buf.end());
        s.at(i) = buf;
    }
    sort(s.begin(),s.end());
    long long num = 0;
    long long ans = 0;
    for(int i = 1; i < n; i++){
        if(s.at(i) == s.at(i-1)){
            num++;
        }else{
            ans += (num+1) * num / 2;
            num = 0;
        }
    }
    ans += (num+1) * num / 2;
    num = 0;
    cout << ans << endl;
}


Measured memory_bytes: 5760
#include<stdio.h>

int main(void){
    int n,m,i,j,sum=0,temp;
    scanf("%d %d",&n,&m);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    for(i=0;i<n;i++){
        for(j=n-1;j>i;j--){
            if(a[j]>a[j-1]){
                temp=a[j];
                a[j]=a[j-1];
                a[j-1]=temp;
            }
        }
    }
    if(a[m-1]*4*m>=sum){
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    
}

Measured memory_bytes: 1704
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b; cin >> a >> b;
  string s; cin >> s;
  if(s.length() != a + b + 1) cout << "No" << endl;
  else {
    FOR(i,0,s.length()) {
      if(i == a) {
        if(s[i] != '-') {
          cout << "No" << endl;
          return 0;
        }
      } else {
        if(!isdigit(s[i])) {
          cout << "No" << endl;
          return 0;
        }
      }
      
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n, m, l;
  cin >> n >> m >> l;
  int A[100][100];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  int B[100][100];
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < l; j++) {
      cin >> B[i][j];
    }
  }

  long long C[100][100] = {};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < l; j++) {
      for (int k = 0; k < m; k++) {
        C[i][j] += A[i][k] * B[k][j];
      }
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < l; j++) {
      if (j == l - 1) {
        cout << C[i][j] << endl;
      } else {
        cout << C[i][j] << " ";
      }
    }
  }

  return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
int n;
int sum;
int add[N],sub[N];
int val_add,val_sub;
int ans;
string s;
 
int fpow(int x){
    int res=0;
    while(x){
      res++;
      x%=__builtin_popcount(x);
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n>>s;
     for(int i=0;i<n;++i){
         if(s[i]=='1') sum++;
     }
     add[n-1]=1,sub[n-1]=1;
     for(int i=n-2;i>=0;--i){
         if(sum!=1) sub[i]=2*sub[i+1]%(sum-1);
         add[i]=2*add[i+1]%(sum+1);
     }

     for(int i=n-1;i>=0;--i){
        if(s[i]=='1'){
           if(sum!=1) val_sub=(val_sub+sub[i])%(sum-1);
           val_add=(val_add+add[i])%(sum+1);
        }
     }

     for(int i=0;i<n;++i){
        if(s[i]=='1'){
           if(sum==1){
             cout<<0<<endl;
             continue;
           }
           ans=(val_sub-sub[i])%(sum-1)+(sum-1);
           ans%=(sum-1);
           cout<<fpow(ans)+1<<endl;
        }
        else{
          ans=(val_add+add[i])%(sum+1)+sum+1;
          ans%=(sum+1);
          cout<<fpow(ans)+1<<endl;
        }
     }






    return 0;
}

Measured memory_bytes: 5304
#include <stdio.h>
  
int main(void){
  char str[1010];
  int i,sum;
  
  scanf("%s",str);
  while(str[0]!='0'){
    i=0;  sum=0;
    while(str[i]){
      sum+=str[i]-'0';  i++;
    }
    printf("%d\n",sum);
    scanf("%s",str);
  }
  
  return 0;
}

Measured memory_bytes: 536
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
typedef long long ll;
using namespace std;

int main() {
	int N; cin >> N;
	ll L[90];
	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i <= N; ++i) {
			L[i] = L[i - 2] + L[i - 1];
	}
	cout << L[N] << endl;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_BIT 20

int main() {
    i64 N; cin >> N;
    vector<i64> A(N);
    REP(i, N) cin >> A[i];

    vector<i64> P(N + 1, 0);
    vector<i64> X(N + 1, 0);
    REP(i, N) P[i + 1] = P[i] + A[i];
    REP(i, N) X[i + 1] = X[i] ^ A[i];

    i64 cnt = 0;
    i64 right = 0;
    REP(left, N) {
        auto cond = [&]() {
            return (P[right + 1] - P[left]) == (X[right + 1] ^ X[left]);
        };
        while (right < N && cond()) {
            right++;
        }
        cnt += right - left;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main(){
  ll N,A,B;
  vector<ll> P(3,0);
  cin>>N>>A>>B;
  for(int i=0;i<N;++i){
    ll tmp=0;
    cin>>tmp;
    if(tmp<=A){P[0]++;}
    else if(tmp<=B){P[1]++;}
    else{P[2]++;}
  }
  ll min=*min_element(P.begin(),P.end());
  cout<<min<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;

int main() {
 int a,b,c;
  in(a>>b>>c);
  int m = maxx(a,b,c);
  int n = minn(a,b,c);
  int k = a+b+c-m-n;
  out(m*10+k+n);
}
  

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
)

func fastGetInt(b []byte) int {
	neg := false
	if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n
	}
	return n
}

//========== Implement Algorithm =======================
func solution(X int, Y int) string {
	var retVal string
	if X >= Y {
		retVal = "No"
	} else {
		if Y%2 == 1 {
			retVal = "No"
		} else {
			if X*2 <= Y && Y <= X*4 {
				retVal = "Yes"
			} else {
				retVal = "No"
			}
		}
	}
	return retVal
}

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	//================== Variables used ====================
	var X, Y int
	var ret string
	//======================================================

	//============== Get return value from File ============
	if len(os.Args) >= 2 {

		file, err := os.Open(os.Args[1])
		if err != nil {
			log.Fatalf("failed opening file: %s", err)
		}
		scanner = bufio.NewScanner(file)
		defer file.Close()

	}
	scanner.Split(bufio.ScanWords)
	//======================= I/O ==========================
	scanner.Scan()
	X = fastGetInt(scanner.Bytes())
	scanner.Scan()
	Y = fastGetInt(scanner.Bytes())

	//======================================================
	ret = solution(X, Y)
	//==================== OUTPUT ==========================
	fmt.Println(ret)
}


Measured memory_bytes: 1824
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if (i*500)+(j*100)+(k*50)==x:
                cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,w;
cin>>n>>w;
pair<int,int> arr[n];
for(int i=0;i<n;i++)
{
    cin>>arr[i].ff>>arr[i].ss;
}
int inf=pow(10,17);
int mx=pow(10,5)+5;
int prev[mx]={};
int dp[mx]={};
for(int i=1;i<mx;i++)
{
    prev[i]=inf;
}

prev[arr[0].ss]=arr[0].ff;
for(int i=1;i<n;i++)
{
    for(int j=1;j<mx;j++)
    {if(j>=arr[i].ss)
        {
            dp[j]=min(prev[j-arr[i].ss]+arr[i].ff,prev[j]);
        }
        else
        {
            dp[j]=prev[j];
        }
    }
    for(int j=1;j<mx;j++)
    {
        prev[j]=dp[j];
        dp[j]=inf;
    }
}
int ans=0;
for(int i=0;i<mx;i++)
{
    if(prev[i]<=w)
    {
        ans=i;
    }
}
cout<<ans<<endl;













    return 0;
}

Measured memory_bytes: 1792
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# include <stack>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
ll counter;

int main() {
	ll a = 0, b = 0, n = 0,k=0, counter = 0, maxi = 0;
	ll B[1000];
	std::string str, str2;
	cin >> n>>k;
	cin >> str;
	rep(i, str.size()) {
		if (i!=str.size()-1&&str[i]=='R'&&str[i] == str[i + 1]) {
			counter++;
		}
		if (i != 0 && str[i] == 'L' && str[i] == str[i - 1]) {
			counter++;
		} 
	}
	counter += k * 2;
	if (counter > n - 1)counter = n - 1;
	cout << counter << endl;
}


Measured memory_bytes: 512
from collections import deque
from collections import defaultdict
V, E = map(int, input().split())
d = [0]*V
G = defaultdict(list)
for i in range(E):
    s, t = map(int, input().split())
    d[t] += 1
    G[s].append(t)
q = deque([])
for i in range(V):
    if d[i] == 0:
        q.append(i)
ans = []
while q:
    s = q.popleft()
    ans.append(s)
    for t in G[s]:
        d[t] -= 1
        if d[t] == 0:
            q.append(t)
for x in ans:
    print(x)    
        



Measured memory_bytes: 9556
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
const double esp = 1e-6;
ll n , k , a[maxn];
vector<ll>res;
int main()
{
    ios::sync_with_stdio(false);
    cin >> n >> k;
    bool pos = false;
    for (int i = 1 ; i <= n ; i++){
        cin >> a[i];
        if (a[i] > 0) pos = true;
    }
    sort(a + 1 , a + 1 + n);
    if (pos == false && k % 2){
        reverse(a + 1 , a + 1 + n);
        for (int i = 1 ; i <= k ; i++){
            res.push_back(a[i]);
        }

    }
    else {
        int l = 1 , r = n;
        for (int i = 1 ; i <= k/2 ; i++){
            ll v1 = a[l] * a[l + 1] , v2 = a[r] * a[r - 1];
            if (v1 > v2){
                res.push_back(a[l]);
                res.push_back(a[l + 1]);
                l += 2;
            }
            else{
                if ((r - 2 >= 1 && a[r - 2] < 0) && k > 0 && k % 2){
                    res.push_back(a[l]);
                    res.push_back(a[l + 1]);
                    l += 2;
                    continue;
                }
                res.push_back(a[r]);
                res.push_back(a[r - 1]);
                r -= 2;
            }
        }
        if (k % 2){
            res.push_back(a[r]);
        }
    }

    ll ans = 1;
    for (auto g : res) ans = ((ans * (g)%mod)%mod + mod)%mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6860
#ABC093B
A,B,K = map(int, input().split())
ans = []
if B-A + 1 > K*2:
    for i in range(K):
        ans.append(A+i)
        ans.append(B-i)
    ans.sort()
    for j in ans: 
         print(j)
else:
    for l in range(B-A+1):
        print(A + l)

Measured memory_bytes: 3060
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        N %= 10;
        if(N == 2 || N == 4 || N == 5|| N == 7 || N ==9) {
            System.out.println("hon");
        }else if(N == 3) {
            System.out.println("bon");
        }else {
            System.out.println("pon");
        }


    }
}

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

int main()
{
	int NumMem[2][3000];
	int cnt = 0;
	for (int i = 0; i<3000; i++)
	{
		cin >> NumMem[0][i] >> NumMem[1][i];
		if ((NumMem[0][i] == 0) && (NumMem[1][i] == 0) || (i == 2999))
		{
			break;
		}
		if (NumMem[0][i] < NumMem[1][i])
		{
			cout << NumMem[0][i] << " " << NumMem[1][i] << endl;
		}
		else
		{
			cout << NumMem[1][i] << " " << NumMem[0][i] << endl;
		}
	}
	return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long INF = 1LL << 60;
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

signed main()
{   
    //gearup;
    ll n; cin >> n;
    //素数判定
    bool is_prime = true;
    ll res = 0;
    for(ll i=2;i*i<=n;i++){
        if(n%i == 0){
            is_prime = false;
            res = i;
        }
    }
    if(!is_prime) cout << res-1 + n/res -1 << endl;
    else cout << n-1 << endl;
}


Measured memory_bytes: 256
a=list(input())
b=list(input())
c=list(input())
x=a[0]
for i in range(len(a)+len(b)+len(c)):
  if x=="a":
    if len(a)==0:
      print("A")
      break
    else:
      x=a.pop(0)
  elif x=="b":
    if len(b)==0:
      print("B")
      break
    else:
      x=b.pop(0)
  else:
    if len(c)==0:
      print("C")
      break
    else:
      x=c.pop(0)
    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define LL long long
#define L(x) x<<1    //左儿子 x*2
#define R(x) x<<1|1 //右儿子  x*2+1
using namespace std;
string s;
int main() {
    int n;
    cin>>n;
    int ans1=0,ans2=0;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        if(s[i]==')')
            ans1++;
        else
        {
            int m=min(ans1,ans2);
            ans1-=m;
            ans2-=m;
            for(int i=1;i<=ans1;i++)
                cout<<'(';
            ans1=0;
            ans2++;
        }
    }
    int m=min(ans1,ans2);
    ans1-=m;
    ans2-=m;
    for(int i=1;i<=ans1;i++)
    {
        printf("(");
    }
    cout<<s;
    for(int i=1;i<=ans2;i++)
    {
        printf(")");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

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

    int A, B;
    for (A=119; A >= -118; A--) {
        for (B=A-1; B>= -119; B--) {
            if(pow(A, 5) - pow(B, 5) == X) {
                cout << A << " " << B << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3588
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <iostream>
#include <vector>
#include <iomanip>
#define lsb(x) ((x) & -(x))
using namespace std;

#define mod 1000000007
typedef long long i64;
int n;

struct Mat {
    int v[50][50];
    Mat() {
        fill(v[0], v[50], 0);
    }
    int * operator[](int a) { return v[a]; }
};

Mat operator* (Mat & a, Mat & b)
{
    Mat ans;
    for (int i = 0; i < n; i++) {
        for (int k = 0; k < n; k++) {
            if (!a[i][k])
                continue;
            for (int j = 0; j < n; j++)
                ans[i][j] = (ans[i][j] + 1LL * a[i][k] * b[k][j]) % mod;
        }
    }
    return ans;
}

Mat put(Mat a, i64 p)
{
    Mat ans = a;
    p--;

    while (p) {
        if (p & 1LL)
            ans = ans * a;
        p /= 2;
        if (p)
            a = a * a;
    }

    return ans;
}

int main()
{
    Mat a;
    i64 k;
    scanf("%d%lld", &n, &k);

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            scanf("%d", a[i] + j);

    a = put(a, k);


    int ans = 0;

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            ans = (ans + a[i][j]) % mod;

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256