akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long k = sc.nextLong();
        if (k % 2 == 1) {
            System.out.println(b - a);
        } else {
            System.out.println(a - b);
        }
    }

}

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

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

    int n;
    cin >> n;
    double middle = 0;
    vector<int> pos(n);
    for (int i = 0; i < n; i++) {
        cin >> pos.at(i);
        middle += pos.at(i);
    }

    // get middle pos
    // cout << middle << ", " << middle / pos.size() << endl;
    int middle_pos = 0;
    if (((int)(middle * 10 / pos.size())) % 10 >= 5) {
        middle_pos = middle / pos.size() + 1;
    } else {
        middle_pos = middle = middle / pos.size();
    }
    // cout << middle_pos << endl;

    long ans = 0;
    for (size_t i = 0; i < pos.size(); i++) {
        ans += pow((pos.at(i) - middle_pos), 2);
    }
    cout << ans << endl;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    vector<int> b(m);
    vector<int> c(n,0);
    for(int i = 0; i < m; i++){
        cin >> a.at(i) >> b.at(i);
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(a.at(j) == i+1 || b.at(j) == i+1){
                c.at(i) += 1;
            }
        }
    }
    for(int i = 0; i < n; i++){
        cout << c.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[1000];
	int i;
	
	scanf("%[^\n]", str);
	for (i = 0; i < strlen(str); i++){
		if (('a' <= str[i]) && (str[i] <= 'z')){
			str[i] -= 0x20;
		}
	}
	printf("%s\n", str);

	
	return (0);
}

Measured memory_bytes: 0
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())))[a-x:]
q = sorted(list(map(int, input().split())))[b-y:]
r = sorted(list(map(int, input().split()))+p+q)[::-1]

print(sum(r[:x+y]))


Measured memory_bytes: 110188
N = int(input())

for i in range(N):
 A,T = map(int,input().split())
 if(i == 0):
  now_A,now_T = A,T
 else:
  if((now_A<=A)and(now_T<=T)):
    now_A,now_T = A,T
  else: #上のはこっちにまとめられる
    if(now_A%A == 0): tmp1 = now_A//A
    else: tmp1 = now_A//A + 1
    if(now_T%T == 0): tmp2 = now_T//T
    else: tmp2 = now_T//T + 1
    tmp = max(tmp1,tmp2)
    now_A,now_T = tmp*A,tmp*T
ans = now_A + now_T
print(ans)

Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

//func nextString() string {
//	sc.Scan()
//	return sc.Text()
//}

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func main() {
	nextInt()
	M := nextInt()
	L := 0
	R := 10000000
	for i := 0; i < M; i++ {
		l := nextInt()
		r := nextInt()
		L = max(L, l)
		R = min(R, r)
	}
	if R-L >= 0 {
		fmt.Println(R - L + 1)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 3948
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
constexpr LL LINF = 9000000000000000000;
LL f(LL b, LL n) {
	if (n < b)return n;
	else return f(b, n / b) + n%b;
}

int main() {
	LL n, s;
	cin >> n >> s;
	LL i = 2;
	for (; i <= sqrt(n); i++) {
		if (f(i, n) == s) {
			cout << i << endl;
			return 0;
		}
	}
	LL a = n - s;
	if (a < 0) {
		cout << -1 << endl;
		return 0;
	}
	else if (a == 0) {
		cout << n + 1 << endl;
		return 0;
	}
	LL ans = LINF;
	for (; i >= 1; i--) {
		if (a%i != 0)continue;
		LL b = a / i + 1;
		if (f(b, n) == s) {
			ans = min(ans, b);
		}
	}
	if (ans != LINF) {
		cout << ans << endl;
	}
	else {
		cout << -1 << endl;
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

int n, m;
ll ans = 0;
vector<bool> load;
vector<vector<int>> vec;

void dfs(int now, int cnt) {
  load[now] = true;
  cnt++;
  
  if (cnt == n) {
    ans++;
  }
  
  for (auto itr = vec[now].begin(); itr != vec[now].end(); itr++) {
    if (load[*itr]) {
      continue;
    }
    dfs(*itr, cnt);
  }
  load[now] = false;
  cnt--;
}

int main()
{
  cin >> n >> m;
  load.resize(n, false);
  vec.resize(n);
  for (int i = 0; i < m; i++) {
    int from, to;
    cin >> from >> to;
    from--;
    to--;
    vec[from].push_back(to);
    vec[to].push_back(from);
  }
  
  dfs(0, 0);
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import math
import copy

neko = 0

n,a,b = map(int,input().split())
nya =0

for i in range(1,n+1):
    if i:
        nya += i%10
    if i >= 10:
        nya += i//10%10
    if i >= 100:
        nya += i//100%10
    if i >= 1000:
        nya += i//1000%10
    if 10000 == i:
        nya += 1
    if (a<=nya)and(nya<=b):
        neko += i
    nya = 0
print(neko)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    string s, t;
    cin >> s;
    cin >> t;
    ll ans = s.size();
    for (int i = 0; i < s.size() - t.size() + 1; i++) {
        ll count = 0;
        for (int j = 0; j < t.size(); j++) {
            if (s[i + j] != t[j]) count++;
        }
        ans = min(ans, count);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define LL long long
#define INF 1e9
#define eps 1e-9
#define PI acos(-1.0)
#define  Exp 2.7182818284
using namespace std;
const int maxn=123456;
int n;
struct he{
int id,sum;
}ai[maxn],bi[maxn];

bool cmp(he a,he b){
    if(a.sum!=b.sum)
        return a.sum>b.sum;
    return a.id<b.id;
}
void init(){
    for(int i=1;i<=100000;i++){
        ai[i].sum=0;
        bi[i].sum=0;
        ai[i].id=i;
        bi[i].id=i;
    }
    for(int i=1;i<=n;i++){
        int v;
        scanf("%d",&v);

        if(i%2==1)
            ai[v].sum++;
        else bi[v].sum++;
    }
}

void play(){
    sort(ai+1,ai+1+100000,cmp);
    sort(bi+1,bi+1+100000,cmp);

    int ans=INF;
    for(int i=1;i<=2;i++){
        for(int j=1;j<=2;j++){

            if(ai[i].id==bi[j].id)continue;

            ans=min(ans,n-ai[i].sum-bi[j].sum);
        }
    }
    printf("%d\n",ans);


}

void Pri(){


}



int main() {



    while(scanf("%d",&n)!=EOF){
        init();
        play();
        Pri();



    }




    return 0;

}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
        using namespace std;
         
        int main(){
          string n;
          cin >> n;
          if(n.at(0)=='1')cout << '9';
          else if(n.at(0)=='9')cout << '1';
          else cout << n.at(0);
          if(n.at(1)=='1')cout << '9';
          else if(n.at(1)=='9')cout << '1';
          else cout << n.at(1);
          if(n.at(2)=='1')cout << '9';
          else if(n.at(2)=='9')cout << '1';
          else cout << n.at(2);
          cout << endl;
          return 0;
        }

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    def dot(aa, bb):
        return [[sum(a * b for a, b in zip(ar, bc)) % md for bc in zip(*bb)] for ar in aa]

    md = 10 ** 9 + 7
    n, k = MI()
    aa = LLI(n)
    ans=[[(i==j)*1 for j in range(n)] for i in range(n)]
    while k:
        if k & 1:
            ans = dot(ans, aa)
        aa = dot(aa, aa)
        k >>= 1
    # print(ans)
    print(sum(sum(ar) for ar in ans) % md)

main()


Measured memory_bytes: 3372
n = input()

m=int(n)
count = 0

def num753(start,n):
  global count
  if len(start) > len(n):
    return
  if int(start+"3") <= int(n) and "7" in start+"3" and "5" in start+"3" and "3" in start+"3":
    count +=1
  if int(start+"5") <= int(n) and "7" in start+"5" and "5" in start+"5" and "3" in start+"5":
    count +=1
  if int(start+"7") <= int(n) and "7" in start+"7" and "5" in start+"7" and "3" in start+"7":
    count +=1
    
  num753(start+"3",n)
  num753(start+"5",n)
  num753(start+"7",n)
  
  return count

print(num753("",n))

Measured memory_bytes: 3188
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> // pair
#include <cmath>   // modfに必要

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

template <class InputIterator, class T>
bool contains(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// =========ここまでテンプレ============

int main()
{
    ll a, b, n;
    cin >> a >> b >> n;
    ll k = min(n, b - 1);
    // if (n < b - 1)
    // {
    //     double m = (double)(min(n, b - 1)) / (double)b;
    //     float integral_part = 0;
    //     double fractional_part = modf(m, &integral_part);
    //     cout << floor(a * fractional_part);
    // }
    // else
    // {
    ll result = (a * k) / b;
    cout << result;
    // }
}

// 与式は floor(A*((x/B)%1)) と同じ。
// つまり x/B の小数部分を最大にすればいい。
// それはつまり min(n, B-1) /B

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  while(1){
    cin>>h>>w;
    if(h==0&&w==0) break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cout<<"#";
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return(0);
}

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

int main() {
  std::string S; std::cin >> S;
  if(S == "SUN") { std::cout << 7 << std::endl; return 0; }
  if(S == "MON") { std::cout << 6 << std::endl; return 0; }
  if(S == "TUE") { std::cout << 5 << std::endl; return 0; }
  if(S == "WED") { std::cout << 4 << std::endl; return 0; }
  if(S == "THU") { std::cout << 3 << std::endl; return 0; }
  if(S == "FRI") { std::cout << 2 << std::endl; return 0; }
  if(S == "SAT") { std::cout << 1 << std::endl; return 0; }
  return 1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 300001;
long long dp[3001];
int main(){
	// ios_base::sync_with_stdio(0), cin.tie(0);
	int r, g, b, n;
	dp[0] = 1;
	cin >> r >> g >> b >> n;
	for(int i = r;i <= n;++i){
		if(dp[i - r])dp[i] += dp[i - r];
	}
	for(int i = g;i <= n;++i){
		if(dp[i - g])dp[i] += dp[i - g];
	}
	for(int i = b;i <= n;++i){
		if(dp[i - b])dp[i] += dp[i - b];
	}
	cout << dp[n];
}

Measured memory_bytes: 256
#include<stdio.h>
main()
{
    int n,i,j,p=0,c=0;
    scanf("%d",&n);
    int s[n];
    scanf("%d",&s[0]);
    p=s[0];
    c++;
    for(i=1;i<n;i++){
        scanf("%d",&s[i]);
        if(s[i]<=p){
            p=s[i];
            c++;
        }
    }
    printf("%d\n",c);
}


Measured memory_bytes: 2504
#include <stdio.h>

int main() {
  int n, r, p, c;
  int cards[50], temp[50];
  int i, j;

  while(1) {
    scanf("%d %d", &n, &r);
    if(n == 0 && r == 0) break;

    for(i = 0; i < 50; i++) {
      cards[i] = i + 1;
    }
    for(i = 0; i < r; i++) {
      scanf("%d %d", &p, &c);
      for(j = 0; j < c; j++) {
	temp[j] = cards[n - (c + p - 1) + j];
      }
      for(j = 0; j < p - 1; j++) {
	cards[n - (c + p - 1) + j] = cards[n - (p - 1) + j];
      }
      for(j = 0; j < c; j++) {
	cards[n - c + j] = temp[j];
      }
    }
    printf("%d\n", cards[n-1]);
  }
  return 0;
}

Measured memory_bytes: 0
#include<cstdio>
int n;
char s[100005];
bool a[3], t[2];
int main(){
  scanf("%d %s", &n, s);
  for(int i = 0; i < n; i++) a[i%3] ^= s[i] == 'o';
  if(n%3 == 0 && (a[0] != a[1] || a[1] != a[2])){
    printf("-1");
    return 0;
  }
  t[0] = a[0]^a[n%3];
  t[1] = a[1]^a[(n-2)%3]^(s[0] == 'o');
  printf("%c%c", t[0] ? 'S' : 'W', t[1] ? 'S' : 'W');
  for(int i = 2; i < n; i++){
    t[i&1] = t[0]^t[1]^(s[i-1] == 'o');
    printf("%c", t[i&1] ? 'S' : 'W');
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define INF 100000000;
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int r, D, x;
	cin >> r >> D >> x;
	REP(i, 10) {
		int val = r * x - D;
		cout << val << endl;
		x = val;
	}
	return 0;
}

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

using namespace std;


int main(void){
  string str;
  cin>>str;
  int cnt=0;
  string res="";
  for(int i = 0 ; i < str.size() ; i++){
    if(str[i]=='A'){
      cnt++;
    }
    if(str[i]=='Z'&&cnt>0){
      res+="AZ";
      cnt =0;
    }
  }
  if(res=="")cout<<-1<<endl;
  else   cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 1192
///apigs property
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define F first
#define S second
#define pb push_back
#define vll vector< ll >
#define vi vector< int >
#define pll pair< ll , ll >
#define pi pair< int , int >
#define all(s) s.begin() , s.end()
using namespace std;
typedef long long ll;
ll q, dp[105][100005], a[555555] , b[555555], k, l, m, n, o, p;
map < ll , ll > mp;
vll adj[555555];
const ll mod = 1e9+7;
ll mem(ll idx , ll ct){
	if(idx == n + 1){
		if(ct != 0)ct = 1e18;
		return ct;
	}
	ll &r = dp[idx][ct];
	if(r != -1)return r;
	return r = min(mem(idx + 1 , ct - b[idx]) + a[idx] , mem(idx + 1 , ct));
}
int main() {
	memset(dp , -1 , sizeof dp);
    fast , cin >> n >> m;
    for(ll i = 1 ; i <= n ; i++){
    	cin >> a[i] >> b[i];
	}
	for(ll i = 1e5 ; i >= 0 ; i--){
		k = mem(1 , i);
		if(k <= m){
			return cout << i , 0;
		}
	}
	cout << k << endl;
}

Measured memory_bytes: 98692
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()
	l := scanInts(n)

	sort.Ints(l)

	ans := 0
	for i := 0; i < n; i++ {
		for j := i+1; j < n-1; j++ {
			ab := l[i]+l[j]
			index := bs(ab, l[j+1:])
			if l[index+j+1] < ab {
				ans += index+1
			}
		}
	}

	fmt.Println(ans)
}

func bs(t int, a []int) int {
	l, r := 0, len(a)
	for r-l > 1 {
		mid := (r+l)/2
		if a[mid] < t {
			l = mid
		} else {
			r = mid
		}
	}
	return l
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
from collections import defaultdict

# 切り離す必要があるものを辺として、二部グラフの判定
N,M = map(int,input().split())

# 補グラフ
graph = [set(x for x in range(N) if x != y) for y in range(N)]
for _ in range(M):
    a,b = map(lambda x: int(x) - 1,input().split())
    graph[a].remove(b)
    graph[b].remove(a)

color = [None] * N
size = defaultdict(lambda: [0,0])

def set_color(root,x,c):
    size[root][c] += 1
    color[x] = c
    for y in graph[x]:
        if color[y] is None:
            set_color(root,y,1-c)
        elif color[y] == color[x]:
            print(-1)
            exit()

for x in range(N):
    if color[x] is None:
        set_color(x,x,0)

# 二部グラフになるべく平均的に分けたい
# 可能なサイズの集合を持つ

se = {0}
for x,y in size.values():
    se = set(s + x for s in se) | set(s + y for s in se)

answer = min(x*(x-1)//2+(N-x)*(N-x-1)//2 for x in se)
print(answer)

Measured memory_bytes: 36720
s=chomp(readline())
t=chomp(readline())
A=String[]
for i=1:length(s)-length(t)+1
	flag=true
	for j=1:length(t)
		if s[i+j-1]!='?'&&s[i+j-1]!=t[j]
			flag=false
		end
	end
	if flag
		push!(A,join(i<=k<i+length(t) ? t[k-i+1] : s[k]=='?' ? 'a' : s[k] for k=1:length(s)))
	end
end
println(isempty(A) ? "UNRESTORABLE" : minimum(A))


Measured memory_bytes: 113912
n = int(input())
c = [int(input()) for i in range(n)]
num,x = 1,[0]*(200001)
c.append(0)
x[c[0]]+=1
for i in range(1,n):
    if c[i]-c[i-1]: x[c[i]] = (x[c[i]]+num)%(10**9+7)
    if c[i]-c[i+1]: num = x[c[i]]
    else: num = 0
print(num)

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

using namespace std;

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

  string n;
  cin >> n;
  if (n[0] == '9' || n[1] == '9') {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


Measured memory_bytes: 256
m=24*60*60
while True:
	n=int(input())
	if n==0:break
	dp=[0]*(m+1)
	for _ in range(n):
		a,d=input().split()
		a,b,c=map(int,a.split(':'));
		d,e,f=map(int,d.split(':'));
		dp[a*3600+b*60+c]+=1
		dp[d*3600+e*60+f]-=1
	for i in range(m):
		dp[i+1]+=dp[i]
	print(max(dp))

Measured memory_bytes: 11500
attrs = Array.new
while line = $stdin.gets
    attrs << line.chomp.split.map{|v| v.to_i }
end

N = (attrs.shift)[0]
A = attrs.shift
h = {}
if N == 1 then
  puts 1
else
  for i in 1..N do
    h[ A[i - 1] ] = i
  end
  result = ""
  for i in 1..N do
    result << h[i].to_s
    result << " " unless i == N
  end

  puts result
end

Measured memory_bytes: 18956
N = int(input())
S = input()
Lw = [0]*N
Le = [0]*N

cw = 0
ce = 0
for i in range(N):
  if S[i] == "W":
    cw += 1
  Lw[i] = cw
  if S[N - 1 - i] == "E":
    ce += 1
  Le[N-1-i] = ce

min = min(Le[1], Lw[N-2])
for i in range(1, N-1):
  p = Le[i + 1] + Lw[i - 1]
  if p < min:
    min = p

print(min)

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

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	long r = 0;
	for (int b = k + 1; b <= n; b++)
		r += k ? n / b * (b - k) + max(0, n%b + 1 - k) : n;
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a, b, c;
	{
		scanf("%d %d %d", &a, &b, &c);
		if (a == 1 && b == 1 || c == 1)
		{
			printf("Open\n");
		}
		else
		{
			printf("Close\n");
		}
	}
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#define INF 1000000000000000
using namespace std;

int search_index(long long x, long long* A, int n) {
  // return i s.t. A[i] < x < A[i+1]
  // if x < A[0] return -1
  // if A[n-1] < x return n
  int left, right, mid;
  left = 0; right = n-1;
  while (true) {
    mid = (left + right) / 2;
    if (A[mid] < x && x < A[mid+1]) return mid;
    if (A[mid] < x) {
      left = mid+1;
    } else {
      right = mid-1;
    }
  }
}

long long min(long long a, long long b) {
  if (a < b) return a;
  return b;
}
/*
long long abs(long long a) {
  if (a < 0) return -a;
  return a;
}
*/

int main() {
  int A, B, Q;
  cin >> A >> B >> Q;

  long long S[A+2], T[B+2], x;
  for (int i=1; i<A+1; i++) cin >> S[i];
  for (int i=1; i<B+1; i++) cin >> T[i];
  S[A+1] = T[B+1] = INF;
  S[0] = T[0] = -INF;

  int A_i, B_i;
  long long a[2], b[2], ans;
  for (int i=0; i<Q; i++) {
    ans = INF;
    cin >> x;
    A_i = search_index(x, S, A+2);
    B_i = search_index(x, T, B+2);
    a[0] = S[A_i]; a[1] = S[A_i+1];
    b[0] = T[B_i]; b[1] = T[B_i+1];
    for (int j=0; j<2; j++) {
      for (int k=0; k<2; k++) {
        long long d1 = abs(a[j] - x) + abs(b[k] - a[j]);
        long long d2 = abs(b[k] - x) + abs(a[j] - b[k]);
        ans = min(ans, min(d1, d2));
      }
    }
    cout << ans << endl;
  }
}


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

const int N = 111111;
vector<int> tree[N];
int distBlack[N];
int distWhite[N];
int n;

void dfs(int node, bool black, int p = 0, int dist = 0) {
    if(black) distBlack[node] = dist;
    else distWhite[node] = dist;
    for(nnode : tree[node]) {
        if(nnode != p) {
            dfs(nnode, black, node, dist + 1);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    dfs(1, true);
    dfs(n, false);
    int cb = 0, cw = 0;
    for(int i = 1; i <= n; i++) {
        if(distBlack[i] <= distWhite[i]) {
            cb++;
        } else {
            cw++;
        }
    }
    cout << (cb > cw ? "Fennec" : "Snuke") << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll N; cin >> N;
  vector<char> name;
  while (N > 0) {
    name.push_back('a'+(N-1)%26);
    N = (N-1)/26;
  }

  reverse(name.begin(), name.end());
  for (auto c : name) {
    cout << c;
  }
  cout << endl;
  
  return 0;
}




Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)

int mt[100][100];
int w,h;
vector<pair<int,int> > block;


void saiki(int y,int x){
	rep(i,block.size())
		if(y==block[i].first && x==block[i].second){
			mt[y][x]=0;
			return;
		}
	if(x-1>=0 && y-1>=0)mt[y][x]=mt[y][x-1]+mt[y-1][x];
	else if(x-1>=0)mt[y][x]=1;
	else if(y-1>=0)mt[y][x]=1;

	if(y==h-1 && x==w-1)return;
	
	if(x+1<w)saiki(y,x+1);
	if(y+1<h)saiki(y+1,x);
}

int main(){
	int n,x,y;
	while(cin >> w >> h && w && h){
		block.clear();
		
		cin >> n;
		for(int i=0;i<n;i++){
			cin >> x >> y;
			x--;y--;
			block.push_back( pair<int,int>(y,x) );
		}
		rep(i,100)rep(j,100)mt[i][j]=0;
		mt[0][0]=1;
		saiki(0,0);
		cout << mt[h-1][w-1] << endl;
	}
}

Measured memory_bytes: 940
h,w,m=map(int,input().split())
HH=[0 for i in range(h+1)]
WW=[0 for i in range(w+1)]
Q=[]
for i in range(m):
    a,b=map(int,input().split())
    HH[a]+=1
    WW[b]+=1
    Q.append((a,b))

Q.sort()
head=0

maxH=max(HH)
maxW=max(WW)

HHH=[]
for i in range(h+1):
    if HH[i]==maxH:
        HHH.append(i)

WWW=[]
for i in range(w+1):
    if WW[i]==maxW:
        WWW.append(i)

ans=maxH+maxW
flg=-1
end=False
for i in HHH:
    for q in WWW:
        while (i,q)!=Q[head]:
            head+=1
            if head==m:
                flg=0
                end=True
                break     
        if end:
            break
    if end:
        break
print(ans+flg)

Measured memory_bytes: 152344
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true)cerr
void print(){cout<<endl;}
template<typename T,typename... Args>
void print(T a, Args... args) {cout<<a<<" ";print(args...);}
lli llipowerp(lli x, lli y, lli p=LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
inline void printvec(vector<T> inp){
    for(auto it:inp) cout<<it<<" ";
    cout << endl;
}
//---------------------------------------------------------------------------------

int main()
{
    lli x;
    cin>>x;
    lli s=100;
    for(int i=1;i<5000;i++){
        s=s+(s/100);
        if(s>=x){
            cout<<i<<endl;
            return 0;
        }
    }

}


Measured memory_bytes: 3632
#include <stdio.h>

typedef long long int llint;

int n,k;
int r,s,p;
char t[100001];
llint dp[200000][3];//0:r,1:s,2:p

llint max(llint a,llint b){return a>b?a:b;}

int num(char c)
{
    switch(c)
    {
        case 'r':return 2;
        case 's':return 0;
        case 'p':return 1;
    }
    return -1;
}

// int func(int a,int b){return a%b==0?a/b:a/b+1;}//天井関数

int main()
{
    scanf("%d%d",&n,&k);
    scanf("%d%d%d",&r,&s,&p);
    scanf("%s",t);

    for(int i=0;i<k;i++)
    {
        switch(t[i])
        {
            case 'r':
                dp[i][2]+=p;
                break;
            case 's':
                dp[i][0]+=r;
                break;
            case 'p':
                dp[i][1]+=s;
                break;
        }
        for(int j=1;j*k+i<n;j++)
        {
            // printf("%d ",j*k+i);
            dp[j*k+i][0]+=max(dp[j*k+i-k][1],dp[j*k+i-k][2]);
            dp[j*k+i][1]+=max(dp[j*k+i-k][0],dp[j*k+i-k][2]);
            dp[j*k+i][2]+=max(dp[j*k+i-k][1],dp[j*k+i-k][0]);
            switch(t[j*k+i])
            {
                case 'r':
                    dp[j*k+i][2]+=p;
                    break;
                case 's':
                    dp[j*k+i][0]+=r;
                    break;
                case 'p':
                    dp[j*k+i][1]+=s;
                    break;
            }
        }
        // printf("\n");
    }
    llint ans=0;
    for(int i=0;i<k;i++)
    {
        ans+=max(dp[n-1-i][0],max(dp[n-1-i][1],dp[n-1-i][2]));
    }
    printf("%lld\n",ans);
    return 0;
}

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

using namespace std;

int main(){
    int n;
    long long int ans = 0;
    cin >> n;
    vector<int>step(n);

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

    int max_step = 0;

    for(int i = 0; i < n; i++){
        max_step = max(max_step,step[i]);
        
        ans += max_step-step[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4048
import java.util.*;

public class Main {
	static int A;
	static int B;
	static int C;
	static int n;
	static int[] arr;
	
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		System.out.println(checkPoint(0, new Bamboo()));
	}
	
	static int checkPoint(int level, Bamboo b) {
		if (level == n) {
			return b.getPoint();
		}
		int min = Integer.MAX_VALUE;
		int v = arr[level];
		int ans = checkPoint(level + 1, b.copy().addA(v));
		if (min > ans) {
			min = ans;
		}
		ans = checkPoint(level + 1, b.copy().addB(v));
		if (min > ans) {
			min = ans;
		}
		ans = checkPoint(level + 1, b.copy().addC(v));
		if (min > ans) {
			min = ans;
		}
		ans = checkPoint(level + 1, b);
		if (min > ans) {
			min = ans;
		}
		return min;
	}
	
	static class Bamboo {
		int a;
		int b;
		int c;
		int mp;
		
		public Bamboo() {
		}
		
		public Bamboo addA(int a) {
			if (this.a != 0) {
				mp += 10;
			}
			this.a += a;
			return this;
		}
		
		public Bamboo addB(int b) {
			if (this.b != 0) {
				mp += 10;
			}
			this.b += b;
			return this;
		}
		
		public Bamboo addC(int c) {
			if (this.c != 0) {
				mp += 10;
			}
			this.c += c;
			return this;
		}
		
		public int getPoint() {
			if (a == 0 || b == 0 || c == 0) {
				return Integer.MAX_VALUE;
			} else {
				return Math.abs(a - A) + Math.abs(b - B) + Math.abs(c - C) + mp;
			}
		}
		
		public Bamboo copy() {
			Bamboo x = new Bamboo();
			x.a = a;
			x.b = b;
			x.c = c;
			x.mp = mp;
			return x;
		}
	}
}




Measured memory_bytes: 24660
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    int p[n];
    for(int i=0;i<n;i++)cin >> p[i];
    sort(p,p+n);
    int ans = 0;
    for(int i=0;i<k;i++)ans += p[i];
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n, a, b;

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

	if (n % 500 <= a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  REP(i, 3){
    if(S[i] == '1'){
      cout << 9;
    }else{
       cout << 1;
    }
  }
  cout << endl;
}


Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main(){
  int n;
  int i,j,k;
  int build[4][3][10]={{{}}};
  cin >> n;
  int b,f,r,v;
  for(i=0;i<n;i++){
    cin >> b >> f >> r >> v;
    build[b-1][f-1][r-1]+=v;
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
    cout << " ";
    cout << build[i][j][k];
      }
      cout << endl;
    }
    if(i<3)cout << "####################" << endl;
  }
  return 0;
}


Measured memory_bytes: 3084
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static int gcd(int x, int y){
		if(y == 0){
			return x;
		}else{
			return gcd(y, x % y);
		}
	}
	
	public static boolean search_matching(int cur, int size, boolean[][] adj, boolean[] visited, LinkedList<Integer> stack){
		if(cur == size - 1){
			stack.add(cur);
			return true;
		}
		
		for(int to = 0; to < size; to++){
			if(!adj[cur][to]){
				continue;
			}else if(visited[to]){
				continue;
			}
			
			visited[to] = true;
			
			if(search_matching(to, size, adj, visited, stack)){
				stack.add(cur);
				return true;
			}
			//prev[to] = -1;
		}
		
		return false;
	}
	
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		
		while (true) {
			final int m = sc.nextInt();
			final int n = sc.nextInt();
			
			if(m == 0 && n == 0){
				break;
			}
			
			int[] blue = new int[m];
			int[] red = new int[n];
			
			for(int i = 0; i < m; i++){
				blue[i] = sc.nextInt();
			}
			
			for(int i = 0; i < n; i++){
				red[i] = sc.nextInt();
			}
			
			boolean[][] adj = new boolean[n + m + 2][m + n + 2];
			for(int i = 0; i < m; i++){
				adj[0][i + 1] = true;
			}
			for(int i = 0; i < n; i++){
				adj[m + i + 1][n + m + 1] = true;
			}
			
			for(int i = 0; i < m; i++){
				for(int j = 0; j < n; j++){
					
					if(gcd(blue[i], red[j]) != 1){
						adj[i + 1][m + j + 1] = true;
					}
				}
			}
			
			int count = 0;
			while(true){
				boolean[] visited = new boolean[n + m + 2];
				LinkedList<Integer> stack = new LinkedList<Integer>();
				if(!search_matching(0, n + m + 2, adj, visited, stack)){
					break;
				}
				
				//System.out.println(stack);
				
				int prev = stack.poll();
				while(!stack.isEmpty()){
					int cur = stack.poll();
					
					adj[prev][cur] = true;
					adj[cur][prev] = false;
					prev = cur;
				}
				
				count++;
			}
			
			System.out.println(count);
		}
	}

}

Measured memory_bytes: 64956
#include<stdio.h>
using namespace std;

int main(void)
{
	int N, S[100];
	int B = 0;
	int A = 0;
	int K[100];
	int min=0;
	scanf("%d", &N);

	for (int i = 0; i < N; i++) {
		scanf("%d", &S[i]);
		B += S[i];
		//printf("%d", B);
	}
	for (int i = 0; i < N; i++) {
		B -= S[i];
		A += S[i];
		if (A > B) {
			K[i] = A - B;
		}
		else if (B > A) {
			K[i] = B - A;
		}
		else {
			printf("0");
			return 0;
		}
	}
	for (int i = 0; i < N; i++) {
		if (i == 0) {
			min = K[0];
		}
		else {
			if (K[i - 1] >= K[i])
				min = K[i];
		}
	}
	printf("%d", min);

	return 0;
}

Measured memory_bytes: 888
/*
Written By mafailure
*/
//In the name of God
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less
using namespace std;
using namespace __gnu_pbds;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
//#define int long long 
// int dx[]={-1,1,0,0}; int dy[]={0,0,1,-1};
// int dx[]={2,2,-2,-2,1,1,-1,-1}; int dy[]={1,-1,1,-1,2,-2,2,-2};
const long long mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef vector< pair< int, int > > vii;
typedef map<int, int> mii;
typedef pair<int, ii> pip;
typedef pair<ii, int> ppi;
#define arrinp(arr,init,final,size,type) type* arr=new type[size];for(int i=init;i<final;i++)cin>>arr[i];
#define cr2d(arr,n,m,t) t**arr=new t*[n];for(int i=0;i<n;i++)arr[i]=new t[m];
#define w(t) int t;cin>>t; while(t--)
#define takeInp(n) int n;cin>>n;
#define fr(i,init,final) for(int i=init;i<final;i++)
#define frr(i,init,final) for(int i=init;i>=final;i--)
#define Fr(i,final) for(int i=0;i<final;i++)
#define Frr(i,first) for(int i=first;i>=0;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define debug(x) cerr<<">value ("<<#x<<") : "<<x<<endl;
#define setb __builtin_popcount
#define lsone(n) (n&(-n))
#define rlsone(n) (n&(n-1))

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>  nds; 
vi init(string s)
{
	istringstream sin(s);
	int n;
	vi arr;
	while(sin>>n)arr.push_back(n);
	return arr;
}
int power(int x, int y)
{ 
	if(y==0)return 1;
	int u=power(x,y/2);
	u=(u*u)%mod;
	if(y%2)u=(x*u)%mod;
	return u;
    
}
int gcd(int a,int b)
{
	if(a<b)return gcd(b,a);
	return (b==0?a:(a%b?gcd(b,a%b):b));
}
int gcd_e(int a,int b,int &x,int &y)
{
	
	if(b==0){x=1; y=0; return a;}
	int x1,y1;
	int p=gcd_e(b,a%b,x1,y1);
	x=y1;
	y=x1-(a/b)*y1;
	return p;
}
signed main()
{
	IOS
	string s;
	cin>>s;
	if(s=="RRR")cout<<3<<endl;
	else if(s=="RRS")cout<<2<<endl;
	else if(s=="SRR")cout<<2<<endl;
	else if(s=="SSS")cout<<0<<endl;
	else cout<<1<<endl;
	
}



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

using namespace std;

int main(void){
    int n;
    vector<int> p;
    cin >> n;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        p.push_back(a);
    }
    int min = 200003;
    //int max = 0;
    int ans = 0;

    for(int i=0; i<n; i++){
        if(min >= p[i]){
            ans += 1;
            min = p[i];
        }else{
            
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
typedef long long ll;
const int maxn=1e5+233;

int n,m;
int main()
{
	cin>>n;
	int fi=n/100,se=n%100;
	if((fi>12|| fi==0) && se<=12 && se>=1)printf("YYMM\n");
	else if(fi<=12 && fi>=1 && (se>12 || se==0))printf("MMYY\n");
	else if(fi<=12 && fi>=1 && se<=12 && se>=1)printf("AMBIGUOUS\n");
	else printf("NA\n");
		
    return 0;
}




Measured memory_bytes: 256
x=list(str(input()))
y=list(str(input()))
x.sort()
y.sort(reverse=True)

while len(x)!=len(y):
	if len(x)>len(y):
		y.append('Z')
	else:
		x.append('Z')
ans=0
i=0

while  ans==0 and i!=len(x):
	if ord(x[i])>ord(y[i]):
		ans=-1
	elif ord(x[i])<ord(y[i]):
		ans=1
	else:
		i=i+1
if ans==1:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main() {

	int n;
	cin >> n;
	int a[100000];
	int i;
	int flag[100001];
	for (i = 0; i < n; i++) {
		flag[i] = 0;
	}
	for (i = 0; i < n; i++) {
		cin >> a[i];
		flag[a[i]]++;
	}
	for (i = 1; i < n; i = i + 2) {
		if (flag[n - i] == 2) {
			flag[n - i] = 0;
		}
		else {
			cout << 0 << endl;
			return 0;
		}
	}
	if (n % 2 == 1) {
		if (flag[0] == 1) {
			flag[0] = 0;
		}
		else {
			cout << 0 << endl;
			return 0;
		}
	}
	for (i = 0; i < n; i++) {
		if (flag[i] > 0) {
			cout <<  0 << endl;
			return 0;
		}
	}
	long long int s = 1;
	long long int mod = 1000000007;
	for (i = 1; i < n; i = i + 2) {
		s = (s * 2) % mod;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 4392
N, K = map(int, input().split())

nums = [0] * K
for i in range(1, N + 1):
    nums[i % K] += 1

ans = 0
for a in range(0, K):
    b = (K - a) % K
    c = (K - a) % K
    if (b + c) % K != 0:
        continue
    ans += nums[a] * nums[b] * nums[c]

print(ans)


Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
int dp[1010][1010];
int main(){
  for(int i=0;i<1010;i++)
    for(int j=0;j<1010;j++)
      dp[i][j]=1e9;
  string s1,s2;
  cin>>s1>>s2;
  int n=s1.size();
  int m=s2.size();
  for(int i=0;i<=n;i++)dp[i][0]=i;
  for(int i=0;i<=m;i++)dp[0][i]=i;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      dp[i][j]=min(dp[i][j],dp[i-1][j-1]+(s1[i-1]!=s2[j-1]));
      dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
      dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
    }
  }
  int ans=1e9;
  for(int i=0;i<=m;i++)ans=min(ans,dp[n][i]+abs(m-i));
  cout<<dp[n][m]<<endl;
  return 0;
}



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

while True:
    try:
        list = [float(x) for x in raw_input().split() ]
        x = (list[2]*list[4]-list[1]*list[5])/(list[0]*list[4]-list[1]*list[3])+0
        y = (list[0]*list[5]-list[2]*list[3])/(list[0]*list[4]-list[1]*list[3])+0

        print("%.3f %.3f" %(x, y))

    except EOFError:
        break

Measured memory_bytes: 4240
// https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W;
    cin >> H >> W;
    if (H == 1 || W == 1) {
        cout << 1 << endl;
    } else {
        cout << DIV(H * W, 2) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int a,b,c,d,p1,p2;
cin>>a>>b>>c>>d;
p1=a*b;
p2=c*d;
if(p1>p2){
    cout<<p1<<endl;
}else{
    cout<<p2<<endl;
}

}


Measured memory_bytes: 384
import java.util.Scanner;

/**
 *
 * @author C0117306
 */
public class Main {
    
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int goukei=n*800;
        int sa=n/15*200;
        System.out.println(goukei-sa);
       
    }
    
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
char sb[100];
char s[100];
int stsy(int,int,int,int);
int pr(int,int);
int ka(int,int);
int main(){
  while(1){
    cin >> sb;
    if(sb[0]=='.')break;
    int co=0;
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
	for(int k=0;k<3;k++){
	  strcpy(s,sb);
	  int ans;
	  //   cout <<i<<j<<k <<" ";
	  ans=stsy(0,i,j,k);
	  //	  cout << ans << endl;
	  if(ans==2)
	    co++;
	}
      }
    }
    cout << co << endl;
  }
  return 0;
}
int stsy(int I,int p,int q,int r){
  int d=-1;
  int d2=-1;
  int mi=0;
  int t=0;
  int x=0;
  while(1){
    //cout << s[I] ;
    if(s[I]==')'||s[I]=='\0')return d2;
    else if(s[I]=='('){
      d=stsy(I+1,p,q,r);
      for(;s[I]!=')';I++);
      s[I]='x';
      
    }
    else if(s[I]=='-'){
      if(mi==0)mi=1;
      else mi=0;
    }
    else if(s[I]=='P')d=p;
    else if(s[I]=='Q')d=q;
    else if(s[I]=='R')d=r;
    else if(s[I]=='0')d=0;
    else if(s[I]=='1')d=1;
    else if(s[I]=='2')d=2;
    else if(s[I]=='+')t=1;
    else if(s[I]=='*')x=1;
    if(d!=-1&&mi==1){
      if(d==2)d=0;
      else if(d==0)d=2;
      mi=0;
    }
    if(t==1&&d!=-1){
      d2=pr(d,d2);
      //  cout << " "<<d2 <<'+'<< " ";
      d=-1;
      t=0;
    }
    if(x==1&&d!=-1){
      d2=ka(d,d2);
      d=-1;
      x=0;
    }
    if(d!=-1){
      d2=d;
    }
    d=-1;
    I++;
  }    
}
int pr(int a,int b){
  return max(a,b);
}
int ka(int a,int b){
  return min(a,b);
}

Measured memory_bytes: 3000
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 60
int n, k;
ll x[N], y[N];
int main(){
	cin>>n>>k;
	rep(i, n) cin>>x[i]>>y[i];
	ull res = 5e18;
	rep(i, n) rep(j, i) rep(i2, n) rep(j2, n){
		ll lx = x[i], rx = x[j], ly = y[i2], ry = y[j2];
		if(lx>rx) swap(lx, rx);
		if(ly>ry) swap(ly, ry);
		ull sq = (ull)(rx-lx)*(ry-ly);
		if(res<=sq) continue;
		int cnt = 0;
		rep(l, n) cnt += (lx<=x[l]&&x[l]<=rx&&ly<=y[l]&&y[l]<=ry);
		if(cnt>=k) res = sq;
	}
	cout<<res<<endl;
	return 0;
}


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

using namespace std;

int main() {
  int a, b, x;

  cin >> a >> b;
  x = a + b;

  if (x % 2 == 0) x = x / 2;
  else x = x / 2 + 1;

  cout << x << endl;
  
  return 0;
}


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

#define N 1000002
#define pb push_back
int hit[N], a[N];
int main(){
    int n, m;
    cin >> n >> m;
    for (int i=1; i<=m; i++){
        scanf("%d", &a[i]);
    }
    for (int i=m; i>=1; i--){
        int x = a[i];
        if (hit[x] == 0) printf("%d\n", x);
        hit[x] = 1;
    }
    for (int i=1; i<=n; i++){
        if (hit[i] == 0) printf("%d\n", i);
    }
    return 0;
}

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

int main() {
  int n,m,c;
  cin >> n >> m >> c;
  int b[20],a[20][20];
  for (int i=0; i<m; i++) {
    cin >> b[i];
  }
  for (int i=0; i<n; i++) {
    for (int j=0; j<m; j++) {
      cin >> a[i][j];
    }
  }

  int cnt=0;
  for (int i=0; i<n; i++) {
    int sum=0;
    for (int j=0; j<m; j++) {
      sum+=a[i][j]*b[j];
    }
    sum+=c;
    if (sum>0)
      cnt++;
  }

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

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

int main() {
int N,M;
  int T=0;
  
cin>>N>>M;
  vector<int> S(M);
  for(int i=0; i<M; i++){
    cin>>S.at(i);
    T+=S.at(i);
  }
  if(T>N) cout<<"-1";
  else cout<< N-T;

}


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

int main() {
  int N;
  int ans;
  ans = 0;
  cin >> N;
  std::vector<int> V(N);
  std::vector<int> C(N);

   for(int i = 0;i<N;++i){
    cin >> V.at(i);
   }
   for(int j = 0;j<N;++j){
     cin >> C.at(j);
   }
   for(int k = 0;k<N;++k){
     if(V.at(k) > C.at(k)){
       ans = ans + V.at(k) - C.at(k);
}
   }
     cout << ans << endl;
   }     


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){ 
   vector<int> a(12);
   a={1,2,1,3,1,3,1,1,3,1,3,1};
   int x,y;
   cin>>x>>y;
   a[x-1]==a[y-1]? cout<<"Yes":cout<<"No";

}

Measured memory_bytes: 256
def get_ans(pairs):
    pairs = sorted(pairs, key=lambda x: -sum(x))
    score = 0
    flg = 0
    for a,b in pairs:
        score += a*(1-flg) - b*flg
        flg = 1- flg
    return score

if __name__ == '__main__':
    n = int(input())
    p = []
    for i in range(n):
        p.append(tuple(map(int, input().split())))

    print(get_ans(p))

Measured memory_bytes: 22160
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
bool check(int n){
  int cnt = 0;
  while(n){
    n /= 10;
    cnt++;
  }
  return cnt & 1;
}
int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i++){
    if(check(i)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.Scanner;

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

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int A1 = sc.nextInt();
		int A2 = sc.nextInt();
		int A3 = sc.nextInt();

		if(A1+A2+A3>=22) {
			System.out.println("bust");
		} else {
			System.out.println("win");
		}
	}
}


Measured memory_bytes: 21844