akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

map<int, pair<int, int>> A;
vector<vector<bool>> board(3, vector<bool>(3, false));

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

  int count=0;
  while(N>0){
    N /= K;
    count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3612
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();

    sc.close();

    int count = 0;

    for (int i = 1; i <= N; i++) {
      String s = String.valueOf(i);
      String[] S = s.split("");
      int k = 0;
      for (int j = 0; j < S.length; j++) {
        k += Integer.valueOf(S[j]);
      }
      if (A <= k && k <= B) {
        count += i;
      }
    }

    System.out.println(count);

  }

}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef double ld;
ll a[100005];
int main()
{ 
ios_base::sync_with_stdio(false);

cin.tie(NULL);
//freopen("input.txt", "r", stdin);
//freopen("output.txt","w",stdout);
ll a,b;
cin>>a>>b;
if(a==0)
{
   if(b==100)
   {
   	cout<<"101";
   }
   else cout<<b;

}
else if(a==1)
{
   if(b==100)
   {
   	cout<<"10100";
   }
   else {
   	cout<<b<<"00";
   }
}
else {
    if(b==100)
    {
    	cout<<"1010000";
    }
    else cout<<b<<"0000";
}
return 0;
}       


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

using ll    = long long;
using vll   = vector<ll>;
using pll   = pair<ll,ll>;
using ld    = long double;

const ll mod = (ll)1e9 + 7;
const ll mxN = (ll)4e5 + 3;

void solve() {
	string s;ll k;cin>>k>>s;
	if(s.length()<=k) cout<<s<<"\n";
	else cout<<s.substr(0,k)<<"...\n";
}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
//	pre();
//	ll t;cin>>t;while (t--)
		solve();
}


Measured memory_bytes: 3640
N=int(input())
A = map(int,input().split(' '))

o = 0
s = 0
f = 0
for a in A:

    if a % 2 == 0:
        if a % 4 == 0:
            f += 1
        else:
            s += 1
    else:
        o += 1
if s == 0:
    if f >= o-1:
        print("Yes")
    else:
        print("No")
else:
    if f >= o:
        print("Yes")
    else:
        print("No")



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

int main() {
string a,b;
cin>>a>>b;
if(a=="H"){
   if(b=="H")  cout <<"H"<<endl;
   else cout <<"D"<<endl;
}
else if(a=="D"){
  if(b=="H") cout <<"D"<<endl;
  else cout <<"H"<<endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int a,b,c;cin>>a>>b>>c;
    int k;cin>>k;
    for(int i=0;i<=k;i++){
        for(int j=0;i+j<=k;j++){
            ll na=a,nb=b,nc=c;
            rep(l,i)nb*=2;
            rep(r,j)nc*=2;
            if(na<nb&&nb<nc){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}


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

int main()
{

int n;
cin>>n;

int c[n],v[n];
for(int index = 0;index<n;index++)
cin>>v[index];
for(int index = 0;index<n;index++)
cin>>c[index];
int ans = 0;
for(int index = 1;index<=(1<<n);index++)
{
  int curr =0;
  int pos = index;
  for(int i = 0;i<n;i++)
  {
      
      if((pos)&1)
      {
        //  cout<<v[i]<<" "<<c[i]<<endl;
           curr+=(v[i]-c[i]);
      }
      pos/=2;
     
  }
  ans= max(curr,ans);
}

cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}



int32_t main(){
  fastio;
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int tot=0;
    int x = min(k,a);
    k-=x;
    tot+=x;
    x = min(k,b);
    k-=x;
    x = min(k,c);
    k-=x;
    tot-=x;
    cout << tot << endl;
  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        int z = Integer.parseInt(sc.next());
        x -= z;
        int count = 0;
        while (x-y-z>=0) {
                count++;
                x -= y;
                x -= z;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21844
package main

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

var sc = bufio.NewScanner(os.Stdin)
var ReadString func() string
var ReadLine func() string
var ReadInt64 func() int64
var ReadInt func() int
var ReadIntSlice func(int) []int
var ReadInt64Slice func(int) []int64
var GetIntAbs func(int) int
var Atoi func(string) int
var FindMin func([] int) int
var FindMax func([] int) int
var StrReverse func(string) string

func init() {
	ReadString = newReadString()
	ReadLine = readLine
	ReadInt64 = readInt64
	ReadInt = readInt
	ReadIntSlice = readIntSlice
	FindMin = findMin
	FindMax = findMax
	StrReverse = strReverse
	GetIntAbs = getIntAbs
}

func main() {
  s := ReadString()
  sl := len(s)
  var rs int
  var prev string
  for i := 0; i < sl; i++ {
    v := string(s[i])
    if prev != v {
      rs += 1
      prev = v
    } else if i + 1 < sl {
      t := v
      for k := i + 1; k < sl; k++ {
        if k >= sl {
          break
        }
        t = fmt.Sprintf("%s%s", t, string(s[k]))
        if t != prev {
          rs += 1
          prev = t
          i = k
          break
        }
      }

    }

  }
  fmt.Println(rs)
}

func strReverse(s string) string {
	runes := []rune(s)
	l := len(runes)
	for i, j := 0, l-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


func newReadString() func() string {
	sc.Buffer(make([]byte, 202400), 404800)
	sc.Split(bufio.ScanWords)
	return func() string {
		if !sc.Scan() {
			panic("scanできなかった")
		}
		return sc.Text()
	}
}

func readLine() string {
	if !sc.Scan() {
		panic("line をscanできなかった")
	}
	return sc.Text()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		fmt.Println("parseInt失敗")
		panic(err.Error())
	}
	return int64(i)
}

func readInt() int {
	i := ReadInt64()
	return int(i)
}

func readIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}

func readInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt64()
	}
	return arr
}

/*------ number util ------*/

func getIntAbs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func atoi(a string) int {
	i, err := strconv.Atoi(a)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func findMin(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	min := arr[0]
	for _, v := range arr {
		if v < min {
			min = v
		}
	}
	return min
}

func findMax(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	max := arr[0]
	for _, v := range arr {
		if v > max {
			max = v
		}
	}
	return max
}


Measured memory_bytes: 4224
from collections import defaultdict
from bisect import bisect_left, bisect, insort_left, insort
INF = 10000
def lcs(s1, s2):
    c = defaultdict(list)
    for i, s in enumerate(s1):
        c[s].append(i)
    for s in set(s2):
        c[s].append(INF)
    def g(li, a):
        for i in li:
            if i >= a:
                return i
        return -1
    dp = []
    for s2_k in s2:
        bgn_idx = 0
        for i, cur_idx in enumerate(dp):
            chr_idx = c[s2_k][bisect_left(c[s2_k], bgn_idx)]
            if chr_idx == INF:
                continue
            dp[i] = min(cur_idx, chr_idx + 1)
            bgn_idx = cur_idx
        else:
            chr_idx = c[s2_k][bisect_left(c[s2_k], bgn_idx)]
            if chr_idx != INF:
                dp.append(chr_idx + 1)
    return len(dp)
def solve():
    N = int(input())
    for _ in range(N):
        x = input()
        y = input()
        print(lcs(x, y))
solve()



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

using namespace std;

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

    int dig;
    int sum = 0;

    while (s){
        dig = s % 10;
        sum = sum + dig;
        s = s / 10;
    }
    cout << sum << endl;
    return 0;
}

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


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll a,b,n;
    cin>>a>>b>>n;
    if(n<b)
    {
        ll s=((a*n)/b)-(a*(n/b));
        cout<<s<<endl;
    }
    else
    {
        n=b-1;
        ll q=((a*n)/b)-(a*(n/b));
        cout<<q<<endl;
    }
    
return 0;
}

Measured memory_bytes: 3580
#include <iostream>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))

int main(int argc, char *argv[]) {
  char c;
  int count = 0;
  while (std::cin >> c) {
    if (c == EOF) break;
    if (c == '1') count++;
  }
  std::cout << count << std::endl;

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
using namespace std;
#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)
int INF=1e9;
const long long mod=1e9+7;
typedef long long ll;

int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]==s[i+1]){
      cout<<"Bad"<<endl;
      return 0;
    }
  }
  cout<<"Good"<<endl;
  return 0;
}


Measured memory_bytes: 256
///
// File:  d.go
// Author: ymiyamoto
//
// Created on Sun Mar 25 21:33:43 2018
//
package main

import (
	"fmt"
)

var A, B int

func main() {
	fmt.Scan(&A, &B)
	A--
	B--

	square := make([][]string, 100)
	for i := range square {
		square[i] = make([]string, 100)
		for j := range square[i] {
			if j < 50 {
				square[i][j] = "#"
			} else {
				square[i][j] = "."
			}
		}
	}

	r, c := 0, 0
	for i := 0; i < A; i++ {
		square[r][c] = "."
		r += 2
		if 100 <= r {
			r = 0
			c += 2
		}
	}

	r, c = 0, 51
	for j := 0; j < B; j++ {
		square[r][c] = "#"
		r += 2
		if 100 <= r {
			r = 0
			c += 2
		}
	}

	fmt.Println(100, 100)
	for i := range square {
		for j := range square[i] {
			fmt.Print(square[i][j])
		}
		fmt.Println()
	}
}


Measured memory_bytes: 896
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List (foldl')
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST
import qualified Data.Sequence as S

import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
readInt = fst . fromJust . B.readInt
readInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO [Int]
readIntegers = map (fst . fromJust . B.readInteger) . B.words <$> B.getLine :: IO [Integer]
read2dInts = map (map (fst . fromJust . B.readInt) . B.words) . B.lines <$> B.getContents
readVInts = map (fst . fromJust . B.readInt) . B.lines <$> B.getContents

main :: IO ()
main = do
  q <- readLn :: IO Int
  qs <- read2dInts
  -- qs <- replicateM q $ map read . words <$> getLine :: IO [[Int]]
  solve qs

type ZippedList a = ([a], [a])

empty :: ZippedList a
empty = ([], [])

singleton :: a -> ZippedList a
singleton x = ([], [x])

insert :: a -> ZippedList a -> ZippedList a
insert x (as, bs) = (as, x:bs)

move :: Int -> ZippedList a -> ZippedList a
move !d org@(as, bs)
  | d > 0  = move (d - 1) (b:as, tail bs)
  | d < 0  = move (d + 1) (tail as, a:bs)
  | d == 0 = org
  where
    a = head as
    b = head bs

delete :: ZippedList a -> ZippedList a
delete (as, b:bs) = (as, bs)

output :: (Show a) => ZippedList a -> IO ()
output (left, right) = do
  putStr . unlines . map show . reverse $ left
  putStr . unlines . map show $ right

solve :: [[Int]] -> IO()
solve = output . foldl' f empty
  where
    f :: ZippedList Int -> [Int] -> ZippedList Int
    f s (query:qs) 
      | query == 0 = insert (head qs) s
      | query == 1 = move (head qs) s
      | query == 2 = delete s





Measured memory_bytes: 274300
A=int(input())
B=int(input())
C=int(input())
X=int(input())

out=0

for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if a*500+b*100+c*50 == X:
        out+=1
        
print(out)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int k, s,count=0;
	cin >> k >> s;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			if (x + y <= s&&x+y+k>=s) {
				count++;
			}
		}
	}
	cout << count << endl;
	int a;
	cin >> a;
	return 0;
}

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



int main() {
	string s;
	int ta = 0;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '1') {
			ta++;
		}
	}
	cout << ta << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct{
  char moji;
  int num;
  int count;
} Card;

int partition(Card [], int, int);
void quicksort(Card [], int, int);

int main(){
  int k, i, stable = 1;
  Card A[100000];

  scanf("%d", &k);
  for(i=0; i<k; i++){
    scanf(" %c%d", &A[i].moji, &A[i].num);
    A[i].count = i;
  }

  quicksort(A, 0, k-1);

  for(i = 1; i < k; i++){
    if(A[i].num == A[i-1].num && A[i].count < A[i-1].count){
      stable = 0;
      break;
    }
  }

  if(stable) printf("Stable\n");
  else printf("Not stable\n");
  for(i = 0; i < k; i++) printf("%c %d\n", A[i].moji, A[i].num);
  
  return 0;
  
}

int partition(Card A[], int p, int r){
  int n, i, j;
  Card temp;
  n = A[r].num;
  i = p-1;
  for(j=p; j<r; j++){
    if(A[j].num <= n){
      i++;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }
  temp = A[i+1];
  A[i+1] = A[r];
  A[r] = temp;
  
  return i+1;
  
}

void quicksort(Card A[], int p, int r){
  int q;
  if(p < r){
    q = partition(A, p, r);
    quicksort(A, p, q-1);
    quicksort(A, q+1, r);
  }
}



Measured memory_bytes: 2880
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
 
public class Main {
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
		solve(fs);
	}
 
	public static void solve(FastScanner fs) {
		int n = fs.nextInt();
		int m = fs.nextInt();
 
		int[] l = new int[m];
		int[] r = new int[m];
 
		for (int i = 0; i < m; i++) {
			l[i] = fs.nextInt();
			r[i] = fs.nextInt();
		}
 
		int lmax = l[0];
		int rmin = r[0];
 
		for (int i = 1; i < m; i++) {
			if (l[i] > lmax)
				lmax = l[i];
			if (rmin > r[i])
				rmin = r[i];
		}
 
		int ans = rmin - lmax + 1;
		if (ans < 0)
			ans = 0;
 
		System.out.println(ans);
	}
}
 
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
 
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
 
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
 
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
 
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
 
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
 
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
 
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
 
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 22648
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 

const int MOD = 1000000007;

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

    vector<int> ok(N, 0);
    for (int i = 0; i < Q; ++i) {
        int a;
        cin >> a;
        --a;
        ++ok[a];
    }

    int minPoint = Q-K+1;

    for (int i = 0; i < N; ++i) {
        if (minPoint <= ok[i]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    
    return 0;
}


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

using namespace std;

long long N, K;
long long result = 0;

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

  for (long long b = K + 1; b <= N; b++)
  {
    //result += ((K + 2) / b) * (b - (N - K - 1));
    //result += ((K + 2) / b) * (b - K);
    long long syou = ((N - K + 1) / b);
    result += syou * (b - K);
    //int amari = (K + 2) % b;
    long long amari = (N - K + 1) % b;
    if (amari != 0)
    {
      // amari < b
      result += fmin(b - K, amari);
      /*for (int a = K + syou * b; a < K + syou * b + amari; a++)
      {
        b - K if (j + ((N - K + 1) / b) * b)
            //if ((j + (N - K - 1)) % b >= K)
            if ((j + K) % b >= K)
        {
          result++;
        }
      }*/
    }
  }
  if (K == 0)
  {
    result -= N;
  }
  cout << result << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <ext/pb_ds/assoc_container.hpp>
#include <thread>
#define endl "\n"
using namespace std;
#define ios ios_base::sync_with_stdio(false);
#define lll __int128_t
#define ll long long int
#define XOX
#define FOR(i,a,b) for(ll i=a;i<(ll)b;i++)
#define FORr(i,a,b) for(ll i =a;i>=(ll)b;i--)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,n)
#define print(arr)  for(auto a: arr) cout << a<< " "; cout << endl;
#define case(i) cout << "Case " << i << ": ";
#define in(a) ll a = read();
#define inp(arr,n) vector<ll>arr(n); for(auto &a: arr) a = read(); 
#define pb emplace_back
#define all(a) a.begin(), a.end()
#define mp make_pair
#define f first
#define s second
#define mod 998244353
#define pll pair<ll, ll>
inline ll read()
{
    ll x=0; static ll p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
    return x;
}
template<typename T> ostream& operator<<(ostream &os, const multiset<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T> ostream& operator<<(ostream &os, const set<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
 
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#define DEBUG
#ifdef DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
void solve(int pk);

int main()
{
  //freopen("in", "r", stdin);
   ll nn = 1;
   //nn= read();
 //  ios
  // cin >> nn;
    rep(i, nn) solve(i);
}
void solve(int tt)
{
    in(n)
    ll ans = 0;
    for(int i = 1; i < n; i++){
        ans += (n/i);
        if(n%i == 0) ans--;
    }
    cout << ans << endl;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3
int num[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

int main(){
    cin.sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    if (num[x] == num[y]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
  int N;
  
  cin >> N;
  vector<char> colors(N);
  for (int i = 0; i < N; i++)
    cin >> colors.at(i);
  
  bool ToF = true; //Three or Four
  for (int i = 0; i < N; i++) {
    if (colors.at(i) == 'Y')
      ToF = false;
  }   
  if (ToF)
    cout << "Three" << endl;
  else cout << "Four" << endl;
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        int N = Integer.parseInt(input.split(" ")[0]);
        int M = Integer.parseInt(input.split(" ")[1]);
        int X = Integer.parseInt(input.split(" ")[2]);
        int Y = Integer.parseInt(input.split(" ")[3]);
        int x[] = new int[N];
        input = sc.nextLine();
        for(int i = 0; i < N; i++){
            x[i] = Integer.parseInt(input.split(" ")[i]);
        }
        int y[] = new int[M];
        input = sc.nextLine();
        for(int i = 0; i < M; i++){
            y[i] = Integer.parseInt(input.split(" ")[i]);
        }

        boolean war = false;

        for(int i = X+1; i <= Y; i++){
            boolean xT = true;
            for(int j = 0; j < N; j++)if(xT && x[j] >= i)xT = false;
            boolean yT = true;
            for(int j = 0; j < M; j++)if(yT && y[j] < i)yT = false;
            if(xT && yT)war = true;
        }
        if(war){
            System.out.println("No War");
        }else{
            System.out.println("War");
        }

    }
}

Measured memory_bytes: 25812
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(a,b) (0<=(a)&&(a)<(b))

using namespace std;

int main(){
	int R0,W0,C,R;
	while(cin>>R0>>W0>>C>>R,R0){
		int ans;
		int c=R0/W0;
		for(ans=0;c<C;ans++)c=(R0+R*(ans+1))/W0;
		p(ans);
	}
	return 0;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
long long extGCD(long long a,long long mod,long long &x,long long &y){
    if(mod==0){
        x=1;
        y=0;
        return a;
    }
    long long d=extGCD(mod,a%mod,y,x);
    y-=(a/mod)*x;
    return d;
}
long long invmod(long long a,long long mod){
    long long x,y;
    extGCD(a,mod,x,y);
    x%=mod;
    if(x<0)x+=mod;
    return x;
}
ll fac[2000010],finv[2000010],inv[2000010];
void combinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    REP(i,2,2000010){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=invmod(i,mod);
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
ll rui(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1)res=res%mod*a%mod;
        a=a%mod*a%mod;
        b/=2;
    }
    res%=mod;
    return res;
}
int main(){
    ll n;cin>>n;
    combinit();
    vector<ll>prcnt(1000010);
    vector<ll>a(n);
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        ll k=a[i];
        REP(j,2,sqrt(a[i])+1){
            ll cnt=0;
            while(k%j==0){
                cnt++;
                k/=j;
            }
            prcnt[j]=max(prcnt[j],cnt);
        }
        if(k>1)prcnt[k]=max(prcnt[k],1LL);
    }
    ll b=1;
    REP(i,2,1000010){
        b=b%mod*rui(i,prcnt[i])%mod;
    }
    ll ans=0;
    rep(i,n){
        ans=(ans+b%mod*inv[a[i]]%mod)%mod;
    }
    if(ans<0)ans+=mod;
    cout<<ans<<endl;
}

Measured memory_bytes: 55040
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define ll long long
//#define int long long
using namespace std;
void boost()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
void free()
{
	freopen("A.in", "r", stdin);
	freopen("A.out", "w", stdout);
}
main()
{
	//free();
	boost();
	int a, b, c;
	cin >> a >> b >> c;
	if(a + b >= c) cout << "Yes";
	else cout << "No";
	exit(0);	
}



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

int main(){
    long long int X, K, D;
    cin >> X >> K >> D;
    long long int first = X;
    long long int k = 0;
    //cout << X/D << endl;
    
        if(abs(X) >= D){
            if(X > 0){
                k = X/D;
                X %= D;
                if(k > K){
                    k = K;
                    X = first - D*K;
                }
                
            }else
            {
                k = abs(X)/D;
                X = -(abs(X)%D);
                if(k > K){
                    k = K;
                    X = first + D*K;
                }
            }
        
        }
            if((K - k)%2 == 1){
                if(X > 0){
                    X -= D;
                }else if(X <= 0){
                    X += D;
                }
            }
        
    

    cout << abs(X) << endl;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    
  
  if(n%2==1){
    for(int i=0; i<m; i++){
      cout << 1+i << " " << n-i <<endl;
    }
  }else{
    for(int i=0; i<m; i++){
      if(i>=n/4)cout << 1+i << " " << n-i-1 <<endl;
      else cout << 1+i << " " << n-i <<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3632
d = {"r": "p", "s": "r", "p": "s"}
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
score = {"r": r, "s": s, "p": p}
d2 = {}
r = 0


def set_hand(l, k):
    if l + k < n:
        if {d.get(t[l - k]), d.get(t[l + k])} == {"r", "s"}:
            return "p"
        if {d.get(t[l - k]), d.get(t[l + k])} == {"r", "p"}:
            return "s"
        if {d.get(t[l - k]), d.get(t[l + k])} == {"p", "s"}:
            return "r"
        return t[l]
    else:
        return t[l]


for i in range(k):
    for l in range(i, n, k):
        if l - k >= 0:
            if d2[l - k] == d.get(t[l]):
                d2[l] = set_hand(l, k)
            else:
                d2[l] = d.get(t[l])
                r += score[d2[l]]
        if l - k < 0:
            d2[l] = d.get(t[l])
            r += score[d2[l]]
print(r)


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

using namespace std;

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

const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1000000000000000000L;

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

    int g[100000][2];
    rep(i, k) {
        g[i][0] = (i * 10) % k;
        g[i][1] = (i + 1) % k;
    }

    bool used[100000];
    fill(used, used + k, false);
    deque<P> dq;
    dq.push_back(P(1, 1));
    while(true) {
        P p = dq.front(); dq.pop_front();
        if(p.first == 0) {
            cout << p.second << endl;
            break;
        }
        if(used[p.first]) continue;
        used[p.first] = true;
        dq.push_front(P(g[p.first][0], p.second));
        dq.push_back(P(g[p.first][1], p.second + 1));
    }

    return 0;
}


Measured memory_bytes: 1920
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (200006)
ll n,ans,tmp;
pi A[MAXN];
multiset<pi> h, l;
ll dist(ll x,ll y){
	return abs(A[x].f - A[y].f) + abs(A[x].s - A[y].s);
}
int main(){
	FAST
	cin>>n;
	FOR(i,1,n) cin>>A[i].f>>A[i].s;
	tmp=-LLINF; FOR(i,1,n) tmp=max(tmp,A[i].s);
	ans=tmp, tmp=LLINF; FOR(i,1,n) tmp=min(tmp,A[i].s); ans-=tmp;
	sort(A+1,A+n+1);
	FOR(i,1,n) {
		auto tmp = h.lower_bound(pi(A[i].s, 0));
		if(tmp!=h.end())ans = max(ans, dist(tmp->s, i));
		tmp = l.upper_bound(pi(A[i].s, LLINF));
		if(tmp!=l.begin())--tmp,ans=max(ans, dist(tmp->s, i));
		if(h.empty() || (--h.end())->f < A[i].s) {
			while(h.size()){
				auto tmp = (--h.end())->s;
				if(A[i].s - A[tmp].s < A[i].f - A[tmp].f) break;
				h.erase(--h.end());
			}
			h.ins(pi(A[i].s, i));
		}
		if(l.empty() || l.begin()->f > A[i].s) {
			while(l.size()){
				auto tmp = l.begin()->s;
				if(A[tmp].s - A[i].s < A[i].f - A[tmp].f) break;
				l.erase(l.begin());
			}
			l.ins(pi(A[i].s, i));
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 6736
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF = 100000000;
ll i,j,k;
int main(){
    ll n;cin>>n;
    vector<ll> a(n);for(i=0;i<n;i++){cin>>a[i];}
 
    sort(a.begin(),a.end());

    ll key,another,maxi=a[n-1];
    
    another=(a[n-1]+1)/2;//anotherがあったらmax間違いなし！

    vector<long long int>::iterator position;
    position=upper_bound(a.begin(),a.end(),another);
    key=distance(a.begin(),position);
    if(a[key-1]!=another){//a[]にanotherがないとき
        if(a[key]-another<another-a[key-1]){//anotherに近い方がmax
            another=a[key];
        }else{another=a[key-1];}
    }

    cout<<a[n-1]<<" "<<another<<endl;
       
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans;
int main(){
  ll N,M;
  cin>>N>>M;

if(N*2<=M){
  ans+=N;
  M-=N*2;
  ans+=M/4;
}else{
  ans+=M/2;
}
cout<<ans<<endl;
}


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

using namespace std;
typedef long long ll;

vector<ll>h;

int main(){

	int N;
	ll A,B;

	scanf("%d %lld %lld",&N,&A,&B);

	int i;

	for(i=0;i<N;i++){
		ll hi;
		scanf("%lld",&hi);
		h.push_back(hi);
	}

	ll l,r,mid;

	l=0;
	r=1000000000;
	mid=(l+r)/2;

	while(1){

		ll sum=0;

		for(i=0;i<N;i++){
			if(h[i]-(mid*B)>0){
				if((h[i]-(mid*B))%(A-B)==0){
					sum+=(h[i]-(mid*B))/(A-B);
				}
				else{
					sum+=((h[i]-(mid*B))/(A-B))+1;
				}
			}
		}
		if(sum<=mid){
			r=(l+r)/2;
		}
		else{
			l=(l+r)/2;
		}
		mid=(l+r)/2;
		if(l==r-1){break;}
	}

	printf("%lld\n",r);

	return 0;
}

Measured memory_bytes: 1400
h,w=map(int,input().split())
g=[input() for _ in range(h)]
for x in range(h):
  for y in range(w):
    if g[x][y]=='.': continue
    ng=1
    for dx,dy in [(1,0),(0,1),(-1,0),(0,-1)]:
      nx,ny=x+dx,y+dy
      if 0<=nx<h and 0<=ny<w:
        if g[nx][ny]=='#': ng=0
    if ng:
      print('No')
      exit()
print('Yes')

Measured memory_bytes: 9128
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll N;
ll A[201010];

int main() {
  cin >> N;
  rep(i, 0, N) {
    ll a;
    cin >> a;
    A[i] = a - (i + 1);
  }
  sort(A, A + N);

  ll mid = (N + 1) / 2;
  ll b = A[mid - 1];

  ll ans = 0;
  rep(i, 0, N) { ans += abs(A[i] - b); }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<cctype>
int main(){
    char ch;
    int A[26]={},num;
    while(scanf("%c",&ch)!=EOF){
        ch=tolower(ch);
        if(isalpha(ch)){
            num=ch-'a';
            A[num]+=1;
        }
    }
    for(int i=0;i<26;i++){
        printf("%c : %d\n",i+'a',A[i]);
    }
    return 0;
}



Measured memory_bytes: 2680
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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 T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

ll N,A[100007];

int main(){
    ll c4=0;
    cin >> N;
    ll sum=0;
    rep(i,N){
        cin >> A[i];
        sum+=A[i];
    }
    if(sum%(((N+1)*N)/2)!=0){
        cNO;
        return 0;
    }
    ll K=sum/(((N+1)*N)/2);
    rep(i,N){
        ll l=A[(i-1+N)%N];
        ll r=A[i];
        ll t=K;
        while(r-l!=t && t>-1){
            l-=N;
            r-=1;
            t--;
            c4++;
        }
        if(c4>K){
            cNO;
            return 0;
        }
    }
    if(c4==K){
        cYES;
    }
    else{
        cNO;
    }
}

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

int gcd(long long a,long long b){
    if(b == 0) return a;
    return gcd( b , a % b);
}

int find(string str, const string& word) {
  int count = 0;
  for (string::size_type pos = 0; (pos = str.find(word, pos)) != string::npos; pos += word.size()) {
    ++count;
  }
  return count;
}

int main(){
    int a,b;
    int ans;
    cin >> a >> b;
    if(a > 12) ans = b; 
    else if(a > 5) ans = b / 2;
    else ans = 0;

    cout << ans << endl;
    return 0;

}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int powInt(int x, int y)
{
    int res = 1;
    for (int i = 1; i <= y; ++i) res *= x;
    return res;
}

int main()
{
    int D, G;
    cin >> D >> G;
    int p[D], c[D];
    REP(i, D)
    {
        cin >> p[i] >> c[i];
    }

    int ans = 0;
    REP(i, D) ans += p[i];

    for (int i = 0; i <= powInt(2, D) - 1; ++i)
    {
        int score = 0;
        int count = 0;
        bool isComp[D] = {false};
        REP(d, D)
        {
            if ((i & powInt(2, d)) == powInt(2, d))
            {   
                score += 100 * (d + 1) * p[d] + c[d];
                count += p[d];
                isComp[d] = true;
            }
        }

        if (score >= G)
        {
            ans = min(ans, count);
            continue;
        }

        bool isAchive = false;
        for (int d = D - 1; d >= 0; --d)
        {
            if (!isComp[d] && !isAchive)
            {
                for (int j = 1; j <= p[d] - 1; ++j)
                {
                    score += 100 * (d + 1);
                    count++;
                    if (score >= G)
                    {
                        ans = min(ans, count);
                        isAchive = true;
                        break;
                    }
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np
n = int(input())
v = list(map(int, input().split()))
gu = [0] * (10**5 + 5)
ki = [0] * (10**5 + 5)

for i in range(n):
  if i % 2:
    ki[v[i]] += 1
  else:
    gu[v[i]] += 1
ki = np.array(ki)
gu = np.array(gu)

a = np.argmax(ki)
b = np.argmax(gu)

if a != b:
  print(n-ki[a]-gu[b])
else:
  gu = sorted(gu)
  ki = sorted(ki)
  print(min(n-ki[-1] - gu[-2], n-ki[-2]-gu[-1]))

Measured memory_bytes: 25256
#include <iostream>
#include <map>
#include <vector>
#include <string>
#define FIN freopen("inputs.txt", "r", stdin)
using namespace std;
typedef long long ll;
// map<char*, int> m = {
//     make_pair("AC", 0),
//     make_pair("WA", 1),
//     make_pair("TLE", 2),
//     make_pair("RE", 3)
// };
map<string, int> m;

string vs[4] = {"AC", "WA", "TLE", "RE"};
int main()
{
#ifndef ONLINE_JUDGE
    FIN;
#endif
    m["AC"] = 0;
    m["WA"] = 1;
    m["TLE"] = 2;
    m["RE"] = 3;
    int n;
    cin>>n;
    vector<int> freq(4, 0);
    while (n--)
    {
        string sts;
        cin >> sts;
        freq[m[sts]]++;
    }
    for (int i = 0; i < 4; i++)
    {
        printf("%s x %d\n", vs[i].c_str(), freq[i]);
    }
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
main(){
  long long a,b,x;cin >> a >> b >> x;
  long long ans = 0;
  if(a == 0){
    ans+=b/x+1;
  } else {
    ans+=b/x+1 - (a-1)/x-1;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
struct DirectedGraph {
    vector<vector<int> > parent;
    vector<int> dist;
    DirectedGraph(int n) {
        parent.resize(n+1);
        dist.resize(n+1, -1);
    }
    void setParent(int chi, int par) {
        parent[chi].push_back(par);
    }
    int getDist(int n) {
        if (dist[n] != -1) {
            return dist[n];
        }
        if (parent[n].empty()) {
            return dist[n] = 0;
        }
        int tmp = 0;
        for (int p : parent[n]) {
            tmp = max(getDist(p), tmp);
        }
        return dist[n] = ++tmp;
    }
};
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    auto dg = DirectedGraph(N);
    for (int i = 0; i < M; ++i) {
        int x, y;
        cin >> x >> y;
        dg.setParent(x, y);
    }
    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        ans = max(ans, dg.getDist(i));
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 7552
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c$}SA&2Hm15WWY<I}lj3krE|{7kgL)ac-Mq_tINx2(m=mglS4k%ig571ikgvK0t5np+H~Cmp;bMkQ7CcRDM=4V3EW5`{v__d`HTMc2$cjGOu@{+LkL?uBW#J-_qlwg{(J5ez9ltD=FEgsbxzFDT@aq=WJeHY}*R{t$b5(UY8kJND5|-kIMF;p%q;aUW+A3PCundN<_V6Jd}M-6MW0mI9$a<3yW^`A}fXkC@gug-I6U`w&3{c_=vz$c3Qc}$d>&|(el!fp`lY!IWwOKbw-~_-Jl1Yz;T|JOt3c36XOUR@<nRg;qy~1D0xQ?kAJG)KZmE^4o|-y9{)Q${qg_5e;=M6508I!CY6tU%_@Rc2R1VmH-wELWEhs~#Rh+OH6wd6)m2Fnk)=A(dZ9te$O%75Jw>$4K<Tod|H|5x2GsGQ1S`fVtiC3~li;(zV>2*BlQfhuayBKCejc;BQ0SqvTt~dmRC+XxL*gzSqGOYH5ehP}=?aLFQ<3arSO6zHG*r?Pa(%62VeU9P%+4A^^ub!E9H|*OZD7H*e!VdpCV5XzweIPlfUl{YEm3E~i?$i5l3$@wyMFr3or?5~D7#34=MAgU=U4;bO&YZD&y(n)3=mZF70fo?9GdX;YXrG&hS@21=Wb|Sk~a{rm!*z6-!)ayQrPk=fbU#o>9&W8s%k#dAh0hcI+F<Lw=~uU8qIfdA2Pf_s4bK}R(A~+=zfGl5g4wg7X25{XvobC2_ZRiAn6&ujHeZ*BWb&n!bT4iv$@SevyH5)h+VG#<VZhIs@n}GCRf-O&@?yF8TT4|1YbEauYu&SX`}}r1JC5gfMp8XKA5^mV3c(T@L8m@a&LPX>vF`pG&~KxO4qA)C}#=_&nt&w2R5WX=@!rCp=|kugH4hL#e0bjlOY4J#GB$imu$I;u?w8vl88}Nhv~FyN*-XY%Urz71D8=z0%=10EO&la?wA5a!*DJmm5ag-@r$}8i=@ZdrAr#I)05I>5Lu-?PSsb0$Hn0LEq=SFhbB-PSBkM5A5$R?eLPZ+H@O?xNLZ6|#S#BBgwI^kVjbrw62@mJ6FH}g7(wMYL1l~)#*_1f9&1A1Ps&)Y(2HTW15pc6J=14i#a6e^Ji}J`3bsnaR=^>~6yyIbzPo2gp@G`C(paN4g;P<!mbK5gG_C$zk;MPX;1g%)Wq8_fKIb7l*C8`aRO?w7DVAY9vs+CKG2fZ${_btEDI~Oi%I%G@k%d@N?@GyPD~H2Fxhi0{G!o)k*c%@P3D>b?7^fA@Gg9^kT63g#l9_|hn0B`YpgRZZefW6g<A~Nu$ZK*5iOr#qA3kcK0l2i0sjY|KCh7%eR-R8TyC>8EO!YU?9Qx)%6A)hkTX7zKCJQ}7;r<>9=L6XE<-#wqS-OVw_k-nla#u)a<V*j`GSX&bm*L{Ug|v9Zg>+F%I4v?^st*fwDAP%LMGAdkQGSf=o}WuaJ~cuqyau;QfKDT+|7pbE7ssE@zU@8Ya5o(8heN1Bi`#E9*d5CYJiqVoh5@LgT|K(R@7;5|;&O8G1FwD&Cz(=KCnBqzM$2jSdbR!#WOU)10y_`%zX3Jegro")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 14848
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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

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

    int fh, fc;
    fh = x/500;
    fc = (x%500) / 5;
    int ans;
    ans = fh * 1000 + fc * 5;
    cout << ans << endl; 
}


Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^8 -> 8回
// double pi = M_PI or acos(-1)
// printf("%.10f\n", ans);

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());  // 昇順に並べる
    return ret;
}

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

    vector<ll> nums = divisor(n);

    ll x, y;
    if (nums.size() % 2 == 0) {  // even
        x = nums.at(nums.size() / 2 - 1);
        y = nums.at(nums.size() / 2);
    } else {
        x = nums.at(nums.size() / 2);
        y = nums.at(nums.size() / 2);
    }

    ll ans = (x - 1) + (y - 1);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
#include <vector>
#include <limits.h>
#include <stack>
#include <queue>

using namespace std;

#define PI 3.14159265359
#define INF LLONG_MAX

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

    cin >> N;
    cin >> A;

    int amari = N % 500;
    if (amari > A)
    {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int sum = 0;
    for(int i = 0; i < n; i++){
      int x = sc.nextInt();
      sum += Math.min(x, k - x) * 2;
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<algorithm>

std::string revstr(std::string S){
 std::reverse(S.begin(), S.end());
 return S;
}


int main(){
std::string S, revS, T, revT, U, revU;
std::cin >> S;

std::size_t len=S.length();

revS=revstr(S);
  
T=S.substr(0,(len-1)/2);

revT=revstr(T);

U=S.substr((len+3)/2-1, (len-1)/2);

revU=revstr(U);
  
  std::cerr << T << " "<< U << "\n";

if((S==revS)&&(T==revT)&&(U==revU)){
  
  std::cout << "Yes" << "\n";
} else{
  std::cout << "No" << "\n";
}

return 0;
}

Measured memory_bytes: 256