akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
int alpha[26];
int main() {
    string s;
    cin>>s;
    rep(i,s.size()){
        int a=s[i]-'a';
        alpha[a]++;
    }
    rep(i,26){
        if(alpha[i]%2){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
<?php
 
fscanf(STDIN, '%d', $N);
$num_arr = explode(" ", trim(fgets(STDIN)));

$bubble_arr = bubble_sort($num_arr);
echo implode(" ", $bubble_arr)."\n";

is_stable($bubble_arr, $bubble_arr);

$selection_arr = selection_sort($num_arr);
echo implode(" ", $selection_arr)."\n";

is_stable($bubble_arr, $selection_arr);

function bubble_sort($num_arr) {
    for ($i = 0, $len = count($num_arr); $i < $len; $i++) {
        for ($j = $len - 1; $j > $i; $j--) {
            $tmp = $j;
            if ($num_arr[$j-1][1] > $num_arr[$tmp][1]) {
                $card = $num_arr[$tmp];
                $num_arr[$j] = $num_arr[$j-1];
                $num_arr[$j - 1] = $card;
            }
        }
    }
    return $num_arr;
}

function selection_sort($num_arr){
    $min = 0;
    $flag = 0;
    for ($i = 0; $i < count($num_arr)-1; $i++) {
        $min = $i;
        for ($j = $i+1; $j < count($num_arr); $j++) {
            if ($num_arr[$j][1] < $num_arr[$min][1]) {
                $min = $j;
                $flag = 1;
            }
        }
        if ($flag) {
            $tmp = $num_arr[$i];
            $num_arr[$i] = $num_arr[$min];
            $num_arr[$min] = $tmp;
            $flag = 0;
        }
    }
    return $num_arr;
}

function is_stable($origin, $sort_arr) {
    for ($i = 0; $i < count($origin); $i++) {
        if ($origin[$i][0] != $sort_arr[$i][0]) {
            echo "Not stable\n";
            return;
        }
    }

    echo "Stable\n";
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N; cin >> N;
  vector<ll> A(N); REP(i, N) cin >> A[i];
  ll max_n = *max_element(all(A));
  vector<int> tmp(N + 1); REP(i, N + 1) tmp[i] = 0;
  REP(i, N) {
    tmp[A.at(i)]++;
  }

  ll a = 0;
  REP(i, max_n + 1) {
    ll b = tmp.at(i);
    if(b == 0) continue;
    a += b*(b-1)/2;
  }

  REP(i, N) {
    ll b = tmp[A.at(i)];
    ll c = b*(b-1)/2 - (b-1)*(b-2)/2;
    cout << a - c << endl;
  }
}


Measured memory_bytes: 4992
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Vector;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Stack;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String x = in.next();
            Stack<Character> s = new Stack<>();
            int c = 0;
            for (int i = 0; i < x.length(); i++) {
                s.push(x.charAt(i));
                while (s.size() > 1) {
                    Character p = s.pop();
                    Character q = s.pop();
                    if ((p == '1' && q == '0') || (p == '0' && q == '1')) {
                        c++;
                        continue;
                    } else {
                        s.push(q);
                        s.push(p);
                        break;
                    }
                }
            }
            out.println(c * 2);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 25172
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        sc.close();
        String[] S = str.split("");
        int Maxcount = 0;
        int count = 0;

        for(int i=0; i<S.length;i++){
            count =0; 
            for(int j=i; j<S.length; j++){
                if("A".equals(S[j]) || "C".equals(S[j]) || "G".equals(S[j]) || "T".equals(S[j])){
                    count ++;
                }else{
                    break;
                }
            }
            Maxcount = Math.max(count, Maxcount);
        }
        System.out.println(Maxcount);
    }
}

Measured memory_bytes: 27016
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	string s;
	cin >> s;
//	if(s.size()>4)
//	return 0;
	for (int i=0;i<s.size();i++)
	{
		if(s[i]==s[i+1])
		{
			cout << "Bad";
			return 0;
		}
	}
	cout << "Good";
		
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
    
    int n,temp,s,w,a,b,c,d;
    long long int ans=0;
    vector<int> all;
    cin>>a>>b>>c>>d;
    int flag=1;
    while(1)
    {
        if(flag)
        {
            c-=b;
            flag=0;
        }
        else
        {
            a-=d;
            flag=1;
        }
        if(a<=0)
        {
            cout<<"No"<<endl;
            return 0;
        }
           else if(c<=0)
           {
               cout<<"Yes"<<endl;
               return 0;
           }
    }

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


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


int main(){
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for(auto& b : B){
    cin >> b;
  }
  int ans = 0;
  for(int ii=0; ii<N; ii++){
    int sum = C;
    for(int jj=0; jj<M; jj++){
      int a;
      cin >> a;
      sum += a*B[jj];
    }
    if(sum>0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int t,ts;
	int train[10];

	ts = 0;

	while(scanf("%d",&t) != EOF){
		if(t == 0){
			printf("%d\n",train[ts-1]);
			train[ts-1] = 0;
			ts--;
		}else{
			train[ts] = t;
			ts++;
		}
	}

	return 0;
}

Measured memory_bytes: 600
import sys
def main():
  input = sys.stdin.readline
  h, w = map(int, input().split())
  A = []
  AB = []
  A_append = A.append
  AB_append = AB.append
  for i in range(h):
    row = list(map(int, input().split()))
    A_append(row)
  for i in range(h):
    row = [abs(A[i][j] - int(b)) for j, b in enumerate(input().split())]
    AB_append(row)
 
  dp_cur = [set([]) for _ in range(w)]
  dp_cur[0].add(AB[0][0])
  for i in range(h):
    dp_next = [set([]) for _ in range(w)]
    for j in range(w):
      if j < w - 1:
        add1 = dp_cur[j+1].add
        dif1 = AB[i][j+1]
      if i < h - 1:
        add2 = dp_next[j].add
        dif2 = AB[i+1][j]
      for item in dp_cur[j]:
        if j < w - 1:
          add1(item+dif1)
          add1(abs(item-dif1))
        if i < h - 1:
          add2(item+dif2)
          add2(abs(item-dif2))
    if i == h - 1:
      break
    dp_cur = dp_next
  print(min(dp_cur[w-1]))
if __name__ == '__main__':
  main()


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll r;
    cin>>r;
    double ans=0;
    ans=2*3.14159;
    ans=ans*r;
    cout<<ans;
    //printf("%.4f",ans);

    return 0;
}


Measured memory_bytes: 3804
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

const ld pi = 3.141592653589793;

int main() {
  ll a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

bool query(const vector<int>& v, int n)
{
    cout << '?';
    for(int i=0; i<n; ++i)
        cout << ' ' << (v[i] + 1);
    cout << endl;

    string s;
    cin >> s;
    return s == "Red";
}

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

    vector<int> v(2*n);
    for(int i=0; i<2*n; ++i)
        v[i] = i;

    vector<bool> isRed(2*n, false);
    if(!query(v, n))
        reverse(v.begin(), v.end());

    int left = 0;
    int right = n;
    while(right - left > 1){
        int mid = (left + right + 1) / 2;
        vector<int> v2 = v;
        rotate(v2.begin(), v2.begin() + mid, v2.end());
        if(query(v2, n))
            left = mid;
        else
            right = mid;
    }
    rotate(v.begin(), v.begin() + left, v.end());
    isRed[v[0]] = true;

    for(int i=1; i<n; ++i){
        swap(v[i], v[n]);
        if(!query(v, n))
            isRed[v[n]] = true;
        swap(v[i], v[n]);
    }
    for(int i=n+1; i<2*n; ++i){
        swap(v[0], v[i]);
        if(query(v, n))
            isRed[v[0]] = true;
        swap(v[0], v[i]);
    }

    cout << "! ";
    for(int i=0; i<2*n; ++i){
        if(isRed[i])
            cout << 'R';
        else
            cout << 'B';
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 724
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int main(){
    fastcin();

    LL n;
    cin >> n;
    set<LL> tmp;
    for(LL i=2; i*i <= n; i++){
        if(n%i == 0){
            LL m = n;
            while(m%i == 0 && m >= i) m /= i;
            if(m == 1) tmp.insert(i);
            else if(m > i && m%i == 1) tmp.insert(i);
        }
        if(n%i == 1){
            tmp.insert(i);
            tmp.insert(n/i);
        }
    }
    if(n > 2) tmp.insert(n-1);
    tmp.insert(n);
    // repe(i, tmp) cout<< i << endl;
    cout << tmp.size() << endl;
}

Measured memory_bytes: 256
/*
  AOJ 1028
  Title:ICPC: Ideal Coin Payment and Change
  @kankichi573
  14/12/21 TLE
*/
#include <stdio.h>
#include <limits.h>
#define min(x,y) (((x)<(y))?(x):(y))

int p,n[6];
int coin[6]={500,100,50,10,5,1};
int sum[6];

int change_count(int x)
{
  int i,ret;
  ret=0;
  for(i=0;i<6;i++)
    {
      ret += x / coin[i];
      x %= coin[i];
    }
  return(ret);
}

int pay_count(int x)
{
  int i,ret,c;
  ret=0;
  for(i=0;i<6;i++)
    {
      c = x / coin[i];
      c = min(n[i],c);
      //printf("::%d [%d](%d)\n",coin[i],c,n[i]); 
      x -= c*coin[i];
      ret += c;
      if(x==0)
	return(ret);
    }
  return(-1); //cannot pay
}

solve()
{

  int i,min_,c1,c2,c;
  min_=INT_MAX;

  for(i=0;i<500;i++)
    {
      c1=pay_count(p+i);
      if(c1<0)
	continue;
      c2=change_count(i);
      c=c1+c2;
      min_=min(min_,c);
    }
  return(min_);
}



main()
{
  while(scanf("%d",&p) && (p))
  {
    scanf("%d %d %d %d %d %d",
	  &n[5],&n[4],&n[3],&n[2],&n[1],&n[0]);

      printf("%d\n",solve());
    }
  return(0);
}
/*
main()
{
  while(scanf("%d",&p) && (p))
  {
    scanf("%d %d %d %d %d %d",
	  &n[5],&n[4],&n[3],&n[2],&n[1],&n[0]);
       
    printf("=%d %d\n",p,pay_count(p));
  }
  return(0);
}
*/

Measured memory_bytes: 600
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
//typedef pair<ll,ll> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

signed main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin>>N;
    while(N--){
        int Y,M,D,ans=0;
        cin>>Y>>M>>D;
        ans-=(D-1);
        for(;Y<=999;Y++){
            for(;M<=10;M++){
                if(Y%3==0 || M%2==1) ans+=20;
                else ans+=19;
            }
            M=1;
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3164
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    s64 n, k;
    cin >> n >> k;

    vs64 h(n);
    rep (i, n)
    {
        cin >> h[i];
    }

    sort(h.begin(), h.end(), greater<s64>());

    s64 ans = 0;
    for (s64 i = k; i < n; ++i)
    {
        ans  += h[i];
    }

    cout << ans << "\n";
    return 0;
}



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

int main() {
    int n;
    cin >> n;
    vector<string> w(n);
    for (int i = 0; i < n; i++) {
        cin >> w[i];
    }

    bool ans = true;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (w[i] == w[j]) {
                ans = false;
            }
        }
    }
    for (int i = 0; i < n - 1; i++) {
        if (w[i].back() != w[i + 1].front()) {
            ans = false;
        }
    }
    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define endl '\n'
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define FORE(i, a, b) for (int i = (a), e = (b); i < e; ++i)
#define RFORE(i, a, b) for (int i = (b)-1, e = (a); i >= e; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
    }
    SORT(a);
    int ans = 0;
    FOR(i, 0, N) {
        int tmp = x - a.at(i);
        if (tmp < 0) {
            break;
        } else if (tmp == 0) {
            ++ans;
            break;
        } else if (i == N - 1) {
            break;
        } else {
            x = tmp;
            ++ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3660
N = int(input())
a = [int(input()) for i in range(N)]

#最初はボタン１が光っている
index = 1

#押した回数0からスタート
count = 0

while count < N:
  
  if a[index-1]==2:
    count += 1
    #print(str(2) + "!!")
    print(count)
    exit()
    
  else:
    #ボタン押す
    count += 1
    #次に光るボタンの番号
    index=a[index-1]
    #print(str(index) + "!!")

print(-1)


Measured memory_bytes: 13068
a, b = map(int,input().split()) # 複数の数字を変数に格納

char = ''
num = 0
result = ''

if a > b:
    char = str(b)
    num = a
else:
    char = str(a)
    num = b

for i in range(num):
    result = result + char
    
print(result)

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

int main() {
  int N,K,l[N]; cin >> N >> K;
  for(int i=0; i<N; i++) cin >> l[i];
  
  sort(l,l+N);
  reverse(l,l+N);
  
  int sum=0;
  for(int i=0; i<K; i++){
    sum+=l[i];
  }
  
  cout << sum << endl;
}


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

class Cube{
public:
  int f[6];
  Cube(){}
  void roll_z(){roll(1,2,4,3);}
  void roll_y(){roll(0,2,5,3);}
  void roll_x(){roll(0,1,5,4);}
  void roll(int i,int j,int k,int l){
      int t=f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=t;
  }
  void move(char ch){
      if(ch=='E')for(int i=0;i<3;i++)roll_y();
      if(ch=='W')roll_y();
      if(ch=='N')roll_x();
      if(ch=='S')for(int i=0;i<3;i++)roll_x();
  }
};

int main(){
    Cube c;
    string com;
    for(int i=0;i<6;i++){cin>>c.f[i];}
    cin>>com;
    for(int i=0;i<com.size();i++){
        c.move(com[i]);
    }
    cout<<c.f[0]<<endl;
    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <string>
using namespace std;
int main()
{
  string S;
  cin >> S;
  int ans = 700;
  for (int i = 0; i < S.length(); i++) {
    if (S[i]=='o') ans += 100;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn gcd(a: i32, b: i32) -> i32 {
    fn gcd1(m: i32, n: i32) -> i32 {
        if n == 0 {
            m
        } else {
            gcd1(n, m % n)
        }
    }
    if a > b {
        gcd1(a, b)
    } else {
        gcd1(b, a)
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let x: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let mut xv = vec![0i32; n];
    for i in 0..n - 1 {
        xv[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    xv[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut ans = (x - xv[0]).abs();
    for i in 1..n {
        ans = gcd(ans, (x - xv[i]).abs());
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const K = parseInt(arg[0].split(" ")[1]);
    
    const A = arg[1].split(" ").map(n=>parseInt(n));
    
    let answer = 0;
    
    if(N <= K) {
        answer = 1;
    } else {
        answer = Math.ceil((N - K) / (K - 1)) + 1;
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    int a, b;
    cin >> a >> b;

    if (a > 9 || b > 9) {
        puts("-1");
    } else {
        cout << a * b << endl;;
    }
}

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

int W,H;

void dfs(string *m, int x, int y){
	if(y-1 >= 0 && m[y-1][x] == '.'){
		m[y-1][x] = '@';
		dfs(m, x, y-1);
	}
	if(y+1 < H && m[y+1][x] == '.'){
		m[y+1][x] = '@';
		dfs(m, x, y+1);
	}
	if(x-1 >= 0 && m[y][x-1] == '.'){
		m[y][x-1] = '@';
		dfs(m, x-1, y);
	}
	if(x+1 < W && m[y][x+1] == '.'){
		m[y][x+1] = '@';
		return dfs(m, x+1, y);
	}
}
int main(){
	cin >> W >> H;
	while(W!=0 || H!=0){
		string m[H];
		int x,y;
		for(int i = 0; i < H; i++){
			string tmp;
			cin >> tmp;
			m[i] = tmp;
			for(int j = 0; j < W; j++){
				if(tmp[j] == '@'){
					x = j, y = i;
				}
			}
		}
		dfs(m,x,y);
		int ans = 0;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if(m[i][j] == '@'){
					ans++;
				}
			}
		}
		cout << ans << endl;
		cin >> W >> H;
	}
}


Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
//typedef long long LL;
using namespace std;

struct Work{
    int w_time;
    int deadline;

    Work(int w_time_i, int deadline_i){
        w_time = w_time_i;
        deadline = deadline_i;
    }
};

int main(){
    int n;
    int tmp_1;
    int tmp_2;
    int n_time = 0;
    int possible = true;
    vector<Work> work;

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp_1 >> tmp_2;
        work.push_back(Work(tmp_1, tmp_2));
    }
    sort(work.begin(), work.end(), [](Work a, Work b){
        return a.deadline < b.deadline;
    });

    for(int i=0; i<n; i++){
        n_time += work[i].w_time;
        if(n_time>work[i].deadline){
            possible = false;
            break;
        }
    }

    if(possible){
        cout << "Yes";
    }else{
        cout << "No";
    }
    cout << endl;
}

Measured memory_bytes: 2420
p = int(input())
a = list(map(int,input().split()))
L = [0]*(p+1)
L[1] = 1
for n in range(1,p):
    for m in range(n+1,0,-1):
        L[m] = (L[m-1]-n*L[m])%p

fact = [1]*p
for n in range(1,p):
    fact[n] = n*fact[n-1]%p

factinv = [pow(m,p-2,p) for m in fact]

def Ln(n):
    res = [0]*p
    res[p-1] = 1
    for m in range(p-2,-1,-1):
        res[m] = (n*res[m+1]+L[m+1])%p
    res = [(1-2*((p-1-n)%2))*factinv[n]*factinv[p-1-n]*c%p for c in res]
    return res


ans = [0]*p
for n in range(p):
    if a[n] == 0:
        continue
    l = Ln(n)
    for m in range(p):
        ans[m] += l[m]
        ans[m] %= p

print(' '.join(str(c) for c in ans))

Measured memory_bytes: 49884
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
int main()
{
fast;
ll n,m;
    cin>>n>>m;
    ll a[m];
    ll sum=0;
    f(i,m)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>n)
        cout<<"-1";
    else
        cout<<n-sum;
return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <map>

typedef unsigned long long ull;
using namespace std;

map <int, int> mp;
map <int, int> ::iterator it;

int main() {
	int n, value;
	cin >> n;
	
	for(int i=0; i < n; i++) {
		cin >> value;
		
		mp[value]++;
		mp[value-1]++;
		mp[value+1]++;
	}
	
	int res = 0;
	for(it = mp.begin(); it != mp.end(); it++) {
		if(it->second > res) {
			res = it->second;
		}
	}
	
	cout << res;
	
	return 0;
}

Measured memory_bytes: 4736
A, V = [int(x) for x in input().split(' ')]
B, W = [int(x) for x in input().split(' ')]
T = int(input())

if (A + T * V) >= (B + T * W) and  (A - T * V) <= (B - T * W):
  print('YES')
else:
  print('NO')

Measured memory_bytes: 9180
#include <cstdio>

using namespace std;

int main(void) {
  int a, b, t, sum = 0;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &t);
  
  sum = 0;
  for(int tt = a; tt < t + 0.5; tt += a) {
    sum += b;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 256
// vim: shiftwidth=2 expandtab foldmethod=marker

// include {{{
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <utility>
#include <cstdlib>
#include <random>
#include <chrono>
// }}}

// debug(...) {{{
#ifdef LOCAL_DEBUG
#include "./debug.h"
#else
#define debug(...)
#define debugn(...)
#define debug_reset()
#endif

#include <cstdio>

template<class T>
std::string bin(int bits, const T& x) {
  char buf[bits + 1];
  buf[bits] = '\0';
  for(int i = 0; i < bits; i++) {
    if((x >> i) & 1) {
      buf[bits - i - 1] = '1';
    } else {
      buf[bits - i - 1] = '0';
    }
  }
  return std::string(buf);
}
std::string bin(int x) {
  if(x < 0) return bin(32, x);
  for(int i = 4; i < 31; i++) {
    int y = 1 << i;
    if(x < y) return bin(i, x);
  }
  return bin(32, x);
}
// }}}

// misc {{{
using namespace std;
template<class T, class U>

using umap = unordered_map<T, U>;
template<class T>
using uset = unordered_set<T>;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

template<class T>
void sort(T& arr) {
  std::sort(arr.begin(), arr.end());
}
template<class T, class By>
void sort_by(T& arr, By by) {
  std::sort(arr.begin(), arr.end(), [by](auto l, auto r){return  by(l) < by(r); });
}

template<class T>
void reverse(T& arr) {
  std::reverse(arr.begin(), arr.end());
}

class Random {
  public:
  std::uniform_int_distribution<> uniform_int;
  std::mt19937 rnd;
  std::bernoulli_distribution bern_dist;
  int uniform(int l, int r) {
    return uniform_int(rnd, std::uniform_int_distribution<>::param_type(l, r));
  }
  int next(int N) {
    return uniform(0, N - 1);
  }
  int bern(double p) {
    return bern_dist(rnd, std::bernoulli_distribution::param_type(p));
  }
};
// }}}

// main {{{
void solve();
int main() {
  solve();
}
// }}}

void solve() {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N - 1);
  rep(i, N) { cin >> A[i]; }
  rep(i, N) { cin >> B[i]; }
  rep(i, N - 1) cin >> C[i];

  int ans = 0;
  int prev = -100;
  rep(i, N) {
    int cur = A[i] - 1;
    ans += B[cur];
    if(prev + 1 == cur) ans += C[prev];
    prev = cur;
  }
  cout << ans << endl;
}


Measured memory_bytes: 888
import java.util.*

fun log(base: Double, a: Double) = Math.log(a) / Math.log(base)

fun main(args : Array<String>) {
  val (n, k) = readLine()!!.split(' ').map(String::toInt)
  val kd = k.toDouble()
  var ans = 0.0
  for (i in 1..n) {
    if (k <= i) {
      ans += 1.0 / n
      continue
    }
    val x = Math.ceil(log(2.0, kd / i))
    ans += Math.pow(0.5, x) / n
  }
  println(ans)
}


Measured memory_bytes: 36332
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int N, K, d, A, ans = 0;
	scanf("%d %d", &N, &K);
	bool bully[N];
	fill_n(bully, N, true);
	for (int i = 0; i < K; ++i) {
		scanf("%d", &d);
		for (int j = 0; j < d; ++j) {
			scanf("%d", &A);
			bully[A - 1] = false;
		}
	}
	for (int i = 0; i < N; ++i) ans += bully[i];
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int n,k;cin>>n>>k;
  string s;cin>>s;
  if(s.at(k-1)=='A') s.at(k-1)='a';
  if(s.at(k-1)=='B') s.at(k-1)='b';
  if(s.at(k-1)=='C') s.at(k-1)='c';
  cout<<s<<endl;
}

Measured memory_bytes: 256
using System;

namespace Dice
{
    class Program
    {
        private static bool Eql(string[] x, string[] y)
        {
            var g = true;
            for (int o = 0; o < x.Length; o++)
              if (x[o] != y[o]) g = false;
            return g;
        }

        private static bool Check(string[] x, string[] y)
        {
            if (Eql(x, y)) return true;
            for (int p = 0; p < 2; p++)
            {
                for(int q = 0; q < 4; q++)
                {
                    var a = x[0]; var b = x[1]; var c = x[2];
                    var d = x[3]; var e = x[4]; var f = x[5];
                    x = p == 0 ? new string[] { e, a, c, d, f, b }:
                                 new string[] { d, b, a, f, e, c };
                    if (Eql(x, y)) return true;
                    var h = x;
                    for(int r = 0; r < 4; r++)
                    {
                        var i = h[0]; var j = h[1]; var k = h[2];
                        var l = h[3]; var m = h[4]; var n = h[5];
                        h = new string[] { i, k, m, j, l, n };
                        if (Eql(h, y)) return true;
                    }
                }
            }
            return false;
        }

        static void Main()
        {
            int s = int.Parse(Console.ReadLine());
            var t = new string[s][];
            for(int u = 0; u < s; u++)
                t[u] = Console.ReadLine().Split(' ');
            for (int v = 0; v < s; v++)
                for (int w = v + 1; w < s; w++)
                    if (Check(t[v], t[w]))
                    {
                        Console.WriteLine("No");
                        return;
                    }
            Console.WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 9252
#include<stdio.h>
#include<stdlib.h>
#define MAX 1000000000000000000
int main(void){
  
  int i,n;
  long long p[100001];
  long long ans = 1;
  long long def = 1000000000000000000;
  int zero_flag = 0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
	scanf("%lld",&p[i]);
    if(p[i] == 0) {
      printf("0");
      return 0;
      zero_flag = 1;
    }
  }
  
  long long prod = 1;
  for(i=0;i<n;i++){
    if(p[i]<=1000000000000000000/prod){
   prod = prod * p[i]; 
    }else{ 
      printf("-1");
      return 0;
    }
  }
  
  printf("%lld",prod);
  
  return 0;
}

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

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

int MOD=1e9+7;
ll INF=1e18;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int main(){
    while(1){
        int n; cin>>n;
        if(n==0) return 0;
        int a[110][110], hands[110][110];
        memset(hands, 0, sizeof(hands));
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                cin>>a[i][j];
            }
        }

        for(int i=0; i<n; i++){
            int MIN=1e9, id;
            for(int j=0; j<n; j++) MIN=min(MIN, a[i][j]);
            for(int j=0; j<n; j++){
                if(a[i][j]==MIN) hands[i][j]++;
            }
        }
        for(int i=0; i<n; i++){
            int MAX=0;
            for(int j=0; j<n; j++) MAX=max(MAX, a[j][i]);
            for(int j=0; j<n; j++){
                if(a[j][i]==MAX) hands[j][i]++;
            }
        }

        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                if(hands[i][j]==2){
                    cout << a[i][j] << endl;
                    goto END;
                }
            }
        }

        cout << 0 << endl;
        END:;
    }
}


Measured memory_bytes: 3056
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
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 main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int i,j,h,w;
	cin>>h>>w;
	char m[h+2][w+2];
	for(i=0;i<h+2;i++)for(j=0;j<w+2;j++)m[i][j]='.';
	for(i=1;i<h+1;i++)for(j=1;j<w+1;j++)cin>>m[i][j];
	for(i=1;i<h+1;i++)for(j=1;j<w+1;j++){
		if(m[i][j]=='#'){
			if(m[i-1][j-1]!='#'){
				if(m[i-1][j-1]=='.')m[i-1][j-1]='1';
				else m[i-1][j-1]++;
			}
			if(m[i-1][j+1]!='#'){
				if(m[i-1][j+1]=='.')m[i-1][j+1]='1';
				else m[i-1][j+1]++;
			}
			if(m[i-1][j]!='#'){
				if(m[i-1][j]=='.')m[i-1][j]='1';
				else m[i-1][j]++;
			}
			if(m[i][j+1]!='#'){
				if(m[i][j+1]=='.')m[i][j+1]='1';
				else m[i][j+1]++;
			}
			if(m[i][j-1]!='#'){
				if(m[i][j-1]=='.')m[i][j-1]='1';
				else m[i][j-1]++;
			}
			if(m[i+1][j-1]!='#'){
				if(m[i+1][j-1]=='.')m[i+1][j-1]='1';
				else m[i+1][j-1]++;
			}
			if(m[i+1][j]!='#'){
				if(m[i+1][j]=='.')m[i+1][j]='1';
				else m[i+1][j]++;
			}
			if(m[i+1][j+1]!='#'){
				if(m[i+1][j+1]=='.')m[i+1][j+1]='1';
				else m[i+1][j+1]++;
			}
		}
	}
	for(i=1;i<h+1;i++){
		for(j=1;j<w+1;j++){
			if(m[i][j]=='.')cout<<0;
			else cout<<m[i][j];
		}
		cout<<endl;
	}
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}

int main(){
    ll A,B,C,K;
    string S;
    cin >> A >> B >> C >> K;
    ll sum = 0;
    if(A >= K){
        cout << K << endl;
        return 0;
    }
    K -= A;
    if(B >= K){
        cout << A << endl;
        return 0;
    }
    K -= B;
    cout << A-K << endl;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC138A
{
    class Program
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            Console.WriteLine(n >= 3200 ? s : "red");
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
const int N=20;
int n;long long a[N];
long long dfs(int l,int r,int x,int y){
    if(r-l<=1) return 0;
    long long mn=1e18;
    for(int i=l+1;i<=r-1;i++)
        mn=min(mn,dfs(l,i,x,x+y)+dfs(i,r,x+y,y)+a[i]*(x+y));
    return mn;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    printf("%lld",dfs(1,n,1,1)+a[1]+a[n]);
    return 0;
}

Measured memory_bytes: 256
/*
*
*	AUTHOR :- @soham01
*		// "WORK HARD AND NEVER GIVE UP" //
*
*/
#include "bits/stdc++.h"

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> //find_by_order(), order_of_key()
#define pb push_back
#define mp make_pair
#define vi vector<long long int >
#define vb vector<bool>
#define vs vector<string>
#define vd vector<double>
#define vvi vector<vector<long long int> >
#define vp vector<pair<long long int , long long int > >
#define seti set<long long int >
#define setc set<char>
#define setd set<double>
#define mod 1000000009
#define endl '\n'
typedef long long int lli;

// ITS MY REQUEST TO PLEASE PLEASE DO LOOK AT THE CONSTRAINS GIVEN CAREFULLY
// DO CHECK FOR CORNER CASES

/*-------LET THE GAME BEGIN-----------*/

void solve()
{
	lli a, b, c;
	cin >> a >> b >> c;
	if (a <= b)
	{
		cout << c << endl;
	}
	else if (a > b)
	{
		if(a%b!=0){
		cout << (a / b + 1)*c << endl;
		}
		else{
			cout << (a/b) * c << endl;
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	solve();
	return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
int main(void)
{
	int i, n;
	char s[101];
	scanf("%s", s);
	n = strlen(s);
	rep(i,n) printf("%c", 'x');
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  vector<string> weather = {"Sunny", "Cloudy", "Rainy"};
  
  for (int i = 0; i < 3; i++){
    if (S == weather.at(i) && S != "Rainy"){
      cout << weather.at(i + 1) << endl;
    }
  }
  if (S == "Rainy"){
    cout << "Sunny" << endl;
  }
}

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

int naive(int N, int K){
    deque<int> q; q.push_front(0);
    int T = N/K;
    for(int i=1;i<=T;i++){
        int rot = K % q.size();
        for(int j=0;j<rot;j++){
            int cur = q.front(); q.pop_front();
            q.push_back(cur);
        }
        q.push_front(i);
    }
    return q[(N%K)%q.size()];
}

int go(int N, int K){
    while(1){
        if(N%K==0) return N/K;
        if(N<K) return 0;
        if(N/K <= 100) return naive(N, K);
        N -= N/K+1;
    }
}

int main(){
    int N; scanf("%d",&N);
    int g = 0;
    for(int i=0;i<N;i++){
        int a, k; scanf("%d%d",&a,&k);
        g ^= go(a, k);
    }
    printf(g ? "Takahashi\n" : "Aoki\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>

using namespace std;

int main() {
	array <array <array <int, 10>, 3>, 4> buildings{0};
	int size = 0;
	int b = 0;
	int f = 0;
	int r = 0;
	int v = 0;

	for (auto building : buildings) {
		for (auto floor : building) {
			for (int i = 0; i < 10; i++) {
				floor[i] = 0;
			}
		}
	}
	cin >> size;
	for (int i = 0; i < size; i++) {
		cin >> b >> f >> r >> v;
		buildings[b-1][f-1][r-1] += v;
		if (buildings[b-1][f-1][r-1] < 0) {
			buildings[b-1][f-1][r-1] = 0;
		}
	}
	for (int i = 0; i < 4; i++) {
		for (auto floor : buildings[i]) {
			for (int a = 0; a < 10; a++) {
				cout << ' ';
				cout << floor[a];
				if (a == 9) {
					cout << endl;
					continue;
				}
			}
		}
		if (i != 3) {
			cout << "####################" << endl;
		}
	}
}



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

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll k,a,b;
    cin >> k >> a >> b;
    ll biscuit = 0;
    if (a >= b){
    	cout << k+1 << endl;
    }
    else {
    	ll earn = (b-a)/2;
    	if (earn > 1 && k-a > 0){
    		k = k-a+1;
    		ll answer = (k/2)*(b-a)+a;
    		if (k%2 == 0) cout << answer << endl;
    		else cout << answer+1 << endl;
    	} else {
    		cout << k+1 << endl;
    	}
    }
    cin >> k;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define ASSERT(expr...) assert((expr))

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

using f32 = float;
using f64 = double;

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define ll long long

ll mod_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        return mod_pow(x * x % MOD, n / 2) % MOD;
    } else {
        return x * mod_pow(x, (n - 1)) % MOD;
    }
}

ll mod_pow_r(ll x, ll n) {
    if (x == 0) return 0;
    if (n == 0) return 1;

    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n /= 2;
    }
    return ret;
}

ll factorial(ll n) {
    ll ret = 1;
    REP(i, n) {
        ret *= (i + 1);
        ret %= MOD;
    }
    return ret;
}

ll combination(ll n, ll r) {
    if (n < 0 || n < r || r < 0) return 0;
    ll fn = factorial(n);
    ll fr = factorial(r);
    ll fn_r = factorial(n-r);

    ll d = (mod_pow(fr, MOD - 2) * mod_pow(fn_r, MOD - 2)) % MOD;
    ll u = fn % MOD;
    return u * d % MOD;
}

void solve() {
    ll X, Y;
    cin >> X >> Y;
    if ((X + Y) % 3 != 0) {
        cout << 0; 
        return;
    }
    int rep_n = X - (X + Y) / 3;
    int rep_m = Y - (X + Y) / 3;
    cout << combination(rep_n + rep_m, rep_n);
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
def main():
    N = input()

    N_set = list(set(N))
    N_list = list(N)

    m = "No"
    if len(N_set) == 1:
        m = "Yes"
    elif len(N_set) != 2 and len(N_set) != 1:
        m = "No"
    else:
        if N_list[0] == N_list[1]:
            if N_list[1] == N_list[2]:
                m = "Yes"
                
        else:
            if N_list[1] == N_list[2]:
                if N_list[2] == N_list[3]:
                    m = "Yes"
        
    print(m)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
class UnionFind():
    def __init__(self, n):  #初期化　最初はみんなばらばら
        self.n = n
        self.parents = [-1] * n
    def find(self, x):  #xの根を見つける　たどった経路全ての根を更新
        if self.parents[x] < 0:
            return x   #根の番号を返す
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)  #x,yの木の根
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x  #xをでかい木にする

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):  #xの含まれる木の要素数を返す
        return -self.parents[self.find(x)]

    def same(self, x, y):  #x,yが同じ気に属するか判定
        return self.find(x) == self.find(y)

    def members(self, x):  #xの含まれる木の要素を配列で返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):  #根をすべて返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self): #木の個数
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,q = map(int,input().split())
uf = UnionFind(n)
ans = []
for _ in range(q):
    com,x,y = map(int,input().split())
    if com == 0:
        uf.union(x,y)
    else:
        judge = uf.same(x,y)
        if judge:
            ans.append(1)
        else:
            ans.append(0)
for i in ans:
    print(i)


Measured memory_bytes: 6828
package main

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

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

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

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

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

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

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

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

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

	a, b, x := float64(scanInt()), float64(scanInt()), float64(scanInt())

	if a*a*b/2 >= x {
		fmt.Println(math.Atan(b*b*a/2/x)/math.Pi*180)
	} else {
		fmt.Println(math.Atan(2*(a*a*b-x)/a/a/a)/math.Pi*180)
	}
}


Measured memory_bytes: 640
c=0
r=1
n=gets.to_i
(2*n).times.map{|i|[gets.to_i,i<n]}.sort.each{|k,v|
	if !v
		r*=c if c>0
		c-=1
	else
		r*=-c if c<0
		c+=1
	end
	r%=10**9+7
}
p r

Measured memory_bytes: 19320
L, R = map(int, input().split())

count_limit = 0 # count limit is 2019
min_num = 2020
for i in range(L, R+1):

    count_limit_j = 0
    for j in range(i+1, R+1):
        min_num = min(min_num, (i*j)%2019)
        count_limit_j = count_limit_j + 1
        if count_limit_j>2020:
            break

    # limit process
    count_limit = count_limit + 1
    if count_limit>2020:
        break

print(min_num)


Measured memory_bytes: 40428
#include<iostream>
using namespace std;
int c[200005];
int r[200005];
int main()
{
	long long N;
	cin >> N;
	long long ans = 0;
	int Q;
	cin >> Q;
	int maxh,maxl;
	maxl = N;
	maxh = N;
	for(int i = 2; i <= N-1; i++)
	{
		c[i] = r[i] = N-2;
	}
	for(int i = 1; i <= Q; i++)
	{
		int flag,x;
		cin >> flag >> x;
		if(flag == 1)
		{
			if(x < maxl)
			{
				for(int i = x + 1; i < maxl; i++)
				r[i] = maxh - 2;
				r[x] = 0;
				maxl = x;
				ans = ans + maxh - 2; 
			}
			else if(x == maxl)
			continue;
			else{
				ans = ans + r[x];
				r[x] = 0;
			}
		}
		else{
			if(x < maxh)
			{
				for(int i = x + 1; i < maxh; i++)
				c[i] = maxl - 2;
				c[x] = 0;
				maxh = x;
				ans = ans + maxl- 2;
			}
			else if(x == maxh)
			continue;
			else{
				ans = ans + c[x];
				c[x] = 0;
			}
		}
	}
	cout <<(N-2)*(N-2) - ans << endl;
} 

Measured memory_bytes: 4696