akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
string s;
int calc(int l,int r){
    int keta = 1;
    int res = 0;
    for(int i = r-1;i >=l;i--){
        //trace(l,r,s[i]);
        res += keta*(s[i] - '0');
        keta *= 10;

    }
    return res;
}
signed main(){
    cin >> s;
    int n = s.size();
    int ret = 0;
    rep(i,1<<(n-1)){
        int now = 0;
        rep(j,n-1){
            if(i>>j&1){
                ret += calc(now,j+1);
                //trace(now,j+1,calc(now,j+1));
                now = j+1;
            }
        }
        ret+= calc(now,n);
        



        
    }
    cout  << ret << endl;
    return 0;
}

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

using ll = long long;
#define rep(n, i) for(ll i = 0; i < n; ++i)

void solve(void){
  ll n; cin >> n;
  vector<ll> a(n, 0);
  rep(n, i) cin >> a[i];

  ll res = a[0];
  for(ll i = 1; i < n; ++i) res ^= a[i];

  vector<ll> b(n, 0);
  rep(n, i) b[i] = (res ^ a[i]);

  rep(n, i) {
    cout << (res ^ a[i]);
    (i < n-1) ? cout << " " : cout << endl;
  }
}

int main(void) {
  solve();
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  int A[N + 1], B[N];
  for (int i = 0; i < N + 1; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];
  
  long long monster = 0;
  for (int i = 0; i < N; i++) {
    int town1 = max(0, A[i] - B[i]);
    B[i] -= A[i] - town1;
    monster += A[i] - town1;

    int town2 = max(0, A[i + 1] - B[i]);
    monster += A[i + 1] - town2;
    A[i + 1] = town2;
  }
  cout << monster << endl;
  return 0;
}

Measured memory_bytes: 1024
D,G = list(map(int,input().split()))
pc = []
for i in range(D):
    pc.append(list(map(int,input().split())))

scoreList = [0 for i in range(D)]

for i in range(D):
    scoreList[i] = (i + 1) * 100 * pc[i][0] + pc[i][1]

choiceList = [[] for i in range(2 ** D)]
for i in range(2 ** D):
    for j in range(D):
        choiceList[i].append(i // (2 ** j) % 2)

minCount = 10 ** 8
for choice in choiceList:
    score = 0
    count = 0
    for i in range(len(choice)):
        if choice[i] == 1:
            score += scoreList[i]
            count += pc[i][0]
    for j in range(D):
        countTmp = count
        extraScore = (j + 1) * 100 * pc[j][0]
        delta = G - score
        if delta < 0:
            countTmp = count
        elif delta == 0:
            countTmp = count
        elif delta > 0:
            if delta <= extraScore and choice[j] == 0:
                countTmp += delta // ((j + 1) * 100)
                if delta % ((j + 1) * 100) > 0:
                    countTmp += 1
            else:
                countTmp = 10 ** 8
        if countTmp < minCount:
            minCount = countTmp
print(minCount)

Measured memory_bytes: 9240
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
    cnt = 0
    while a[i] > 0:
        if a[i] % 2 == 0:
            cnt += 1
            a[i] = a[i] // 2
        else:
            break
    ans += cnt
print(ans)

Measured memory_bytes: 4148
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
#include <map>
#include <math.h>

using ll = long long;
using namespace std;

int main(){
    ll a, b, c , X, Y;
    cin >> a >> b >> c >> X >> Y;
    
    ll count=INF;
    rep(i, max(X, Y)+1){
       ll x = max(0LL, X-i);
       ll y = max(0LL, Y-i);
       ll d; d= c*2*i + x*a + y*b;
       if (count>d) count = d;
    }
    cout << count << endl;

}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int H_1, M_1, H_2, M_2, k;

  cin >> H_1 >> M_1 >> H_2 >> M_2 >> k;

  int min = M_2 - M_1;
  
  int time = (H_2 - H_1) * 60;
  time += (M_2 - M_1);



  cout << time - k << endl;

  return 0;
}

Measured memory_bytes: 3672
import math
from collections import Counter
from itertools import accumulate

def P(n,r):
    return math.factorial(n)//math.factorial(n-r)

def C(n,r):
    return P(n,r)//math.factorial(r)

n = int(input())
a = list(map(int,input().split()))
ac = [0] + list(accumulate(a))
c = Counter(ac)

cnt = 0
for v in c.values():
    if v >= 2:
        cnt += C(v,2)
print(cnt)
        

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

#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()

using namespace std;

using ll = long long;

int main() {
    constexpr int A_MAX = 100000;
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    sort(all(A));

    vector<ll> sum_A(N + 1, 0);
    REP(i, N) sum_A[i + 1] = sum_A[i] + A[i];

    function<ll(int)> f = [&](int lb) {
        ll result = 0;
        REP(i, N) {
            result += distance(lower_bound(all(A), lb - A[i]), A.end());
        }
        return result;
    };

    int first = 0;
    int last = 2 * A_MAX + 1;
    while (first < last) {
        int mid = (first + last) / 2;
        if (f(mid) >= M) {
            first = mid + 1;
        } else {
            last = mid;
        }
    }
    int K = first;

    ll result = 0;
    ll cnt = 0;
    REP(i, N) {
        int j = distance(A.begin(), lower_bound(all(A), K - A[i]));
        result += A[i] * (N - j) + sum_A[N] - sum_A[j];
        cnt += N - j;
    }
    result += (M - cnt) * (K - 1);

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <set>
#include <map>
#include <ctime>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define lowbit(x) ((x)&(-(x)))
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,b,a) for (int i=(b);i>=(a);--i)
typedef long long LL;
inline int read(){
    int x=0,f=1; char ch=getchar();
    while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
    while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
    return x*f;
}

const int MAXN=1000005;
int n,m,q,tot,b[MAXN];
int main(){
	n=read(); m=read(); q=read();
	memset(b,0,sizeof(b));
	FOR(i,0,n)
		FOR(j,0,m) {
			int x=i*(m-j)+j*(n-i);
			b[x]=1;
		}
	if (b[q]) printf("Yes\n"); else printf("No\n");
    return 0;
}

/*
*/


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

// MOD確認

ll dy[4]{-1,0,1,0};
ll dx[4]{0,-1,0,1};

ll H,W;
ll Sh,Sw,Gh,Gw;
char field[1010][1010];

ll d[1010][1010];
ll done[1010][1010];
priority_queue<tuple<ll,ll,ll>> Q;

void djikstra(ll sy,ll sx,ll gy,ll gx){
   rep(i,1010)rep(j,1010){
      d[i][j] = INF;
      done[i][j] = 0;
   }
   d[sy][sx] = 0;
   Q.emplace(0,sy,sx);
   while(Q.size()){
      ll cost,y,x;
      tie(cost,y,x) = Q.top();
      Q.pop();
      done[y][x] = 1;
      if(y == gy && x == gx) break;
      rep(i,4){
         ll ny = y + dy[i],nx = x + dx[i];
         if(0 <= ny && ny < H && 0 <= nx && nx < W){
            if(field[ny][nx] != '#' && !done[ny][nx]){
               if(d[ny][nx] > -cost){
                  d[ny][nx] = -cost;
                  Q.emplace(cost,ny,nx);
               }
            }
         }
      }
      FOR(i,-2,3){
         FOR(j,-2,3){
            ll ny = y + i,nx = x + j;
            if(0 <= ny && ny < H && 0 <= nx && nx < W){
               if(field[ny][nx] != '#' && !done[ny][nx]){
                  if(d[ny][nx] > -cost + 1){
                     d[ny][nx] = -cost + 1;
                     Q.emplace(cost - 1,ny,nx);
                  }
               }
            }
         }
      }
   }
}

int main(){
   cin >> H >> W >> Sh >> Sw >> Gh >> Gw;
   Sh--;Sw--;Gh--;Gw--;
   rep(i,H) rep(j,W) cin >> field[i][j];
   djikstra(Sh,Sw,Gh,Gw);
   if(d[Gh][Gw] >= INF) cout << -1 << endl;
   else cout << d[Gh][Gw] << endl;
}

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

namespace Atcoder
{
    public class Program
    {
        private static long mod = 1000000007;

        static void Main(string[] args)
        {
            var r = ReadSplit();
            var x1 = r[0].Int();
            var x2 = r[1].Int();
            var x3 = r[2].Int();
            var x4 = r[3].Int();
            var x5 = r[4].Int();
            if (x1 == 0)
            {
                Write("1");
                return;
            }
            if (x2 == 0)
            {
                Write("2");
                return;
            }
            if (x3 == 0)
            {
                Write("3");
                return;
            }
            if (x4 == 0)
            {
                Write("4");
                return;
            }
            if (x5 == 0)
            {
                Write("5");
                return;
            }
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long N;
    cin >> N;
    int K;
    cin >> K;
    if(N%2LL){
        for(int i=0; i<K; i++){
            long long a,b;
            cin >> a >> b;
            if(a>(N+1LL)/2LL){
                a = (N+1LL)/2LL - (a%((N+1LL)/2LL));
            }
            if(b>(N+1LL)/2LL){
                b = (N+1LL)/2LL - (b%((N+1LL)/2LL));
            }
            long long mn = min(a,b);
            if(mn%3){
                cout << mn%3 << "\n";
            }else{
                cout << 3 << "\n";
            }
        }
    }else{
        for(int i=0; i<K; i++){
            long long a,b;
            cin >> a >> b;
            if(a>(N+1LL)/2LL){
                a = N-a+1LL;
            }
            if(b>(N+1LL)/2LL){
                b = N-b+1LL;
            }
            long long mn = min(a,b);
            if(mn%3){
                cout << mn%3 << "\n";
            }else{
                cout << 3 << "\n";
            }
        }
    }
    return 0;

}


Measured memory_bytes: 3180
#include <stdio.h>

int main(void) {
	int N, K;
	int i;

	scanf("%d%d", &N, &K);

	int score;
	int base = 1;
	int count[N + 1];
	int total_count = 0;

	double p = 1;

	while (base < K) {
		base *= 2;
	}

	for (i = 1;i <= N;i++) {
		score = i;
		count[i] = 1;

		while (score < K) {
			count[i] *= 2;
			score *= 2;
		}

		total_count += base / count[i];
	}

	p *= total_count;
	
	p /= base * N;

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

	return 0;
}

Measured memory_bytes: 512
s = raw_input()
sr = s[::-1]
sx = s.replace("x","")

if s == sr:
  print 0
  exit(0)

if sx != sx[::-1]:
  print -1
  exit(0)

x1 = []
x2 = []
pos1 = 0
pos2 = 0

for a in s:
  if a != "x":
    x1.append(pos1)
    pos1 = 0
  else:
    pos1 += 1
x1.append(pos1)

for a in sr:
  if a != "x":
    x2.append(pos2)
    pos2 = 0
  else:
    pos2 += 1
x2.append(pos2)

count = 0
for a in range(len(x1)):
  count += abs(x1[a]-x2[a])

print count/2


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

using namespace std;


// Bismilahir Rahmanir Rahim


typedef unsigned int ui;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef short int si;
typedef unsigned short int usi;
typedef pair <int, int> pii;


#define CASE false
#define TEST false
#define BUFFER true
#define TIME false
#define DEBUG true
#define SET_GEN false
#define _ << " " <<
#define __ << "\n"
#define ff first
#define ss second
#define RANGE(a, b) (rand() % (b-a+1) + a)


const double pi = acos(-1.);
const double eps = 1e-7;
const int high = 2e9;
const int inf = 2147483647;
const int _inf = -2147483648;
const lli INF = 1e18;
const int mod = 1e9+7;


void delay(int sec); // DEBUG

const int maxn = 1e5 + 1;
vector <int> adj[maxn];
int in_degree[maxn];
int dist[maxn];
bool vis[maxn];


void dfs(int now)
{
	assert(!vis[now]);
	vis[now] = true;
	
	for(auto u : adj[now]) {
		dist[u] = max(dist[u], dist[now]+1);
		in_degree[u]--;
		if (!in_degree[u]) dfs(u);
	}
	
	return ;
}

void solution(void)
{	
	int n, m;
	
	cin >> n >> m;
	
	while (m--) {
		int u, v;
		
		cin >> u >> v;
		
		adj[u].push_back(v);
		in_degree[v]++;
	}
	
	for(int i = 1; i <= n; ++i) {
		if (!vis[i] && in_degree[i] == 0) dfs(i);
	}
	
	int ans = _inf;
	for(int i = 1; i <= n; ++i) ans = max(ans, dist[i]);
	
	cout << ans __;


    return ;
}

int main(int argc, char *arv[])
{
    #if BUFFER
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #endif

    #if SET_GEN
    srand((unsigned int) time(0));
    #endif

    #if prep
    prep_calc();
    #endif

    int t = 1;

    #if CASE
    int cnt = 1;
    #endif

    #if TEST
    cin >> t;
    #endif

    #if TIME
    clock_t start_time, end_time;
    double time_elapsed;
    #endif


    while(t--) {

        #if TIME
        start_time = clock();
        #endif

        #if CASE
        cout << "Case " << cnt++ << ": ";
        #endif

        solution();

        #if TIME
        end_time = clock();

        time_elapsed = (double) (end_time - start_time) / CLOCKS_PER_SEC;

        cout << "\nRuntime: " << fixed << setprecision(7) << time_elapsed << "\n";
        #endif
    }


    return 0;
}

void delay(int sec)
{
    int mili_sec = 1000 * sec;

    clock_t start_time = clock();

    while (clock() < start_time + mili_sec);

    return ;
}


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

#define ll long long 

using namespace std;

ll a,b;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>a>>b;
    ll c=max(a,b);
    int k=2;
    
    while(c%min(a,b)!=0){
        c=max(a,b);
        c*=k;
        k++;
    }
    cout<<c;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[200005],b[200005];
int main(){
	cin>>n;
	for (int i=1;i<=n;++i){
		scanf("%d",&a[i]);
	}
	for (int i=n;i>=1;--i){
		if (i*2>n) b[i]=a[i];
		else{
			int sum=0;
			for (int j=i+i;j<=n;j+=i){
				sum=(sum+b[j])%2;
			}
			b[i]=sum^a[i];
		}
	}
	int tot=0;
	for (int i=1;i<=n;++i) tot+=b[i];
		cout<<tot<<endl;
	for (int i=1;i<=n;++i){
		if (b[i]) printf("%d ",i);
	}
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  pair<ll,ll> s;
  cin >> s.first >> s.second;
  pair<ll,ll> t;
  cin >> t.first >> t.second;

  ll x = t.first - s.first;
  ll y = t.second - s.second;
  
  string to = "";
  rep(i,y) to += 'U';
  rep(i,x) to += 'R';
  string back = "";
  rep(i,y) back += 'D';
  rep(i,x) back += 'L';






  cout  << to<< back << "LU" << to << "RD" << "RD" << back << "LU" << endl;

  

  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	s, _ := reader.ReadString('\n')

	for i := 0; i < len(s); i++ {
		c := s[i]
		if c >= 'A' {
			if c < 'a' {
				fmt.Print(string(c + 'a' - 'A'))
			} else if c <= 'z' {
				fmt.Print(string(c - 'a' + 'A'))
			}
		} else {
			fmt.Print(string(c))
		}
	}
}



Measured memory_bytes: 1088
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        for (int i = a; i < Math.min(a + c, b+1); i++) {
            System.out.println(i);
        }
        for (int i = Math.max(b - c + 1, a + c ); i <= b; i++) {
            System.out.println(i);
        }
    }
}


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

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

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
int a[125252];

int main(){
    scanf("%d",&n);
    REP(i,n)scanf("%d",a+i);
    sort(a,a+n);
    int lb = a[n/2-1];
    int ub = a[n/2];
    printf("%d\n",ub-lb);
    return 0;
}


Measured memory_bytes: 640
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}/*}}}*/
/******************heading******************/

const int N=2e5+5;

int n;
int a[N];

map<int,int> c;
bool check(int k){
    int len=0;
    c.clear();
    FOR(i,1,n){
        if(a[i]>len){
        }else {
            int pos=a[i];
            if(k==1)return 0;
            while(pos&&c.count(pos)&&c[pos]==k-1)--pos;
            if(pos==0)return 0;
            c[pos]++;
            map<int,int>::iterator it=c.find(pos);
            ++it;
            c.erase(it,c.end());
        }
        len=a[i];
    }
    return 1;
}
int main(){
    scanf("%d",&n);
    FOR(i,1,n)scanf("%d",&a[i]);
    int l=1,r=n+1,mid;
    while(l<r)mid=(l+r)>>1,check(mid)?r=mid:l=mid+1;
    printf("%d\n",l);
    return 0;
}


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

struct Ant {int x, w, y, z=-1;};

int main() {
  int N, L, T;
  cin >> N >> L >> T;
  vector<Ant> ant(N);
  for(auto& a: ant) cin >> a.x >> a.w;

  for(auto& a: ant) {
    if(a.w == 1) a.y = (a.x + T) % L;
    else         a.y = (a.x - T) % L;
    if(a.y < 0) a.y += L;
  }

  ant[0].z = 0;
  for(auto& a: ant) if(a.w != ant[0].w) {
    if(ant[0].w == 1) {
      auto d = a.x - ant[0].x;
      if(d <= 2*T) ant[0].z += 1 + (2*T-d)/L;
    } else {
      auto d = ant[0].x + L-a.x;
      if(d <= 2*T) ant[0].z -= 1 + (2*T-d)/L;
    }
    ant[0].z %= N;
    if(ant[0].z < 0) ant[0].z += N;
  }

  auto s = ant[0];
  sort(begin(ant), end(ant), [](auto l, auto r) {return l.y!=r.y ? l.y<r.y : l.w>r.w;});

  for(auto i=0; i<N; ++i) if(ant[i].x == s.x) {
    for(auto j=0; j<N; ++j) {
      auto p = (i + j) % N;
      auto z = (s.z + j) % N;
      ant[p].z = z;
    }
    break;
  }

  sort(begin(ant), end(ant), [](auto l, auto r) {return l.z < r.z;});
  for(auto a: ant) cout << a.y << endl;
}


Measured memory_bytes: 2816
from collections import defaultdict
from itertools import combinations


def main():
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        S = input()
        d[S[0]] += 1
    ans = 0
    for chars in combinations('MARCH', 3):
        ans += d[chars[0]] * d[chars[1]] * d[chars[2]]
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
#define N 10005
char s[N],t[N];
signed main()
{
	scanf("%s%s",s+1,t+1);
	int n=strlen(s+1),m=strlen(t+1);
	int ans=inf;
	for(int i=1;i<=n;i++)
	{
		if(i+m-1>n) break;
		int cnt=0;
		for(int j=1;j<=m;j++) cnt+=(s[i+j-1]!=t[j]);
		ans=min(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 3688
# encoding:utf-8
import copy
import numpy as np
import random
import bisect #bisect_left　これで二部探索の大小検索が行える

length = []

for i in range(5):
    length.append(int(input()))

k = int(input())

length.sort()
if length[-1]-length[0] > k:
    print(":(")
else:
    print("Yay!")


Measured memory_bytes: 24260
N=int(input())
A=[]
for i in range(N):
    h,p=map(int,input().split())
    A.append((h+p,h,p))
A.sort()
dp=[[10**13]*(N+1) for i in range(N+1)]
for i in range(N+1):
    dp[i][0]=0
for i in range(1,N+1):
    s=A[i-1][1]
    t=A[i-1][2]
    for j in range(1,i+1):
        #print(A[i-1])
        if dp[i-1][j-1]>s:
            dp[i][j]=dp[i-1][j]
        else:
            dp[i][j]=min(dp[i-1][j],dp[i-1][j-1]+t)
for j in range(N,-1,-1):
    if dp[N][j]<10**13:
        print(j)
        break

Measured memory_bytes: 232884
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a>>b>>c;
    if(c-a-b<=0){
        cout<<"No";
        return 0;
    }
    d=a*b*4;e=(c-a-b)*(c-a-b);
    if(d<e){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

template <typename T> lint gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> lint lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b) a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b) a=b;}
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef STOP_DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

struct IoSetup{
    IoSetup(){
      ios::sync_with_stdio(false);
      cin.tie(0);
      cout << fixed << setprecision(20);
      cerr << fixed << setprecision(20);
    }
} IoSetup;
long long a[1100];
void check(int n) {
  for (int i = 2; i <= n; ++i) {
    while (n % i == 0) {
      (++a[i]);
      n /= i;
    }
  }
}
const int mod = 1e9 + 7;

int main() {
  int n; cin >> n;
  for (int i = 2; i <= n; ++i) {
    check(i);
  }
  lint ans = 1;
  for (int i = 0; i < 1010; ++i) {
    ans *= a[i]+1;
    ans %= mod;
  }
  cout << ans << '\n';
}


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

int n, k;
vector <int> e[2001];
int d[2001][2001];
vector <int> eA, eB;

void dfs(int cur, int from, int root, int curDist)
{
	d[root][cur] = curDist;
	for(int i = 0; i < e[cur].size(); i++)
	{
		int t = e[cur][i];
		if(t != from)
			dfs(t, cur, root, curDist + 1);
	}
}

int MAIN()
{
	cin >> n >> k;
	for(int i = 1; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		e[a].push_back(b);
		e[b].push_back(a);
		eA.push_back(a);
		eB.push_back(b);
	}
	for(int i = 1; i <= n; i++)
		dfs(i, -1, i, 0);
	int bestAns = 0;

	for(int i = 1; i <= n; i++)
	{
		int cnt = 0;
		for(int j = 1; j <= n; j++)
			if(2 * d[i][j] <= k)
				cnt ++;
		bestAns = max(bestAns, cnt);
	}
	for(int i = 0; i < eA.size(); i++)
	{
		int a = eA[i];
		int b = eB[i];
		int cnt = 0;
		for(int j = 1; j <= n; j++)
			if(2 * min(d[j][a], d[j][b]) + 1 <= k)
				cnt ++;
		bestAns = max(bestAns, cnt);
	}
	cout << n - bestAns << endl;
	return 0;
}

int main()
{
	int start = clock();
	#ifdef LOCAL_TEST
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	ios :: sync_with_stdio(false);
	cout << fixed << setprecision(16);
	int ret = MAIN();
	#ifdef LOCAL_TEST
		cout << "[Finished in " << clock() - start << " ms]" << endl;
	#endif
	return ret;
}


Measured memory_bytes: 16128
def countAB(S):
  ct=0
  flg = True
  pos=0
  while flg:
    idx = S.find('AB',pos)
    if idx!=-1:
      ct+=1
    else:
      flg = False
    pos = idx + 2
  return ct
 
N = int(input())
 
num_AB = 0
num_A = 0
num_B = 0
num_BA = 0
for n in range(N):
  S = input()
  num_AB += countAB(S)
  if S[len(S)-1]=='A':
    num_A += 1
  if S[0]=='B':
    num_B += 1
  if S[len(S)-1]=='A' and S[0]=='B': 
    num_BA += 1
    
num_AB_cmb = min(num_A,num_B)
if num_A == num_BA and num_B == num_BA and num_BA!=0:
  num_AB_cmb = num_BA-1
 
print("{0}".format(num_AB + num_AB_cmb))

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main() {
    int N, M;
    cin >> N >> M;
    int ret[31][31] = {};
    for (int i = 0; i < N; ++i) {
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int temp;
            cin >> temp;
            ret[i][temp-1] = 1;
        }
    }
    int retN = 0;
    for (int j = 0; j < M; ++j) {
        bool like = true;
        for (int i = 0; i < N; ++i) {
            if (ret[i][j] != 1)
            {
                like = false;
            }
            if (!like)
                break;
        }
        if (like)
            retN++;
    }
    cout << retN << endl;

    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

#define P 1000000007
#define N_MAX 10000000
typedef long long int ll;
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
  if(n<0||k<0||n<k) return 0;
  return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
  fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
  for(int i = 2; i <= N_MAX; i++){
    fac[i] = (fac[i-1]*i)%P;
    inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
    finv[i] = (finv[i-1]*inv[i])%P;
  }
}
ll pp(ll a, ll b){
  return (a * b)%P;
}
int main(int argc, char const *argv[]) {
  init();
  ll n, ans = 0;std::cin >> n;
  ll s = 0;
  for(ll i=n/2+n%2;i<n;i++){
    ll tmp = pp(fac[i], fac[n-1-i]);
    tmp = pp(tmp, comb(i-1, n-1-i));
    tmp = (tmp - s + P)%P;
    s = (s + tmp)%P;
    ans = (ans + pp(i, tmp))%P;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 234624
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  vector<int> p(m);
  rep(i,m){
    int k;
    cin >> k;
    s[i] = vector<int>(k);
    rep(j,k) cin >> s[i][j];
  }
  rep(i,m) cin >> p[i];

  int ans = 0;
  rep(bit,1<<n){
    bool ok = true;
    rep(i,m){
      int sum = 0;
      rep(j,s[i].size()){
        int biti = bit&(1<<(s[i][j]-1));
        if(biti>0) ++sum;
      }
      if(sum%2!=p[i]){
        ok = false;
        break;
      }
    }
    if(ok) ++ans;
  }
  cout << ans << endl;
}


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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

int main(){

string S;
cin >> S;

REP(i, S.size()){
  int cnt = 0;
  REP(j, S.size()){
    if(S.at(i) == S.at(j)) cnt++;
    if(j == S.size() - 1 && cnt % 2 != 0){
      no;
      return 0;
    } 
  }
}

yes;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if (abs(a - b) <= (v - w) * t)cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

int main() {
    long long int n,k;cin>>n>>k;
	if(n%k==0)   cout<<"0"<<endl;
	else{
	long long int a=n%k;
	long long int ans=min(a,abs(a-k));
	cout<<ans<<endl;
	}
	return 0;
}

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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<< "\n"

int main(){
    int b;
    cin >> b;
    int num = b/3600;
    b %= 3600;
    int sum = b/60;
    printf("%d:%d:%d\n",num,sum,b%60);
    return 0;
}


Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
int main() {
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    for (int i = 0; i < s.size()-1; ++i) {
        if(s[i] == s[i+1]){
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
}
std::uint32_t euclidean_gcd(std::uint32_t a, std::uint32_t b){return b != 0 ? euclidean_gcd(b, a % b) : a;}


void solve(long long N, std::vector<std::string> S){
    map <string, int> m;
    REP(i, N){
        m[S[i]]=0;
    }
    REP(i, N){
        m[S[i]]++;
    }
    int maxim=0;
    REP(i,N){
        maxim=max(maxim, m[S[i]]);
    }
    vector <string> unique;
    vector <string> dict;
    REP(i, N){
        if(m[S[i]]==maxim){
            dict.PB(S[i]);
            m[S[i]]=0;
        }
    }
    SORT(dict);
    REP(i, dict.size()){
        cout<<dict[i]<<endl;
    }return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 28404
func mainA() {
    let S = readLine()!

    switch S {
    case "SSS":
        print(0)
    case "SSR":
        print(1)
    case "SRS":
        print(1)
    case "RSS":
        print(1)
    case "SRR":
        print(2)
    case "RRS":
        print(2)
    case "RSR":
        print(1)
    case "RRR":
        print(3)
    default:
        fatalError()
    }
}
mainA()

Measured memory_bytes: 7748
/*
g++ -std=c++14 -O2 -Wall a.cpp -o a && a
g++ -std=c++14 -O2 -Wall a.cpp -o a && a < in.txt > out.txt
*/

//  io
#include <iostream>
//#include <fstream> //http://www.cplusplus.com/reference/fstream/fstream/
#include <cstdio>
//#include <iomanip> //http://www.cplusplus.com/reference/iomanip/
//  util
#include <string>
#include <cstring>
#include <algorithm>
//#include <utility>
//#include <functional> //http://www.cplusplus.com/reference/functional/
//#include <cstdlib>
#include <cmath>
//#include <complex>
//#include <random>
//#include <bitset>
//  containers https://en.cppreference.com/w/cpp/container
#include <vector>
#include <queue>
#include <set>
#include <map>
//#include <unordered_set>
//#include <unordered_map>
//  time
//#include <ctime>
//#include <chrono>
//                  https://en.cppreference.com/w/cpp/header/chrono
//                  http://www.cplusplus.com/reference/chrono/

using namespace std;
typedef vector<int> arri;
typedef vector<float> arrf;
typedef pair<int, int> pairi;
typedef long long ll;
typedef long double ld;
const int mod = 1000000007;
const ll inf = 0x7fffffffffffffff;
const ll infneg = -0x7fffffffffffffff;

ll modadd(ll a, ll b) { return ((a += b) < mod) ? a : (a - mod); }
ll modmult(ll a, ll b) { return (ll)((a * b) % mod); }

//file input routed to stdinout
/*
std::ifstream inFile("input.txt");
std::ofstream outFile("output.txt");
std::cin.rdbuf(inFile.rdbuf());
std::cout.rdbuf(outFile.rdbuf());
*/

ll dp[2010][2010];

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

    memset(dp, 0, 2010 * 2010 * sizeof(int));

    int n, k;
    cin >> n >> k;

    for (int i = 0; i < n + 1; i++)
    {
        dp[i][0] = 1;
        for (int j = 1; j < i + 1; j++)
        {
            dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1]) % mod;
        }
    }

    if (n == 1 && k == 1)
    {
        cout << 1;
    }
    else
    {
        for (int i = 1; i <= k; i++)
        {
            ll aux = dp[n - k + 1][i] * dp[k - 1][i - 1] % mod;
            cout << aux << endl;
        }
    }
}

Measured memory_bytes: 31744
function Main(input) {
  input = input.split("\n");
  var A = parseInt(input[0].split(" ")[0]);
  var B = parseInt(input[0].split(" ")[1]);
  var C = parseInt(input[0].split(" ")[2]);
  var ans = Math.max(0,C-(A-B));

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
//
//  main.cpp
//  D - ModSum
//
//  Created by Hashizo on 2019/09/01.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>

using namespace std;

#undef LONG_MAX
#undef LONG_MIN

#define LONG_MAX	9223372036854775807
#define LONG_MIN	(-LONG_MAX  -1)

#define ll long long

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {
	ll n;
	ll cnt = 0;
	cin >> n;

	FOR(i, 1, n) {
		cnt += i;
	}
	
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static int mod = 1000000007;

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

    long[] count = new long[K+1];

    for(int j=K; j>=1; j--) {
      count[j] = power((long)K/j, (long)N);

      int multi = 2;
      while(j*multi <= K) {
        count[j] -= count[j*multi];
        multi++;
      }
    }

    long sum = 0;
    for(int j=1; j<=K; j++) {
      sum += j * count[j] % mod;
      sum = sum % mod;
    }

    System.out.println(sum);
  }

  public static long power(long x, long n) {
    long result = 1;
    while(n > 0) {
      if(n%2 == 1) {
        result *= x;
        result %= mod;
      }
      x = x*x;
      x %= mod;

      n >>= 1;
    }

    return result;
  }
}

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

int main() {
  string s;
  cin >> s;
  string ans = "No";
  if (s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(0) != s.at(2)) ans = "Yes";
  else if (s.at(0) == s.at(2) && s.at(1) == s.at(3) && s.at(0) != s.at(1)) ans = "Yes";
  else if (s.at(0) == s.at(3) && s.at(1) == s.at(2) && s.at(0) != s.at(1)) ans = "Yes";
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using V = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

/* ----------- ANSWER ----------- */
/* ------------------------------ */

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n = inl();
        vl a(n);
        rep(i, n) cin >> a[i];

        sort(all(a));
        V<P> ans;
        ll bg = a.back(), sml = a[0];
        for (long long i = 1; i < n - 1; ++i) {
            if (a[i] <= 0) {
                ans.eb(P(bg, a[i]));
                bg -= a[i];
            } else {
                ans.eb(P(sml, a[i]));
                sml -= a[i];
            }
        }
        ans.eb(P(bg, sml));
        cout << bg - sml << endl;
        each(m, ans) {
            cout << m.F << " " << m.S << endl;
        }

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(q);
  rep(i,q) cin >> a.at(i);
  
  vector<int> pts(n,k-q);
  rep(i,q) pts.at(a.at(i)-1)++;
  
  rep(i,n) {
    if (pts.at(i) > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 1408