akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
using namespace std;

int n;
int num[20];
int sle[20];
int ans;

bool check(){
	int i;
	for(i=1;i<=n;i++){
		if((num[i]+sle[i])%2==0)
			return true;
	}
	return false;
}

void DFS(int x){
	if(x==n+1){
		if(check())
			ans++;
		return;
	}
	sle[x]=1;
	DFS(x+1);
	sle[x]=-1;
	DFS(x+1);
	sle[x]=0;
	DFS(x+1);
}

int main(){
	scanf("%d",&n);
	int i;
	for(i=1;i<=n;i++){
		scanf("%d",&num[i]);
	}
	DFS(1);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N >> S;
  
  if (N == 1 &&  N % 2 == 1) {
    cout << "No" << endl;
    return 0;
  } else {
    
    int n = N / 2; 
    string s1, s2;
    for (int i = 0; i < N; i++) {
      if (i < n) s1 += S.at(i);
      else s2 += S.at(i);
    }
    if (s1 == s2)  cout << "Yes" << endl;
    else  cout << "No" << endl;
  }

  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
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(){
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    int n = s.size();
    map<char,vector<int>> m;
    rep(i,n) {
        m[s[i]].push_back(i);
    }
    ll ans = 0;
    int pre_idx = -1;
    map<char, int> cnt;
    rep(i, t.size()) {
        char c = t[i];
        if(m.count(c) == 0) {
            cout << -1 << endl;
            return 0;
        }
        auto idx_itr = lower_bound(m[c].begin()+cnt[c], m[c].end(), pre_idx+1);
        if(idx_itr != m[c].end()) {
            pre_idx = *idx_itr;
        } else {
            cnt.clear();
            pre_idx = -1;
            ans += n;
            auto idx_itr2 = lower_bound(m[c].begin()+cnt[c], m[c].end(), pre_idx+1);
            pre_idx = *idx_itr2;
        }
        cnt[c]++;
    }
    ans += pre_idx+1;
    cout << ans << endl;
}


Measured memory_bytes: 4124
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define in(n) cin>>n>>
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    
    int n,k;
    
    cin >>n>>k ;
    
    if(k==1){
    
    cout << '0' << endl;
    
    }else{
    
    cout << n-k << endl;
    
    }
    
    

return 0;}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int h,n,a[100000],i,j;
    long long sum = 0;
    scanf("%d %d",&h,&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
        sum += a[i];
    }
    if(sum >= h)printf("Yes");
    else printf("No");

}


Measured memory_bytes: 512
package main

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

type plan struct {
	t, x, y int
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func md(from, to plan) int {
	return abs(to.x-from.x) + abs(to.y-from.y)
}

func main() {
	var N int
	fmt.Scan(&N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	plans := make([]plan, N+1)
	for i := 1; i < len(plans); i++ {
		sc.Scan()
		plans[i].t, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		plans[i].x, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		plans[i].y, _ = strconv.Atoi(sc.Text())
	}
	ok := true
	for i := 0; i < N; i++ {
		d := md(plans[i], plans[i+1])
		t := plans[i+1].t - plans[i].t
		if d > t || (t-d)%2 != 0 {
			ok = false
			break
		}
	}
	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll c[110][110], n, p, x, y;
void init(){
	c[0][0] = c[1][1] = c[1][0] = 1;
	for( int i = 2; i <= n; i ++ ){
		c[i][0] = 1;
		for( int j = 1; j <= i; j ++ )
			c[i][j] = c[i-1][j-1] + c[i-1][j];
	}
}
int main()
{
	cin >> n >> p;
	init();
	
	ll a = 0, b;
	for( int i = 1; i <= n; i ++ ){
		cin >> b;
		if( b & 1 ) a ++;
	}
	b = n - a;
// a记奇数
//	cout << b << endl;
	ll ans = 0;
	
	if( p == a & 1 )
		for( int i = 0; i <= a; i += 2 )
			x += c[a][i];
	else 
		for( int i = 1; i <= a; i += 2 )
			x += c[a][i];
	for( int i = 0; i <= b; i ++ )
		y += c[b][i];
	cout << x * y;
	return 0;
}

Measured memory_bytes: 256
a,b = list(map(int,input().split()))

input_lines = [list(map(int,input().split())) for i in range(b)]
input_lines = sorted(input_lines,key=lambda x: x[1]) #各要素において[1]に基づきソートする

c=[0]
for i in input_lines:
    #for j in c:
    #   if j > i[0]:
    #        p=1
    if max(c)<=i[0]:
        c.append(i[1])
        
print(len(c)-1)




Measured memory_bytes: 29864
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  string s ;
  cin >> s ;
  
  s.at(3) = '8' ;
  
  cout << s <<endl ;
  
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
//void inputer();
int N, L;

int main() {
	cin >> N >> L;
	int sum = L + 1 - 1;
	int minN = L + 1 - 1;

	for (int i = 2; i <= N; i++) {
		if (abs(L + i - 1) < abs(minN)) {
			minN = L + i - 1;
		}
		sum += L+i-1;
	}
	cout << sum - minN;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#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 cout << -1 << endl;return 0
#define MM <<" "<<
#define Endl endl



signed main(void){
    const int K = 1000000000;
    int S;
    cin >> S;
    if(S==K*K){
        cout << "0 0 " << K << " 0 0 " << K << endl;
        return 0;
    }
    int a=K-(S%K),b=1+S/K;
    cout << 0 << " " << 0 << " ";
    cout << K << " " << 1 << " ";
    cout << a << " " << b << " ";
    
    
    return 0;
}


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

int main() {
    int N, T, A;
    cin >> N >> T >> A;

    float minDiff = (float)INT_MAX;
    int index =1;
    
    for (int i = 1; i <= N; i++)
    {
        float h;
        cin >> h;
        float diff= (float)abs(T-h*0.006 - A);
        if (diff < minDiff){
            minDiff=diff;
            index = i;
        }        
    }
    
    cout << '\n' << index;
    return 0;
}

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

ll f[610][310][310];
int num[610],h[610],c[610],n,tt;
bool bo[610];

inline int rd()
{
	int x=0,f=1;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

inline ll pls(const ll x,const ll y) { return (x+y<mod)?x+y:x+y-mod; }

int main()
{
	n=rd()*2;
	for (int i=1;i<=n;i++) num[i]=rd();
	tt=0;
	for (int i=1;i<=n;i+=2) if (num[i]>0&&num[i+1]>0) bo[num[i]]=bo[num[i+1]]=true;
	for (int i=1;i<=n;i++) if (!bo[i]) h[++tt]=i;
	int cnt=0;
	for (int i=1;i<=n;i+=2)
	{
		if (num[i]>0&&num[i+1]>0) continue;
		if (num[i]>0) c[lower_bound(h+1,h+tt+1,num[i])-h]=1;
		if (num[i+1]>0) c[lower_bound(h+1,h+tt+1,num[i+1])-h]=1;
		if (num[i]==-1&&num[i+1]==-1) cnt++;
	}
	f[tt][0][0]=1;
	for (int i=tt;i;i--) for (int j=0;j<=n/2;j++) for (int k=0;k<=n/2;k++) if (f[i][j][k])
	{
		if (c[i])
		{
			if (j) f[i-1][j-1][k]=pls(f[i-1][j-1][k],f[i][j][k]);
			f[i-1][j][k+1]=pls(f[i-1][j][k+1],f[i][j][k]);
		}
		else
		{
			if (j) f[i-1][j-1][k]=pls(f[i-1][j-1][k],f[i][j][k]);
			if (k) f[i-1][j][k-1]=pls(f[i-1][j][k-1],f[i][j][k]*k%mod);
			f[i-1][j+1][k]=pls(f[i-1][j+1][k],f[i][j][k]);
		}
	}
	ll ans=f[0][0][0];
	for (int i=1;i<=cnt;i++) ans=ans*i%mod;
	printf("%lld\n",ans);
	return 0;
}

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

namespace ABC098A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, d, e;

            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = a + b;
            d = a - b;
            e = a * b;
            if (c>d&&c>e)
            {
                Console.WriteLine(c);
            }
            else if(d>c&&d>e)
            {
                Console.WriteLine(d);
            }
            else if (e > c && e > d)
            {
                Console.WriteLine(e);
            }
            else if (c==d||c==e)
            {
                Console.WriteLine(c);
            }
            else if ( d == e)
            {
                Console.WriteLine(d);
            }
         
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main(){
    string str;
    cin >> str;
    if (str[str.length()-1] == 's') {
        cout  << str + "es" << endl;
    }
    else {
                cout  << str + "s" << endl;

    }

    return 0;
}

Measured memory_bytes: 3604
N, K = list(map(int, input().split()))
S = input()

rl = 0
lr = 0

happy = 0

for i in range(len(S) - 1):
    if S[i] == S[i+1]:
        happy += 1
    if S[i] == 'R' and S[i+1] == 'L':
        rl += 1
    if S[i] == 'L' and S[i+1] == 'R':
        lr += 1


if K <= min(rl, lr):
    print(happy + 2 * K)
    exit()

print(happy + min(rl, lr) + min(max(rl,lr),K))

Measured memory_bytes: 3316
#include"bits/stdc++.h"
using namespace std;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) <= abs(x - b)) {
		cout << "A" << endl;
		return 0;
	}
	cout << "B" << endl;
	return 0;
}

Measured memory_bytes: 256
n, q, s, t = gets.chomp.split.map(&:to_i)
a = []
(n + 1).times{a << gets.to_i}
b = []
1.upto(n){|i| b << a[i] - a[i - 1]}
plus = minus = 0
b.each{|x|
    plus += x if x >= 0
    minus += x if x < 0
}

q.times{
    l, r, delta = gets.chomp.split.map(&:to_i)
    if b[l-1] >= 0
        if b[l-1] + delta >= 0
            plus += delta
        else
            plus -= b[l-1]
            minus += b[l-1] + delta
        end
    else
        if b[l-1] + delta >= 0
            plus += b[l-1] + delta
            minus -= b[l-1]
        else
            minus += delta
        end
    end
    b[l-1] += delta

    if b[r]
        if b[r] >= 0
            if b[r] - delta >= 0
                plus -= delta
            else
                plus -= b[r]
                minus += b[r] - delta
            end
        else
            if b[r] - delta >= 0
                plus += b[r] - delta
                minus -= b[r]
            else
                minus -= delta
            end
        end
        b[r] -= delta
    end
    puts -plus * s - minus * t 
}


Measured memory_bytes: 10136
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  int N;
  N = S.size();
  char last = S.at(N-1);
  if (last == 's') {
    cout << S + "es"<< endl;
  }
  else {
    cout << S + "s"<< endl;
  }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int n, a;
  vector<int> v1;
  cin >> n;
  REP(i, n) {
    cin >> a;
    v1.push_back(a);
  }
  vector<int> v2(v1);
  sort(v2.rbegin(), v2.rend());

  REP(i, n) {
    if (v1[i] == v2[0]) cout << v2[1] << endl;
    else cout << v2[0] << endl;
  }

  return 0;
}

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

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

  set<int> s;
  int bn = 7 % K; // define (an % 7) as bn
  
  int cnt = 1;
  while(s.count(bn) == 0){
    if (bn == 0){
      cout << cnt << endl;
      return 0;
    }
    s.insert(bn);
    bn = (10 * bn + 7) % K;
	cnt++;
  }
  
  cout << -1 << endl;
  return 0;
}

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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  int ans = 1e9;
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
    if (k - 1 <= i) {
      ans = min(ans, v[i] - v[i - k + 1] + min(abs(v[i]), abs(v[i - k + 1])));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
def print_max_min_sum(args):
    """
    args: a list of integer
    outputs a tuple

    >>> print_max_min_sum([10, 1, 5, 4, 17])
    1 17 37
    """
    print("{0} {1} {2}".format(min(args), max(args), sum(args)))


if __name__ == '__main__':
    cnt = int(input())
    nums = [int(i) for i in input().split(' ')]

    print_max_min_sum(nums[0:cnt])

Measured memory_bytes: 8708
import os, sys, atexit
from io import BytesIO, StringIO
 
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
_OUTPUT_BUFFER = StringIO()
sys.stdout = _OUTPUT_BUFFER
 
@atexit.register
def write():
    sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
n = int(input())
l = list(map(int, input().split()))
l.sort()
vis = [0] * 1000004
for i in l: vis[i] -= -1
for i in range(n):
    tmp = l[i]
    while tmp <= l[n - 1]:
        if vis[tmp]:
            if tmp == l[i]:
                if vis[tmp] > 1: vis[tmp] = 0
            else:
                vis[tmp] = 0
        tmp += l[i]
ans = 0
for i in vis: ans += i
print(ans)

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main(){
    string s;
    cin >> s;
    vi cnt(26);
    rep(i, 4) cnt[s[i]-'A']++;
    bool ok = true;
    rep(i, 26) if (!(cnt[i]==0||cnt[i]==2)) ok = false;
    if (ok) cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


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

#define int long long int
#define ff first
#define ss second
#define pb push_back

int bexp(int a, int b)
{
    int res = 1;

    while (b)
    {
        if (b & 1) res = (res * a);

        a = (a * a); 
        b >>= 1;
    }
    return res;
}

#define N 200010
#define MOD 1000000007

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


int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int n;
    cin >> n;
    cout << (1000 - n % 1000) % 1000;
    return 0;
}


Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int n = input[0];
            int d = input[1];
            List<double[]> X = new List<double[]>();
            foreach(int i in Enumerable.Range(0, n))
            {
                X.Add(Console.ReadLine().Split(' ').Select(s => double.Parse(s)).ToArray());
            }

            int integerCount = 0;
            for(int i = 0; i < n - 1; i++)
            {
                for(int j = i + 1; j < n; j++)
                {
                    double distance = Distance(X[i], X[j]);
                    if (distance == (int)distance) integerCount++;
                }
            }

            Console.WriteLine($"{integerCount}");
        }

        static double Distance(double[] a, double[] b)
        {
            double sum = 0;
            for(int i = 0; i < a.Count(); i++)
            {
                sum += Math.Pow(a[i] - b[i], 2);
            }
            return Math.Sqrt(sum);
        }
    }
}


Measured memory_bytes: 13524
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
    int x,n; cin >> x >> n;
    vector<int> v(102,1);
    for(int i=0; i<n; i++){
        int p; cin >> p;
        v[p] = 0;
    }
    int ans=1e7;
    for(int i=0; i<102; i++) if(v[i]==1) if(abs(x-i)<abs(x-ans)) ans=i;
    cout << ans << "\n";
    return 0;
}

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

const int MOD = 1e9 + 7;
int N;
int a[22][22];
ll dp[23][2200000];

int bitcnt(int n) {
	int ret = 0;
	for (int i = 0; i < 22; i++)
		if (n & (1 << i)) ret++;
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
			cin >> a[i][j];

	dp[0][0] = 1;
	for (int mask = 0; mask < (1 << N); mask++) {
		int i = bitcnt(mask);
		for (int k = 0; k < N; k++) 
			dp[i + 1][mask | (1 << k)] = (dp[i + 1][mask | (1 << k)] + dp[i][mask] * a[i][k]) % MOD;
	}
	cout << dp[N][(1 << N) - 1] << '\n';
	return 0;
}

Measured memory_bytes: 340224
#include <cstring>
#include <cstdint>
#include <iostream>
#include <string>
#include <memory>
#include <queue>
#include <limits>
#include <list>
#include <utility>
#include <sstream>
#include <random>
using namespace std;
long long l = 1e9 + 7;

long long c(long long x) {
	long long out = 1;
	for (long long i = x; i > 0; i--)
	{
		out *= i;
		out %= l;
	}
	return out;
}

int main() {
	int N, M;
	cin >> N >> M;
	long long s = abs(N - M);
	if (s >= 2)cout << 0;
	else if (s == 1) {
		cout << (c(N) * c(M)) % l;
	}
	else {
		cout << (c(N) * c(M) * 2) % l;
	}
	return 0;
}

Measured memory_bytes: 256
//#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <cassert>
#include <fstream>
#include <algorithm>
#include <list>
#include <random>
#include <ctime>
#include <cmath>
#include <random>
#include <bitset>
#include <complex>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define mmin(a, b) a = min(a, (b))
#define mmax(a, b) a = max(a, (b))
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ALL(a) a.begin(),a.end()
#define sqr(x) (x) * (x)
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define cint const int & 
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;

const double PI = 2 * acos(0.0);

template<class T>
void show(const vector<T> &a) {
	for (T x : a)
		cout << x << " ";
	cout << endl;
}


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	string s;
	cin >> s;
	int n = SZ(s);
	set<string> ans;
	int k;
	cin >> k;
	fori(i, n) {
		for (int j = i; j < n && (j - i) < 6; ++j) {
			ans.insert(s.substr(i, j - i + 1));
		}
	}

	for (auto x : ans) {
		--k;
		if (!k) {
			cout << x << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 2176
# Generated by AtcoderGreedy on 2018-05-12
# ARC097 D
# Your code here
$N, $M = gets.chomp.split(' ').map(&:to_i)

$p = gets.chomp.split(' ').map(&:to_i)

$group = (0...$N).to_a

$rank = Array.new($N, 0)

def find(i)
  $group[i] == i ? i : $group[i] = find($group[i])
end

def union(i, j)
  x = find(i)
  y = find(j)

  if $rank[x] < $rank[y]
    $group[x] = y
  else
    $group[y] = x
    $rank[x] += 1 if $rank[x] = $rank[y]
  end
end

$M.times do
  x, y = gets.chomp.split(' ').map(&:to_i)
  union(x - 1, y - 1)
end

$group_num = {}
$N.times do |i|
  $group_num[find($group[i])] ||= []
  $group_num[find($group[i])] << $p[i]
end

$res = []

count = 0
$N.times do |i|
  count += 1 if find($p[i] - 1) == find(i)
end

puts count


Measured memory_bytes: 20996
#include<bits/stdc++.h>
#define INT long long int
#define oo 987654321
#define MOD 1000000007
using namespace std;
INT n, a[200020], dt[200020], m;
vector<INT> b[200020];

INT dp(int x)
{
    if( x == n ) return 1;
    if( ~dt[x] ) return dt[x];
    INT& ret = dt[x];
    ret = dp(x+1);
    int p = (int)(upper_bound(b[a[x]].begin(), b[a[x]].end(), x) - b[a[x]].begin());
    if( p < b[a[x]].size() ) ret += dp(b[a[x]][p]), ret %= MOD;
    return ret;
}

int main()
{
    ios::sync_with_stdio(false);
    memset(dt, -1, sizeof(dt));
    cin>>n;
    for(int i = 0, j = 0, t ; i < n ; i++ )
    {
        cin>>t;
        if( j and t == a[j-1] ) continue;
        a[j++] = t;
        m = j;
    }
    n = m;
    for(int i = 0 ; i < n ; i++ )
        b[a[i]].push_back(i);
    cout<<dp(0)<<endl;
    return 0;
}

Measured memory_bytes: 17408
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1141&lang=jp*/

#include <iostream>

#define N (int)1e6

using namespace std;

int main()
{
	int a,d,n;
	bool not_p[N];
	
	not_p[0]=true;
	for(int i=1;i<N;i++){
		if(!not_p[i]){
			for(int j=2;j*(i+1)-1<N;j++){
				not_p[j*(i+1)-1]=true;
			}
		}
	}
	while(cin>>a>>d>>n && (0<a || 0<d || 0<n)){
		int i=0;
		int j=0;
		while(j<n && a+d*i<N){
			if(!not_p[a+d*i-1]){
				j++;
			}
			i++;
		}
		cout<<a+d*(i-1)<<endl;
	}
	return 0;
}

Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int n, q;

int main()
{
    cin >> n;
    vector<int> s(n);
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    cin >> q;
    int ans = 0;
    vector<int> t(q);
    for (int i = 0; i < q; i++)
    {
        cin >> t[i];
        auto itr = lower_bound(s.begin(), s.end(), t[i]);
        if (itr != s.end() && *itr == t[i])
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename... Types>
struct dynarr: std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto&& operator[](size_type i) { return this->at(i); }
  auto&& operator[](size_type i) const { return this->at(i); }
};

int main() {
  i64 n;
  cin >> n;
  rep(i,1,10) rep(j,1,10) {
    if(i * j == n) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


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

int main()
{
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n)
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    ll ans = 0;
    for (auto &p : mp)
    {
        int s = p.second;
        ans += (ll)s * (s - 1) / 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11136
// "include" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>
// }}}
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	int g = 0,p = 0,sum = 0;
	rep(i,n){
		if(s[i] == 'g'){
			if(g > p){
				++p;
				++sum;
			}
			else ++g;
		}
		else{
			if(g > p) ++p;
			else{
				++g;
				--sum;
			}
		}
	}
	cout << sum << '\n';
	return 0;
}


Measured memory_bytes: 512
loop do
    n = gets.to_i
    break if n == 0
    a = gets.split.map(&:to_i).sort.reverse
    b = gets.split.map(&:to_i).sort.reverse
    puts (1..n-1).find {|i|
        next if i.even?
        a[i-1] > b[(i-1)/2]
    } || 'NA'
end


Measured memory_bytes: 18612
fun main(args: Array<String>) {
    abc127d()
}

private data class Operation(val amount: Int, val value: Long)

fun abc127d() {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val numbers = readLine()!!.split(" ").map { it.toLong() }
        .sorted().toMutableList()
    val operations = (1..m).map { readLine()!!.split(" ").map { it.toLong() } }
        .map { Operation(it[0].toInt(), it[1]) }.sortedByDescending { it.value }

    val changeValues = mutableListOf<Long>()
    op@ for (operation in operations) {
        val changeValue = (1..operation.amount).map { operation.value }
        for (cv in changeValue) {
            if (changeValues.size >= n) break@op
            changeValues.add(cv)
        }
    }

    numbers.addAll(changeValues)
    numbers.sort()

    val answer = numbers.drop(changeValues.size).sum()

    println(answer)
}


Measured memory_bytes: 102572
#!/usr/bin/env fsharpi

open System;

let readIntN ( str : string ) =
    str.Split(' ')
    |> Array.map System.Int32.Parse

let readInt1 ( str : string ) =
    readIntN str |> fun arr -> arr.[0]

let readInt2 ( str : string ) =
    readIntN str |> fun arr -> (arr.[0],arr.[1])

let readInt3 ( str : string ) =
    readIntN str |> fun arr -> (arr.[0],arr.[1],arr.[2])

let s = Console.ReadLine()
let ss = s.Split( ' ' )
let aa = System.Int32.Parse ss.[0]
let bb = System.Int32.Parse ss.[2]
let res = if ss.[1] = "+" then  aa + bb else aa - bb
Console.WriteLine res



Measured memory_bytes: 11092
//code by parshuram_84
#include<bits/stdc++.h>
#define mod 1000000007
#define pii pair<int,int>
#define pll pair<long long,long long>
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define vp vector<pair<long long,long long>>
#define vpp vector<pair<pair<long long,long long>,long long>>
using namespace std;

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

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define read ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define debug(x) cout<<#x<<": "<<x<<endl;
#define debug2(x, y) cout<<#x<<": "<<x<<"  |  "<<#y<<": "<<y<<endl;
#define forr(i, s, n) for(ll i=(s); i<(int)(n); ++i)
#define forn(i, n) forr(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define clr(v, a) memset(v, a, sizeof v);
#define pb(n) push_back(n)
#define fst first
#define snd second
#define endl '\n'
#define INF 2e9 + 5
#define LINF 1e18l + 5l
#define MOD 1000000007
#define EPS 1e-7
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<string> vs;
#define MAX 100010
int n,m;
vi v[MAX];
int maxv[MAX];
map<pair<int, int> , int> dp;
int run(int idx) {
    if(maxv[idx] != -1) {
        return maxv[idx];
    }
    int tmx = 0;
    forn(i, v[idx].size()) {
        int u = v[idx][i];
        if(dp[{i, u}] == 0) {
            dp[{i, u}] = run(u) + 1;
            // debug2("r", idx);
            // debug2(u, (dp[{i, u}]));
            tmx = max(tmx, dp[{i, u}]);
        } else {
            tmx = max(tmx, dp[{i, u}]);
        }
    }
    return maxv[idx] = tmx;
}
int main(){
    read;
    cin>>n>>m;
    clr(maxv, -1);
    forn(i, m) {
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
    }
    int mx = 0;
    forr(i, 1, n + 1) {
        int p = run(i);
        mx = max(mx, p);
    }
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 18560
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int a;
    string s;
    cin >> a >> s;
    if(a < 3200) {
        cout << "red" << endl;
    } else {
        cout << s << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int digits(ll m){
    int re = 0;
    while(m > 0){
        m /= 10;
        re++;
    }
    return re;
}
int main(){
    ll n; cin >> n;
    ll ans;
    ll ans_min = 10000000;
    for(ll i = 1; i <= sqrt(n); i++){
        ll j = n / i;
        if(i * j == n){
            ans = max(digits(i), digits(j));
            ans_min = min(ans, ans_min);
        }
    }
    cout << ans_min << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
    int A, B;
    cin >> A >> B;
    if (A == 1){
      A = 14;
    }
    if (B == 1){
      B = 14;
    }  
    if (A > B){
      cout << "Alice" << endl;
    }
    else if (A == B){
      cout << "Draw" << endl;
    }
    else{
      cout << "Bob" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

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

  if (A == B) cout << "H" << endl;
  else cout << "D" << endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <cstdio>
#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
using namespace std;
int main()
{
	int e; while (cin >> e , e)
	{
		int m = 214214, x = 0;
		rep(z, 101) rep(y, 1001)
		{
			x = e - (y * y + z * z * z);
			if (e == x + (y * y) + (z * z * z) && x >= 0 ) 
			{ m = min(x + y + z, m); }
		}
		printf("%d\n", m);
	}
	return 0;
}

Measured memory_bytes: 3112
a=input()
b=input()
cnt=0
passw=''
if (len(a)-len(b))==1:
  while 1:
      passw=passw+a[cnt]+b[cnt]
      cnt=cnt+1
      if (cnt+1)>len(b):
        passw=passw+a[cnt]
        break
else:
  while 1:
      passw=passw+a[cnt]+b[cnt]
      cnt=cnt+1
      if (cnt+1)>len(b):
        break
print(passw)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const  int mod = 1000000007;
void add(ll& a, ll b)
{
    a+=b;
    while(a>=mod)
        a-=mod;
    while(a<0)
        a+=mod;
    
}

int main()
{
	ll n,m; cin>>n>>m;
	ll a[n];
	ll sum = 0;
	for(int i = 0; i < n ;i ++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	sort(a,a+n,greater<ll>());
	ll tot;
	bool cant = false;
	for(int i = 0 ; i < m ; i++)
	{
		if(a[i]<(sum+4*m-1)/(4*m))
			cant = true;
	}
	if(!cant)
	cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

  	return 0;
}

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

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

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		UnionFindTree uft = new UnionFindTree(n);
		for (int i = 0; i < m; i++) {
		    uft.unite(sc.nextInt() - 1, sc.nextInt() - 1);
		}
		int count = uft.getCount();
		System.out.println(count - 1);
	}
	
	static class UnionFindTree {
	    int[] parents;
	    
	    public UnionFindTree(int size) {
	        parents = new int[size];
	        for (int i = 0; i < size; i++) {
	            parents[i] = i;
	        }
	    }
	    
	    public int find(int x) {
	        if (x == parents[x]) {
	            return x;
	        } else {
	            return parents[x] = find(parents[x]);
	        }
	    }
	    
	    public boolean same(int x, int y) {
	        return find(x) == find(y);
	    }
	    
	    public void unite(int x, int y) {
	        if (!same(x, y)) {
	            parents[find(x)] = find(y);
	        }
	    }
	    
	    public int getCount() {
	        HashSet<Integer> set = new HashSet<>();
	        for (int i = 0; i < parents.length; i++) {
	            set.add(find(i));
	        }
	        return set.size();
	    }
	}
}


Measured memory_bytes: 58940
#include <cstdio>
typedef long long ll;
int main() {
	ll n;
	scanf("%lld", &n);
	for (int i = 1; i <= 3500; i++) {
		for (int j = 1; j <= 3500; j++) {
			ll t = 4 * i * j - n * i - n * j;			
			if (t > 0 && i * j * n % t == 0) {
				printf("%d %d %lld\n", i, j, i * j * n / t);
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 128
import java.util.HashSet;
import java.util.Set;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Set<String> dic = new HashSet<String>();

        String cmd;
        String str;
        int times = sc.nextInt();

        for(int i = 0; i < times; i++){
            cmd = sc.next();
            str = sc.next();

            if(cmd.equals("insert"))
                dic.add(str);

            if(cmd.equals("find")){
                if(dic.contains(str))
                    System.out.println("yes");
                else
                    System.out.println("no");
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 209508
import Control.Monad
import Data.Bool
import Data.List

readInt = readLn :: IO Int
readInts = map read . words <$> getLine :: IO [Int]
readNInts = flip replicateM readInts

main :: IO ()
main = do
    [a, b, c] <- readInts
    print $ if (a * c) <= b
               then c
               else b `div` a


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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+123;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define MP make_pair
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ a%=MOD;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=MOD;--b;}a*=a;a%=MOD;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///


void _case()
{
    ll i,n;
    string a;
    cin>>n>>a;
    if(sz(a)>n){
        for(i=0;i<n;i++) cout<<a[i];
        cout<<"..." el;
    }
    else cout<<a el;

}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class D {
	ll k;
	const ll n{ 50 };
public:
	D()
	{
		cin >> k;
	}
	void solve()
	{

		if (k == 0)
		{
			cout << 2 << endl;
			cout << "1 1" << endl;
			return;
		}

		vll ans(n);
		REP(i, n)
			ans[i] = i + 1;

		ll r{ k % 50 };

		REP(i, n)
			ans[i] += (k - 1) / 50;

		//if (!r)
		//{
		//	REP(i, n)
		//		--ans[i];
		//}

		if (r)
		{
			REP(i, n - r)
			{
				--ans[i];

			}
		}
	

		cout << n << endl;
		REP(i, n - 1)
			cout << ans[i] << " ";
		cout << ans[n - 1] << endl;

	}
};


int main()
{
	D solution;
	solution.solve();

	return 0;
}

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

int main()
{
    int x;
    int y;
    bool bLoop = true;
    
    while (bLoop)
    {
        cin >> x >> y;
        
        if ((x == 0) && (y == 0))
        {
            bLoop = false;
        }
        else
        {
            if (x < y)
            {
                cout << x << " " << y << endl;
            }
            else
            {
                cout << y << " " << x << endl;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 2988
#include <cstdio>

using namespace std;
int k;
int gcd_2(int x,int y){return y?gcd_2(y,x%y):x;}
int gcd_3(int x,int y,int z){return gcd_2(gcd_2(x,y),z);}
long long sum=0;
int main(){
    scanf("%d",&k);
    for(int a=1;a<=k;a++)
        for(int b=1;b<=k;b++)
            for(int c=1;c<=k;c++)
                sum+=gcd_3(a,b,c);
    printf("%lld",sum);
    return 0;
}

Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_NO(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("NO\n");
}

void deb_p(pii p) { printf("pair = %d %d\n", p.fi, p.se); }
void deb_i(int i) { printf("i = %d\n", i); }
void deb_v(vector<int> v) {
  printf("v = ");
  for (auto i : v) printf("%d ", i);
  printf("\n");
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

set<vi> st;
int ans = 0;

void f(vi v, int n, int m, int x) {
  if (x == n) {
    st.insert(v);
    return;
  }

  rep2(i, min(v[max(0, x - 1)], m), m) {
    v[x] = i;
    f(v, n, m, x + 1);
  }
}
int g(vi v, vi a, vi b, vi c, vi d) {
  int res = 0;
  rep(i, size(a)) if (v[b[i]] - v[a[i]] == c[i]) res += d[i];
  return res;
}

void solve(void) {
  int n, m, q;
  cin >> n >> m >> q;
  vi a(q), b(q), c(q), d(q);
  rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i], --a[i], --b[i];
  vi v;
  rep(i, n) v.pb(0);
  f(v, n, m, 0);

  for (auto& i : st) chmax(ans, g(i, a, b, c, d));
  cout << ans << endl;
}
int main(void) { solve(); }


Measured memory_bytes: 13688
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a;
    for(int i=0;i<n;i++) {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    int max_diff = 0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            int diff = abs(a[i]-a[j]);
            if (diff>=max_diff) max_diff = diff;
        }
    }
    cout << max_diff << endl;
    
}

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

int main() {
  int n;
  string s;
  long long sum = 0;
  cin >> n;
  cin >> s;
  long long r = 0, g = 0, b = 0;
  for (int i = 0; i < n; i++) {
    if (s.at(i) == 'R') r++;
    else if (s.at(i) == 'G') g++;
    else b++;  
  }
  sum = r * g * b;
  for (int j = 1; j < n; j++) {
    int i = j - 1, k = j + 1;
    while (i>=0 && k <= n-1)
    {
      if ((s.at(i) != s.at(j)) && (s.at(i) != s.at(k)) && (s.at(j) != s.at(k))) {
        sum--;
      }
      i--;
      k++;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3640
# xor battle


def is_included(base, X):
    base.sort(reverse=True)
    V = X
    for x in base:
        V = min(V, V ^ x)
    return V


def solve():
    N = int(input())
    a = list(map(int, input().split()))[::-1]
    player = input()[::-1]
    basement = [0]
    for i in range(N):
        v = a[i]
        K = is_included(basement, v)
        if player[i] == "0":
            if K == 0:
                pass
            else:
                basement.append(K)
        else:
            if K == 0:
                pass
            else:
                return 1

    return 0


def main():
    T = int(input())
    for i in range(T):
        A = solve()
        print(A)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 9264
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (ll i = (ll)(start); i < (ll)(n); ++i)
static const int INFTY = (1 << 30);
ll N, M;
void func()
{
    cin >> N;
    ll tmp(0), i(1);
    while (tmp < N)
    {
        tmp += powl(26l, i);
        ++i;
    }
    --i; //文字数
    // cout << i << endl;
    string ans;
    ans.resize(i);
    rep(j, 0, i)
    {
        if (N % 26l)
        {
            ans[i - j - 1] = (N % 26l) + 'a' - 1;
            N /= 26l;
        }
        else
        {
            ans[i - j - 1] = 'z';
            N = N / 26l - 1;
        }
    }
    // rep(j, 0, i) { cout << ans[i]; }
    cout << ans << endl;
}
int main()
{
    func();
}


Measured memory_bytes: 3748
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        int[] num = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        int W = num[0]; int H = num[1]; int x = num[2]; int y = num[3]; int r = num[4];

        if (x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H && x - r >= 0 && y + r <= H && x + r <= W && y - r >= 0)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 9436
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
ll a[100005] = {};
int main() {
	ll N, M;
	cin >> N >> M;
	ll ans;
	if (N*2 <=  M) {
		ans = N + (M - 2 * N) / 4;
	}
	else {
		ans = M / 2;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  long long N;
  cin >> N;
  vector<long long> sum(N+1,0),A(N+1);
  long long ans,preN;
  for(int i=0; i<=N; i++){
    cin >> A[i];
  }
  if(N == 0){
    if(A[0] == 1) cout << 1;
    else cout << -1;
    return 0;
  }
  sum[N] = A[N];
  for(int i=N-1; i>=0; i--){
    sum[i] = A[i] + sum[i+1];
  }
  
  if(A[0] != 0){
    cout << -1;
    return 0;
  }
  ans = 1;
  preN = 1;
  for(int i=1; i<=N; i++){
    if(preN * 2 >= sum[i]){
      ans += sum[i];
      preN = sum[i] - A[i];
    }
    else if(preN*2 >= A[i]){
      ans += preN*2;
      preN = preN*2 - A[i];
    }
    else{
      cout << -1;
      return 0;
    }
  }
  cout << ans; 
  return 0;
}

Measured memory_bytes: 4844