akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define llint long long

using namespace std;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	if(n%2) cout << n/2 << endl;
	else cout << n/2-1 << endl;
	
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  int cnt = 0;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    if(A.at(i) % 2 == 0){
      if(A.at(i) % 3 == 0 || A.at(i) % 5 == 0){
        cnt++;
      }
    }
    else{
      cnt++;
    }
  }
  
  if(cnt == N){
    cout << "APPROVED" << endl;
  }
  else{
    cout << "DENIED" << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var hw = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var h = hw[0];
            var w = hw[1];
            var grid = new string[h];
            for (var i = 0; i < grid.Length; i++)
            {
                grid[i] = Console.ReadLine();
            }

            var answer = true;
            for (var y = 0; y < h - 1; y++)
            {
                for (var x = 0; x < w - 1; x++)
                {
                    if (grid[y][x] == '#')
                    {
                        var left = false;
                        var right = false;
                        var top = false;
                        var bottom = false;
                        if (x - 1 >= 0 && grid[y][x - 1] == '#') left = true;
                        if (x + 1 < w && grid[y][x + 1] == '#') right = true;
                        if (y - 1 >= 0 && grid[y - 1][x] == '#') top = true;
                        if (y + 1 < h && grid[y + 1][x] == '#') bottom = true;

                        if (!(left || right || top || bottom))
                        {
                            answer = false;
                            break;
                        }
                    }
                }
            }

            Console.WriteLine(answer ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF (1e10+5)
#define F first
#define S second
#define pb push_back
#define MP make_pair
#define FRL(i,a,n) for(i=a;i<n;i++)
#define FR(i,n) FRL(i,0,n)
#define RFRL(i,n) for(i=n;i>=0;i--)
#define MOD 1000000007
#define fill(a) memset(dp,a,sizeof(dp));

using namespace std;

typedef long long int  ll;

typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector< pair<ll,ll> > vpi;
typedef set<ll> st;
typedef map<ll,ll> mp;
typedef unordered_map<ll,ll> ump;

template< class T>
T minn(T a,T b)
{
	return (a>b)?b:a;
}
template< class T>
T maxx(T a,T b)
{
	return (a>b)?a:b;
}


void FILE_OP()
{
	#ifndef ONLINE_JUDGE
        freopen("inputf.txt", "r", stdin);
        freopen("output2.txt", "w", stdout);
    #endif
}
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll n;
vi v(100005);
ll dp[100005];
/*ll frog(ll i,ll c)
{
	if(i>n)
		return 0;
	
	c=c+minn(frog(i+1,abs(v[i-1]-v[i])),frog(i+2,abs(v[i-2]-v[i])));
	return c;

}*/




void SOLVE()
{

	
	ll tt,m,i,j,k,a,b,c,d,l,r;
	//cin>>tt;
	tt=1;
	fill(0)
	while(tt--)
	{
		cin>>n>>k;
		
		FR(i,n)
			cin>>v[i];
		dp[0]=0;dp[1]=abs(v[1]-v[0]);
		for(i=2;i<n;i++)
		{
			ll mn=INF;
			for(j=1;j<=k;j++)
			{
				if(i-j<0) continue;
				mn=minn(dp[i-j]+abs(v[i]-v[i-j]),mn);
			}
			dp[i]+=mn;
		}
		cout<<dp[n-1];
		
	}


		
}

int main()
{
	FAST_IO
	//FILE_OP();
	SOLVE();
	
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int cmp(const void *x, const void *y) {
  return *(int *)x - *(int *)y;
}

int main() {
  int n, k, ans = 1;
  scanf("%d%d", &n ,&k);
  int a[n], sum = 0;
  for (size_t i = 0; i < n; i++) {
    scanf("%d", a+i);
    sum += a[i];
  }
  for (size_t i = 1; i < (int)sqrt((double)sum)+1; i++) {
    if (sum%i == 0) {
      int d1 = i, d2 = sum/i;
      int r1[n], r2[n], r1sum = 0, r2sum = 0, cnt = 0;
      for (size_t j = 0; j < n; j++) {
        r1[j] = a[j] % d1;
        r2[j] = a[j] % d2;
        r1sum += r1[j];
        r2sum += r2[j];
      }
      qsort(r1, n, sizeof(int), cmp);
      qsort(r2, n, sizeof(int), cmp);
      for (size_t j = n-r1sum/d1; j < n; j++) {
        cnt += d1-r1[j];
      }
      ans = (cnt <= k) ? d1 : ans;
      cnt = 0;
      for (size_t j = n-r2sum/d2; j < n; j++) {
        cnt += d2-r2[j];
      }
      if (cnt <= k) {
        ans = d2;
        break;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

int main(){
    int N;
    string S;
    cin >> N >> S;
    if(S.length()%2==0){
        int mid = S.length()/2;
        string Sfo = S.substr(0,mid);
        string Sba = S.substr(mid);
        if(Sfo == Sba) cout << "Yes";
        else cout << "No";
    }
    else cout << "No";
    
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
 
public class Main {
	public static void main(String[] args) {
		char[] chars = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
		try (Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			List<String> list = Arrays.asList("a");
			for (int i = 0; i < a - 1; i++) {
				list = list.stream().map(str -> {
					List<String> newStrs = new ArrayList<>();
					for (int j = 0; j<=calcCodePoints(str); j++) {
						newStrs.add(str + chars[j]);
					}
					return newStrs;
				}).flatMap(l -> l.stream()).collect(Collectors.toList());
			}
			list.stream().sorted().forEach(s -> System.out.println(s));
		}
	}
	
	public static int calcCodePoints(String s) {
		return s.chars().mapToObj(c -> (char) c).collect(Collectors.toSet()).size();
	}
}

Measured memory_bytes: 83912
#include<bits/stdc++.h>
using namespace std;
int ans[2000][2000];
int main()
{
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    for(int i=0;i<b;i++) for(int j=0;j<a;j++) ans[i][j]=1;
    for(int i=b;i<h;i++) for(int j=a;j<w;j++) ans[i][j]=1;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++) cout<<ans[i][j];
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 9344
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[8] = { 0,0,1,-1, 1,1,-1,-1 };// 前４つで４近傍
const int c_Dy[8] = { 1,-1,0,0 ,1,-1,1,-1};// 全部で８近傍
const int c_div = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846;


int main() {


	int N, K, X[1000];
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++) {
		scanf("%d", &X[i]);
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans +=2* min(X[i], abs(X[i] - K));
	}

	printf("%d", ans);



}







Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#define rep(i,a) for( int i = 0; i != (a); ++i )
#define repd(i,a) for( int i = (a); i >= 0; --i )
#define repi(i,a,b) for( int i = (a); i != (b); ++i )
using namespace std;
typedef unsigned long long ull;

int n, m;
std::string s, t;
int dp[4001][4001];

void solve(){
	memset(dp, 0, sizeof(dp));
	int ans = 0;
	for (int i = 0; i < n; ++i){
		for (int j = 0; j < m; ++j){
			if (s[i] == t[j]){
				dp[i + 1][j + 1] = dp[i][j] + 1;
				ans = max(dp[i + 1][j + 1], ans);
			}
			else{
				dp[i + 1][j + 1] = 0;
			}
		}
	}
	std::cout << ans << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (std::cin >> s >> t){
		n = s.size(), m = t.size();
		solve();
		
	}
	//std::cout << '\n';
	//system("pause");
	return 0;

}

//1000000000000000000

Measured memory_bytes: 63748
#include<stdio.h>
int main (void)
{
	int a, b, c, empty;
	scanf("%d %d %d",&a,&b,&c);
	if (b<a){
		empty=a;
		a=b;
		b=empty;
	}
	if (c<a){
		empty=a;
		a=c;
		c=empty;
	}
	if (c<b){
		empty=b;
		b=c;
		c=empty;
	}
printf("%d %d %d\n",a,b,c);
return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N,M,X;
    cin >> N >> M >> X;
    int A[M];
    for(int i=0;i<M;i++) cin >> A[i];

    int to0=0,toN=0;
    for(int i=0;i<M;i++){
        if(A[i] < X) to0++;
        if(A[i] > X) toN++;
    }

    cout << min(to0,toN) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,S;
    cin >> N;
    S = 0;
    for (int i = 0; i < N; i++){
        int l,r;
        cin >> l >> r;
        S += r - l + 1;
    }
    cout << S << endl;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int ans = 0;
    rep(i, N){
        int l, r; cin >> l >> r;
        ans += r-l+1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
# int(input()) # 入力が1つ
sx, sy, tx, ty = map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字

ans = ''
ans += 'U' * (ty - sy) + 'R' * (tx - sx)
ans += 'D' * (ty - sy) + 'L' * (tx - sx)
ans += 'L' + 'U' * (ty - sy + 1) + 'R' * (tx - sx + 1) + 'D'
ans += 'R' + 'D' * (ty - sy + 1) + 'L' * (tx - sx + 1) + 'U'

print(ans)

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

int main()
{
    int N, K;
    cin >> N >> K;
    int sum = 1;

    for(int i=0; i<N; i++){
        if(sum < K)
            sum *= 2;
        else if(sum >= K)
            sum += K;
    }    
    
    cout << sum << endl;
}


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

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

    int n; 
    cin>>n;
    int a = 0; 
    int b = 0;
    for (int i=-150; i<=150; i++){
        int flag = 0;
        for (int j=-150; j<=150; j++){
            if (n == (1LL*i*i*i*i*i-1LL*j*j*j*j*j)){
                a = i; b = j;
                flag = 1;
                break;
            }
        }
        if (flag) break;
    }
    if (a>0 and b>0){
        cout<<max(a, b)<<" "<<min(a, b);
    }
    else if (a>0 and b<=0){
        cout<<a<<" "<<b;
    }
    else if (a<=0 and b>0){
        cout<<b<<" "<<a;
    }
    else if (a<=0 and b<=0){
       cout<<max(a, b)<<" "<<min(a, b);
    }

    return 0;
}



Measured memory_bytes: 3652
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int t = 0, x = 0, y = 0;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int tt, xx, yy;
    cin >> tt >> xx >> yy;
    int d = tt - t - abs(xx - x) - abs(yy - y);
    if (d >= 0 && d % 2 == 0) {
      t = tt;
      x = xx;
      y = yy;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main()
{
    int N;
    string s, t;
    cin >> N >> s >> t;
    string ans;
    for (int i = 0; i < N; i++)
    {
        ans.push_back(s[i]);
        ans.push_back(t[i]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
ll X;
int main(){
	cin>>X;
	ll total=0;

	total=X/11*2;
	if(X%11>6)total++;
	if(X%11>0)total++;
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define mod 1000000007

const int sz=1e5+5;
ll inf=1e15;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        ll a,b,c;
        cin>>a>>b>>c;
        ll ans=(ceil((a*1.0)/(b/1.0))*c);
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 3628
package main

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

func solve(N int64) {
	ans := int64(0)
	for i := int64(1); i <= N; i++ {
		if i%3 != 0 && i%5 != 0 {
			ans += i
		}
	}
	fmt.Println(ans)
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int64
	scanner.Scan()
	N, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	solve(N)
}


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

int main(){
    int n, k;
    cin>>n>>k;
    vector<int>power(n);
    for (int i=0;i<n;i++){
        cin>>power.at(i);
    }
    for(int i=0;i<min(k,50);i++){
        vector<int>b(n,0);
        for(int j=0;j<n;j++){
            int start = max(0,j-power[j]);
            int end = min(j+power[j],n-1);
            b[start]++;
            if(end+1<n) b[end+1]--;
        }
        for(int i=1;i<n;i++){
        b[i]+=b[i-1];
        }
        power = b;
    }
    for(int x:power){
        cout<< x <<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 4852
n,m=map(int,input().split())
num=[1]*n
red=[True]+[False]*(n-1)
for _ in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    if red[x]:
        red[y]=True
    num[x]-=1
    num[y]+=1
    if not num[x]:
        red[x]=False
print(sum(red))

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

long long n, x[101], ans=1e13;

int main(){
	cin >> n;
	for (int i=0;i<n;i++) cin >> x[i];
	for (int p=1;p<=100;p++){
		long long tmp=0;
		for (int i=0;i<n;i++){
			tmp+=(x[i]-p)*(x[i]-p);
		}
		ans=min(ans,tmp);
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

#define INF 200000009

typedef long long ll;

int main(){
    int h,w; cin >> h >> w;
    int d[h][w];
    rep(i,h) rep(j,w) d[i][j] = INF;
    vector<string> vs(h);
    rep(i,h) cin >> vs[i];
    int sh,sw;
    rep(i,h) rep(j,w){
        if(vs[i][j] == '.'){
            sh = i; sw = j;
            break;
        } 
    }
    bool c[h][w]; rep(i,h) rep(j,w) c[i][j] = false;
    
    //行き
    queue<pair<int,int>> q;
    q.push(mp(sh,sw));
    c[sh][sw] = true;
    d[sh][sw] = 0;

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

    while(!q.empty()){
        int th = q.front().first;
        int tw = q.front().second;
        q.pop();
        rep(i,4){
            if(
                th + dy[i] < h && th + dy[i] >= 0 &&
                tw + dx[i] < w && tw + dx[i] >= 0 &&
                vs[th + dy[i]][tw + dx[i]] == '.' &&
                !c[th + dy[i]][tw + dx[i]]
            ){
                d[th + dy[i]][tw + dx[i]] = d[th][tw] + 1;
                c[th + dy[i]][tw + dx[i]] = true;
                q.push(mp(th + dy[i], tw + dx[i]));
            }
        }
    }

    int ma = -1;
    rep(i,h) rep(j,w){
        if(ma <= d[i][j] && d[i][j] != INF){
            sh = i; sw = j;
            ma = d[i][j];
        }
    }
    /*
    rep(i,h){
        rep(j,w){
            cout << d[i][j] << " ";
        }
        cout << endl;
    }
    */
    rep(i,h) rep(j,w) d[i][j] = INF;
    rep(i,h) rep(j,w) c[i][j] = false;
    q.push(mp(sh,sw));
    c[sh][sw] = true;
    d[sh][sw] = 0;

    while(!q.empty()){
        int th = q.front().first;
        int tw = q.front().second;
        q.pop();
        rep(i,4){
            if(
                th + dy[i] < h && th + dy[i] >= 0 &&
                tw + dx[i] < w && tw + dx[i] >= 0 &&
                vs[th + dy[i]][tw + dx[i]] == '.' &&
                !c[th + dy[i]][tw + dx[i]]
            ){
                d[th + dy[i]][tw + dx[i]] = d[th][tw] + 1;
                c[th + dy[i]][tw + dx[i]] = true;
                q.push(mp(th + dy[i], tw + dx[i]));
            }
        }
    }

    ma = -1;
    rep(i,h) rep(j,w){
        if(ma <= d[i][j] && d[i][j] != INF){
            sh = i; sw = j;
            ma = d[i][j];
        }
    }

    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 384
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    double W, H, x, y;
    cin >> W >> H >> x >> y;

    int ans = (H == 2*y && W == 2*x);
    cout << 0.5*H*W << " " << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n;
    int[][] distances;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        distances = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                distances[i][j] = sc.nextInt();
            }
        }
        solve();
    }

    void solve() {
        long sumDistances = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i >= j) {
                    continue;
                }
                int minDistance = distances[i][j];
                boolean direct = true;
                for (int k = 0; k < n; k++) {
                    if (k == i || k == j) {
                        continue;
                    }
                    int tempMinDistance = distances[i][k] + distances[k][j];
                    if (tempMinDistance < minDistance) {
                        System.out.println(-1);
                        return;
                    }
                    if (tempMinDistance == minDistance) {
                        direct = false;
                    }
                }
                if (direct) {
                    sumDistances += (long)minDistance;
                }
            }
        }
        System.out.println(sumDistances);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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


int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  ll ans = 0;
  int t = n-1;
  rep(i,n) {
    int lim = 2;
    if (i == 0) lim = 1;
    rep(j,lim) {
      if (t > 0) {
        ans += a[i];
        t--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4024
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;


int main ()
{
    ll k, a, b;
    cin >> k >> a >> b;
    if (b -a <= 2) {
        cout << k+1; return 0;
    }
    else {
        if ((k - a + 1)%2==0) cout << (a  + (k - a + 1)/2*(b-a));
        else cout << (a + (k-a)/2*(b-a) +1);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m);i<(n);++i)
#define test(x) cout << #x << ' ' << x << endl;
#define eb emplace_back
#define pb push_back
#define mp make_pair 
int a[100000],dp[100000],n,b;
 
int dpp (int k) {
	if (dp[k]>-1) return dp[k];
	fop (i,1,b+1) {
		if (dp[k]==-1) dp[k]=abs(a[k+i]-a[k])+dpp(k+i);
		else if (k+i<n) dp[k]=min(abs(a[k+i]-a[k])+dpp(k+i),dp[k]);
	}
	return dp[k];
}
 
 
 
int main () {
	cin >> n >> b;
	fop (i,0,n)  {
      cin >> a[i];
      dp[i]=-1;
    }
    dp[n-1]=0;
	cout << dpp(0) << endl;
}

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

#define double long double
#define int long long
#define ALL(x) x.begin(),x.end()
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb(x) push_back(x)
#define eb emplace_back
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend()) 
#define mp(x, y) make_pair(x, y)
#define INF 1000000000
#define F(i, a, n) for(i=a;i<n;i++)
#define SI(x) cin>>x
#define DI(x, y) cin>>x>>y
#define TI(x, y, z) cin>>x>>y>>z
#define FI(w, x, y, z) cin>>w>>x>>y>>z
#define SO(x) cout<<x<<"\n"
#define DO(x, y) cout<<x<<" "<<y<<"\n"
#define TO(x, y, z) cout<<x<<" "<<y<<" "<<z<< "\n"
#define FO(w, x, y, z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<"\n"
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

const int MOD = 1e9 + 7;
const int N = 1e5 + 5;
int dp[N][2];

inline int add(int x, int y)
{
	return ((x%MOD) + (y%MOD))%MOD;
}

inline int mul(int x, int y)
{
	return ((x%MOD)*(y%MOD))%MOD;
}



void dfs(int x, vi adj[], int p = - 1)
{
	dp[x][0] = dp[x][1] = 1;
	for(auto v: adj[x])
	{
		if(v == p)
			continue;
		dfs(v, adj, x);
		dp[x][0] = mul(dp[x][0], add(dp[v][0], dp[v][1]));
		dp[x][1] = mul(dp[x][1], dp[v][0]);
	}
}


int32_t main(void)
{
    FASTER;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int i, j;
    int n;
    SI(n);
    vi adj[n];
    F(i, 0, n - 1)
    {
    	int u, v;
    	DI(u, v);
    	--u; --v;
    	adj[u].pb(v);
    	adj[v].pb(u);
    }
    dfs(0, adj);
    SO(add(dp[0][0], dp[0][1]));
    
    
    #ifdef LOCAL
    	cout<<endl<<endl<<"Time: "<<(float)clock()/CLOCKS_PER_SEC<<" seconds"<<endl;
    #endif
    return 0;
}

Measured memory_bytes: 17424
#include"bits/stdc++.h"

using namespace std;

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

	for (int i = 1;; i++) {
		if (i*i > N) {
			cout << (i - 1)*(i - 1) << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[n-1])


Measured memory_bytes: 2940
N = int(input())

prime = []
prime.append(2)
k = 0
for i in range(3, N+1):
    if prime[k]*prime[k] < i:
         k += 1
    for j in range(0, k+1):
        if i%prime[j] == 0:
            break
    else:
        prime.append(i)

count = []
for p in prime:
    i = 0
    q = p
    while q < N:
        i += N//q
        q *= p
    count.append(i)

ans = 0

for c in count:
    if 74 <= c:
        ans += 1

for i, ci in enumerate(count):
    if ci < 24:
        break
    for j, cj in enumerate(count):
        if cj < 2:
            break
        if i != j:
             ans += 1

for i, ci in enumerate(count):
    if ci < 14:
        break
    for j, cj in enumerate(count):
        if cj < 4:
            break
        if i != j:
             ans += 1

for i, ci in enumerate(count):
    if ci < 4:
        break
    M = len(count)
    for j in range(i+1, M):
        if count[j] < 4:
            break
        for k, ck in enumerate(count):
            if ck < 2:
                break
            if k != i and k != j:
                ans += 1

print(ans)


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

int main(){
	char n[5];
	cin >> n;
	if((n[0]==n[1] && n[1]==n[2]) || (n[1]==n[2] && n[2]==n[3])){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int c = a+b;
    if(c%2 == 0){
        cout<<c/2<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		int max = 0;
		for (int i = 0; i < 2; i++) {
			int temp = 0;
			for (int j = 0; j < 4; j++) {
				temp += sc.nextInt();
			}
			max = Math.max(temp,max);
		}
		System.out.println(max);
		
	}

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

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
 
int main() {    
    string S,T;
    cin >> S >> T;
    bool a=true;
    for(int i=0;i<S.size();i++){
        if(S.at(i)!=T.at(i)) a=false;
    }
    if(a) cout << "Yes" << endl;
    else cout << "No" << endl;

}


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

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;



int main()
{
    int n, k;
    cin >> n >> k;
    vector<ll> se, fu;
    int zero = 0;

    if(n == k) {
        ll ans = 1;
        for(int i = 0; i < n; i++) {
            ll t; cin >> t;
            ans *= t;
            ans %= mod;
        }
        cout << (ans % mod + mod) % mod << endl;
        return 0;
    }


    for(int i = 0; i < n; i++) {
        int t; cin >> t;
        if(t > 0)se.emplace_back(t);
        if(t <= 0)fu.emplace_back(-t);
        if(t == 0)zero++;

    }

    sort(se.begin(), se.end());
    sort(fu.begin(), fu.end());

    if(n - zero < k) {
        cout << 0 << endl;
        return 0;
    }


    //負 or ゼロになる
    if((int)fu.size() == n && k % 2) {
        ll ans = 1;
        for(int i = 0; i < k; i++)ans *= -fu[i], ans %= mod;
        cout << (ans % mod + mod) % mod << endl;
        return 0;
    }




    ll ans = 1;
    if(k % 2) {
        ans = se.back();
        se.pop_back();
    }
    k /= 2;

    for(int i = 0; i < k; i++) {
        ll pl = (se.size() >= 2 ? se.back() * *(se.end() - 2) : 1);
        ll mi = (fu.size() >= 2 ? fu.back() * *(fu.end() - 2) : 1);
    
        if(pl >= mi && se.size() >= 2) {
            ans *= pl % mod;
            ans %= mod;
            se.pop_back(), se.pop_back();
        } else if(mi > pl && fu.size() >= 2){
            ans *= mi % mod;
            ans %= mod;
            fu.pop_back(), fu.pop_back();
        } else {
            while(true);
            // cerr << fu.size() << " : " << se.size() << endl;
            // ans *= fu.back() * se.back();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5392
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)
vi a,b,c;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z,w;
    cin>>n>>z>>w;
    in(a,n);
    if(n==1){
        cout<<abs(a[n-1]-w);
    }
    else{
        cout<<max(abs(a[n-1]-w), abs(a[n-1]-a[n-2]));
    }


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL<<60;
constexpr auto mod = 1000000007;

int main() {
	int n;
	cin >> n;
	vector<ll> a(n), b(n), c(n);
	FOR(i, n)cin >> a[i];
	FOR(i, n)cin >> b[i];
	FOR(i, n)cin >> c[i];
	SORT(a); SORT(c);
	ll ans = 0;
	FOR(i, n) {
		auto A = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
		auto C = c.end() - upper_bound(c.begin(), c.end(), b[i]);
		ans += A * C;
	}
	cout << ans << endl;
}


Measured memory_bytes: 2688
using System;

namespace ABC087_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            var c = int.Parse(Console.ReadLine());
            var x = int.Parse(Console.ReadLine());
            var count = 0;

            for (var i = 0; i <= b; i++)
                for (var j = 0; j <= c; j++)
                    for (var k = 0; k <= a; k++)
                    {
                        if (500 * k + 100 * i + 50 * j == x)
                            count++;
                    }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, num = 1;
  cin >> n;
  rep(i, n) {
    int a;
    cin >> a;
    if(a == num) num++;
  }
  cout << (num == 1 ? -1 : n + 1 - num) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
typedef long long ll;
using namespace std;

const ll mod = 1000000007;

/*
ZZ(xi-xj)(yk-yl)
= Z(xi-xj) * Z(yk-yl)
Z(xi-xj)
Zxi
*/

int main(){
  int n,m;
  cin >> n >> m;
  vector<ll> x(n);
  vector<ll> y(m);
  rep(i,n) cin >> x[i];
  rep(i,m) cin >> y[i];
  ll ans = 0;
  ll zi=0,zj=0,zk=0,zl=0;
  rep(i,n-1){
    zi += (x[i+1]+mod)%mod*(i+1)%mod; zi %= mod;
    zj += (x[i]+mod)%mod*(n-1-i)%mod; zj %= mod;
  }
  rep(i,m-1){
    zk += (y[i+1]+mod)%mod*(i+1)%mod; zk %= mod;
    zl += (y[i]+mod)%mod*(m-1-i)%mod; zl %= mod;
  }
  ans = (zi-zj+mod)%mod;
  ans *= (zk-zl+mod)%mod; ans %= mod;
  cout << ans % mod << endl;
  return 0;
}


Measured memory_bytes: 4844
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		List<List<Integer>> list = new ArrayList<>(m + 1);
		for (int i = 0; i <= m; i++) {
			list.add(new ArrayList<>());
		}
		int[] cnt = new int[m + 2];
		for (int i = 1; i < n; i++) {
			list.get(a[i]).add(i);
			if (a[i - 1] < a[i]) {
				cnt[a[i - 1] + 1]++;
				cnt[a[i]]--;
			} else {
				cnt[a[i - 1] + 1]++;
				cnt[0]++;
				cnt[a[i]]--;
			}
		}
		for (int i = 1; i < cnt.length; i++) {
			cnt[i] += cnt[i - 1];
		}

		long ans = 0;
		for (int i = 1; i < n; i++) {
			if (a[i - 1] < a[i]) {
				ans += a[i] - a[i - 1];
			} else {
				ans += a[i] + 1;
			}
		}

		long val = ans;
		for (int i = 1; i <= m; i++) {
			for (int j : list.get(i - 1)) {
				val += (a[j] + m - a[j - 1]) % m - 1;
			}
			val -= cnt[i - 1];
			ans = Math.min(ans, val);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 42436
#include<bits/stdc++.h>
using namespace std;
int main()
{ int x,y;
cin>>x>>y;
if(((x==1)||(x==3)||(x==5)||(x==7)||(x==8)||(x==10)||(x==12))&&((y==1)||(y==3)||(y==5)||(y==7)||(y==8)||(y==10)||(y==12)))
cout<<"Yes";
else
if(((x==4)||(x==6)||(x==9)||(x==11))&&((y==4)||(y==6)||(y==9)||(y==11)))
cout<<"Yes";
else
cout<<"No";
return 0;
}

Measured memory_bytes: 256
/**
 * Title: A - Weather Prediction
 * Url: https://atcoder.jp/contests/abc141/tasks/abc141_a
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
    string s; cin >> s;
    string ans;
    if(s=="Sunny") {
        ans = "Cloudy";
    } else if (s=="Cloudy") {
        ans = "Rainy";
    } else {
        ans = "Sunny";
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
int abs(int x){
    if(x<0) return -x;
    else return x;
}
int main() {
    int k,s;
    cin>>k>>s;
    int cou=0;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            int z=s-x-y;
            if(z>=0 and z<=k) cou++;
        }
    }
    cout<<cou<<endl;
    
}

Measured memory_bytes: 3596
n = int(input())
if 64 <= n:
    print (64)
elif 32 <= n and n < 64:
    print (32)
elif 16 <= n and n < 32:
    print (16)
elif 8 <= n and n < 16:
    print (8)
elif 4 <= n and n < 8:
    print (4)
elif 2 <= n and n < 4:
    print (2)
else:
    print (1)


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#define P(s,t) printf("%d"s,t);
#define F(i,c) for(i=0;i<c;i++)
int main(void) {
	int r,c,i,j,v;
	int sr, *sc;
	scanf("%d %d", &r, &c); 
	sc = (int *)calloc(c + 1, sizeof(int));
	F(i,r){
		sr = 0;
		F(j,c) {
			scanf("%d", &v);
			sr += v;
			sc[j] += v;
			P(" ",v)
		}
		sc[c] += sr;
		P("\n",sr)
	}
	F(j,c) {
		P(" ",sc[j])
	}
	P("\n",sc[c])
	free(sc);
	return 0;	
}

Measured memory_bytes: 612
#20:15
n,m = map(int,input().split())
ab = []
for _ in range(n):
  ab.append(list(map(int,input().split())))
ab.sort()
ans = 0
for x in ab:
  a,b = x
  if m - b > 0:
    m -= b
    ans += a * b
  else:
    ans += a * m
    break
print(ans)

Measured memory_bytes: 27760
if __name__ == '__main__':
    n, k = map(int, input().split())
    if k % 2 == 1:
        base = n // k
        if base == 0:
            print(0)
        else:
            print(base ** 3)
    else:
        ans = 0
        base = n // k
        if base != 0:
            ans += base ** 3

        base = n // (k // 2)
        if base % 2 == 0:
            base = base // 2
        else:
            base = (base + 1) // 2

        ans += base ** 3

        print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <stdio.h>
using namespace std;

int main()
{
    long double a,b;
    cin >> a >>b;
    long double sum = a*b;
    long long int sumi = sum;
    /*
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    */
    cout << sumi << endl; 
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int w[n], s[n]; ll v[n];
  rep(i,n) cin >> w[i] >> s[i] >> v[i];
  int ord[n];
  rep(i,n) ord[i] = i;
  sort(ord,ord+n,[&](int a, int b){return w[a]+s[a] < w[b]+s[b];});
  vector<vector<ll>> dp(n+1,vector<ll>(MAX));
  rep(i,n) {
    rep(j,MAX) {
      dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
      if(s[ord[i]] >= j) {
        int wa = min(MAX-1,j+w[ord[i]]);
        dp[i+1][wa] = max(dp[i+1][wa],dp[i][j]+v[ord[i]]);
      }
    }
  }
  ll ans = 0;
  rep(i,MAX) ans = max(ans,dp[n][i]);
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define IO ios_base::sync_with_stdio(0);cin.tie(0);

int main()
{
  IO;
  int n; cin >> n;
  map <int, int> st;

  for (int i = 0; i < n; ++i)
  {
    int k; cin >> k;
    st[k + 1]++;
    st[k]++;
    st[k - 1]++;
  }

  int maxn = -1;
  for (auto elem : st)
  if (elem.second > maxn)
  maxn = elem.second;

  cout << maxn << endl;

  return 0;
}

Measured memory_bytes: 4736
#include <cstdio>

int main()
{
    int n;
    scanf("%d", &n);

    int possible = false;

    if(n >= 18)
    {
        possible = true;
    }
    else
    {
        for(int i = 0; 4*i <= n; i++)
        {
            if( (n - 4*i)%7 == 0)
            {
                possible = true;
                break;
            }
        }
    }

    printf(possible ? "Yes\n" : "No\n");

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,k,mod=1e9+7; 
int fac[10000005],inv[10000005];
inline int pows(int a,ll b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=(ll)ans*a%mod;
		a=(ll)a*a%mod;
		b>>=1;
	}
	return ans;
}
inline ll c(int a,int b)
{
	if(a<b)return 0;
	ll fa=fac[a],fb=inv[b],fc=inv[a-b];
	return fa*fb%mod*fc%mod;
}
template<class t> inline void write(t x){
    if(x<0){putchar('-'),write(-x);}
    else{if(x>9)write(x/10);putchar('0'+x%10);}
}
int main()
{
	scanf("%lld%lld",&n,&k);
	fac[0]=1;
	for(register int i=1;i<=n;i++)
	fac[i]=(ll)fac[i-1]*i%mod;
	inv[n]=pows(fac[n],mod-2);
	for(register int i=n-1;i>=0;i--)inv[i]=(ll)inv[i+1]*(i+1)%mod;
	for(register int i=1;i<=k;i++)
	write(c(n-k+1,i)*c(k-1,i-1)%mod),putchar('\n');
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
	using namespace std;
	typedef long long int ll;
	
	#define mod					1000000007
	#define pii                 pair<int,int>
	#define vi                  vector<int>
	#define vii                 vector<std::vector<int>> v;
	#define mem(dp,a)           memset(dp,a,sizeof dp)
	#define sonic               ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	#define pb(x)               push_back(x)
	#define mkp(x,y)             make_pair(x,y)
	#define all(c)              c.begin(), c.end()
	#define ff                  first
	#define ss                  second
	#define INF                 INT_MAX
	
	/* Bit Manipulation */
	
	#define isOn(S, j) (S & (1 << j))
	#define setBit(S, j) (S |= (1 << j))
	#define clearBit(S, j) (S &= ~(1 << j)) // to turn off
	#define toggleBit(S, j) (S ^= (1 << j))
	#define lowBit(S) (S & (-S)) // to get lsb
	#define setAll(S, n) (S = (1 << n) - 1)
	
	#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
	#define isPowerOfTwo(S) (!(S & (S - 1)))
	#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
	#define turnOffLastBit(S) ((S) & (S - 1))
	#define turnOnLastZero(S) ((S) | (S + 1))
	#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
	#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
	
	void printSet(int vS) {                         // in binary representation
	  printf("S = %2d = ", vS);
	  stack<int> st;
	  while (vS)
	    st.push(vS % 2), vS /= 2;
	  while (!st.empty())                         // to reverse the print order
	    printf("%d", st.top()), st.pop();
	  printf("\n");
	}
	
	
	
	
	
// Main Starts...
	int main()
	{
	    sonic;
	    ll n;
	    cin >> n;
	    vector<ll> v;
	    for (ll i=0,x;i<n;i++)
	    {
	    	cin >> x;
	    	v.pb(x);
	    }
	    ll large = v[0], cnt=0;
	    for (ll i:v)
	    {
	    	large = max(large,i);
	    	cnt += (large-i);
	    }
	    cout << cnt << endl;
	}
	//******Main Ends here****************//
	
	
	


Measured memory_bytes: 5304
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define endl '\n'
#define PI acos(-1)
typedef long long ll;
using namespace std;
int n, m, *x, a, b;
unordered_map<int, vector<int> > mp;
int go(int i)
{
    if(mp.find(i) == mp.end())
        return 0;
    if(~x[i - 1])
        return x[i - 1];
    for(int j = 0; j < mp[i].size(); j++)
        x[i - 1] = max(x[i - 1], go(mp[i][j]) + 1);
    return x[i - 1];
}
int main()
{
    cin.tie(NULL); cout.tie(NULL);  ios_base::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif
    cin >> n >> m;
    x = new int[n];
    memset(x, -1, 4 * n);
    for(int i = 0; i < m; i++)
    {
        cin >> a >> b;
        mp[a].push_back(b);
    }
    for(unordered_map<int, vector<int> >::iterator it = mp.begin(); it != mp.end(); it++)
        go(it->first);
    int ans = 0;
    for(int i = 0; i < n; i++)
        ans = max(ans, max(x[i], 0));
    cout << ans;
}

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

int main(){
  int n;
  cin>>n;
  if(n>=400 && n<600)
      cout<<8<<endl;
  if(n>=600 && n<800)
      cout<<7<<endl;
  if(n>=800 && n<1000)
      cout<<6<<endl;
  if(n>=1000 && n<1200)
      cout<<5<<endl;
  if(n>=1200 && n<1400)
      cout<<4<<endl;
  if(n>=1400 && n<1600)
    cout<<3<<endl;
  if(n>=1600 &&n<1800)
    cout<<2<<endl;
  if(n>=1800 && n<2000)
     cout<<1<<endl;
  return 0;
}


Measured memory_bytes: 3632
a,b,c,d,e,f=map(int,input().split());ans,ma=[0]*2,0
for i in range(f//100+1):
  if i%b==0 or i%a==0:
    w=i*100
    x=min(f-w,i*e)
    s=0
    for j in range(x//c+1):
      ss=j*c
      s=max(s,ss+((x-ss)//d)*d)
    if w!=0:
      if ma<=(100*s)/(w+s):ans=[w,s];ma=(100*s)/(w+s)
print(ans[0]+ans[1],ans[1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return a > b ? a = b, true : false; }
const ll MAXN=1e5+4;
ll a[MAXN];
ll sum[MAXN];
queue<pair<ll,ll> > q;
vector<ll> ans;
set<ll> s;
int main() {
	ios_base::sync_with_stdio(false);
	ll n,k; scanf("%lld %lld",&n,&k);
	for (ll i=0;i<n;i++) scanf("%lld",&a[i]);
	for (ll i=-1;i<=n;i++) s.insert(i);
	for (ll i=1;i<n;i++) {
		if (a[i-1]+a[i]>=k) {
			q.push(MP(i-1,i));
		}
	}
	while(!q.empty()) {
		pair<ll,ll> w=q.front(); q.pop();
		ll x=w.first,y=w.second;
		auto xit=s.find(x); if (xit==s.end()) continue;
		auto yit=s.find(y); if(yit==s.end()) continue;
		ans.PB(y);
		++yit; ll r=*yit;
		--xit; ll l=*xit;
		s.erase(y);
		a[x]+=a[y];
		a[y]=0;
		if (l>=0) {
			if (a[l]+a[x]>=k) q.push(MP(l,x));
		}
		if (r<n) {
			if (a[x]+a[r]>=k) q.push(MP(x,r));
		}
	}
	reverse(ans.begin(),ans.end());
	if (ans.size()==n-1) {
		printf("Possible\n");
		for (auto &w:ans) printf("%lld\n",w);
	}
	else printf("Impossible\n");
}

Measured memory_bytes: 9080
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
	int a = stdIn.nextInt();
	int k=a;
	int count=0;
	for(int i=0;i<3;i++){
	    k=a%10;
	    if(k==1){
		count++;
	    }
	    a/=10;
	}
	System.out.println(count);
    }
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n;
    cin>>n;
    vi x(n);
    rep(i,n)cin>>x[i];

    int sum=0,sum2=0;
    double avg=0;
    rep(i,n){
        avg+=x[i];
        sum2+=x[i]*x[i];
    }
    sum=avg;
    avg=avg/n;
    // cerr<<"sum,sum2,avg "<<sum<<","<<sum2<<","<<avg<<"\n";

    int p=avg;
    if(avg-p>=0.5)p++;

    sum2+=n*p*p-2*p*sum;

    cout<<sum2<<"\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 
#include <time.h>

int main(void){
    std::string S,T;
    std::cin >> S >> T;
    bool flag=0;
    for(long i=0; i<S.length(); i++){
        if(S[i]!=T[i]){
            flag=1;
        }
    }
    if(flag){
        std::cout << "No" << std::endl;
    }else{
        std::cout << "Yes" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
k  = int(input())
a, b  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

for i in range(a, b+1):
    if i % k == 0:
        print('OK')
        break
else:
    print('NG')


Measured memory_bytes: 9464
#include<iostream>
#include<algorithm>
#include<vector>
using lint=int64_t;
using namespace std;

void dfs(vector<vector<int>> &edge,int& node,int& dist,int d,int cur,int prev)
{
	if(d>dist)
	{
		node=cur;
		dist=d;
	}

	for(auto&& i:edge[cur])
	{
		if(i==prev)
			continue;

		dfs(edge,node,dist,d+1,i,cur);
	}
	
	return;
}

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

	vector<vector<int>> edge(N);
	for(int i=0;i<N-1;i++)
	{
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}

	int node=0;
	int dist=0;
	dfs(edge,node,dist,0,0,-1);

	dist=0;
	dfs(edge,node,dist,0,node,-1);

	if(dist%3==1)
		cout << "Second";
	else
		cout << "First";
	cout << endl;
	return 0;
}


Measured memory_bytes: 26752
import re

S = input()

rrr = S.count("RRR")
rr = S.count("RR")
r = S.count("R")

if rrr == 1:
    print(3)
elif rr == 1:
    print(2)
elif r == 1 or r == 2:
    print(1)
else:
    print(0)

Measured memory_bytes: 9804