akhauriyash/Code-Regression huggingface dataset:
//Bismillahir Rahmanir-Rahim
/**@MSR**/
#include<bits/stdc++.h>
using namespace std;

#define mod 1e9+7
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vll vector<long long>
#define ll long long
#define lli long long int
#define el '\n'
#define mem(a,b) memset(a, b, sizeof(a) )

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

const int mx = 2e5+123;
ll dp[123][mx];
int n;
int wiehgElement[mx], valElement[mx];
int totalSize;


////*****memoization process******///


ll solve(int i, int j )
{
    if (i > n )
        return 0;
    if (dp[i][j] != -1 )
        return dp[i][j];

    ll ret1 = 0, ret2 = 0;

    if (j + wiehgElement[i] <= totalSize )
        ret1 = valElement[i] + solve ( i+1,j+ wiehgElement[i] );
    ret2 = solve ( i+1, j );


    dp[i][j]=max(ret1,ret2);

    return dp[i][j];
}



int main()
{
    optimize();
    ll t,x,y,k,z,m,a,b;
    /**/
    mem(dp,-1);
    cin>>n>> totalSize;

    for (int i = 1; i <= n; i++ )
    {
        cin >> wiehgElement[i] >> valElement[i];
    }

    cout << solve (1,0) << endl;


    return 0;
}
/**/





Measured memory_bytes: 195888
input_line=input().rstrip().split()
num1 = int(input_line[0])
num2 = int(input_line[1])
 
if (num1 > num2):
  print(str(num2)*num1)
elif (num1 < num2):
  print(str(num1)*num2)
elif (num1 == num2):
  print(str(num1)*num2)

Measured memory_bytes: 9116
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
//最大公約数
template<typename T>
constexpr T gcd(T a, T b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

//最小公倍数
template<typename T>
constexpr T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}
int main() {
	int a, b;
	cin >> a >> b;
	int x = a - 1;
	if (a <= b) x++;
	PRI(x);
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, x[20], y[20], p[20];
ll ans[20];
int s[20];
int t1[20], t2[20];
bool bl[20];

signed main() {
	cin >> n;
	fill(ans, ans + n + 1, 1000000000000000000);
	for (int i = 0; i < n; i++)cin >> x[i] >> y[i] >> p[i];
	for (int i = 0; i < (1 << n); i++) {
		fill(bl, bl + n, false);
		int cnt = 0;
		for (int j = 0; j < n; j++)if (i&(1 << j))s[cnt] = j, cnt++, bl[j] = true;
		for (int j = 0; j < (1 << cnt); j++) {
			int q1 = 0, q2 = 0;
			for (int k = 0; k < cnt; k++) {
				if (j&(1 << k))t1[q1] = x[s[k]], q1++;
				else t2[q2] = y[s[k]], q2++;
			}
			t1[q1] = 0, t2[q2] = 0;
			ll cnt2 = 0;
			for (int j = 0; j < n; j++) {
				if (bl[j])continue;
				int mi = 1000000000;
				for (int k = 0; k <= q1; k++)mi = min(mi, abs(x[j] - t1[k]));
				for (int k = 0; k <= q2; k++)mi = min(mi, abs(y[j] - t2[k]));
				cnt2 += (ll)mi*p[j];
			}
			ans[cnt] = min(ans[cnt], cnt2);
		}
	}
	for (int i = 0; i <= n; i++)cout << ans[i] << endl;
}


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

long long mod(long long val, long long p) {
  long long res = val % p;
  if (res < 0) res += p;
  return res;
}

int main() {
  long long MOD = 1000000007;
  long long N, K; cin >> N >> K;
  long long ans = 0;
  long long tmp1 = 0, tmp2 = 1;
  for (int i = 1; i <= N+1; i++) {
    tmp1 = (tmp1 + i-1) % MOD;
    tmp2 = (tmp2 + N+1-i) % MOD;
    if (i < K) continue;
    ans = mod(ans + tmp2 - tmp1, MOD);
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb(a) push_back(a)
#define pi pair<int,int>
#define f first
#define s second
#define endl "\n"
void solve()
{
  int n=5;
  int arr[n];
  int ans=-1;
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
      if(arr[i]==0)
      ans=i+1;
  }
  cout<<ans<<endl;
  
}
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
       solve();
    return 0;
} 

Measured memory_bytes: 3612
n=int(input())
h=list(map(int,input().split()))
cnt=0
ans=0
c=0
for i in range(100000):
    if h==[0]*n:
        break
    for j in range(n):
        if h[j]!=0:
            h[j]-=1
            cnt+=1
        elif h[j]==0 and cnt!=0:
            ans+=1
            cnt=0
            break
        elif h[j]==0 and ans==0:
            continue
        if j==n-1:
            ans+=1
            cnt=0
        #print(j)
    #print(h)
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

bool sort_second(std::tuple<std::string,int,int> a, std::tuple<std::string,int,int> b) {
  if(std::get<1>(a) != std::get<1>(b) && std::get<0>(a) == std::get<0>(b)){
    return std::get<1>(a) > std::get<1>(b);
  }
  else{
    return std::get<0>(a) < std::get<0>(b);
  }
}

int main(){
  int n;
  std::cin >> n;
  vt<std::tuple<std::string,int,int>> res(n);
  rep(i,n) {
    std::string s; int p, num = i+1;
    std::cin >> s >> p;
    std::get<0>(res[i]) = s;
    std::get<1>(res[i]) = p;
    std::get<2>(res[i]) = num;
  }

  sort(res.begin(), res.end(),sort_second);

  for(auto &x : res)
    std::cout << std::get<2>(x) << '\n';
  return 0;
}


Measured memory_bytes: 256
from collections import deque
s = deque(input())
num = int(input())
cnt = 0
for _ in range(num):
    t = input().split()
    if t[0] == "1":
        cnt += 1
    else:
        if (int(t[1])+cnt) % 2 == 1:
            s.appendleft(t[2])
        else:
            s.append(t[2])
if cnt % 2 == 1:
    s.reverse()
print("".join(s))

Measured memory_bytes: 8556
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0, tmp = 0;
    string s, t;
    cin >> s >> t;
    if(s == t){
            cout << "Yes" << endl;
            return 0;
    }
    rep(i, s.length()){
        s = s.back() + s.substr(0, s.size() - 1);
        if(s == t){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define de(c) cout << #c << " = " << c << endl
#define dd(c) cout << #c << " = " << c << " "
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}());
const ll mod=100000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 200023;
int T;
ll n;
ll p;
string str;
map<ll,ll> ma;

int main(int argc, char const *argv[])
{
#ifdef indiewar
    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//    cin >> T;
    T =1;
    while(T--)
    {
        cin >> n;
        cin >> p;
        cin >> str;
        if(p == 2 || p == 5)
        {
            ll sum = 0;
            rep(i,0,n)
            {
                if((str[i]-'0') % p == 0)
                {
                    sum+=i+1;
                }
            }
            cout << sum << endl;
            return 0;
        }
        ll ans = 0;
        // p | x => p | (x*10^i)
        ma[0]++;
        ll res = 0;
        ll a = 1;
        per(i,0,n)
        {
            res = ( res + (str[i]-'0')*a) % p;
            ans += ma[res];
            ma[res]++;
            a *= 10;
            a %= p;
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = atan(1.0) * 4.0;
// const int MOD = 998244353;
const ll LINF = 9e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

ll N;
VL H, ans;

signed main() {
    SCIN(S);
    ll N = S.length(), cnt = 0;
    ans.resize(N);
    REP(i, N) {
        if(S[i] == 'R') {
            cnt++;
        } else {
            ans[i] += cnt / 2;
            ans[i - 1] += (cnt + 1) / 2;
            cnt = 0;
        }
    }
    REPR(i, N - 1) {
        if(S[i] == 'L') {
            cnt++;
        } else {
            ans[i] += cnt / 2;
            ans[i + 1] += (cnt + 1) / 2;
            cnt = 0;
        }
    }
    REP(i, N) { cout << ans[i] << " "; }
    cout << "\n";
}

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

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979

int main()
{
	int n, total = 0;
	cin >> n;
	vector<int> time(n);
	rep(i, n)
	{
		cin >> time[i];
		total += time[i];
	}

	int m;
	cin >> m;
	rep(i, m)
	{
		int p, x;
		cin >> p >> x;

		cout << total - time[p-1] + x;
		if (i < m - 1) cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3588
def main():
    _, _, M = list(map(int, input().split()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    m = 10**9
    for _ in range(M):
        x, y, c = list(map(int, input().split()))
        m = min(A[x - 1] + B[y - 1] - c, m)
    m = min(m, min(A) + min(B))
    return m

print(main())


Measured memory_bytes: 18612
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	int N, L[201];
	cin >> N;
	rep(i, 2 * N) cin >> L[i];

	sort(L, L + 2 * N);
	int ans = 0;
	for (int i = 0; i < 2 * N; i += 2) {
		ans += min(L[i], L[i + 1]);
	}
	cout << ans << endl;
	return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

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

int main()
{
    cout << fixed << setprecision(15);
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N+1, 0);

    REP(i, M){
        ll a, b;
        cin >> a >> b;

        A[a]++;
        A[b]++;
    }

    for(ll i=1; i<=N; i++){
        cout << A[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
 
public class Main {
	
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        final int N = sc.nextInt();
        
        int[] heights = new int[N];
        for(int i = 0; i < N; i++){
        	heights[i] = sc.nextInt();
        }
        
        ArrayList<Integer> signed = new ArrayList<Integer>();
        int prev = Integer.MIN_VALUE;
        for(int i = 0; i < N - 1; i++){
        	final int next_diff = heights[i + 1] - heights[i];
        	final int next_sign = next_diff == 0 ? 0 : next_diff / Math.abs(next_diff);
        	
        	if(i == 0){
        		prev = next_sign;
        		continue;
        	}
        	
        	if(prev != next_sign){
        		signed.add(prev);
        		prev = next_sign;
        	}
        }
        if(prev != Integer.MIN_VALUE){
        	signed.add(prev);
        }
        //System.out.println(signed);
        
        int[] counts = new int[5];
        
        for(int i = 1; i < signed.size() - 1; i++){
        	final int prev_sign = signed.get(i - 1);
        	final int curr_sign = signed.get(i);
        	final int next_sign = signed.get(i + 1);
        	
        	if(curr_sign == 0){
        		if(prev_sign == 1 && next_sign == -1){
        			counts[0]++;
        		}else if(prev_sign == -1 && next_sign == 1){
        			counts[1]++;
        		}else {
        			counts[2]++;
        		}
        	}
        }
        
        for(int i = 0; i < signed.size() - 1; i++){
        	final int curr_sign = signed.get(i);
        	final int next_sign = signed.get(i + 1);
        	
        	if(curr_sign != next_sign && curr_sign != 0 && next_sign != 0){
        		if(curr_sign > 0){
        			counts[3]++;
        		}else{
        			counts[4]++;
        		}
        	}
        }
        
        for(int i = 0; i < 5; i++){
        	if(i != 0){
        		System.out.print(" ");
        	}
        	System.out.print(counts[i]);
        }
        System.out.println();
    }
     
} 


Measured memory_bytes: 63908
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto e : a) cout << e << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);

using namespace std;


int main(){
    fast;
    double n; cin >> n;
    FOR(i, n + 1, 0)
    {
        ld npr = (ld)i;
        ll now = 1.08 * npr;
        if(round(now) == n)
        {
            cout << npr << endl;
            return 0;
        }
    }
    cout << ":(";
    return 0;
}



Measured memory_bytes: 256
// Vicfred
// https://atcoder.jp/contests/abc177/tasks/abc177_e
// math
import std.stdio, std.algorithm, std.range, std.functional;
import std.array;
import std.conv;
import std.container;
import std.numeric;
import std.string;

uint[] sieve(in uint limit) nothrow @safe {
    if (limit < 2)
        return [];
    auto composite = new bool[limit];

    foreach (immutable uint n; 2 .. cast(uint)(limit ^^ 0.5) + 1)
        if (!composite[n])
            for (uint k = n * n; k < limit; k += n)
                composite[k] = true;

    //return iota(2, limit).filter!(not!composite).array;
    return iota(2, limit).filter!(i => !composite[i]).array;
}

void main() {
    const long MAXN = 10^^6;
    auto primes = (MAXN).sieve;

    long[long] visited;

    long n = readln.chomp.to!long;
    long[] a = readln.split.map!(to!long).array;

    long factor = a[0];
    foreach(number; a)
        factor = gcd(factor,number);

    RedBlackTree!long[long] pfactors;
    foreach(number; a)
        pfactors[number] = new RedBlackTree!long;

    long[] fprime = new long[MAXN+1];
    fprime[1] = 1;
    foreach(prime; primes) {
        for(int i = 1; i*prime <= MAXN; i++) {
            if(fprime[i*prime] == 0)
                fprime[i*prime] = prime;
        }
    }

    //fprime.writeln;

    foreach(number; a) {
        long nn = number;
        while(nn != 1) {
            pfactors[number].insert(fprime[nn]);
            nn /= fprime[nn];
        }
    }

    //pfactors.writeln;

    bool flag = true;
    foreach(number; a) {
        if(!flag) break;
        foreach(prime; pfactors[number]) {
            if(prime in visited) {
                flag = false;
                break;
            } else {
                visited[prime] = 1;
            }
        }
    }

    if(flag) {
        "pairwise coprime".writeln;
        return;
    }

    if(!flag && factor != 1) {
        "not coprime".writeln;
        return;
    }

    if(factor == 1) {
        "setwise coprime".writeln;
    }
}



Measured memory_bytes: 331600
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int i,j,n,m,x,t,a,st,en,t1[10001],cnt;
	scanf("%d %d %d",&n,&m,&t);
	for(i=0;i<=t;i++)	t1[i]=0;
	for(i=0;i<n;i++)	{
		scanf("%d",&a);
		st=a-m;
		if(st<0)	st=0;
		en=a+m;
		if(en>t)	en=t;
		t1[st]++;	t1[en]--;
	}
	x=0;	cnt=0;
	for(i=0;i<t;i++)	{
		x+=t1[i];
		if(x==0)	cnt++;
//		printf("x=%d\n",x);
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 2792
import sys
input = sys.stdin.readline

A, B, K = map(int, input().split())

L = set()
for i in range(min(K, B-A+1)):
    L.add(A+i)
    L.add(B-i)
L = sorted(list(L))
for i in range(len(L)):
    print(L[i])


Measured memory_bytes: 9120
#include<stdio.h>
int main(void){
	int x,y,z;
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0&&y==0){
			break;
		}
			if(x>y){
				z=x;
				x=y;
				y=z;
			}
			printf("%d %d\n",x,y);
		}
		
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int n,k,c;
char s[200005];
set<int> st;
set<int> st2;
set<int> st3;
int main(){
	//freopen("in.txt","r",stdin);
	scanf("%d%d%d%s",&n,&k,&c,s);
	
	int cnt=0;
	for(int i=0;i<n;i++){
		if(s[i]=='o') {
			st.insert(i+1);
			cnt++;
			i+=c;
		}
		if(cnt>k) return 0;
	}
	
	cnt=0;
	for(int i=n-1;i>=0;i--){
		if(s[i]=='o'){
			st2.insert(i+1);
			cnt++;
			i-=c;
		}
		if(cnt>k) return 0;
	}
	set_intersection(st.begin(),st.end(),st2.begin(),st2.end(),ostream_iterator<int>(cout,"\n"));
	
	return 0;
}

Measured memory_bytes: 20480
def examB():
    N = I()
    cur = "No"
    cake = N//4
    for i in range(cake+1):
        if (N-i*4)%7==0:
            cur = "Yes"
            break
    print(cur)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 38304
x1,y1,x2,y2 = map(int,input().split())
x3 = x2-(y2-y1)
y3 = y2+(x2-x1)
x4 = x3-(x2-x1)
y4 = y3-(y2-y1)
print(x3,y3,x4,y4)


Measured memory_bytes: 38384
#include <iostream>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#define ll long long
const int N=1e6+10;
using namespace std;
int a,b;
int main(){
  cin>>a>>b;
  if(500*a>=b)
      cout<<"Yes"<<endl;
  else
      cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<map>
using namespace std;

int main(void)
{
	int s;
	cin >> s;

	map<int, int> dic;
	int epoch = 0;
	while(1){
		if(dic[s] == 0)
			dic[s] = epoch + 1;
		else{
			cout << epoch+1 << endl;
			return 0;
		}

		epoch++;
		if(s%2 == 0)
			s /= 2;
		else
			s = 3*s + 1;
	}

	return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int main()
{
  string s;
  cin >> s;
  int c = 15 - s.length();
  REP(i, s.length())
  {
    if (s[i] == 'o')
    {
      c++;
    }
  }
  if (c >= 8)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
str_line = input().split(" ")
num_line = [int(n) for n in str_line]

num_line.sort()
num_list = [num_line[0]]
for i in range(1,len(num_line)):
    if num_line[i] != num_line[i-1]:
        num_list.append(num_line[i])

#print(num_list)
print(len(num_list))

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

int main(){
    int a[5];
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
    for(int i = 0; i < 5; i++){
        if(a[i]) continue;
        cout << i + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define r(i, n) for (int i=0;i<n;i++)
using namespace std;
int main() {
  int n,k,q;
  cin >> n >> k >> q;
  int a[n];
  r(i, n) a[i]=k-q;
  r(i, q) {
    int c;
    cin >> c;
    a[c-1]++;
  }
  r(i, n) {
    string b;
    if (a[i]>0) {
      b="Yes";
    }
    else b="No";
    cout << b << endl;
  }
  return 0;
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define MAXN 11111

const int INF = 1 << 29 ;
typedef long long ll ;
typedef pair < int , int > pii ;

bitset < 2000*2000 + 5 > dp ;

int main() {
    int n  , x , sum = 0 , ans ;
    dp[0] = 1 ;
    scanf("%d" ,&n) ;

    while(n--) {
        scanf("%d" ,&x) ;
        sum+=x ;
        dp|=(dp<<x) ;
    }
    ans = (sum+1)>> 1 ;
    while(!dp[ans]) ans++ ;
    printf("%d\n" , ans) ;

    return 0 ;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int M, D; cin >> M >> D;
    int ans = 0;
    for(int i=1; i<=M; i++){
        for(int j=1; j<=D; j++){
            int d1 = j%10;
            int d2 = j/10%10;
            if(d1>=2 && d2>=2 && d1*d2==i) ans++;
            
        }
    }
    cout << ans << endl;
    return 0;
    
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define TRAV(i, n) for(auto &i : n)
#define SZ(x) (int)(x).size()
#define PR std::pair
#define MP std::make_pair
#define X first
#define Y second
typedef long long ll;

using namespace std;

int comp(const void* a, const void* b)  { return *(int*)a > *(int*)b ; }

int findNumberOfTriangles(int arr[], int n)
{
    qsort(arr, n, sizeof( arr[0] ), comp);
    int count_ = 0;
    for (int i = 0; i < n - 2; ++i)
    {
        int k = i + 2;
        for (int j = i + 1; j < n; ++j)
        {
            while (k < n && arr[i] + arr[j] > arr[k]) ++k;
            if(k > j)
            count_ += k - j - 1;
        }
    }
    return count_;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int arr[n + 1];
    for (int i = 0; i < n; i++){
        cin >> arr[i];
    }

    cout << findNumberOfTriangles(arr, n);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    char b;
    cin >>b;
    char C='C';
    char A='A';
    char G='G';
    char T='T';
    if(b==A)
    cout << "T" <<' ';
    else if(b==T)
    cout << "A" <<' ';
    else if(b==G)
    cout << "C" <<' ';
    else if(b==C)
    cout << "G" <<' ';
    return 0;
}

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

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>	tree_set;
typedef long long ll;
typedef long double ld;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

ll mod=1e9 + 7;

int main()
{
    fast();
    ll n;
    cin>>n;
    string str;
    map<string,ll> cnt;
    for(ll i=0;i<n;i++)
    {
        cin>>str;
        sort(str.begin(),str.end());
        cnt[str]++;
    }

    ll ans = 0;
    for(map<string,ll>::iterator itr=cnt.begin();itr!=cnt.end();++itr)
    {
        ll val = itr->second;
        ans = ans + (val*(val-1))/2;
    }
    cout<<ans;


}



Measured memory_bytes: 11264
import java.util.*;
 public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);

      int N = sc.nextInt();
   

      if(N / 100 == 7 || N % 100 / 10 == 7 || N % 10 == 7){
         System.out.println("Yes");
      }else{
         System.out.println("No");
      }
     
   }
 }

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

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

std::vector<int> prim;
void getPrim(int N) {
    prim.reserve(N/2);
    std::vector<bool> used(N+1, false);
    REP(i, 4) {
        used[i] = true;
    }
    prim.pb(2);
    prim.pb(3);
    FOR(i, 1, (N+1)/2) {
        if(i*2 <= N) used[i*2] = true;
        if(i*3 <= N) used[i*3] = true;
    }

    FOR(i, 1, N/6 + 1) {
        int a = 6*i - 1;
        if(a > N) break;
        if(!used[a]) {
            prim.pb(a);
            FOR(i, 1, (N+a-1)/a){
                used[a*i] = true;
            }
        }

        int b = 6*i + 1;
        if(b > N) break;
        if(!used[b]) {
            prim.pb(b);
            FOR(i, 1, (N+b-1)/b){
                used[b*i] = true;
            }
        }
    }
}

int main() {
    std::cin >> N;
    getPrim(N);

    std::vector<int> cnt(N+1, 0);
    FOR(i, 2, N+1) {
        EACH(j, prim) {
            if(i < (*j)) break;

            int x = i;
            while( x >= (*j) && x%(*j)==0 ) {
                cnt[*j]++;
                x /= *j;
            }
        }
    }
    LL ans = 1ll;
    EACH(it, cnt) {
        if(*it > 0) {
            ans =  ( ( ans + MOD ) * (*it + 1) ) % MOD;
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
// problem: "https://atcoder.jp/contests/abc144/tasks/abc144_d"

#include<bits/stdc++.h>
#define lf double
#define ll long long

using namespace std;

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

    lf theta = atan(a*a*a*1.0/(2.0*(a*a*b-x)));

    if(x >= a*a*a/(2.0*tan(theta)))
        cout<<setprecision(12)<<90.0 - theta * 180.0 / M_PI;
    else
        cout<<setprecision(12)<<90.0 - atan(2.0*x/(a*b*b)) * 180.0 / M_PI;

    return 0;
}


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

int main () {
  string t;
  cin >> t;
  string t_c;
  t_c = t;
  for(int i=0;i<t.length();i++) {
    if(t.at(i) == '?') {
      t_c.at(i) = 'D';
    }
  }
  cout << t_c << endl;
}


Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,c,d,x;
    cin>>a>>b>>c>>d;

    if(a>=d)
    {
        cout<<d<<endl;
    }
    else if(a+b>=d)
    {
        cout<<a<<endl;
    }
    else
    {
        x=d-(a+b);
        cout<<a-x<<endl;
    }








    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

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

    vector<int> p(N, 0);

    REP(i, N)
    {
        cin >> p[i];
        p[i]--;
    }

    vector<int> a(N, 0);
    vector<int> b(N, 0);

    int itv = N + 1;
    REP(i, N)
    {
        a[i] = itv * (i + 1);
        b[i] = itv * (N - (i + 1));
    }

    REP(i, N) b[p[i]] += (i + 1);

    REP(i, N)
    {
        cout << a[i] << (i != N - 1 ? ' ' : '\n');
    }

    REP(i, N)
    {
        cout << b[i] << (i != N - 1 ? ' ' : '\n');
    }

    return 0;
}


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

class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] d = new int[n];
        for (int i = 0; i < n; i++) {
            d[i] = scan.nextInt();
        }
        Arrays.sort(d);
        int half = d.length/2;
        System.out.println(d[half]- d[half-1]);
    }
}

Measured memory_bytes: 50360
/**
 * @author: Jun
 * @date  : 03-17-2019
 **/
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define el '\n'
#define MOD 1000000007

int n,k;
set<int> filt;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> k;
    for(int i=0;i<k;i++){
        int g;
        cin >> g;
        filt.insert(g);
    }

    for(int i=n;i<=10000000;i++){
        bool can=true;
        int q = i;
        while(q!=0){
            if(filt.count(q%10)==1){
                can=false;
                break;
            }
            q /= 10;
        }
        if(can){
            cout << i << el;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
    int n, m, t;
    scanf("%d%d", &n, &m);
    int *v = new int[n];
    for (int i = 0; i < n; i++) v[i] = 0;
    for (auto i = 0; i < 2 * m; i++) {
        scanf("%d", &t);
        v[t]++;
    }

    bool ret = true;
    for (auto i = 0; i < n; i++) {
        if (v[i] % 2 == 1) {
            ret = false;
            break;
        }
    }

    printf(ret?"YES\n":"NO\n");

    delete[] v;
    return 0;
}

Measured memory_bytes: 640
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn solve_one_dim(l0: usize, l1: usize) -> Vec<i64> {
  let s: Vec<_> = (0 .. l0 + 1).map(|i| {
    if i % l1 == 0 {
      - ((i / l1) as i64)
    } else {
      1000 - ((i / l1) as i64)
    }
  }).collect();
  let mut a = vec![];
  for i in 0 .. l0 {
    a.push(s[i+1] - s[i]);
  }
  a
}

fn main() {
  input! {
    h0: usize,
    w0: usize,
    h1: usize,
    w1: usize,
  }
  if h0 % h1 != 0 {
    println!("Yes");
    let a = solve_one_dim(h0, h1);
    for &x in a.iter() {
      for _ in 0 .. w0 {
        print!("{} ", x);
      }
      println!("");
    }
  } else if w0 % w1 != 0 {
    println!("Yes");
    let a = solve_one_dim(w0, w1);
    for _ in 0 .. h0 {
      for x in a.iter() {
        print!("{} ", x);
      }
      println!("");
    }
  } else {
    println!("No");
  }
}


Measured memory_bytes: 5628
/// @file

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>

namespace {

bool run(std::istream& is, std::ostream& os);
}  // unnamed namespace

/// @brief エントリポイント
#ifdef _TEST
static int run()
#else
int main()
#endif
{
  try {
    if (run(std::cin, std::cout) == false) {
      std::cerr << "main funciton error.\n";
      return EXIT_FAILURE;
    }
  } catch (const std::exception& e) {
    std::cerr << "catch exception\n";
    std::cerr << e.what() << "\n";
    return EXIT_FAILURE;
  }

  return EXIT_SUCCESS;
}

namespace {

/// @brief 実行処理
bool run(std::istream& is, std::ostream& os)
{
  long n;
  long m;
  is >> n >> m;

  std::vector<std::pair<long, long>> shopList(n);
  for (auto& v: shopList) is >> v.first >> v.second;

  std::sort(shopList.begin(), shopList.end());

  long sumMoney(0);
  long numDrinks(0);
  for (const auto& shop: shopList) {
    if (numDrinks + shop.second >= m) {
      const long BUY_NUM = m - numDrinks;
      sumMoney += shop.first * BUY_NUM;
      break;
    }

    numDrinks += shop.second;
    sumMoney += shop.first * shop.second;
  }

  os << sumMoney << "\n";

  return true;
}
}  // unnamed namespace


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,k;
	cin>>a>>b>>k;
	for(int i=a;i<b+1;i++){
		if(i<a+k||i>b-k){
			cout<<i<<endl;
		}
		else{
			continue;
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MAXN = (int)2e5 + 77;
ll a[MAXN], p[MAXN];
int n;

ll get(int l, int r) {
	if(l <= r) {
		return p[r] - (l == 0 ? 0 : p[l - 1]);
	} else {
		return 0;
	}
}

vector<pll> split(int l, int r) {
	int low = 0, high = r - l + 1;
	ll sum = get(l, r);

	while(high - low > 1) {
		int mid = (low + high) / 2;

		ll val = get(l, l + mid - 1);
		if(2 * val == sum) {
			return {make_pair(val, val)};
		} else if(2 * val < sum) {
			low = mid;
		} else {
			high = mid;
		}
	}

	ll left1 = get(l, l + low - 1);
	ll right1 = sum - left1;

	ll left2 = get(l, l + high - 1);
	ll right2 = sum - left2;

	return {make_pair(left1, right1), make_pair(left2, right2)};
}

void solve() {
	cin >> n;
	ll answ = LL_INF;

	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		p[i] = a[i] + (i == 0 ? 0 : p[i - 1]);
	}

	for(int pref = 2; pref <= n; ++pref) {
		if(n - pref >= 2) {
			for(auto& left: split(0, pref - 1)) {
				for(auto& right: split(pref, n - 1)) {
					ll mx = max({left.first, left.second, right.first, right.second});
					ll mn = min({left.first, left.second, right.first, right.second});

					DBG(left); DBG(right);
					answ = min(answ, mx - mn);
				}
			}
		}
	}

	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 3456
#include <iostream>

using namespace std;

int main(){

  while(1){
    int n;
    cin >> n;

    if(!n) break;

    for(int i = 0;i < n;i++){
      int d[8] = {0};
      for(int j = 1;j <= 8;j++){
	cin >> d[j];
      }
      cout << d[1]*d[5]-(d[2]*d[6]+d[3]*d[7]+d[4]*d[8]) << " " << d[1]*d[6]+d[2]*d[5]-d[4]*d[7]+d[3]*d[8] << " " << d[1]*d[7]+d[3]*d[5]+d[4]*d[6]-d[2]*d[8] << " " << d[1]*d[8]+d[4]*d[5]-d[3]*d[6]+d[2]*d[7] << endl;
    }
  }
}


Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
using namespace std;
const int maxn = 300100;
char str[maxn];
string s;
int qrs;

class query {
public:
	int q_type;
	int side;
	char c;
}Q[maxn];


int main() {
	cin>>s;
	cin>>qrs;

	int li = 1, ri = sz(s);

	int val = sz(s);
	for(int i=1;i<=qrs;i++) {
		cin>>Q[i].q_type;

		if(Q[i].q_type == 2) {
			cin>>Q[i].side>>Q[i].c;
			ri++;
			val++;
		} 
	}

	bool rev = false;
	for(int i=qrs;i>=1;i--) {
		if(Q[i].q_type == 1) rev = !rev;
		else {
			if((Q[i].side == 1 && !rev) || (Q[i].side == 2 && rev)){
				str[li] = Q[i].c;
				li++;
			}
			else {
				str[ri] = Q[i].c;
				ri--;
			}
		}
	}

	if(rev) {
		for(int i=0;i<sz(s);i++) {
			str[li + i] = s[sz(s) - i - 1];
		}
	}
	else {
		for(int i=0;i<sz(s);i++) {
			str[li + i] = s[i];
		}
	}

	for(int i=1;i<=val;i++) {
		cout<<str[i];
	} cout<<"\n";
}

Measured memory_bytes: 3456
from bisect import *

n=int(input())
a=sorted(list(map(int,input().split())))
N=a[-1]
inx=bisect(a,N//2)
a=[a[0]]+a+[a[-1]]
th=10**9
for i in [a[inx-1],a[inx],a[inx+1]]:
 if abs(i-N//2)<=th and i<N:
  R=i
  th=abs(i-N//2)
print(N,R)

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

using namespace std;

typedef long long ll;

int main(){
    int n;
    cin>>n;
    set<int>s;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        s.insert(a);
    }
    cout<<s.size();
}


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

using namespace std;
const int IINF = INT_MAX;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000000000
int main(){
    int x,a;
	cin >> x >> a;
	
	if(x < a) cout << 0 << endl;
	else cout << 10 << endl;
	

    return 0;	
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define ull unsigned long long
#define eps (1e-6)
using namespace std;
const int N = 1e5;
int main()
{
    int n, cnt = 0;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
    {
        int x;
        scanf("%d", &x);
        while(x%2==0)
        {
            cnt++;
            x /= 2;
        }
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int a, b, c;
  std::cin >> a >> b >> c;
  if((a == b && a != c) || 
    (a == c && a != b) ||
    (b == c && b != a))
    std::cout << "Yes";
  else
    std::cout << "No";
  return 0;
}

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

int main()
{
	
	int n,k,dp[100001],h[100000],i,j,m,min;
	cin>>n>>k;
	
	for(i=0;i<n;i++)
	cin>>h[i];
	
	dp[n-1]=0;
	
	
	for(i=n-2;i>=0;i--)
	{
		min=INT_MAX;
		for(j=1;j<=k;j++)
		{
			if(i+j>=n)
			break;
			
			m=abs(h[i]-h[i+j])+dp[i+j];
			
			if(m<min)
			min=m;
			
		}
		dp[i]=min;
	}
	
	cout<<dp[0];
	
}


Measured memory_bytes: 1024
N, X, Y = map(int, input().split())
L = [0 for i in range(N-1)]
for j in range(2, N + 1):
    for i in range(1, j):
        D1 = j - i
        D2 = abs(X-i) + 1 + abs(Y-j)
        L[min(D1, D2) - 1] += 1
for k in range(N-1):
    print(L[k])

Measured memory_bytes: 3444
//header{{{
//#define _GLIBCXX_DEBUG
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
//using namespace boost::multiprecision;  
//using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    int n;
    cin >> n;

    vector<int> a(n);

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

    int m = 1000, t = 0;
    int maxv = 0, minv = 500;

    a.erase(unique(all(a)), a.end());

    if(a.size() == 1){
        cout << 1000 << '\n';
        return 0;
    }

    n = a.size();

    a.insert(a.begin(), INF);
    a.push_back(0);
    
    for(int i = 1; i <= n; ++i){
        if(a[i-1] > a[i] && a[i] < a[i+1]){
            int x = m / a[i];
            m -= a[i] * x;
            t += x;
        }else if(a[i-1] < a[i] && a[i] > a[i+1]){
            m += a[i] * t;
            t = 0;
        }
    }

    cout << m << '\n';

    return 0;
}


Measured memory_bytes: 3660