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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = atan(1.0) * 4.0;
// const int MOD = 998244353;
const ll LINF = 9e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

void cinfast() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

bitset<4000001> dp[2];
ll A[2000];

signed main() {
    // cinfast();
    LCIN(N);
    ll sum = 0;
    REP(i, N) {
        cin >> A[i];
        sum += A[i];
    }
    ll now = 0, next = 1;
    dp[now].set(0);
    REP(i, N) {
        dp[next] = 0;
        dp[next] |= dp[now];
        dp[next] |= dp[now] << A[i];
        swap(now, next);
    }
    FOR(i, (sum + 1) / 2, 4000001) {
        if(dp[now][i]) {
            eputs(i);
        }
    }
}


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


int main(){
  ios::sync_with_stdio(0); cin.tie(0);
  int n, x; cin >> n >> x;
  vector<int> v(n);
  for(int i = 0 ; i < n ; i++) cin >> v[i];
  sort(v.begin(), v.end());
  int cnt = 0;
  for(int i = 0 ; i < n ; i++){
    if(v[i] <= x){
      x -= v[i];
      cnt++;
    }
  }
  if(cnt==n && x!=0) cout << cnt-1;
  else cout << cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> dp(n+1);
    dp[0] = 2;
    dp[1] = 1;
    for(int i=2; i<=n; ++i) {
        dp[i] = dp[i-2] + dp[i-1];
    }
    cout << dp[n] << "\n";
}

Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    tlist = []
    for i in range(K):
        di = int(input())
        li = list(map(int, input().split()))
        tlist += li
    tset = set(tlist)
    print(N-len(tset))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9204
#include<iostream>
#include<algorithm>
#include<vector>
#include<iterator>
using namespace std;
using LL = long long;

int main()
{
	LL N;
	cin >> N;
	vector<LL> top(N),mid(N),bot(N);
	LL i;
	for(i = 0;i < N;i++)
	{
		cin >> top[i];
	}
	for(i = 0;i < N;i++)
	{
		cin >> mid[i];
	}
	for(i = 0;i < N;i++)
	{
		cin >> bot[i];
	}
	vector<LL> topnum(N),midnum(N);
	sort(top.begin(),top.end());
	sort(mid.begin(),mid.end());
	sort(bot.begin(),bot.end());
	
	for(i = 0;i < N;i++)
	{
	vector<LL>::iterator tmpit = upper_bound(bot.begin(),bot.end(),mid[i]);
		LL tmpdistance;
		if(tmpit ==  bot.end()) 
		{
			tmpdistance = N;
		}
		else
		{
			tmpdistance = distance(bot.begin(),tmpit);
		}
		midnum[i] = N - tmpdistance;
	}
	LL bigsum = 0;
	for(i = 0;i < N;i++)
	{
		bigsum += midnum[i];
	}
	vector<LL> sum(N);
	sum[0] = midnum[0];
	for(i = 1;i < N;i++)
	{
		sum[i] = sum[i-1] + midnum[i];
	}
	for(i = 0;i < N;i++)
	{
	vector<LL>::iterator tmpit = upper_bound(mid.begin(),mid.end(),top[i]);
		LL tmpdistance;
		if(tmpit ==  mid.end()) 
		{
			tmpdistance = N;
		}
		else
		{
			tmpdistance = distance(mid.begin(),tmpit);
		}
		if(tmpdistance == 0) topnum[i] = bigsum;
		else{
		topnum[i] = bigsum - sum[tmpdistance-1];
			}
	}
	LL ans = 0;
	for(i = 0;i < N;i++)
	{
		ans += topnum[i];
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 4992
import java.util.*;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int a = scan.nextInt();
        int b = scan.nextInt();
        int tmp  = n * a;
        if(tmp > b) {
            System.out.println(b);
        }
        else  {
            System.out.println(tmp);
        }
    }
}


Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int arr[3];
  cin>>arr[0];
  cin>>arr[1];
  cin>>arr[2];
  sort(arr, arr+3);
  int cost=0;
  cost+=(arr[2]-arr[1]);
  cost+=(arr[1]-arr[0]);
  cout<<cost<<endl;
}


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

int main()
{
    int N;
    cin >> N;
    vector<tuple<string, int, int>> v;
    for(int i = 0; i < N; i++){
      string s;
      int p;
      cin >> s >> p;
      v.emplace_back(s, 100 - p, i+1);
    }
    sort(v.begin(), v.end());
    for(auto x : v){
      cout << get<2>(x) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n + 2];
        long sum = 0;
        int x = 0;
        for (int i = 1; i <= n; i++) {
            int temp = Integer.parseInt(sc.next());
            sum += Math.abs(x - temp);
            a[i] = temp;
            x = temp;
            if (i == n) {
                sum += Math.abs(temp);
            }
        }
        long[] ans = new long[n];
        for (int i = 1; i <= n; i++) {
            ans[i - 1] = sum - Math.abs(a[i] - a[i - 1]) - Math.abs(a[i + 1] - a[i]) + Math.abs(a[i + 1] - a[i - 1]);
        }
        StringBuilder sb = new StringBuilder();
        for (long l : ans) {
            sb.append(l);
            sb.append("\n");
        }
        System.out.println(sb.toString());
    }
}

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

int main() {
  
  int N; cin >> N; int ans = 0;
  
  for (int i = 1; i <= N; i++) {
    
    string S = to_string(i); int tmp = S.size();
    
    if (tmp % 2 == 1) ans++;
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pii pair<int,int>
#define MP make_pair
#define F first
#define S second
#define mod 1000000007

ll mp[10][10];

inline void f( int n ){
    
    int x,y;
    
    x = n%10;
    while( n>0 ){
        y = n%10;
        n = n/10;
    }
    mp[x][y]++;
}


int main() {
flash;
    
    ll n; cin>>n;
    for(int i=1;i<=n;i++){ f(i); }
    
    ll ans = 0,x;
    
    for(int i=1;i<=9;i++){
        for(int j=i+1;j<=9;j++){
            ans += 2*mp[i][j]*mp[j][i];
        }
    }
    
    for(int i=1;i<=9;i++){
        x = mp[i][i];
        ans += x*x ;
    }
    /*
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            cout<<mp[i][j]<<" ";
        }cout<<endl;
    }cout<<endl;
    */
    cout<<ans;
    
	return 0;
}

Measured memory_bytes: 256
from functools import lru_cache
Mod = 10**9+7

l = [int(t) for t in list(input())]
n = len(l)

@lru_cache(maxsize=10000)
def f(x):
  if x == 0:
    return 1
  elif x%2 == 1:
    return (3*f(x-1))%Mod
  else:
    return (f(x//2)**2)%Mod

@lru_cache(maxsize=10000)
def g(x):
  if x == 0:
    return 1
  elif x%2 == 1:
    return (2*g(x-1))%Mod
  else:
    return (g(x//2)**2)%Mod



s = 0
k = 0
for i in range(n):
  if l[i] == 0:
    continue
  s = (s + f(n-1-i)*g(k))%Mod
  k += 1
s = (s + g(k))%Mod
print(s)

Measured memory_bytes: 13956
#include<bits/stdc++.h>
#define XX first
#define YY second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=998244353;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N;
int D[114514];
int cnt[114514];

LL mypow(LL base, LL exp) {
  if (!exp) return 1;
  LL res = mypow(base*base%MOD, exp/2);
  if (exp%2) res = res*base%MOD;
  return res;
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  cin >> N;
  rep(i, N) {
    cin >> D[i];
    cnt[D[i]]++;
  }
  if (D[0] != 0 || cnt[0] != 1) {
    cout << "0" << endl;
    return 0;
  }
  LL ans = 1;
  reps(i, 1, N) {
    ans *= mypow(cnt[i-1], cnt[i]);
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
# 33
A, B = map(int, input().split(' '))
S = str(input())

ans = 'Yes'
if S[A] != '-':
    ans = 'No'
else:
    S = S.replace('-', '', 1)
    if S.isdecimal() == False:
        ans = 'No'

print(ans)

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

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if(s * t >= d) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

void fact(int N, list<int> &V) {
    for (int i = 2; i*i <= N; i++) {
        while (N % i == 0) {
            V.emplace_back(i);
            N /= i;
        }
    }
    if (N != 1) V.emplace_back(N);
}

int main() {
    int N; cin >> N;
    map<int, int> M;
    ll MOD = (ll)pow(10,9) + 7;

    for (int i = 2; i <= N; i++) {
        list<int> V;
        V.clear();
        fact(i, V);
        if (V.empty()) M[i]++;
        else for (auto x : V) M[x]++;
    }

    ll res = 1;
    for (auto x : M) {
        res *= (x.second + 1);
        res %= MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define cin1(x) scanf("%d",&x)
#define cin2(x,y) scanf("%d%d",&x,&y)
#define cin3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define rr read()
#define ll long long
#define CloseIo ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll  long long 
using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(b+c-a>0)
    	cout<<b+c-a;
    else
    	cout<<"0";
    cout<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define llint long long

using namespace std;

llint n;
char c[45][45];
llint dp[45][45][45];

int main(void)
{
	cin >> n;
	llint N = 2*n;
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= N; j++){
			cin >> c[i][j];
		}
	}
	
	for(int i = 2; i <= N; i++) dp[i][i][i] = 1;
	for(int len = 3; len <= N-1; len++){
		for(int l = 2; l+len-1 <= N; l++){
			int r = l+len-1;
			for(int k = l; k <= r; k++){
				
				for(int nl = l+1; nl <= k; nl++){
					for(int nr = k; nr <= r-1; nr++){
						for(int a = l; a < nl; a++){
							for(int b = nr+1; b <= r; b++){
								if(c[a][b] == '0') continue;
								dp[l][r][k] += dp[l][nl-1][a] * dp[nl][nr][k] * dp[nr+1][r][b];
							}
						}
					}
				}
				
			}
		}
	}
	
	llint ans = 0;
	for(int i = 2; i <= N; i++) if(c[1][i] == '1') ans += dp[2][N][i];
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] confrom = new int[n+1];
		int[] a = new int[n];
		int ma = 0;
		for(int i = 0; i < n; i++)
		{
			a[i] = sc.nextInt();
			
			confrom[a[i]] = confrom[a[i]-1]+1;
			ma = Math.max(ma, confrom[a[i]]);
		}
		System.out.println(n-ma);

	}

}


Measured memory_bytes: 86936
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end
def cnt(a,b)
  x = rot(a)
  y = rot(b)
  if($rnk[x] == $rnk[y])
    $per[x] = y
    $rnk[y] += 1
  elsif($rnk[x] < $rnk[y])
    $per[x] = y
  else
    $per[y] = x
  end
end

def jdg(a,b)
  rot(a) == rot(b)
end

def rot(x)
  saiki = []
  while(true)
    if $per[x] == x
      rotr = $per[x]
      break
    else
      saiki.push(x)
      x = $per[x]
    end
  end
  saiki.each do |d|
    $per[d] = rotr
  end
  return rotr
end


n = inp[0]
xt = []
n.times{|i|xt<<(inp + [i])}
xst = xt.sort_by{|u|u[0]}
yst = xt.sort_by{|u|u[1]}
lt = []
$per = na(n)
$rnk = na(n,0)
$per.size.times do |i|
  $per[i] = i
end
(n-1).times do |i|
  lt.push([xst[i+1][0]-xst[i][0],xst[i][2],xst[i+1][2]])
end
(n-1).times do |i|
  lt.push([yst[i+1][1]-yst[i][1],yst[i][2],yst[i+1][2]])
end
lt.sort_by!{|u|u[0]}
ans = 0
used = na(n,false)
lt.each do |c,r,l|
  next if(jdg(l,r))
  ans += c
  cnt(l,r)
end
p ans

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

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int main() {
    long long A, B;
    cin >> A >> B;
    cout << A / GCD(A, B) * B << endl;
}

Measured memory_bytes: 3644
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

var (
	reader io.Reader = os.Stdin
	writer io.Writer = os.Stdout
)

func main() {
	run()
}

func run() {
	// scanner := bufio.NewScanner(reader)
	// scanner.Scan()
	// S := scanner.Text()
	burReader := bufio.NewReaderSize(reader, 100000)
	buf := make([]byte, 0, 100000)

	for {
		line, isPrefix, err := burReader.ReadLine()

		if err != nil {
			if err.Error() == "EOF" {
				break
			}

			panic(err)
		}

		buf = append(buf, line...)

		if !isPrefix {
			break
		}
	}

	input := buf
	words := []string{"dream", "dreamer", "erase", "eraser"}

LOOP_MAIN:
	for i := len(input) - 1; i >= 0; {
	LOOP_WORDS:
		for _, word := range words {
			if len(word)-1 > i {
				continue
			}

			for j := 0; j < len(word); j++ {
				if word[len(word)-1-j] != input[i-j] {
					continue LOOP_WORDS
				}
			}

			// fmt.Println(i, word)
			i -= len(word)
			// fmt.Println(i, word)
			continue LOOP_MAIN
		}

		fmt.Fprintln(writer, "NO")
		return
	}
	fmt.Fprintln(writer, "YES")
}

func reverse(str string) string {
	runes := []rune(str)

	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}

	return string(runes)
}


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

int main(void)
{
	unsigned long long int a, b, c, d , c_ , d_;
	
	cin >> a >> b >> c >> d;

	c_ = b / c - (a - 1) / c;
	d_ = b / d - (a - 1) / d;

	if (c < d)
	{
		unsigned long long int tmp = c;
		c = d;
		d = tmp;
	}

	unsigned long long int r = c % d;
	unsigned long long int x = c * d;
	while (r != 0)
	{
		c = d;
		d = r;
		r = c % d;
	}
	r = x / d;
	r = b / r - (a - 1) / r;
	

	cout << ( b - a + 1 ) - ( c_ + d_ - r );

	return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;
import java.lang.*;
class Main{
  public static void main(String args[]){

    int id, k, l, r,p;
    StringBuilder build = new StringBuilder();
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Node node[] = new Node[n+1];

    for(int i = 1; i<n+1; i++){
      node[i] = new Node();
      node[i].key = sc.nextInt();
    }

    for(int i = 1; i<n+1; i++){
      System.out.print("node "+i+": key = "+node[i].key+", ");
      l = i*2;
      r =  i*2+1;
      p = i/2;
      if(p>=1)System.out.print("parent key = "+node[p].key+", ");
      // build.append("parent key = ").append(node[i].pk).append(", ");
      if(l<=n)System.out.print("left key = "+node[l].key+", ");
      // build.append("left key = ").append(node[i].lk).append(", ");
      if(r<=n)System.out.print("right key = "+node[r].key+", ");
      System.out.println("");
      // if(l<=n)node[i].lk = node[l].key;
      // if(r<=n)node[i].rk = node[r].key;
      // if(p>1)node[i].pk = node[p].key;

    }

    for(int i = 1 ; i < n; i++){
      // build.append("node ").append(node[i].id).append(": key =  ").append(node[i].key).append(", ");


      // build.append("right key = ").append(node[i].rk).append(", ");
      // build.append("\n");
    }

    // System.out.print(build);

  }
}

class Node{
  int id;
  int key;
  int pk = -1;
  int lk = -1;
  int rk = -1;
}



Measured memory_bytes: 27036
#pragma region
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
#pragma endregion

void solve() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  while (n) n /= k, ans++;
  cout << ans << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val students = (0 until n).map {
        val (x, y) = readLine()!!.split(' ').map { it.toInt() }
        x to y
    }
    val checkpoints = (0 until m).map {
        val (x, y) = readLine()!!.split(' ').map { it.toInt() }
        x to y
    }

    fun manhattan(p1: Pair<Int, Int>, p2: Pair<Int, Int>): Int {
        return Math.abs(p1.first - p2.first) + Math.abs(p1.second - p2.second)
    }

    for (student in students) {
        var no = 1
        var distance = manhattan(student, checkpoints.first())
        for (i in 1 until checkpoints.size) {
            val d = manhattan(student, checkpoints[i])
            if (d < distance) {
                no = i + 1
                distance = d
            }
        }
        println(no)
    }
}


Measured memory_bytes: 38184
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x3f3f3f3f
using namespace std;

int a[505][505], f[505][505];

int main()
{
	int n, m, q, l, r;
	scanf("%d%d%d", &n, &m, &q);
	for (int i = 1; i <= m; ++i) 
	{
		scanf("%d%d", &l, &r);
		a[l][r]++;
	}
	for (int i = 1; i <= n; ++i) f[i][i] = a[i][i];
	for (int i = 1; i <= n - 1; ++i) f[i][i + 1] = a[i][i + 1] + f[i + 1][i + 1] + f[i][i];
	for (int k = 2; k <= n - 1; ++k)
		for (int i = 1; i <= n - k; ++i) 
			f[i][i + k] = a[i][i + k] + f[i][i + k - 1] + f[i + 1][i + k] - f[i + 1][i + k - 1];
	for (int i = 1; i <= q; ++i)
	{
		scanf("%d%d", &l, &r);
		printf("%d\n", f[l][r]);
	}
	return 0;
}

Measured memory_bytes: 2944
N, C = map(int, input().split())
X = []
for _ in range(N):
    x, v = map(int, input().split())
    X.append((v, x))

A = [0] * (N+1)
B = [0] * (N+1)
MAA = [0] * (N+1)
MAB = [0] * (N+1)

for i in range(N):
    A[i+1] = A[i] + X[i][0] - (X[i][1] - (X[i-1][1] if i else 0))
    MAA[i+1] = max(MAA[i], A[i+1])

for i in range(N)[::-1]:
    B[i] = B[i+1] + X[i][0] + (X[i][1] - (X[i+1][1] if i < N-1 else C))
    MAB[i] = max(MAB[i+1], B[i])

ma = max(max(MAA), max(MAB))
for i in range(N):
    ma = max(ma, A[i+1] + MAB[i+1] - X[i][1])
    ma = max(ma, B[i] + MAA[i] + X[i][1] - C)

print(ma)

Measured memory_bytes: 62808
def dfs(v,t):
    d[v]=t
    t+=1
    for i in edge[v]:
        if d[i]==-1:
            t=dfs(i,t)
    f[v]=t
    t+=1
    return t

n=int(input())
edge=[[] for _ in range(n)]
for _ in range(n):
    u,_,*v=map(lambda x:int(x)-1,input().split())
    edge[u]=sorted(v)
d,f=[-1]*n,[-1]*n
k=1
for i in range(n):
    if d[i]==-1:
        k=dfs(i,k)
for i in range(n):
    print(i+1,d[i],f[i])



Measured memory_bytes: 5664
n,t = map(int,input().split())
lug = [int(input()) for i in range(n)]
right = sum(lug)+1
left = max(lug)-1

def is_ok(lug,t,a):#全ての荷物を積載量aで積めるかどうか
    truck_num = 1
    truck = 0
    for i in lug:
        if i > a:
            return False
        truck += i
        if truck ==a:#もしトラックにa分積まれてたらリセット
            truck = 0
            truck_num += 1
        elif truck > a:
            truck = i
            truck_num += 1
    if truck == 0:
        truck_num -= 1
    if truck_num > t:
        return False
    return True

while left+1 < right:
    center = (left + right)//2
    if is_ok(lug,t,center):
        right = center
    else:
        left = center
print(right)


Measured memory_bytes: 9564
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N=5500;
const int M=220;
int n,m,d[N][M],stack[N],L,R,l[N][M],r[N][M],num[N];
long long sq[N][N],ans,a[N];
int main(){
//	freopen("1.in","r",stdin);
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++)scanf("%lld",&a[i]);
	for(int i=1;i<n;i++)a[i]+=a[i-1];
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)scanf("%d",&d[i][j]);
	for(int j=1;j<=m;j++){
		L=0;R=0;
		for(int i=1;i<=n;i++){
			while(L&&stack[L]<d[i][j])L--;
			l[i][j]=L?num[L]+1:1;
			++L;
			stack[L]=d[i][j];
			num[L]=i;
		}
		for(int i=n;i>=1;i--){
			while(R&&stack[R]<d[i][j])R--;
			r[i][j]=R?num[R]-1:n;
			++R;
			stack[R]=d[i][j];
			num[R]=i;
		}
		for(int i=1;i<=n;i++){
			sq[l[i][j]][i]+=d[i][j];
			sq[l[i][j]][r[i][j]+1]-=d[i][j];
			sq[i+1][i]-=d[i][j];
			sq[i+1][r[i][j]+1]+=d[i][j];
		}
	}
	
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++)sq[i][j]+=sq[i][j-1];
		for(int j=i;j<=n;j++)sq[i][j]+=sq[i-1][j];
		for(int j=i;j<=n;j++)ans=max(ans,sq[i][j]-a[j-1]+a[i-1]);
	}
	
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 229760
import java.io.*;
import java.math.*;
import java.util.*;
public class Main{
 
	public static void main(String[] args) { 
		FastScanner input = new FastScanner();
		PrintWriter w = new PrintWriter(System.out);
		long N = input.nextLong();
		long M = input.nextLong();
		String S = input.next();
		String T = input.next(); //Skip first char of both given strings 
		boolean bad=false;
		if (S.charAt(0)!=T.charAt(0)) bad=true;
		long ans = N*M;
		ans/=GCD(N,M); //Indirect LCM calculation
		long checkN = ans/N;
		long checkM = ans/M;
		for (long check = 1; check < N; check++) {
			if ((checkN*check)%checkM==0) {
				long val = checkN*check;
				val/=checkM;
				int i = (int)(val);
				if (val<M&&T.charAt(i)!=S.charAt((int)(check))) {
					bad=true;
					break;
				}
			}
		}
		w.println(bad?-1:ans);
		w.flush();
	}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 29360
from math import pow
from itertools import combinations
x = int(input())

def func(a, b):
    return pow(a, 5) - pow(b,5)

ok = False
for a in range(-200, 200):
    for b in range(-200, 200):
        if func(a, b) == x:
            print(a, b)
            ok = True
            break
    if ok:
        break


    

Measured memory_bytes: 65952
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib> 
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
using namespace std;

int main() {
	string x, y;
	cin >> x >> y;
	
	string flip_x = {x[2], x[1], x[0]};
	
	if (flip_x == y) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

const LL MOD = 1000000007;
LL combi(LL N_, LL C_) {
	const int NUM_ = 400001;
	static LL fact[NUM_ + 1], factr[NUM_ + 1], inv[NUM_ + 1];
	if (fact[0] == 0) {
		inv[1] = fact[0] = factr[0] = 1;
		for (int i = 2; i <= NUM_; ++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i%MOD, factr[i] = factr[i - 1] * inv[i] % MOD;
	}
	if (C_<0 || C_>N_) return 0;
	return factr[C_] * fact[N_] % MOD*factr[N_ - C_] % MOD;
}

LL hcomb(int P_, int Q_) { return (P_ == 0 && Q_ == 0) ? 1 : combi(P_ + Q_ - 1, Q_); }

LL modpow(LL a, LL n = MOD - 2) {
	LL r = 1;
	while (n) r = r*((n % 2) ? a : 1) % MOD, a = a*a%MOD, n >>= 1;
	return r;
}

int h, w, a, b;

int main() {
	cin >> h >> w >> a >> b;
	LL ans = 0;
	for (int i = 0; i <= h - a; i++) {
		ans += combi(b + i - 2, i - 1) % MOD*combi(w - b - 1 + h - i, h - i) % MOD;
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 9600
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false); cin.tie(0);
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const int nmax = 1e5 + 10;
int n;
int a[nmax];
ll f[nmax];
int main() {
    IO;
  
    cin >> n;
    a[0] = 0;
    for (int i = 1; i <= n; i++) cin >> a[i];
    a[n + 1] = 0;
    f[0] = 0;
    for (int i = 1; i <= n + 1; i++) 
        f[i] = f[i - 1] + abs(a[i] - a[i - 1]);
    for (int i = 1; i <= n; i++) {
        ll res = f[i - 1] + f[n + 1] - f[i + 1] + abs(a[i + 1] - a[i - 1]);
        cout << res << "\n";
    }
    return 0;
}


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

#include <iomanip>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
// #define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const ll INF = 1e17;
ll dp[100005][13];

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

signed main(void) {
  ll H, N;
  cin >> H >> N;
  vector<ll> A(N);
  ll ans = 0;
  rep(i, N) {
    cin >> A[i];
    ans += A[i];
  }

  if (ans >= H) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  // cout << ans << endl;
}


Measured memory_bytes: 1024
from fractions import gcd
a,b,c,d = map(int, input().split())

lcm = (c*d)//gcd(c,d)

x = ((a-1)//c)+((a-1)//d)-((a-1)//lcm)
y = (b//c)+(b//d)-(b//lcm)

print((b-(a-1))-(y-x))


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

using namespace std;

const int MAXN = 1e6 + 10;

vector<int> adj[MAXN];
vector<long long> val(MAXN);
vector<bool> vis(MAXN);
vector<int> par(MAXN);

void bfs(int s) {
	queue<int> q;
	q.push(s);
	vis[s] = true;
	while(!q.empty()) {
		s = q.front();
		q.pop();
		for(auto i : adj[s]) {
			if(!vis[i]) {
				vis[i] = true;
				val[i] += val[s];
				q.push(i);
			}
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	int n, q;
	cin >> n >> q;

	int u, v;

	for(int i = 1; i < n; i++) {
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	while(q--) {
		int x, c;
		cin >> x >> c;
		val[x] += c;
	}

	//for(int i = 1; i <= n; i++) cout << val[i] << ' ';

	bfs(1);

	for(int i = 1; i <= n; i++) cout << val[i] << ' ';

	return 0;
}

Measured memory_bytes: 45300
n=int(input())
b=[int(x) for x in input().split()]
a=[0]*n
for i in range(n-1,-1,-1):
    if i==n-1:
        a[i]=b[i-1]
    elif i==0:
        a[i]=b[i]
    else:
        if b[i]<b[i-1]:
            a[i]=b[i]                                                                                                                                                                                                                                                                                                                           
        else:
            a[i]=b[i-1]
print(sum(a))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,m;
int g[55][55],f[55][55];
int floyed()
{
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(i==j)
				f[i][j]=0;
			else if(g[i][j]==1)
				f[i][j]=1;
			else
				f[i][j]=1234;
	for(int k=0;k<n;k++)
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
	for(int i=0;i<n;i++)
		for(int j=0;j<i;j++)
			if(f[i][j]>123)
				return 1;
	return 0; 
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a][b]=g[b][a]=1;
	}
	int ans=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<i;j++)
			if(g[i][j]==1)
			{
				g[i][j]=g[j][i]=0;
				ans+=floyed();
				g[i][j]=g[j][i]=1;
			}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n;
  cin >> n;
  if (n < 1000) cout << "ABC" << endl;
  else cout << "ABD" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define print(x) cout << (x) << endl;
int main() {
    int K, S, count = 0;
    cin >> K >> S;
    for (int i = 0; i <= K; i++) {
        for (int j = 0; j <= K; j++) {
            if (S - i - j + 1 > 0 && S - i - j - 1 < K) count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
int n,h,w,sum=0;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 
	cin>>n>>h>>w;
 
	sum+=(n-h+1)*(n-w+1);
	cout<<sum;
	return 0;
}

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

using namespace std;

int dp[5001][5001];

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;

    for(int i = N-1; i >= 0; i--){
        for(int j = N-1; j >= 0; j--){
            if(S[i] != S[j]){
                dp[i][j] = 0;
            }else{
                dp[i][j] = dp[i+1][j+1] + 1;
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i >= j){
                continue;
            }else{
                int now = min(dp[i][j], j-i);
                ans = max(ans, now);
            }
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 97920
import java.util.*

fun main(args : Array<String>) {
    val sc = Scanner(System.`in`)
    val k = sc.nextLong()
    val x = sc.nextLong()
    println(problem137b(k, x))
}

fun problem137b(k: Long, x: Long): String {
    return (x - k + 1 until x + k).joinToString( " ")
}

Measured memory_bytes: 31524
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            List<ClsPot> lstPot = new List<ClsPot>() { new ClsPot() { iT = 0, iX = 0, iY = 0 } };
            for (int i = 0; i < iN; i++)
            {
                sS = Console.ReadLine().Trim().Split(' ');
                ClsPot oneUsr = new ClsPot();
                oneUsr.iT = int.Parse(sS[0]);                       // t秒後
                oneUsr.iX = int.Parse(sS[1]);                       // X
                oneUsr.iY = int.Parse(sS[2]);                       // Y
                lstPot.Add(oneUsr);                                 // 点一覧
            }
            //// Debug入力
            //int iN = 100000;
            //List<ClsPot> lstPot = new List<ClsPot>() { new ClsPot() { iT = 0, iX = 0, iY = 0 } };
            //for (int i = 1; i <= iN; i++)
            //{
            //    ClsPot oneUsr = new ClsPot();
            //    oneUsr.iT = i * 2;                                  // t秒後
            //    oneUsr.iX = i;                                      // X
            //    oneUsr.iY = i;                                      // Y
            //    lstPot.Add(oneUsr);                                 // 点一覧
            //}

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

            // 解析
            string sOut = "Yes";
            int iSt = lstPot[0].iT;                                 // 移動元
            int iSx = lstPot[0].iX;                                 // 移動元
            int iSy = lstPot[0].iY;                                 // 移動元
            for (int i = 1; i < lstPot.Count; i++)
            {
                int iNt = lstPot[i].iT - iSt;                       // 移動時間
                int iNx = lstPot[i].iX;                             // 移動先
                int iNy = lstPot[i].iY;                             // 移動先
                int iD = Math.Abs(iNx - iSx) + Math.Abs(iNy - iSy); // 2点間距離 (x1,y1) と (x2,y2) 間のマンハッタン距離は |x1-x2|+|y1-y2|
                if (iD > iNt) { sOut = "No"; break; }               // 移動時間以上の距離はダメ
                if ((iNt - iD) % 2 != 0) { sOut = "No"; break; }    // 最終的に移動先に到着出来ないとダメ
                iSt = lstPot[i].iT;
                iSx = iNx;
                iSy = iNy;
            }

            // 出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

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

        // 点情報
        private class ClsPot
        {
            public int iT { get; set; } = 0;
            public int iX { get; set; } = 0;
            public int iY { get; set; } = 0;
        }

}


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


import itertools


INT_END = 10 ** 5 + 1


def sieve_of_eratosthenes(end, typecode="L"):
    """Enumerates the prime numbers below the given integer.

    :param int end: Prime numbers below this integer will be enumerated.
    :param str typecode: The type of the array to be returned (optional).
    :return: The array of the prime numbers.
    :rtype: :class:`array.array`
    """

    assert end > 1
    is_prime = [True for i in range(end)]
    is_prime[0] = False
    is_prime[1] = False
    # primes = array.array(typecode)
    for i in range(2, end):
        if is_prime[i]:
            # primes.append(i)
            for j in range(2 * i, end, i):
                is_prime[j] = False
    # return primes
    return is_prime


class CumulativeSum(object):
    """Constructs the cumulative sum of the elements in the given sequence.

    :param sequence: The sequence to be processed.
    :type sequence: sequence
    """

    def __init__(self, sequence):
        self.cumulative_sum = [0]
        self.cumulative_sum.extend(itertools.accumulate(sequence))

    def partial_sum(self, first, last):
        """Computes the partial sum of the sequence.

        :param first: The index representing the first element of the
                      subsequence.
        :type first: int
        :param last: The index representing the last element of the
                     subsequence.
        :return: The partial sum.
        """
        return self.cumulative_sum[last + 1] - self.cumulative_sum[first]


def enumerate_like_number(end=INT_END):
    is_prime = sieve_of_eratosthenes(end)
    is_like = [False for _ in range(end)]
    for i in range(1, end, 2):
        if is_prime[i] and is_prime[(i + 1) // 2]:
            is_like[i] = True
    return is_like


def main():
    q = int(input())
    cs = CumulativeSum(enumerate_like_number())
    for _ in range(q):
        l, r = (int(z) for z in input().split())
        print(cs.partial_sum(l, r))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6820
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        if (a.equals(b)) {
            System.out.println("H");
        } else {
            System.out.println("D");
        }

    }

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define FOR(i,b,e) for(int i=(b);i<(e);++i)

using namespace std;
int main(void){
  int cnt1=0,cnt2=0;
  string S;  cin>>S;

  FOR(i,0,S.length() ){
    if(i%2==0){
      if(S[i]=='0'){
        cnt1++;
      }else{
        cnt2++;
      }
    }else{                      // if(i%2==1){}
      if(S[i]=='1'){
        cnt1++;
      }else{
        cnt2++;
      }
    }
  }
  cout<<min(cnt1,cnt2)<<endl;
  return 0;
}



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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

#define MOD 1000000007
#define INF 1000000000000000ull
#define MAX_V 210

ll N, M, R;
vector<ll> visit;
ll d[MAX_V][MAX_V];    // d[u][v] は辺 e=(u,v) のコスト(存在しない場合は INF、ただし d[i][i]=0 とする)
ll V;                  // 頂点数

int main()
{
    cin >> N >> M >> R;
    V = N;
    // 初期化
    REP(i, V+1) { REP(j, V+1) { d[i][j] = (i==j) ? 0 : INF; }}
    REP(i, R) {
        ll r;
        cin >> r;
        visit.push_back(r);
    }
    REP(i, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        d[a][b] = c;
        d[b][a] = c;
    }
    // ワーシャルフロイド
    REP(k, V+1) {
        REP(i, V+1) {
            REP(j, V+1) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    // 訪れる順番を全パターン試す
    ll ans = INF;
    SORT(visit);
    do {
        ll tmp = 0;
        REP(i, R-1) {
            tmp += d[visit[i]][visit[i+1]];
        }
        ans = min(ans, tmp);
    } while( next_permutation(visit.begin(), visit.end()) );
    printf("%lld\n", ans);


    return 0;
}


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

int main(void){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a+b > c+d){
        cout << "Left" << endl; 
    }else if(a+b == c+d){
        cout << "Balanced" << endl;
    }else{
        cout << "Right" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                void solve(){
                    ll n;
                    cin>>n;
                    string str;
                    cin>>str;
                    ll ans = INF, temp = 0;
                    for(int i = 0; i < n; i++)
                        temp += str[i]=='W';
                    ans = min(ans, temp);
                    // cout<<ans;   
                    temp = 0;
                    for(int i = 0; i < n; i++)
                        temp += str[i]=='R';
                    ans = min(ans, temp);
                    // cout<<ans;
                    ll red = temp, temp2 = 0;
                    for(int i = 0; i <temp; i++)
                        temp2 += str[i]=='W';
                    ans = min(ans, temp2);
                    cout<<ans;
                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //cout<<"Case #"<<i<<": ";
                                solve();
                         }
        return 0; 
}         
 
 

Measured memory_bytes: 3764
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int n=s.nextInt()+1,m=n/2,a,b,i=s.nextInt();i-->0;)System.out.println((m-1-Math.max(Math.abs((a=s.nextInt()-m)>0&&n%2>0?a-1:a),Math.abs((b=s.nextInt()-m)>0&&n%2>0?b-1:b)))%3+1);}}

Measured memory_bytes: 12000
import numpy as np
a,b = map(int,input().split())
if (a*10**b) > (b*10**a):
    print(int(a * (10**(b-1) + 10**(b-2) + 10**(b-3) + 10**(b-4) + 10**(b-5) + 10**(b-6) + 10**(b-7) + 10**(b-8) + 10**(b-9))))
else:
    print(int(b * (10**(a-1) + 10**(a-2) + 10**(a-3) + 10**(a-4) + 10**(a-5) + 10**(a-6) + 10**(a-7) + 10**(a-8) + 10**(a-9))))

Measured memory_bytes: 12392