akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void) {
	int i, j, a[111111]={}, temp, ans, t, sum[111111]={};
	
	while(scanf("%d", &t)!=EOF){
		
		for(i=0;i<t;i++){
			scanf("%d", &a[i]);
		}
		ans=0;
		
		for(i=0;i<t;i++){
			for(j=t-1;j>i;j--){
				if(a[j]<a[j-1]){
					temp=a[j];
					a[j]=a[j-1];
					a[j-1]=temp;
				}
			}
		}
		
		for(i=0;i<t;i++){
			sum[i]=sum[i-1]+a[i];
		}
		
		for(i=0;i<t;i++)
		ans+=sum[i];
		
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1472
def solve(string):
    n, *a = map(int, string.split())
    m1, m2 = sorted(a, reverse=True)[:2]
    return "\n".join(map(str, [m2 if _a == m1 else m1 for _a in a]))


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 27456
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const int INF  = 1<<30;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"

void Main()
{
	int A,B,C;
	ll result=0;
	cin>>A>>B>>C;

	int maxi=max({A,B,C});
	int left=maxi*3-(A+B+C);
	result=left/2;
	if(left%2==1) result+=2;

	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}

static const ULLONG UL_HUGE_DIVIDER = 1000000007LLU;
static const LLONG LL_HUGE_DIVIDER = 1000000007LL;

//static void ABC111D_RobotArms();
static void AtCoderBeginnerContest999();

#if 1
int main()
{
	//ABC111D_RobotArms();
	AtCoderBeginnerContest999();
	fflush(stdout);
	return 0;
}
#endif

static void AtCoderBeginnerContest999()
{
	int N;
	scanf(" %d", &N);

	char strNum[4] = { 0 };
	int i = 0;
	while (N > 0) {
		strNum[i] = N % 10 + '0';
		if (strNum[i] == '1') strNum[i] = '9';
		else strNum[i] = '1';

		N /= 10;
		i++;
	}
	for (int j = i - 1; j >= 0; j--) {
		printf("%c", strNum[j]);
	}
	printf("\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
#include <functional>

struct Node {
	std::vector<int> edgesDest;
	std::vector<int> edgesCost[2];

	bool done = false;
	int cost = -1;

	bool operator < (const Node& n) {
		return cost < n.cost;
	}
};

int main() {
	int n, m;
	std::vector<Node> nodes;
	using Pair = std::pair<int, int>;

	while (std::cin >> n >> m) {
		if (n == 0 && m == 0)
			break;

		nodes.clear();
		nodes.resize(m);
		for (int i = 0; i < n; ++i) {
			int a, b, c, t;
			std::cin >> a >> b >> c >> t;

			nodes[a - 1].edgesDest.push_back(b - 1);
			nodes[a - 1].edgesCost[0].push_back(c);
			nodes[a - 1].edgesCost[1].push_back(t);

			nodes[b - 1].edgesDest.push_back(a - 1);
			nodes[b - 1].edgesCost[0].push_back(c);
			nodes[b - 1].edgesCost[1].push_back(t);
		}

		int k;
		std::cin >> k;
		for (int i = 0; i < k; ++i) {
			for (int j = 0; j < nodes.size(); ++j)
				nodes[j].done = false, nodes[j].cost = -1;

			int p, q, r;
			std::cin >> p >> q >> r;
			--p, --q;

			nodes[p].cost = 0;

			std::priority_queue<Pair, std::vector<Pair>, std::greater<Pair>> queue;
			queue.push(Pair(0, p));
			while (!queue.empty()) {
				const Pair& qtop = queue.top();
				Node& node = nodes[qtop.second];

				if (node.done) {
					queue.pop();
					continue;
				}
				if (qtop.second == q) {
					std::cout << node.cost << std::endl;
					break;
				}
				queue.pop();

				node.done = true;
				for (int j = 0; j < node.edgesDest.size(); ++j) {
					int dest = node.edgesDest[j];
					int cost = node.cost + node.edgesCost[r][j];

					if (nodes[dest].cost < 0 || cost < nodes[dest].cost) {
						nodes[dest].cost = cost;
						queue.push(Pair(cost, dest));
					}
				}
			}
		}
	}

	return 0;
}

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


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
	t=1;
    while(t--)
    {
		ll h,w;
		cin>>h>>w;
		ll even,odd;
		if(h==1 || w==1)
			cout<<"1";
			else
				
		{
			if(w%2==0)
		
		{
			even=w/2;
			odd=w/2;
		}
		else
		{
			odd=(w/2)+1;
			even=odd-1;
		}
		if(h%2==0)
		{
			cout<<(h/2)*(even + odd);
		}
		else
		{
			cout<<((h/2)*even)+((h/2)+1)*odd; 
		}
		}
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < int(B); ++I)

int main(){
    int N;
    cin >> N;
    vector<int> x(N),y(N);
    FOR(i,0,N)cin >> x[i] >> y[i];
    double ans = 0;
    int n = 2000;
    for(double sita=0;sita<=2*M_PI;sita+=2.0*M_PI/n){
        double tox = cos(sita);
        double toy = sin(sita);
        int nowx=0;
        int nowy=0;
        FOR(i,0,N){
            double dot = tox*x[i] + toy*y[i];
            if(dot >= 0.0){
                nowx += x[i];
                nowy += y[i];
            }
        }
        double anst = sqrt((double)nowx*nowx + (double)nowy*nowy);
        ans = max(ans,anst);
    }
    cout<<fixed<<setprecision(15)<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
 if(a<b){
     if(b<c){
              cout<<a<<" "<<b<<" "<<c<<endl;
             }
     if(b>c){
              if(a<c){
                       cout<<a<<" "<<c<<" "<<b<<endl;
                     }
               else{
                       cout<<c<<" "<<a<<" "<<b<<endl;
                    }
             }
      }
 if(a>b){
	 if(a<c)
	 {cout<<b<<" "<<a<<" " <<c<<endl;
	 }
	 if(a>c){
		 if(b<c){
			 cout<<b<<" "<<c<<" "<<a<<endl;}
		 else{
			 cout<<c<<" "<<b<<" "<<a<<endl;
		 }

	 }

}
}

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

int main(){

int a, b, c, wk;

cin >> a >> b >> c;

if(a > b){

wk = a;
a = b;
b = wk;

}

if(a > c){

wk = a;
a = c;
c = wk;

}

if(b > c){

wk = b;
b = c;
c = wk;

}

cout << a << ' ' << b << ' ' << c << endl;

return 0;

}


Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

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







    

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
  
  int cnt=0,key,i,left,right,mid,num1[100000],num2[100000],n,m;
  
  scanf("%d",&n);
  for(i=0;i<n;i++) 
    scanf("%d",&num1[i]);
  
  scanf("%d",&m);
  for(i=0;i<m;i++)
    scanf("%d",&num2[i]);
  
  for(i=0;i<m;i++) {
    right = n;
    left = 0;
    key = num2[i];
    
    while(left < right) {
      mid = (left + right)/2;
      
      if(num1[mid] == key){
	cnt++; 
	break;
      }
      else if(num1[mid] < key) { 
	left  = mid + 1;
      }
      
      else { 
	right = mid ;
      }
    }
  }
  printf("%d\n",cnt);
  
  return 0;
} 

Measured memory_bytes: 1192
#include<stdio.h>
#include<math.h>
main(){
	double a,b,C;
	double rC,c2jou,c;
	double s,l,h;
	double pi = 3.14159265;

	scanf("%lf %lf %lf",&a,&b,&C);

	rC = C * 2 * pi / 360.0;
	s = 0.5 * a * b * sin(rC);
	c2jou = a * a + b * b - 2 * a * b * cos(rC);
	c = sqrt(c2jou);
	l = a + b + c;
	h = 2 * s / a;

	printf("%f\n%f\n%f\n",s,l,h);
	return 0;
}

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

namespace ABC127A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, d;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            if (a < 13 && a >= 6)
                Console.WriteLine(b / 2);
            else if (a  <=6)
                Console.WriteLine("0");
            else
                Console.WriteLine(b);

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
int main(){
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if (a+b>c+d)
	{
		printf("Left\n");
	}else if (a+b==c+d)
	{
		printf("Balanced\n");
	}else if (a+b<c+d)
	{
		printf("Right\n");
	}
}

Measured memory_bytes: 128
n = gets.to_i
t, a = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
min_diff = 10 ** 9
min_diff_i = nil
h.each_with_index do |x, i|
  diff = ((t * 1000 - x * 6) - a * 1000).abs
  if diff < min_diff
    min_diff = diff
    min_diff_i = i
  end
end
puts (min_diff_i + 1)


Measured memory_bytes: 1916
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
static const int MAX = 100000 + 1;

int main(){
    int n;
    cin >> n;
    vector<int> b(n);
    for (int i = 0; i < n-1; i++)
    {
        cin >> b[i];
    }
    b[n-1] = MAX;
    vector<int> a(n);
    int ans = 0;
    a[0] = b[0];
    ans += a[0];

    for (int i = 1; i < n; i++)
    {
        a[i] = min(b[i], b[i - 1]);
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
T = input()

if len(T) > len(S) or len(S) == 0:
    print(0)

answer = float("inf")
for i in range(len(S) - len(T) + 1):

    sub = S[i: i + len(T)]

    unique = 0
    for s,o in zip(sub, T):
        if s != o:
            unique += 1
    
    answer = min(answer, unique)

print(answer)

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

using namespace std;

using ll = long long;

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

const double EPS = 1e-5;
const int MOD = 1e9+7;

int main(){
  int n;
  vector<double> v;
  int p;
  double new_elem;

  cin >> n;

  repn(i,n){
    scanf("%d", &p);
    v.emplace_back(p);
  }

  while(v.size() != 1){
    sort(v.begin(), v.end());
    new_elem = (*v.begin() + *(v.begin() + 1)) / 2.0;
    v.erase(v.begin());
    v.erase(v.begin());
    v.emplace_back(new_elem);
  }

  cout << *v.begin();

  return 0;


}


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

const int N = 2e5+7;
int ans[N];
bool done[N];

void put(int idx, int v) {
    assert(!done[v] && !ans[idx]);
    ans[idx] = v;
    done[v] = 1;
}

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

    int n;
    cin>>n;

    int x;
    cin>>x;

    if (x == 1 || x==2*n-1) {
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;

    if (x+2<2*n)    put(n-2, x+2);
    put(n-1, x-1);
    put(n, x);
    put(n+1, x+1);
    if (x > 2) put(n+2, x-2);

    int nxt = 1;
    for (int i=1; i<2*n; i++) {
        if (!ans[i]) {
            while (done[nxt])   nxt++;
            done[nxt] = 1;
            ans[i] = nxt;
        }
        cout<<ans[i]<<" ";
    }

}


Measured memory_bytes: 4576
def main():
    H, W = map(int, input().split())
    grid = ["." * (W + 2)]
    for _ in range(H):
        grid.append("." + input() + ".")
    grid.append("." * (W + 2))

    DX = (-1, 0, 1, 0, -1, -1, 1, 1)
    DY = (0, 1, 0, -1, -1, 1, -1, 1)
    DX = DX[:4]
    DY = DY[:4]
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            if grid[i][j] == ".":
                continue
            isOK = False
            for dx, dy in zip(DX, DY):
                if grid[i + dx][j + dy] == "#":
                    isOK = True
            if not isOK:
                return "No"

    return "Yes"


if __name__ == "__main__":
    print(main())

Measured memory_bytes: 9248
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
    int n,a,b;
    double max=0;
    double s,t,u,l;
    cin >> n;
    int x[100]={};
    int y[100]={};
    int xy[100]={};
    for(int i=0;i<n;i++){
        cin >> a;
        x[i]=a;
    }
    for(int i=0;i<n;i++){
        cin >> b;
        y[i]=b;
    }
    for(int i=0;i<n;i++){
        s+=fabs(x[i]-y[i]);
    }
    printf("%.5f\n",s);
    for(int i=0;i<n;i++){
        u+=(x[i]-y[i])*(x[i]-y[i]);
    }
    printf("%.5f\n",sqrt(u));
    for(int i=0;i<n;i++){
        t+=fabs(x[i]-y[i])*fabs(x[i]-y[i])*fabs(x[i]-y[i]);
    }
    printf("%.5f\n",cbrt(t));
    for(int i=0;i<n;i++){
        l=fabs(x[i]-y[i]);
        if(max<l){
            max=l;
        }l=0;
    }
    printf("%.5f\n",max);
}


Measured memory_bytes: 3400
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(N: int, S: "List[str]"):

    def seq_positive(ls):
        state = 0
        for l, st in ls:
            if state+l < 0:
                return False
            state += st
        return True

    # 部分括弧列の特徴量を計算する。
    # 経過中の最小値と、最終到達値
    left_seq = []
    right_seq = []
    total = 0
    for s in S:
        state = 0
        lower = 0
        for c in s:
            if c == "(":
                state += 1
            else:
                state -= 1
            lower = min(lower, state)
        if state > 0:
            left_seq.append((lower, state))
        else:
            right_seq.append((lower-state, -state))
        total += state

    left_seq.sort(reverse=True)
    right_seq.sort(reverse=True)
    # print(left_seq)
    # print(right_seq)

    if seq_positive(left_seq) and seq_positive(right_seq) and total == 0:
        yes()
    else:
        no()

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;

const int N = 200100;

int p[N];

int get_root(int v) {
    if (v == p[v]) {
        return v;
    }
    return p[v] = get_root(p[v]);
}

void un(int u, int v) {
    u = get_root(u);
    v = get_root(v);
    p[u] = v;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        p[i] = i;
    }
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        --a[i];
    }
    for (int i = 0; i < m; ++i) {
        int l, r;
        cin >> l >> r;
        --l;
        --r;
        un(l, r);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (get_root(i) == get_root(a[i])) {
            ++ans;
        }
    }
    cout << ans;
    return 0;
}

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

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

    while (op != '?') {
        int result = 0;
        switch (op) {
            case '+':
                result = a + b;
                break;
            case '-':
                result = a - b;
                break;
            case '*':
                result = a * b;
                break;
            case '/':
                result = a / b;
                break;
        }
        cout << result << endl;

        cin >> a >> op >> b;
    }

    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int n, sum=0;
    cin >> n;
    rep(i, n){
        int p1, p2;
        cin >> p1 >> p2;
        sum += p2 - p1 + 1;
    }
    cout << sum << endl;
}

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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

bool checkeven(vector<int> v){
    for (int i = 0; i < (int)v.size(); i++) {
        if (v[i] & 1) {
            return false;
        }
    }

    return true;
}

int main(int argc, char const* argv[])
{
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    int c=0;
    while(checkeven(A)){
        c++;
        for (int i = 0; i < n; i++) {
            A[i] /= 2;
        }
    }

    cout << c << endl;

    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 2e5 + 5;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
 
int fac[MAX_N], inv[MAX_N];
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b, bool usemod = true) {ll c = 1LL; while (b > 0) {if (b & 1LL) {if(!usemod)c*=a;else c = a * c%mod;}if (!usemod) a*=a;else a = a * a%mod; b >>= 1LL;}return c;}
void _nCr() {fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) {fac[i] = fac[i - 1LL] * i%mod;}for (int i = 0; i < MAX_N; i++) {inv[i] = POW(fac[i], mod - 2);}}
ll nCr(ll n, ll r) {return (fac[n] * inv[r] % mod)*inv[n - r] % mod;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}

bool solve() {
	int n,k; cin >>n >> k;
	_nCr();
	FOR (i,1,k+1) {
		if (i == 1) {
			cout << n-k+1 << endl;
			continue;
		}
		int ans = 0;
		//両端に置かない
		if (n-k-1 >= i - 2) {
			ans += nCr(k-1,i-1) * nCr(n-k-1,i-2) % mod;
			ans %= mod;
		}
			//片方置く
		if (n-k-1 >= i - 1) {
			ans += nCr(k-1,i-1) * nCr(n-k-1,i-1) % mod * 2 % mod;
			//両端
			ans %= mod;
		}
		if (n-k-1 >= i) {
			ans += nCr(k-1,i-1) * nCr(n-k-1,i) % mod;
		}
		ans %= mod;
		cout << ans << endl;
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

Measured memory_bytes: 3456
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

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

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<i64> as(X), bs(Y), cs(Z);
  F0R(i, X) { cin >> as[i]; }
  F0R(i, Y) { cin >> bs[i]; }
  F0R(i, Z) { cin >> cs[i]; }
  sort(rng(as));
  sort(rng(bs));
  sort(rng(cs));

  // 指定した値以上のB+Cは何通りあるか
  auto hbc = [&](i64 v)->int {
    int r = 0;
    auto cit = lower_bound(rng(cs), v - bs.back());
    RF0(i, Y) {
      while (cit != cs.end() && *cit < v - bs[i]) cit++;
      if (cit == cs.end()) break;
      r += cs.end() - cit;
    }
    return r;
  };

  // 指定した値以上のA+B+Cは何通りあるか
  auto habc = [&](i64 v)->int {
    int r = 0;
    RF0(i, X) {
      int a = hbc(v - as[i]);
      if (!a) break;
      r += a;
      if (r > 10000) break;
    }
    return r;
  };

  i64 thr = 0, rest;
  if ((i64)X * Y * Z >= 10000) {
    i64 l = 0, r = 3e10;
    bool found = false;
    while (r - l > 1) {
      auto mp = (l + r) / 2;
      auto h = habc(mp);
      if (h > 10000) {
        l = mp;
      }
      else if (h < K) {
        r = mp;
      }
      else {
        found = true;
        thr = mp;
        break;
      }
    }
    if (!found) {
      thr = r;
      rest = l;
    }
  }

  vector<i64> rs;
  RF0(a, X) {
    RF0(b, Y) {
      if (as[a] + bs[b] + cs.back() < thr) {
        break;
      }
      RF0(c, Z) {
        if (as[a] + bs[b] + cs[c] < thr) break;
        rs.push_back(as[a] + bs[b] + cs[c]);
      }
    }
  }
  while (rs.size() < K) rs.push_back(rest);
  sort(rrng(rs));
  F0R(i, K) {
    cout << rs[i] << newl;
  }
}
#endif


Measured memory_bytes: 3760
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        Point[] students = new Point[n];
        for (int i = 0; i < n; i++) {
            students[i] = new Point(sc.nextInt(), sc.nextInt());
        }

        Point[] checkPoints = new Point[m];
        for (int i = 0; i < m; i++) {
            checkPoints[i] = new Point(sc.nextInt(), sc.nextInt());
        }

        for (int i = 0; i < n; i++) {
            int minIndex = 0;
            int minManhattan = Integer.MAX_VALUE;
            for (int j = 0; j < m; j++) {
                int manhattan = Math.abs(students[i].x - checkPoints[j].x) + Math.abs(students[i].y - checkPoints[j].y);
                if (manhattan < minManhattan) {
                    minManhattan = manhattan;
                    minIndex = j;
                }
            }
            System.out.println(minIndex +1);
        }
    }

    static class Point {
        int x;
        int y;

        Point(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
}

Measured memory_bytes: 23764
/*      ex3_3
        Tarara  */
#include <stdio.h>

int main(void)
{
    int number; //整数
    int base;   //進数

    scanf("%d %d", &number, &base);

    int digits = 1; //出力する桁数
    while (number >= base)
    {
        number /= base;
        digits++;
    }
    printf("%d\n", digits);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int t[200005];
int main()
{
    int n,m;
    long long int sum=0;
    scanf("%d%d",&n,&m);
    t[0]=0;
    for(int i=1;i<=n;i++)
        {
            scanf("%d",&t[i]);
            if(t[i]==0)
                sum+=m;
            else if(t[i]<=t[i-1]+m)
            {
                sum+=(t[i]-t[i-1]);
            }
            else
                sum+=m;
        }
        printf("%lld\n",sum);
}


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

int main() {
    ios::sync_with_stdio(false);

    int a, b; cin >> a >> b;
    for(int x = 0; x < 1e6; x++) {
        double y = (double)x;
        if(int(y * 0.08) == a and int(y * 0.1) == b) {
            cout << x << '\n';
            exit(0);
        }
    }
    cout << "-1\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pii pair<int,int>
typedef long long int ll;
const int N=1e5+7;
int cnt[2][N];
pii mx[2][2];
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int n; cin>>n;

	for(int i=1; i<=n; i++) {
		int a; cin>>a;
		cnt[(i%2)][a]++;
	}


	for(int i=1; i<N-5; i++) {
		if(mx[0][0].first<=cnt[0][i]) {
			mx[0][1]=mx[0][0];
			mx[0][0].first=cnt[0][i];
			mx[0][0].second=i;
		}
		else if(mx[0][1].first<=cnt[0][i]) {
			mx[0][1].first=cnt[0][i];
			mx[0][1].second=i;
		}
	}
	for(int i=1; i<N-5; i++) {
		if(mx[1][0].first<=cnt[1][i]) {
			mx[1][1]=mx[1][0];
			mx[1][0].first=cnt[1][i];
			mx[1][0].second=i;
		}
		else if(mx[1][1].first<=cnt[1][i]) {
			mx[1][1].first=cnt[1][i];
			mx[1][1].second=i;
		}
	}
	if(mx[1][0].second!=mx[0][0].second) {
		cout<<n-mx[1][0].first-mx[0][0].first<<endl;
	}
	else{
		cout<<n-max(mx[1][1].first+mx[0][0].first,mx[1][0].first+mx[0][1].first)<<endl;;
	}

	return 0;
}


Measured memory_bytes: 4444
#include <iostream>

using namespace std;

int main()
{
	int w, h, n;
	int lw = 0, lh = 0;
	int x[100], y[100], a[100];
	
	cin >> w >> h >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> a[i];
	}
	
	for (int i = 0; i < n; i++) {
		if (a[i] == 1) {
			if (lw < x[i]) lw = x[i];
		}
		else if (a[i] == 2) {
			if (w > x[i]) w = x[i];
		}
		else if (a[i] == 3) {
			if (lh < y[i]) lh = y[i];
		}
		else if (a[i] == 4) {
			if (h > y[i]) h = y[i];
		}
	}
	
	cout << (w <= lw || h <= lh ? 0 : (w - lw) * (h - lh)) << endl;
	
	return (0);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int t = 1;
vvi to;
vi d, f;
vector<bool> visited;

void dfs(int i) {
    i--;
    if (visited[i]) return;
    visited[i] = true;

    d[i] = t;
    t++;
    sort(ALL(to[i]));

    for (int nv : to[i]) {
        //debug(nv)
        
        dfs(nv);
    }
    
    f[i] = t;
    t++;
}
 
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    to = vvi(N, vi());
    REP(i, N) {
        int k, idx;
        cin >> idx >> k;
        idx--;
        to[i].resize(k);
        REP(j, k) cin >> to[idx][j];
    }
    // debug(N)

    d.resize(N);
    f.resize(N);
    visited = vector<bool>(N, false);

    
    REP(i, N){
        if (f[i] == 0) dfs(i+1);
    } 

    REP(i, N) {
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3144
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int n;
int cache[1000][100000];
int recur(int x,int a[],int b[],int c[],int idx)
{
    if(idx >= n)
    {
        return 0;
    }
    if(cache[x][idx] != -1)
    {
        return cache[x][idx];
    }
    if(x == 1)
    {
        return cache[x][idx] = a[idx] + max(recur(2,a,b,c,idx+1),recur(3,a,b,c,idx+1));
    }
    if(x == 2)
    {
        return cache[x][idx] = b[idx] + max(recur(1,a,b,c,idx+1),recur(3,a,b,c,idx+1));
    }
    if(x == 3)
    {
        return cache[x][idx] = c[idx] + max(recur(2,a,b,c,idx+1),recur(1,a,b,c,idx+1));
    }
}
int main() 
{
    cin >> n;
    memset(cache,-1,sizeof(cache));
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    cout<<max(recur(1,a,b,c,0),max(recur(2,a,b,c,0),recur(3,a,b,c,0)))<<endl;
	return 0;
}


Measured memory_bytes: 399872
#include <iostream>
#include <vector>
#include <map>
#include <string>

using namespace std;

int calc_gcd(int a, int b)
{
  if (b == 0)
    return a;
  return calc_gcd(b, a%b);
}

int main()
{
  long long n;
  cin >> n;
  
  long long p[n];  
  for (int i=0;i<n;++i) {
    cin >> p[i];
  }
  
  long long ans = 0;
  for (int i=0;i<n-2;++i) {
    if (p[i] < p[i+1] && p[i+1] < p[i+2])
      ans++;
    else if (p[i+2] < p[i+1] && p[i+1] < p[i])
      ans++;
  }  
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll INF = 1e17;
const ll MOD = 1e9+7;

// https://math.nakaken88.com/textbook/cp-binary-exponentiation-and-recursive-function/
ll modPow(long long a, long long n) {
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  long long t = modPow(a, n / 2);
  return (t * t) % MOD;
}

ll comb(ll n, ll p) {
	if (p * 2 > n) p = n - p;
	if (p > n - p) p = n - p;
	ll a = 1, b = 1;
	for(int i=1; i< p+1; i++) {
		a = (a * (n - i + 1)) % MOD;
		b = (b * i) % MOD;
	}
	return a * (modPow(b, MOD - 2)) % MOD;
}

int main() {
    // input, ready
    vector<int> cw(10);
    vector<vector<int>> cv;
    int H,W;
    cin >> H >> W;
    for (int i=0; i<10; i++) {
      for (int j=0; j<10; j++) {
        cin >> cw[j];
      }
      cv.push_back(cw);
    }
    vector<int> aw(W);
    vector<vector<int>> ah;
    for (int i=0; i<H; i++) {
      for (int j=0; j<W; j++) {
        cin >> aw[j];
      }
      ah.push_back(aw);
    }

    // resolve
    int dp[10][10];
    memset(dp, 0, sizeof(dp));
    for (int i=0; i<10; i++) {
      dp[0][i] = cv[i][1];
    }
    for (int i=1; i<10; i++) {
      for (int j=0; j<10; j++) {
        if (j==1) continue;
        if (dp[i][j] == 0) dp[i][j] = dp[i-1][j];
        for (int k=0; k<10; k++) dp[i][j] = min(dp[i][j], dp[i-1][k]+cv[j][k]);
      }
    }

    // output
    ll ans=0;
    for (int i=0; i<H; i++) {
      for (int j=0; j<W; j++) {
        if (ah[i][j] == 1 || ah[i][j] == -1) continue;
        ans += dp[9][ah[i][j]];
      }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>

using namespace std;

char *c;
int n;

int main() {
	string s;
	string a = "END OF INPUT";

	while (1) {
		getline(cin, s);
		if (s == a) {
			//cout << endl;
			break;
		}
		n = s.length();
		int series = 0;
		for (int i = 0; i < n; i++) {
			if (s[i] == ' ') {
				if (i > 0) {
					if (s[i - 1] == ' ') {
						cout << "0";
						continue;
					}

				}
				cout << series;
				series = 0;
				continue;
			}
			series++;
			if (i == n - 1)
				cout << series;
		}
		cout << endl;
	}


	return 0;
}

Measured memory_bytes: 2980
#include <iostream>

using namespace std;

int main() {
    int n;
    long a, rem;
    int count = 0;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        while (true) {
            if (a % 2 != 0) break;
            ++count;
            a = a / 2;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    map<int,char> mp;
    char j='a';
    for(int i=1;i<=26;i++)
    {
        mp[i]=j;
        j++;
    }
    ll n;
    while(cin>>n)
    {
        int cnt=0;
        ll req=1LL;
        while((n-(req*26LL))>=0)
        {
            req=req*26LL;
            n-=req;
            cnt++;
        }
        if(n==0)
        {
            for(int i=0;i<cnt;i++)
            {
                cout<<'z';
            }
            cout<<endl;
        }
        else
        {
            vector<int> res;
            n--;
            while(n>0)
            {
                res.push_back(n%26);
                n=n/26;
            }
            cnt++;
            int baki=cnt-res.size();
            for(int i=0;i<baki;i++)
            {
                res.push_back(0);
            }
            while(res.size())
            {
                cout<<mp[res.back()+1];
                res.pop_back();
            }
            cout<<endl;

        }
    }
    return 0;
}


Measured memory_bytes: 3664
// Tの型推論もしてくれているんやろ　適当わら
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let r:u32 = read(); //Tの型はu32ということね　納得
    println!("{}", r * r);
}

Measured memory_bytes: 4352
#include <stdio.h>
int main(){
  int w,h,num;
  int x,y,judge;
  int x_remain=0,y_remain=0;
  scanf("%d %d %d\n",&w,&h,&num);
  for(int i=0;i<num;i++){
    scanf("%d %d %d\n",&x,&y,&judge);
    
    switch(judge){
      case 1:if(x_remain < x)
               x_remain=x;
             break;
               
      case 2:if(w > x)
               w=x;
             break;
      case 3:if(y_remain < y)
               y_remain=y;
             break;
      case 4:if(h > y)
               h=y;
             break;
    }
  }
  if(w-x_remain > 0 && h-y_remain > 0)
  	printf("%d",(w-x_remain)*(h-y_remain));
  else
    printf("0");
}

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

using namespace std;

#define ops cout<<"ops"<<endl;
#define freopens freopen("cowpatibility.in", "r", stdin);freopen("cowpatibility.out", "w", stdout);
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define DIM 1007
#define DIMM 100007
#define INF 1000000000007.0
#define X 31
#define eps 0.0000001
#define PI 3.14159265358979323846
#define MAX 25
#define MODULO (long long)1000000007

const long double gr=(1+sqrt(5))/2;

typedef int I;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<I,I> pII;
typedef pair<ll,ll> pllll;
typedef pair<ld,ld> pldld;

typedef vector<I> vI;
typedef vector<ll> vll;
typedef vector<pllll> vpllll;

typedef char cr;
typedef string str;

ll n,m;
ll a[DIM][DIM],dp[DIM][DIM];
str s;

int main()
{
    //ops;
    //freopens;
    fast;
    //ll x1,y1,xs,ys,x2,y2,x3,x4,y3,y4;

    cin>>n>>m;
    for(int i=1;i<=n;i++){
     cin>>s;
     for(int j=1;j<=m;j++)
      if(s[j-1]=='#')
       a[i][j]=1;
    }
    dp[1][1]=1;
    for(int j=2;j<=m;j++){
     if(a[1][j]==1)break;
     dp[1][j]=dp[1][j-1];
    }
    for(int i=2;i<=n;i++){
     if(a[i][1]==1)break;
     dp[i][1]=dp[i-1][1];
    }
    for(int i=2;i<=n;i++){
     for(int j=2;j<=m;j++){
      if(a[i][j]==0){
       dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MODULO;
      }
     }
    }
    cout<<dp[n][m]<<endl;
    return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;




int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	ll n;
	cin>>n;
	vector<ld> A(n);
	for(int i=0;i<n;i++)
		cin>>A[i];
	sort(all(A));
	ld prev=A[0];
	for(int i=1;i<n;i++)
		prev=(prev+A[i])/2;
	cout<<prev;
		

}


Measured memory_bytes: 3848
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  if (n%2 == 0) printf("%d\n", n);
  else printf("%d\n", 2*n);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#define INF 1000000009
#define LINF 1000000000000000009
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmax(T &a, const T&b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T&b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	vector<int> t(n);
	for (int i = 0; i < n; i++) cin >> s[i] >> t[i];
	string x;
	cin >> x;
	int ans = 0;
	int p = -1;
	for (int i = 0; i < n; i++) {
		if (s[i] == x) p = i;
	}
	for (int i = p + 1; i < n; i++) ans += t[i];
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long num[200200];
int main(){
    int n , k;
    long long ans = 0;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> num[i];
    }
    sort(num, num+n);
    for(int i = 0; i < n-k; i++){
        ans += num[i];
    }
    cout << ans << '\n';
    return 0;
}

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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="776755555555555555555555555555555555555554555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 2
#define pi 3.1415926535
using namespace std;
struct __INIT{
    __INIT(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout<<fixed<<setprecision(15);
    }
}__init;


int main(void){
    ll x;
    cin>>x;
    for(ll a = 1;a<=1000;a++){
        for(ll b=-1000;b<=1000;b++){
            if(a*a*a*a*a-b*b*b*b*b==x){
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

template< int mod >
struct Combination {
  vector< int64_t > mfact, rfact;

  Combination(int sz) : mfact(sz + 1), rfact(sz + 1) {
    mfact[0] = 1;
    for(int i = 1; i < mfact.size(); i++) {
      mfact[i] = mfact[i - 1] * i % mod;
    }
    rfact[sz] = inv(mfact[sz]);
    for(int i = sz - 1; i >= 0; i--) {
      rfact[i] = rfact[i + 1] * (i + 1) % mod;
    }
  }

  int64_t fact(int k) const {
    return (mfact[k]);
  }

  int64_t pow(int64_t x, int64_t n) const {
    int64_t ret = 1;
    while(n > 0) {
      if(n & 1) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return (ret);
  }

  int64_t inv(int64_t x) const {
    return (pow(x, mod - 2));
  }

  int64_t P(int n, int r) const {
    if(r < 0 || n < r) return (0);
    return (mfact[n] * rfact[n - r] % mod);
  }

  int64_t C(int p, int q) const {
    if(q < 0 || p < q) return (0);
    return (mfact[p] * rfact[q] % mod * rfact[p - q] % mod);
  }

  int64_t H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return (r == 0 ? 1 : C(n + r - 1, r));
  }
};

int N, K;
int64 dp[2002][2002];
Combination< mod > tap(2002 * 2002);

int64 rec(int top, int bottom) {
  if(top == 0 && bottom == 0) return 1;
  if(~dp[top][bottom]) return dp[top][bottom];
  int ret = 0;
  if(top > 0) {
    (ret += rec(top - 1, bottom)) %= mod;
  }
  if(bottom > top) {
    int64 mul = bottom;
    (mul *= rec(top, bottom - 1)) %= mod;
    (mul *= tap.C(top + (K - 1) * bottom - 1, K - 2)) %= mod;
    (ret += mul) %= mod;
  }
  return dp[top][bottom] = ret;
}

int main() {
  cin >> N >> K;
  memset(dp, -1, sizeof(dp));
  if(K == 1) cout << 1 << endl;
  else cout << rec(N, N) << endl;
}

Measured memory_bytes: 94336
// in the name of Allah

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

ll mod;

ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

/*

// a bit of NT

const int _N = 1234567;

ll F[_N];
ll IF[_N];

void init() {
	F[0] = 1;
	for(int i=1; i<_N; i++) F[i] = mul(F[i-1], i);
	IF[_N-1] = power(F[_N-1], mod-2);
	for(int i=_N-2; i>=0; i--) IF[i] = mul(IF[i+1], i+1);
}

ll ncr(ll x, ll y) {
	if(y > x || y < 0) return 0;
	return mul(F[x], mul(IF[x-y], IF[y]));
}

/**/

ll euler(ll m) {
	ll res = 1;
	for(ll i = 2; i*i <= m; i++) {
		if(m%i == 0) {
			m /= i;
			res *= (i - 1);
			while(m % i == 0) {
				m /= i;
				res *= i;
			}
		}
	}
	if(m > 1) res *= (m-1);
	return res;
}

#define max_n 100001

int n;
ll phi;
ll dp1[max_n];
vector <int> g[max_n];

void dfs(int u, int p) {
	ll res = 1;
	for(int v : g[u]) {
		if(v == p) continue;
		dfs(v, u);
		res = mul(res, add(dp1[v], 1));
	}
	dp1[u] = res;
}

ll dp[max_n];

void DFS(int u, int p, ll up) {
	dp[u] = mul(dp1[u], add(1, up));
	vector <ll> all;
	all.pb(1);
	for(int v : g[u]) {
		if(v == p) continue;
		all.pb(add(1, dp1[v]));
	}
	all.pb(1);
	vector <ll> pre(sz(all), 1);
	for(int i=1; i<sz(all); i++) {
		pre[i] = mul(pre[i-1], all[i]);
	}
	vector <ll> suf(sz(all), 1);
	for(int i = sz(all)-2; i>=0; i--) {
		suf[i] = mul(suf[i+1], all[i]);
	}
	int i = 0;
	for(int v : g[u]) {
		if(v == p) continue;
		i++;
		ll L = pre[i-1];
		ll R = suf[i+1];
		DFS(v, u, mul(mul(L, R), add(1, up)));
	}
}

int main() {
	// ll start = clock();
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll md;
	cin >> n >> md; mod = md * 2;
	for(int i=1; i<n; i++) {
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}

	dfs(1, 0);
	phi = euler(mod);
	DFS(1, 0, 0);

	for(int i=1; i<=n; i++) cout << dp[i]%md << endl;

	// cerr << (clock() - start) / (CLOCKS_PER_SEC*1.0) << endl;
	return 0;
}

Measured memory_bytes: 25472
N, M = [int(_) for _ in input().split()]
X = [[int(_) for _ in input().split()] for _ in range(N)]

X.sort()
ans = 0
k = M
for a, b in X:
     x = min(k, b)
     ans += a * x
     k -= x
     if k == 0:
         break
print(ans)


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

int main() {
  int N,M;
  std::cin >> N >> M;
  vector<int> L(M), R(M);
  for (int i = 0; i < M; i++) std::cin >> L[i] >> R[i];
  int max = *std::max_element(L.begin(), L.end());
  int min = *std::min_element(R.begin(), R.end());
  if (min < max) {
      std::cout << 0 << std::endl;
      return 0;
  }
  std::cout <<  min - max + 1 <<std::endl;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (true) {
			int n = in.nextInt();
			if (n == 0) break;//??????
			int[] a = new int[n];
			int[] b = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
				b[i] = in.nextInt();
			}
			int scoreA = 0, scoreB = 0;
			for (int i = 0; i < a.length; i++) {
				int score = a[i] + b[i];
				if (a[i] == b[i]) {
					scoreA += score / 2;//?????????????????????1??????????????????
					scoreB += score / 2;
				} else {
					if (a[i] > b[i]) {
						scoreA += score;//A????????????
					} else {
						scoreB += score;//B????????????
					}
				}
			}
			System.out.println(scoreA + " " + scoreB);//??????
		}
		in.close();
	}
}

Measured memory_bytes: 56944
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    cout<<x*x;
    return 0;
}

Measured memory_bytes: 256