akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        //     Console.WriteLine(Math.Max(0,a[0]-a[1]));
        string a = Console.ReadLine();
        for(int i = 0; i < a.Length; i++)
        {
            if (i % 2 == 0) { Console.Write(a[i]); }
        }Console.WriteLine();
        Console.ReadLine();
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b)
    {
        return a / gcd(a, b) * b;
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (long i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] longs()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13140
/**
*	created: 23.08.2020 10:55:16
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
using ll = long long;
using P = pair<int,int>;
// #define endl '\n'
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1ll << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int n; cin >> n;
    map<int,int> s;
    map<int,int> d;
    rep(i,n) {
        int a; cin >> a;
        s[i+1+a]++; d[i+1-a]++;
    }
    // j - a[j] = i + a[i]
    // i - a[i] = j + a[j]
    int ans = 0;
    for (auto p : s) ans += d[p.first] * p.second;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 37800
#60 C - March
import collections
import itertools
N = int(input())
S = [input() for _ in range(N)]
S = [s[0] for s in S if s[0] == 'M' or s[0] == 'A' or s[0] == 'R' or s[0] == 'C' or s[0] == 'H']

cnt = collections.Counter(S)

comb = itertools.combinations(cnt.keys(),3)

ans = 0
for a,b,c in comb:
    ans += cnt[a]*cnt[b]*cnt[c]
print(ans)

Measured memory_bytes: 17196
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
       mut a:i64,mut b:i64,
    }
    // |a-k| = |b-k|
    // +-(a-k) = +-(b-k)
    //
    // a < b を仮定
    // 負にするしかない?
    // a < 0  , b > 0  にする
    // k-a = b-k
    // k = (a+b)/2
    if a > b {
        swap(&mut a, &mut b);
    }
    if (b - a) % 2 != 0 {
        println!("IMPOSSIBLE");
    } else {
        println!("{}", (b + a) / 2);
    }
}


Measured memory_bytes: 2172
#include <iostream>
#include <vector>

int main() {
    int N, Q;
    std::cin >> N >> Q;
    std::vector<std::vector<int>> v(N);
    for (int q = 0; q < Q; ++q) {
        int t;
        std::cin >> t;
        if (t == 0) {
            int i, x;
            std::cin >> i >> x;
            v[i].push_back(x);
        } else if (t == 1) {
            int i;
            std::cin >> i;
            if (!v[i].empty()) std::cout << v[i].back() << std::endl;
        } else {
            int i;
            std::cin >> i;
            if (!v[i].empty()) v[i].pop_back();
        }
    }
    return 0;
}



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

int main(){
  char C;
  cin >> C;
  
  string alp = "abcdefghijklmnopqrstuvwxyz";
  
  for(int i = 0; i < alp.size(); i++) {
    if(C == alp.at(i)) {
      cout << alp.at(i + 1) << endl;
    }
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		String ans = "";
		while(n != 0) {
			n--;
			ans += (char)('a'+n%26);
			n/=26;
		}
		for(int i = ans.length()-1; i >= 0; i--) {
			System.out.print(ans.charAt(i));
		}
	}
}

Measured memory_bytes: 39404
#include <bits/stdc++.h>
using namespace std;
int n, m;

struct indata {
    int s;
    int c;
};

bool cmp(const indata &a, const indata &b) {
    return a.s < b.s;
}

int main() {
    cin >> n >> m;
    vector<int> s(m, 0);
    vector<int> c(m, 0);
    vector<indata> sc(m);

    for(int i = 0; i < m; ++i) {
        cin >> sc.at(i).s >> sc.at(i).c;
    }

    sort(sc.begin(), sc.end(), cmp);

    int now = 0;
    vector<int> ans(n, 0);
    ans.at(0) = 11;
    for(int i = 1; i <= n; ++i) {
        if(now < m && sc.at(now).s == i) {
            // cout << "now" << now << endl;
            int ansb = sc.at(now).c;
            now++;
            while(now < m && sc.at(now).s == i) {
                if(ansb != sc.at(now).c) {
                    ans.at(i-1) = 10;
                    break;
                }
                now++;
            }
            if(ans.at(i-1) != 10) ans.at(i-1) = ansb;
        }
    }

    bool flg = true;
    for(int i = 0; i < n; ++i) {
        if(ans.at(i) == 10) flg = false;
    }

    if(flg) {
        bool zflg = true;
        for(int i = 0; i < n; ++i) {
            if(i == 0) {
                if(ans.at(0) == 11) {
                    if(n == 1) {

                    }else {
                        zflg = false;
                        cout << 1;
                    }
                }else if(ans.at(0) == 0){
                    
                }else {
                    zflg = false;
                    cout << ans.at(i);
                }
            }else {
                if(zflg) {

                }else {
                    zflg = false;
                    cout << ans.at(i);
                }
            }
        }
        if(zflg) {
            if(n == 1) {
                cout << 0;
            }else {
                cout << -1;
            }
        }
        cout << endl;

    }else {
        cout << -1 << endl;
    }



}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main()
{
int k;
char s[100];
char t[100];

scanf("%d",&k);
scanf("%s",s);

if(strlen(s) <= k){
  printf("%s",s);
}else{
  strncpy(t,s,k);
  t[k] = '\0';
  printf("%s...\n",t);
}

return 0;


}

Measured memory_bytes: 1732
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


D = z()
C = zz()
S = defaultdict(list)
for i in range(D):
    S[i + 1] = zz()
# やらなくていいコンテストはやらないC=0
never_held = []

arr = list(range(26))
C, arr = zip(*sorted(zip(C, arr), reverse=False))
for i in range(D):
    print(arr[i % 26]+1)


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

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    if (s[0] == 'R' & s[1] == 'S' & s[2] == 'R') {
        cout << 1 << endl;
        return 0;
    } else {
        rep(i, 3) {
            if (s[i] == 'R') ans++;
        }
        cout << ans << endl;
        return 0;
    }


    return 0;
}

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

struct City {
  int year;
  int prefecture;
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);
  int n, m;
  cin >> n >> m;
  vector<int> p[n];
  vector<pair<int, int>> all(m);

  rep(i, m) {
    int index;
    cin >> index; --index;
    int year;
    cin >> year;
    p[index].push_back(year);
    all[i] = pair<int, int>{index, year};
  }
  vector<int> ps[n] (p);
  rep(i, n) {
    sort(ps[i].begin(), ps[i].end());
  }
  rep(i, m) {
    int index = all[i].first;
    int year = all[i].second;
    auto it = lower_bound(ps[index].begin(), ps[index].end(), year);
    auto d = distance(ps[index].begin(), it);
    printf("%06d%06ld\n", index+1, d+1); 
  }
  return 0;
}


Measured memory_bytes: 13184
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    char[] chars = scanner.nextLine().toCharArray();
    if(chars[2] == chars[3]
     &&chars[4] == chars[5])
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}

Measured memory_bytes: 21588
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskC {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int[] a = new int[n];
			long s = 0;
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
				s += a[i];
			}
			long ans = Long.MAX_VALUE;
			long t = 0;
			for (int i = 0; i + 1 < n; i++) {
				s -= a[i];
				t += a[i];
				ans = Math.min(ans, Math.abs(s - t));
			}
			out.println(ans);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 49856
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }


int main() {
  int N; cin >> N;
  vector<array<int, 3>> abc(N);
  rep(i, N) cin >> abc[i][0] >> abc[i][1] >> abc[i][2];

  vector<array<int, 3>> dp(N+1);
  rep(i, N) rep(j, 3) rep(k, 3) {
    if (j == k) continue;
    chmax(dp[i+1][k], dp[i][j] + abc[i][k]);
  }

  int ans = *max_element(all(dp[N]));
  cout << ans << '\n';
}


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

using namespace std;

int n, l, v[102], sol;

int main()
{
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> v[i];
  l = 1;
  for (int i = 1; i <= n; i++) {
    if (v[i] == v[i + 1])
      l++;
    else {
      sol += l / 2;
      l = 1;
    }
  }
  cout << sol;
  return 0;
}


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

int main() {
  int n, m;
  while (true) {
    scanf("%d %d", &n, &m);
    if (n==0 && m==0) {
      break;
    }
    vector<int> a(n);
    for (int i=0; i<n; i++) {
      cin >> a[i];
    }
    int ans = -INT_MAX;
    for (int i=0; i<n; i++) {
      for (int j=0; j<n; j++) {
	if (i!=j && a[i]+a[j]<=m) {
	  ans = max(ans,a[i]+a[j]);
	}
      }
    }
    if (ans<0) {
      printf("NONE\n");
    } else {
      printf("%d\n", ans);
    }
  }
  return 0;
}

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

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

    vector<int> v{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int K;

    cin >> K;

    cout << v[K-1];


    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

ll calc(ll a, ll b, ll p) {
    if (b == 0) {
        return 1;
    }
    if (b % 2 == 0) {
        ll d = calc(a, b / 2, p);
        return (d * d) % p;
    }
    else {
        return (a * calc(a, b - 1, p) % p);
    }
}

int main() {
    ll x, y;
    cin >> x >> y;

    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    ll n = ((2 * y) - x) / 3;
    ll m = ((2 * x) - y) / 3;

    if (n < 0 || m < 0) {
        cout << 0 << endl;
        return 0;
    }

    n = n + m;

    long long fact[n]; // n
    fact[0] = 1;
    for (int i = 1; i <= n; i++) { // n
        fact[i] = (fact[i - 1] * i) % MOD;
    }

    ll ans = (((fact[n] * calc(fact[n - m], MOD - 2, MOD)) % MOD) * calc(fact[m], MOD - 2, MOD)) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 8708
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll d;cin >> d;
	vector<ll> c(26);REP(i, 26)cin >> c[i];

	REP(i, d){
		ll ma = -1;
		ll out = 0;
		REP(_, 26){
			ll a;cin >> a;
			if(ma < a){
				ma = a;
				out = _;
			}
		}
		cout << out + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define ll long long
const int inf = 1000000000; // 10^9

int main(){
    int q;
    string que[520000];
    cin >> que[250000] >> q;
    int cnt = 0;
    int t;
    int left = 249999;
    int right = 250001;

    rep(i, q){
        cin >> t;
        if(t == 1){
            cnt++;
        }
        else if(cnt % 2 == 0){
            int c;
            cin >> c;
            if(c == 1){
                cin >> que[left];
                left--;
            }
            else{
                cin >> que[right];
                right++;
            }
        }
        else{
            int c;
            cin >> c;
            if(c == 2){
                cin >> que[left];
                left--;
            }
            else{
                cin >> que[right];
                right++;
            }
        }
    }
    if(cnt % 2 == 0){
        for(int i = left + 1; i < right; i++) cout << que[i];
    }
    else{
        for(int i = right - 1; i > left; i--){
            reverse(que[i].begin(), que[i].end());
            cout << que[i];
        }
    }

    return 0;
}

Measured memory_bytes: 14080
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
int dp[3100][6000];
ll int solve(string a,string b,int n,int m){
    if(n==0||m==0)return 0;
    if(dp[n][m]!=-1)return dp[n][m];
    if(a[n-1]==b[m-1])return dp[n][m]=1+solve(a,b,n-1,m-1);
    else return dp[n][m]=max(solve(a,b,n-1,m),solve(a,b,n,m-1));
}

int main(){
ios_base::sync_with_stdio(0);
ll int t,n,i,j,k,m;
t=1;
while(t--){

string s,t;
cin>>s>>t;
memset(dp,0,sizeof dp);

Fo(i,1,s.length()+1){
    Fo(j,1,t.length()+1){
        if(s[i-1]==t[j-1]){
            dp[i][j]=dp[i-1][j-1]+1;

        }else{
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
}


//solve(s,t,s.length(),t.length());
string ans;
i=s.length();
j=t.length();
if(i==1&&j==1){
    if(s==t)cout<<s;
    else cout<<" ";
    continue;
}
while(i>0&&j>0){
    if(s[i-1]==t[j-1]){
        ans+=s[i-1];
        i--,j--;
    }else{
        if(dp[i][j-1]>dp[i-1][j])j--;
        else i--;
    }
}
reverse(all(ans));
cout<<ans;


    
}

}


Measured memory_bytes: 76240
#include<iostream>
using namespace std;
int main() {

	string s;
	cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == s[i + 1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
	return 0;

}

Measured memory_bytes: 3596
A = tostring(io.read())
B = tostring(io.read())
if #A>#B then
    print("GREATER")
elseif #A<#B then
    print("LESS")    
elseif #A==#B then
    i = 1
    while A:sub(i,i) == B:sub(i,i) and i<#A do
        i = i+1
    end
    if A:sub(i,i) > B:sub(i,i) then
        print("GREATER")
    elseif A:sub(i,i) < B:sub(i,i) then
        print("LESS")
    elseif A:sub(i,i) == B:sub(i,i) then
        print("EQUAL")
    end
end

Measured memory_bytes: 496
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i = n; i >= 12; i--){
    if(i % 2 == 0) continue;
    int cnt = 0;
    for(int j = i; j >= 1; j--){
      if(i % j == 0) cnt++;
    }
    if(cnt == 8) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split(" ");
  var a = parseInt(input[0], 10);
  var b = parseInt(input[1], 10);
  var c = parseInt(input[2], 10);
  if(a + b - c < 0) {
    console.log("No");
  } else {
    console.log("Yes");
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
// 2013/09/10 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){			// 複数の入力に対応

		int s;
		cin >> s;

		if(s==0)		// 総額が0のとき入力の終わり
			break;

		int b1, b2, b3, b4, b5, b6, b7, b8, b9;
		cin >> b1;
		cin >> b2;
		cin >> b3;
		cin >> b4;
		cin >> b5;
		cin >> b6;
		cin >> b7;
		cin >> b8;
		cin >> b9;

		int b10 = s-b1-b2-b3-b4-b5-b6-b7-b8-b9;

		cout << b10 << '\n';

	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int func (int n, int x) {
    int cnt = 0;
    repSE (i, 1, n+1) {
        repSE (j, 1, n+1) {
            if (j == i) continue;
            int k = x - i - j;
            if (k < 1 || k > n || k == i || k == j) continue;
            cnt ++;
        }
    }
    return cnt / 6;
}

int main()
{
    int n, x;
    while (true) {
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        cout << func(n,x) << "\n";
    }
    return 0;
}



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

using namespace std;

int main(){
  int N, K;
  int sum = 0;
  int l[100];

  cin >> N >> K;
  for(int i = 0;i < N;i++){
    cin >> l[i];
  }

  sort(l, l+N, std::greater<int>());

  for(int i = 0;i < K;i++){
    sum += l[i];
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stack>
using namespace std;
static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, tt;
int color[N], nt[N], M[N][N], d[N], f[N];

int next(int u) {
	for(int v = nt[u]; v < n; v++) {
		nt[u] = v + 1;
		if(M[u][v]) return v;
	}
	return -1;
}

void dfs_visit(int r) {
	for(int i = 0; i < n; i++) nt[i] = 0;
	
	stack<int> S;
	S.push(r);
	color[r] = GRAY;
	d[r] = ++tt;
	
	while(!S.empty()) {
	    int u = S.top();
	    int v = next(u);
	    if(v != -1) {
			if(color[v] == WHITE) {
               color[v] = GRAY;
    		   d[v] = ++tt;
   		       S.push(v);
			}
    	}
    	else{
	    	S.pop();
	    	color[u] = BLACK;
	    	f[u] = ++tt; 
	    }
	} 
}


void dfs() {
   for(int i = 0; i < n; i++) {
   	   color[i] = WHITE;
       nt[i] = 0; 
   }
   tt = 0;
   
   for(int i = 0; i < n; i++) {
   	   if(color[i] == WHITE) {
   	   	   dfs_visit(i);
   	   }
   }
   
   for(int i = 0; i < n; i++) {
   	  cout << i+1 << " " << d[i] << " " << f[i] << endl; 
   }   
}

int main() {
	int u, k, v;
	cin >> n;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
		    M[i][j] = 0;
        }
	} 
	
	for(int i = 0; i < n; i++) {
		cin >> u >> k;
		u--;
		for(int j = 0; j < k; j++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	
    dfs();
    
    return 0;
	
} 

Measured memory_bytes: 3096
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix

from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
input=sys.stdin.readline  #危険！基本オフにしろ！

def BELLMANFORD(point,d,n):
    cost       = {node:-float("inf")for node in range(1,n+1)}
    preference = {node:None         for node in range(1,n+1)}      #最適路のこと 
    cost[point]= 0
    for i in range(n-1):                                  #経路の長さは最大n-1であるため
        for now,lis in d.copy().items():
            for nex,c in lis:
                if cost[nex]<cost[now]+c:
                    cost[nex]=cost[now]+c
                    preference[nex]=now
 
    negative=[0]*n                                        #負閉路の長さは最大nであるため
    
    for i in range(n):                  #閉路判定
        for now,lis in d.copy().items():
            for nex,c in lis:
                if negative[now-1]==1:
                    negative[nex-1]=1
                if cost[nex]<cost[now]+c:
                    cost[nex]=cost[now]+c
                    preference[nex]=now
                    negative[now-1]=1
 
    return cost,negative


def main():
    n,m=map(int,input().split())
    d=defaultdict(list)
    for i in range(m):
        a,b,c=map(int,input().split())
        d[a].append([b,c])
    x,y=(BELLMANFORD(1,d,n))
    if y[n-1]>0:
        print("inf")
    else:
        print(x[n])


if __name__ == '__main__':
    main()


Measured memory_bytes: 5752
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(0) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main(){ cin.sync_with_stdio(0);
    ll H, W; cin >> H >> W;

    vs strings(H);
    FOR(i, 0, H) cin >> strings[i];

    ll cnt = 0;
    vvl mat(H, vl(W, -1));

    FOR(i, 0, H) {
        FOR(j, 0, W) {
            if (mat[i][j] == -1) {
                mat[i][j] = cnt;
                mat[H-1-i][j] = cnt;
                mat[i][W-1-j] = cnt;
                mat[H-1-i][W-1-j] = cnt;
                cnt ++;
            }
        }
    }

    map<ll, ll> cntCnt;
    FOR(i, 0, H) FOR(j, 0, W) cntCnt[mat[i][j]] ++;
    map<ll, ll> revCntCnt;
    for (auto p : cntCnt) revCntCnt[p.yy] ++;

    map<char, ll> charCnt;
    FOR(i, 0, H) FOR(j, 0, W) charCnt[strings[i][j]] ++;

    ll fours = revCntCnt[4];
    TR(fours);
    for (auto &it : charCnt) {
        while (fours && it.yy >= 4) {
            fours --;
            it.yy -= 4;
        }
    }
    TR(fours);

    ll twos = revCntCnt[2];
    TR(twos);
    for (auto &it : charCnt) {
        while (twos && it.yy >= 2) {
            twos --;
            it.yy -= 2;
        }
    }
    TR(twos);

    ll ones = revCntCnt[1];
    TR(ones);
    for (auto &it : charCnt) {
        while (ones && it.yy >= 1) {
            ones --;
            it.yy -= 1;
        }
    }
    TR(ones);

    //FOR(i, 0, H) { FOR(j, 0, W) cerr << mat[i][j] << " "; cerr << endl; }

    if (fours || twos || ones) cout << "No" << endl;
    else cout << "Yes" << endl;
} //cin.tie(0) bei schnellem Wechseln


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rp(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)
ll dp[4020][2020][2];
ll mod=924844033;
int main(){
    int N,K;
    cin>>N>>K;
    vector<ll> m;
    ll c=0,s=0;
    bool t[2001];
    for(int i=1;i<N+1;i++){
        if(!t[i]){
            s+=(N-i)/K*2;
            rp(j,0,(N-i)/K) m.push_back(c);
            c++;
            rp(j,0,(N-i)/K) m.push_back(c);
            c++;
            for(int j=i;j<=N;j+=K){
                t[j]=true;
            }
        }
    }
    dp[0][0][0]=1;
    rp(i,0,s){
        rp(j,0,min(ll(2001),ll(i+1))){
            (dp[i+1][j+1][1]+=dp[i][j][0])%=mod;
            if(m[i]!=m[i-1]) (dp[i+1][j+1][1]+=dp[i][j][1])%=mod;
            (dp[i+1][j][0]+=(dp[i][j][0]+dp[i][j][1]))%=mod;
        }
    }
    ll per[2001];
    per[0]=1;
    rp(i,1,2001){
        per[i]=(per[i-1]*i)%mod;
    }
    ll sub=0;
    for(int i=1; i<=min(ll(s),ll(N)); ++i)
    {
        if(i%2==0) sub = (sub - ((dp[s][i][0]+dp[s][i][1])*per[N-i])%mod + mod)%mod;
        else sub = (sub + ((dp[s][i][0]+dp[s][i][1])*per[N-i])%mod)%mod;
    }
    
    ll ans=(per[N]-sub+mod)%mod;
    cout << ans << endl;
    return 0;
    
};

Measured memory_bytes: 102272
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()


int main() {
    int k;
    cin>>k;
    
    queue<long long> q;
    rep(i,9) q.push(i+1);
    
    rep(i,k-1){
        long long x = q.front();
        q.pop();
        if(x%10!=0) q.push(x*10+x%10-1);
        q.push(x*10+x%10);
        if(x%10!=9) q.push(x*10+x%10+1);
    }
    dunk(q.front());
}



Measured memory_bytes: 1792
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

//階乗,二項係数
//*
ll fact[100010];
ll invfact[100010];
void makefact(int n,ll m){
	fact[0]=1;
	rep(i,0,n)fact[i+1]=fact[i]*(i+1)%m;
	invfact[n]=invp(fact[n],m);
	for(int i=n;i>0;i--)invfact[i-1]=invfact[i]*i%m;
}
ll choose(int n,int r,int m){return n<0||r<0||n-r<0?0:fact[n]*invfact[r]%m*invfact[n-r]%m;}
//*/

int main(){
	makefact(2000,MOD);
	int n,m;
	scanf("%d%d",&n,&m);
	printf("%lld\n",choose(n+m-1,n,MOD));
}


Measured memory_bytes: 2112
/*
 ID: bradyawn
 PROG: contest
 LANG: C++11
 */

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <map>
#include <unordered_map>
#include <utility>
#include <set>
#include <unordered_set>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <random>
#include <cstring>
#include <complex>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int,int> i2;
typedef pair<ll,ll> ll2;

int n, m;

struct BIT
{
    int tr[100001];
    
    void upd(int p, int v)
    {
        while (p <= n)
        {
            tr[p] += v;
            p += p & -p;
        }
    }
    
    int get(int p)
    {
        int ret = 0;
        while (p > 0)
        {
            ret += tr[p];
            p -= p & -p;
        }
        return ret;
    }
    
    int get(int a, int b)
    {
        return get(b)-get(a-1);
    }
    
};

BIT fen;

i2 que[100001];

int main()
{
    //ifstream inf("");
    //ofstream outf("");
    //cout << setprecision(10);
    ios::sync_with_stdio(0); cin.tie(0);
    
    cin >> n >> m;
    
    for (int i = 1; i <= m; i++) cin >> que[i].first >> que[i].second;
    sort(que+1, que+1+m);
    
    for (int i = m; i >= 1; i--)
    {
        if (fen.get(que[i].first, que[i].second-1) == 0) //[a,b) connected
            fen.upd(que[i].first, 1); //disconnect
        
    }
    
    //for (int i = 1; i <= n; i++) cout << fen.get(i,i) << " \n"[i==n];
    
    cout << fen.get(n-1) << '\n';
    
    return 0;
    
}





Measured memory_bytes: 1408
import math
import sys
input = sys.stdin.readline

h1, m1, h2, m2, t = map(int, input().split())
if h1 < h2:
	diff = (h2 - h1 - 1) * 60 + (60 - m1) + m2
else:
	diff = m2 - m1
print(max(diff - t, 0))

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

#define VIC ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
#define wtf(s) freopen((s), "w", stdout)
#define rff(s) freopen((s), "r", stdin)
#define pi (2 * acos(0))
typedef long double ld;
typedef long long ll;
typedef complex<ld> point;
#define endl '\n'
#define matrix vector<vector<ll>>
#define EPS 1e-9
#define X real()
#define Y imag()
#define vec(a, b) ((b) - (a))
#define dot(a, b) ((conj(a) * (b)).real())
#define cross(a, b) ((conj(a) *(b)).imag())
#define lengthsqr(v) (dot(v, v))
#define length(v) ((ld)hypot((v).Y, (v).X))
#define same(a, b) (lengthsqr(vec(a, b)) < EPS)

const int N = 1e5 + 5, inf = 1e9 + 5;
const ll mod = 1e9 + 7;

int dp[N], a[N];

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


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

vi AS;
vi ans;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N; 

	AS.resize(N);
	F0R(i, N) cin >> AS[i];

	int count = 0;

	ans.resize(N);
	for (int i = N - 1; i >= 0; --i) {
		int total = 0;
		for (int j = i; j < N; j += i + 1) {
			total += ans[j];
		}
		ans[i] = AS[i] != (total % 2);
		if (ans[i]) ++count;
	}

	cout << count << endl;
	for (int i = 0; i < N; ++i) {
		if (ans[i]) cout << i + 1 << " ";
	}	
	cout << endl;
}

Measured memory_bytes: 2560
#include<stdio.h>

int main() {
	long long int a,f;
	long long int p[5], n;
	unsigned long long int count = 0;

	scanf("%lld", &n);
	long long int num = n;

	scanf("%lld", &p[0]);
	long long int min = p[0];
	int place = 0;

	for (int i = 1;i < 5;i++) {
		scanf("%lld", &p[i]);
		if (min > p[i]) {
			min = p[i];
			place = i;
		}
	}

	count = n / min;

	if (n % min != 0) {
		count++;
	}

	count += place;
	count += 4 - place;


	printf("%lld", count);

	return 0;
}

Measured memory_bytes: 128
n = int(input())

ans = [0 for _ in range(n)]



for y in range(1, int(n**.5)+2):
    for z in range(1, int(n**.5)+2):
      for x in range(1, int(n**.5)+2):
        param = (x**2 + y**2 + z**2 + x*y + y*z + z*x)
        if 1 <= param <= n:
          ans[param-1] += 1

for i in ans:
  print(i)


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (5006)
ll n, A[MAXN], p[MAXN], sz[MAXN], mod=1e9+7, ans, dp[MAXN], m;
bool done[MAXN];
vector<ll> v;
int find(int x) { return p[x] == x ? x : p[x]=find(p[x]); }
void merge(int x,int y){p[find(x)]=find(y);}
int main(){
	FAST
	cin>>n;
	FOR(i,1,n)p[i]=i;
	FOR(i,1,n){
		cin>>A[i];
		if(A[i]==-1){
			v.eb(i);
		}else{
			merge(A[i],i);
		}
	}
	m=v.size();
	FOR(i,1,n)++sz[find(i)];
	auto qexp=[&](ll x,ll e){
		ll sum=1;
		for(;e;e>>=1,x*=x,x%=mod)if(e&1)sum*=x,sum%=mod;
		return sum;
	};
	dp[0]=1;
	for(auto i:v){
		i=find(i);
		DEC(j,m,1){
			dp[j]+=dp[j-1]*sz[i]%mod, dp[j]%=mod;
		}
		done[i]=1;
	}
	ll cc=0;
	FOR(i,1,n)if(find(i)==i&&!done[i]){
		++cc;
	}
	ans=qexp(n-1, m) * (n-cc) % mod;
	ll f=1;
	FOR(i,1,m){
		if(i^1) ans -= f * dp[i] % mod * qexp(n-1, m-i) % mod, ans += mod, ans %= mod;
		else ans -= f * ((dp[i]+mod-m)%mod) % mod * qexp(n-1, m-i) % mod, ans += mod, ans %= mod;
		f *= i, f %= mod;
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 3828
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <fstream>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	multiset<ll> s;
	rep(i, n)
	{
		ll x; cin >> x;
		s.insert(x);
	}
	deque<ll> q;
	q.push_front(*s.begin());
	q.push_back(*--s.end());
	s.erase(s.begin());
	s.erase(--s.end());
	ll res = q.back() - q.front();
	while (s.size() > 1)
	{
		ll l = *s.begin();
		ll r = *--s.end();
		ll lf, lb, rf, rb;
		lf = abs(l - q.front()), lb = abs(l - q.back()), rf = abs(r - q.front()), rb = abs(r - q.back());
		if (lf == max({ lf,lb,rf,rb }))
		{
			res += lf;
			q.push_front(l);
			s.erase(s.begin());
		}
		else if (lb == max({ lf,lb,rf,rb }))
		{
			res += lb;
			q.push_back(l);
			s.erase(s.begin());
		}
		else if (rf == max({ lf,lb,rf,rb }))
		{
			res += rf;
			q.push_front(r);
			s.erase(--s.end());
		}
		else
		{
			res += rb;
			q.push_back(r);
			s.erase(--s.end());
		}
	}
	if (s.size() == 1)
	{
		ll x = *s.begin();
		res += max(abs(x - q.front()), abs(x - q.back()));
	}
	cout << res << endl;
}

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

#define llong long long
#define inf 999999999
#define mp make_pair
#define pb push_back
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<PP, int> PPP;
typedef struct data{
	int now;
	int cost;
}data;
int nh[4] = {1, 0, -1, 0};
int nw[4] = {0, 1, 0, -1};

llong int x, y;

int dp(llong int a){
	if(a > y) return 0;
	return 1 + dp(a * 2);
}

int main(){
	cin >> x >> y;
	cout << dp(x) << endl;
	return 0;
}

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

#define int long long int
#define float long double
#define pb push_back
#define fi first
#define se second
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define mem(a,k) memset(a,k,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define inf LLONG_MAX
int exp(int x,int y,int mod){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int modinv(int x,int mod){return exp(x,mod-2,mod);}


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

    int k,a,b;
    cin>>k>>a>>b;
    bool ok=0;
    for(int i=a;i<=b;i++)
    	if(i%k==0)
    		ok=1;
    cout<<(ok?"OK":"NG");
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef unsigned long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

long double A;
long double B;

signed main(){
	cin>>A>>B;
	long double d=A*B;
	DEB(d)END
	cout<<(int)floor(d)<<endl;
	return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

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

string check(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a<b)
        return "No";
    if (b>d)
        return "No";
    if (c+1>b)
        return "Yes";
    ll g = gcd(b, d);
    if (g<b-c)
        return "No";
    else{
        if (a%b>c && a%b<b)
            return "No";
        return "Yes";
    }
    return "No";
}

int main()
{
    int t;
    cin >> t;
    rep(i,t){
        cout << check() << endl;
    }
}


Measured memory_bytes: 256
H, W = [int(i) for i in input().split()]
Map = []
for i in range(H):
    Map.append(list(input()))
for i in range(H):
    for j in range(W):
        if Map[i][j] != '.':
            print(Map[i][j], sep="", end="")
            continue
        bomb = 0
        if i > 0 and Map[i-1][j] == '#': #左
            bomb += 1
        if i < H-1 and Map[i+1][j] == '#': #右
            bomb += 1
        if j > 0 and Map[i][j-1] == '#': #上
            bomb += 1
        if j < W-1 and Map[i][j+1] == '#': #下
            bomb += 1
        if i > 0 and j > 0 and Map[i-1][j-1] == '#': #左上
            bomb += 1
        if i < H-1 and j > 0 and Map[i+1][j-1] == '#': #右上
            bomb += 1
        if i > 0 and j < W -1 and Map[i-1][j+1] == '#': #左下
            bomb += 1
        if i < H -1 and j < W -1 and Map[i+1][j+1] == '#': #右下
            bomb += 1
        Map[i][j] = str(bomb)
        print(Map[i][j], sep="", end="")
    print()

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

int main(){
  int n,p;
  while(1){
  cin>>n>>p;
  if(n+p==0) break;
  int a[50]={},s=p;
  int i=0,vic,f=0;
  while(1){
    if(i==n) i=0;
    if(f==1) break;

    if(p<=0){
	if(a[i]==s){
	  f=1;
	  vic=i;
	}

      if(p==0){
	  p+=a[i];
	  a[i]=0;
	} 
    }

    else{
      a[i]++;
      p--;
    }
  i++;
  }

  cout<<vic<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
 
signed main()
{
  int x,t; cin >> x >> t;
  if(x<t){
    cout << "0" << "\n";
    return 0;
  }
  else{
  cout << (x-t) << "\n";
  }
}

Measured memory_bytes: 3608