akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
typedef long long int64;

using namespace std;

int main()
{
    int64 x, rem, ans;

    cin >> x;

    ans = (x / 11) * 2;
    rem = x % 11;

    if (rem > 6){
        ans += 2;
    } else if (!(rem == 0) && (rem <= 6)){
        ans += 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	long c[];
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int min, max ;
		min =1;
		max =N;
		for (int i =0;i<M;i++) {
			int x,y;
			x= sc.nextInt();
			y =sc.nextInt();
			if (x>min) {
				min =x;
			}
			if (y<max) {
				max =y;
			}
		}
		if (max<min) {
			System.out.println(0);
			return ;
		}
		System.out.println(max-min+1);
	}
}

Measured memory_bytes: 63316
n, m, l = map(int, input().split())

mtrx1 = [list(map(int, input().split())) for i in range(n)]
mtrx2 = [list(map(int, input().split())) for i in range(m)]

mtrx_ans = [[0]*l for i in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            mtrx_ans[i][j] +=  mtrx1[i][k] * mtrx2[k][j]

for i in range(n):
    print(mtrx_ans[i][0], end="")
    for j in range(1, l):
        print(" {}".format(mtrx_ans[i][j]), end="")
    print()


Measured memory_bytes: 7056
class Dice < Array
	def roll!(drct)
		drct.split("").each{|s|
		case s
		when "E" then
			self.replace([at(3),at(1),at(0),at(5),at(4),at(2)])
		when "N" then
			self.replace([at(1),at(5),at(2),at(3),at(0),at(4)])
		when "S" then
			self.replace([at(4),at(0),at(2),at(3),at(5),at(1)])
		when "W" then
			self.replace([at(2),at(1),at(5),at(0),at(4),at(3)])
		when "R" then
			self.replace([at(0),at(3),at(1),at(4),at(2),at(5)])
		end
		}
	end
	def is_top
		at(0)
	end
	def getr!(face)
		while at(0) != face[0] do
			roll!(["E","N","S","W"].sample)
		end
		while at(1) != face[1] do
			roll!("R")
		end
		at(2)
	end
	def is_eq(dice)
		for i in 1..4 do
			for j in 1..4 do
				return 0 if self == dice
				roll!("R")
			end
			roll!("E")
		end
		for i in 1..3 do
			roll!("N")
			for j in 1..4 do
				return 0 if self == dice
				roll!("R")
			end
		end
		return 1
	end
end

a = Array.new
b = Array.new
for i in 0..n = gets.to_i-1 do
	a[i] = Dice.new(gets.split.map(&:to_i))
end
for i in 1..n do
	b[i-1] = a[0].is_eq(a[i])
end
puts b.inject(:+) == n ? "Yes" : "No"

Measured memory_bytes: 10276
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4.2")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define PB push_back
#define all(x) x.begin(),x.end()
#define vi vector<ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define vb vector<bool>
#define vvi vector<vector<ll> >
#define vvii vector<vii>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define read(x) long long x;cin>>x;
#define FOR(a,b,c,d) for(int a=b;a<=c;a+=d)
#define MP make_pair
#define F first
#define AS assign
#define S second
#define debug(x) cout<<(#x)<<": "<<(x)<<"\n"
#define SZ(x) x.size()
#define mod 1000000007
#define lg2(x) 63-(__builtin_ctzll(x))
#define RZ resize
#define IN insert
#define X real()
#define Y imag()
#define FBO find_by_order
#define OFK order_of_key
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
typedef unsigned long long ull;
typedef long double d64;
typedef complex<d64>P;

int modpow(int a,int b,int m){
    if(!b)return 1%m;
    ll u=modpow(a,b/2,m);
    u=(u*u)%m;
    if(b&1)u=(u*a)%m;
    return u;
}

int main(){
read(n);
ll k;
cin>>k;
fast
int ans=0;
while(n--){
    read(a);read(b);
    if(a*a+b*b<=k*k)ans++;
}
cout<<ans;
return 0;
}




Measured memory_bytes: 3632
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long min = 100;
    for(long i = 1; i <= Math.sqrt(N); i++){
      if(N%i == 0){
        long A = calc(i, N/i);
        min = A < min ? A : min;
      }
    }
    System.out.println(min);
  }
  public static long calc(long A, long B){
    if(A < B){
      return calc(B, A);
    }
    int ans = 1;
    while(A/10 != 0){
      A /= 10;
      ans++;
    }
    return ans;
  }
}

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

string order;
vector<int> num;
vector<char> word;
int n;
char button[9][5] = {{'.',',','!','?',' '},{'a','b','c'},{'d','e','f'},{'g','h','i'},{'j','k','l'},{'m','n','o'},{'p','q','r','s'},{'t','u','v'},{'w','x','y','z'}};

int main()
{
        int but = 0,push = 0;
        cin >> n;
        for(int i=0;i<n;i++){
                cin >> order;
                for(int j=0;j<order.size();j++){
                        num.push_back((int)(order[j]-'0'));
                }
                for(int j=0;j<num.size();j++){
                        if(1<=num[j] && num[j]<=9 && but==0){
                                but = num[j];
                        }else if(1<=num[j] && num[j]<=9 && but!=0){
                                push++; //cout << "pushed" << endl;
                        }else if(num[j]==0 && but && but!=1 && but!=7 && but!=9){
                                word.push_back(button[but-1][push%3]); //cout << button[but-1][push%3] << endl;
                                push = 0;
                                but = 0;
                        }else if(num[j]==0 && but && (but==7 || but==9)){
                                word.push_back(button[but-1][push%4]); //cout << button[but-1][push%4] << endl;
                                push = 0;
                                but = 0;
                        }else if(num[j]==0 && but && but==1){
                                word.push_back(button[but-1][push%5]);
                                push = 0;
                                but = 0;
                        }else if(num[j]==0 && !but){
                                continue;
                        }
                }
                for(int k=0;k<word.size();k++){
                        cout << word[k];
                }
                cout << endl;
                word.clear();
                num.clear();
        }

        return 0;

}

Measured memory_bytes: 1228
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main(void){
	int N; ll D;
	cin >> N >> D;
	int res = 0;
	for (int i = 0; i < N; ++i){
		ll X, Y; cin >> X >> Y;
		if (X * X + Y * Y <= D * D) ++res;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3632
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9

n, k = [0, 0]
w = []


def validate(p):
    c = 0
    for i in range(k):
        s = 0
        while s + w[c] <= p:
            s = s + w[c]
            c = c + 1
            if c == n:
                return True
    return False


def main():
    global n
    global k
    global w
    n, k = map(int, input().split())
    for i in range(n):
        w.append(int(input()))

    # bianry search
    left = 0
    right = 100000 * 10000
    p = right / 2
    while left != right:
        if validate(p):
            right = p
        else:
            left = p + 1
        p = math.floor((left + right) / 2)

    print(p)


if __name__ == '__main__':
    main()



Measured memory_bytes: 12916
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, P; 
  cin >> N >> P;

  string s;
  cin >> s;


  int ans = 0;
  if(P == 2 || P == 5){
    REP(i, N){
      if((s[i]-'0')%P == 0) ans += i+1;
    }
    cout << ans << "\n";
    return 0;
  }

  map<int, int> m;
  m[0] = 1;

  int now = 0;
  int p = 1;
  RREP(i, N){
    (now += p*(s[i]-'0')) %= P;
    (p *= 10) %= P;
    m[now]++;
  }

  for(auto p : m){
    ans += p.second*(p.second-1)/2;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const ll inf = 1e9;
int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    int q; cin >> q;
    rep(i,q){
        int b, m, e;
        cin >> b >> m >> e;
        swap_ranges(a.begin()+b, a.begin()+m, a.begin()+e);
    }
    rep(i,n)cout << a[i] << ((i < n-1)?" ":"\n");
    return 0;
}


Measured memory_bytes: 3096
package main

import (
	"math/rand"
	"time"
	"os"
	"bufio"
	"fmt"
	"strconv"
	"strings"
)

var(
	sc = bufio.NewScanner(os.Stdin)
	mod = 1000000007
	mod9 = 1000000009
)

func init()  {
	rand.Seed(time.Now().UnixNano())
	buf := make([]byte, 0) //ここのサイズは何でもよさそう
	sc.Buffer(buf, 1000000009)
}


//||||||||||||||||||||||||||入力|||||||||||||||||||||||||||||||||||||||\
//数字一文字入力
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

//文字列を一行入力
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

//空白区切りの文字列の入力
func spaceLine() []string {
	sc.Scan()
	return strings.Split(sc.Text()," ")
}

//数字を一行入力
func intLine() []int {
	str := spaceLine()
	buf := make([]int,len(str))
	for i,s:=range str{
		buf[i],_ = strconv.Atoi(s)
	}
	return buf
}

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

//ソートする
//sは最初のインデックス fは最後のインデックス
func Sort(ls []float64,l int,r int)  {
	if r - l <= 0{return}
	pipot := l + rand.Intn(r-l+1)
	ls[r],ls[pipot] = ls[pipot],ls[r]
	i := l
	for j:=l;j<r;j++{
		if ls[j] < ls[r]{
			ls[i],ls[j] = ls[j],ls[i]
			i ++
		}
	}
	ls[i],ls[r] = ls[r],ls[i]
	Sort(ls,l,i-1)
	Sort(ls,i+1,r)
}

//配列の大小を指定した要素で比較
//a < bならtrue
func sizeCheck(a []int,b []int,ls []int) bool {
	for _,i:= range ls{
		if a[i] < b[i]{
			return true
		} else if a[i] > b[i] {
			return false
		}
	}
	return false
}

//二次元配列のソート
func Sort2D(ls [][]int,l int,r int,index ...int)  {
	if r - l <= 0{return}
	pipot := l + rand.Intn(r-l+1)
	ls[r],ls[pipot] = ls[pipot],ls[r]
	i := l
	for j:=l;j<r;j++{
		if sizeCheck(ls[j],ls[r],index){
			ls[i],ls[j] = ls[j],ls[i]
			i ++
		}
	}
	ls[i],ls[r] = ls[r],ls[i]
	Sort2D(ls,l,i-1,index ...)
	Sort2D(ls,i+1,r,index ...)
}

func main() {
	n := nextInt()
	dp := make([][][][]int,n+1)
	for i:=0;i<len(dp);i++{
		dp[i] = make([][][]int,4)
		for j:=0;j<len(dp[0]);j++{
			dp[i][j] = make([][]int,4)
			for k:=0;k<len(dp[0][0]);k++{
				dp[i][j][k] = make([]int,4)
			}
		}
	}
	dp[0][3][3][3] = 1
	for position:=0;position<n;position++{
		for i:=0;i<len(dp[0]);i++{
			for j:=0;j<len(dp[0][0]);j++{
				for k:=0;k<len(dp[0][0][0]);k++{
					if dp[position][i][j][k] == 0{continue}
					for str:=0;str<4;str++{
						if j == 0 && k == 1 && str == 2{continue}
						if j == 1 && k == 0 && str == 2{continue}
						if j == 0 && k == 2 && str == 1{continue}
						if i == 0 && j == 1 && str == 2{continue}
						if i == 0 && k == 1 && str == 2{continue}

						dp[position+1][j][k][str] += dp[position][i][j][k]
						dp[position+1][j][k][str] %= mod
					}

				}
			}
		}
	}

	ans := 0
	for i:=0;i<len(dp[0]);i++{
		for j:=0;j<len(dp[0][0]);j++{
			for k:=0;k<len(dp[0][0][0]);k++{
				ans += dp[len(dp)-1][i][j][k]
				ans %= mod
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 768
n, x=map(int, input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n):
  if a[i]>x:
    ans+=a[i]-x
    a[i]=x
for i in range(n-1):
  if a[i]+a[i+1]>x:
    ans+=(a[i]+a[i+1]-x)
    a[i+1]=x-a[i]
print(ans) 

Measured memory_bytes: 14592
import sys
input = sys.stdin.readline
ri = lambda: int(input())
#rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

P,Q,R=rl()
print(P+Q+R-max([P,Q,R]))

Measured memory_bytes: 3064
from math import factorial
MOD = 10**9 + 7

def prime_factor(n):
    res = []
    d = 2
    while d * d <= n:
        if n % d == 0:
            count = 0
            while n % d == 0:
                count += 1
                n = n // d
            res.append(count)
        d += 1
    if n > 1:
        res.append(1)
    return res
    
N, M = map(int, input().split())
ans = 1
for c in prime_factor(M):
    for i in range(c):
        ans *= N + i
    ans = ans // factorial(c)
    ans %= MOD
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(){
	int n,m,x,y;
	scanf("%d%d%d%d", &n, &m, &x, &y);
	int a_city[n], b_city[m];
	for(int i=0; i<n; i++){
		scanf("%d", &a_city[i]);
	}
	for(int i=0; i<m; i++){
		scanf("%d", &b_city[i]);
	}
	
	int amax=-101, bmin=101;
	for(int i=0; i<n; i++){
		if(amax<a_city[i]) amax=a_city[i];
	}
	for(int i=0; i<m; i++){
		if(bmin>b_city[i]) bmin=b_city[i];
	}
	
	if((x<=amax)&&(amax<bmin)&&(bmin<y)) printf("No War");
	else printf("War");
	
	return 0;
}

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

using namespace std;
using pii = pair<int, int>;
using ll = long long;
const int maxn = 1e5+7;

struct node{
	int x, y, id;
};
node a[maxn];
vector<pii>G[maxn];
int ans;

ll n;
bool vis[maxn];
void dijk()
{
	ans = 0;
	memset(vis, 0, sizeof(vis));
	priority_queue<pii, vector<pii>, greater<pii>>que;
	que.push({0, 1});
	while(!que.empty()){
		int u = que.top().second;
		int w = que.top().first;
		que.pop();
		if(vis[u])continue;
		ans += w;
		vis[u]=1;
		for(auto i:G[u]){
			que.push(i);
		}
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for(int i=1; i<=n; ++i){
		cin >> a[i].x>>a[i].y;
		a[i].id=i;
	}
	sort(a+1, a+1+n, [&](node a, node b){
		return a.x<b.x;
	});
	for(int i=2; i<=n; ++i){
		G[a[i].id].push_back(make_pair(a[i].x-a[i-1].x, a[i-1].id));
		G[a[i-1].id].push_back(make_pair(a[i].x-a[i-1].x, a[i].id));
	}
	sort(a+1, a+1+n, [&](node a, node b){
		return a.y<b.y;
	});
	for(int i=2; i<=n; ++i){
		G[a[i].id].push_back(make_pair(a[i].y-a[i-1].y, a[i-1].id));
		G[a[i-1].id].push_back(make_pair(a[i].y-a[i-1].y, a[i].id));
	}
	dijk();
	cout << ans <<"\n";
}

Measured memory_bytes: 11640
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
 
using namespace std;
//using namespace __gnu_pbds;

//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;                         

const int N = (int)5e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;

void solve () {
	int n;
	cin >> n;
	string a, b;
	cin >> a >> b;
	for (int i = n; i >= 1; i --) {
		string f, s;
		f = "", s = "";
		for (int j = n - i; j < n; j ++) {
			f += a[j];
		}		      
		for (int j = 0; j < i; j ++) s += b[j];
		if (f == s) {
			cout << 2 * n - i;
			return;
		}
	}
	cout << n * 2;
}   	
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//    cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

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

int main(){
  int a;
  cin >> a;
  if(a < 1200){
    cout << "ABC" << endl;
  }
  else if(a < 2800){
    cout << "ARC" << endl;
  }
  else{
    cout << "AGC" << endl;
  }
}


Measured memory_bytes: 256
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))

count = 0
good_list = [i for i in range(1, n + 1)]
bad_list = []
for i in range(m):
    a, b = list(map(int, input().split()))

    if h[a - 1] < h[b - 1]:
        bad_list.append(a)
    elif h[a - 1] > h[b - 1]:
        bad_list.append(b)
    else:
        bad_list.append(a)
        bad_list.append(b)

print(len(set(good_list) - set(bad_list)))


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

int main() {
  int N, K;
  cin>>N>>K;
  vector<int> h(N,0);
  for(int i=0;i<N;i++)
    cin>>h[i];
  
  vector<int> cost(N,0);
  cost[1] = abs(h[1]-h[0]);
  
  for(int i = 2;i < N;i++) {
    int res = INT_MAX;
    for(int k = 1 ; k <= K and i-k >= 0 ; k++) {
      res = min(res, cost[i-k] + abs(h[i]-h[i-k]));
    }
    cost[i] = res;
  }
  
  cout<<cost[N-1];
  
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(void){
  int n, a, b;
  cin >> n >> a >> b;
  int x=0, y=0, z=0;
  for(int i = 0; i < n; ++i) {
    int tmp;
    cin >> tmp;
    if (tmp <= a)
      ++x;
    else if (tmp <= b)
      ++y;
    else
      ++z;
  }
  int minvar = x;
  if (minvar > y)
    minvar = y;
  if (minvar > z)
    minvar = z;
  cout << minvar << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,X;
  cin>>N>>X;
  vector<int> m(N);
  int S=0;
  int T=100000;
  int U=0;
  for(int i=0;i<N;i++)
  {
    cin>>m.at(i);
    S+=m.at(i);
    U++;
  }
  sort(m.begin(),m.end());
  U+=(X-S)/m.at(0);
  cout<<U<<endl;
}

  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int N = 405;
bool t[25][25];
int dp[1 << 25];
int add(int a, int b) {
  a += b;
  if (a >= MOD) {
    a -= MOD;
  }
  return a;
}
int main() {
  int n; cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> t[i][j];
    }
  }
  dp[0] = 1;
  for (int mask = 0;
    mask <= (1 << n) - 1; mask++) {
    int man = __builtin_popcount(mask);
    for (int woman = 0; woman < n; woman++) {
      if (t[man][woman] && !((1 << woman) & mask)) {
          int mask2 = mask ^ (1 << woman);
          dp[mask2] = add(dp[mask2], dp[mask]);
      }
    }
  }
  cout << dp[(1 << n) - 1] << "\n";
  return 0;
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
    using  namespace  std;
    int a[19] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,4,9,25,49};

    int  main(){
        string s;
        int flag = 0,cflag = -1;
        int N;
        cin>>N;
        int l = 0,r = N-1;
        printf("%d\n",l);
        fflush(stdout);
            cin>>s;
        if(s[0] == 'V')
            return 0;
        if(s[0] == 'F')
            cflag = 0;
        else cflag = 1;
        l++;
        while(true)
        {
            int mid = (l+r)/2;
            //cout<<l<< " "<<r<<endl;
            printf("%d\n",mid);
            fflush(stdout);
            cin>>s;
            int cnt = mid - (l-1) + 1;
            if(s[0] == 'V')
                break;
            else
            {
                if(cnt%2 == 0)
                {
                    if(cflag == 0&&s[0] == 'F')
                        r = mid-1;
                    else if(cflag == 0&&s[0] == 'M')
                    {
                        l = mid+1;
                        cflag = 1;
                    }
                    else if(cflag == 1&&s[0] == 'M')
                    {
                        r = mid-1;
                    }
                    else
                    {
                        l = mid+1;
                        cflag = 0;
                    }
                }
                else
                {
                    if(cflag == 1&&s[0] == 'M')
                    {
                        l = mid+1;
                    }
                    else if(cflag == 1&&s[0] == 'F')
                    {
                        r = mid - 1;
                    }
                    else if(cflag == 0&&s[0] == 'F')
                    {
                          l = mid+1;
                    }
                    else r = mid - 1;
                }
            }
        }
        return 0;
    }


Measured memory_bytes: 852
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>


long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

    int N;cin>>N;
    long long  K;cin>>K;
    char s[N+2];
    s[0]='R';
    s[N+1]='L';
    for(int i=1;i<=N;i++){
        cin>>s[i];
    }
    char before='R';
    long long cnt=0;
    long long edge=0;
    long long ans=0;//not happy
    for(int i=1;i<N+2;i++){
        if(before=='R'&& s[i]=='L'){
            if(i==1 ||i==N+1){
            ans++;
            edge++;
            }
            else{
                ans+=2;
                cnt++;
            }

        }
        before=s[i];
    }

    long long t=min(K,cnt);
    long long p=0;
    long long l=max(p,K-cnt);//edgeの操作可能回数
    l=min(edge,l);
    p=1;
    ans=max(p,ans-2*t-l);
    
    cout<<N-ans<<endl;

 return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

string s;

int main()
{
    cin >> s;
    int ans, N = s.size();
    ans = N;
    for (int i = 0; i + 1 < N; i++)
    {
        if (s[i] != s[i + 1])
        {
            ans = min(max(N - i - 1, i + 1), ans);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, s[500010], cnt;
void merge(int left, int mid, int right) {
	cnt += right - left;
	int n1 = mid - left, n2 = right - mid;
	int* l = new int[n1 + 1], * r = new int[n2 + 1];
	rep(i, n1)l[i] = s[left + i];
	rep(i, n2)r[i] = s[mid + i];
	l[n1] = r[n2] = INF;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		if (l[i] < r[j]) {
			s[k] = l[i];
			i++;
		}
		else {
			s[k] = r[j];
			j++;
		}
	}
}

void mergesort(int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergesort(left, mid);
		mergesort(mid, right);
		merge(left, mid, right);
	}
}
signed main() {
	cin >> n;
	rep(i, n)cin >> s[i];
	mergesort(0, n);
	rep(i, n - 1)cout << s[i] << " ";
	cout << s[n - 1] << endl << cnt << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int N; cin >> N;
    vector<int> a(N);
    int ans = 0;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        int x = i + 1;
        if(x % 2 == 1 && a[i] % 2 == 1) ans++;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <algorithm>
using namespace std;

int main()
{
   string x;
    while(cin>>x){
        int a = 0,b = 0,c = 0;
        for(int i = 0;i < 3;i++){
            if(x[i] == 'a') a++;
            if(x[i] == 'b') b++;
            if(x[i] == 'c') c++;
        }
        if(a == 1&&b == 1&&c == 1)
            cout<<"Yes"<<endl;

        else cout<<"No"<<endl;
        /*if(x == "abc" || x == "acb" || x == "bac" || x == "bca" || x == "cab" || x == "cba"){
            cout<<"Yes"<<endl;
        }
        else cout<<"No"<<endl;*/
    }

    return 0;
}



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

int
main(int argc, char *argv[])
{
    char o[100] = {}; char e[100] = {};
    scanf("%s%s", o, e);
    
    for(int i = 0; i < strlen(e); i++){
        printf("%c%c", o[i], e[i]);
    }
    if(strlen(o) > strlen(e)) printf("%c\n", o[strlen(o) - 1]);
    else printf("\n");
    
    return 0;
}


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

typedef long long ll;
typedef double db;

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, MOD = 1e9 + 7, N = 1e5 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);

void test() {
    char c; cin >> c;
    int k;
    k = c - 'a';
    if (k <= 25 and k >= 0) {
        cout << "a\n";
    } else {
        cout << "A\n";
    }
}

int main() {
      fast_io();
      #ifdef HOME
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
      #endif
      cout << fixed << setprecision(15);
      int t = 1;
      // cin >> t;
      for (int i = 1; i <= t; ++i) {
          test();
      }
      #ifdef HOME
          cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
      #endif
      return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
    int n;
    int score[256][3] = {0};
    int i, j;

    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d %d %d", score[i], score[i] + 1, score[i] + 2);
    }
    for (i = 0; i < 3; i++){
        int num[128] = {0};
        for (j = 0; j < n; j++){
            num[score[j][i]]++;
        }
        for (j = 0; j < n; j++){
            if (num[score[j][i]] > 1){
                score[j][i] = 0;
            }
        }
    }
    for (i = 0; i < n; i++){
        printf("%d\n", score[i][0] + score[i][1] + score[i][2]);
    }

    return 0;
}

Measured memory_bytes: 600
import java.util.*;
class Main {
	static int n;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			n = sc.nextInt();
			if (n == 0) break;
			int maxDistance = 0;
			Map<Integer, Integer> map = new HashMap<Integer, Integer>(n);
			for (int i = 0; i < n; i++) {
				int p = sc.nextInt();
				int d = sc.nextInt() + sc.nextInt();
				map.put(d, p);
				maxDistance = Math.max(d, maxDistance);
			}
			System.out.printf("%d %d\n", map.get(maxDistance), maxDistance);
		}
	}
}

Measured memory_bytes: 16000
#include <cstdio>
#include <cmath>
#include <queue>
#include <utility>

using namespace std;

#define pi 3.141592653589793

queue< pair< double , double > > points;

void make_coordination( int n, queue< pair< double , double > > points, double length ){

    double left[2], right[2], x, y, i = 0;

    left[0] = 0.0;
    left[1] = 0.0 ;

    for( i = 0 ; i < n ;  i++ ){

    while(1){

        left[0] = points.front().first;
        left[1] = points.front().second;

        points.pop();

        right[0] = points.front().first;
        right[1] = points.front().second;

 

        points.push( make_pair( left[0], left[1] ) );

        x =  ( right[0] - left[0] ) / 3.0 + left[0] ;
        y =  ( right[1] - left[1] ) / 3.0  + left[1] ;

        points.push( make_pair( x , y ) );

        x = left[0] + ( ( right[0] - left[0] ) / 3.0 ) * cos( pi / 3 ) - ( ( right[1] - left[1] ) / 3.0 ) * sin( pi / 3 ) + ( right[0] - left[0] ) / 3.0;
        y = left[1] + ( ( right[0] - left[0] ) / 3.0 ) * sin( pi / 3 ) + ( ( right[1] - left[1] ) / 3.0 ) * cos( pi / 3 ) + ( right[1] - left[1] ) / 3.0 ;



        points.push( make_pair( x , y ) );    

        x =  2 * ( right[0] - left[0] ) / 3.0 + left[0] ;
        y =  2 * ( right[1] - left[1] ) / 3.0  + left[1] ;

        points.push( make_pair( x , y ) );



        if( right[0] > 99.99999999  ) { 
            
            points.push( make_pair( right[0], right[1] ) );
            points.pop();
            break;
        
        }

    }

    }

    int j = points.size(); 

    for( i = 0; i < j; i++){

        printf("%f %f\n", points.front().first, points.front().second);
        points.pop();

    }

}


int Koch_curve(int n){

    int i = 0;
    double x, y, length, left, right;

    x = 0.0;
    y = 0.0;

    points.push( make_pair( x, y) );

    x = 100.0;
    y = 0.0;

    points.push( make_pair( x, y) );

    length = 100.0;

        make_coordination( n,  points, length);

    return 0;

}





int main(){

    int n;

    scanf("%d", &n);

    Koch_curve(n);
   
    return 0;

}

Measured memory_bytes: 2828
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

	n = n - m;


	cout << (1900 * m + 100 * n) * (ll)pow(2, m) << endl;
}


Measured memory_bytes: 384
"use strict";

function main(input){
  const args = input.trim().split('\n');
  const n = parseInt(args[0],10);
  const h = args[1].split(' ').map(_=>parseInt(_,10));
  
  const dp = Array(n).fill(0); // i => i-stepでの最小コスト
  dp[1] = Math.abs(h[1] -h[0]);
  for(let i=2; i<n; i++){
    const cost1 = dp[i-1] + Math.abs(h[i] - h[i-1]);
    const cost2 = dp[i-2] + Math.abs(h[i] - h[i-2]);
    dp[i] = Math.min(cost1, cost2);
  }
  
  console.log(dp[n-1]);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 27556
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, P> PP;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
struct edge
{
    int to, cost;
    edge(int to, int cost) : to(to), cost(cost) {}
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(3);
    int n, m, p, a, b;
    while(cin >> n >> m >> p >> a >> b, n | m | p)
    {
        a--, b--;
        vector<int> t(n);
        for(int i = 0; i < n; i++) cin >> t[i];
        vector<edge> G[m];
        for(int i = 0; i < p; i++)
        {
            int x, y, z; cin >> x >> y >> z;
            x--, y--;
            G[x].push_back(edge(y, z));
            G[y].push_back(edge(x, z));
        }
        priority_queue<PP, vector<PP>, greater<PP>> que;
        vector<vector<double>> cost(m, vector<double>(1<<n, INF));
        que.push(PP(0.0, P(a, 0)));
        cost[a][0] = 0;
        while(not que.empty())
        {
            PP p = que.top(); que.pop();
            int v = p.second.first;
            int bit = p.second.second;
            for(int u = 0; u < G[v].size(); u++)
            {
                edge e = G[v][u];
                for(int i = 0; i < n; i++)
                {
                    int nb = bit | (1<<i);
                    if(not (bit & (1<<i)))
                    {
                        double c = (double)e.cost / t[i];
                        if(cost[v][bit] + c < cost[e.to][nb])
                        {
                            cost[e.to][nb] = cost[v][bit] + c;
                            que.push(PP(cost[e.to][nb], P(e.to, nb)));
                        }
                    }
                }
            }
        }
        double ans = INF * 1.0;
        for(int i = 0; i < (1<<n); i++) ans = min(ans, cost[b][i]);
        if(ans >= INF) cout << "Impossible" << endl;
        else cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 4524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string S;
	int Q;cin>>S>>Q;
	int rev=0;
	deque<char> str;
	for(auto c:S)str.push_back(c);
	
	FOR(q,1,Q){
		int T;cin>>T;
		if(T==1) rev++;
		else{
			int F; char c;
			cin>>F>>c;
			if(F==1){
				if(rev%2) str.push_back(c);
				else str.push_front(c);
			}
			else{
				if (rev%2) str.push_front(c);
				else str.push_back(c);
			}
		}
	}
	if (rev%2) reverse(all(str));
	for(auto i:str)cout<<i;
}


Measured memory_bytes: 976
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n,m,p;
int main(){
  int x;
  while(cin>>n>>m>>p,n||m||p){
    map<int,int> ma;
    int sum = 0;
    for(int i = 1;i <=n;i++){
      cin>>x;
      ma[i]+=x;
      sum +=x*100;
    }
    sum -=(sum*p)/100;
    if(ma[m]==0)
      sum = 0;
    else{
      sum /=ma[m];
    }
    cout <<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define RANGE(i,n) for(int i=0;i<n;i++)
typedef long long ll;
struct P{
    ll var1;
    ll var2;
};
bool operator< ( const P &one, const P &two){
    return one.var1 < two.var1;
};
bool operator> ( const P &one, const P &two){
    return one.var1 > two.var1;
};

using namespace std;

ll souwa(ll s, ll num){
    return (s + s+num-1) * num / 2;
}

signed main() {
    int N, L;
    cin >> N >> L;
    ll start = L;
    ll end = L + N -1;
    if ( start > 0){
        cout << souwa(start + 1, N-1) << endl;
    }else if(end < 0){
        cout << souwa(start , N-1) << endl;
    }else{
        cout << souwa(start , N) << endl;
    }
}




Measured memory_bytes: 256
n, m = map(int, input().split())
ab = []
for i in range(n):
    ab.append(list(map(int, input().split())))

cd = []
for i in range(m):
    cd.append(list(map(int, input().split())))

for i in range(n):
    a, b = ab[i]
    dis = 10 ** 9
    point = 0
    for j in range(m):
        c, d = cd[j]
        if abs(a - c) + abs(b - d) < dis:
            point = j + 1
            dis = abs(a - c) + abs(b - d)
    print(point)


Measured memory_bytes: 9136
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
 
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cassert>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <numeric>
#include <time.h>
#include <stack>
#include <bitset>

#define prev asasddlsa
#define rank aljds

#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i++)
 
using namespace std;
 
typedef long long ll;
typedef double dbl;
 
template<typename T>
void print(const vector<T>& s){
    for (auto x : s)
        cout << x << " ";
    cout << endl;
}
 
template<class T>   
void print(const T* s, int n){
    for (int i = 0; i < n; i++)
        cout << s[i] << ' ';
    cout << endl;
}

template<class T>
void print(vector<vector<T>> s){
    for (int i = 0; i < s.size(); i++)
        print(s[i]);
}

int solve(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    m1 += h1 * 60;
    m2 += h2 * 60;
    if (m2 >= m1)
        cout << m2 - m1 - k << endl;
    else
        cout << m1 + 60 * 24 - m2 - k << endl;
    return 0;    
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(10);
    cout << fixed; 
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<functional>
#include<list>
#define P pair<int,int>
#define mod 1000000007
using namespace std;

P a[200000];
int hanten[2] = { 1,0 };
signed main() {
	int b; cin >> b;
	for (int c = 0; c < b; c++) {
		int d; scanf("%d", &d);
		a[c] = P(d, 0);
	}
	for (int c = 0; c < b; c++) {
		int d; scanf("%d", &d);
		a[b + c] = P(d, 1);
	}
	sort(a, a + b * 2);
	long long ans = 1;
	int count[2]{};
	for (int i = 0; i < b * 2; i++) {
		int s = a[i].second;
		if (count[hanten[s]] == 0) {
			count[s]++;
		}
		else {
			ans = ans*count[hanten[s]] % mod;
			count[hanten[s]]--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
LRC = $<.map{|ln| ln.split.map(&:to_i) }
N,M = LRC.shift

RC = [[1,0]]
LRC.sort_by{|l,| l }.each{|l,r,c|
	i = RC.bsearch_index{|ir,| l<=ir }
	ic = i ? RC[i][1] : break
	j = ((i...RC.size).bsearch{|j| c+ic<RC[j][1] }||RC.size)
	k = ((j...RC.size).bsearch{|k| r<RC[k][0] }||RC.size)
	RC.slice!(j...k)
	RC.insert(j,[r,c+ic]) if RC[j-1][0] < r
}

r,c = RC[-1]
p(r<N ? -1 : c)


Measured memory_bytes: 28552
apple = list(map(int, input().split()))
x = apple[0]
y = apple[1]        #to eat
a = apple[2]
b = apple[3]        #i have
c = apple[4]

p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

XredApl = []
for i in range(x):
    XredApl.append(p[i])

YgrnApl = []
for i in range(y):
    YgrnApl.append(q[i])
    
fnlst = XredApl + YgrnApl + r 
fnlst.sort(reverse=True)
s = 0
for i in range(x+y):
    s += fnlst[i]
    
print(s)


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

using namespace std;

int main()
{
    int n, m;
    vector<pair<long long int, long long int>> v;
    long long int ans = 0;

    cin >> n >> m;

    for (int i = 0; i < n; i++) {
        long long int a, b;

        cin >> a >> b;

        v.push_back(make_pair(a, b));
    }

    sort(v.begin(), v.end());

    for (auto x: v) {
        if (x.second > m) {
            ans += x.first * m;
            break;
        }
        else {
            ans += x.first * x.second;
            m -= x.second;
        }

    }

    cout << ans << endl;
}


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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define float			double
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vc				vector<char>
#define vb				vector<bool>
#define vf				vector<float>
#define vs				vector<string>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define hashmap         unordered_map
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

template<class T>
void printV(vector<T> a) {for (auto v : a)cout << v << " ";}
template<class T>
void readV(vector<T>& a) {int n = a.size(); for (int i = 0 ; i < n ; i++)cin >> a[i];}
template<class T>
void printA(T* a , int n) {for (int i = 0; i < n  ; i++)cout << a[i] << " ";}
template<class T>
void readA(T* a , int n) {for (int i = 0 ; i < n ; i++)cin >> a[i];}
auto clk = clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
void run_time() {cout << endl<<"Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;}

void aryan_pandeya() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


int32_t main() {
	aryan_pandeya();
	FIO;

		
	int n ;
	cin>>n ;

	int count = 0; 


	for(int i = 1 ; i<n ; i++){
		if(n%i==0){
			count+=(n/i)-1;
		}
		else{
			count+=(n/i);
		}
	}
	cout<<count;




 



	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int mod = 1e9;
int main(){ 
  int n, k, s;
  cin >> n >> k >> s;
  if (k == 0) {
    for (int i = 0; i < n; i++) cout << (s + 1) % mod << " ";
    cout << endl;
  } else {
    for (int i = 0; i < k; i++) {
      cout << s << " ";
    }
    for (int i = k; i < n; i++) {
      cout << (s + 1 != mod ? (s + 1) % mod : s + 1) << " ";
    }
    cout << endl;
  }
  return 0;
} 

Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;

int n;
int mod=10007;
string str;
int dp[1<<3][1001];
int bit[1001];
int main(void){
	scanf("%d",&n);
	cin >> str;
	for(int i=0;i<str.size();i++){
		if(str[i]=='J')bit[i]=0;
		if(str[i]=='O')bit[i]=1;
		if(str[i]=='I')bit[i]=2;
	}
	dp[1][0]=1;
	int res=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<1<<3;j++){
			if(dp[j][i]>0){
				for(int k=0;k<1<<3;k++){
					bool flag=false;
					for(int l=0;l<3;l++){
						if((j>>l & 1) && (k>>l & 1))flag=true;
					}
					if(!flag)continue;
					if(k>>bit[i] & 1)dp[k][i+1]=(dp[k][i+1]+dp[j][i])%mod;
				}
			}
		}
	}
	for(int i=0;i<1<<3;i++)res=(res+dp[i][n])%mod;
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 1260
def main():
    N, M = map(int,input().split())
    A = list(map(int,input().split()))
    Sum = sum(A)
    count = 0
    ans = "No"
    for a in A:
        if a >= Sum / (4 * M):
            count += 1
    if(count >= M):
        ans = "Yes"
    print(ans)
main()

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

int n;
//int a[200010];
int b[200010];

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

    cin >> n;

    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        if(n % 2 == 0){
            if(i % 2 == 0){
                b[n / 2 + i / 2] = a;
            }
            else {
                b[n / 2 - i / 2 - 1] = a;
            }
        }
        else {
            if(i % 2 == 0){
                b[n / 2 - i / 2] = a;
            }
            else {
                b[n / 2 + i / 2 + 1] = a;
            }
        }
    }
    for(int i = 0; i < n; ++i){
        if(i != 0){
            cout << " ";
        }
        cout << b[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2944
s=input()
K=int(input())
s_set=set([])
for i in range(len(s)):
    for j in range(i,len(s)):
        if len(s[i:j+1])<=K:
            s_set.add(s[i:j+1])
L=sorted(list(s_set))
print(L[K-1])

Measured memory_bytes: 42332
if __name__ == "__main__":
    N = int(input())
    B = list(map(int, input().split()))

    # Aの数列を作っていく
    A = list()
    A.append(B[0])
    for i in range(1, N-1):
        A.append(min(B[i-1], B[i]))
    A.append(B[-1])

    print(sum(A))


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

#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fst first
#define snd second

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<ll> dp(n);
    for (int i = 1; i < n; i++)
    {
        dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
        for (int j = 2; j <= k && i - j >= 0; j++)
        {
            dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
        }
    }
    cout << dp[n - 1];
    return 0;
}

Measured memory_bytes: 1408
import sys
sys.setrecursionlimit(10**6)
from collections import deque
n,m=map(int,input().split())
edges=[[] for i in range(n)]
for i in range(m):
    u,v=map(int,input().split())
    edges[u-1].append(v-1)
s,t=map(int,input().split())
inf=100000000000
score=[[inf]*3 for i in range(n)]
now=deque()
now.append(s-1)
score[s-1][0]=0
def bfs(dep,l):
    global n,m,edges,s,t,score,inf,now
    f=False
    for i in range(l):
        ne=now.popleft()
        for j in edges[ne]:
            if score[j][dep%3]==inf:
                score[j][dep%3]=dep
                now.append(j)
    l_ne=len(now)
    if l_ne:bfs(dep+1,l_ne)
bfs(1,1)
if score[t-1][0]!=inf:
    print(score[t-1][0]//3)
else:
    print(-1)

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

int main(){
  int c=0;
  char S[12],T[12];
  int L;
  int i;
  scanf("%s\n",S);
  scanf("%s\n",T);
  L=strlen(S);
  
  for(i=0;i<L;i++){
    if(S[i]!=T[i]){
      c=1;
      break;
    }
  }
  if(c==0)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(11);
    int a, b, k;
    cin >> a >> b >> k;
    int n = min(a, b);
    int cnt = 0;
    for(int i = n; i >= 1; i--){
        if(a%i == 0 && b%i == 0) cnt++;
        if(cnt == k){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256