akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Console;

namespace AtCoder_1
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = CinT();
            var t = CinTAr();
            int bre = 0;
            for(int i = 1;i <= n; i++)
            {
                if (i != t[i - 1]) { bre++; }
                if(bre > 2) { break; }
            }
            if(bre <= 2) { Cout("YES"); } else
            {
                Cout("NO");
            }
            Cin();
        }



        static readonly int MOD1E9 = (int)1e9 + 7;
        static string Cin() { return ReadLine(); }
        static string[] CinAr() { return ReadLine().Split(' '); }
        static int CinT() { return S2i(Cin()); }
        static int[] CinTAr() { return CinAr().Select((x, i) => { return S2i(x); }).ToArray(); }
        static long CinL() { return S2L(Cin()); }
        static long[] CinLAr() { return CinAr().Select((x, i) => { return S2L(x); }).ToArray(); }
        static double CinD() { return S2D(Cin()); }
        static double[] CinDAr() { return CinAr().Select((x, i) => { return S2D(x); }).ToArray(); }
        static int S2i(string s) { return int.Parse(s); }
        static long S2L(string s) { return long.Parse(s); }
        static double S2D(string s) { return double.Parse(s); }
        static void OYes() { Cout("Yes"); }
        static void ONo() { Cout("No"); }
        static void Cout(object s) { WriteLine(s); }
        static int[] yakusuu(int n)
        {
            if (n == 1) { return new int[] { 1 }; }
            HashSet<int> res = new HashSet<int>();
            for (int i = 1; i < Math.Ceiling(n / 2.0); i++)
            {
                if (n % i == 0)
                {
                    res.Add(i);
                    res.Add(n / i);
                }
            }
            return res.ToArray();
        }
        /// <summary>
        /// Debug時のみの使用を推奨
        /// </summary>
        /// <typeparam name="Type"></typeparam>
        /// <param name="types"></param>
        static void CoutAr<Type>(IEnumerable<Type> types)
        {
            string text = "";
            foreach (var i in types)
            {
                text += " " + i;
            }
            WriteLine(text.Substring(1));
        }
    }
}


Measured memory_bytes: 13268
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

def main():
  x = int(input())
  ls = list(map(int, input().split()))
  ls.sort()
  if ls[-1] < sum(ls[:-1]):
    print('Yes')
  else:
    print('No')
  pass

if __name__=='__main__':
  main()

Measured memory_bytes: 2940
// How many ways?
// 2020/3/22 08:40 -

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

int main() {
    int n,x;

    while (true){
        
        
        cin >> n >> x;
        if(n==0 && x==0) return 0;
        int sum=0;

        for (int i=1; i < n+1;i++){
            for (int j=i+1; j < n+1;j++){
                for (int k=j+1; k < n+1;k++){

                    // if (i == j || i == k || j==k) break;
                    if ((i + j + k) == x) {
                        sum++;
                    // cout << i <<j<<k<<endl;
                    }

            
                }

            }
        
        }
        cout << sum <<endl;
    }
}







Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll>v;
    for(int i=1;i<10;i++)v.push_back(i);
    int cnt=0;
    while(cnt<n){
        ll x=v[cnt];
        cnt++;
        ll rem=x%10;
        if(rem==0){
            v.push_back(x*10);
            v.push_back((x*10)+1);
        }
        else if(rem==9){
            v.push_back((x*10)+9);
            v.push_back((x*10)+8);
        }
        else{
            v.push_back((x*10)+rem);
            v.push_back((x*10)+rem-1);
            v.push_back((x*10)+rem+1);
        }
    }
    sort(v.begin(),v.end());
    cout<<v[n-1]<<endl;
}


Measured memory_bytes: 7404
import sys
readline = sys.stdin.readline

class Segtree:
    def __init__(self, A, intv, initialize = True, segf = max):
        self.N = len(A)
        self.N0 = 2**(self.N-1).bit_length()
        self.intv = intv
        self.segf = segf
        if initialize:
            self.data = [intv]*self.N0 + A + [intv]*(self.N0 - self.N)
            for i in range(self.N0-1, 0, -1):
                self.data[i] = self.segf(self.data[2*i], self.data[2*i+1]) 
        else:
            self.data = [intv]*(2*self.N0)
        
    def update(self, k, x):
        k += self.N0
        self.data[k] = x
        while k > 0 :
            k = k >> 1
            self.data[k] = self.segf(self.data[2*k], self.data[2*k+1])
    
    def query(self, l, r):
        L, R = l+self.N0, r+self.N0
        s = self.intv
        while L < R:
            if R & 1:
                R -= 1
                s = self.segf(s, self.data[R])
            if L & 1:
                s = self.segf(s, self.data[L])
                L += 1
            L >>= 1
            R >>= 1
        return s
    
    def binsearch(self, l, r, check, reverse = False):
        L, R = l+self.N0, r+self.N0
        SL, SR = [], []
        while L < R:
            if R & 1:
                R -= 1
                SR.append(R)
            if L & 1:
                SL.append(L)
                L += 1
            L >>= 1
            R >>= 1
        
        if reverse:
            for idx in (SR + SL[::-1]):
                if check(self.data[idx]):
                    break
            else:
                return -1
            while idx < self.N0:
                if check(self.data[2*idx+1]):
                    idx = 2*idx + 1
                else:
                    idx = 2*idx
            return idx - self.N0
        else:
            pre = self.data[l+self.N0]
            for idx in (SL + SR[::-1]):
                if not check(self.segf(pre, self.data[idx])):
                    pre = self.segf(pre, self.data[idx])
                else:
                    break
            else:
                return -1
            while idx < self.N0:
                if check(self.segf(pre, self.data[2*idx])):
                    idx = 2*idx
                else:
                    pre = self.segf(pre, self.data[2*idx])
                    idx = 2*idx + 1
            return idx - self.N0


INF = 10**18 + 3
N, E, T = map(int, readline().split())
X = list(map(int, readline().split()))
X = [0] + [x-X[0]  for x in X] + [INF]
E -= X[0]
dp = [0]*(N+2)
dpl = Segtree([0]*(N+2), INF, initialize = False, segf = min)
dpr = Segtree([0]*(N+2), INF, initialize = False, segf = min)
dpl.update(0, 0)
dpr.update(0, 0)

for i in range(1, N+1):
    di = X[i]
    dn = X[i+1]
    ok = i
    ng = -1
    while abs(ok-ng) > 1:
        med = (ok+ng)//2
        if (X[i] - X[med])*2 <= T:
            ok = med
        else:
            ng = med
    left = ok-1
    resr = dpr.query(left, i) + T + di
    resl = dpl.query(0, left) + 3*di
    dp[i] = min(resl, resr)
    dpl.update(i, dp[i] - di - 2*dn)
    dpr.update(i, dp[i] - di)

print(dp[N] + E - X[N])

Measured memory_bytes: 80280
n, s = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
x << s
x.sort_by!{|y| y}
y = []
x.each_with_index do |z, i|
  y << (x[i + 1] - x[i]) if i < n
end
puts y.inject{|a, b| a.gcd(b)}

Measured memory_bytes: 11648
def calc(N):
    n = 0
    for i in range(1,N+1):
        n+=i
        if n>=N:break
    if n!=N:
        print("No")
        return
    print("Yes")
    print(i+1)
    S = [list(range(1,i+1))]
    print(i,*S[0])
    m = i
    for j in range(1,i+1):
        S.append([])
        for s in S[:-1]:
            S[-1].append(s.pop())
        S[-1].extend(range(m+1,m+1+i-j))
        m = max(S[-1])
        print(i,*S[-1])
def main():
    N=int(input())
    calc(N)
main()

Measured memory_bytes: 9280
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int modulo(1e9 + 7);
const int N(1111);
char a[N][N];
int pw(int x, long long n) {
	int res(1);
	if(n < 0) {
		n = 0;
	}
	while(n) {
		if(n & 1) {
			res = (long long)res * x % modulo;
		}
		x = (long long)x * x % modulo;
		n /= 2;
	}
	return res;
}
struct Matrix {
	int a[2][2];
	Matrix() {
	}
};
inline Matrix operator * (const Matrix & a, const Matrix & b) {
	Matrix res;
	for(int i(0); i < 2; i++) {
		for(int j(0); j < 2; j++) {
			res.a[i][j] = 0;
			for(int k(0); k < 2; k++) {
				res.a[i][j] = (res.a[i][j] + (long long)a.a[i][k] * b.a[k][j]) % modulo;
			}
		}
	}
	return res;
}
Matrix pw(Matrix x, long long n) {
	Matrix res;
	res.a[0][0] = res.a[1][1] = 1;
	res.a[0][1] = res.a[1][0] = 0;
	while(n) {
		if(n & 1) {
			res = res * x;
		}
		x = x * x;
		n /= 2;
	}
	return res;
}
int main() {
	int n, m;
    long long k;
	scanf("%d%d", &n, &m);
	cin >> k;
	int h1v(0), h1h(0), degh(0), degv(0), cnt(0);
	for(int i(0); i < n; i++) {
		scanf("%s", &a[i]);
		for(int j(0); j < m; j++) {
			if(i > 0 && a[i - 1][j] == '#' && a[i][j] == '#') {
				h1v++;
			}
			if(j > 0 && a[i][j] == '#' && a[i][j - 1] == '#') {
				h1h++;
			}
			if(i == n - 1 && a[i][j] == '#' && a[0][j] == '#') {
				degv++;
			}
			if(a[i][j] == '#') {
				cnt++;
			}
		}
		if(a[i][0] == '#' && a[i][m - 1] == '#') {
			degh++;
		}
	}
	int ans;
	if(degv == 0 && degh == 0) {
		ans = pw(cnt, k - 1);
	}else if(degv > 0 && degh > 0) {
		ans = 1;
	}else {
		int deg(degv + degh);
		int h1(degv ? h1v : h1h);
		if(k <= 1) {
			ans = 1;
		}else {
			int h(h1), pwdeg(deg);
			Matrix mat;
			mat.a[0][0] = cnt;
			mat.a[0][1] = (modulo - h1) % modulo;
			mat.a[1][0] = 0;
			mat.a[1][1] = deg;
			mat = pw(mat, k - 1);
			h = ((long long)mat.a[0][0] * h1 + (long long)mat.a[0][1] * deg) % modulo;
			ans = (mat.a[0][0] + mat.a[0][1]) % modulo; //(pw(cnt, k - 1) - h + modulo) % modulo;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 1280
#include <cstdio>

using namespace std;

int main()
{
	int n, m;
	
	scanf("%d %d", &n, &m);
	
	int ans = m;
	
	for (int i = 0; i < n; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		m += (a - b);
		if (m < 0) return (!printf("0\n"));
		else ans = m > ans ? m : ans;
	}
	return (!printf("%d\n", ans));
}

Measured memory_bytes: 1024
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

H, W = ri_()
c = [rs() for _ in range(H)]
for ci in c:
    print(ci)
    print(ci)
    

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

const int INF = 1e9;

struct edge
{
	int to,cap,rev;
};

vector<edge> G[100];
bool used[100];

void add_edge(int from,int to,int cap)
{
	G[from].push_back((edge){to,cap,(int)G[to].size()});
	G[to].push_back((edge){from,0,(int)G[from].size()-1});
}

int dfs(int v,int t,int f)
{
	if(v==t)return f;
	used[v] = true;
	for(int i = 0;i<G[v].size();i++)
	{
		edge &e = G[v][i];
		if(!used[e.to]&&e.cap>0)
		{
			int d = dfs(e.to,t,min(f,e.cap));
			if(d>0)
			{
				e.cap -=d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t)
{
	int flow = 0;
	for(;;)
	{
		memset(used,0,sizeof(used));
		int f = dfs(s,t,INF);
		if(f==0)return flow;
		flow+=f;
	}
}

int main()
{
	int n,m;
	cin >> n >> m;
	for(int i = 0;i<m;i++)
	{
		int u,v,c;
		cin >> u >> v >> c;
		add_edge(u,v,c);
	}
	cout<<max_flow(0,n-1)<<endl;
}


Measured memory_bytes: 3180
N, M =list(map(int, input().split()))
LR_list = [list(map(int, input().split())) for _ in range(M)]
get_L = lambda lst: lst[0]
get_R = lambda lst: lst[1]
Lmax = max(map(get_L, LR_list))
Rmin = min(map(get_R, LR_list))
if (Rmin < Lmax):
    print(0)
else:
    print(Rmin - Lmax +1)


Measured memory_bytes: 61452
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;

	VAR(int, n);

	if (n == 1) {
		OUT("Yes")BR;
		OUT(2)BR;
		OUT("1 1 ")BR;
		OUT("1 1 ")BR;
		return 0;
	}
	
	int k;
	bool ok = false;
	REP(i, MAX_N) {
		if (2 * n == i * (i - 1)) {
			ok = true;
			k = i;
			break;
		}
	}
	if (!ok) {
		OUT("No")BR;
		return 0;
	}

	int last = 2;
	
	vector< vector< int > > ans;
	ans.push_back(vector< int >{1, 2});
	ans.push_back(vector< int >{2, 3});
	ans.push_back(vector< int >{3, 1});

	
	for (int range = 2; range < k - 1; range++) {
		last += range;
		vector< int > tmp;
		// debug(range);
		REP(j, range) {
			tmp.push_back(j + last);
		}
		// 新しい部分の追加
		ans.push_back(tmp);

		// last = 4
		REP(j, ans.size()) {
			ans[j].push_back(j + last - 1 + (j < ans.size() - 1 ? 1 : 0));
		}

	}

	OUT("Yes")BR;
	OUT(ans.size())BR;
	// debug(k);
	REP(i, ans.size()) {
		OUT(ans[i].size());
		SP;
		REP(j, ans[i].size()) {
			OUT(ans[i][j])SP;
		}
		BR;
	}

	
  return 0;
}


Measured memory_bytes: 3840
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
int R[MAX],n;

cin >> n;
for(int i=0;i<n;i++) cin>>R[i];

int maxv=R[1]-R[0];
int minv=R[0];

for (int i=1;i<n;i++){
        maxv = max(maxv,R[i] -minv);
        minv = min(minv,R[i]);
}
cout <<maxv<<endl;
return 0;
}

Measured memory_bytes: 3824
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <numeric>
#include <cassert>

using lli = long long int;
lli inf = 1000000007;
using namespace std;

void solve()
{
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;
	int ans = min(N, K) * X + max(0,N-K) * Y;
	cout << ans << endl;
}

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

Measured memory_bytes: 256
#define pb push_back
#define MX 1e18
#define mod 1000000009
#define ff first
#define ss second
#define for1(i,n) for(int i=1;i<=n;i++)
#define for0(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long unsigned  ll;
bool isprime(int n){
  for(int i=2;i*i<=n;i++){
    if(n%i == 0)return false;
  }
  return true;
}
vector<int>v;
int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  for(int i=2;i<=5555;i++)if(isprime(i) && i%10==1 )v.pb(i);
  for0(i,n)cout<<v[i]<<" ";
  return 0;
}


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

#define endl "\n"
#define si(a) scanf("%d ",&a);
#define si2(a,b) scanf("%d %d ",&a,&b);
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sll(a) scanf("%lld ",&a);
#define sll2(a,b) scanf("%lld%lld",&a,&b)
#define sll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sf(a) scanf("%f ",&a);
#define sd(a) scanf("%lf ",&a);
#define sc(a) scanf("%c ",&a);
#define ss(a) scanf("%s ",a);
#define sf2(a,b) scanf("%f %f ",&a,&b);
#define sd2(a,b) scanf("%lf %lf ",&a,&b);
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define forq(i,q,n) for(int i=q;i<n;i++)
#define form(i,n) for(int i=n;i>=0;i--)
#define forp(i,q,n) for(int i=q;i>=n;i--)
#define fi first
#define se second
#define INF 1000000010
#define MOD 1000000007
#define MAXN
#define LL long long int


using namespace std;

int n, m;

void init(){
	si2(n, m);
	if(n == 2 and m == 2) {
		printf("1\n");
		return;
	}
	else 
	{
		int mul = 0;
		mul = (n - 1) * (m - 1);
		//mul = mul -2;
		printf("%d\n", mul);
	}
}

int main(){
	
	init();
	return 0;
}


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

int main() {

	int n, q; cin >> n >> q;
	string s; cin >> s;
	vector<int> accum(n + 1, 0);
	for (int i = 1; i < n; i++) {
		if (s[i - 1] == 'A' && s[i] == 'C') {
			accum[i + 1]++;
		}
		accum[i + 1] += accum[i];
	}
	for (int i = 0; i < q; i++) {
		int l, r; cin >> l >> r;
		int ans = accum[r] - accum[l];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3832
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	
	cout << max(0, c - (a - b))<< endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll,ll>
#define PP pair<P,P>
using namespace std;

int main(){
    int x,y; cin >> x >> y;
    if(x*2<= y && y<=x*4 && (y%2==0)) cout << "Yes" << endl;
    else cout << "No" << endl;
return 0;
}



Measured memory_bytes: 3580
// C++ includes
#include <bits/stdc++.h>
// 俳句
using namespace std;

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    string s;
    ll q;
    ll f;
    char c;
    cin >> s;
    cin >> q;
    vll query(q);
    ll reverse_count = 0;
    REP(i,q){
        cin >> query[i];
        switch(query[i]){
        case 1:
            reverse_count++;
            break;
        case 2:
            cin >> f;
            cin >> c;
            switch(((f-1)+(reverse_count%2))%2+1){
            case 1:
                s.insert(s.begin(), c);
                break;
            case 2:
                s.push_back(c);
                break;            
            default:
                break;
            }
            break;
        default:
            break;
        }
    }
    if(reverse_count % 2 == 1){
        reverse(s.begin(), s.end());
    }
    cout << s;
}

Measured memory_bytes: 2564
N = int(input())
a = [int(s) for s in input().split()]
p = {}

for b in a:
    if b in p:
        p[b] += 1
    else:
        p[b] = 1

ans = 0
for k in p:
    if k > p[k]:
        ans += p[k]
    elif k < p[k]:
        ans += (p[k] - k)

print(ans)

Measured memory_bytes: 21792
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, L: "List[int]"):
    ll = sorted(L)
    return YES if ll[-1] < sum(ll[:-1]) else NO


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 5380
#include<stdio.h>
#include<bitset>
int main()
{
	const int N=65536;
	std::bitset<N>p;
	int i,j,n,r;
	p.set();
	for(i=2;i<N/2;++i)if(p[i])for(j=i*2;j<N;j+=i)p[j]=0;
	while(scanf("%d",&n),n)
	{
		for(r=0,i=j=n/2;i>1;++j)if(p[i--]&&p[j])++r;
		printf("%d\n",r);
	}
	return 0;
}

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

int main(){
  int A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;

  int64_t ans=0;
  if(2*C>A+B){
    ans=A*X+B*Y;
  }
  else{
    ans=2*C*min(X,Y);
    if(2*C>=A){
      ans=ans+A*(X-min(X,Y));
    }
    else{
      ans=ans+2*C*(X-min(X,Y));
    }
    if(2*C>=B){
      ans=ans+B*(Y-min(X,Y));
    }
    else{
      ans=ans+2*C*(Y-min(X,Y));
    }
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
N,M=map(int,input().split())
ans=[-1]*N
for i in range(M):
    s,c=map(int,input().split())
    if ans[s-1]==-1 or ans[s-1]==c:
        ans[s-1]=c
    else:
        print(-1)
        sys.exit()
if N!=1 and ans[0]==0:
    print(-1)
else:
    l=[]
    for i in range(N):
        if N==1 and ans[0]==-1:
            l.append("0")
        elif i==0 and ans[i]==-1:
            l.append("1")
        elif i!=0 and ans[i]==-1:
            l.append("0")
        else:
            l.append(str(ans[i]))
    print("".join(l))


Measured memory_bytes: 3064
#include <stdio.h> 

int main()
{
	int a,b;
	while(scanf("%d %d",&a,&b))	
	{	
	    
		if(a == 0 && b==0)
		{
			break;
		}
		if(a>b)
		{
			printf("%d %d\n",b,a);
		}
	
		else
		{
			printf("%d %d\n",a,b);
		}
		
	}
	 
	return 0;
	
}


Measured memory_bytes: 2576
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<set>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

int parse(string str){
	int ret = 0;
	rep(i,str.size()){
		ret *= 10;
		ret += str[i]-'0';
	}
	return ret;
}

int getval(string str){
	
	
	int rcont=0;
	rep(i,str.size())if(str[i]=='[')rcont++;
	
	if(rcont==0)return (parse(str)+1)/2;
	
	
	int st=0;
	int now=0;
	vector<int> cand;
	reps(i,0,str.size()){
		if(str[i]=='[')now++;
		if(str[i]==']')now--;
		
		if(now==0){
			string next = str.substr(st+1, (i-st-1));
			cand.push_back(getval(next));
			st = i+1;
		}
	}
	
	sort(cand.begin(),cand.end());
	int ret = 0;
	rep(i,(cand.size()+1)/2){
		ret += cand[i];
	}
	
	//cout<<"str="<<str<<" "<<ret<<endl;
	return ret;
}


int main(){
	
	int n;
	cin>>n;
	
	rep(p,n){
		string str;
		cin>>str;
		
		printf("%d\n",getval(str));
	}
}

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

using namespace std;

typedef long long ll;

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

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
ll modpow(ll a,ll b){
  ll r=1;
  while(b){
    if(b&1)r=r*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return r;
}

const int MX = 25212521;
ll fact[MX];
ll ifact[MX];

int h,w,k;

int main(){
  scanf("%d%d%d",&h,&w,&k);
  fact[0] = 1;
  FOR(i,1,MX)fact[i] = fact[i-1]*i%MOD;
  ifact[MX-1] = modpow(fact[MX-1], MOD-2);
  FORR(i,1,MX)ifact[i-1] = ifact[i]*i%MOD;
  ll ans = 0;
  FOR(p,max(0,k-w),min(h,k)+1){
    ll X = p;
    ll Y = k-X;
    ll hPx = fact[h] * ifact[h-X] % MOD;
    ll wPy = fact[w] * ifact[w-Y] % MOD;
    ll val = fact[X+Y+1] * ifact[X] % MOD * ifact[Y+2] % MOD;
    val = val * ifact[3] % MOD * (Y+1) % MOD * (Y+2) % MOD * (2*X*Y%MOD + 3*X + 3*Y + 6) % MOD;
    val = (val - 1ll*fact[X+Y]*ifact[X]%MOD*ifact[Y]%MOD + MOD) % MOD;
    ans += hPx * wPy % MOD * val % MOD;
    ans %= MOD;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 394240
n, m, q = gets.split.map(&:to_i)
num_sets = []
maximum = 0
q.times do
  num_sets << gets.split.map(&:to_i)
end

(1..m).to_a.repeated_combination(n) do |array|
  total = 0
  num_sets.each do |set|
    diff = array[set[1] - 1] - array[set[0] - 1]
    if diff == set[2]
      total += set[3]
    end
  end

  if maximum < total
    maximum = total
  end
end

puts maximum

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());

    int M = a[n - 1];
    int d[1000001] = {0};

    for(int i = 0;i < n;i++){
        for(int j = 1;j*a[i] <= M;j++){
            d[a[i]*j]++;
        }
    }

    /*
    for(int i = 1;i <= M;i++){
        cout << d[i] << " ";
    }

    cout << endl;
    */

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

    cout << ans << endl;

    
}


Measured memory_bytes: 7988
///A drunk man will find his way home, but a drunk bird may get lost forever...i
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef pair <int, int> pii;
#define pb push_back
#define pf push_front
#define f first
#define s second
#define sz(x) (int)x.size()
#define smin(x , y) x = min(x , y)
#define smax(x , y) x = max(x , y)
#define mp make_pair
const int mx = 2000 * 100 + 10, m = 1000 * 1000 * 1000 + 7;
int fact[mx], inv[mx], c[mx], w[mx], t[mx];
bool mark[mx];
vector < int > ad[mx], com;
vector < pii > v[mx], sor;
int _pow(int a, int b){
	if(!b)
		return 1;
	return ((_pow((a * a) % m, b >> 1) * ((b & 1) ? a : 1)) % m);
}
void dfs(int v){
	mark[v] = 1;
	t[c[v]]++;
	com.pb(c[v]);
	for(auto u : ad[v])
		if(!mark[u])
			dfs(u);
	return;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
    cin.tie(0);
	cout.tie(0);
	int n, x, y;
	cin >> n >> x >> y;
	for(int i = 1; i <= n; i++){
		cin >> c[i] >> w[i];
		v[c[i]].pb({w[i] , i});
	}
	fact[0] = 1;
	for(int i = 1; i <= mx; i++)
		fact[i] = (fact[i - 1] * i) % m;
	inv[mx] = _pow(fact[mx] , m - 2);
	for(int i = mx - 1; i >= 0; i--)
		inv[i] = ((inv[i + 1] * (i + 1)) % m);
	for(int i = 1; i <= n; i++){
		if(sz(v[i])){
			sort(v[i].begin() , v[i].end());
			pii s = v[i][0];
			sor.pb(s);
			for(auto u : v[i])
				if(u.f + s.f <= x){
				//	cout << u.s + 1 << " " << s.s + 1 << endl;
					ad[u.s].pb(s.s);
					ad[s.s].pb(u.s);
				}
		}
	}
	sort(sor.begin() , sor.end());
	pii mn1 = sor[0], mn2 = {0 , -1};
	if(sz(sor) > 1)
		mn2 = sor[1];
	for(int i = 1; i <= n; i++){
		if(c[i] != c[mn1.s] && w[i] + mn1.f <= y){
		//	cout << "1 " << i << " " << mn1.f << endl;
			ad[i].pb(mn1.s);
			ad[mn1.s].pb(i);
		}
		else if(mn2.f && w[i] + mn2.f <= y){
		//	cout << "2 " << i << " " << mn2.f << endl;
			ad[i].pb(mn2.s);
			ad[mn2.s].pb(i);
		}
	}
	int ans = 1;
	for(int i = 1; i <= n; i++){
		if(mark[i])
			continue;
		com.clear();
		dfs(i);
		ans *= fact[sz(com)];
		ans %= m;
		for(auto u : com){
//			cout << t[u] << " " << inv[t[u]] << endl;
			ans = (ans * inv[t[u]]) % m;
			t[u] = 0;
		//	t[u]--;
		}
	//	cout << endl;
	//	cout << ans << endl;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 38596
n = int(input())
b = list(map(int, input().split()))

a = [0] * n
a[n - 1] = b[n - 2]

for i in range(n - 2, 0, -1):
    a[i] = b[i]
    if a[i] > b[i - 1]:
        a[i] = b[i - 1]

a[0] = b[0]

print(sum(a))


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ull unsigned long long

int main(){
    ull n,k,i,a[200002]={},machi=1,num=0,loop=0,check[200002]={},ans=0;
    scanf("%lld%lld",&n,&k);
    for (i=1; i<=n; i++) scanf("%lld",&a[i]);
    for (i=1; i<=k; i++) {
        num++;
        if (check[machi]!=0) break;
        check[machi]=i;
        machi=a[machi];
    }
    if (num==k) {
        printf("%lld",machi);
        return 0;
    }
    if (num==2) {
        printf("%d",1);
        return 0;
    }
    loop=num-check[machi];
    ans=(k-check[machi]+1)%loop;
    for (i=1; i<=ans; i++) {
        machi=a[machi];
    }
    printf("%lld",machi);
    return 0;
}





Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

struct UnionFind{
    vector<int> d;
    UnionFind(int n=0):d(n,-1){}
    int root(int x){
        if(d[x]<0)return x;
        return d[x]=root(d[x]);
    }
    bool unite(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return false;
        if(d[x]>d[y])swap(x,y);
        d[x]+=d[y];
        d[y]=x;
        return true;
    }
    bool same(int x,int y){return root(x)==root(y);}
    int usize(int x){return -d[root(x)];}
};

int main() {
    int n,m;cin >>n>>m;
    UnionFind uni(n);
    for (int i = 0; i < m; ++i) {
        int a,b;cin >>a>>b;
        a--;b--;
        uni.unite(a,b);
    }
    vector<bool>used(n,false);
    ll ans=-1;
    for (int i = 0; i < n; ++i) {
        if(!used[uni.root(i)]){
            ans++;
            used[uni.root(i)]=true;
        }
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 3740
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
const ll inf = 1e18;
const ll mod = 1e9 + 7;

ll pow (ll x, ll n){
    ll ans = 1;
    while(n>0){
        if(n & 1 == 1){
            ans *= x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}


int main(){
    int s, w;
    cin >> s >> w;
    string ans;
    if(w >= s){
        ans = "unsafe";
    }else{
        ans = "safe";
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

inline ll pow_five(ll x) { return x * x * x * x * x; }

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll x;
    cin >> x;
    FOR(a, -2000, 2001) FOR(b, -2000, 2001) if (pow_five(a) - pow_five(b) == x)
        return cout << a << ' ' << b, 0;
    return 0;
}

Measured memory_bytes: 3640
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int n,m;
  cin>>n>>m;
  
  dsu d(n);
  
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--,b--;
    d.merge(a,b);
  }
  
  vector<vector<int>> e=d.groups();
  cout<<e.size()-1<<endl;
  
  return 0;
}

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

class dice
{
public:
    int F[6];
    int q1, q2;
    dice();
	void input();
    void roll_a();
    void roll_b();
    bool check(const dice& d);
    bool equal(const dice& d);
};

dice::dice(){}

void dice::input()
{
    int i;
    for(i = 0; i < 6; i++) cin >> F[i];
    q1 = F[0] + F[1] + F[2] + F[3] + F[4] + F[5];
    q2 = F[0] * F[5] + F[1] * F[4] + F[2] * F[3];
}

void dice::roll_a()
{
    int i;
    i = F[0]; F[0] = F[2]; F[2] = F[1]; F[1] = i;
    i = F[3]; F[3] = F[4]; F[4] = F[5]; F[5] = i;
}

void dice::roll_b()
{
    int i;
    i = F[0]; F[0] = F[5]; F[5] = i;
    i = F[1]; F[1] = F[3]; F[3] = i;
    i = F[2]; F[2] = F[4]; F[4] = i;
}
 
bool dice::check(const dice& d)
{
    int l, m;
    if((d.F[0] != F[0]) || (d.F[5] != F[5])) return false;

    for(l = 1; l <= 4; l++){
        for(m = 1; m <= 4; m++){
            if(d.F[m] != F[(l * m) % 5]) break;
        }
        if(m == 5) return true;
    }
    return false;
}

bool dice::equal(const dice& d)
{
    bool eq;
    if((q1 != d.q1) || (q2 != d.q2)) return false;
    for(int i = 0; i < 2; i++){
        eq = check(d);
        if(!eq){ roll_a(); eq = check(d); }
        if(!eq){ roll_a(); eq = check(d); }
        if(eq || i == 1) break;
        roll_b();
    }
    return eq;
}

int main()
{
    dice d[100];
    int n, i, j;

    cin >> n;
    for(i = 0; i < n; i++){ d[i].input(); }

    for(i = 0; i < n; i++){
        for(j = i + 1; j < n; j++){
            if(d[i].equal(d[j])) break;
        }
        if(j < n) break;
    }
    if(i + j == 2 * n){ cout << "Yes"; }else{ cout << "No"; }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1160
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("rawtypes")
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		ArrayList<Integer> x = new ArrayList<Integer>();
		ArrayList<Integer> x_sort = new ArrayList<Integer>();

		for(int i = 0; i < n; i++) {
			int xi = Integer.parseInt(sc.next());
			x.add(xi);
			x_sort.add(xi);
		}
		Collections.sort(x_sort);

		int median_minor = x_sort.get((n / 2) - 1);
		int median_major = x_sort.get(n / 2);

		for(int i = 0; i < n; i++) {
			if(x.get(i) <= median_minor) {
				System.out.println(median_major);
			}else {
				System.out.println(median_minor);
			}
		}

	}

}


Measured memory_bytes: 95848
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int A, B;
    cin >> A >> B;
    cout << max({A+B,A-B,A*B});

    return 0;
}


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

#define int long long
#define pii pair<int, int>
#define pb push_back

int const M = 1e6 + 10;
int b[M];
int spf[M];

void init() {
    for (int i = 2; i < M; i++) {
        for (int j = i; j < M; j += i) {
            if(spf[j] == 0) {
                spf[j] = i;
            }
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int N;
    cin >> N;
    int a[N];
    init();
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int g = a[0];
    bool pw = 1;
    for (int i = 1; i < N; i++) {
        g = __gcd(g, a[i]);
        int X = a[i];
        while (X > 1) {
            int p = spf[X];
            while (X % p == 0) X /= p;
            b[p]++;
            if (b[p] > 1) {
                pw = 0;
                break;
            }
        }
    }
    if(pw == 1) {
        return cout << "pairwise coprime\n", 0;
    }
    if (g == 1) {
        cout << "setwise coprime\n";
    }
    else {
        cout << "not coprime\n";
    }
    return 0;
}



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

string a;
int main()
{
    cin >> a;
    int len = a.length();
    int ans = 0;
    for (int i = 0; i < len; i++)
    {
        int ls = 0;
        while (a[i] == 'R')
            ls++, i++;
        ans = max(ans, ls);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}


int main()
{
        //input->compute->output//
        int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;

        int x=x2;
        int y=y2;
        int dx=x2-x1;
        int dy=y2-y1;

        for(int i=0;i<2;i++){
                swap(dx,dy);
                dx=-dx;
                x+=dx;
                y+=dy;
                cout<<x<<" "<<y<<' ';
        }
        cout<<endl;


        

        return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


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

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

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

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

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

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

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

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

Combination<MOD> com(2010);


int main() {
	int n, k; cin >> n >> k;

	for (int i = 1; i < k+1; i++) {
		cout << com.C(n - k + 1, i)*com.C(k - 1, i - 1)%MOD << endl;;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false

signed main(void){
    int N,K,C;
    string S;
    vector<int> L,R;
    cin >> N >> K >> C;
    cin >> S;
    REP(i,N){
        if(S[i]=='o'){
            L.push_back(i);
            i+=C;
        }
    }
    
    RREP(i,N){
        if(S[i]=='o'){
            R.push_back(i);
            i-=C;
        }
    }
    
    #if debug
    REP(i,L.size()){
        cout <<L[i] << " "; 
    }cout << endl;
    REP(i,R.size()){
        cout <<R[i] << " "; 
    }cout << endl;
    #endif
    
    L.resize(K);
    R.resize(K);
    reverse(R.begin(),R.end());
    
    #if debug
    REP(i,R.size()){
        cout <<R[i] << " "; 
    }cout << endl;
    #endif
    
    REP(i,K){
        if(L[i]==R[i]){
            cout << L[i]+1 << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int x, y;
    cin >> x >> y;
    cout << x + y / 2 << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
vector<vector<ll> > v;
ll dfs(ll now){
	vector<ll> d;
	for(auto& to: v[now]){
		d.pb(dfs(to));
	}
	ll ret = 0;
	sort(be(d));
	reverse(be(d));
	ll idx = 1;
	for(auto& i: d){
		ret = max(ret, idx + i);
		idx++;
	}
	return ret;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, a;
    cin >> n;
    v.resize(n);
    for(int i=1;i<n;i++){
    	cin >> a;
    	v[a-1].pb(i);
    }
    cout << dfs(0) << endl;
    return 0;
}


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

int const N = 15;
char s[N + 1];

int main(){
	scanf("%s", s);
	int n = strlen(s);
	int o = 15 - n;
	f(i, 0, n)o += s[i] == 'o';
	printf("%s\n", o >= 8 ? "YES" : "NO");
}

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

int main() {
  int n;
  while (true) {
    cin >> n;
    if (!n) break;
    vector<int> s(n);
    double m{};
    for (int i{}; i < n; ++i) {
      cin >> s[i];
      m += s[i];
    }
    m /= n;
    double sa{};
    for (int i{}; i < n; ++i) {
      double tmp = s[i] - m;
      sa += tmp * tmp;
    }
    sa /= n;
    cout << fixed << setprecision(4) << sqrt(sa) << endl;
  }

  return 0;
}



Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int N;
  cin >> N;
  vector<long long> vec(3*N);
  rep(i,3*N){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  long long sum=0;
  rep(i,N*2){
    if(i%2==1){
      sum += vec[i];
    }
  }
  cout <<  sum << endl;
}




Measured memory_bytes: 2560
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int a, b, c; cin>>a>>b>>c;

    if(21 < a + b + c) cout << "bust" << endl;
    else cout << "win" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
        int a,b,c;
  char s[101];
    // 整数の入力
    scanf("%d", &a);
    // スペース区切りの整数の入力
    //scanf("%d %d",&b,&c);
    // 文字列の入力
    //scanf("%s",s);
    // 出力
    if(a%2==0){
    printf("%d",a);
    }else{
      printf("%d",2*a);
    }
    return 0;
}

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

int main(){
  int n;
  int a[2][100],b[2][100];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[0][i];
  }
  for(int i=0;i<n;i++){
    cin >> a[1][i];
  }
  b[0][0] = a[0][0];
  b[1][0] = a[0][0] + a[1][0];
  for(int i=1;i<n;i++){
    b[0][i] = b[0][i-1]+a[0][i];
    b[1][i] = max(b[0][i],b[1][i-1])+a[1][i];
  }
  cout << b[1][n-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<ii>;
const ll MOD = 998244353;
const int INF = 1e9+9;
const int MAXN = 102;


int n, m;
string s[MAXN]; int dp[MAXN][MAXN];

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }

    dp[0][0] = s[0][0] == '#';
    for (int j = 1; j < m; ++j) {
        dp[0][j] = dp[0][j-1]+(s[0][j] == '#' and s[0][j-1] != '#');
    }
    for (int i = 1; i < n; ++i) {
        dp[i][0] = dp[i-1][0]+(s[i][0] == '#' and s[i-1][0] != '#');
        for (int j = 1; j < m; ++j) {
            dp[i][j] = min(dp[i-1][j]+(s[i][j] == '#' and s[i-1][j] != '#'),
                           dp[i][j-1]+(s[i][j] == '#' and s[i][j-1] != '#'));
        }
    }
    cout << dp[n-1][m-1] << endl;
}


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

int main(){
  int N;
  cin >> N;
  int y = 0;

  for (int i = 0; i < N; i++){
    string S;
    cin >> S;
    if (S == "Y"){
      y ++;
      break;
    }
  }

  if (y == 1){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }

}

Measured memory_bytes: 256