akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


i64 T, n, m, to[10101];
vector<int> v[404];
vector<P> G[404];
vector<vector<int>> dist(404, vector<int>(404, INF));
vector<int> route[404][404];
i64 now = 1, next_t = 0;
i64 have[404] = {0};

i64 para[2] = {180, 16};

void floyd(){
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			for(int k = 1; k <= n; k++){
				if(dist[j][k] > dist[j][i] + dist[i][k]){
					//route[j][k] = route[j][i]+route[i][k];
					route[j][k] = route[j][i];
					route[j][k].insert(route[j][k].end(),route[i][k].begin(),route[i][k].end());
					dist[j][k] = dist[j][i] + dist[i][k];
				}
			}
		}
	}
}

P choice_next(int start, i64 t){
	i64 ma = -1, k = -1;
	for(int i = 2; i <= n; i++){
		if(!have[i]) continue;
		if(dist[start][i] >= T-t) continue;
		i64 cnt = 0;
		for(int j = 0; j < route[start][i].size(); j++){
			cnt += have[route[start][i][j]];
		}
		if(ma < cnt * para[0] / (dist[start][i])){
			ma = cnt * para[0] / (dist[start][i]);
			k = i;
		}
	}
	return P(ma, k);
}

int Move(int start, i64 next_t){
	P choice = choice_next(start, next_t);
	i64 ma = choice.first, k = choice.second;
	if(ma >= para[1]){
		int npos = route[start][k][0];
		have[npos] = 0;
		for(int i = 0; i < dist[now][npos]; i++){
			if(next_t >= T) break;
			next_t++;
			cout << npos << endl;
		}
		now = npos;
		next_t = Move(now, next_t);
		
		return next_t;
	}
	for(int i = route[1][now].size()-2; i >= -1; i = route[1][now].size()-2){
		int npos;
		if(i == -1) npos = 1;
		else npos = route[1][now][i];
		for(int j = 0; j < dist[now][npos]; j++){
			if(next_t >= T) break;
			next_t++;
			cout << npos << endl;
		}
		now = npos;
	}
	return next_t;
}

int main(){
	cin >> n >> m;
	for(int i = 0; i <= n; i++){
		dist[i][i] = 0;
	}
	for(int i = 0; i < m; i++){
		int a,b,c;
		cin >> a >> b >> c;
		G[a].push_back(P(b,c));
		G[b].push_back(P(a,c));
		dist[a][b] = c;
		dist[b][a] = c;
		route[a][b].push_back(b);
		route[b][a].push_back(a);
	}
	cin >> T;
	for(int i = 0; i < T; i++){
		int a,b,c;
		cin >> a;
		if(a){
			cin >> b >> c;
			v[c].push_back(i);
			to[i] = c;
		}
	}
	
	floyd();
	
	for(i64 t = 0; t < T; t++){
		if(now == 1) have[to[t]]++;
		if(next_t > t) continue;
		next_t = Move(1, t);
		if(next_t == t){
			cout << -1 << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 27136
#include<stdio.h>
int main (void)
{
  int n,num,a[4][14]={},i,j;
  char s,r;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    s=0;
    num=0;
    scanf("%c%c%d",&r,&s,&num);
    if(s=='S'){a[0][num]=1;}
    if(s=='H'){a[1][num]=1;}
    if(s=='C'){a[2][num]=1;}
    if(s=='D'){a[3][num]=1;}
  }
  for(i=0;i<4;i++){
    for(j=1;j<14;j++){
      if(a[i][j]==0){
    if(i==0){printf("S %d\n",j);}
    if(i==1){printf("H %d\n",j);}
    if(i==2){printf("C %d\n",j);}
    if(i==3){printf("D %d\n",j);}
      }
    }
  }
  return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long A, B;
	cin >> A >> B;
	for (long long i = 1; i < 1e5; i++){
		if ((A * i) % B == 0) {
			cout << A * i << endl;
			return 0;
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

int porcentaje(int total, int porcentaje) {	
	return (porcentaje * total) / 100;
}

int main() {
	optimizar_io
	int a, b;

	cin >> a >> b;
	for (int i = 1; i <= 1e6; i++) {
		if (porcentaje(i, 8) == a and b == porcentaje(i, 10)) {
			cout << i << "\n";
			return 0;
		}
	}
	cout << "-1\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int fw[200005];
int n;
int sum(int x){
    int ans =1000000;
    while (x){
        ans = min(ans,fw[x]);
        x -= (x)&(-x);
    }
    return ans;
}
void up(int x,int v){
    while (x <= 2*n+3){
        fw[x] = min(v,fw[x]);
        x += (x)&(-x);
    }
}
int main(){
    string s;
    cin >> s;
    n = s.size();
    int a[n];
    for (int i = 0; i < n; i++) a[i] = s[i]-'a';
    for (int k = 0; k < 26; k++){
        for (int i = 0; i < 200005; i++){
            fw[i] = 1000000;
        }
        int cur = n+1;
        up(n+1,-1);
        int b[n];
        for (int i = 0; i < n; i++){
            if (a[i] == k) cur++;
            else cur--;
            //printf("%c %d %d\n",k+'a',i,cur);
            b[i] = cur;
            int p = sum(cur-1);

            if (i-p >= 2){
                printf("%d %d\n",p+2,i+1);
                return 0;
            }
            if (i >= 1) up(b[i-1],i-1);
        }
    }
    printf("-1 -1\n");
}


Measured memory_bytes: 2048
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    ll n, b = 0, z = 0;
    cin >> n;
    ll a[n + 1];
    for (ll i = 1 ; i <= n ; i++) cin >> a[i], a[i] -= i;
    sort(a + 1, a + n + 1);
    if (n % 2) b = a[n / 2 + 1]; 
    else b = a[n / 2];
    for (ll i = 1 ; i <= n ; i++) z += abs(a[i] - b); 
	cout << z;
}

Measured memory_bytes: 5136
#include <stdio.h>
int gcd(int x, int y, int z){
    int i = 1, gcd;
    while(i <= x && i <= y && i <= z){
        if(x % i == 0 && y % i == 0 && z % i == 0) gcd = i;
        i++;
    }
    return gcd;
}

int main(void){
    int i, j, K, l, sum = 0;
    scanf("%d", &K);
    for(i=1;i<=K;i++){
        for(j=1;j<=K;j++){
            for(l=1;l<=K;l++) sum += gcd(i, j, l);
        }
    }
    printf("%d\n", sum);
    
    return 0;
}

Measured memory_bytes: 1732
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int min = Integer.MAX_VALUE;
        int minIndex = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if (min > a[i]) {
                min = a[i];
                minIndex = i;
            }
        }

        int alive = n;
        while (true) {
            for (int i = 0; i < n; i++) {
                if (a[i] > 0 && i != minIndex) {
                    a[i] = a[i] % min;
                    if (a[i] <= 0) {
                        alive--;
                    }
                    if (a[i] > 0 && min > a[i]) {
                        min = a[i];
                        minIndex = i;
                    }

                    if (alive == 1) {
                        System.out.print(a[minIndex]);
                        return;
                    }
                }
            }
        }
    }

}

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

typedef long long ll;

int main(){
    int a,b;
    cin >> a >>b;
    if(a+b==15){
        cout<< '+'<<"\n";
    }else if(a*b==15){
        cout<< '*'<<"\n";
    }else{
        cout<<"x";
    }
}


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

int main(){

    ll n; cin >> n;
    ll in;
    vector<vector<P>> a(n);
    rep(i, n){
        cin >> in;
        ll x, y;
        rep(j, in){
            cin >> x >> y;
            a[i].push_back({x, y});
        }
    }

    ll mx = 0;
    rep(bit, 1<<n){
        bitset<15> bs(bit);
        bool b = false;
        rep(i, n){
            if(bs.test(i)){
                rep(j, a[i].size()){
                    if(bs.test(a[i][j].first-1) != a[i][j].second){
                        b = true;
                        break;
                    }
                }
                if(b) break;
            }
        }
        if(!b){
            ll cnt = 0;
            rep(i, n) if(bs.test(i)) cnt++;
            mx = max(mx, cnt);
        }
    }

    cout << mx << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
using namespace std;

int main(void){
  int i,n,m,x,y,a=0;
  int d[200001],e[200001];

  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    d[i]=0;e[i]=0;
  }
  for(i=0;i<m;i++){
    scanf("%d %d",&x,&y);
    if(x==1)
      d[y]=1;
    if(y==n)
      e[x]=1;
  }

  for(i=0;i<n;i++){
    if(d[i]==1&&e[i]==1){
      a = 1;
      break;
    }
  }

  if(a==1)
    printf("POSSIBLE\n");
  else
    printf("IMPOSSIBLE\n");

  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

int main()
{
    fastio;
    long long n,i,j,k,sum=0,high,low,mid,p;
    static long long ara[103];
    cin>>n;
    for(i=0;i<n;i++)
        cin>>ara[i];
    sort(ara,ara+n);
    for(i=0;i<n-2;i++)
    {
        for(j=i+1;j<n-1;j++)
        {
            if(ara[i]==ara[j])
                continue;
            else
            {
                for(k=j+1;k<n;k++)
                {
                    if(ara[j]==ara[k])
                        continue;
                    else
                    {
                        low=k;
                        high=n-1;
                        p=0;
                        while(low<=high)
                        {
                            mid=(low+high)/2;
                            if(ara[mid]>=ara[i]+ara[j] && ara[mid-1]<ara[i]+ara[j])
                            {
                                sum=sum+mid-k;
                                p=1;
                                break;
                            }
                            else if(ara[mid]<ara[i]+ara[j])
                                low=mid+1;
                            else if(ara[mid]>=ara[i]+ara[j])
                                high=mid-1;
                        }
                        if(p==0)
                            sum=sum+n-k;
                        break;
                    }
                }
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}


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

using static Input;
//using static Util;
class Program
{
    static int N;
    static int M;
    static int[] A;
    static void INPUT()
    {
        N = NextInt();
        M = NextInt();
        A = LineInt();
    }
    static void OUT()
    {
        var total = A.Sum();
        var t = (float)total / (M * 4);

        var count = 0;
        foreach (var a in A)
        {
            count += a < t ? 0 : 1;
        }

        Console.WriteLine(count >= M ? "Yes" : "No");
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{
}




Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(i);
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5])
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
S = input()
Q = int(input())
reverseCount = 0
pre = ""
pro = ""
for _ in range(Q):
    query = input()
    if len(query) == 1:
        reverseCount += 1
    else:
        _, F, C = query.split(" ")
        if (int(F) + reverseCount) % 2 == 1:
            pre = C + pre
        else:
            pro = pro + C
S = pre + S + pro
if reverseCount % 2 == 0:
    print(S)
else:
    print(S[::-1])


Measured memory_bytes: 4600
a,b,x=map(int,input().split())
from math import*

# if a*a*b/2<=x:
#     c=2*x/a/a-b
#     theta=atan((b-c)/a)
#     print(theta*180/pi)
# else:
#     d=a-2*x/b/a
#     theta=atan(b/(a-d))
#     print(theta*180/pi)

def check(theta):
    theta_pi=theta*pi/180
    if a*a*b/2<=x:
        youryo=a*a*0.5*(b+b-a*tan(theta_pi))
    else:
        youryo=a*b*0.5*b/tan(theta_pi)
    
    return youryo>=x
    
top=90 #ng
bottom=0 #ok
while top-bottom>1e-10:
    mid=(top+bottom)*0.5
    if check(mid):
        bottom=mid
    else:
        top=mid
        
print(bottom)

#please

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <string>
using namespace std;

int main(void){
    int n, a[100010], b[100010];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    
    sort(a, a + n);
    
    long long ans = 0;
    
    if (n % 2 == 0) {
        b[0] = a[(n - 1) / 2];
        b[n - 1] = a[n / 2];
        
        for (int i = 1; i < n - 1; i++) {
            if (i % 2 != 0) b[i] = a[n - 1 - i / 2];
            else b[i] = a[i / 2 - 1];
        }
    }
    else {
        if (a[n / 2] - a[n / 2 - 1] < a[n / 2 + 1] - a[n / 2]) {
            b[0] = a[n / 2];
            b[n - 1] = a[n / 2 - 1];
            
            for (int i = 1; i < n - 1; i++) {
                if (i % 2 != 0) b[i] = a[n - 1 - i / 2];
                else b[i] = a[i / 2 - 1];
            }
        }
        else {
            b[0] = a[n / 2];
            b[n - 1] = a[n / 2 + 1];
            
            for (int i = 1; i < n - 1; i++) {
                if (i % 2 != 0) b[i] = a[i / 2];
                else b[i] = a[n - i / 2];
            }
        }
    }
    
    for (int i = 0; i < n - 1; i++) {
        ans += abs(b[i + 1] - b[i]);
//        cout << b[i] << " ";
    }
//    cout << b[n - 1] << endl;
    
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    ll N;
    cin >> N;
    ll A = 0;
    for(ll i = 0; i < N; i++){
        ll a;
        cin >> a;
        A |= a;
    }
    if(A & 1)cout << "first" << endl;
    else cout << "second" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=1e3+4;
const int MD=1e9+7;
ll dp[M][M];
char mat[M][M];
int main()
{
	int h,w;
	cin>>h>>w;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		cin>>mat[i][j];
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(i==1 && j==1) dp[i][j]=1;
			else
			{
				if(mat[i][j]=='.')
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MD;
				else 
				dp[i][j]=0;
			}
		}
	}
	cout<<dp[h][w];
	return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX = 100005;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;

bool a[10];
int main()
{
    int n;
    cin >> n;
    int ans = 0, qq = 0, tem;
    while(n--)
    {
        cin >> tem;
        if(tem < 400) a[0] = true;
        else if(tem < 800) a[1] = true;
        else if(tem < 1200) a[2] = true;
        else if(tem < 1600) a[3] = true;
        else if(tem < 2000) a[4] = true;
        else if(tem < 2400) a[5] = true;
        else if(tem < 2800) a[6] = true;
        else if(tem < 3200) a[7] = true;
        else qq++;
    }
    for(int i = 0; i < 8; ++i)
    {
        if(a[i]) ans++;
        //cout << a[i] << " ";
    }
    //cout << endl;
    int maxx;
    if(qq)
        maxx = ans+qq;
    else
        maxx = ans;
    if(ans == 0) ans = 1;
    //if(maxx == 0) maxx = 1;
    cout << ans << " " << maxx;
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())


A = [int(s) for s in input().split()]

A = [(a-A[0])%m for a in A]

end = A[-1]

dist = [0]*m
cycles = 0
x = 0

for a,b in zip(A[:-1],A[1:]):
  cycles += b < a
  dist[b] += (b-a)%m
  x += min((b-a)%m, 1 + b)

dist[0] += 1

res = x

for k in range(m):

  x += dist[k]
  x -= cycles + (k <= end)

  res = min(res, x)

print(res)

Measured memory_bytes: 13880
import numpy as np
import math

_, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

logk = 50
half = len(a) / 2

base = np.array([2**i for i in range(logk + 1)])

a = np.array(a)

ones = a[:,None] & base > 0
zeros = (ones != True)

# print(base[:5])
# print(ones)
# print(zeros)

no = np.sum(ones, axis=0)
nz = np.sum(zeros, axis=0)

ov = no * base
zv = nz * base

# print(no)
# print(nz)

inc = ov < zv

inceq = ov == zv
# vi = np.sum(v * base)


# def largest(fx, kk, i):
#     if i == len(base):
#         return fx

#     kone = kk + base[i]
#     if kone > k:
#         return fx

#     kzero = kk
#     fzero = fx + ov[i]
#     fone = fx + zv[i]
#     return max(largest(fzero, kzero, i + 1), largest(fone, kone, i + 1))

# print(largest(0, 0, 0))

kk = [0]
fx = [0]
for i, b in reversed(list(enumerate(base))):
    for j in range(len(fx)):
        added = kk[j] + b
        if (inc[i] or inceq[i]) and added <= k:
            if inceq[i]:
                fx.append(fx[j] + ov[i])
                kk.append(kk[j])
            fx[j] += zv[i]
            kk[j] += b

        else:
            fx[j] += ov[i]

print(max(fx))


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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*（๑•﹏•๑｀) */

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

	if (M == 0){
		if (K != 0){
			puts("-1");
		}else{
			puts("0 0");
		}

		return 0;
	}

	if (M == 1){
		if (K == 0){
			puts("0 0 1 1");
		}else {
			puts("-1");
		}

		return 0;
	}

	int N = 1;

	FORq(i,1,M){
		N *= 2;
	}

	N--;

	if (N < K){
		puts("-1");
		return 0;
	}

	FORq(i,0,N){
		if (i == K) continue;
		cout << i << " ";
	}

	cout << K << " ";

	FORqr(i,0,N){
		if (i == K) continue;
		cout << i << " ";
	}

	cout << K << " " << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>

using namespace std;
const int MaxN = 55;
int n, k, m, v[MaxN];
pair<int, int> ops[2 * MaxN];

inline void solveneg()
{
    for (int i = n - 1; i >= 1; i--) if(v[i] > v[i + 1])
    {
        v[i] += v[i + 1];
        ops[++m] = {i + 1, i};
    }
}

inline void solvepoz()
{
    for (int i = 2; i <= n; i++) if(v[i] < v[i - 1])
    {
        v[i] += v[i - 1];
        ops[++m] = {i - 1, i};
    }
}

int main()
{
    cin >> n;
    int maxi = -1000001, mini = 1000001, pmini, pmaxi;
    for (int i = 1; i <= n; i++)
    {
        cin >> v[i];
        if (v[i] > maxi) maxi = v[i], pmaxi = i;
        if (v[i] < mini) mini = v[i], pmini = i;
    }
    bool ok = 1;
    for (int i = 2; i <= n; i++) if(v[i] < v[i - 1]) ok = 0;
    if (ok)
    {
        cout << 0 << '\n';
        return 0;
    }
    if (mini >= 0) solvepoz();
    if (maxi <= 0) solveneg();
    if (maxi > 0 && mini < 0)
    {
        if (-mini > maxi)
        {
            for (int i = 1; i <= n; i++) if (v[i] != mini)
            {
                v[i] += mini;
                ops[++m] = {pmini, i};
            }
            solveneg();
        }
        else
        {
            for (int i = 1; i <= n; i++) if (v[i] != maxi)
            {
                v[i] += maxi;
                ops[++m] = {pmaxi, i};
            }
            solvepoz();
        }
    }
    cout << m << '\n';
    for (int i = 1; i <= m; i++) cout << ops[i].first << ' ' << ops[i].second << '\n';
    return 0;
}


Measured memory_bytes: 256
N = gets.strip.to_i
a = gets.strip.split.map(&:to_i)
cum_a = [a[0]]
(1..N-1).each do |index|
  cum_a[index] = cum_a[index-1]+a[index]
end


result = nil
(0..N-2).each do |index|
  left_score = cum_a[index]
  right_score = cum_a.last-left_score
  diff = right_score - left_score
  score = diff.abs
  result = score if result.nil? || result > score
end

puts result


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

vector<bool> prime_table(int n)
{
    vector<bool> prime(n + 1, true);
    if (n >= 0)
        prime[0] = false;
    if (n >= 1)
        prime[1] = false;
    for (int i = 2; i * i <= n; i++)
    {
        if (!prime[i])
            continue;
        for (int j = i + i; j <= n; j += i)
        {
            prime[j] = false;
        }
    }
    return prime;
}

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

    ll N;
    string S;
    cin >> N;
    auto t = prime_table(250);
    ll ans = 0;
    for (int i = 1; i < N;i=i+2)
    {
        for (ll j = i + 2; j < N; j = j + 2)
        {
            for (ll k = j + 2; k < N; k = k + 2)
            {
                if(t[i]&&t[j]&&t[k]){
                    ll p = i * j * k;
                    if(p<=N){
                        ans++;
                    }
                }
            }
        }
    }
    if(N>=135){
        ans++;
    }
    if(N>=189){
        ans++;
    }
    cout << ans << endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009
#define ar pairs

using namespace std;

typedef long long lli;
#define int long long
struct pa{
	int x, y;
	bool operator<(pa &other){
		return x < other.x;
	};
}pairs[100005];

signed main(){
	ios_base::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	for(int i=0; i<n; i++){
		int x, y;
		cin >> x >> y;
		pairs[i] = {x, y};
	}

	sort(pairs, pairs+n);

	int res = 0;
	for(int i=0; i<n; i++){
		if(m <= ar[i].y){
			res += ar[i].x * m;
			break;
		}
		res += ar[i].x * ar[i].y;
		m -= ar[i].y;

	}

	cout << res;

	return 0;
}

Measured memory_bytes: 1792
x1, y1, x2, y2 = map(int, input().split())

x4, y4 = x1-(y2-y1), y1+(x2-x1)
x3, y3 = x4+(x2-x1), y4+(y2-y1)

print(f'{x3} {y3} {x4} {y4}')



Measured memory_bytes: 9032
fun main(arr: Array<String>) {
    println(if(mustWar()) "War" else "No War")
}

fun mustWar():Boolean {
    val (n,m,x,y) = readLine()!!.split(" ").map { it.toInt() }
    val xCities = readLine()!!.split(" ").map { it.toInt() }.sorted()
    val yCities = readLine()!!.split(" ").map { it.toInt() }.sorted()
    if(x >= y) {
        return true
    }
    if(xCities.last() >= yCities.first()) {
        return true
    }
    if(xCities.last() >= y) {
        return true
    }
    if(x >= yCities.first()) {
        return true
    }
    return false
}


Measured memory_bytes: 40444
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
	if(y<=0) return 1;
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//------------------------------------------------------------------------------------------

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);


	ll n;
	cin>>n;
	map<string , int> mp;
	string s;
	
	for(int i=0;i<n;i++){
		cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<"\n";
	cout<<"WA x "<<mp["WA"]<<"\n";
	cout<<"TLE x "<<mp["TLE"]<<"\n";
	cout<<"RE x "<<mp["RE"]<<"\n";
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
map<int,string> m;
int dp[105][5][5][5];
bool check(int a,int b,int c,int d)
{

//    if(m[a]+m[c]+m[b]=="AGC")
//        return false;
//    if(m[a]+m[b]+m[c]=="AGC")
//        return false;
    if(m[a]+m[c]+m[d]=="AGC")
        return false;
    if(m[a]+m[b]+m[d]=="AGC")
        return false;
    if(m[b]+m[c]+m[d]=="AGC")
        return false;
    if(m[b]+m[d]+m[c]=="AGC")
        return false;
//    if(m[b]+m[a]+m[c]=="AGC")
//        return false;
    if(m[c]+m[b]+m[d]=="AGC")
        return false;
    return true;
}
int main()
{
    int n;
    scanf("%d",&n);
   dp[0][0][0][0]=1;
    m[0]='W',m[1]='A',m[2]='C',m[3]='G',m[4]='T';
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=4; j++)
        {
            for(int k=0; k<=4; k++)
            {
                for(int l=0; l<=4; l++)
                {
                    for(int m=0; m<=4; m++)
                    {
                        if(check(m,l,k,j))
                            dp[i][j][k][l]=(dp[i][j][k][l]+dp[i-1][k][l][m])%mod;
                    }
                }
            }
        }
    }
    int ans=0;
    for(int i=1;i<=4;i++){
        for(int j=1;j<=4;j++){
            for(int k=1;k<=4;k++){
                ans=(ans+dp[n][i][j][k])%mod;
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
A, B, C, D = map(int, input().split())
def gcd(a,b):
    while b != 0:
        a, b = b, a%b
    return a
def lcm(a,b):
    return int(a*b / gcd(a,b))
X = A-B
Y = lcm(C,D)
i = B//C-(A-1)//C
j = B//D-(A-1)//D
k = B//Y-(A-1)//Y
print(int(B-A+1-(i+j-k)))

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  while (K--) {
    vector<int> V(N);
    for (int i = 0; i < N; i++) {
      V.at(max(0, i - A.at(i)))++;
      if (i + A.at(i) + 1 < N) V.at(i + A.at(i) + 1)--;
    }
    for (int i = 1; i < N; i++) V.at(i) += V.at(i - 1);
    if (A == V) break;
    A = V;
  }
  for (auto a : A) cout << a << "\n";
}

Measured memory_bytes: 4852
main = do
  n <- readLn
  p <- map read . words <$> getLine
  print $ func [n] p
  
func :: [Int] -> [Int] -> Int
func min [] = length min - 1
func min@(m:_) (x:xs) 
  | m >= x = func (x:min) xs
  | otherwise = func min xs

Measured memory_bytes: 62076
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

int main() {
  int h, w;
  cin >> h >> w;

  multiset<int> st;
  map<int, int> mp;
  rep(i, 0, w) {
    mp[i] = i;
    st.insert(0);
  }

  int a, b;
  rep(i, 0, h) {
    cin >> a >> b;
    --a;
    int most_right = -1;
    for (auto itr = mp.lower_bound(a); itr != mp.upper_bound(b);) {
      most_right = max(most_right, itr->second);
      int d = itr->first - itr->second;
      st.erase(st.find(d));
      itr = mp.erase(itr);
    }
    if (most_right != -1 && b < w) {
      st.insert(b - most_right);
      mp[b] = most_right;
    }
    if (st.size() > 0)
      cout << *st.begin() + i + 1 << '\n';
    else
      cout << -1 << '\n';
  }
  return 0;
}


Measured memory_bytes: 21944
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	int t = 1 ;
	string s ; cin >> s ;
	ll x,y ;
	cin >> x >> y ;
	bool ok = false ;
	ll cnt = 0 ;
	vll a(0),b(0) ;
	for(int i=0;i<s.size();i++){
		if(s.at(i)=='T'){
			if(!ok){
				ok = true ;
				t ^= 1 ;
				continue ;
			}
			if(cnt){
				if(t){
					a.push_back(cnt) ;
				}else{
					b.push_back(cnt) ;
				}
			}
			t ^= 1 ;
			cnt = 0 ;
		}else{
			if(!ok){
				x-- ;
			}else{
				cnt++ ;
			}
		}
	}
	if(ok&&cnt){
		if(t) a.push_back(cnt) ;
		else b.push_back(cnt) ;
	}
	x = abs(x) ;
	y = abs(y) ;
	ll sum1=0,sum2=0 ;
	vvll dp1(a.size()+1,vll(s.size()+1,0)),dp2(b.size()+1,vll(s.size()+1,0)) ;
	dp1.at(0).at(0) = dp2.at(0).at(0) = 1 ;
	for(int i=0;i<(int)a.size();i++){
		for(int j=0;j<=s.size();j++){
			if(dp1.at(i).at(j)){
				if(j+a.at(i)<=s.size()) dp1.at(i+1).at(j+a.at(i)) = 1 ;
				dp1.at(i+1).at(abs(j-a.at(i))) = 1 ;
			}
		}
	}
	for(int i=0;i<(int)b.size();i++){
		for(int j=0;j<=s.size();j++){
			if(dp2.at(i).at(j)){
				if(j+b.at(i)<=s.size()) dp2.at(i+1).at(j+b.at(i)) = 1 ;
				dp2.at(i+1).at(abs(j-b.at(i))) = 1 ;
			}
		}
	}
	yorn(x<=s.size()&&dp1.at(a.size()).at(x)&&dp2.at(b.size()).at(y)) ;
}


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

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

  if (N <= A) {
    cout << "Yes" << endl;
  }
  else if(N % 500 <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  if (n % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 0; i < n / 2; i++) {
    if (s.at(i) != s.at(i + n / 2)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
import itertools

n = int(input())
ps = tuple(map(int, input().split()))
qs = tuple(map(int, input().split()))

nli = [i for i in range(1, n+1)]
# print(nli)

anss = list(itertools.permutations(nli, n))
# print(anss)

ans = abs(anss.index(ps) - anss.index(qs))
print(ans)

Measured memory_bytes: 8052
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let m = get!(usize);
    let mut xs = vec![vec![]; n+1];
    for i in 0..m {
    	let p = get!(usize);
        let y = get!();
        xs[p].push((y,i));
    }
    let mut ans = vec![(0,0); m];
    for i in 0..xs.len() {
    	xs[i].sort();
        for j in 0..xs[i].len() {
        	ans[xs[i][j].1] = (i,j+1);
        }
    }
    for &(p,id) in ans.iter() {
    	println!("{:06}{:06}", p, id);
    }
}

Measured memory_bytes: 19964
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
int N, K, d[100009]; long long w[100009];
int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> w[i] >> d[i];
	long long l = 0, r = 1LL << 61;
	while (r - l > 1) {
		long long m = (l + r) >> 1;
		long long cnt = 0;
		for (int i = 0; i < N; i++) {
			if (m >= w[i]) cnt += (m - w[i]) / d[i] + 1;
		}
		if (cnt >= K) r = m;
		else l = m;
	}
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
const int sz=55;
int n,k,a[sz];
multiset<int> l[sz],r[sz];
int ans;
int csl[sz],csr[sz];

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    multiset<int> myset;
    myset.clear();
    csl[0]=a[0];
    csr[n-1]=a[n-1];
    for(int i=0;i<n;i++){
        if(a[i]<0) myset.insert(a[i]);
        l[i]=myset;
    }
    for(int i=1;i<n;i++) csl[i]=csl[i-1]+a[i];
    for(int i=n-2;i>=0;i--) csr[i]=csr[i+1]+a[i];
    myset.clear();
    for(int i=n-1;i>=0;i--){
        if(a[i]<0) myset.insert(a[i]);
        r[i]=myset;
    }
    for(int i=0;i<=k;i++){
        for(int j=0;j+i<=k&&i+j<=n;j++){
            int rem=k-i-j;
            if(!i&&!j) rem=0;
            int tmp=0;
            if(i+j==n){
                tmp=csl[n-1];
                for(auto u:l[n-1]){
                    if(rem) tmp+=abs(u);
                    else break;
                    rem--;
                }
            }else{
                if(i) tmp=csl[i-1];
                if(j) tmp+=csr[n-1-j+1];
                myset.clear();
                if(i) for(auto u:l[i-1]) myset.insert(u);
                if(j) for(auto u:r[n-j]) myset.insert(u);
                for(auto u:myset){
                    if(rem) tmp+=abs(u);
                    else break;
                    rem--;
                }
            }
            ans=max(ans,tmp);
        }
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 384
(defun splitat (c line)
  (labels ((rec (line acc)
				(let ((pos (position-if (lambda(cc) (char= c cc)) line)))
				  (if pos
					  (rec (subseq line (1+ pos)) (cons (subseq line 0 pos) acc))
					(nreverse (cons line acc))))))
	(rec line nil)))


(defun f(line)
  (let ((lst (mapcar #'parse-integer (splitat #\space line))))
    (<= (reduce #'+ lst) 21)))
(let ((line (read-line nil nil)))
  (format t "~A~%" (if (f line) "win" "bust")))


Measured memory_bytes: 12896
import sys
from collections import deque
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,T = IL()
ab = [IL() for i in range(N)]
ab.sort()

ans = 0
dp = [[0]*T for i in range(N+1)]
for i in range(1,N+1):
  a,b = ab[i-1]
  for j in range(T):
    if 0 <= j-a < T:
      dp[i][j] = max(dp[i-1][j], dp[i-1][j-a] + b)
    else:
      dp[i][j] = dp[i-1][j]
  else:
    ans = max(ans, dp[i-1][-1] + b)
print(ans)

Measured memory_bytes: 117976
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <limits>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define print_double(val,a) cout << fixed << setprecision(a) << val << endl;
ll mod = 1e9 + 7;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int u;
  cin>>u;
  cout<<"Christmas";
  rep(i,25-u){cout<<" Eve";}
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};


int main() {
    ll S; cin >> S;
    const int v=1000000000;

    ll x=(v-S%v)%v;
    ll y=(S+x)/v;
    cout << "0 0 1000000000 1 " << x << " " << y<< endl;
    return 0;
}

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

using namespace std;

int a[100000];

int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	sort(a+1,a+n+1);
	cout<<a[n]-a[1];
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int N, K = 60, d[60] = {0};
long long A, ans = 0, M = 1000000007;
int main() {
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> A;
        for(int j = 0; j < K; j++) {
            if(A & (1LL << j))
                d[j]++;
        }
    }
    for(int i = 0; i < K; i++) {
        ans = (ans + 1LL * ((1LL * d[i] * (N - d[i])) % M) * ((1LL << i) % M)) % M;
    }
    cout << ans;
}

Measured memory_bytes: 256
N=int(input())
div=0
A=0
B=N
count=0
answer=0
for i in range(1,N+1,2):
  div=0
  count=0
  while True:
    div+=1
    if i%div==0:
      A=div
      B=i/div
      if A<B:
        count+=1
    if A>=B:
      if count==4:
        answer+=1  
      break
print(answer)

Measured memory_bytes: 3064
from scipy.sparse.csgraph import *;from scipy.sparse import *;H,W,*S=open(0).read().split();W=int(W);m=int(H)*W;A=[]
for i in range(m):
 h,w=divmod(i,W)
 if S[h][w]=='S':A=[m*2,h,m*2,w+m]+A
 elif S[h][w]=='T':A=[h,m*3,w+m,m*3]+A
 elif S[h][w]=='o':A+=[h,w+m,w+m,h]
f=maximum_flow(csr_matrix(([999]*4+[1]*(len(A)//2-4),(A[::2], A[1::2])),(m*4,m*4)),m*2,m*3).flow_value;print(f if f<999 else -1)

Measured memory_bytes: 41016
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	int n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
    
    ll dp[n][n];
    memset(dp,0LL,sizeof dp);
    
    for(int i=0;i<n;i++)
    {
    dp[i][i]=a[i];
    if(i!=n-1)
    dp[i][i+1]=abs(a[i]-a[i+1]);
    }

    for(int gap=3;gap<=n;gap++)
    {
    for(int l=0;l<=n-gap;l++)
    {
    int r=l+gap-1;
    dp[l][r]=max(a[l]+min(dp[l+2][r]-a[l+1],dp[l+1][r-1]-a[r]),
    	         a[r]+min(dp[l+1][r-1]-a[l],dp[l][r-2]-a[r-1]));
    }
    }


    cout<<dp[0][n-1];
	return 0;

}

Measured memory_bytes: 73872
#include <iostream>
#include <cmath>

using namespace std;

long long N;

int main(){
    cin >> N;
    long long n = ceil(sqrt(N));
    long long m;
    for(long long t=n;t>=1;t--){
        if(N % t == 0){
            n = t;
            m = N / t;
            break;
        }
    }
    if(n < m) n = m;
    int count = 0;
    while(true){
        if(n == 0){
            cout << count << endl;
            break;
        }
        n /= 10;
        count++;
    }
    return 0;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("Ofast")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;
using ull = unsigned long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string & str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	printf("%d\n", a + b + c);

	Please AC;
}


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

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

/*------------------------------------------------------------------*/

int main(){
    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
        a[i]--;
    }
    vector<bool> pos(n + 1, 0);
    vector<ll> count(n + 1);

    int i = 0;
    int cur;
    int beg;
    while(true){
        if(i == 0){
            pos[0] = 1;
            count[0] = i + 1;
            cur = a[0];
            i++;
            continue; 
        }
        if(pos[cur]){
            i++;
            beg = count[cur] - 1;
            i -= count[cur];
            //cout << beg << " " << i << endl;
            break;
        }
        pos[cur] = 1;
        count[cur] = i + 1;
        i++;
        cur = a[cur];
    }

    if(k < beg){
        rep(j, n){
            if((count[j] - 1) == k){
                cout << j + 1 << endl;
                return 0;
            }
        }
    }
    rep(j, n){
        if(count[j] <= beg) count[j] = -1;
        else count[j] -= (beg + 1); 
        //cout << count[j] << endl;
    }
    rep(j, n){
        if(count[j] == ((k - beg) % i)){
            cout << j + 1 << endl;
            return 0;
        }    
    }
}

Measured memory_bytes: 6416