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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

#define mod (1000000007)


// dp[i][c3][c2][c1] := i 個の文字までで3,2,1個前がそれぞれc3,c2,c1となっているものの個数
lli dp[101][4][4][4];


int main() {
    lli n;
    cin1(n);

    // 0: A
    // 1: C
    // 2: G
    // 3: T
    // 初期化
    REP(c2, 0, 4) {
        REP(c1, 0, 4) {
            REP(c0, 0, 4) {
                if ( (c2 == 0 && c1 == 2 && c0 == 1) || // AGC
                     (c2 == 0 && c1 == 1 && c0 == 2) || // ACG
                     (c2 == 2 && c1 == 0 && c0 == 1) )  // GAC
                    continue;
                dp[3][c2][c1][c0] = 1;
            }
        }
    }

    REPE(i, 4, n) {
        REP(c3, 0, 4) {
            REP(c2, 0, 4) {
                REP(c1, 0, 4) {
                    REP(c0, 0, 4) {
                        // AGC
                        if ( (c2 == 0 && c1 == 2 && c0 == 1) || // AGC
                             (c2 == 0 && c1 == 1 && c0 == 2) || // ACG
                             (c2 == 2 && c1 == 0 && c0 == 1) || // GAC
                             (c3 == 0 && c1 == 2 && c0 == 1) || // A*GC
                             (c3 == 0 && c2 == 2 && c0 == 1))   // AG*C
                            continue;
                        dp[i][c2][c1][c0] = (dp[i][c2][c1][c0] + dp[i-1][c3][c2][c1]) % mod;
                    }
                }
            }
        }
    }

    lli ans = 0;
    REP(c2, 0, 4) {
        REP(c1, 0, 4) {
            REP(c0, 0, 4) {
                ans = (ans + dp[n][c2][c1][c0]) % mod;
            }
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
using namespace std;
#define vel vector<long long>
#define vvel vector<vel>
#define veb vector<bool>
#define int long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
#define fin(fl,s) if(fl){cout<<s<<endl;return 0;}
long long p = 1000000007;
vel kai(200001, 1);
vel ink(200001, 1);
int le = (1 << 20) + 1;
vel BIT(le, 0);
template<typename T>
V<T> uni(V<T> &list) {
	if (list.size() == 0) { return list; }
	sort(list.begin(), list.end());
	V<T> ql(1, list[0]);
	rep(i, list.size() - 1) {
		if (list[i] != list[i + 1]) { ql.push_back(list[i + 1]); }
	}
	list = ql;
	return ql;
}
void update(int i,int pl) {
	while (i <le) {
		BIT[i] += pl; BIT[i] %= p;
		i += (i & (-i));
	}
}
int cal(int i) {
	int ans = 0;
	while (i > 0) {
		ans += BIT[i];
		i -= (i & (-i));
	}
	return ans;
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, 200000) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, 200001) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p; ans *= ink[n - r]; ans %= p;
	return ans;
}
int per(int n, int r) {
	int ans = kai[n] * ink[n - r];
	ans %= p;
	return ans;
}
signed main() {
	int n, m; cin >> n >> m;
	vel x(n); vel y(m);
	vel l(0); vel r(0);
	rep(i, n) { cin >> x[i]; }
	rep(i, m) { cin >> y[i]; }
	rep(i, n) {
		auto itr = upper_bound(y.begin(), y.end(), x[i]);
		if (itr != y.begin() and itr!=y.end()) {
			r.push_back(*itr - x[i]);
			itr--;
			l.push_back(x[i] - *itr);
		}
	}
	int sz = l.size();
	V<pin> pa(sz);
	rep(i, sz) { pa[i] = mkp(r[i], -l[i]); }
	uni(pa);
	sz = pa.size();
	vel v(sz);
	rep(i, sz) { v[i] = -pa[i].second; }
	vel mv = v; uni(mv);
	rep(i, sz) { v[i] = lower_bound(mv.begin(), mv.end(), v[i]) - mv.begin(); }
	rep(i, sz) {
		int cm = cal(v[i])+1;
		update(v[i] + 1, cm%p);
	}
	cout << (BIT[le - 1]+1)%p << endl;
	return 0;
}

Measured memory_bytes: 21092
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<vector>
#include<deque>
#include<map>
using namespace std;

int main() {
	int n,max=0,m=0;
	char str[1001];
	scanf("%d %s", &n,&str);
	for (int i = 0; i < n; i++) {
		if (str[i] == 'I')m++;
		else if (str[i]=='D')m--;
		if (max < m)max = m;
	}
	printf("%d\n", max);
}


Measured memory_bytes: 384
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}


int main()
{
#if defined(_DEBUG) 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	cout.tie(NULL);

	int n;
	cin >> n;

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

	if (n % 2 == 1)
	{
		for (int i = n - 1; i >= 0; i--)
		{
			if (i % 2 == 1)
				continue;
			cout << x[i] << " ";
		}

		for (int i = 0; i < n; i++)
		{
			if (i % 2 == 0)
				continue;
			cout << x[i] << " ";
		}
	}
	else
	{
		for (int i = n - 1; i >= 0; i--)
		{
			if (i % 2 == 0)
				continue;
			cout << x[i] << " ";
		}

		for (int i = 0; i < n; i++)
		{
			if (i % 2 == 1)
				continue;
			cout << x[i] << " ";
		}
	}


	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <string>

int main()
{
    int cnt = 0;

    std::string S;
    std::string T;

    std::cin >> S;
    std::cin >> T;

    for (int i = 0; i < 3; i++)
    {
        if (S[i] == T[i])
        {
            cnt++;
        }
    }

    std::cout << cnt << std::endl;
}


Measured memory_bytes: 256
n, m, k = map(int, input().split())
cells = [[''] * m for i in range(n)]

def count_black(num1, num2):
    num1 = bin(num1)[2:].rjust(n, '0')
    num2 = bin(num2)[2:].rjust(m, '0')
    blacky = 0
    for i in range(n):
        for j in range(m):
            if num1[i] != '1' and num2[j] != '1' and cells[i][j] == '#':
                blacky += 1
    return blacky == k

def get_ways(r, c):
    result = 0
    for i in range(0, 2 ** r):
        for j in range(0, 2 ** c):
            ans = count_black(i, j)
            result += 1 if ans else 0
    return result

for i in range(n):
    string = input()
    for j in range(m):
        cells[i][j] = string[j]

num_ways = get_ways(n, m)
print(num_ways)

Measured memory_bytes: 68484
N = gets.to_i
A,B = gets.split.map(&:to_i)
array = gets.split.map(&:to_i)
first = []
second = []
third = []
array.each{|x|
  if x <= A
    first << x
  elsif x > A && x <= B
    second << x
  elsif x > B
    third << x
  end
}
size = [first.size,second.size,third.size]
puts size.min


Measured memory_bytes: 1916
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int d;
    cin >> d;
    while(d){
        int r = d % 10;
        if(r == 7){
            cout << "Yes";
            return 0;
        }
        d /= 10;
    }
    cout << "No";
}









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

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


LL solve(vector<LL>& a){
    LL res = 0;
    for(LL d = 60; d >= 0; --d){
        LL cur = -1;
        for(LL i = 0; i < a.size(); ++i){
            if(a[i] & (1LL<<d)) cur = i;
        }
        if(cur < 0) continue;
        if((res & (1LL<<d)) == 0){
            res ^= a[cur];
        }
        for(LL i = 0; i < a.size(); ++i){
            if(a[i] & (1LL<<d)) a[i] ^= a[cur];
        }
    }
    return res;
}

int main(){
    LL n;
    cin >> n;
    vector<LL> a(n);
    for(LL i = 0; i < n; ++i){
        cin >> a[i];
    }
    vector<LL> cnt(61);
    for(LL i = 0; i < n; ++i){
        for(LL j = 0; j < 61; ++j){
            if((a[i]>>j)&1) cnt[j] += 1;
        }
    }
    LL ans = 0;
    LL mask = 0;
    for(LL j = 0; j < 61; ++j){
        if(cnt[j] % 2 == 1){
            ans += (1LL << j);
        }else{
            mask |= (1LL << j);
        }
    }
    for(LL i = 0; i < n; ++i){
        a[i] = (a[i] & mask);
    }
    ans += solve(a) * 2;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long sum,a[305][305];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
			cin>>a[i][j];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<i;j++)
		{
			long long t=a[i][j]+1;
			for(int k=0;k<n;k++)
			{
				if(i==k||j==k)
					continue;
				t=min(t,a[i][k]+a[k][j]);
			}
			if(t<a[i][j])
			{
				cout<<"-1";
				return 0;
			}
			if(t>a[i][j])
				sum+=a[i][j];
		}
	}
	cout<<sum;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int A, B;
  cin >> A >> B;
  cout << max(0, A-2*B) << endl;
  return 0;
}

Measured memory_bytes: 3084
import java.util.Scanner;
import java.util.ArrayList;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();
		ArrayList<Integer> zero=new ArrayList<>();
		ArrayList<Integer> one=new ArrayList<>();
		boolean ch=false;
		boolean ii=false;
		if(s.charAt(0)=='1'){
			ch=false;
			ii=false;
		}else{
			ch=true;
			ii=true;
		}
		for(int i = 0; i<n; i++){
			if(s.charAt(i)=='1' && !ch){
				one.add(i);
				ch=true;
			}else if(s.charAt(i)=='0' && ch){
				zero.add(i);
				ch=false;
			}
		}
		if(zero.size()==0){
			System.out.println(s.length());
			return;
		}
		int ans=0;
		int sub=0;
		for(int i=0; i<=zero.size()-k; i++){
			if(k+i<zero.size()){
				ans=Math.max(ans,zero.get(k+i)-sub);
				if(ii){
					sub=one.get(i);
				}else{
					sub=one.get(i+1);
				}
			}else{
				ans=Math.max(ans,s.length()-sub);
			}
		}
		if(k>zero.size()){
			ans=s.length();
		}
		System.out.println(ans);
	}
}


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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  vector<int> A(N+1);
  vector<int> ten(N+1);
  vector<int> ch(N+2);
  ten.at(0)=1;
  for(int i=0;i<N;i++){
    A.at(i+1) = A.at(i) + (S[N-i-1]-'0')*ten.at(i);
    A.at(i+1) %= 2019;
    ten.at(i+1)=ten.at(i)*10%2019;
  }
  int s=0;
  for(int i=0;i<N-3;i++){
    if(ch.at(i))
      continue;
    vector<int> a;
    for(int j=i+4;j<=N;j++){
      if((A.at(j)-A.at(i)) % 2019 == 0) {
        s++;
        ch.at(j)=1;
        j+=3;
        a.push_back(j);
      }
    }
    int b=a.size();
    s += b*(b-1)/2;
  }
  cout << s << endl;
}




Measured memory_bytes: 6012
#include<stdio.h>
int main()
{
    long long int r,d,x,i;
    scanf("%lld%lld%lld",&r,&d,&x);
    for(i=1;i<=10;i++)
    {
        x=x*r-d;
        printf("%lld\n",x);
    }
    return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


typedef vector<vector<ll>> mat;

// 行列A*Bの計算
mat mulmod(mat &A, mat&B){
    mat C((int)A.size(), vector<ll>((int)B.size()));
    for(int i=0; i<(int)A.size(); ++i){
        for(int j=0; j<(int)B[0].size(); ++j){
            for(int k=0; k<(int)B.size(); ++k){
                C[i][j] += A[i][k] * B[k][j];
                chmod(C[i][j]);
            }
        }
    }
    return C;
}

// A^nの計算
mat matrixpowmod(mat A, ll n){
    mat B((int)A.size(), vector<ll>((int)A.size(), 0));
    for(int i=0; i<(int)A.size(); ++i) B[i][i] = 1;

    while(n>0){
        if(n&1) B = mulmod(B, A);
        A = mulmod(A, A);
        n >>= 1;
    }
    return B;
}


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

    ll n, k; cin >> n >> k;
    vector<vector<ll>> a(n, vector<ll>(n));
    rep(i, n) rep(j, n) cin >> a[i][j];

    mat C=matrixpowmod(a, k);

    ll ans=0;
    rep(i, n) rep(j, n){
        ans+=C[i][j];
        chmod(ans);
    }
    cout << ans << endl;

    return 0;
}


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

namespace ABC138A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            if (a >= 3200)
            {
                Console.WriteLine(s);
            }
            else
            {
                Console.WriteLine("red");
            }
        }
    }
}


Measured memory_bytes: 27412
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
	return *(int *)a - *(int *)b;
}

int main(void)
{
	int i, j;
	//  dic_t dic[200000];
	int ii[100];
	int ilen[100];
	int min, max;
	int len, flg;
	int cnt, maxcnt;
	int yy500,zz500;
	int yy5,zz5;
  
  scanf("%d", &len);
//	printf("len %d\n",len);
	yy500 = len/500;
  	zz500 = len%500;
	yy5 = zz500/5;
//  printf("yy %d  zz %d\n",yy500,zz500);
  printf("%d\n",yy500*1000+yy5*5);
  
	return 0;
}


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 100 + 10;
const int MOD = 1e9 + 7;


int a[N][N];
int h , w , n;
int32_t main(){
    boost;
    //code
    
    cin >> w >> h >> n;
    int x , y , pt;

    vector<pair<int,int>> v;
    for(int i =  0 ; i < n ; ++i){
    	cin >> x >> y >> pt;

    	if(pt == 1 or pt == 2){
    		v.push_back({x,pt});
    	}
    	else{
    		v.push_back({y,pt});
    	}
    }

    for(int i = 0 ; i < n ; ++i){
    	x = v[i].first;
    	pt = v[i].second;

    	if(pt == 1){
    		for(int j = 0 ; j < h ; ++j){
    			for(int k = 0 ; k < x ; ++k){
    				a[j][k] = 1;
    			}
    		}
    	}
    	else if(pt == 2){
    		for(int j = 0 ; j < h ; ++j){
    			for(int k = x ; k < w ; ++k){
    				a[j][k] = 1;
    			}
    		}
    	}
    	else if(pt == 3){
    		for(int j = 0 ; j < w ; ++j){
    			for(int k = 0 ; k < x ; ++k){
    				a[k][j] = 1;
    			}
    		}
    	}
    	else{
    		for(int j = 0 ; j < w ; ++j){
    			for(int k = x ; k < h ; ++k){
    				a[k][j] = 1;
    			}
    		}
    	}
    }
    int cnt = 0;
    for(int i = 0 ; i < h ; ++i){
    	for(int j = 0 ; j < w ; ++j){
    		if(!a[i][j])
    			cnt++;
    	}
    }

    cout << cnt;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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 INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
ll mod                = 1e9 + 7;
int main() {
	int n;
	ll ans = 1LL;
	cin >> n;
	int per;
	map<int, ll> dis;
	for (int cnt = 2; cnt <= n; cnt++) {
		per = cnt;
		for (int c = 2; c <= sqrt(per); c++) {
			while (per % c == 0) {
				dis[c]++;
				per /= c;
			}
		}
		dis[per]++;
	}
	repi(itr, dis) {
	//	clog << (itr->F) << "   " << (itr->S) << endl;
		if (itr->F == 1) continue;
		ans *= (itr->S + 1);
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3732
k = int(input())
q = k//50
r = k%50
print(50)
a = [0]*50
for i in range(50):
    if i < r:
        a[i] = 100+q-r
        # a[i] = 49+50*(q+1)-49*q-(r-1)
    else:
        a[i] = 49+q-r
        # a[i] = 49+50*q-49*q-r
print(*a)

Measured memory_bytes: 9000
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
//ユーグリッドの互除法による最大公約数を求めるメソッド
ll gcd(ll a, ll b) {
  ll smaller = min(a, b);
  ll bigger = max(a, b);
  ll surplus = bigger % smaller;
  if (surplus == 0) return smaller;
  surplus = gcd(smaller, surplus);
  return surplus;
}

//最小公倍数を求めるメソッド
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

//素数判定
bool isPrime(ll num) {
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
      if (num % i == 0) {
        // 素数ではない
        return false;
      }
    }
    // 素数である
    return true;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll n = gcd(a, b);
  ll ans = 1;
  for(int i = 2; i <= sqrt(n); ++i){
    if(n%i != 0) continue;
    while(n%i == 0) n /= i;
    ++ans;
  }
  if(n > 2) ans++;
  cout << ans << endl;
  return 0;
}

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


int dp[101][10001];
int item[101][2];
int n, w;


void makeDP(){
	for(int i = 0;i <= w;i++) dp[0][i] = 0;
	for(int i = 0;i <= n;i++) dp[i][0] = 0;
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= w;j++){
			dp[i][j] = max(dp[i-1][j], j-item[i][1]>-1 ? dp[i-1][j-item[i][1]]+item[i][0] : 0);
		}
	}
}


int main(){
	cin >> n >> w;

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

	makeDP();

	cout << dp[n][w] << endl;

	return 0;
}

Measured memory_bytes: 6992
import java.util.Scanner;
public class Main {
   public static void main(String[] args) {

          Scanner sc = new Scanner(System.in);
          int A = sc.nextInt();
          int B = sc.nextInt();
          int C = sc.nextInt();
          int count = 0;

          while(A%2 == 0 && B%2 == 0 && C%2 == 0){
        	  int Ab = A/2;
        	  int Bb = B/2;
        	  int Cb = C/2;
        	  A = 0;
        	  B = 0;
        	  C = 0;
        	  A += Bb + Cb;
        	  B += Ab + Cb;
        	  C += Ab + Bb;
        	  count++;
              	if(A == B && A == C){
              		count = -1;
              		break;
              	}
              }
          System.out.println(count);
          }
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(5e3 + 5);

/////////////////////////////////////////////////////////////
class RollingHash {
 public:
  using hash_type = tuple<ll, ll, ll>;

  string s;

  vector<ll> base;
  vector<ll> mod;

  vector<vector<ll>> hash;
  vector<vector<ll>> pow;

  RollingHash(string s) {
    this->s = s;

    base = {1009LL, 1007LL, 1005LL};
    mod = {(ll)(1e9 + 7), (ll)(1e9 + 9), (ll)(999999937)};

    hash = vector<vector<ll>>(3, vector<ll>());
    pow = vector<vector<ll>>(3, vector<ll>());

    init(s);
  }

  void init(const string &s) {
    int n = s.size();

    for (int i = 0; i < 3; ++i) hash[i].assign(n + 1, 0);
    for (int i = 0; i < 3; ++i) pow[i].assign(n + 1, 1);

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 3; ++j) {
        hash[j][i + 1] = (hash[j][i] + s[i]) * base[j] % mod[j];
        pow[j][i + 1] = pow[j][i] * base[j] % mod[j];
      }
    }
  }

  // 0-indexed, [l, r]
  hash_type get(int l, int r) {
    l += 1;
    r += 1;

    l -= 1;

    ll t0 = ((hash[0][r] - hash[0][l] * pow[0][r - l]) % mod[0] + mod[0]) % mod[0];
    ll t1 = ((hash[1][r] - hash[1][l] * pow[1][r - l]) % mod[1] + mod[1]) % mod[1];
    ll t2 = ((hash[2][r] - hash[2][l] * pow[2][r - l]) % mod[2] + mod[2]) % mod[2];

    return make_tuple(t0, t1, t2);
  }

  // get hash for whole string
  hash_type get_whole() {
    return get(0, s.size() - 1);
  }
};
/////////////////////////////////////////////////////////////

int n;
string s;

bool check(int length, RollingHash &rh) {
  map<RollingHash::hash_type, int> mp;

  for (int i = 0; i < s.size(); ++i) {
    int end_pos = i + length - 1;

    if (end_pos >= s.size()) break;

    int l = i;
    int r = end_pos;

    auto hash = rh.get(l, r);

    auto ptr = mp.find(hash);

    if (ptr != mp.end()) {
      if (ptr->second + length - 1 < i) {
        return true;
      }
    } else {
      mp[hash] = i;
    }
  }

  return false;
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

  cin >> s;

  RollingHash rh(s);

  int ok = 0;
  int ng = s.size();

  while (abs(ok - ng) > 1) {
    int next = (ok + ng) / 2;

    if (check(next, rh)) {
      ok = next;
    } else {
      ng = next;
    }
  }

  int ans = ok;

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    yorn(s.substr(0, s.size() / 2) == s.substr(s.size() / 2))
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	ll arr[n+1];
	for(int a=1;a<=n;a++)
	cin>>arr[a];
	ll dp[n+1][2];
	dp[1][0]=0;
	dp[1][1]=0;
	dp[2][0]=abs(arr[2]-arr[1]);
	dp[2][1]=1000000000000000;
	for(int a=3;a<=n;a++)
	{
		dp[a][0]=min(dp[a-1][0],dp[a-1][1])+abs(arr[a]-arr[a-1]);
		dp[a][1]=min(dp[a-2][0],dp[a-2][1])+abs(arr[a]-arr[a-2]);
	}
	cout<<min(dp[n][0],dp[n][1]);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define test int t; cin>>t; while(t--)
int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);cout.tie(0);

   ll a[1000],c,d,i,j,k,l=1e13;
   cin>>c;
   for(i=0;i<c;i++)
   {
       cin>>a[i];
   }
   sort(a,a+c);
   for(i=a[0];i<=a[c-1];i++)
   {
       d=0;
       for(j=0;j<c;j++)
       {
           d+=(a[j]-i)*(a[j]-i);
       }
       if(d<l)
       {
           l=d;
       }
   }
   cout<<l<<endl;
   return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[100005] = {}, z = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n + 1; i++) z += abs(a[i] - a[i - 1]);
    for (int i = 1; i <= n; i++) cout << z + abs(a[i - 1] - a[i + 1]) - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) << '\n';
}


Measured memory_bytes: 1664
n,m,c = map(int, input().split())
b = list(map(int, input().split()))
cnt = 0
for _ in range(n):
  a = list(map(int, input().split()))
  s = 0
  for i in range(m):
    s += a[i]*b[i]
  if s+c > 0:
    cnt += 1
print(cnt)

Measured memory_bytes: 3060
import java.io.File;
import java.util.Properties;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static Properties pps = System.getProperties();
	static boolean dbg=true;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[] a=ni(3);
		
		System.out.println(Solve(a));
		
	}

	private static int Solve(int[] a) {
		// TODO Auto-generated method stub
		return Math.min(a[2], a[1]/a[0]);
	}

	public static void out(String str) {

		if (dbg)
			System.out.println(str);
	}

	public static void out(int str) {

		if (dbg)
			System.out.println(str);
	}

	public static int ni() {
		sc.nextLine();
		return sc.nextInt();
	
	}
	public static String ns() {
		
		return sc.nextLine();
	}
	public static int[] ni(int k) {
		int[] res=new int[k];
		for(int i=0;i<k;i++)
			res[i]=sc.nextInt();
		sc.nextLine();
		return res;
	}
	public static String[] ns(int k) {
		String[] res=new String[k];
		for(int i=0;i<k;i++)
			res[i]=sc.nextLine();
		return res;
	}
	
	public static int[][] ni(int a,int b) {
		int[][] res=new int[a][b];
		for(int i=0;i<a;i++)
			for(int j=0;j<b;j++)
				res[i][j]=sc.nextInt();
		sc.nextLine();
		return res;
	}
}


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

typedef long long ll;
int main()
{
    int n;
    cin >> n;
    map<int, ll> f1;
    map<int, ll> f2;
    for (int q = 1; q <= n; q++)
    {
        int a;
        cin >> a;
        int val1 = a - q;
        int val2 = a + q;
        if (f1.find(val1) == f1.end())
        {
            f1[val1] = 1;
        }
        else
        {
            f1[val1]++;
        }
        if (f2.find(val2) == f2.end())
        {
            f2[val2] = 1;
        }
        else
        {
            f2[val2]++;
        }
    }
    auto it = f1.begin();
    ll tot = 0;
    while (it != f1.end())
    {
        int val = it->first;
        auto it2 = f2.find(-1 * val);
        if (it2 != f2.end())
        {
            tot += it->second * it2->second;
        }
        it++;
    }
    cout << tot;
}


Measured memory_bytes: 26664
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) throws Exception {
        B();
    }
 
    public static void B() throws Exception {
        Scanner scanner = new Scanner( System.in );
        String S = scanner.next();
        boolean inACGT = false;
        int start = 0, len = 0;
        for (int i = 0; i < S.length(); i++) {
            char c = S.charAt( i );
            boolean isACGT = c == 'A' || c == 'C' || c == 'G' || c == 'T';
            if (inACGT) {
                if (!isACGT) {
                    inACGT = false;
                    len = Math.max( len, i - start);
                }
            } else {
                if (isACGT) {
                    inACGT = true;
                    start = i;
                }
            }
        }
        if (inACGT) len = Math.max( len, S.length() - start);
        System.out.println(len);
    }
 
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String str = sc.nextLine();
		str = str.replace("apple","/");
		str = str.replace("peach","apple");
		str = str.replace("/","peach");
		System.out.println(str);
		sc.close();
		
	}

}

Measured memory_bytes: 17128
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;
 
const int MAX_N = int(1e6) + 10;
const long long int MOD= 998244353;
const long long int INF=1e18;
 
 
typedef long long int ll;
typedef unsigned long long int llu;


ll max(ll a,ll b){
	return a>b?a:b;
}
int main()
{
	ll n,s; cin>>n>>s;
  ll a[n];
  for(int i=0;i<n;++i)cin>>a[i];
  vector<vector<ll> > dp(n,vector<ll>(3001,0));
  dp[0][a[0]]=1;
  dp[0][0]=2;
  for(int i=1;i<n;++i){
    dp[i][0]=dp[i-1][0]*2%MOD;
    for(int j=1;j<=s;++j){
      dp[i][j]=2*dp[i-1][j];
      if(j>=a[i])dp[i][j]+=dp[i-1][j-a[i]];
      dp[i][j]%=MOD;
    }
  }
  cout<<dp[n-1][s];
  return 0;
}

Measured memory_bytes: 73748
#include<iostream>
using namespace std;int main(){int n,y,b,r,t,u,i;while(1){cin>>n;if(!n)break;cin>>y;double e=n,s;for(u=0;u<n;u++){cin>>b>>r>>t;double a;if(t==1)a=n*(100+r*y)/100.0;if(t==2){a=n;for(i=0;i<y;i++)a=a*(100+r)/100.0;}if(a>e)e=a,s=b;}cout<<s<<endl;}return 0;}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	vector<int> v(3);
	v = {a, b, c};
	sort(all(v));
	ans += (v[2] - v[0]) / 2;
	v[0] += (v[2] - v[0]) / 2 * 2;
	ans += (v[2] - v[1]) / 2;
	v[1] += (v[2] - v[1]) / 2 * 2;
	if(v[0] == v[1] && v[1] == v[2]) ;
	if(v[0] == v[1] && v[1] != v[2]) ans++;
	if(v[0] != v[1] && v[1] != v[2]) ans += 2;
	if(v[0] != v[1] && v[1] == v[2]) ans += 2;
	// rep(i, 3) cout << v[i] << endl;
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n; cin >> n;

    map<string, int> ma;

    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        ma[s]++;
    }

    int mx = 0;

    for (auto t : ma) {
        mx = max(mx, t.second);
    }

    for (auto t : ma) {
        if (mx == t.second) {
            cout << t.first << endl;
        }
    }
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
#define mxn 1000010
#define LL long long
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
#define node(a,b,c) (node){a,b,c}
using namespace std;
const int inf=1e9,mod=1e9+7;
int n,sl,fh,a[mxn];
LL res,ans[mxn];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	n=rd();int x=1;
	for(int i=1;i<=n;++i,x=-x) a[i]=rd(),res+=x*a[i];
	ans[1]=res;
	for(int i=1;i<n;++i) ans[i+1]=a[i]*2-ans[i];
	for(int i=1;i<=n;++i) printf("%lld ",ans[i]);puts("");
	return 0;
}

Measured memory_bytes: 6144
//#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 100 + 5;
const int OO = 2e9;

int n,f[N][11],p[N][12],c[N],ans;

void init() {



}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;

    ans = -OO;

    for(int i=0;i<n;++i) {

        for(int j=0;j<10;++j) {

            cin >> f[i][j];

        }

    }

    for(int i=0;i<n;++i) {

        for(int j=0;j<11;++j) {

            cin >> p[i][j];

        }

    }

    for(int i=1;i<(1<<10);++i) {

        int curBit = i;

        int sum = 0;

        memset(c,0,sizeof(c));

        for(int j=0;j<10;++j) {

            if(curBit&1) {

                for(int k=0;k<n;++k) {

                    if(f[k][j]) c[k]++;

                }

            }

            curBit /= 2;

        }

        for(int k=0;k<n;++k) {

            sum += p[k][c[k]];

        }

        ans = max(ans,sum);

    }

    cout << ans << '\n';

    return 0;

}

Measured memory_bytes: 256
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const n = Number(stdin.split('\n')[0])

const a = stdin
  .split('\n')[1]
  .split(' ')
  .map(Number)

const getDiv2Count = x => {
  let count = 0
  let num = x
  while (num % 2 === 0) {
    num /= 2
    count++
  }
  return count
}

const div2CountList = a.map(getDiv2Count)

console.log(div2CountList.reduce((p, c) => p + c))


Measured memory_bytes: 7840
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;

bool is_prime(ll a) {
  if (a < 2) return false;
  for (int i = 2; i <= sqrt(a); i++) {
    if (a % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  int Q;
  cin >> Q;
  const int maxn = 1e5 + 10;
  vector<int> a(maxn);
  for (int i = 1; i < maxn; i++) {
    if (i % 2 != 0 && is_prime(i) && is_prime((i + 1) / 2)) {
      a[i] = a[i - 1] + 1;
    } else {
      a[i] = a[i - 1];
    }
  }

  vector<int> ans;
  rep (i, Q) {
    int l, r; cin >> l >> r;
    ans.push_back(a[r] - a[l - 1]);
  }
  for (auto v : ans) cout << v << endl;
  return 0;
}


Measured memory_bytes: 4380
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>

int todec(char mcxi[]);
void tom(char res[], int num);

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

    for(i = 0; i < n; i++){
        char line[100];
        gets(line);
        char *p = line;
        while(*p != ' ')
            p++;
        char mcxi1[100], mcxi2[100];
        *p = '\0';
        p++;
        strcpy(mcxi1 + 1, line);
        strcpy(mcxi2 + 1, p);

        int res = todec(mcxi1 + 1) + todec(mcxi2 + 1);

        char result[100];
        tom(result, res);
        printf("%s\n", result);
    }

    return 0;
}

int todec(char mcxi[])
{
    char *p = mcxi;
    int ret = 0;
    while(*p != '\0'){
        if(isalpha(*p)){
            int base;
            switch(*p){
                case 'm':
                    base = 1000;
                    break;
                case 'c':
                    base = 100;
                    break;
                case 'x':
                    base = 10;
                    break;
                case 'i':
                    base = 1;
                    break;
                default:
                    printf("err\n");
                    break;
            }
            if(isdigit(*(p - 1))){
                    char ch = *(p - 1);
                    ret += (ch - '0') * base;
            }else{
                ret += base;
            }
        }
        p++;
    }
    return ret;
}

void tom(char res[], int num)
{
    int m, c, x, i;
    i = num % 10;
    num /= 10;
    x = num % 10;
    num /= 10;
    c = num % 10;
    num /= 10;
    m = num % 10;
    //printf("m: %d\n", m);
    //printf("c: %d\n", c);
    //printf("x: %d\n", x);
    //printf("i: %d\n", i);

    char ms[3];
    char cs[3];
    char xs[3];
    char is[3];
    res[0] = '\0';

    if(m == 1){
        ms[0] = 'm';
        ms[1] = '\0';
        strcat(res, ms);
    }else if(m > 1){
        ms[0] = m + '0';
        ms[1] = 'm';
        ms[2] = '\0';
        strcat(res, ms);
    }
    if(c == 1){
        cs[0] = 'c';
        cs[1] = '\0';
        strcat(res, cs);
    }else if(c > 1){
        cs[0] = c + '0';
        cs[1] = 'c';
        cs[2] = '\0';
        strcat(res, cs);
    }
    if(x == 1){
        xs[0] = 'x';
        xs[1] = '\0';
        strcat(res, xs);
    }else if(x > 1){
        xs[0] = x + '0';
        xs[1] = 'x';
        xs[2] = '\0';
        strcat(res, xs);
    }
    if(i == 1){
        is[0] = 'i';
        is[1] = '\0';
        strcat(res, is);
    }else if(i > 1){
        is[0] = i +'0';
        is[1] = 'i';
        is[2] = '\0';
        strcat(res, is);
    }
}

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

public class Main
{
	public static void main(String[] Arguments) throws IOException 
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer ST = new StringTokenizer(BR.readLine());
		int S = Integer.parseInt(ST.nextToken()), W = Integer.parseInt(ST.nextToken());
		System.out.println((W >= S) ? "unsafe" : "safe");
	}
}


Measured memory_bytes: 25380
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int l = Integer.parseInt(sc.next());
        int r = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        int count = 0;
        for(int i=l; i<=r; i++) {
            if(i % d == 0) count++;
        }
        System.out.println(count);
    
    }
}


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

ll read(){
	ll i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

signed main(){
	int n=read(),a=read(),b=read();
	if(a*b<n||a+b>n+1){
		print(-1);
		return 0;
	}
	vi cnt(a,1);
	int rem=n-a;
	REP(i,a){
		int w=min(rem,b-1);
		cnt[i]+=w;
		rem-=w;
	}
	vi ans;
	for(auto c:cnt){
		int head=ans.size()+1;
		vi tmp;
		REP(j,c)tmp.PB(j+head);
		reverse(ALL(tmp));
		ans.insert(ans.end(),ALL(tmp));
	}
	REP(i,n)
		print(ans[i],i==n-1?1:2);
}


Measured memory_bytes: 7280
from collections import deque

s = deque(input())
q = int(input())
rev_f = True

for i in range(q):
    cmd = input().split()
    if cmd[0] == '1':
        rev_f = (False if rev_f else True)
    else:
        f = cmd[1]
        c = cmd[2]
        if (rev_f and f == '1') or (not rev_f and f != '1'):
            s.appendleft(c)
        else:
            s.append(c)

print(''.join(s if rev_f else reversed(s)))


Measured memory_bytes: 8436
#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];
    }

    int s= round(accumulate(a.begin(),a.end(),0)/double(n));
	int sum = 0;

    for(auto x:a){
        sum+=abs(x-s)*abs(x-s);
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
v = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
vc = [[x/y, x-y] for x, y in zip(v, c)]
vc.sort(key=lambda x: x[0], reverse=True)
diff = 0
for a in vc:
    if a[0] > 1.0:
        diff += a[1]
print(diff)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
#include <queue>

using namespace std;

vector<vector< int > > g;

int main() {
	int n, m;
	cin >> n >> m;
	g.resize(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	int s = 0;
	queue<int> q;
	q.push (s);
	vector<bool> used (n);
	vector<int> d (n, -1), p (n);
	used[s] = true;
	p[s] = -1;
	d[s] = 0;
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		for (size_t i=0; i<g[v].size(); ++i) {
			int to = g[v][i];
			if (!used[to]) {
				used[to] = true;
				q.push (to);
				d[to] = d[v] + 1;
				p[to] = v;
			}
		}
	}

	for (int i = 0; i < n; i++) {
		if (d[i] == -1) {
			cout << "No\n";
			return 0;
		}
	}

	cout << "Yes\n";
	for (int i = 1; i < n; i++) {
		cout << p[i] + 1 << "\n";
	}
	return 0;
}


Measured memory_bytes: 10652
/*
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College
    Date:13/06/2020
*/
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define ff first
#define clr(a,x) memset(a,x,sizeof(a))
#define ss string 
#define se second
#define alt(v) v.begin(),v.end()
#define pb emplace_back
#define mp make_pair
#define ipair pair<int,int>
#define fab(i,a,b) for(ll i=(a);i<(b);i++)
#define fba(i,a,b) for(ll i=(b);i>=(a);i--)
#define arr(i,n) fab(i,0,n)
ll mod=1000000007;
int dx[]={-1,1,0,0};
int dy[]={0,0,1,-1};
const int inf = 1e12;
bool test = 0;

const int N = 3e5+5;
int mx[4*N];

void update(int n,int st,int end ,int pos,int val)
{
    
    if(st > pos or end < pos)
        return;
    if(st == end and st == pos)
    {
        mx[n] = max(mx[n],val);
        return;
    }
    int mid = (st + end)/2;
    update(2*n,st,mid,pos,val);
    update(2*n+1,mid+1,end,pos,val);
    mx[n] = max(mx[2*n],mx[2*n+1]);
}
 
int query(int n,int st,int end,int l,int r)
{  
    if(l<=st && end<=r)
    return mx[n];
    int m=(st+end)/2;
    if(r<=m)
        return query(2*n,st,m,l,r);
    else if(l>m)
        return query(2*n+1,m+1,end,l,r);
    else
    {
        int p1,p2;
        p1=query(2*n,st,m,l,r);
        p2=query(2*n+1,m+1,end,l,r);
        return max(p1,p2);
    }
}


int st,last;
int n,k,x;
void solve() 
{ 
    cin >> n >> k;
    clr(mx,0);
    st = 0,last = 300000;
    for(int i = 1;i <= n; ++i)
    {
        cin >>x;
        int l = max(st,x-k);
        int r = min(last,x+k);
        int x1 = query(1,st,last,l,r);
        update(1,st,last,x,x1+1);
    }
    cout<<query(1,st,last,st,last);
}










signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // precompute();
    if(test)
        cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

const int MOD = 1000000007;
const int inf = 314159265;
using ll = long long;
 
int main() {
 
  string S, T;
  cin >> S >> T;

  int count, ans = inf;
  for(int i = 0; i < (S.size() - T.size() + 1); i++){
    count = 0;
    for(int j = 0; j < T.size(); j++){
      if(S.at(i+j) != T.at(j)){
        count++;
      }
    }
    ans = min(count, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<queue>
#include<vector>
using namespace std;
const int N=1e5+10;
vector<int>f[N],a;
queue<int>q;
int n,m,p,x,y,in[N],ans,dp[N];
int main()
{
	scanf("%d%d",&n,&m);
	while(m--)
	{
		scanf("%d%d",&x,&y);
		f[x].push_back(y);
		in[y]++;
	}
	for(int i=1;i<=n;i++)
		if(!in[i])q.push(i);
	while(!q.empty())
	{
		p=q.front();
		q.pop();
		a.push_back(p);
		for(int j=0;j<f[p].size();j++)
			if(!--in[f[p][j]])q.push(f[p][j]);
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<f[a[i]].size();j++)
			dp[f[a[i]][j]]=dp[a[i]]+1;
		ans=max(ans,dp[a[i]]); 
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 7032
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
import collections
import heapq
N = int(input())
a = list(map(int, input().split()))
ans = 1
max_ = pow(10, 18)
if 0 in a:
    print(0)
    exit()
for tmp in a:
    ans *= tmp
    if (ans > max_):
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 40052
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int n;
    cin>>n;
    ll ans=0;
    vector<ll> a(n),b(n),c(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n)cin>>c[i];
    SORT(a);SORT(c);
    rep(i,n){
        ll ai=upper_bound(ALL(a),b[i]-1)-a.begin();
        ll bi=lower_bound(ALL(c),b[i]+1)-c.begin();
        ans+=ai*(n-bi);   
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2560