akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> plli;
typedef vector< vi > vvi ;
typedef vector< vlli > vvlli  ;
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define flli(i,a,b) for(long long int i=a;i<=b;i++)
#define bi(i,a,b) for(int i=a;i>=b;i--)
#define blli(i,a,b) for(long long int i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pi 2*acos(0.0)
#define pb push_back
#define tr(v,it) for(decltype(v.begin()) it=v.begin();it!=v.end();it++)
#define present(v,num) (v.find(num)!=v.end())
#define cpresent(v,num) (find(v.begin(),v.end(),num)!=v.end())
#define pq priority_queue
#define mp make_pair
const int inf=INT_MAX;
const lli INF =LLONG_MAX;
const lli mod = 1e9+7;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast;
    lli n,x,t;cin>>n>>x>>t;
    lli ans=t*(n/x);
    if(n%x!=0)ans+=t;
    cout<<ans;
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

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

using namespace std;

constexpr int MOD = 1000000007;

using Long = long long;
template<typename T>
using V = vector<T>;
template<typename T>
using Vv = V<V<T>>;
using Vb = V<bool>;
using Vvb = V<Vb>;
using Vi = V<int>;
using Vvi = V<Vi>;
using Vl = V<Long>;
using Vvl = V<Vl>;
using Vd = V<double>;
using Vvd = V<Vd>;
using Vs = V<string>;

template<typename T>
T read() {
    T res;
    cin >> res;
    return res;
}

template<typename T>
V<T> readV(int n) {
    V<T> res((size_t) n);
    for (int i = 0; i < n; ++i) {
        res[i] = read<T>();
    }
    return res;
}

template<typename T>
Vv<T> readVv(int n, int m) {
    Vv<T> res((size_t) n, V<T>((size_t) m));
    for (int i = 0; i < n; ++i) {
        res[i] = readV<T>(m);
    }
    return res;
}

// *** SOLUTION BEGIN ***

void solve() {
    int n;
    cin >> n;
    auto a = readV<int>(n);
    a.push_back(0);
    Vl cost(n + 1);
    for (int i = n - 1; i >= 0; --i) {
        cost[i] = abs(a[i] - a[i + 1]) + cost[i + 1];
    }
    Long acc = 0;
    int prev = 0;
    for (int i = 0; i < n; ++i) {
        cout << acc + abs(a[i + 1] - prev) + cost[i + 1] << '\n';
        acc += abs(a[i] - prev);
        prev = a[i];
    }
}

// *** SOLUTION END ***

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout << fixed;
    solve();
    return 0;
}


Measured memory_bytes: 2424
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define long int64_t
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef priority_queue<pii, vector<pii>, greater<pii>> min_pq;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OST;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

const int N = 100001;

int a[N << 1];

bool check(int v, int l, int r, int m)
{
	for(int i=0; i<v; i++)
		if(a[l+i] + a[r-i] < m)
			return false;
	return true;
}

int solve(int v, int l, int r, int m)
{
	int ret = 0;
	for(int i=0; i<v; i++)
		ret = max(ret, a[l+i] + a[r-i] - m);
	for(int i=1; i<=(r >> 1) - v; i++)
		ret = max(ret, a[i] + a[l-i]);
	return ret;
}

int main()
{
	fio;
	int n, m;
	cin >> n >> m;
	for(int i=1; i<=n+n; i++)
		cin >> a[i];
	sort(a+1, a+n+n+1);
	int l = 0, r = n;
	while(l != r)
	{
		int mid = l+r >> 1;
		if(check(n - mid, mid + mid + 1, n + n, m))
			r = mid;
		else
			l = mid + 1;
	}
	cout << solve(n - l, l + l + 1, n + n, m) << endl;
	return 0;
}

Measured memory_bytes: 1152
import heapq

def prim():
    used = [1] * n
    used[0] = 0
    lis = []
    res = 0
    
    for q in edge[0]:
        heapq.heappush(lis,q)
        
    while lis:
        minedge = heapq.heappop(lis)
        
        if used[minedge[1]] == 0:
            continue

        v = minedge[1]
        used[v] = 0

        for q in edge[v]:
            if used[q[1]] == 1:
                heapq.heappush(lis , q )
        res += minedge[0]
    return res
    
n , m = map(int,input().split())
edge = [[] for _ in range(n)]

for _ in range(m):
    ad ,b ,c = map(int,input().split())
    edge[ad].append([c , b])
    edge[b].append([c , ad])
print(prim())


Measured memory_bytes: 34972
#include <stdio.h>

int main(void)
{
	int n;
	int data[100];
	int i, j, dnum, num;
	
	while (1){
		scanf("%d", &dnum);
		
		if (dnum == 0){
			break;
		}
		for (i = 0; i < dnum; i++){
			scanf("%d", &data[i]);
		}
		dnum = i;
		num = 0;
		for (i = 0; i < dnum - 1; i++){
			for (j = 0; j < dnum - i - 1; j++){
				if (data[j] > data[j + 1]){
					data[j] ^= data[j + 1];
					data[j + 1] ^= data[j];
					data[j] ^= data[j + 1];
					num++;
				}
			}
		}
		
		printf("%d\n", num);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>

int main(){
    int n, L;
    std::cin >> n >> L;
    std::vector<int> taste(n);
    int sum = 0;
    int mostZeroTaste = 1000;
    for(int i = 0; i < n; i++){
        taste[i] = L + i;
        sum += taste[i];
        if(std::abs(mostZeroTaste) > std::abs(taste[i])){
            mostZeroTaste = taste[i];
        }
    }

    std::cout << sum - mostZeroTaste << std::endl;

    return 0;
}


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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    ll A[N];
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    ll opt[N];
    ll cnt[50];
    int B;
    for(B = 0; (1ll << B) <= K; B++) {
        cnt[B] = 0;
        for(int i = 0; i < N; i++) {
            cnt[B] += ((A[i] >> B) & 1);
        }
        opt[B] = max(cnt[B], N - cnt[B]) << B;
        if(B > 0)
            opt[B] += opt[B - 1];
    }
    // debugArray(opt, B);
    ll ans = 0, sum = 0;
    for(int i = 0; i < N; i++) {
        ans += A[i];
        sum += (A[i] >> B) << B;
    }
    for(int b = B - 1; b >= 0; b--) {
        if((K >> b) & 1) {
            if(b > 0)
                ans = max(ans, sum + (cnt[b] << b) + opt[b - 1]);
            sum += max(cnt[b], N - cnt[b]) << b;
        } else {
            sum += cnt[b] << b;
        }
    }
    // debug(ans);
    ans = max(ans, sum);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1152
#include<iostream>
using namespace std;
int a[200000], b[200000], c[200000];
long int all = 0;
void merge_sort(int left, int midle, int right) {
	for (int i = 0; i < midle - left; i++) {
		b[i] = a[i + left];
	}
	for (int i = 0; i < right - midle; i++) {
		c[i] = a[i + midle];
	}
	int j = 0;
	int k = 0;
	for (int i = left; i < right; i++) {
		if (k == right - midle || (j < midle - left && b[j] <= c[k]))
		{
			a[i] = b[j];
			j++;
		}
		else {
			a[i] = c[k];
			all += midle - left - j;
			k++;
		}
	}
}
void merge(int left, int right) {
	if (left+1 < right) {
		int midle = (left + right) / 2;
		merge(left, midle);
		merge(midle, right);
		merge_sort(left, midle,right);
	}
}
int main(void) {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	merge(0, n);
	cout << all<<endl;
}


Measured memory_bytes: 4652
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    int best = 1;
    for (int i = 1; i * i <= m; i++) {
        if (m % i == 0) {
            if (i >= n) {
                best = std::max(best, m / i);
            }
            if (m / i >= n) {
                best = std::max(best, i);
            }
        }
    }
    cout << best;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef vector <ll> vi;                 // Vector of long long
typedef vector <vi> vvi;                // Vector of vi
typedef vector <pair<ll,ll>> ii;        // Vector of pairs
#define ff first                        // For pairs
#define ss second                       // For pairs
#define sz(a) int((a).size())           // Function to determine size of any container
#define pb push_back                    // Pushback to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
#define MAXN (ll)(22LL)
#define MAXB (ll)(1LL << MAXN)
#define MOD (ll)(1e9 + 7)
#define mod(a) (((a % MOD) + MOD) % MOD)

ll n;
ll check[MAXN][MAXN];
ll dp[MAXN][MAXB];

ll solve(ll i, ll b)
{
    if (i == n)
    {
        if (b == ((1LL << n) - 1LL))
            return 1LL;
        else
            return 0LL;
    }

    if (dp[i][b] == -1)
    {
        ll ans = 0;
        for (int j = 0; j < n; j++)
        {
            ll a = b & (1LL << j);
            if (a == 0LL && check[i][j] == 1LL)
                ans = mod(ans + solve(i + 1, b | (1LL << j)));
        }

        dp[i][b] = ans;
    }
    return dp[i][b];
}

int main(void)
{
    memset(dp, -1, sizeof(dp));
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;

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

    cout << solve(0, 0) << "\n";
}

Measured memory_bytes: 721152
#include <stdio.h>
int main (void)
{
    int a,b;

    scanf("%d %d",&a,&b);

    if(a == b){
        printf("Draw\n");
    }else if(a == 1 || (a > b && b != 1)){
        printf("Alice\n");
    }else{
        printf("Bob\n");
    }

    return 0;
}

Measured memory_bytes: 128
# coding=utf-8

###
### for atcorder program
###

import sys
import math
import array

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]
#R = float(input())
#A = [int(x) for x in input().split()]
#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

def main():
    ans = []
    while(True):
        N = int(input())
        point = []

        if N == 0:
            break

        for i in range(N):
            point.append(int(input()))
    
        pointsum = sum(point)-(max(point)+min(point))

        ans.append(pointsum//(N-2))
        
    for i in ans:
        print(i)

if __name__ == '__main__':
    main()




Measured memory_bytes: 5748
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
      	int k = sc.nextInt();
        int o=0;
      	for (int i=0;i<n;i++){
          int a=sc.nextInt();
        	if(a>=k)o++;
        }
      
		System.out.println(o);
	}
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll gcd(ll a, ll b)
{
    if (a < b)
        swap(a, b);
    ll c = a % b;
    if (c == 0)
        return b;
    return gcd(b, c);
}

int main()
{
    ll N, M;
    cin >> N >> M;
    string S, T;
    cin >> S >> T;

    ll L = N * M / gcd(N, M);
    bool e = false;
    REP(i, std::min(N, M))
    {
        if (N >= M)
        {
            if ((i * L / M) % (L / N) != 0)
                continue;
            int j = (i * L / M) / (L / N);
            if (S[j] == T[i])
                continue;
        }
        else
        {
            if ((i * L / N) % (L / M) != 0)
                continue;
            int j = (i * L / N) / (L / M);
            if (S[i] == T[j])
                continue;
        }
        e = true;
        break;
    }

    if (e)
        cout << -1 << endl;
    else
        cout << L << endl;
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
int a, b, c;
int main(){
	scanf("%d %d %d", &a, &b, &c);
	if(b - a == c - b)
		printf("YES\n");
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
using uint = unsigned int;

bool is_prime(const uint n) {
    if (n < 4) {
		return n == 2 || n == 3;
	}
	
    if (n % 2 == 0 || n % 3 == 0 || (n % 6 != 1 && n % 6 != 5)) {
		return false;
	}
	
    for (uint i = 5; i * i <= n; i += 6) {
		if (n % i == 0 || n % (i + 2) == 0) {
			return false;
		}
	}
    
	return true;
}

int main() {
	uint X;
	cin >> X;
	
	while(!is_prime(X)) {
		X++;
	}
	
	cout << X;
	
	return 0;
}

Measured memory_bytes: 256
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	q, h, s, d, n := nextInt(), nextInt(), nextInt(), nextInt(), nextInt()

	h = min(2*q, h)
	s = min(2*h, s)

	if 2*s < d {
		fmt.Println(n * s)
	} else {
		fmt.Println((n/2)*d + (n%2)*s)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int f[MAX_N]={};
int b[MAX_N]={};

int main() {
    int n;
    cin>>n;
    int n1=n/100;
    int n2=n-n1*100;

    if(n1>0 && n1<13){
        if(n2>0 && n2<13){
            cout<<"AMBIGUOUS"<<endl;
        }else{
            cout<<"MMYY"<<endl;
        }   
    }else if(n2>0 && n2<13) {
        cout<<"YYMM"<<endl;
    }else{
        cout<<"NA"<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNING

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm> 
#include<cmath>
#define PI 3.1415926535
using namespace std;
typedef long long ll;
int main()
{
	ll a,b,j,i,ii,u,d,mid;
	scanf("%lld%lld%lld",&a,&b,&j);
	if(a*a*b%2==0&&j==a*a*b/2)
	{
		printf("%.10lf\n",atan((double)b/a)*180/PI);
		return 0;
	}
	if((double)a*a*b/2>j)
	{
		printf("%.10lf\n",atan((double)a*b*b/2/j)*180/PI);
		return 0;
	}
	else
	{
		printf("%.10lf\n",atan(2*(double)b/a-2*(double)j/(a*a*a))*180/PI);
		return 0;
	}
	return 0;
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int [] a = new int [3];
        for (int i = 0; i < 3 ; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int largestNum = a[2];
        int mediumNum = a[1];
        int smallestNum = a[0];
        int diffLM = largestNum - mediumNum;
        int diffLS = largestNum - smallestNum;
        if (diffLM % 2 == 0 && diffLS % 2 == 0) {
            System.out.println(diffLM/2 + diffLS/2);
        } else if (diffLM % 2 != 0 && diffLS % 2 != 0) {
            System.out.println(diffLM/2 + diffLS/2 + 1);
        } else {
            System.out.println(diffLM/2 + diffLS/2 +2);
        }

    }

}

Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdint>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

const double PI=3.141592653589793;

int main(){
    int x,a,b;
    cin >> x >> a >> b;

    if(b<=a){
        cout << "delicious" << endl;
    }
    else if(b<=a+x){
        cout << "safe" << endl;
    }
    else{
        cout << "dangerous" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text;

namespace _084_SearchEngine
{
	class Program
	{
		static void Main ( string[] args )
		{
			char[] separator = { ' ', '.', ',' };
			string[] inputStr = Console.ReadLine ().Split (separator, StringSplitOptions.RemoveEmptyEntries);

			var result = string.Join (" ", inputStr.Where (item => 2 < item.Length && item.Length < 7).ToArray ());

			Console.WriteLine (result);
		}
	}
}

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
typedef long long  int lli;


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

	vector<lli> h(n);

	for(lli i=0;i<n;i++) 
		cin>>h[i];

	vector<lli> cost(n);
	cost[0] = 0;
	cost[1] = abs(h[1] - h[0]);

	for(lli i=2;i<n;i++)
	{
		cost[i] = min(cost[i-1] + abs(h[i] - h[i-1]), cost[i-2] + abs(h[i]- h[i-2]));
	}
	
	cout<<cost[n-1]<<endl;
}

Measured memory_bytes: 1792
from collections import Counter 

def main():
    n = int(input())
    a = list([int(t)for t in input().split()])
    c = Counter(a)
    checker = [False]*(10**6+1)
    times = [False]*(10**6+1)

    for a_i in a:
        checker[a_i] = True
    ans = 0
    for i in range(1,10**6+1):
        if times[i]:
            continue
        if not checker[i]:
            continue
        if checker[i] and c[i]==1:
            ans+=1
        for j in range(i,10**6+1,i):
            times[j] = True
        
    print(ans)
            
if __name__ == "__main__":
    main()


Measured memory_bytes: 47860
#include <bits/stdc++.h>
#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 N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  int ans = 1000000000;
  for (int i = a.front(); i <= a.back(); i++) {
    int temp = 0;
    for (int j = 0; j < N; j++) {
      temp += (a[j] - i) * (a[j] - i);
    }
    ans = min(ans, temp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
typedef long long ll;
 
int main() {
  ll a,b;
  cin>>a>>b;
  cout<<(b%a==0 ? a+b:b-a);
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define maxn 200005
using namespace std;

typedef long long LL;

int n, rpos, a[maxn];
LL k;

inline LL C(const LL& n) { return n * (n - 1) >> 1; }

inline LL floordiv(LL a, LL b)
{
    bool f = (a < 0) ^ (b < 0); // '^' is '!='
    if(a < 0) a = -a;
    if(b < 0) b = -b;
    return f? -(a / b + 1): a / b;
}

inline LL ceildiv(LL a, LL b)
{
    bool f = (a < 0) ^ (b < 0);
    if(a < 0) a = -a;
    if(b < 0) b = -b;
    return f? -(a / b): (a - 1) / b + 1; // (a - 1) / b + 1 = ceil(a * 1.0 / b)
}

int main()
{
	scanf("%d%lld", &n, &k);
	for(int i=1; i<=n; i++) scanf("%d", a + i);
	sort(a + 1, a + n + 1);
	LL l = 0, r = 0, z = 0, L = 0, R = 0, Z = 0; // l: negativecnt, r: positivecnt, z: zerocnt
	for(int i=1; i<=n; i++)
		z += a[i] == 0,
		l += a[i] < 0,
		r += a[i] > 0;
	// L: cnt of res < 0, R: cnt of res > 0, Z: cnt of res == 0
    L = l * r; R = C(l) + C(r); Z = C(n) - L - R;
    rpos = n + 1; // rpos: the first positive number in a
    for(int i=1; i<=n; i++)
		if(a[i] > 0)
		{
	        rpos = i;
			break;
    	}
	if(k <= L) // answer is negative
	{
		LL ql = -1e18, qr = -1, mid, ans = -233;
		while(ql <= qr)
		{
			mid = ql + qr >> 1;
			LL sum = 0, now = r, cur = rpos;
			for(int i=1; i<=n && a[i]<0; i++)
			{
				LL up = mid / a[i] + 1;
				while(now && a[cur] < up) cur ++, now --;
				sum += now;
			}
			if(sum < k) ql = (ans = mid) + 1;
			else qr = mid - 1;
		}
		printf("%lld\n", ans);
	}
	else if(k <= L + Z) // answer is 0
        puts("0");
    else // answer is positive
	{
        k -= L + Z;
        LL ql = 1, qr = 1e18, mid, ans = -233;
        while(ql <= qr) {
            mid = (ql + qr) >> 1;
            LL sum = 0, now = r, cur = n;
            for(int i = rpos; i <= n; i ++) {
                LL up = mid % a[i] == 0 ? mid / a[i] - 1 : floordiv(mid, a[i]);
                while(now && a[cur] > up) cur --, now --;
                sum += cur >= i ? now - 1 : now;
            }
            now = l; cur = 1;
            for(int i = n; i >= 1; i --) if(a[i] < 0) {
                LL up = mid % a[i] == 0 ? mid / a[i] + 1 : ceildiv(mid, a[i]);
                while(now && a[cur] < up) cur ++, now --;
                sum += cur <= i ? now - 1 : now;
            }
            sum >>= 1;
            if(sum < k) ql = (ans = mid) + 1;
            else qr = mid - 1;
        }
        printf("%lld\n", ans);
    }
    return 0;
} 

Measured memory_bytes: 896
<?php
define('MOD', 10 ** 9 + 7);
fscanf(STDIN, '%d', $n);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$ans = 0;
for ($k = 0; $k < 60; $k++) {
    $cnt_1 = 0;
    for ($i = 0; $i < $n; $i++) {
        if (($a[$i] >> $k) & 1) $cnt_1++;
    }
    $ans = modAdd($ans, modMul(modMul($n - $cnt_1, $cnt_1), modPow(2, $k)));
}
echo $ans . PHP_EOL;

// 足し算
function modAdd($x, $y)
{
    return ($x + $y) % MOD;
}

// 引き算
function modSub($x, $y)
{
    return ($x + MOD - $y) % MOD;
}

// 掛け算
function modMul($x, $y)
{
    return ($x * $y) % MOD;
}

// 割り算
function modDiv($x, $y)
{
    return modMul($x, modPow($y, MOD - 2));
}

// 累乗（繰り返し二乗法）
function modPow($n, $x)
{
    if ($x === 0) return 1;
    $res = (modPow($n, $x >> 1) ** 2) % MOD;
    if ($x % 2 === 1) $res = modMul($res, $n);
    return $res;
}

Measured memory_bytes: 40936
#include <stdio.h>
typedef struct Dice{
	int	f1;
	int	f2;
	int	f3;
	int	f4;
	int	f5;
	int	f6;
	int tmp;
}Dice;

int main(void)
{
	int n, upper, front, right, a, b, i, j;
	Dice D0;
	scanf("%d%d%d%d%d%d", &D0.f1, &D0.f2, &D0.f3, &D0.f4, &D0.f5, &D0.f6);
	scanf("%d", &n);
	for(j=0; j<n; j++){
		scanf("%d%d", &upper, &front);
		a=0;
		while(D0.f1 != upper){
			D0.tmp = D0.f1;
			a++;
			b = a % 2;
			switch(b){
				case 0:
					D0.f1 = D0.f4;
					D0.f4 = D0.f6;
					D0.f6 = D0.f3;
					D0.f3 = D0.tmp;
					break;
				case 1:
					D0.f1 = D0.f2;
					D0.f2 = D0.f6;
					D0.f6 = D0.f5;
					D0.f5 = D0.tmp;
					break;
				default:
					break;
			}
		}
		if(front == D0.f2){
			right = D0.f3;
		}else if(front == D0.f3){
			right = D0.f5;
		}else if(front == D0.f5){
			right = D0.f4;
		}else if(front == D0.f4){
			right = D0.f2;
		}
		printf("%d\n", right);
	}
	return 0;
}

Measured memory_bytes: 596
def eratosthenes(n):
    prime = [2]
    if n == 2:
        return prime
    limit = int(n ** 0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


def solve():
    N = int(input())
    primes = eratosthenes(55555)
    ans = []
    for p in primes:
        if p % 5 == 1:
            ans.append(p)
    print(' '.join(map(str, ans[:N])))


if __name__ == '__main__':
    solve()


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

using namespace std;
	
int main(){
	string s;
	cin >> s;
	
	vector<int> a(26,0);
	
	for(int i=0;i<s.size();i++){
		a[(int)(s[i]-'a')]++;
	}
	
	for(int i=0;i<a.size();i++){
		if(a[i]>=2){
			cout << "no" << endl;
			return 0;
		}
	}
	
	cout << "yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

int line[5];

int main()
{
	for(int i=0;i<5;i++)scanf("%d",&line[i]);
	sort(line,line+5);
	for(int i=4;i>=0;i--)
	{
		printf("%d",line[i]);
		if(i!=0)printf(" ");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>

typedef long long LL;
const int MX = 2e3 + 5, N = 2e5 + 5, MOD = 1e9 + 7;
int a[N], b[N], n;
LL f[(MX<<1) + 5][(MX<<1) + 5];
LL jc[(MX<<2) + 5], inv[(MX<<2) + 5], invjc[(MX<<2) + 5];
LL ans;
inline int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){if (ch == '-')f = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
inline void add(LL &a, LL b) {
    a += b;
    if (a >= MOD)a -= MOD;
}
inline LL calc(int a, int b) {
    return (LL)jc[a] * invjc[b] % MOD * invjc[a - b] % MOD;
}
int main() {
    n = read();
    for (int i = 1; i <= n; ++i) {
        a[i] = read();
        b[i] = read();
        f[MX - a[i]][MX - b[i]]++;
    }
    for (int i = 1; i <= (MX << 1); ++i) {
        for (int j = 1; j <= (MX << 1); ++j) {
            add(f[i][j], f[i - 1][j]);
            add(f[i][j], f[i][j - 1]);
        }
    }
    invjc[0] = invjc[1] = inv[0] = inv [1] = jc [0] = jc [1] = 1;
    for (int i = 2; i <= (MX << 2); ++i)jc[i] = (LL)jc[i - 1] * i % MOD;
    for (int i = 2; i <= (MX << 2); ++i)inv[i] = (LL)(MOD - MOD / i) * inv[MOD % i] % MOD;
    for (int i = 2; i <= (MX << 2); ++i)invjc[i] = (LL)invjc[i - 1] * inv[i] % MOD;
    for (int i = 1; i <= n; ++i)add(ans, f[a[i] + MX][b[i] + MX]);
    for (int i = 1; i <= n; ++i)add(ans, MOD - calc(2 * (a[i] + b[i]), 2 * a[i]));
    printf("%lld\n", ans * inv[2] % MOD);
    return 0;
}


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

typedef long long ll;

int main() {

   int n;
   cin >> n;

   vector<ll> dp(3, 0);
   // dp[i] = max value obtained by taking ith item at previous step

   for (int day = 0; day < n; day++) {
       vector<int> v(3);
       for (int i=0; i<3; i++)
        cin >> v[i];

       vector<ll> new_dp(3, 0);

       for (int i=0; i<3; i++)
        for (int j=0; j<3; j++) {
            if (i != j) {
                new_dp[j] = max(new_dp[j], dp[i] + v[j]);
            }
        }
     
       dp = new_dp;
   }

   cout << max({dp[0], dp[1], dp[2]}) << endl;
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c;

    if (a>b){
        d = a; a = b; b = d;
    }
    if (b>c){
        d = b; b = c; c = d;
    }
    if (a>b){
        d = a; a = b; b = d;
    }
    cout << a << " " << b << " " << c <<endl;
    return 0;
}


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

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

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let a: Vec<i32> = (0..n).map(|_| read()).collect();
    let mut ans = 0;

    'outer: for shift in 0..32 {
        for i in a.iter() {
            if (i >> shift) & 1 == 1 {
                break 'outer;
            }
        }
        ans += 1;
    }
 
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(n,a) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define int ll

int n;
int a[1110];

signed main(){
  cin>>n;
  rep(i,n){
    cin>>a[i];
  }

  int i=0;
  int ans=0;
  while(i+1<n){
    int j=i;
    while(i<n&&a[j]==a[i]){
      i++;
    }
    ans+=(i-j)/2;
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
import numpy as np
import numba
from numba import njit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

i4 = numba.int32

def get_input():
    D = int(readline())
    C = np.array(readline().split(), np.int32)
    S = np.array([readline().split() for _ in range(D)], np.int32)
    return D, C, S

@njit((i4, i4[:], i4[:, :], i4[:]), cache=True)
def first_computation(D, C, S, T):
    x = 0
    last = np.zeros((26, D), np.int32)
    for d in range(D):
        if d:
            last[:, d] = last[:, d - 1]
        i = T[d]
        x += S[d, i]
        last[i, d] = d + 1
        for i in range(26):
            x -= C[i] * (d + 1 - last[i, d])
    return last, x

@njit((i4, i4[:], i4[:, :], i4[:], i4[:, :], i4, i4), cache=True)
def difference_update(D, C, S, T, last_day, d, q):
    p = T[d]
    T[d] = q
    x = S[d, q] - S[d, p]

    i = np.searchsorted(last_day[p], d + 1)
    d_p = last_day[p, i - 1] if i >= 1 else 0
    coef = 0
    for k in range(d, D):
        if last_day[p, k] == d + 1:
            # k 日目に入るスコアの変更
            coef += d_p - d - 1
            last_day[p, k] = d_p
        else:
            break
    x += coef * C[p]

    coef = 0
    for k in range(d, D):
        if last_day[q, k] < d + 1:
            coef += (d + 1 - last_day[q, k])
            last_day[q, k] = d + 1
        else:
            break
    x += coef * C[q]
    return x

@njit((i4, i4[:], i4[:, :], i4[:], i4[:, :], i4), cache=True)
def swap_update(D, C, S, T, last_day, d):
    p = T[d]
    q = T[d + 1]
    if p == q:
        return 0
    x = difference_update(D, C, S, T, last_day, d, q)
    x += difference_update(D, C, S, T, last_day, d + 1, p)
    return x

def output(T):
    T += 1
    print(*T, sep='\n')

@njit((i4, i4[:], i4[:, :], i4[:], i4[:, :]), cache=True)
def random_update(D, C, S, T, last_days):
    d = np.random.randint(0, D, 1)[0]
    p = T[d]
    xcum = 0
    for q in range(26):
        if p == q:
            continue
        xcum += difference_update(D, C, S, T, last_days, d, q)
        if xcum > 0:
            return q, xcum
    difference_update(D, C, S, T, last_days, d, p)
    return p, 0

@njit((i4, i4[:], i4[:, :], i4[:], i4[:,:]), cache=True)
def main(D, C, S, T, last_days):
    for _ in range(10**5):
        d = np.random.randint(1, D-1, 1)[0]
        x = swap_update(D,C,S,T,last_days,d)
        if x < 0:
            swap_update(D,C,S,T,last_days,d)
        random_update(D, C, S, T, last_days)[1]
    return T

def first_strategy(D, C, S):
    T = np.empty(D, np.int32)
    for d in range(D):
        T[d] = d % 26
    return T

D, C, S = get_input()

T = first_strategy(D, C, S)
last_days, score = first_computation(D, C, S, T)
T = main(D,C,S,T,last_days)
output(T)

Measured memory_bytes: 108380
if __name__ == "__main__":
    n = int(input())
    l_a = list(map(int, input().split()))
    s_a = list(set(l_a))

    s_a.sort()

    dub_a = [0]*(max(s_a)+1)

    for i in l_a:
        dub_a[i] += 1

    dp = [1]*(max(s_a)+1)

    for i in s_a:
        if dp[i] == 0:
            pass
        else:
            for j in range(2*i, len(dp), i):
                dp[j] = 0


    count = 0
    for i in s_a:
        if dp[i]==1 and dub_a[i]==1:
            count += 1
    print(count)

Measured memory_bytes: 34932
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int w[101000], n, D[101000];
vector<int>E[101000];
void DFS(int a, int pp){
    int i, x, ck = 0, Mx = 0;
    long long s = 0;
    for(i=0;i<E[a].size();i++){
        x = E[a][i];
        if(x==pp)continue;
        DFS(x, a);
        ck = 1;
        if(D[x]==-1){
            D[a]=-1;
            return;
        }
        Mx = max(Mx, D[x]);
        s += D[x];
    }
    if(!ck){
        D[a]=w[a];
        return;
    }
    if(s > w[a]*2 || s < w[a] || Mx > w[a]){
        D[a]=-1;
        return;
    }
    D[a] = w[a]*2-s;
}
int main(){
    int i, a, b;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&w[i]);
    }
    if(n==2){
        printf(w[1]==w[2]?"YES\n":"NO\n");
        return 0;
    }
    for(i=1;i<n;i++){
        scanf("%d%d",&a,&b);
        E[a].push_back(b);
        E[b].push_back(a);
    }
    for(i=1;i<=n;i++)if(E[i].size()!=1)break;
    DFS(i,0);
    printf(D[i]?"NO\n":"YES\n");
}

Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=100100100100;
const int Inf=1001001001;
const int mod=1000000007;
int main(){
    int r,d,a;cin>>r>>d>>a;
    vi v(11);
    v[0]=a;
    rep(i,10)v[i+1]=v[i]*r-d;
    rep(i,10)cout<<v[i+1]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
// #include <regex> //正規表現
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
// グリッドグラフの移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

string S; cin >> S;

if (S == "Sunny") cout << "Cloudy" << endl;
else if (S == "Cloudy") cout << "Rainy" << endl;
else if (S == "Rainy") cout << "Sunny" << endl;

}

// 境界，出力文字列 チェック



Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a + b) * c / 2 << endl;
}


Measured memory_bytes: 256
import bisect
N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
ans = 0
for i in range(N): ans += bisect.bisect_left(A,B[i]) * (N-bisect.bisect_right(C,B[i]))
print(ans)

Measured memory_bytes: 23180
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll f(ll n){
    return (n*n + 4) / 8;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,x;
    cin >> a >> b >> x;
    ll v1 = a / x;
    ll v2 = b / x;
    ll ans = v2 - v1;
    if(a % x == 0){
        ans++;
    }
    print(ans);
}


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;
using P = pair<int, int>;

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

Measured memory_bytes: 3636
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto A = s[1];
    auto B = s[2];

    if (N > 1L * A * B || N < A + B - 1) {
        writeln(-1);
        return;
    }

    auto lens = new int[](A);
    lens.fill(1);
    lens[0] = B;

    int rest = N - B - A + 1;
    for (int i = 1; i < N && rest > 0; ++i) {
        int x = min(B-1, rest);
        lens[i] += x;
        rest -= x;
    }

    auto ans = new int[](N);
    int pos = 0;
    int num = 1;
    foreach (i; 0..A) {
        foreach (j; 0..lens[i]) {
            ans[pos+lens[i]-j-1] = num++;
        }
        pos += lens[i];
    }

    
    ans.map!(to!string).join(" ").writeln;
}


Measured memory_bytes: 7036
#include <bits/stdc++.h>
#define All(v) v.begin(), v.end()
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

lint x[55], y[55];
const int MAX_N = 55;
int parent[MAX_N], r[MAX_N];

void init(int n){
    for(int i=0;i<n;i++){
        parent[i] = i;
        r[i] = 0;
    }
}

int find(int x){
    if(parent[x] == x) return x;
    else return parent[x] = find(parent[x]);
}

void unite(int x, int y){
    x = find(x); y = find(y);
    if(x == y) return;
    if(r[x]<r[y]) parent[x] = y;
    else{
        parent[y] = x;
        if(r[x] == r[y]) r[x]++;
    }
}


int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>x[i]>>y[i];
    }
    lint ans = 2 * N;
    if(N==1) {cout<<1<<endl; return 0;}
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i==j) continue;
            lint p=x[j]-x[i], q=y[j]-y[i];
            init(N);
            unordered_set<int> S;
            for(int k=0;k<N;k++){
                for(int l=0;l<N;l++){
                    if(x[l]-x[k]==p and y[l]-y[k]==q) unite(k, l);
                }
            }
            for(int k=0;k<N;k++) S.emplace(find(k));
            ans=min(ans, (lint)S.size());
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

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

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);

  for(int i= 0; i<N; i++){
    cin >> A.at(i);
  }

  vector<ll> B(N);
  vector<ll> C(N);
  vector<ll> M(N);
  B.at(0) = A.at(0);
  for(int i = 1; i<N; i++){
    B.at(i) = gcd(B.at(i-1), A.at(i));
  }


  C.at(N-1) = A.at(N-1);
  for(int i = N-2; i>= 0 ; i--){
    C.at(i) = gcd(C.at(i+1), A.at(i));
  }
  for(int i = 0; i<N; i++){
    if(i == 0){
      M.at(i) = C.at(i+1);
    }else if(i == N-1){
      M.at(i) = B.at(i-1);
    }else{
      M.at(i) = gcd(B.at(i-1), C.at(i+1));
    }
  }

  sort(M.rbegin(), M.rend());
  cout << M.at(0) << endl;



}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;
int main(){
    int k,x;
    cin>>k>>x;
    rep(i,max(-1000000,x-(k-1)),min(1000000,x+(k-1))+1){
        cout<<i;
        if(i==min(1000000,x+(k-1))) cout<<endl;
        else cout<<" ";
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    string s;
    cin >> s;
    int n=s.size();
    int ans = 1000;
    rep(i,n-2){
        int k = (s[i]-'0')*100 + (s[i+1]-'0')*10 + (s[i+2]-'0');
        ans = min(ans,abs(753 - k));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3552
M = [int(input()) for _ in range(5)]
m = []
T = 0
for i in range(5):
    if M[i] % 10 == 0:
        T += M[i]
    else:
        T += M[i]
        T += 10 - M[i] % 10
        m.append(M[i] % 10)
print(T - (10 - (10 if not m else min(m))))

Measured memory_bytes: 3060
import java.util.*;
fun main() {
    val sc=Scanner(System.`in`)
    val n=sc.nextInt();
    var cnt=0
    for(i in 1..n){
        if(sc.nextInt()==sc.nextInt()){
            cnt++
        }else{
            cnt=0
        }
        if(cnt==3){
            println("Yes")
            return
        }
    }
    println("No")
}

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

#define N 1000

int CalLCS(char *,char *);

int main(){
  int loop;
  int count=0;
  int result=0;
  char lcsX[N],lcsY[N];

  scanf("%d",&loop);

  while(1){
    if(count==loop){
      break;
    }

    else{
      scanf("%s",lcsX);
      scanf("%s",lcsY);
      result=CalLCS(lcsX,lcsY);
    }

    printf("%d\n",result);
    count++;
  }
  
  return 0;
}

int CalLCS(char *lcsX,char *lcsY){
  int Xlength;
  int Ylength;
  int i,j;
  int LCS[N+1][N+1];
  int MLCS=0;


  Xlength=strlen(lcsX);
  Ylength=strlen(lcsY);

  for(i=1;i<=Xlength;i++){
    LCS[i][0]=0;
  }

  for(i=1;i<=Ylength;i++){
    LCS[0][i]=0;
  }

  for(i=1;i<=Xlength;i++){
    for(j=1;j<=Ylength;j++){

      if(lcsX[i-1]==lcsY[j-1]){
	LCS[i][j]=LCS[i-1][j-1]+1;
      }

      else if(LCS[i-1][j]>=LCS[i][j-1]){
	LCS[i][j]=LCS[i-1][j];
      }

      else if(LCS[i][j-1]>LCS[i-1][j]){
	LCS[i][j]=LCS[i][j-1];
      }
      
    }
  }

  for(i=0;i<=Xlength;i++){
    for(j=0;j<=Ylength;j++){

      if(MLCS<LCS[i][j]){
	MLCS=LCS[i][j];
      }
      
    }
  }

 
  return MLCS;
}



Measured memory_bytes: 5616
#include<string>
#include<iostream>
using namespace std;
int main(){
	int n;
	
	while(cin>>n,n){
	bool a[100000]={0};
	int ans=0;
	for(int i=1;i<=n;i++){
		bool tmp;
		cin>>tmp;
		if(i%2==1)a[i-1]=tmp;
		else{
			if(tmp==a[i-2]){//右端とおくやつが同じなら
				a[i-1]=tmp;
			}
			else{
				//cout<<"i"<<i;
				int j=i-2;
				bool ki=tmp;
				while(true){
					if(tmp!=a[j]){
						a[j]=tmp;
					}
					else if(tmp==a[j]||j<0) break;
					j--;
				}
				a[i-1]=tmp;
			}
		}
		}
		for(int i=0;i<n;i++)if(a[i]==0)ans++;
			cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1264
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(13 <= a) System.out.println(b);
        else if(a < 6) System.out.println(0);
        else System.out.println(b/2);
        sc.close();

    }

}


Measured memory_bytes: 21844