akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
long N(int x){
  return (long)(x+1)*(x+2)*(x+3)/6;
}
 
int main(){
  int n;
  while(~scanf("%d",&n)){
    if (n>2000) n = 4000-n;
    if (n<1001) printf("%d\n",N(n));
    else printf("%ld\n", N(n)-(N(2*(n-1000))-n+999)/2);
  }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define FOR(i, x, y) for (ll i = x; i < y; i++)
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, a[400], cost[400][400], dp[400][400];
    cin >> n;
    FOR(i, 0, n) { cin >> a[i]; }
    FOR(i, 0, n) {
        fill(dp[i], dp[i] + 400, LLONG_MAX);
        dp[i][i] = 0;
        cost[i][i] = a[i];
    }
    FOR(i, 1, n) {
        FOR(j, 0, n - i) {
            cost[j][j + i] = a[j + i] + cost[j][j + i - 1];
            FOR(k, j, j + i) {
                dp[j][j + i] =
                    min(dp[j][j + i], dp[j][k] + cost[j][k] + dp[k + 1][j + i] +
                                          cost[k + 1][j + i]);
            }
            // cout << j << ' ' << j + i << ' ' << dp[j][j + i] << '\n';
        }
    }
    cout << dp[0][n - 1] << '\n';
    return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1e6+5
#define quick_pow_mod 1e9+7
#define PII pair<int,int>
const int factor_N = 1e7 + 5;
const int tree_arr_N = 1e6 + 5;
using namespace std;
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (; isdigit(c); c = getchar())
		x = x * 10 + c - 48;
	return x * f;
}
int n;
int main() {
	n = read();
	n %= 1000;
	if (n == 0) cout << 0 << endl;
	else cout << 1000 - n << endl;
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
 
using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
 
const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
 
char C[] = {'I', 'O', 'T', 'J', 'L', 'S', 'Z'};
 
LL func1(map<char, LL> mp) {
    LL ans = mp['O'];
 
 
    LL buf = mp['I'] / 2;
    ans += (buf) * 2;
    buf = mp['L'] / 2;
    ans += (buf) * 2;
    buf = mp['J'] / 2;
    ans += (buf) * 2;
    mp['I'] %= 2;
    mp['L'] %= 2;
    mp['J'] %= 2;
 
 
 
    return ans;
}
LL func2(map<char, LL> mp) {
    LL ans = mp['O'];
 
    if (mp['I'] > 0 && mp['L'] > 0 && mp['J'] > 0) {
        mp['I'] --;
        mp['J'] --;
        mp['L'] --;
        ans += 3;
    }
    LL buf = mp['I'] / 2;
    ans += (buf) * 2;
    buf = mp['L'] / 2;
    ans += (buf) * 2;
    buf = mp['J'] / 2;
    ans += (buf) * 2;
    mp['I'] %= 2;
    mp['L'] %= 2;
    mp['J'] %= 2;
 
    return ans;
}
 
int main(void) {
    map<char, LL> mp;
    REP(i, 7) {
        LL buf;
        scanf("%lld", &buf);
        mp[C[i]] = buf;
    }
 
    cout << max(func1(mp), func2(mp)) << endl;
}

Measured memory_bytes: 384
#!/usr/bin/perl

my ($x) = map { $_ - 0 } split(/\s+/,<STDIN>);

my $a = int($x / 500);

$x -= 500 * $a;

my $b = int($x / 5);

my $r = $a * 1000 + $b * 5;
print "$r\n";



Measured memory_bytes: 512
import sys
import math
l = []
for i in range(int(input())):
    l.append(list(map(int,input().split())))
start = [0,0]
back = 0
for i in l:
    dist = math.fabs((start[0] - i[1]) + (start[1] -i[2]))
    if(dist > (i[0]-back)):
        print("No")
        sys.exit()
    else:
        if((dist-(i[0]-back))%2 == 0):
            start = [i[1],i[2]]
            back = i[0]
        else:
            print("No")
            sys.exit()
print("Yes")

Measured memory_bytes: 27400
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

priority_queue<P> pq;

ll a[225816],b[225816];

int main(void){
	int n,i;
	ll x,y,z,ans=0ll,tmp;
	P p;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	for(i=0; i<n; ++i){
		cin >> b[i];
		pq.push(P(b[i],i));
	}
	while(!pq.empty()){
		p = pq.top();
		pq.pop();
		i = p.second;
		x = b[(i+n-1)%n];
		z = b[(i+1)%n];
		tmp = (b[i]-a[i])/(x+z);
		ans += tmp;
		b[i] -= (x+z)*tmp;
		if(tmp && b[i]>a[i]){
			pq.push(P(b[i],i));
		}
	}
	for(i=0; i<n; ++i){
		if(a[i]-b[i]){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 8944
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split();
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);

            int ans = 0;

            if(N != 0) ans += N*(N-1)/2;
            if(M != 0) ans += M*(M-1)/2;
            
            Console.WriteLine(ans);
        }
    }
}


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

const int N = 200003;

int n, a[N], b[N];
int maxx=-1, maxi;
signed main(void)
{
	cin >> n;
	for(int i=1; i<=n; ++i) 
	{

	cin >> a[i];b[i]=a[i];
	if(maxx < a[i])
	{
		maxx = a[i];
		maxi=i;
	 } 
}
sort(b+1, b+n+1);
for(int i=1; i<=n; ++i)
{
	if(i != maxi)printf("%d\n", b[n]);
	else 	printf("%d\n", b[n-1]);
}
	

	return 0;
}

Measured memory_bytes: 3200
using System;

namespace ProgramingStydying
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var ans = "";
            for(int i = 0; i < s.Length; i += 2)
            {
                ans += s[i];
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 47916
while True:
  try:
    ss = input()
    ans1 = ans2 = 0
    for i in range(len(ss) - 2):
      if ss[i] == 'J' and ss[i + 1] == 'O' and ss[i + 2] == "I":
        ans1 += 1
      elif ss[i] == 'I' and ss[i + 1] == 'O' and ss[i + 2] == "I":
        ans2 += 1
    print(ans1)
    print(ans2)
  except EOFError:
    break


Measured memory_bytes: 5572
#include <bits/stdc++.h>
#define ull uint64_t
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mx5 100005
#define mx6 1000005
#define mod 1000000007
#define nfs ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main() {
    nfs
    
    int n, w, ans = 0;
    ll dp[mx5] = {};
    fill(dp+1, dp + mx5, mod*10000ll);
    
    cin >> n >> w;
    
    for (int i = 0, wi, vi; i < n; i++) {
        cin >> wi >> vi;
        for (int j = mx5-1; j >= vi; j--) {
            dp[j] = min(dp[j], dp[j - vi] + wi);
        }
    }
    for (ans = mx5-1; ans >= 0 && dp[ans] > w; ans--);
    
    cout << ans;
}

Measured memory_bytes: 4392
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    
    int amari_ini = a % b;
    for (int i = 1; i < b + 1; i++) {
        int amari = (amari_ini * i) % b;

        if (amari == c) {
            cout << "YES" << endl;
            return 0;
        }   
    }   

    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<int> subsum(n + 1, 0);
    subsum[0] = abs(0 - a[0]);
    for(int i = 1; i < n; i++)
    {
        subsum[i] = subsum[i - 1] + abs(a[i - 1] - a[i]);
    }
    subsum[n] = subsum[n - 1] + abs(a[n - 1] - 0);
    for(int i = 0; i < n; i++)
    {
        if(i == 0)
        {
            int total = subsum.back() - subsum[i + 1] + abs(0 - a[i + 1]);
            cout << total << endl;
        }else if(i == n - 1)
        {
            int total = subsum[i - 1] + abs(a[i - 1] - 0);
            cout << total << endl;
        }
        else{
            int total = subsum[i - 1] + (subsum.back() - subsum[i + 1]) + abs(a[i - 1] - a[i + 1]);
            cout << total << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>
int main(void)
{
    int h=0,m=0,s=0;
    scanf("%d",&s);
    m=s/60;
    s%=60;
    h=m/60;
    m%=60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

Measured memory_bytes: 2744
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e18

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	if(k==0){
		cout << n*n << endl;
		return 0;
	}
	for(int i = k+1; i <= n; i++){
		ans+=n/i*(i-k);
		if(n%i){
			ll x=n%i;
			ans+=max(ll(0),x-k+1);
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

void fast()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
}
int gcd(int a, int b) {
   if (b == 0)
      return a;
   return gcd(b, a % b);
}
const int mxA = 1e7;
int freq [mxA+1] ;
int pref [mxA+1];

int main()
{
    fast();
    int n;
    cin >> n;
    int counter = 0;
    int sum = 0;
    for(int i = 1 ; i<=n ; i++)
    {
        if(i%2!=0)
        {
            for(int j = 1 ; j<=i ; j++)
            {
                if(i%j==0) counter++;
            }
            if(counter >= 8 ) sum++;
            counter=0;

        }

    }
    cout << sum;
}



Measured memory_bytes: 256
a, b, c, x, y = gets.chomp.split(" ").map(&:to_i)

if (a + b) / 2 >= c
  if x == y
    puts c * x * 2
  elsif x > y
    puts [c * x * 2, c * y * 2 + (x - y) * a].min
  elsif x < y
    puts [c * y * 2, c * x * 2 + (y - x) * b].min
  end
else
  puts a * x + b * y
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
    using namespace std;
     
    #define ll long long
    #define mod 1000000007
    #define IO_fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     
    int main(){
        IO_fast
        int n;
        cin >> n;
        ll a[n];
        for(int i = 0 ; i<n ; i++) cin >> a[i];
     
        ll sum[n];
        sum[0] = a[0]%mod;
        for(int i = 1 ; i<n ; i++){
            sum[i] = a[i]%mod + sum[i-1];
            sum[i] = sum[i]%mod;
        }

        ll answer = 0;
        for(int i = 0 ; i<n ; i++){
            answer = (answer+(a[i]%mod)*(sum[n-1]-sum[i]+mod))%mod;
            answer = answer%mod;
        }
     
        cout << answer << endl;
        return 0;
    }

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

int main(int argc, char const *argv[])
{
	int x , a , b ;

	cin >> x >> a >> b ;

	if(abs(a-b) <= x){
		if(a-b >= 0)printf("delicious\n");
		else printf("safe\n");
	}
	else printf("dangerous\n");

	return 0;
} 

Measured memory_bytes: 256
N,K = list(map(int,input().split()))
AB = [list(map(int,input().split())) for _ in range(N)]
M = {}
for ab in AB:
    if ab[0] in M:
        M[ab[0]] += ab[1]
    else:
         M[ab[0]] = ab[1]
tmp = 0
keys = sorted(M.keys())
if M[keys[0]] >= K:
    print(keys[0])
    exit()
for i in range(1,len(keys)):
    M[keys[i]] = M[keys[i]]+M[keys[i-1]]
    if M[keys[i-1]] < K <= M[keys[i]]:
        print(keys[i])
        exit()

Measured memory_bytes: 34124
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
??§???????°?????????????
"""
import sys

lower = "abcdefghijklmnopqrstuvwxyz"
upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
inp = sys.stdin.read() # EOF?????§????????????
inp = inp.translate(str.maketrans(upper,lower))

for i in lower:
    print("{0} : {1}".format(i,inp.count(i)))

Measured memory_bytes: 7348
#include <stdio.h>
int main(void){
	int n,i,a,b,A,B;
	for(;;){
		A=0;
		B=0;
		scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<n;i++){
			scanf("%d %d",&a,&b);
			if(a==b){
				A+=a;
				B+=b;
			}
			if(a>b){
				A+=a+b;
			}
			if(b>a){
				B+=a+b;
			}	
		}
		printf("%d %d\n",A,B);
	}
	return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
    vector<int> vec(N);
  int H;
  for (int i = 0; i < N; i++) {
    cin >> H;
    vec.at(i) = H;
  }
  sort(vec.begin(), vec.end(), greater<int>());
  long long Ans = 0;
  if (N <= K)
    cout << 0 << endl;
  else {
    for (int i = 0; i < K; i++)
      vec.at(i) = 0;
    for (int i = 0; i < N; i++)
      Ans += vec.at(i);
    cout << Ans << endl;
  }
}


Measured memory_bytes: 4032
#include <bits/stdc++.h>
#define mp make_pair
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 30) - 1LL;
const ll LINF = (1LL << 60) - 1LL;
const double eps = 1e-9;
const ll MOD = 10007LL;
template <typename T>
void chmin(T& a, T b) {
    a = min(a, b);
};
template <typename T>
void chmax(T& a, T b) {
    a = max(a, b);
};
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    int k;
    cin >> k;
    if(e - a > k) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    
    String S = stdIn.next();
  byte ans = 0;
    switch(S) {
     case "SUN": ans = 7; break;
     case "MON": ans = 6; break;
     case "TUE": ans = 5; break;
     case "WED": ans = 4; break;
     case "THU": ans = 3; break;
     case "FRI": ans = 2; break;
     case "SAT": ans = 1; break;
    }
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> p(n);
	rep (i, n) cin >> p[i];

	vector<int> sum(n + 1, 0);
	rep (i, n) sum[i + 1] = sum[i] + p[i];

	int id;
	int _max = -1;
	rep (i, n - k + 1) {
		if (chmax(_max, sum[i + k] - sum[i])) id = i;
	}

	double ans = 0;
	for (int i = id; i < id + k; i++) {
		ans += (double)((1 + p[i]) * p[i] / 2) / (double)p[i];
	}
	//cout << id << endl;
	printd(ans)
	return 0;
}

Measured memory_bytes: 2560
N = int(input())
flowers = list(map(int, input().split()))
flowers.append(0)
ans=0

while(flowers!=[0]*(N+1)):
  for i in range(N+1):
    if flowers[i] != 0:
      index = i
      break
  
  mmm=flowers[index]
  num = mmm
  for i in range(index, N+1):
    if flowers[i] >= num:
      num = flowers[i]
    else:
      mmm = num-flowers[i]
      stop = i
      break
      
  ans += mmm
  for i in range(index, stop):
    flowers[i] -= mmm
      
  
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
static const ll LOGN=55;


ll dp[20][MAX];

int main(void) {
  ll N;
  ll i, j;
  vector<ll> c;
  
  cin >> N;
  for(i=1; i<=N; i*=6) c.push_back(i);
  for(i=1; i<=N; i*=9) c.push_back(i);
  
  
  for(i=0; i<=c.size(); i++) {
    for(j=0; j<=N; j++) {
      dp[i][j]=INF;
    }
  }
  
  dp[0][0]=0;
  for(i=0; i<c.size(); i++) {
    for(j=0; j<=N; j++) {
      chmin(dp[i+1][j], dp[i][j]);
      if(j+c[i]<=N)
        chmin(dp[i][j+c[i]], dp[i][j]+1);
    }
  }
  
  pt(dp[c.size()][N]);
}






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

int main() {
  int n,k; cin>>n>>k;
  ll ans=0;
  rep(b, k+1, n+1) ans+=(n/b)*(b-k)+max(0, n%b-k+1);
  if (k==0) ans-=n;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var: ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        mut s: chars,
    }
    if s[0] != s[1] && s[1] != s[2] && s[2] != s[3] {
        println!("Good");
    } else {
        println!("Bad");
    }
}

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

int main() {
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    bool flag = true;
    for(int i=0; i<s.size(); i++){
        if(i<=a-1){
            if(s[i] - '0' < 0 || s[i] - '0' > 9){
                flag = false;
                break;
            }
        }else if(i==a){
            if(s[i] != '-'){
                flag = false;
                break;
            }
        }else{
            if(s[i] - '0' < 0 || s[i] - '0' > 9){
                flag = false;
                break;
            }
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a[234567],b=1;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==b)b++;
    }
    if(b==1)cout<<-1<<endl;
    else cout<<n+1-b<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;

const int N=2*1e5+7;
int n,mn=1e9+7,p,ans;

int main()
{
	cin>>n;
	REP(i,n)
	{
		cin>>p;
		if(p<mn)
		{
			ans++;
			mn=min(p,mn);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-8
#define M_PI 3.141592653589793
#define bs 1000000007

#define bsize 256

#define ldouble long double

using namespace std;

long long INF = 1e9;
const int N = 1700031;

int n,ar[N];
long long ans;

int main(){
	//freopen("cinema.in","r",stdin);
	//freopen("cinema.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin>>n;
	for (int i=0;i<n*3;i++)
	{
		cin>>ar[i];
	}
	sort(ar,ar+n*3);


	for (int i=0;i<n;i++)
	{
		ans+=ar[3*n-2*i-2];
		//cout<<ar[3*n-2*i]<<endl;
	}
	cout<<ans<<endl;

	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <math.h>

struct point{
	double x,y;
}p[3];

double area(){
	int i;
	double s,S;
	double len[3];

	s = 0;
	for(i = 0;i < 3;i++){
		len[i] = sqrt(pow(p[i].x-p[(i+1)%3].x,2)+pow(p[i].y-p[(i+1)%3].y,2));
		s += len[i];
	}
	s /= 2.0;

	S = s;
	for(i = 0;i < 3;i++){
		S *= (s-len[i]);
	}

	return sqrt(S);
}

int main(){
	double S;

	scanf("%lf,%lf",&p[0].x,&p[0].y);
	scanf("%lf,%lf",&p[1].x,&p[1].y);

	S = 0.0;

	while(scanf("%lf,%lf",&p[2].x,&p[2].y) != EOF){
		S += area();
		p[1] = p[2];
	}

	printf("%f\n",S);

	return 0;
}

Measured memory_bytes: 652
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007


int main(int argc, char const *argv[]) {
  ll n,b,ans=0;
  std::vector<ll> a;
  std::cin >> n;
  a.resize(n);

  for(int i=0; i<n; i++){
    ll m; std::cin >> m;
    a[i]=m-i-1;
  }
  sort(a.begin(),a.end());

  if(n%2==0){
    b=(a[n/2-1]+a[n/2])/2;
  }
  else b=a[n/2];

  for(int i=0; i<n; i++){
    ans+=abs(a[i]-b);
  }

  std::cout << ans << '\n';

  return 0;
}


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

using namespace std;
using ll =long long;
//nCm 
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nCmここまで

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	string s , t ;
	cin >> s >> t ;
	int a, b ;
	cin >> a>> b ;
	string u ;
	cin >> u ;
	
	if(u == s){
		a -- ;
	} 
	if(u == t){
		b-- ;
	}
	cout << a << " " << b<< endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>
#include <sstream>
typedef long long ll;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[510][510];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}
/*
ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}*/

int main() {
	cin >> n;
	ll res = 0;
	for (ll i = 1; i <= n; i++) {
		ll sum = i * (i + 1) / 2;
		if (i <= n && n <= sum) {
			res = i;
			break;
		}
	}
	for (ll i = res; i >= 1; i--) {
		if (n - i > 0) {
			n -= i;
			cout << i << endl;
		}
		else if (n - i == 0) {
			cout << i << endl;
			return 0;
		}
		else {
			cout << n << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long co[30] = { 0 };
long long ans = 1;
int main() {
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		co[int(s[i] - 'a')]++;
	}
	for (int i = 0; i < 26; i++) {
		ans = ans * (co[i] + 1) % 1000000007;
	}
	ans--;
	if (ans < 0) {
		ans += 1000000007;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3700
#include<iostream>
 
using namespace std;
 
 
int main()
{
	int n;
  cin>>n;
  for(int i=9;i>=1;i--)
  {
	if(n%i==0){
		string a=to_string(int(n/i));
		if(a.size()==1){
			cout<<"Yes"<<endl; return 0;
		}
    }
  }
   cout<<"No"<<endl; return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
using namespace std;

const int N = 5000;
int n;
int a[N];
vector<int> graph[N];

bool dfs(int v, int par = -1)
{
	for (int i = 0; i < graph[v].size(); i++)
	{
		int u = graph[v][i];
		if (u != par && a[u] < a[v])
		{
			if (!dfs(u, v))
			{
				return true;
			}
		}
	}
	return false;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		graph[u - 1].push_back(v - 1);
		graph[v - 1].push_back(u - 1);
	}
	for (int i = 0; i < n; i++)
	{
		dfs(i);
	}
	for (int i = 0; i < n; i++)
	{
		if (dfs(i))
		{
			cout << i + 1 << " ";
		}
	}

}





Measured memory_bytes: 512
#include <stdio.h>

int main(){

    int A, B, K;
    int i = 0;
    scanf("%d", &K);
    scanf("%d", &A);
    scanf("%d", &B);

    while(1){
        if(A<=K*i && B>=K*i){
            printf("OK");
            break;
        }else{
            if(B<K*i){
                printf("NG");
                break;
            }else{
                i++;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1696
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

type Node struct {
	parent, right, left int
}

type Deps []int

func main() {
	answer(os.Stdin)
}

func answer(reader io.Reader) {
	var v, d, c, l, r int

	sc := bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	A := make([]Node, n)
	for i := 0; i < n; i++ {
		A[i].parent, A[i].right, A[i].left = -1, -1, -1
	}

	for i := 0; i < n; i++ {
		sc.Scan()
		v, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		d, _ = strconv.Atoi(sc.Text())
		for j := 0; j < d; j++ {
			sc.Scan()
			c, _ = strconv.Atoi(sc.Text())
			if j == 0 {
				A[v].left = c
			} else {
				A[l].right = c
			}
			l = c
			A[c].parent = v
		}
	}
	for i := 0; i < n; i++ {
		if A[i].parent == -1 {
			r = i
		}
	}

	D := make(Deps, n)
	rec(A, D, r, 0)

	for i := 0; i < n; i++ {
		fmt.Println(String(A, D, i))
	}
}

func rec(T []Node, D Deps, u, p int) int {
	D[u] = p
	if T[u].right != -1 {
		rec(T, D, T[u].right, p)
	}
	if T[u].left != -1 {
		rec(T, D, T[u].left, p+1)
	}

	return 0
}

func String(T []Node, D Deps, u int) string {
	var out bytes.Buffer
	out.WriteString(fmt.Sprintf("node %d: ", u))
	out.WriteString(fmt.Sprintf("parent = %d, ", T[u].parent))
	out.WriteString(fmt.Sprintf("depth = %d, ", D[u]))

	if T[u].parent == -1 {
		out.WriteString("root, ")
	} else if T[u].left == -1 {
		out.WriteString("leaf, ")
	} else {
		out.WriteString("internal node, ")
	}

	out.WriteString("[")

	c := T[u].left
	for {
		if c == -1 {
			break
		}
		out.WriteString(fmt.Sprintf("%d, ", c))
		c = T[c].right
	}

	return strings.TrimRight(out.String(), ", ") + "]"
}



Measured memory_bytes: 32456
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	bool is_visited = false;
} node;
typedef struct {
	int to;
	int cost;
	P <int, int> change;
} edge;
int main( void ){
	int N; cin >> N;
	N--;
	vector <vector <int> > input( N, vector <int>( 3 ));
	rep( i, 0, N ){
		rep( j, 0, 3 ){
			cin >> input[ i ][ j ];
		}
	}
	rep( index, 0, N ){
		int sum = input[ index ][ 1 ] + input[ index ][ 0 ];
		rep( i, index + 1, N ){
			sum = max( sum, input[ i ][ 1 ] );
			sum += ( input[ i ][ 2 ] - ( sum % input[ i ][ 2 ] )) % input[ i ][ 2 ] + input[ i ][ 0 ];
		}
		cout << sum << endl;
		// break;
	}
	cout << "0\n";
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
  int K, X;
  scanf("%d %d", &K, &X);
  for (int i = max(-2000000, X - (K - 1)); i <= min(2000000, X + (K - 1));
       i++) {
    printf("%d ", i);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 128
#include <string>
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {

	int a[3],i;
	int count1 = 0, count2 = 0;

	for (i = 0; i < 3; i++) {
		cin >> a[i];
		if (a[i] == 5)
			count1++;
		if (a[i] == 7)
			count2++;
	}

	if (count1 == 2 && count2 == 1)
		cout << "YES"<<endl;
	else cout << "NO" << endl;

	return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cctype>
using namespace std;

namespace zyt
{
	template<typename T>
	inline bool read(T &x)
	{
		char c;
		bool f = false;
		x = 0;
		do
			c = getchar();
		while (c != EOF && c != '-' && !isdigit(c));
		if (c == EOF)
			return false;
		if (c == '-')
			f = true, c = getchar();
		do
			x = x * 10 + c - '0', c = getchar();
		while (isdigit(c));
		if (f)
			x = -x;
		return true;
	}
	template<typename T>
	inline void write(T x)
	{
		static char buf[20];
		char *pos = buf;
		if (x < 0)
			putchar('-'), x = -x;
		do
			*pos++ = x % 10 + '0';
		while (x /= 10);
		while (pos > buf)
			putchar(*--pos);
	}
	typedef long long ll;
	typedef pair<int, int> pii;
	const int N = 610, P = 1e9 + 7;
	int n, num[N][N], f[N][N], g[N], k;
	pii arr[N];
	bool in(const int a, const int i, const int j)
	{
		return i <= a && a <= j;
	}
	int work()
	{
		read(n), read(k);
		n <<= 1;
		for (int i = 1; i <= k; i++)
		{
			int a, b;
			read(a), read(b);
			if (a > b)
				swap(a, b);
			for (int i = 1; i <= a; i++)
				for (int j = a; j <= n; j++)
					++num[i][j];
			for (int i = 1; i <= b; i++)
				for (int j = b; j <= n; j++)
					++num[i][j];
			arr[i] = pii(a, b);
		}
		for (int i = 1; i <= n; i++)
			for (int j = i; j <= n; j++)
				num[i][j] = (j - i + 1) - num[i][j];
		int ans = 0;
		g[0] = 1;
		for (int i = 2; i <= n; i += 2)
			g[i] = (ll)g[i - 2] * (i - 1) % P;
		for (int i = 1; i <= n; i++)
			for (int j = i; j <= n; j++)
			{
				bool flag = true;
				for (int a = 1; a <= k; a++)
					if (in(arr[a].first, i, j) ^ in(arr[a].second, i, j))
						flag = false;
				if (flag)
				{
					f[i][j] = g[num[i][j]];
					for (int a = i; a < j; a++)
						f[i][j] = (f[i][j] - (ll)f[i][a] * g[num[a + 1][j]] % P + P) % P;
					ans = (ans + (ll)f[i][j] * g[num[1][n] - num[i][j]]) % P;
				}
			}
		write(ans);
		return 0;
	}
}
int main()
{
	return zyt::work();
}

Measured memory_bytes: 3072
n = int(input())
s = input()

pre = ''
post = ''

lp = 0
rp = 0

for c in s:
    if c == '(':
        lp += 1
    elif c == ')':
        if lp != 0:
            lp -= 1
        else:
            pre += '('
post = ')'*lp
ans = pre + s + post
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
int Per[2000010];
int Pow(int a,int n){
    if(n==0)return 1;
    int res=1;
    if(n%2==1)res*=a;
    return ((res*Pow(a,n/2))%mod)*Pow(a,n/2)%mod;
}
int In(int a){
    return Pow(a,mod-2);
}
int Com(int a,int b){
    if(a<b)return 0;
    return (Per[a]*In(Per[b]))%mod*In(Per[a-b])%mod;
}
signed main(void){
    Per[0]=1;
    rep(i,2000009)Per[i+1]=(Per[i]*(i+1))%mod;
    
    int n,k;cin>>n>>k;
    rep(i,k){
        cout<<Com(k-1,i)*Com(n-k+1,i+1)%mod<<endl;
    }
    
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
using namespace std;
int main(){
ll n,min;
cin>>n>>min;

ll count=0;
for(ll i=0;i<n;i++){
    ll h;
    cin>>h;
    if(h>=min)count++;


}
cout<<count;








}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>
#include <stack>
#include <tuple>

using namespace std;
typedef long long ll;

ll ans = 0;
string s;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans = 1e8;
    for (int i = -100; i <= 100; i++)
    {
        int sum = 0;
        for (int j = 0; j < n; j++) sum += (a[j] - i)*(a[j] - i);
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
using namespace std;
//using namespace __gnu_pbds;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long 
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,arr,n) for(int i=arr;i<=n;i++)
#define repd(i,arr,n) for(int i=arr;i>=n;i--)
#define trav(arr,x) for(auto& arr:x)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(arr) arr.size()
#define pi 3.14159265358979323846
#define MAX 500003
#define vi vector<int>
#define pii pair<int,int>
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int,vi,greater<int> >
//#define endl "\n"
 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
//const int mod=998244353;
int power(int a,int b,int mod)
{
    int ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return ans;
}
int solve(int n)
{
    if(n==0) return 0;
    int cnt=0;
    while(n)
    {
        int val=__builtin_popcount(n);
        cnt++;
        n%=val;
    }

    return cnt;
}
int32_t main()
{
    fast;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        int n;
        string str;
        vi v;
        cin>>n>>str;

        int rem=0,cnt=0,less=0,more=0;

        rep(i,n)
        {
            if(str[i]=='1') cnt++;
        }

        repd(i,n-1,0)
        {
            //if(cnt==0) break;
            if(str[i]=='1')
            {
                if(cnt>1)
                less+=power(2,n-i-1,cnt-1);
                more+=power(2,n-i-1,cnt+1);
            }
            //cout<<rem<<endl;
            if(cnt>1) less%=(cnt-1);
            more%=(cnt+1);

        }
        //cout<<rem<<" "<<cnt<<endl;
        rep(i,n)
        {
            if(str[i]=='0')
            {
                int cnt1=cnt+1;
                int temp=more;
                temp%=cnt1;
                temp+=power(2,n-i-1,cnt1);

                temp%=cnt1;
                v.pb(temp);
            }
            else
            {
                int cnt1=cnt-1;
                if(cnt1==0)
                {
                    v.pb(-1);
                    continue;
                }
                int temp=less;
                //temp%=cnt1;

                temp-=(power(2,n-i-1,cnt1));
                temp+=cnt1;
                temp%=cnt1;

                v.pb(temp);
            }
            //cout<<v[i]<<" ";
        }

        rep(i,n)
        {
            if(v[i]==-1) cout<<0<<endl;
            else
            cout<<solve(v[i])+1<<endl;
        }
    }
}   


Measured memory_bytes: 5520
//
// Created by Tian Wang on 16/4/3.
//
#include <iostream>
using namespace std;

int main(){
    for(int i = 1; i <= 9; i++) {
        for(int j = 1; j <= 9; j++) {
            cout << i << 'x' << j << '=' << i*j << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int t[100000][3];

int vac(int i,int j,int n,vector <vector<int>>& dp){
    if(i==n) return 0;

    // vector <int> a(6,0);
    // a[0]=dp[i][0]+vac(i+1,1,n,dp);
    // a[1]=dp[i][0]+vac(i+1,2,n,dp);
    // a[2]=dp[i][1]+vac(i+1,0,n,dp);
    // a[3]=dp[i][1]+vac(i+1,2,n,dp);
    // a[4]=dp[i][2]+vac(i+1,0,n,dp);
    // a[5]=dp[i][2]+vac(i+1,1,n,dp);

    // return *max_element(a.begin(),a.end());

    if(t[i][j]!=-1) return t[i][j];


    return t[i][j]=max(dp[i][(j+1)%3]+vac(i+1,(j+1)%3,n,dp),dp[i][(j+2)%3]+vac(i+1,(j+2)%3,n,dp));
}

void solve(){
    int n; cin>>n;
    vector <vector <int>> v(n,vector <int>(3,0)); 
    int k;
    for(int i=0;i<n;i++)
        for(int j=0;j<3;j++){
            cin>>k;
            v[i][j]=k;
        }

    vector <int> arr(3,0);
    arr[0]=v[0][0]+vac(1,0,n,v);
    arr[1]=v[0][1]+vac(1,1,n,v);
    arr[2]=v[0][2]+vac(1,2,n,v);

    cout<<*max_element(arr.begin(),arr.end());
}

int main(){
    memset(t,-1,sizeof(t));
    fast;
    int m=1;
    // cin>>m;

    while(m--)
    {
    solve();
    }
}

Measured memory_bytes: 17692
import sys

input = sys.stdin.readline
inf = float("inf")

n,m = map(int,input().split())
edge = [[] for i in range(n+1)]

for i in range(m):
    a,b = map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)

def f(x):
    for e in edge[x]:
        if used[e]:
            continue
        else:
            return e
    return -1
used = [False]*(n+1)
used[1] = used[edge[1][0]] = True
path = [1,edge[1][0]]

while True:
    con = f(path[-1])
    if con == -1:
        break
    else:
        path.append(con)
        used[con] = True
path = path[::-1]
while True:
    con = f(path[-1])
    if con == -1:
        break
    else:
        path.append(con)
        used[con] = True
print(len(path))
for e in path:
    print(e,end = " ")

Measured memory_bytes: 23576
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;




int main()
{
  int n, t; //かっている数//最大100
  cin >> n >> t;


  vector< pair<long,long> > ct(n,make_pair(0,0));
  for (int i = 0; i < n; ++i) {
    cin >> ct[i].first >> ct[i].second;
  }

  long mincost=10000000;
  for (int i = 0; i < n; ++i){
    if (mincost > ct[i].first && t >= ct[i].second){
      mincost = ct[i].first;
    }
  }


  cout << (mincost<10000000? to_string(mincost) :"TLE");

  return 0;
}



























Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int t, n, k;
int x[100000];
int main() {
    scanf("%d", &t);
    for (int c=0; c<t; c++) {
        scanf("%d%d",&n,&k);
        for (int i=0; i<n; i++) scanf("%d",&x[i]);
        if (n <= k) {
            puts("0");
            continue;
        }
        vector<int> lines;
        for (int i=1; i<n; i++) lines.push_back(x[i]-x[i-1]);
        sort(lines.begin(), lines.end());
        int res = 0;
        for (int i=0; i<lines.size()-k+1; i++) res += lines[i];
        printf("%d\n",res);
    }
}

Measured memory_bytes: 2452
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  int h,w,n;
  cin >> h >> w >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  vivi s(h,vi(w,0));
  pii last = make_pair(0,-1);
  rep(i,n){
    while(a[i]>0){
      if(!(last.first%2)){
      	rep2(j,last.second+1,w){
          if(a[i]==0) break;
          s[last.first][j] = i+1;
          a[i]--;
          if(j==w-1) {
            last.first++;
            last.second = w;
          }
          else if(a[i]==0) {
            last.second = j;
            break;
          }
      	}  
   	  }
      else{
        for(int j = last.second-1;j>=0;j--){
          if(a[i]==0)break;
          s[last.first][j] = i+1;
          a[i]--;
          if(j==0){
            last.first++;
            last.second = -1;
          }
          else if(a[i]==0){
            last.second = j;
            break;
          } 
        }
      }
    }
  }
  rep(i,h)rep(j,w){
    cout << s[i][j] << " ";
    if(j==w-1) cout << endl;
  }
}




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

int main() {
	int n, a, b, x = -1, y = -1, z;
	cin >> n >> a >> b;
	vector<int> p(n);
	for (int i = 0; i < n; i++)
		cin >> p.at(i);

	sort(p.begin(), p.end());
	if (p.back() <= b) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 0; i < n; i++) {
		if (x == -1 && p.at(i) > a)
			x = i;
		if (y == -1 && p.at(i) > b) {
			y = i - x;
			break;
		}
	}
	z = n - x - y;
	cout << min(x, min(y, z)) << endl;
}

Measured memory_bytes: 256
package main
import (
	"fmt"
	"math"
)

type Point struct{
	x,y  float64
}

func (p *Point)Dist(other_p Point)(ret float64){
	return math.Sqrt( (math.Pow((p.x-other_p.x), 2))+(math.Pow((p.y-other_p.y), 2)))
}

func main(){
	var x1, y1, x2, y2 float64
	fmt.Scan(&x1, &y1, &x2, &y2)
	p1 := Point{x:x1, y:y1}
	p2 := Point{x:x2, y:y2}
	fmt.Println(p1.Dist(p2))
}


Measured memory_bytes: 1156