akhauriyash/Code-Regression huggingface dataset:
//#include "pch.h"
#include <iostream>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)
typedef long long ll;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	
	int num1 = stoi(s.substr(0,2));
	int num2 = stoi(s.substr(2));
	
	//cout << num1 << ", " << num2 << endl;
	
	
	//AMBIGUOUSの場合
	if ((1 <= num1 && num1 <= 12) && (1 <= num2 && num2 <= 12)){
	    cout << "AMBIGUOUS" << endl;
	}
	
	//YYMMの場合
	else if ((num1 == 0 || num1 > 12) && (1 <= num2 && num2 <= 12)){
	    cout << "YYMM" << endl;
	}
	
	//MMYYの場合
	else if ((1 <= num1 && num1 <= 12) && (num2 == 0 || num2 > 12)){
	    cout << "MMYY" << endl;
	}
	
	else{
	    cout << "NA" << endl;
	}
	
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(10)<<fixed;
  double r;
  cin>>r;
  cout<<r*2*3.141592<<'\n';
  return 0;
}


Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int k;
    cin>>k;

    cout<<((1+k)/2)*(k/2)<<endl;

    return 0;
}


Measured memory_bytes: 1016
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    ll a,b,k;
    cin>>a>>b>>k;
    if(a>=k){
        cout<<a-k<<" "<<b;
    }else{
        cout<<0<<" "<<max(b-(k-a),(ll)0);
    }
    
    return 0;
}

Measured memory_bytes: 256
"use strict";
main(require("fs").readFileSync("/dev/stdin", "utf8").replace(/\r?\n$/, "").split(/\r?\n/));

function main(lines){
	function Dice(labels){
		this.t = labels[0];
		this.s = labels[1];
		this.e = labels[2];
		this.w = labels[3];
		this.n = labels[4];
		this.b = labels[5];
	}
	Dice.prototype.roll = function(dir){
		var temp;
		if(dir == "N"){
			temp = this.t;
			this.t = this.s;
			this.s = this.b;
			this.b = this.n;
			this.n = temp;
		}
		else if(dir == "S"){
			temp = this.t;
			this.t = this.n;
			this.n = this.b;
			this.b = this.s;
			this.s = temp;
		}
		else if(dir == "W"){
			temp = this.t;
			this.t = this.e;
			this.e = this.b;
			this.b = this.w;
			this.w = temp;
		}
		else if(dir == "E"){
			temp = this.t;
			this.t = this.w;
			this.w = this.b;
			this.b = this.e;
			this.e = temp;
		}
	};

	var dice = new Dice(lines[0].split(" "));
	lines.slice(2).forEach(function(line){
		line = line.split(" ");
		var t = line[0], s = line[1];
		for(var i=0;i<8;i++){
			if(dice.s == s) break;
			dice.roll("NW"[i%4/3|0]);
		}
		while(dice.t != t) dice.roll("W");
		console.log(dice.e);
	});
}

Measured memory_bytes: 15432
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
#define ff first
#define ss second
#define pb push_back

int const lim = 1e6+5 ;
bool flag = false;
bool isprime[lim+5];
vector<ll>primes;
int factor[lim+5] ;

void sieve(){
    for(ll i=0;i<lim;i++) isprime[i]=true;
    for(ll i=4;i<lim;i+=2) isprime[i]=false;
    isprime[0]=isprime[1]=0;
	primes.pb(2);
    for(ll i=3;i<lim;i++) {
        if(isprime[i]) {
            primes.pb(i);
            for(ll j=i*i;j<lim;j+=i)
                isprime[j]=false;
        }
    }
}
void fq(int num) {
	if(isprime[num]) {
		factor[num] += 1;
		if(factor[num] > 1 && num != 1) flag = true;
	}
	else{
		for(int i=0;i<primes.size() && primes[i]*primes[i]<=num;i++) {
			int p = primes[i] , cnt = 0;
			if(num % p != 0) continue;
			while(num % p == 0) {
				num /= p;
				cnt += 1;
			}
			factor[p] += 1;
			if(factor[p] > 1) {
				flag = true;
				return ;
			}
		}
		if(num > 1) {
			factor[num] += 1;
			if(factor[num] > 1) flag = true;
		}
	}
	
}

void solve() {
	int n; cin >> n;
	int arr[n + 5] ;

	for(int i=1; i<=n; i++) {
		cin>>arr[i];
	}
	int gcd = arr[1] ;
	for(int i=1;i<=n;i++) gcd = __gcd(gcd, arr[i]);
	if(gcd != 1) cout<<"not coprime"<<endl;
	else {
		for(int i=1;i<=n;i++) {
			fq(arr[i]);
			if(flag) break;
		}
		if(flag) cout<<"setwise coprime"<<endl;
		else cout<<"pairwise coprime"<<endl;
	}
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
 	
 	sieve() ;
    int t = 1, no = 0;
    // cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 9204
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


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


		// 読み込み
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] temp;

		line=br.readLine();
		temp=line.split(" ");

		String a = temp[0].substring(0,1).toUpperCase();
		String b = temp[1].substring(0,1).toUpperCase();
		String c = temp[2].substring(0,1).toUpperCase();


			System.out.println(a+b+c);


	}
}


Measured memory_bytes: 21332
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int n, r;
	int card[50];
	while(cin >> n >> r, n){
		for(int i=0;i<n;i++) card[i] = n-i;
		for(int i=0;i<r;i++){
			int p, c; cin >> p >> c;
			rotate(card, card+p-1, card+p+c-1);
		}
		cout << card[0] << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int maxn = 21;
vector<int> f[maxn][maxn];
int main(){
	for(int i = 0; i < maxn; i++){
		for(int j = 0; j <= i; j++){
			f[i][j].resize(1<<i);
		}
	}
	int n, k; cin >> n >> k;
	for(int i = 0; i <= n; i++){
		string s; cin >> s;
		for(int j = 0; j < (1<<i); j++){
			if(s[j] == '1') f[i][0][j] = 1;
		}
	}
	for(int i = n; i >= 0; i--){
		for(int j = 0; j < i; j++){
			for(int z = 0; z < (1<<i); z++){
				int val = f[i][j][z];
				if(val == 0) continue;
				{
					f[j][j][z&((1<<j)-1)] += val;
				}
				{
					for(int rot = 0; rot < 2; rot++){
						int pos = -1;
						for(int t = j; t < i; t++){
							if(((z>>t)&1) == rot){
								pos = t;
								break;
							}
						}
						if(pos != -1){
							int nz = (z&((1<<j)-1)) + ((z>>pos)<<j);
							f[i - pos + j][j + 1][nz] += val;
						}
					}
				}
			}
		}
		for(int j = 0; j < (1<<i); j++){
			if(f[i][i][j] >= k){
				for(int z = i - 1; z >= 0; z--) cout << ((j>>z)&1);
				cout << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 167616
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets.to_i
d=array(n,1)
n.times do|i|
  d[i]=gets.to_i
end
a=d.uniq
unless a==nil
  puts a.size
else
  puts n
end

Measured memory_bytes: 3836
N = int(input())
t,x,y = 0,0,0
badtrip=False
for i in range(N):
    ti, xi, yi = list(map(int, input().split()))
    absx = abs(x-xi)
    absy = abs(y-yi) 
    if (absx+absy)%2 == (ti-t)%2 and (ti-t)>=(absx+absy):
        t=ti
        x=xi
        y=yi
    else:
        badtrip=True
        break

if badtrip:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
mod = 10**9+7
import sys
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations, combinations_with_replacement
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = Counter(l)

# d = defaultdict(int)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))


n,m = MI()
h = LI()
a = []

d = defaultdict(int)
for _ in range(m):
	aa,bb = MI()
	d[(aa-1)] = max(d[bb-1],d[(aa-1)])
	d[(bb-1)] = max(d[bb-1],d[(aa-1)])
	if not aa==bb:
		if h[aa-1]>=h[bb-1]:
			a.append(bb-1)
		if h[bb-1]>=h[aa-1]:
			a.append(aa-1)

print(n-len(set(a)))
# ans=0
# for i in range(n):
# 	if h[i]<=d[i]:
# 		ans += 0
# 	else:
# 		ans += 1
	# tmp = d[str(h[i])]
	# k = 1
	# if len(tmp)>0:
	# 	tmp = [int(s) for s in tmp.split(':') if not s=='']
	# 	for s in tmp:
	# 		if int(h[i])<=s:
	# 			k = 0
	# ans+=k
# print(ans)
















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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    string s;
    cin >> s;
    int to_L[s.size()], to_R[s.size()];
    int cnt = 0;
    rep(i, s.size())
    {
        if (s[i] == 'R')
            cnt = i;

        to_R[i] = cnt;
    }
    cnt = 0;
    for (int i = (s.size() - 1); i >= 0; i--)
    {
        if (s[i] == 'L')
            cnt = i;
        to_L[i] = cnt;
    }
    vector<int> pos(s.size(), 0);
    rep(i, s.size())
    {
        if (s[i] == 'L')
        {
            if ((i - to_R[i]) % 2 == 0)
            {
                pos[to_R[i]]++;
            }
            else
            {
                pos[to_R[i] + 1]++;
            }
        }
        else
        {
            if ((to_L[i] - i) % 2 == 0)
            {
                pos[to_L[i]]++;
            }
            else
            {
                pos[to_L[i] - 1]++;
            }
        }
    }
    rep(i, s.size())
    {
        cout << pos[i] << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4644
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

def mul_count(min_val, max_val, div_val):
    return max_val // div_val - (min_val - 1) // div_val

A, B, C, D = map(int, input().split())

c_cnt = mul_count(A, B, C)
d_cnt = mul_count(A, B, D)
cd_cnt = mul_count(A, B, lcm(C, D))
print(B - A - (c_cnt + d_cnt - cd_cnt) + 1)

Measured memory_bytes: 63980
def isPalindrome(s5):
    if s5[0] == s5[-1] and s5[1] == s5[-2]:
        return True
    return False


a, b = map(int, input().split(' '))
ans = 0
for i in range(a, b+1):
    if isPalindrome(str(i)):
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include<cstdio>
#include<vector>


using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;


void min_u(ll&m, ll v)
{
	if(m>v) m=v;
}


int main(void)
{
	int q, h, s, d, n;

	while(scanf("%d%d%d%d%d", &q, &h, &s, &d, &n)==5)
	{
		vi c={q, h, s, d};
		vi v={1, 2, 4, 8};
		vll dp(8+1, q*8LL);

		dp[0]=0;
		for(int i=0;i<c.size();i++)
		{
			for(int j=0;j+v[i]<dp.size();j++)
			{
				min_u(dp[j+v[i]], dp[j]+c[i]);
			}
		}
		ll ans=n/2*dp[8];
		if(n&1) ans+=dp[4];

		printf("%lld\n", ans);
	}

	return 0;
}


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

bool arr[1000000] = {};

void sieve(){
	for(int i = 2; i < 1000000; i++){
		if(arr[i])
			continue;
		for(int j = i*2; j < 1000000; j+=i)
			arr[j] = true;
	}
}

int check(int n){
	int counter = 0;
	for(int i = 2; i <= n; i++)
		if(!arr[i])
			counter++;
	return counter;
}

int main(){
	sieve();
	int a;
	while(cin >> a){
		cout << check(a) << endl;
	}
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

	if(A >= 13) cout << B << endl;
	else if(A >= 6 && A <= 12) cout << B / 2 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 256
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll n,m,c,ans;
void solve()
{
    cin>>n>>m;
    map<ll,ll>mp;
    for(ll i=0;i<n;i++)
    {
        ll a,b;cin>>a>>b;
        mp[a]+=b;
    }
    for(auto it:mp)
    {
        if(m)
        {
            ll temp=min(it.second,m);
            ans+=temp*it.first;m-=temp;
        }
        else
            break;
    }
    cout<<ans<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int64_t>>;
int main(){
  int N;cin>>N;
  Graph G(N);
  for(int i=0;i<N-1;i++){
  int64_t a,b;cin>>a>>b;a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }vector<int64_t>c(N);
  for(int i=0;i<N;i++)
    cin>>c.at(i);
  sort(c.begin(),c.end());
  reverse(c.begin(),c.end());
  int64_t M=0;
  for(int i=1;i<N;i++)
    M+=c.at(i);
  vector<int64_t>d(N,-1);d[0]=c.at(0);
  queue<int64_t>que;
  for(int i=1;i<N;i++)
    que.push(c.at(i));
  queue<int64_t>que1;que1.push(0);
  while(!que1.empty()){
  int64_t u=que1.front();
    que1.pop();
    for(auto v:G[u]){
    if(d[v]!=-1)
      continue;
      else{
      int64_t a=que.front();
        que.pop();
        d[v]=a;
        que1.push(v);
      }
    }
  }cout<<M<<endl;
  for(int i=0;i<N-1;i++)
    cout<<d[i]<<" ";
  cout<<d[N-1]<<endl;
  
  return 0;
}

Measured memory_bytes: 4240
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from math import sqrt

n = ni()
ans = n-1

for i in range(2, int(sqrt(n)) + 2):
    if n == i:
        break
    if n % i == 0:
        ans = min(ans, i + n//i - 2)

print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  lint a,b,c,k;
  cin>>a>>b>>c>>k;
  lint count=0;
  if(a>k){
    count+=k;
  }
  else{
    count+=a;
  }
  k-=a;
  if(k>0){
    k-=b;
    if(k>0){
      count-=k;
    }
  }
  cout<<count;
}

Measured memory_bytes: 3612
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.IO.Pipes;
using System.ComponentModel;
using System.Drawing;
using Microsoft.VisualBasic;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] Arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            if ((double)Arr[0] / (double)Arr[2] <= (double)Arr[1]) 
            {
                Console.WriteLine("Yes");
            }else
            {
                Console.WriteLine("No");
            }

        }

    }
}


Measured memory_bytes: 28276
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n, k;
	cin >> n >> k;
	int a[n];
	int pos1;
	zip(i, 0, n)
	{
		cin >> a[i];
		if (a[i] == 1)
		{
			pos1 = i;
		}
	}
	int ans = (n - 1) / (k - 1);
	if ((n - k) % (k - 1) != 0)ans++;
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let s = get!(String);
    let mut map = BTreeMap::new();
    for c in s.chars() {
        *map.entry(c).or_insert(0) += 1;
    }

    for (k, v) in map {
        if v != 2 {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


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

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

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

const int mod = 1000000007;

typedef int64_t ll;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a) {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a) {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

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

  vector<mint> a(n);
  mint sum = 0;
  mint ans = 0;

  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }

  rep(i, n - 1) {
    sum -= a[i];
    ans += a[i] * sum;
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 4844
input()
strs = input().split(' ')
nums = [int(i) for i in strs]

ct = 0
b_flag = False
while(1):
  for i, num in enumerate(nums):
    if num % 2 == 0:
      nums[i] = num/2
      continue
    else:
      b_flag = True
      break
  if b_flag:
    break
  ct += 1
print(ct)

Measured memory_bytes: 39792
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;

int main(){
    double h, a, t;
    cin >> h >> a;
    t = ceil(h/a);
    cout << t;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;

int main(){

	string s;
	cin >> s;
	int ans=700;
	if(s[0]=='o'){
		ans+=100;
	}
	if(s[1]=='o'){
		ans+=100;
	}
	if(s[2]=='o'){
		ans+=100;
	}
	cout << ans << endl;

	return 0;
}

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

#define ll long long int
#define vvl vector<vector<ll>>
#define MOD 1000000007

int main() {

    int N, K;
    cin >> N >> K;

    vvl P(2010, vector<ll>(2010, 0));

    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= i; j++) {
            if (j == 0) {
                P[i][j] = 1;
            }
            else {
                P[i][j] = (P[i-1][j-1] + P[i-1][j]) % MOD;
            }
        }
    }

    // for (int i = 0; i <= N; i++) {
    //     for (int j = 0; j <= N; j++) {
    //         cout << P[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    for (int i = 1; i <= K; i++) {
        cout << (P[N-K+1][i] * P[K-1][i-1]) % MOD << endl;
    }

    return 0;
}


Measured memory_bytes: 31872
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = A[0]
s = (N - 2) // 2
if s > 0:
    ans += sum(A[1:1 + s]) * 2
if (N - 2) % 2:
    ans += A[1 + s]
print(ans)

Measured memory_bytes: 31512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    int n = N;
    int s = 0;
    while (n != 0)
    {
        s += n % 10;
        n /= 10;
    }
    if (N % s == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if (s[0]!=s[1]&&s[1]!=s[2]&&s[2]!=s[0]){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

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

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = a*x + b*y;
    for (int i = 0; i <= max(x, y); i++) {
        ans = min(ans, 2*c*i+max(x-i, 0)*a+max(y-i, 0)*b);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int H, W;
    cin >> H >> W;

    vector<string> a(H);
    rep(i, H) cin >> a[i];

    rep(i, H + 2) {
        rep(j, W + 2) {
            if (i == 0 || i == H + 1) {
                cout << '#';
            }
            else if (j == 0 || j == W + 1) {
                cout << '#';
            }
            else {
                cout << a[i - 1][j - 1];
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n,a,b;
  cin>>n>>a>>b;
  int M = min(a,b);
  int m;
  if(a+b<=n){
    m = 0;
  }else{
    m = a+b-n;
  }
  cout<<M<<' '<<m<<endl;
  
  return 0;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

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

    bool flag = true;
    for (int i = N - 1; i >= 1; --i)
    {
        if (H[i] < H[i - 1])
        {
            if (H[i - 1] - H[i] == 1) 
            {
                H[i - 1]--;
            }
            else 
            {
                flag = false;
                break;
            }
        }
    }
    string ans = flag ? "Yes" : "No";
    cout << ans << endl;
}


Measured memory_bytes: 1024
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim n As Integer = NextInt()
        Dim a(3 * n - 1) As Integer
        For i As Integer = 0 To 3 * n - 1
            a(i) = NextInt()
        Next
        Array.Sort(a)
        Array.Reverse(a)

        Dim ans As Long = 0
        For i As Integer = 0 To n - 1
            ans += a(2 * i + 1)
        Next

        WriteLine(ans)
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function
End Module


Measured memory_bytes: 23640
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	ll cost[105][105];
	memset(cost, 0, sizeof(cost));

	rep(i, n) {
		rep(j, n) cin >> cost[i][j];
	}

	ll ans = 0;
	rep(i, n) {
		REP(j, i+1, n) {
			ans += min(cost[i][j], cost[j][i]);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){

	int r,d,x;
	cin>>r>>d>>x;
	for(int i=0;i<10;i++){
		x = r*x-d;
		cout<<x<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}
const int N = 2e7 + 233;
int n, pos;
bool vis[N];

inline void print() {
    int p = 0;
    rep (i, n) if (vis[i]) p += i, cout << i << "\n";
    assert(p == n);
}

int main(void) {
    read(n);
    int sum = 0;
    rep (i, n) {
	vis[i] = 1;
	sum += i;
	if (sum >= n) {
	    pos = i;
	    break;
	}
    }
    if (sum == n) {
	print();
	return 0;
    }
    int delta = sum - n;
    vis[delta] = 0;
    print();    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=110;
char lx[N];
int a[N];

int main(){
	LL n;
	scanf("%s%lld",lx+1,&n);
	int len=strlen(lx+1);
	for(int i=1;i<=len;++i) a[i]=lx[i]-48;
	LL temp=0;
	if(n<=len){
		int k=len;
		for(int i=1;i<=len;++i){
			if(a[i]!=1) {
				k=i-1;break;
			}
		}
		if(k>=n) return printf("1\n"),0;
	}
		for(int i=1;i<=len;++i){
			if(a[i]!=1) return printf("%d\n",a[i]),0;
		}
	return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder_BeginerContest
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int num = int.Parse(input);

            if (num == 1)
            {
                Console.WriteLine("Hello World");
                return;
            }
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            Console.WriteLine(a + b);

        }
    }
}


Measured memory_bytes: 11092
//  @ /\/\ BESH //

#include <bits/stdc++.h>
#define inp_out_work ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCase    int T; cin>>T; while(T--)
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,s,e) for(int i=s;i<=e;i++)
#define endl '\n'
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define pb push_back


using namespace std;

typedef long long ll;

const int MAXN = 1000001;
const int mod = 1000000007;


int main(){
    ll n;
    cin>>n;
    ll ans = n-1;
    for(ll i = 2; i * i <= n; i++)if(n%i == 0){
        ans = min(ans, i + (n/i) - 2);
    }
    cout<< ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<iostream>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

class UnionFind {
    public:
    std::vector<ll> parent;
    std::vector<ll> sizes;
    UnionFind(ll N) : parent(N), sizes(N, 1) {
        for(ll i=0; i<N; i++) parent[i]=i;
    }
    ll find(ll x){
        if(x==parent[x]) return x;
        return parent[x]=find(parent[x]);
    }
    void unite(ll x, ll y){
        ll x_class = find(x);
        ll y_class = find(y);
        if(x_class == y_class) return;
        if(sizes[x_class] < sizes[y_class])std::swap(x,y);
        parent[y_class] = x_class;
        sizes[x_class] = sizes[y_class];
        sizes[y_class] = 0;
    }
    bool same(ll x, ll y){
        return find(x)==find(y);
    }
    ll size(ll x){
        return sizes[find(x)];
    }
};

int main(){
    UnionFind uf(10005);
    int n,q, com, x, y;

    cin >> n >> q;
    REP(i,q){
        cin >> com >> x >> y;
        if(com==0){
            uf.unite(x,y);
        }
        else{
            cout << uf.same(x,y) << endl;
        }
        //REP(i,13)cout << uf.parent[i] << " ";
        //cout << endl;
    }
}


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


void solve(long long N, long long X, long long T){
    long long ans = ((N+X)-1)/X*T;
    cout<<ans<<endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    long long T;
    scanf("%lld",&T);
    solve(N, X, T);
    return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
inline int read(){
	int v=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9'){
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}
const int Maxn=100005;
int n,v,p;
LL m,a[Maxn];
bool check(int pos){
	vector<int> P;
	for (int i=1,j=0;j<n-p;j++,i++){
		if (i==pos){
			j--;continue;
		}
		P.pb(i);
	}
	LL Nw=a[pos]+m;
	for (int i=0;i<P.size();i++){
		if (Nw<a[P[i]]) return false;
	}
	LL cnt=0;
	for (int i=0;i<P.size();i++){
		cnt+=min(Nw-a[P[i]],m);
	}
	return cnt>=m*(v-p);
}
int main(){
	scanf("%d %lld %d %d",&n,&m,&v,&p);
	for (int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+1+n);
	int lo=0,hi=n;
	while (hi-lo>1){
		int mid=lo+hi>>1;
		if (check(mid)){
			hi=mid;
		}
		else{
			lo=mid;
		}
	}
	printf("%d\n",n-hi+1);
	return 0;
}

Measured memory_bytes: 1984
#include"bits/stdc++.h"
using namespace std;
#define int long long
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
constexpr long long inf = 1e17;
constexpr int mod = 1000000007;

signed main() {
	int x; cin >> x;
	for (int i = 1; i <= 180; i++) {
		if (360 * i%x == 0) {
			cout << 360 * i / x << endl; break;
		}
	}
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <cstdio>
#include <set>
using namespace std;

int N;
vector<int> tree[100];
int dp[100][(1<<4)];

int m;
string str,tmp;
int p,len;


int ans,cnt;
int t[10];

void make_tree(){
  int k=N++;
  if(str[p]=='('){
    p++;
    tree[k].push_back(N);
    make_tree();
    p++;
    tree[k].push_back(N);
    make_tree();
    p++;
  }else{
    int num=str[p]-'0';
    p++;
    dp[k][t[num]]=1;
  }
}

int input(){

  for(int i=0;i<100;i++){
    tree[i].clear();
    for(int j=0;j<(1<<4);j++)dp[i][j]=0;
  }

  getline(cin,str);
  if(str=="END")return 0;
  cin>>m;
  for(int i=1;i<=m;i++){
    t[i]=0;
    int a;
    for(int j=0;j<4;j++){
      cin>>a;
      t[i]=t[i]*2+a;
    }
  }
  getline(cin,tmp);
  N=0;
  p=0;
  len=str.size();
  make_tree();
  return 1;
}

void dfs(int pos){
  if(tree[pos].size()>0){
    int lc=tree[pos][0];
    int rc=tree[pos][1];
    dfs(lc);
    dfs(rc);
    for(int L=0;L<(1<<4);L++){
      for(int R=0;R<(1<<4);R++){
	dp[pos][L|R]+=dp[lc][L]*dp[rc][R];
	dp[pos][L&R]+=dp[lc][L]*dp[rc][R];
	dp[pos][L^R]+=dp[lc][L]*dp[rc][R];
      }
    }
  }
}

int main() {
  while(input()){
    ans=0;
    cnt=0;
    dfs(0);
    cout<<dp[0][15]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1236
n=int(input())
s=input()
w=[0]
b=[0]
for i in range(n):
    if s[i]==".":
        w.append(w[i]+1)
        b.append(b[i])
    else:
        w.append(w[i])
        b.append(b[i]+1)
ans=1000000
cnt=s.count(".")
for j in range(n+1):
    if ans>b[j]+cnt-w[j]:
        ans=b[j]+cnt-w[j]
print(ans)


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

int main()
{
  int W, H, N;
  cin >> W >> H >> N;
  
  int w_max = W;
  int w_min = 0;
  int h_max = H;
  int h_min = 0;
  
  int x, y, a;
  for (int i = 0; i < N; i++) {
    cin >> x >> y >> a;
    if(a == 1){
      if (x > w_min) w_min = x;
    } else if (a == 2) {
      if (x < w_max) w_max = x;
    } else if (a == 3) {
      if (y > h_min) h_min = y;
    } else { 
      if (y < h_max) h_max = y;
    }
  }
  if (w_min > w_max || h_min > h_max) {
    cout << 0 << endl;
  } else {
    cout << (w_max - w_min) * (h_max - h_min) << endl;
  }
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
n=int(input())
div=make_divisors(n)
# print(div)
ans=0
for i in range(len(div)):
  m=div[i]
  m=n//div[i]-1
  if m!=0:
    if n//m==n%m:
      ans+=m
print(ans)



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

using ld = long double;
const ld eps = 1e-8, pi = acos(-1.0);

bool eq(ld a, ld b) {
	return abs(a - b) < eps;
}

using Point = complex<ld>;
class Line {
public:
	Point a, b;
};
class Circle {
public:
	Point p;
	ld r;
};

ld dot(Point a, Point b) {
	return real(conj(a) * b);
}

ld cross(Point a, Point b) {
	return imag(conj(a) * b);
}

int ccw(Point a, Point b, Point c) {
	b -= a, c -= a;
	if (cross(b, c) > eps) return 1;
	if (cross(b, c) < -eps) return -1;
	if (dot(b, c) < 0) return 2;
	if (norm(b) < norm(c)) return -2;
	return 0;
}

bool isis_ll(Line l, Line m) {
	return abs(cross(l.b - l.a, m.b - m.a)) > eps;
}

bool isis_ls(Line l, Line s) {
	return (cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < eps);
}

bool isis_lp(Line l, Point p) {
	return abs(cross(l.b - p, l.a - p)) < eps;
}

bool isis_sp(Line s, Point p) {
	return abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps;
}

Point proj(Line l, Point p) {
	ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
	return l.a + t * (l.a - l.b);
}

Point is_ll(Line s, Line t) {
	Point sv = s.b - s.a, tv = t.b - t.a;
	assert(cross(sv, tv) != 0);
	return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}

bool isis_ss(Line s, Line t) {
	if (isis_ll(s, t)) return isis_ls(s, t) && isis_ls(t, s);
	return isis_sp(s, t.a) || isis_sp(s, t.b) || isis_sp(t, s.a);
}

ld dist_lp(Line l, Point p) {
	return abs(p - proj(l, p));
}

ld dist_ll(Line l, Line m) {
	return isis_ll(l, m) ? 0 : dist_lp(l, m.a);
}

ld dist_ls(Line l, Line s) {
	return isis_ls(l, s) ? 0 : min(dist_lp(l, s.a), dist_lp(l, s.b));
}

ld dist_sp(Line s, Point p) {
	Point r = proj(s, p);
	return isis_sp(s, r) ? abs(r - p) : min(abs(s.a - p), abs(s.b - p));
}

ld dist_ss(Line s, Line t) {
	if (isis_ss(s, t)) return 0;
	return min({ dist_sp(s, t.a), dist_sp(s, t.b), dist_sp(t, s.a), dist_sp(t, s.b) });
}

int main()
{
	int q;
	ld x1, x2, x3, x4, y1, y2, y3, y4;
	cout << fixed << setprecision(10);
	cin >> q;
	while (q--) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		Line l1 = { (Point) { x1, y1 }, (Point) { x2, y2 } };
		Line l2 = { (Point) { x3, y3 }, (Point) { x4, y4 } };
		cout << eq(dist_ss(l1, l2), 0.0) << endl;
	}
	return 0;
}

Measured memory_bytes: 3276
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key < value;
}

int binary_search(vector<ll> a,ll key){
  ll ok = a.size();
  ll ng = -1;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  int ans = pow(3,n);
  vector<int> b(n);rep(i,n)b[i] = a[i] % 2;
  int tmp = 1;
  
  rep(i,n){
    tmp *= (b[i]? 1 : 2);
  }

  ans -= tmp;
  print(ans);
  return 0;
}


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

class Node {
public:
	int location;
	int p, l, r;
	Node() {}
};

class Point {
public:
	int id, x, y;
	Point(){}
	Point(int id,int x,int y):id(id),x(x),y(y){}
	bool operator <(const Point &p) const {
		return id < p.id;
	}

	void print() {
		printf("%d\n", id);
	}
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];

Node T[MAX];
int np;

bool lessX(const Point &p1, const Point &p2) { return p1.x < p2.x; }
bool lessY(const Point &p1, const Point &p2) { return p1.y < p2.y; }

int makeKDtree(int l, int r, int depth) {
	if (!(l < r))return NIL;
	int mid = (l + r) / 2;
	int t = np++;
	if (depth % 2 == 0) {
		sort(P + l, P + r, lessX);
	}
	else {
		sort(P + l, P + r, lessY);
	}
	T[t].location = mid;
	T[t].l = makeKDtree(l, mid, depth + 1);
	T[t].r = makeKDtree(mid+1, r, depth + 1);
	return t;

}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans) {
	int x = P[T[v].location].x;
	int y = P[T[v].location].y;

	if (sx <= x && x <= tx && sy <= y && y <= ty) {
		ans.push_back(P[T[v].location]);
	}
	if (depth % 2 == 0) {
		if (T[v].l != NIL) {
			if (sx <= x)find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
		}
		if (T[v].r != NIL) {
			if (x <= tx)find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
		}
	}
	else {
		if (T[v].l != NIL) {
			if (sy <= y)find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
		}
		if (T[v].r != NIL) {
			if (y <= ty)find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
		}
	}
}

int main() {
	int x, y;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d %d", &x, &y);
		P[i] = Point(i, x, y);
		T[i].l = T[i].r = T[i].p = NIL;
	}
	np = 0;

	int root = makeKDtree(0, N, 0);

	int q;
	scanf("%d", &q);
	int sx, tx, sy, ty;
	vector<Point>ans;
	for (int i = 0; i < q; i++) {
		scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
		ans.clear();
		find(root, sx, tx, sy, ty, 0, ans);
		sort(ans.begin(), ans.end());
		for (int j = 0; j < ans.size(); j++) {
			ans[j].print();
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 16484
H,W=map(int,input().split())
S=[input() for i in range(H)]
ans="Yes"
for i in range(H):
    for j in range(W):
        Tonari=[]
        if i>0:
            Tonari.append(S[i-1][j])
        if i<H-1:
            Tonari.append(S[i+1][j])
        if j>0:
            Tonari.append(S[i][j-1])
        if j<W-1:
            Tonari.append(S[i][j+1])
        if S[i][j]=='#' and all([t=='.' for t in Tonari]):
            ans="No"
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main(void)
{
  char b;
  char ans;
  scanf("%c",&b);
  
  if(b=='T')
  {
    ans='A';
  }
  else if(b=='A')
  {
    ans='T';
  }
  else if(b=='C')
  {
    ans='G';
  }
  else if(b=='G')
  {
    ans='C';
  }

  printf("%c",ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long x;
    cin>>x;
   long long sum=0;
    long long ans=0;
    for(long long i=1;i<=x;i++)
    {


        sum=i*i;

        if(sum<=x){
                 ans=sum;
            }




        }
        if(ans<=x) cout<<ans;
        else cout<<ans-1;

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        int[] b = new int[n];
        int result = 0;
        for (int i = 0; i < n; i++)
            a[i] = Integer.parseInt(sc.next());
        for (int i = n-1; i > 0; i--)
            b[i] = a[i] - a[i-1];
        b[0] = k-a[n-1]+a[0];
        Arrays.sort(b);
        for (int i = 0; i < n-1; i++)
            result += b[i];
        System.out.println(result);
    }
}

Measured memory_bytes: 64112