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

class Main {
    int N;
    long M;
    long[] A;

    public Main(){
        Scanner SC = new Scanner(System.in);
        N = SC.nextInt();
        M = SC.nextLong();
        A = new long[N];

        for(int i=0;i<N;i++){
            A[i] = SC.nextLong() / 2;
        }

        int count = -1;
        for(int i=0;i<N;i++){
            int c = 0;
            long t = A[i];
            while((t&1) == 0){
                t = t>>1;
                c++;
            }
            if(count != -1){
                if(count != c){
                    System.out.println("0");
                    return;
                }
            } else {
                count = c;
            }
        }

        long valueLCM;
        if(N > 1){
            valueLCM = valueLCM = LCM(A[0], A[1]);
            for(int i=1;i<N-1;i++){
                valueLCM = LCM(valueLCM, A[i+1]);
                if(valueLCM < 0){
                    System.out.println("0");
                    return;
                }
            }
        } else {
            valueLCM = A[0];
        }

        long L=-1, R=(M+1)/2;
        while(R-L > 1){
            long mid = L+(R-L)/2;

            if(valueLCM > M/(2*mid+1))
                R = mid;
            else
                L = mid;
        }

        System.out.println(R);
    }

    long LCM(long a, long b){
        return a / GCD(a, b) * b;
    }

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

    public static void main(String[] args){
        Main m = new Main();
    }
}


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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int n, k;
	cin >> n >> k;
	vector<ll> h(n);
	rep(i, n) cin >> h[i];
	
	sort(h.begin(), h.end());
	
	ll mn = INF;
	for(int i = 0; i < n - (k - 1); ++i){
		mn = min(mn, h[i + k - 1] - h[i]);
	}
	cout << mn << endl;
	return 0;
}



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

using namespace std;

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

typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> PL;

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

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

ll N, K;
ll dp1[100001];
ll dp2[100001];
ll a[100];
ll Tarodp(ll), Jirodp(ll);

ll Tarodp(ll sum) {
    if(dp1[sum]) return dp1[sum];
    ll &res = dp1[sum];
    REP(i, N) {
        if(sum < a[i]) break;
        res = max(res, Jirodp(sum - a[i]));
    }
    if(res == 0) res = -1;
    return res;
}

ll Jirodp(ll sum) {
    if(dp2[sum]) return dp2[sum];
    ll &res = dp2[sum];
    REP(i, N) {
        if(sum < a[i]) break;
        res = min(res, Tarodp(sum - a[i]));
    }
    if(res == 0) res = 1;
    return res;
}

signed main() {
    cin >> N >> K;
    REP(i, N) cin >> a[i];
    cout << (Tarodp(K) == 1 ? "First" : "Second") << "\n";
}


Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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; }

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;
	vector<int> k(m), p(m);
	vector<int> s(m);
	int tmp;
	rep(i, m)
	{
		cin >> k[i];
		rep(j, k[i])
		{
			cin >> tmp;
			s[i]+=(1 << (tmp - 1));
		}
	}
	rep(i, m)
	{
		cin >> p[i];
	}

	int lightOn = 0;
	int num = 0;
	int lightNum = 0;
	int ans = 0;
	for (int i = 1; i <= pow(2, n); i++)
	{
		for (int j = 0; j < m; j++)
		{
			lightOn = s[j] & i;
			for (int k = 0; k < 10; k++)
			{
				num += lightOn % 2;
				lightOn /= 2;
			}
			if (num % 2 == p[j])
			{
				lightNum++;
			}
			num = 0;
			
		}
		if (lightNum == m)
		{
			ans++;
		}
		lightNum = 0;
		lightOn = 0;
	}
	cout << ans << endl;
	debug;
	return 0;
}

Measured memory_bytes: 504
def main():
  import numpy as np
  k, q = map(int, input().split())
  d = np.array(list(map(int, input().split())))
  for i in range(q):
    n, x, m = map(int, input().split())
    x %= m
    d_mod = d % m
    zero_d = k - np.count_nonzero(d_mod)
    d_mod_sum = np.sum(d_mod) + m * zero_d
    rep = (n-1) // k
    rem = (n-1) % k
    zero_rem = len(d_mod[:rem]) - np.count_nonzero(d_mod[:rem])
    rem_sum = np.sum(d_mod[:rem]) + m * zero_rem
    ans = n - 1 - (x + d_mod_sum * rep + rem_sum) // m
    print(ans)
if __name__ == '__main__':
  main()

Measured memory_bytes: 12592
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int d,a;
int sum=1;
int main()
{
    scanf("%d%d",&d,&a);
    for(int i=1;i<=d;i++)sum*=100;
    if(a!=100)printf("%d",a*sum);
    else printf("%d",a*sum+sum);
}

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

double a, b, x;


double rad(double r){
    return r * M_PI / 180;
}

bool isOK(double r){
    double men;

    if(a * sin(rad(r)) <= b * sin(rad(90-r))){
        men = b * sin(rad(90-r)) * (b * cos(rad(90-r)) + a * cos(rad(r)));
        men -= b * sin(rad(90-r)) * b * cos(rad(90-r)) / 2;
        men -= a * sin(rad(r)) * a * cos(rad(r)) / 2;
        double tmp = b * sin(rad(90-r)) - a * sin(rad(r));
        men -=  tmp * tmp * tan(rad(r)) / 2;
    }else{
        men = b * b * tan(rad(90-r)) / 2;
    }

    men *= a;
    return men-x >= DBL_EPSILON;
}

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

    double l, r;
    l = 0;
    r = 90;


    while(r-l > 0.00000001){
        double mid = (r+l)/2;
        if(isOK(mid)){
            l = mid;
        }else{
            r = mid;
        }
    }

    printf("%.12lf\n", l);

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
  // 入力
  int n, m;
  cin >> n >> m;
  
  int ll = 1, rr = 100000;
  for (int i = 1; i <= n; i++) {
    int l, r;
    cin >> l >> r;
    if (ll < l)
      ll = l;
    if (rr > r)
      rr = r;
  }

  // 出力
  int ans = rr - ll + 1;
  if (ans < 0)
    ans = 0;
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;
  string s;
  cin >> n >> s;
  if(n % 2 == 1){
    cout << "No" << endl;
    return 0;
  }
  string sreverse1;
  string sreverse2;
  for(int i = s.length()/2; i < s.length(); i++){
    sreverse1 += s[i];
  }
  for(int i = 0; i < s.length()/2; i++){
    sreverse2 += s[i];
  }
  if(sreverse1 == sreverse2){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No"  << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";}
using namespace std;
using ll = long long;

int dp[1005][1005];
vector<int> ans;

int main(void) {
    int q;
    cin >> q;
    rep (_, q) {
        string s, t;
        cin >> s >> t;

        rep (i, 1002) rep (j, 1002) dp[i][j] = 0;


        for (int si = 1; si <= s.size(); si++) {
            for (int ti = 1; ti <= t.size(); ti++) {
                if (s[si - 1] == t[ti - 1]) {
                    dp[si][ti] = dp[si - 1][ti - 1] + 1;
                }
                else {
                    dp[si][ti] = max(dp[si - 1][ti], dp[si][ti - 1]);
                }
            }
        }
        ans.push_back(dp[s.size()][t.size()]);
    }
    
    rep (i, q) cout << ans[i] << endl;
    return 0;
}


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

#define FOR(s, i, n) for(int i = s; i n; i++)
typedef long long ll;
const int INF = 1e9;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int x;
	cin>>x;
	int deg = 0;
	int ans = 0;
	do {
		deg += x;
		ans++;
	}while (deg % 360 != 0);
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 3644
str_s = input()

while len(str_s) > 0:
    str_s = str_s[:-1]
    if len(str_s) % 2 == 0:
        spliter = int(len(str_s) / 2)

        if str_s[:spliter] == str_s[spliter:]:
            print(len(str_s))
            exit(0)





Measured memory_bytes: 2940
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

char s[100001];
bool a[100001];
int main() {
	int n;
	cin >> n >> s;
	for (int i = 0; i < 4; ++i) {
		a[0] = i & 1, a[1] = (i & 2) >> 1;
		for (int j = 2; j < n; ++j) {
			a[j] = a[j - 2];
			if (a[j - 1] ^ (s[j - 1] == 'x')) a[j] ^= 1;
		}
		if ((a[1] == a[n - 1]) != ((s[0] == 'o') ^ a[0])) continue;
		if ((a[0] == a[n - 2]) != ((s[n - 1] == 'o') ^ a[n - 1])) continue;
		for (int i = 0; i < n; ++i) {
			if (a[i]) cout<<"W";
			else cout<<"S";
		}
		return 0;
	}
	cout << "-1" << endl;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
"""
B - Tap Dance
https://atcoder.jp/contests/abc141/tasks/abc141_b

"""
import sys


def solve(S):
    odds = S[::2]
    evens = S[1::2]
    if all(o in 'RUD' for o in odds) and all(e in 'LUD' for e in evens):
        return 'Yes'
    return 'No'


def main(args):
    S = input()
    ans = solve(S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,l;
    cin>>n>>l;
    string s[1010];
    rep(i,n){
        cin>>s[i];
    }
    sort(s,s+n);
    rep(i,n){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N(x ? "Yes" : "No"))

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  vector<int>a(n);
  for (auto i = 0; i < n; ++i) {
    cin >> a[i];
  }
 
  // main procedure
  sort(ALL(a));
  
  int a_i = *(a.end() - 1);
  int a_j;

  auto itr = lower_bound(ALL(a), a_i/2);
  int b = *itr;
  if (itr != a.begin()) {
    itr--;
  }
  int c = *itr;

  if (b*2 - a_i < a_i - c*2) {
    a_j = b;
  } else {
    a_j = c;
  }

  // output
  cout << a_i << " " << a_j << endl;

  return 0;
}


Measured memory_bytes: 640
N = gets.to_i
puts 111 if N >= 100 && N <= 111
puts 222 if N >= 112 && N <= 222
puts 333 if N >= 223 && N <= 333
puts 444 if N >= 334 && N <= 444
puts 555 if N >= 445 && N <= 555
puts 666 if N >= 556 && N <= 666
puts 777 if N >= 667 && N <= 777
puts 888 if N >= 778 && N <= 888
puts 999 if N >= 889 && N <= 999

Measured memory_bytes: 1788
N,M=map(int,input().split())
import math


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
from collections import Counter
L=prime_factorize(M)
c=Counter(L)
k=[]
for v in c.values():
  k.append(v)
mod=10**9+7
P=[1 for i in range(10**6+1)]
for i in range(10**6):
  P[i+1]=P[i]*(i+1)%mod


def comb(a,b):
  return P[a]*pow(P[a-b],mod-2,mod)*pow(P[b],mod-2,mod)%mod
ans=1
for i in range(len(k)):
  ans*=comb(N+k[i]-1,k[i])
  ans%=mod
print(ans)

Measured memory_bytes: 143404
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}
vector<uint32_t> Num(100000);

int main() {
  uint64_t N;
  cin >> N;

  for (uint64_t i = 1; i <= 50000; ++i) {
    if ((uint64_t)(i * 1.08) == N) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;

  return 0;
}


Measured memory_bytes: 640
#C - : (Colon)
import math
A,B,H,M = map(int, input().split())
h = (H*60+M)*360/(12*60)
m = M*360/60

# h = H*30
# h = h + 0.5*M
# m = M*6
w = 0

w = h - m
if w > 180:
    w = w
# elif w < 0:
#     w = w+180
elif w == 180:
    print(abs(A+B))
    exit()
elif w == 0:
    print(abs(A-B))
    exit()
else:
    pass
#print(h,m,w)

c = A**2+B**2-2*A*B*math.cos(math.radians(w))
print(c**(1/2))

Measured memory_bytes: 9528
using System;

class Modulo
{
    private const int MOD = 1000000007;
    private readonly int[] m_facs;
    public int Mul(int a, int b) => (int)(Math.BigMul(a, b) % MOD);
    public Modulo(int n)
    {
        m_facs = new int[n + 1];
        m_facs[0] = 1;
        for (int i = 1; i <= n; ++i)
            m_facs[i] = Mul(m_facs[i - 1], i);
    }
    public int Fac(int n) => m_facs[n];
    public int Pow(int a, int m)
    {
        switch (m)
        {
            case 0:
                return 1;
            case 1:
                return a;
            default:
                int p1 = Pow(a, m / 2);
                int p2 = Mul(p1, p1);
                return ((m % 2) == 0) ? p2 : Mul(p2, a);
        }
    }
    public int Div(int a, int b) => Mul(a, Pow(b, MOD - 2));
    public int Ncr(int n, int r)
    {
        if (n < r) return 0;
        if (n == r) return 1;
        int res = Fac(n);
        res = Div(res, Fac(r));
        res = Div(res, Fac(n - r));
        return res;
    }
}


public class Hello
{
    public static void Main()
    {
        var MOD = 1000000007;
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = int.Parse(line[1]);
        var s = Console.ReadLine().Trim();
        line = s.Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var count = 0;
        for (int i = 0; i < n - 1; i++)
            for (int j = i + 1; j < n; j++)
                if (a[i] > a[j]) count++;
        line = (s + " " + s).Split(' ');
        var b = Array.ConvertAll(line, int.Parse);
        var count2 = 0;
        for (int i = 0; i < n; i++)
            for (int j = n; j < 2 * n; j++)
                if (b[i] > b[j]) count2++;
        var ans = count *(long) k;
        ans %= MOD;
        var md = new Modulo(2);
        var ans2 = (long)k * (k - 1);
        ans2 %= MOD;
        ans2 = md.Div((int)ans2, 2);
        ans2 *= count2;
        ans2 %= MOD;
        ans += ans2;
        ans %= MOD;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
H, W, K = map(int, input().split()) 
sl = []
for _ in range(H):
    sl.append(list(input()))


ans = 10**8
for i in range(2 ** (H-1)):
    fail_flag = False
    comb = []
    for j in range(H-1):
        if ((i >> j) & 1): 
            comb.append(j)
    comb.append(H-1)
    # print(comb)
    sections = []
    for k in range(0,len(comb)):
        if k == 0:
            sections.append( sl[0:comb[0]+1] )
        else:
            sections.append( sl[comb[k-1]+1:comb[k]+1] )
    # print(sections)

    partition_cnt = 0
    sections_w_cnts = [0]*len(sections)
    for w in range(W):
        sections_curr_w_cnts = [0]*len(sections)
        partition_flag = False
        for i, sec in enumerate(sections):
            for row in sec:
                if row[w] == '1':
                    sections_curr_w_cnts[i] += 1
                    sections_w_cnts[i] += 1
                    if sections_curr_w_cnts[i] > K:
                        fail_flag = True
                        break
                    if sections_w_cnts[i] > K:
                        partition_flag = True

            if fail_flag: break
        if fail_flag: break

        if partition_flag:
            sections_w_cnts = [v for v in sections_curr_w_cnts]
            # sections_w_cnts[:] = sections_curr_w_cnts[:]
            partition_cnt += 1
        

    if not fail_flag:
        ans = min(len(comb)-1+partition_cnt, ans)

print(ans)

Measured memory_bytes: 47836
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;

void merge (int *first1, int *last1, int *first2, int *last2){
    int size1 = last1 - first1;
    int size2 = last2 - first2;
    int *result = new int[size1+size2];
    int i = 0;
    int j = 0;
    int index = 0;
    while (true){
        if (i < size1 && (first1[i] <= first2[j] || j >= size2)){
            result[index] = first1[i];
            ++i; ++index;
        }
        if (j < size2 && (first1[i] > first2[j] || i >= size1)){
            result[index] = first2[j];
            ++j; ++index;
        }
        if (i==size1 && j==size2){
            for (i=0; i<size1; ++i) first1[i] = result[i];
            for (j=0; j<size2; ++j) first2[j] = result[j+size1];
            delete[] result;
            return;
        }
    }
}
void MergeSort (int *first, int *last){
    int size = last - first;
    if(size <= 1) return;
    MergeSort(first, first+size/2);
    MergeSort(first+size/2, last);
    merge(first, first+size/2, first+size/2, last);
}


int gcd(int a, int b)
{
    int c;

    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

int dx[3]={-1, 0, 1};
int dy[3]={-1, 0, 1};
int W, H;
char masu[20][20];
int cnt;

int dfs(int a, int b){
  masu[a][b] = '#';
  cnt++;
  REP(i, 3)REP(j, 3) if(masu[a+dx[i]][b+dy[j]]=='.' && abs(dx[i]+dy[j])==1 && a+dx[i] >= 0 && a+dx[i] < W && b+dx[j] >= 0 && b+dx[j] < H) dfs(a+dx[i], b+dy[j]);
  return cnt;
}


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

  while(1){
    cin >> W >> H;
    if(W == 0 && H == 0) break;
    REP(j, H)REP(i, W) cin >> masu[i][j];

    int i0, j0;
    REP(j, H)REP(i, W) if(masu[i][j] == '@'){
      i0=i;
      j0=j;
      break;
    }

    cnt = 0;
    cnt = dfs(i0, j0);
    cout << cnt << endl;
  }
    return 0;
}

Measured memory_bytes: 3044
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ll long long

int main(void){
    string S,C;
    ll Q;
    ll T,F;
    bool on=false;
    cin >> S >> Q;

    REP(i,Q){
        cin >> T;
        if(T==1) on^=true;
        else{
            cin >> F >> C;
            if(on ^ (F==1)) S=S.insert(0,C);
            else S=S.insert(S.size(),C);
        }
    }
    if(on) reverse(S.begin(), S.end());
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 900
//Resting_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;

int main()
{
    ll l,r,i,j,k=2019;
    cin>>l>>r;
    if(((l/k)!=(r/k))||(l%k==0)||(r%k==0))cout<<0;
    else
    {
        ll ans=inf;
        rep(i,l+1,r)
        {
            rep(j,l,i-1)
            {
                ans=min(ans,(i*j)%k);
            }
        }
        cout<<ans;    
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define Rep1(i,k,n) for(int i=k ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

int check(int x,int k){
    int cnt = 0;
    while(x < k){
        x *= 2;
        cnt++;
    }
    return cnt;
}
int main(){

    int n,k ; cin >> n >> k;
    int s[n];
    rep(i,n){
        s[i] = check(i+1, k);
    }

    double ans = 0;

    rep(i,n){
        //cout << pow(2,s[i]) << endl;
        ans += (1+0.0) / (n * pow(2, s[i]));
    }

    printf("%.15f\n" , ans);
    
}

Measured memory_bytes: 640
/// {{{ Author: Wang, Yen-Jen
// include
#include <bits/stdc++.h>

// using
using namespace std;

// types
typedef long long ll;
typedef pair<int,int> pii;

// macro
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin() , (x).end()
#define REP(i , n) for(int i = 0; i < int(n); i++)
#define REP1(i , a , b) for(int i = a; i <= int(b); i++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define LC o<<1 , l , m
#define RC o<<1|1 , m + 1 , r
#define MS(x , v) memset(x , (v) , sizeof(x))

// input
inline bool SR(int &x) {
  return scanf("%d",&x) == 1;
}

inline bool SR(ll &x) {
  return scanf("%lld",&x) == 1;
}

inline bool SR(double &x) {
  return scanf("%lf",&x) == 1;
}

inline bool SR(char *s) {
  return scanf("%s",s) == 1;
}

inline bool RI() {
  return true;
}

template<typename I , typename... T> inline bool RI(I &x , T&... tail) {
  return SR(x) && RI(tail...);
}

// output
inline void SP(const int x) {
  printf("%d",x);
}

inline void SP(const ll x) {
  printf("%lld",x);
}

inline void SP(const double x) {
  printf("%.16lf",x);
}

inline void SP(const char *s) {
  printf("%s",s);
}

inline void PL() {
  puts("");
}

template<typename I , typename... T> inline void PL(const I x , const T... tail) {
  SP(x);
  if(sizeof...(tail)) putchar(' ');
  PL(tail...);
}

// debug
#define WangYenJen

#ifdef WangYenJen
template<typename I> void _DOING(const char *s , I&& x) {
  cerr << s << " = " << x << endl;
}

template<typename I , typename... T> void _DOING(const char *s , I&& x , T&&... tail) {
  int c = 0;
  while(*s != ',' || c != 0) {
    if(*s == '(' || *s == '[' || *s == '{') c++;
    if(*s == ')' || *s == ']' || *s == '}') c--;
    cerr << *s++;
  }
  cerr << " = " << x << " , ";
  _DOING(s + 1 , tail...);
}

#define DEBUG(...) \
do {\
  fprintf(stderr , "%s: Line %d - ",__PRETTY_FUNCTION__,__LINE__);\
  _DOING(#__VA_ARGS__ , __VA_ARGS__);\
} while(0);

#else
#define DEBUG(...)

#endif

// constant number
const int INF = 0x3f3f3f3f;
const ll INF64 = 0x3f3f3f3f3f3f3f3fll;

// random function
inline int RAND() {
  static int x = 880301;
  return (x = x * 0xdefaced + 1) % 0x7fffffff;
}
/// }}}

const int MAX_N = 100000 + 7;

int A[MAX_N];

int main() {
  int N, L;
  RI(N, L);
  REP1(i, 1, N) RI(A[i]);
  int p = -1;
  REP1(i, 1, N - 1) {
    if (A[i] + A[i + 1] >= L) {
      p = i;
      break;
    }
  }
  if (p == -1) PL("Impossible");
  else {
    PL("Possible");
    REP1(i, 1, p - 1) PL(i);
    for (int i = N - 1; i >= p; i--) PL(i);
  }
  return 0;
}


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

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

    map<char,long long> mp;
    for(char c : S) mp[c]++;

    long long ans = 1;
    const int MOD = 1e9+7;

    for(auto p : mp) ans = (ans*(p.second+1)) % MOD;
    ans--;

    cout << ans << endl;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int X = Integer.parseInt(st.nextToken());
        int N = Integer.parseInt(st.nextToken());

        if(N == 0) {
            pw.println(X);
            br.close();
            pw.close();
            return;
        }

        String[] input_array = br.readLine().split(" ");

        Set<Integer> checkSet = new HashSet<>();

        for(String str : input_array) {
            checkSet.add(Integer.parseInt(str));
        }

        int up = X;
        int down = X;
        int increment = 1;

        if(!checkSet.contains(X)) {
            pw.println(X);
            br.close();
            pw.close();
            return;
        }

        while(up != 0 || down != 0) {
            up += increment;
            down -= increment;

            if(!checkSet.contains(down)) {
                pw.println(down);
                break;
            } else if(!checkSet.contains(up)) {
                pw.println(up);
                break;
            }
        } 

        br.close();
        pw.close();
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> A(2, vector<int>(N));
  vector<vector<int>> sum(2, vector<int>(N));
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A.at(i).at(j);
    }
  }
  int cnt = 0, ans = 0;
  for (int i = 0; i < N; i++) {
    cnt = 0;
    for (int k = i; k >= 0; k--) {
      cnt += A.at(0).at(k);
    }
    for (int j = i; j < N; j++) {
      cnt += A.at(1).at(j);
    }
    ans = max(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}


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

int main()
{
	int w, h, n, x, y, a;
	int w1 = 0, h1 = 0;
	cin >> w >> h >> n;
	for (int i = 0; i < n; i++) {
		cin >> x >> y >> a;
		if ((a == 1) && (w1 < x)) w1 = x;
		if ((a == 2) && (x < w)) w = x;
		if ((a == 3) && (h1 < y)) h1 = y;
		if ((a == 4) && (y < h)) h = y;
	}
	cout << max(w - w1, 0) * max(h - h1, 0) << endl;
	return 0;
}

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

int n, a, b, c, x;

int f(int x) {
  return (a*x+b)%c;
}

int main() {
  while(cin >> n >> a >> b >> c >> x, n) {
    int ans = 0;
    vector<int> in(n);
    for(int i=0; i<n; i++) cin >> in[i];
    int i, j=0;
    for(i=0; i<=10000; i++) {
      if(x == in[j]) {
	j ++;
	if(j == n) break;
      }
      x = f(x);
    }
    if(i == 10001) cout << -1 << endl;
    else cout << i << endl;
  }
  
  return 0;
}

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

int main(){
  string S, T; cin >> S >> T;
  int N = S.size();
  vector<int> numS(26), numT(26);
  for(int i = 0; i < N; i++){
    numS[S.at(i) - 'a']++;
    numT[T.at(i) - 'a']++;
  }
  sort(numS.begin(), numS.end());
  sort(numT.begin(), numT.end());
  bool ans = true;
  for(int i = 0; i < 26; i++){
    if(numS.at(i) != numT.at(i)) ans = false;
  }
  if(ans) cout << "Yes" << endl;
  if(!ans) cout << "No" << endl;
}

Measured memory_bytes: 776
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<sstream>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<memory.h>
#include<ctime>
#include<cassert>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<numeric>
#include<bitset>
#include<list>

#define sz(a) (int)a.size()
#define np next_permutation
#define mp make_pair
#define all(a) a.begin(),a.end()
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forv(i, v) for (int i = 0; i < sz(v); ++i)
#define forab(i, a, b) for (int i = a; i <= b; i++)
#define forabd(i, a, b) for (int i = a; i >= b; i--)
#define _(a, b) memset(a, b, sizeof a)
#define pii pair<int, int>
#define pll pair<long long, long long>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

template<class T> inline T sqr(T x) { return x * x; }

const double pi = acos(-1.0), eps = 1e-9, e = exp(1.0);
const int INF = 1000 * 1000 * 1000 + 7, MAXN = 100005, MOD = 1000000007, MAXBIT = 30, pHash = 53;
const ll INFL = 1e+18;

void prepare(string s) {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt","w",stdout);
#else
	if (sz(s) != 0) {
		freopen((s + ".in").c_str(), "r", stdin);
		freopen((s + ".out").c_str(), "w", stdout);
	}
#endif
}

ll d[100];
int n;

void read() 
{
	cin >> n;
}

void solve() 
{
	d[0] = 2;
	d[1] = 1;
	for (int i = 2; i <= n; i++) {
		d[i] = d[i-1] + d[i-2];
	}
	cout << d[n];
}

int main()
{
	srand(time(NULL));
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	prepare("");

	read();
	solve();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define xrange(i, a, b) for(int i=(a); i<=(b); ++i)
#define rrange(i, a, b) for(int i=(a); i>=(b); --i)
#define read(i) scanf("%d", &i);

using namespace std;
typedef long long ll;

int arr[100005];

ll get(ll val, pair<ll, ll> range, int d){

    ll lft = 0;
    ll rgt = 1e18;

    ll res = -1;
    while(lft <= rgt){
        ll mid = (lft + rgt) >> 1;
        ll pass = mid - mid%val;
        if(pass >= range.first && pass <= range.second){
            res = mid;
            if(d) lft = mid + 1;
            else rgt = mid-1;
        }

        if(pass < range.first){
            lft = mid + 1;
        }

        if(pass > range.second){
            rgt = mid - 1;
        }
    }
    return res;
}
int main() {

   	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;

#ifdef LOCAL_DEFINE
    freopen("in", "rt", stdin);
#endif

    // solution Here

    pair <ll, ll> mM = {2, 3};

    int n; cin >> n;
    xrange(i, 0, n-1){
        cin >> arr[i];
    }

    if(arr[n-1] != 2){
        cout << -1 << endl;
        return 0;
    }

    rrange(i, n-2, 0){

        ll res1 = get(arr[i], mM, 0);
        ll res2 = get(arr[i], mM, 1);

        if(res1 == -1){
            cout << -1 << endl;
            return 0;
        }
        mM = make_pair(res1, res2);
    }

    cout << mM.first << " " << mM.second << endl;


#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif

    return 0;
}

Measured memory_bytes: 768
#include <cmath>
#include <vector>
#include <iomanip>
#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>
#include <limits>
#include <list>
#include <stack>
#include <tuple>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef vector<ll> VL;
typedef vector<VL> VVL;


int main() {
	ios::sync_with_stdio(false);
	int n, m;
	while (cin >> n >> m) {
		VP R(m);
		for (int i = 0; i < m; ++i) {
			cin >> R[i].first >> R[i].second;
			--R[i].second;
		}
		sort(R.begin(), R.end());
		VI up(n, 1), down(n, 1);
		for (int i = 0; i < m; ++i) {
			int lni = R[i].second;
			up[lni+1] = up[lni] + 1;
			down[lni] = down[lni+1] + 1;
		}
		for (int i = 0; i < n; ++i) {
			cout << up[i] + down[i] -1 << (i+1 < n ? ' ' : '\n');
		}
	}
}

Measured memory_bytes: 5164
// AtCoder template
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define M_SIZE 100001

int n,m,q,a[M_SIZE],b[M_SIZE],c[M_SIZE],d[M_SIZE],A[M_SIZE];
int dfs(int now_index, int before_A_val){
    int ret = 0;
    if(now_index == n){ // 
        rep(i,q) if(A[b[i]]-A[a[i]] == c[i]) ret += d[i];
        return ret;
    }
    for(int i = 0; before_A_val + i <= m; ++i){
        A[now_index] = before_A_val+i;
        ret = max(ret, dfs(now_index+1, A[now_index]));
    }
    return ret;
}

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

    cin >> n >> m >> q;
    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    
    cout << dfs(0, 1) << endl;
}

Measured memory_bytes: 3672
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前
sort()
sorted(reverse=true)
配列の初期化
配列名=[a]*n+[b]*m
Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools
import fractions
import sys


num = int(stdin.readline().rstrip())
res = 0
for el in range(1, num):
    tes = num % el
    tmp = int(num/el)
    if tes == 0:
        tmp -= 1
    res += tmp
print(res)


Measured memory_bytes: 73112
use std::io::{BufRead, Read};

pub struct Scanner<R>
where
    R: BufRead,
{
    reader: R,
}

impl<R> Scanner<R>
where
    R: BufRead,
{
    pub fn new(reader: R) -> Self {
        Scanner { reader: reader }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: ::std::str::FromStr,
        <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
    {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .unwrap()
    }
}

use std::cmp::min;

fn main() {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let mut sc = Scanner::new(stdin);

    let n: usize = sc.next();
    let mut a: Vec<u64> = (0..n + 1).map(|_| sc.next()).collect();
    let mut b: Vec<u64> = (0..n).map(|_| sc.next()).collect();

    let mut kills: u64 = 0;

    for i in 0..n {
        let kill = min(a[i], b[i]);
        kills += kill;
        b[i] -= kill;

        let next_kill = min(b[i], a[i + 1]);
        kills += next_kill;
        a[i + 1] -= next_kill;
    }
    println!("{}", kills);
}


Measured memory_bytes: 6396
n = int(input())

t1, a1 = map(int,input().split())

for i in range(n-1):
    t,a = map(int,input().split())
    if t1 * a == t * a1:
        pass
    elif t1 * a < t * a1:
        a1 = -(-a1 // a) * a
        t1 = a1 // a * t
    else:
        t1 = -(-t1 // t) * t
        a1 = t1 // t * a

print(a1+t1)


Measured memory_bytes: 9116
#include<iostream>
using namespace std;
#define MAX 1000000
typedef long long llong;

int m, k;
llong T[MAX];
int check(llong p) {
int i = 0;
for (int j = 0; j < k; j++ )
 {
llong s = 0;
while( s + T[i] <= p ) {
s += T[i];
 i++;
  if (i == m ) return m;
}
}
return i;
}
 int solve() {
llong left = 0;
llong right = 100000 * 10000;
llong mid;
while ( right - left > 1 ) {
mid = (left + right) / 2;
int v = check(mid);
if (v >= m ) right = mid;
else left = mid;
}

return right;
}

main() {
int i=0;
cin >> m >> k;
for (i = 0; i < m; i++ ) cin >> T[i];
llong ans = solve();
cout << ans << endl;
}



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

using namespace std;

#define ll long long
#define P pair<int,int>
#define SIZE 200010 

ll n,m,v,p,A[SIZE];

bool check(int d){
	if(d>=n-p) return true;
	ll lim=A[d]+m,zan=m*(v-p),cnt=0;
	for(int i=0;i+p<=n;i++){
		if(i==d) continue;
		ll c=min(m,lim-A[i]);
		if(c<0) return false;
		zan-=c;
	}
	return zan<=0;
}

int main()
{
	ios::sync_with_stdio(false); 
	cin>>n>>m>>v>>p;
	for(int i=0;i<n;i++) cin>>A[i];
	sort(A,A+n);
	ll l=-1,r=n;
	while(r-l>1){
		int d=(l+r)/2;
		if(check(d)) r=d;
		else l=d;
	}
	cout<<n-r;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	static int N;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		sc.close();

		dfs("", 'a');
	}

	public static void dfs(String s, char max) {
		if (s.length() == N) {
			System.out.println(s);
		} else {
			for (char c = 'a'; c <= max; c++) {
				dfs(s + c, ((c == max) ? (char) (max + 1) : max));
			}
		}
	}
}


Measured memory_bytes: 43476
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

lo n,m,b[li],a[li],k,flag,t;
lo cev;
string s;
vector<int> v;

int main(void){
	scanf("%lld %lld %lld",&n,&m,&k);
	n=n-m;
	k=k-n;
	printf("%lld\n",max(k,0ll));
	return 0;
}


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

ll n,k;
bool ch(ll x){
  for(int i=1;i<n;i++)x-=x/k+1;
  return x<0;
}

int main(){
  cin>>n>>k;
  ll l=0,r=1e18,m;
  while(l<r){
    m=(l+r)/2;
    if(ch(m))l=m+1;
    else r=m;
  }
  cout<<r<<endl;
  return 0;
}


Measured memory_bytes: 3072
# coding: utf-8
# Your code here!
N,M=map(int,input().split())
l=[]*M

for i in range(M):
    l.append(list(map(int,input().split())))
    l[i].pop(0)
    
p=list(map(int,input().split()))

count=0
s=[-1]*10

for i in range(2):
    s[0]=i
    for ii in range(2):
        s[1]=ii
        for iii in range(2):
            s[2]=iii
            for iiii in range(2):
                s[3]=iiii
                for iiiii in range(2):
                    s[4]=iiiii
                    for iiiiii in range(2):
                        s[5]=iiiiii
                        for iiiiiii in range(2):
                            s[6]=iiiiiii
                            for iiiiiiii in range(2):
                                s[7]=iiiiiiii
                                for iiiiiiiii in range(2):
                                    s[8]=iiiiiiiii
                                    for iiiiiiiiii in range(2):
                                        s[9]=iiiiiiiiii
                                        #いかれてる
                                        for j in range(M):
                                            sum=0
                                            is_success=True
                                            for item in l[j]:
                                                sum=sum^s[item-1]
                                            if sum!=p[j]:
                                                is_success=False
                                                break
                                        if is_success:
                                            count+=1
                                            
print(int(count/2**(10-N)))

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

int pa[500001] = {};
int root(int x){
    if(pa[x] == x) return x;
    int temp = root(pa[x]);
    pa[x] = temp;
    return temp;
}

void uni(int x, int y){
    x = root(x);
    y = root(y);
    pa[x] = y;
    return;
}

int main(){
    int n, m, temp, x, y, ans = 0;
    cin >> n >> m;
    queue<int> init_que;
    vector<queue<int>> s(n+1,init_que);
    for(int i = 0;i<n;i++){
        cin >> temp;
        s[temp].push(i+1);
        pa[i+1] = i+1;
    }
    for(int i = 0;i<m;i++){
        cin >> x >> y;
        uni(x,y);
    }
    for(int i = 1;i<=n;i++){
        int size = s[i].size();
        while(size >0){
            temp = s[i].front();
            if(root(temp) == root(i)){
                ans++;
                break;
            }
            s[i].pop();
            size--;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 67840
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

void solve(int tc)
{
	int n, m, k;
	cin >> n >> m >> k;
	v64 a(n, 0), b(m, 0);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < m; i++)
		cin >> b[i];
	int ans = 0;
	for (int i = 1; i < n; i++)
		a[i] += a[i - 1];
	for (int j = 1; j < m; j++)
		b[j] += b[j - 1];
	db(a, b);
	for (int i = -1; i < n; i++)
	{
		if (i == -1)
		{
			int idx = upper_bound(b.begin(), b.end(), k) - b.begin();
			idx--;
			db(idx);
			ans = max(ans, idx + 1);
		}
		else
		{
			if (a[i] <= k)
			{
				ans = max(ans, i + 1);
				int idx = upper_bound(b.begin(), b.end(), k - a[i]) - b.begin();
				idx--;
				db(idx);
				ans = max(ans, i + idx + 2);
			}
		}
	}
	cout << ans << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve(tc);
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 6324
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long LL;

int main()
{
    int x;
    while (scanf("%d", &x)==1){
        int t=sqrt(x*2);
        while ((1+t)*t/2<x) t++;
        printf("%d\n", t);
    }
    return 0;
}


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

typedef long long ll;

const ll INF = 1e18;
const int N = 2010;

ll n, x, a[N], b[N][N];

void calc() {
	for (ll i = 0; i < n; i++)
		b[i][0] = a[i];
	for (ll i = 1; i < n; i++)
		for (ll j = 0; j < n; j++) {
			ll prev = (j - i + n) % n;
			b[j][i] = min(b[j][i - 1], a[prev]);
		}
}

ll get(ll shifts) {
	ll res = x * shifts;
	for (ll i = 0; i < n; i++)
		res += b[i][shifts];
	return res;
}

int main() {
	cin >> n >> x;
	for (ll i = 0; i < n; i++) 
		cin >> a[i];
	calc();
	ll ans = INF;
	for (ll i = 0; i < n; i++)
		ans = min(ans, get(i));
	cout << ans;
}


Measured memory_bytes: 35020