akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

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

  int N;
  cin>>N;
  vector<string> res;
  if(N==1){
  	cout<<"1"<<endl;
  	cout<<"1"<<endl;
  	return 0;
  }
  if(N==2){
  	cout<<"2"<<endl;
  	cout<<"0"<<endl;
  	cout<<"11"<<endl;
  	return 0;
  }
  repl(len,2,N+1){
  	string tmp;
  	tmp+="1";
  	rep(i,len-2)tmp+="0";
  	tmp+="1";
  	res.push_back(tmp);
  }
  cout<<res.size()<<endl;
  rep(i,res.size())cout<<res[i]<<endl;

  return 0;
}



Measured memory_bytes: 3316
def main():
    import sys
    from collections import defaultdict
    sys.setrecursionlimit(10 ** 6)
    input = sys.stdin.readline
    N = int(input())
    D = defaultdict(int)
    for _ in range(N):
        D[input().strip()] += 1
    print(len(D))

if __name__ == '__main__':
    main()

Measured memory_bytes: 35608
n = int(input())
hs = [int(x) for x in input().split()]
dp = [0 for _ in range(n+1)]
dp[2] = abs(hs[1] - hs[0])
for i in range(3, n + 1):
    one = dp[i-2] + abs(hs[i-1] - hs[i-3])
    two = dp[i-1] + abs(hs[i-1] - hs[i-2])
    dp[i] = min(one, two)
print(dp[n])


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

int a[10];

int main()
{
	for(int i=1;i<=3;i++)
		cin>>a[i];
	
	sort(a+1,a+4);
	if(a[1]%2==0||a[2]%2==0||a[3]%2==0)
		cout<<"0"<<"\n";
	else
	{
		int t=a[3];
		if(t%2==0)
			cout<<"0"<<"\n";
		else
		{
			long long tmp=(long long)a[1]*a[2];
			cout<<tmp<<"\n";
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#define INF (1e9 + 7)
#define dist(x1, y1, x2, y2) sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
typedef long long int ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vvs = vector<vector<string>>;

int main(){
    
	string S;
	cin >> S;
	int Q;
	cin >> Q;
	vi t, f;
	vs c;
	int j, k;
	string l;
	rep(i, Q){
		cin >> j;
		if(j == 1){
			t.push_back(1);
			f.push_back(0);
			c.push_back("0");
		}
		else{
			cin >> k >> l;
			t.push_back(2);
			f.push_back(k);
			c.push_back(l);
		}
	}

	vi acc(Q);
	if(t[Q - 1] == 1){
		acc[Q - 1] = 1;
	}

	for(int i = Q - 2; i >= 0; i--){
		if(t[i] == 1){
			acc[i] = acc[i + 1] + 1;
		}
		else{
			acc[i] = acc[i + 1];
		}
	}
			
	if(acc[0] % 2 == 1){
		reverse(S.begin(), S.end());
	}

		
	rep(i, Q){
		if(t[i] == 2){
			if((f[i] + acc[i]) % 2){
				S = c[i] + S;
			}
			else{
				S += c[i];
			}
		}
	}
	
	cout << S << endl;
		
	return 0;
	
}



Measured memory_bytes: 14084
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Sat Mar 31 21:39:35 2018
//
package main

import (
	"fmt"
)

var N int

func main() {
	var s, t string
	fmt.Scan(&N, &s, &t)

	count := len(t)
	for i := range s {
		valid := true
		for j := 0; i+j < len(s); j++ {
			if s[i+j] != t[j] {
				valid = false
			}
		}
		if valid {
			count = i
			break
		}
	}

	fmt.Println(len(s) + count)
}


Measured memory_bytes: 512
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn linear_search(array: Vec<u32>, key: u32) -> usize {
    let mut cloned_array: Vec<u32> = array;
    let mut index: usize = 0;
    cloned_array.push(key);
    while cloned_array[index] != key {
        index += 1;
    }
    return index;
}

fn main() {
    let n: usize = read();
    let s: Vec<u32> = (0..n)
        .map(|_| {
            let number: u32 = read();
            number
        })
        .collect();
    let q: usize = read();
    let t: Vec<u32> = (0..q)
        .map(|_| {
            let number: u32 = read();
            number
        })
        .collect();
    let mut count: u32 = 0;
    let s_len: usize = s.len();
    for key in t {
        if s_len != linear_search(s.clone(), key) {
            count += 1;
        }
    }
    println!("{}", count);
}



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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

vector<ll> A(100005, 0);

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

  rep0(i, K) cin >> A[i];

  ll MIN = 2, MAX = 2, temp;
  repR(i, 0, K) {
    // cout << i << SP << MIN << SP << MAX << BR;
    temp = ((MIN + A[i] - 1) / A[i]) * A[i];
    if (temp - (temp % A[i]) > MAX) {
      cout << "-1\n";
      return 0;
    }
    MIN = temp;

    temp = (MAX / A[i]) * A[i] + A[i] - 1;
    if (temp - (temp % A[i]) < MIN) {
      cout << "-1\n";
      return 0;
    }
    MAX = temp;
  }

  cout << MIN << SP << MAX << BR;
  return 0;
}

Measured memory_bytes: 1024
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007
flush = sys.stdin.flush()

def solve():
    n = I()
    ans = [-1]*(2*n)
    q = [i+1 for i in range(n)]
    que = ["?"]+q
    print(*que)
    flush
    t = input()
    T = t
    l = 0
    r = n
    while r-l > 1:
        m = (l+r) >> 1
        q = [i+m+1 for i in range(n)]
        que = ["?"]+q
        print(*que)
        flush
        t = input()
        if t == T:
            l = m
        else:
            r = m
    if T[0] == "R":
        ans[l] = "R"
        ans[l+n] = "B"
    else:
        ans[l] = "B"
        ans[l+n] = "R"
    Q = [i+r+1 for i in range(n-1)]
    for i in range(1,2*n+1):
        if ans[i-1] != -1:
            continue
        if i in Q:
            continue
        q = Q+[i]
        que = ["?"]+q
        print(*que)
        flush
        t = input()
        if t[0] == "R":
            ans[i-1] = "R"
        else:
            ans[i-1] = "B"
    Q_ = []
    for i in range(2*n):
        if len(Q_) == (n>>1):
            break
        if ans[i] == "R" and i+1 not in Q:
            Q_.append(i+1)
    for i in range(2*n):
        if len(Q_) == n-1:
            break
        if ans[i] == "B" and i+1 not in Q:
            Q_.append(i+1)
    for i in Q:
        q = Q_+[i]
        que = ["?"]+q
        print(*que)
        flush
        t = input()
        if t[0] == "R":
            ans[i-1] = "R"
        else:
            ans[i-1] = "B"
    ans = ["! "]+ans
    print(*ans,sep = "")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 43392
import java.io.*;
import java.util.*;
 
public class  Main{
	public static void main(String[] args) throws Exception{
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		long x=sc.nextLong();
		if(x%2==1) {
			pw.println(0);
		}
		else {
			long ans=0;
			for(long i=5;i<=x/2;i*=5) {
				ans+=(x/2)/i;
			}
			pw.println(ans);
		}
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] takearr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] takearrl(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public Integer[] takearrobj(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] takearrlobj(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 21076
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

using namespace std;

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

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

    bool ans=true;

    char a=S[0];
    rep(i,1,4){
        if(a==S[i])ans=false;
        a=S[i];
    }

    if(ans)cout<<"Good";
    else cout<<"Bad";
    return 0;
}

Measured memory_bytes: 256
/*
 * ARC082_D.cpp
 *
 *  Created on: Jun 5, 2018
 *      Author: 13743
 */
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

int p[100001];
//vector<int> con;
//
//int main() {
//	cin.tie(0);
//	ios::sync_with_stdio(false);
//
//	int N;
//	cin >> N;
//	FOR(i, 1, N) {
//		cin >> p[i];
//	}
//
//	bool start = true;
//	FOR(i, 1, N) {
//		if(start && p[i]==i) {
//			con.pb(0);
//			start = false;
//		}
//		if(p[i] == i) con[con.size()-1]++;
//		else start = true;
//	}
//
//	int ans = 0;
//	REP(i, SZ(con)) {
//		ans += con[i]/2;
//		if(con[i]%2 == 1) {
//			ans++;
//		}
//	}
//
//	cout << ans << endl;
//}


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

	int N;
	cin >> N;
	FOR(i, 1, N) {
		cin >> p[i];
	}
	int ans = 0;
	FOR(i, 1, N) {
		if(p[i]==i && i<N) {
			swap(p[i], p[i+1]);
			ans++;
		}
		else if(p[i]==i && i==N) {
			ans++;
		}
	}
	cout << ans << endl;
}






Measured memory_bytes: 640
/*
 * Created by KeigoOgawa
 */


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>

#define INF (int)1e8
#define EPS 1e-10
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define RFOR(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cerr << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> PII;

// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << "\t";
    }
    return s;
}

// 2 dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) {
        s << vv[i] << endl;
    }
    return s;
}

int A, B;


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

    cin >> A >> B;

    int K = 50;
    vector<string> ans;

    REP(i, K) {
        string b = "####################################################################################################";
        ans.push_back(b);
    }

    REP(i, K) {
        string w = "....................................................................................................";
        ans.push_back(w);
    }

    REP(i, A - 1) {
        int r = i * 2 / (2 * K) * 2;
        int c = i * 2 % (2 * K);
        if (r % 2 == 1) c++;
        ans[r][c] = '.';
    }

    REP(i, B - 1) {
        int r = 99 - i * 2 / (2 * K) * 2;
        int c = i * 2 % (2 * K);
        if (r % 2 == 1) c++;
        ans[r][c] = '#';
    }

    cout << 2 * K << " " << 2 * K << endl;
    REP(i, K * 2) {
        cout << ans[i] << endl;
    }

    return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}


signed main(){
    int n;
    cin >> n;
    vector<ll> v(n);
    for(auto& i : v) cin >> i;

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

    ll ans = 0;

    REP(i, n-1){
        ll diff = v[i+1] - v[i];
        if(diff > 1){
            cout << -1 << endl;
            return 0;
        }else if(diff == 1){
            ans++;
        }else{
            ans += v[i+1];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1920
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const int MAX = 1 << 17;

ll mod_pow(ll x, ll e) {
  ll v = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) {
      v = v * x % MOD;
    }
    x = x * x % MOD;
  }
  return v;
}

ll f[MAX], finv[MAX];
void init() {
  f[0] = 1;
  for (int i = 1; i < MAX; i++) f[i] = f[i - 1] * i % MOD;
  finv[MAX - 1] = mod_pow(f[MAX - 1], MOD - 2);
  for (int i = MAX - 2; i >= 0; i--) {
    finv[i] = finv[i + 1] * (i + 1) % MOD;
  }
}

ll fact(int n) { return f[n]; }

ll comb(int n, int k) {
  if (k > n) return 0;
  return f[n] * finv[k] % MOD * finv[n - k] % MOD;
}

int main() {
  init();
  int N, M;
  while (cin >> N >> M) {
    vector<int> A(M);
    for (int i = 0; i < M; i++) {
      cin >> A[i];
    }
    sort(A.rbegin(), A.rend());
    vector<vector<ll>> dp(M + 1, vector<ll>(1 << N, 0));
    dp[0][0] = 1;
    for (int i = 0; i < M; i++) {
      for (int m = 0; m < (1 << N); m++) {
        (dp[i + 1][m] += dp[i][m]) %= MOD;
        int rem = (1 << N) - m - A[i];
        for (int j = 0; j < N; j++) {
          if ((m >> j) & 1) {
            continue;
          }
          ll ways =
              dp[i][m] * comb(rem, (1 << j) - 1) % MOD * fact(1 << j) % MOD;
          (dp[i + 1][m | (1 << j)] += ways) %= MOD;
        }
      }
    }
    ll ans = 0;
    for (int m = 0; m < (1 << N); m++) {
      ll ways = dp[M][m] * fact((1 << N) - 1 - m) % MOD;
      if (__builtin_popcount(m) % 2 == 0) {
        ans = (ans + ways) % MOD;
      } else {
        ans = (ans - ways + MOD) % MOD;
      }
    }
    ans = (ans << N) % MOD;
    cout << ans << endl;
  }
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  for(int i=0; i<N; i++) cin >> s.at(i);
  int M;
  cin >> M;
  vector<string> t(M);
  for(int i=0; i<M; i++) cin >> t.at(i);
  int cnt=0;
  int max=0;
  
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(s.at(i)==s.at(j)) cnt++;
    }
    for(int j=0; j<M; j++){
      if(s.at(i)==t.at(j)) cnt--;
    }
    if(cnt>max) max=cnt;
    cnt=0;
  }
  cout<<max<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
int x, y;
int main() {
    DAU
    cin >> x >> y;
    if (x < 1 || x > 9 || y < 1 || y > 9)
        cout << "-1";
    else cout << x * y;
    PLEC
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n;
	cin >> n;
	double d = n;
	cout << fixed << setprecision(15) << (d/3.0)*(d/3.0)*(d/3.0) << endl;

	return 0;
}



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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

int main()
{
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	sort(all(a));
	int ans = 0;
	rep(i, n - 1)
	{
		if (a[i] <= x)
		{
			ans++;
			x -= a[i];
		}
		else
		{
			break;
		}
	}

	cout << ((a[n - 1] == x) ? ans + 1 : ans) << endl;
	return (0);
}


Measured memory_bytes: 3616
from sys import exit

s = input()

for i in range(len(s)-1, -1, -1):
    if i % 2 == 1:
        continue

    flag = True
    for j in range(i // 2):
        if s[j] != s[i//2+j]:
            flag = False
    
    if flag:
        print(i)
        exit()

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n;cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    
    ll sum = 0;
    rep(i,n)sum+=a[i];
    ll min = sum-a[a.size()-1];
    ll sum1 = 0;
    for(ll i = 0;i<n-1;i++)
    {
        sum1+=a[i];
        if(abs(sum-2*min) > abs(sum-2*sum1))min = sum1;
    }

    cout<<abs(sum-2*min)<<endl;

    return 0;
}

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

int main(){
    int L, R, d;
    cin >> L >> R >> d;
    cout << (R/d) - ((L-1)/d) << endl;
}



Measured memory_bytes: 3632
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

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

int main()
{
        int a, b, ans = 0;
        cin >> a >> b;
        rep2(i, 1, 10)
        {
                rep(j, 10)
                {
                        rep(k, 10)
                        {
                                int x = 10001 * i + 1010 * j + 100 * k;
                                if (x >= a && x <= b)
                                {
                                        ans++;
                                }
                        }
                }
        }

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <stdio.h>
#include <string.h>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x * x + y * y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;

void make_prime_factors(ll num, vector<ll>& prime_factors)
{
	ll base = num;
	ll j = 2;
	while (j*j <= base)
	{
		if (base%j == 0)
		{
			base /= j;
			prime_factors.push_back((ll)j);
		}
		else
		{
			j++;
		}
	}
	if (base >= 2)
	{
		prime_factors.push_back((ll)base);
	}
}

map <vector <int>, bool > memo;


bool dfs(vector <int> x)
{

	const int N = SZ(x);
	if (count(x.begin(), x.end(), 0) == SZ(x))
	{
		return false;
	}


	if (memo.count(x))
	{
		return memo[x];
	}


	bool win = false;

	for (int i=1;i<1<<N;++i)
	{
		bool ari = true;;
		for (int b=0;b<N;++b)
		{
			if ((i & (1<<b)) && x[b]==0)
			{
				ari = false;
			}
		}

		if (ari)
		{
			vector <int> n(x);
			for (int b = 0; b<N; ++b)
			{
				if ((i & (1 << b)))
				{
					n[b]--;
				}
				sort(n.begin(), n.end());
				if (n != x)
				{
					win |= !dfs(n);
				}
			}
		}
	}

	memo[x] = win;
	// BEGIN CUT HERE
	int tmp = 0;
	for (int i=0;i<N;++i)
	{
		printf("%2d,",x[i]);
		tmp += x[i];
	}
	printf(" } %2d = %d\n", tmp, memo[x]);

	return win;
}


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

	bool win = false;
	for (int i = 0; i < N; ++i)
	{
		int tmp;
		cin >> tmp;
		if (tmp % 2) win = true;
	}


	if (win)
	{
		cout << "first" << endl;
	}
	else
	{
		cout << "second" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
#define MSG(a) cout << #a << " " << a << "\n";

int main(){
    int n,k,q;cin >> n >> k >> q;
    vint A(q); REP(i,q) cin >> A[i];

    // ｎ人がＫポイントを持っており、q回クイズを行う
    // A[i]が正解した人の番号であり、A[i]以外の人は-1ポイント

    // 出力：最終的にポイントが１以上あればYes、なければNoとして配列Xを出力する
    vint Point(n); REP(i,n) Point.at(i) = 0;

    REP(i,q){
        Point[A[i]-1]++;
    }

    REP(i,n){
        if(Point[i] + k - q > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    
}

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

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int A, B;
    cin >> A >> B;

    int low_a = (100 * A + 8 - 1) / 8;
    int high_a = (100 * (A + 1) + 8 - 1) / 8 - 1;

    int low_b = (100 * B + 10 - 1) / 10;
    int high_b = (100 * (B + 1) + 10 - 1) / 10 - 1;

    if (high_a < low_b || high_b < low_a) {
        cout << -1 << endl;
    } else {
        cout << max(low_a, low_b) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
stack<char> st;
str s;int f;
int main(){
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(st.empty())st.push(s[i]);
        else{
            if(s[i]!=st.top()){st.pop();f+=2;}
            else{st.push(s[i]);}
        }
    }
    cout<<f<<endl;
}


Measured memory_bytes: 512
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


class BIT:
    def __init__(self, L):
        self.n = len(L)
        self.bit = [0] * (self.n + 1)

    def update(self, idx, x):
        while idx <= self.n:
            self.bit[idx] += x
            idx += idx & (-idx)

    def query(self, idx):
        res = 0
        while idx > 0:
            res += self.bit[idx]
            idx -= idx & (-idx)
        return res

    def sec_sum(self, left, right):
        return self.query(right) - self.query(left - 1)

    def debug(self):
        print(*[self.sec_sum(i, i) for i in range(1, self.n + 1)])


def resolve():
    n = int(input())
    S = list(input().rstrip())
    q = int(input())

    bits = [BIT(S) for _ in range(26)]
    for idx in range(1, n + 1):
        s = S[idx - 1]
        bits[ord(s) - ord("a")].update(idx, 1)

    for _ in range(q):
        query = list(input().split())
        if query[0] == "1":
            i, c = int(query[1]), query[2]
            prev = S[i - 1]
            bits[ord(prev) - ord("a")].update(i, -1)
            bits[ord(c) - ord("a")].update(i, 1)
            S[i - 1] = c
        else:
            l, r = int(query[1]), int(query[2])
            res = 0
            for j in range(26):
                if bits[j].sec_sum(l, r):
                    res += 1
            print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 203844
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;

const int M = 1000001;

int s[] = {0,2,5,5,4,5,6,3,7,6};
int a[M],ans[M];
int n,m;
int dp[M];

int cmp(int a,int b){
    return a > b;
}
 
int main(){
    cin>>n;
	cin>>m;
    for(int i = 0;i < m;i++){
        cin>>a[i];
    }
    memset(dp,-1,sizeof(dp));
    dp[0] = 1;
 
    int vis[10] = {0};
    for(int i = 0;i < m;i++){
        for(int j = s[a[i]];j <= n;j++){
            dp[j] = max(dp[j],dp[j-s[a[i]]]+1);
        }
    }
 
    sort(a,a+m,cmp);
    while(n){
        for(int i = 0;i < m;i++){
            if(n >= s[a[i]] && dp[n-s[a[i]]]+1 == dp[n]){
                putchar(a[i]+'0');
                n = n-s[a[i]];
				break;
            }
        }
    }
 
    cout<<endl;
    return 0;
}

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

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    while(1){
        if (a % 2 == 1){
            a--;
        }
        a /= 2;
        b += a;
        k--;
        if(k == 0)break;

        if (b % 2 == 1){
            b--;
        }
        b /= 2;
        a += b;
        k--;
        if(k == 0)break;
    }
    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#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 N, M, K;
  cin >> N >> M >> K;
  vector<int> as(N), bs(M);
  F0R(i, N) {
    cin >> as[i];
  }
  F0R(i, M) {
    cin >> bs[i];
  }

  int a = 0, b = 0;
  i64 t = 0;
  F0R(i, N) {
    if (t + as[i] > K) {
      break;
    }
    a++;
    t += as[i];
  }
  int result = 0;
  do {
    //debug(a);
    //debug(b);
    chmax(result, a + b);
    if (b == M) break;
    t += bs[b];
    b++;
    while (t > K && a > 0) {
      t -= as[a-1];
      a--;
    }
    if (t > K) break;

  } while (a);

  a = 0;
  b = 0;
  t = 0;
  F0R(i, M) {
    if (t + bs[i] > K) {
      break;
    }
    b++;
    t += bs[i];
  }
  chmax(result, b);

  cout << result;
}
#endif


Measured memory_bytes: 4776
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
	double a, b, c, d, e, f, x, y;
	while(cin >> a >> b >> c >> d >> e >> f) {
		//cout << c*e-b*f << " " << a*e-b*d << " " << c*d-a*f << " " << b*d-a*e << endl;
		if(c*e==b*f) x = 0;
		else x = (c*e-b*f)/(a*e-b*d);
		if(c*d==a*f) y = 0;
		else y = (a*f-c*d)/(a*e-b*d);
		printf("%.3f %.3f\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll mod = 1e9+7;

int main(void){
  ll a;
  cin >> a;
  if(a % 2 == 1){
    puts("0");
    return 0;
  }
  ll res = 0;
  ll div = 5;
  while(div <= a){
    res += (a / div) / 2;
    div *= 5;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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 T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    auto dp0 = make_vec<ll>(200200, 4);
    auto dp1 = make_vec<ll>(200200, 4);
    rep(i, 200200) rep(j, 4) dp0[i][j] = dp1[i][j] = -LINF;
    dp0[0][1] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            if (i % 2 == 1) {
                //使う
                chmax(dp1[i + 1][j], dp0[i][j] + a[i]);
                //使わない
                if (j - 1 >= 0) chmax(dp0[i + 1][j - 1], dp0[i][j]);
                if (j - 1 >= 0) chmax(dp0[i + 1][j - 1], dp1[i][j]);
            }
            if (i % 2 == 0) {
                //使う
                chmax(dp1[i + 1][j + 1], dp0[i][j] + a[i]);
                //使わない
                chmax(dp0[i + 1][j], dp0[i][j]);
                chmax(dp0[i + 1][j], dp1[i][j]);
            }
        }
    }
    cout << max(dp0[n][1], dp1[n][1]) << endl;
}


Measured memory_bytes: 33096
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize, m: usize,
        a: [i64; n],
    }
    let mut que = BinaryHeap::new();
    for i in 0..n {
        que.push(a[i]);
    }
    for _ in 0..m {
        let x = que.pop().unwrap();
        que.push(x / 2);
    }
    let mut tot = 0;
    while let Some(x) = que.pop() {
        tot += x;
    }
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int>a(5);
  for(int i=0;i<5;i++){
    cin>>a.at(i);
  }
  int b;
  bool c=false;
  for(int i=1;i<10;i++){
   for(int j=0;j<5;j++){
     if(a.at(j)%10==i){
       b=j;
       c=true;
       break;
     }
   }
    if(c)
      break;
  } 
  int d;
  for(int i=0;i<5;i++){
    if(i==b){
      d+=a.at(i);
    }else{
      if(a.at(i)%10==0){
        d+=a.at(i);
      }else{
        d+=(a.at(i)/10+1)*10;
      }
    }
  }
  cout<<d;
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

void main(){

    int n = readln().chomp().to!int;
    for(int i=0;i<n;i++){
	string ans = "";
	string inp = readln().chomp();
	ans ~= inp[0];
	for(int j=3;j<inp.length;j++){
	    if(indexOf(ans,inp[j]) != -1) {
		j+=2;
		continue;
	    }
	    if(inp[j-2..j] == "->") ans = ans ~ inp[j];
	    if(inp[j-2..j] == "<-") ans = inp[j] ~ ans;
	    j += 2;
	}
	writeln(ans);
    }

}

Measured memory_bytes: 2480
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        long[][] dp = new long[N+1][W+1];
        Sack[] s = new Sack[N];
        for(int i = 0 ; i < N ; i++)
            s[i] = new Sack(sc.nextInt(),sc.nextInt());
        Arrays.sort(s);
        for(int i = 1 ; i <= N ; i++)
        {
            for(int j = 1; j <= W ; j++)
            {
                if(s[i-1].w <= j )
                {
                    dp[i][j] = Math.max(s[i-1].b+dp[i-1][j-s[i-1].w],dp[i-1][j]);
                }else
                {
                    dp[i][j] = dp[i-1][j];
                }
            }

        }
        System.out.println(dp[N][W]);
    }
    static class Sack implements Comparable<Sack>{
        int w,b;
        @Override
        public int compareTo(Sack o) {
            if(w == o.w)
                return 0;
            return w>o.w?1:-1;
        }

        public Sack(int w , int b)
        {
            this.w = w;
            this.b = b;
        }

        @Override
        public String toString() {
            return w+" "+b;
        }
    }
}


Measured memory_bytes: 126668
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 4e2+7, M = 2e5+7;
int n, h, w;
char s[N][N];
bitset<M> vis;
vector<int> vec[M];
int c[M], f[M][2], pa[M];
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
int id(int x, int y)
{
	return (x-1)*w+y;
}
void dfs(int x, int fa)
{
	vis[x] = 1;
	pa[x] = fa;
	f[x][c[x]] = 1;
	//printf("%d %d\n", x, fa);
	for(int i = 0; i < vec[x].size(); i++)
	{
		int y = vec[x][i];
		if(!vis[y])
		{
			dfs(y, x);
			for(int j = 0; j < 2; j++)
			{
				f[x][j] += f[y][j];
			}
		}
	}
	return;
}
int main()
{
	ll ans = 0;
    scanf("%d%d", &h, &w);
	for(int i = 1; i <= h; i++)
	{
		scanf("%s", s[i]+1);
	}
	for(int i = 1; i <= h; i++)
	{
		for(int j = 1; j <= w; j++)
		{
			c[id(i, j)] = (s[i][j]=='#');
			for(int k = 0; k < 4; k++)
			{
				int fx = i+dx[k], fy = j+dy[k];
				if(fx&&fx<=h&&fy&&fy<=w&&s[i][j]!=s[fx][fy])
				{
					vec[id(fx, fy)].push_back(id(i, j));
					vec[id(i, j)].push_back(id(fx, fy));
				}
			}
		}
	}
	int n = h*w;
	for(int i = 1; i <= n; i++)
	{
		if(!vis[i])
		{
		    dfs(i, 0);
			ans += (ll)f[i][0]*f[i][1];
		}
	}
	printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 25600
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
const int MAX = 510000;
const int MOD = 1000000007;

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

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int N, K;
  cin >> N >> K;
  COMinit();
  FOR(i, 1, K + 1) {
    ll cnt = COM(K - 1, i - 1) * COM(N - K + 1, i);
    cnt = cnt % MOD;
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 12160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ALDS1_11_D
{
    class Program
    {
        const int N = 100000;
        static int n;
        static int[] color = new int[N];
        static List<int>[] G = Enumerable.Range(0, N).Select(n => new List<int>()).ToArray();
        static void dfs(int r, int c)
        {
            var S = new Stack<int>();
            S.Push(r);
            color[r] = c;
            while(S.Any())
            {
                int u = S.Pop();
                for (int i = 0; i < G[u].Count; i++)
                {
                    int v = G[u][i];
                    if (color[v] == 0)
                    {
                        color[v] = c;
                        S.Push(v);
                    }
                }
            }
        }
        static void assigncolor()
        {
            int id = 1;
            for (int u = 0; u < n; u++)
                if (color[u] == 0) dfs(u, id++);
        }
        static void Main(string[] args)
        {
            var a = scan();
            n = a[0];
            int m = a[1];

            for (int i = 0; i < m; i++)
            {
                var t = scan();
                G[t[0]].Add(t[1]);
                G[t[1]].Add(t[0]);
            }

            assigncolor();

            int q = scan()[0];
            var sb = new StringBuilder();

            for (int i = 0; i < q; i++)
            {
                var b = scan();
                sb.AppendLine((color[b[0]]==color[b[1]]) ? "yes": "no");
            }
            Console.Write(sb);
        }
        static int[] scan()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }
    }
}

Measured memory_bytes: 25308
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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 <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    string s; cin >> s;
    REP(i,3){
        cout << s[i];
    }
    cout << endl;

}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    int a,b,c,d,p;
    cin >> a >> b >> c >> d >> p;
    int ans = 0;
    ans = p * a;
    if(p > c)
	ans = min(ans,b + d*(p-c));
    else ans = min(ans,b);
    cout << ans << endl;
    return 0;
}

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

void solve()
{
    int n;
    cin >> n;
    if (n >= 30)
        cout << "Yes";
    else
        cout << "No";
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++)
    {
        //cout << "Case #" << i << ": ";
        solve();
    }
}

Measured memory_bytes: 3628