akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for(ll i = 0; i < n; ++i)
#define RANGE(i, x, n) for(ll i = x; i < n; ++i)

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    ll total = 0;
    vector<ll> A(n+2, 0);
    RANGE(i, 1, n+1) {
        cin >> A[i];
        total += abs(A[i]-A[i-1]);
    }
    total += abs(A[n+1] - A[n]);
    vector<ll> ans(n, 0);
    RANGE(i, 1, n+1) {
        if((A[i] - A[i-1]) * (A[i+1] - A[i]) >= 0) {    // same direct
            ans[i-1] = total;
        }else {
            ans[i-1] = total - (abs(A[i]-A[i-1]) + abs(A[i+1]-A[i]) - abs(A[i+1]-A[i-1]));
        }
    }
    REP(i, n) {
        cout << ans[i] << endl;
    }
}


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

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            if (i * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
# Aizu Problem 0054: Sum of Nth Decimal Places
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


for line in sys.stdin:
    a, b, n = [int(_) for _ in line.split()]
    frac = str(round(a / b, n+2)).split('.')[1]
    print(sum([int(d) for d in frac[:n]]))

Measured memory_bytes: 7780
import math
N, M = map(int, input().split())
mod = int(1E9+7)

def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor

dp = [[1 for _ in range(30)] for _ in range(N)]

for j in range(1, 30):
    for i in range(1, N):
        dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod

A = prime(M)

ans = 1
for x in A.values():
    ans *= dp[N-1][x]
    ans = ans % mod
print(ans)

Measured memory_bytes: 130420
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <algorithm>
#define mp make_pair

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;

const int MAXN = 1e5 + 7;

template<typename T> inline T read() {
	T res = 0, flag = 1; char in = getchar();
	while(!isdigit(in)) { if(in == '-') flag = -1; in = getchar(); }
	while(isdigit(in)) { res = (res << 1) + (res << 3) + in - '0'; in = getchar(); }
	return res * flag;
}

template<typename T> inline void chkmax(T &a, T b) { if(a < b) a = b; }
template<typename T> inline void chkmin(T &a, T b) { if(a > b) a = b; }

int n;
int s[MAXN], ts;
int l[MAXN], tl;
int Min, sum, Max;

inline void init() {
	n = read<int>();
	for(int i = 1; i <= n; ++i) {
		int x = read<int>();
		if(i == 1) Min = x, Max = x;
		if(x <= 0) s[++ts] = x;
		else l[++tl] = x;
		chkmin(Min, x); chkmax(Max, x);
		sum += abs(x);
	}
	if(!ts) {
		printf("%d\n", sum - (Min << 1));
		for(int i = 1; i <= n; ++i)
			if(l[i] == Min) {
				swap(l[1], l[i]);
				break;
			}
		for(int i = 2; i < n; ++i) {
			printf("%d %d\n", Min, l[i]);
			Min = Min - l[i];
		}
		printf("%d %d\n", l[n], Min);
		exit(0);
	}
	if(!tl) {
		printf("%d\n", sum + (Max << 1));
		for(int i = 1; i <= n; ++i)
			if(s[i] == Max) { swap(s[1], s[i]); break; }
		for(int i = 2; i <= n; ++i) {
			printf("%d %d\n", Max, s[i]);
			Max = Max - s[i];
		}
		exit(0);
	}
}

inline void solve() {
	printf("%d\n", sum);
	while(ts != 1) {
		printf("%d %d\n", l[tl], s[ts]);
		l[tl] = l[tl] - s[ts];
		ts--;
	}
	for(int i = 1; i < tl; ++i) {
		printf("%d %d\n", s[1], l[i]); 
		s[1] = s[1] - l[i];
	}
	printf("%d %d\n", l[tl], s[1]);
}

int main() {

	init();
	solve();

	return 0;
}


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

#define ll long long
#define ar array

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)

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

	int n;
    cin >> n;
    ll ans = n%1000;
    if(n%1000 == 0){
        cout << "0" << "\n";
    }else{
        cout << 1000-ans << endl;
    }

}

Measured memory_bytes: 3636
import java.io.{PrintWriter, _}
import java.util
import java.util._


object Main {
  def main(args: Array[String]): Unit = {
    val inputStream = System.in
    val outputStream = System.out
    val in = new InputReader(inputStream)
    val out = new PrintWriter(outputStream)
    val solver = new Task
    solver.solve(1, in, out)
    out.close()
  }

  class Task {
    def solve(testNumber: Int, in: InputReader, out: PrintWriter): Unit = {
      var n = in.nextInt
      var last = n % 10
      n /= 10
      var res = 0
      var count = 0
      while (n > 0) {
        val current = n % 10
        if (current == last) count += 1 else {
          res = math.max(res, count)
          count = 0
        }
        last = current
        n /= 10
      }
      out.println(if (res > 1 || count > 1) "Yes" else "No")

    }
  }

  class InputReader(val stream: InputStream) extends AutoCloseable {
    //reader = new BufferedReader(new FileReader(stream), 32768);
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer = new StringTokenizer("")


    def next: String = {
      while ( {
        tokenizer == null || !tokenizer.hasMoreTokens
      }) try
        tokenizer = new StringTokenizer(reader.readLine)
      catch {
        case e: IOException =>
          throw new RuntimeException(e)
      }
      tokenizer.nextToken
    }

    def nextLine: String = {
      try
        return reader.readLine
      catch {
        case e: IOException =>
          e.printStackTrace()
      }
      ""
    }

    def nextInt: Int = next.toInt

    def nextLong: Long = next.toLong

    override def close(): Unit = {
    }
  }

}


Measured memory_bytes: 25412
#include<iostream>

int gcd(int, int);

using namespace std;

int main(){
  int n;
  cin >> n;
  int l[n];
  for(int i=0; i<n; i++){
    cin >> l[i];
  }
  int re = l[0];
  for(int i=0; i<n; ++i){
    re = gcd(l[i], re);
    if(re == 1){
      break;
    }
  }
  cout << re << endl;
}

int gcd(int a, int b){
  int c = a%b;
  if(!c){
    return b;
  }
  else{
    return gcd(b, c);
  }
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define sz(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
const ll MOD = 1000000007;
//const ll MOD = 998244353;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.12lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}

//約数の列挙O(√n)
vector<ll> divisor(ll n){
    vector<ll> res(0);
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(i != n/i) res.push_back(n/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

void solve(){
  ll H, W;
  cin >> H >> W;
  if(H == 1 || W == 1){
    cout << 1 << endl;
    return;
  }
  if(H % 2 && W % 2){
    cout << H * W / 2 + 1 << endl;
  }else{
    cout << H * W / 2 << endl;
  }
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  solve();
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
		
	int N = sc.nextInt();
	int S = 0;
	
	if(N>=3 && N<=100){
		S = (N - 2)*180;
		System.out.println(S);
	}
	}

}

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

int main() {
    int n, m;
    cin >> n >> m;

    Graph g(n+1);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<int> current, next;
    vector<bool> visited(n+1, false);
    int ans = 0;

    for (int j=1; j<=n; j++) {
        if (visited[j]) continue;
        current.push_back(j);
        visited[j] = true;
        ans++;
        while (!current.empty()) {
            for (auto i: current) {
                for (auto j: g[i]) {
                    if (!visited[j]) {
                        next.push_back(j);
                        visited[j] = i;
                    }
                }
            }
            current.swap(next);
            next.clear();
        }
    }

    cout << ans-1 << endl;
    return 0;
}


Measured memory_bytes: 8804
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}




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

Measured memory_bytes: 3628
p, g = 998244353, 3
invg = pow(g, p-2, p)
W = [pow(g, (p - 1) >> i, p) for i in range(24)]
iW = [pow(invg, (p - 1) >> i, p) for i in range(24)]

def fft(k, f):
    for l in range(k)[::-1]:
        d = 1 << l
        u = 1
        for i in range(d):
            for j in range(i, 1 << k, 2*d):
                f[j], f[j+d] = (f[j] + f[j+d]) % p, u * (f[j] - f[j+d]) % p
            u = u * W[l+1] % p

def ifft(k, f):
    for l in range(k):
        d = 1 << l
        u = 1
        for i in range(d):
            for j in range(i, 1 << k, 2*d):
                f[j+d] *= u
                f[j], f[j+d] = (f[j] + f[j+d]) % p, (f[j] - f[j+d]) % p
            u = u * iW[l+1] % p

def convolve(a, b):
    n0 = len(a) + len(b) - 1
    k = (n0).bit_length()
    n = 1 << k
    a = a + [0] * (n - len(a))
    b = b + [0] * (n - len(b))
    fft(k, a), fft(k, b)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(k, a)
    invn = pow(n, p - 2, p)
    for i in range(n0):
        a[i] = a[i] * invn % p
    return a[:n0]

N, M = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
print(*convolve(A, B))


Measured memory_bytes: 203256
c, r = gets.split.map(&:to_i)
a = Array.new(c+1).map{ Array.new(r+1, 0) }
for i in 0..c-1 do
	a[i] = gets.split.map(&:to_i)
	a[i][r] = 0
end
for i in 0..c-1 do
	for j in 0..r-1 do
		a[i][r] += a[i][j]
	end
end
for i in 0..r do
	for j in 0..c-1 do
		a[c][i] += a[j][i]
	end
end
for i in 0..c do
	puts a[i].join(" ")
end

Measured memory_bytes: 8876
#include <stdio.h>
int main(){
  int H , W;
  while(1){
    scanf("%d %d",&H,&W);
    if(H == 0&& W == 0)break;
    for(int i = 0; i < H; i++){
      if(i == 0 || i == H-1)for(int k = 0;k < W; k++)printf("#");
      else{
        for(int k = 0;k < W; k++){
          if(k == 0 || k == W-1)printf("#");
          else printf(".");
      }
    }
    printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 1740
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int mae = scanner.nextInt();
        int ato = scanner.nextInt();

        while (mae != 0 || ato != 0) {
            int flag = 0;
            for (int i = mae; i <= ato; i++) {
                if (i % 4 == 0) {
                    if (i % 100 == 0 && i % 400 != 0) {
                    } else {
                        System.out.println(i);
                        flag++;

                    }

                }
            }
            if (flag == 0) {
                System.out.println("NA");
            }

            mae = scanner.nextInt();
            ato = scanner.nextInt();
            if (mae != 0 && ato != 0) {
                System.out.println("");
            }
        }
    }
}



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


int main() {
	string s;
	cin >> s;
	int i = 0;
	while (i < s.size()) {
		string tmp = s.substr(i, 7);
		if (tmp == "dreamer") {
			if (s[i + 7] == 'a') {
				i += 5;
				continue;
			}
			i += 7;
			continue;
		}
		tmp = s.substr(i, 6);
		if (tmp == "eraser") {
			i += 6;
			continue;
		}
		tmp = s.substr(i, 5);
		if (tmp == "dream") {
			i += 5;
			continue;
		}
		if (tmp == "erase") {
			i += 5;
			continue;
		}
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * author @sahil
 */
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int p=n;
        int s=0;
        while(n!=0){
            int r=n%10;
            s=s*10+r;
            n=n/10;
        }
        if(p==s) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 21076
fun main(args:Array<String>?): Unit {
    val (n, q) = readLine()!!.trim().split(' ').map(String::toInt)
    val s = readLine()!!.trim()
    val order = Array(q) {
        val (c, t) = readLine()!!.trim().split(' ')
        Pair(c.first(), t.first().toDirection())
    }
    val fromLeft = lowerBound(0, n){value ->
        !isDropFromLeft(value, s, order.asIterable())
    }
    val fromRight = lowerBound(0, n){value ->
        isDropFromRight(value, s, order.asIterable())
    }
    println(
            if (fromLeft <= fromRight) fromRight - fromLeft else 0
    )
}
fun isDropFromRight(start: Int, state: String, order: Iterable<Pair<Char, Direction>>): Boolean {
    var current = start
    for ((t, d) in order) if (state[current] == t) {
        when(d){
            Direction.Left -> current--
            Direction.Right -> current++
        }
        if (current !in state.indices) return current > 0
    }
    return false
}
fun isDropFromLeft(start: Int, state: String, order: Iterable<Pair<Char, Direction>>): Boolean {
    var current = start
    for ((t, d) in order) if (state[current] == t){
        when(d){
            Direction.Left -> current--
            Direction.Right -> current++
        }
        if (current !in state.indices) return current < 0
    }
    return false
}
inline fun lowerBound(from: Int, to: Int, predicate: (value: Int) -> Boolean): Int {
    var left = from
    var right = to
    while(left < right){
        val mid = (left + right) / 2
        if (predicate(mid)){
            right = mid
        }else {
            left = mid + 1
        }
    }
    return right
}
fun Char.toDirection(): Direction {
    return when(this){
        'L' -> Direction.Left
        'R' -> Direction.Right
        else -> throw Exception()
    }
}
enum class Direction{
    Left, Right
}

Measured memory_bytes: 79564
while True:
    a, op, b = input().strip().split()
    a = int(a)
    b = int(b)

    if op == '?':
        break

    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    else:
        print(a // b)


Measured memory_bytes: 5592
import itertools
N, M = map(int, input().split())

path = []
for _ in range(M):
  a, b = map(int, input().split())
  path.append([a, b])

all_routes = itertools.permutations(range(2, N+1))

count = 0
for route in all_routes:
  cur_path = path.copy()
  current = 1
  valid = True
  for next_pos in route:
    if ([current, next_pos] in cur_path):
      cur_path.remove([current, next_pos])
      current = next_pos
      continue
    elif ([next_pos, current] in cur_path):
      cur_path.remove([next_pos, current])
      current = next_pos
      continue
    else:
      valid = False
      break
  
  if(valid == True):
    count += 1

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if (abs(a-c)<=d||abs(a-c)<=2*d  && abs(a-b)<=d && abs(b-c)<=d) 
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    ll a,b,v,w,t;
    cin >> a >> v >> b >> w >> t;
    if( abs(b-a) <= (v-w)*t) dunk("YES");
    else dunk("NO");
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
int N , M ;
int P [100000] , Y [100000];
vector <int> yd [100001];
int main (){
	cin >> N >> M;
	for (int i=0;i<M;i++){
      cin >> P[i] >> Y[i];
      yd[P[i]].push_back(Y[i]);}
	for (int i=0;i<N;i++)sort(yd[i+1].begin(),yd[i+1].end());
	for (int i=0;i<M;i++){
      ll ans=lower_bound(yd[P[i]].begin(),yd[P[i]].end(),Y[i])-yd[P[i]].begin()+1;
      printf ("%012lld\n",ll(P[i])*1000000+ans);
    }
}

Measured memory_bytes: 7808
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(n-1,int(n/2)-1,-1):
  b[i] = a[i]
for i in range(int(n/2)-1,-1,-1):
  c = [(i+1)*x for x in range(1,int(n/(i+1))+1)]
  s = 0
  for j in c:
    s += b[j-1]
  s = s%2
  if s != a[i]:
    b[i] = 1
if sum(b) == 0:
  print(0)
else:
  print(sum(b))
  k = 0
  for i in range(n):
    if b[i] == 1:
      if k == 0:
        print(i+1,end = "")
        k = 1
      else:
        print("",i+1,end="")

Measured memory_bytes: 19664
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        String ans = (a < b) && (b < c) ? "Yes" : "No";
        System.out.println(ans);
    }
}


Measured memory_bytes: 26036
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define mkpr(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()

typedef long long int ll;

ll general,total;
//ll num[ten5];
//ll num2[ten5];
//char cmap[10][10];
//priority_queue<ll> pqll;   //decrease
//priority_queue<double> pqd;
//stack<int> stk;
//vector<pair<ll,ll>> vpll;
//vector<pair<double,double>> vpdd;
//vector<ll> vll[ten52];
//vector<double> vd;
//deque<ll> deq[55];
//list<int> li;
//set<int> sint;
//set<ll> sll;
//set<char> sch;
set<string> sStr;
//map<ll,ll> mp;

ll numR[4000],numG[4000],numB[4000];

/*ll cmp(pair<ll,ll> a,pair<ll,ll> b)
{
    return a.first<b.first;
    //arrising
}*/


int main()
{
    long long int sum,sum2;
    long long int m,n,o,i,j,k=1;
    long long int a,a1,a2,a3,a4,a5,a6;
    string s;
    sum=sum2=0;
    a=a1=a2=a3=a4=a5=a6=0;
    cin>>n>>m;
    a1=(m+1)/2;
    a2=m-a1;
    for(i=1;i<=a1;i++)
        cout<<i<<' '<<1+a1*2-i<<endl;
    for(i=0;i<a2;i++)
    {
        cout<<n-i<<' '<<n-2*a2+i<<endl;
    }
    return 0;
}





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

int main() {
  int N, X;
  cin >> N >> X;
  int ans = 1, D = 0;
  for (int i = 0; i < N; i++) {
    int L;
    cin >> L;
    D += L;
    if (D <= X) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

struct City {
    ll id, prefecture, year, rank;
};

int main() {

    int n, m;
    cin >> n >> m;
    vector<City> cities(m);
    rep(i, m) cities[i].id = i;
    rep(i, m) cin >> cities[i].prefecture >> cities[i].year;
    sort(cities.begin(), cities.end(), [](City &c, City &d) {
        if (c.prefecture != d.prefecture) return c.prefecture < d.prefecture;
        return c.year < d.year;
    });
    cities[0].rank = 0;
    for (int i = 1; i < m; i++) {
        if (cities[i - 1].prefecture != cities[i].prefecture) {
            cities[i].rank = 0;
        } else {
            cities[i].rank = cities[i - 1].rank + 1;
        }
    }
    sort(cities.begin(), cities.end(), [](City &c, City &d) {
        return c.id < d.id;
    });

    for (City &c : cities) {
        printf("%06lld%06lld\n", c.prefecture, c.rank + 1);
    }

}

Measured memory_bytes: 4608
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << (b % a == 0 ? a + b : b - a) << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int mi=INF;
	rep(i,n){
		int a;
		cin>>a;
		int now=0;
		while(a%2==0){
			a/=2;
			now++;
		}
		chmin(mi,now);
	}
	cout<<mi<<endl;
}

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

using ll = long long;

//constant
const ll MOD = 1e+9 + 7;
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// view vector
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
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; }

// ***************************************

int main(void) {

	ll N;
	cin >> N;

	vector<vector<ll>> dp(N, vector<ll>(N));
	vector<ll> A(N);

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

	ll end;
	int sign = (N % 2 == 1) ? 1 : -1;
	REP(i, N) {
		end = N - i;
		REP(j, end) {
			if (i == 0) dp[i][j] = sign * A[j];
			else {
				if (sign == 1) {
					dp[i][j] = max(A[j] + dp[i-1][j+1], A[j+i] + dp[i-1][j]);
				}
				else {
					dp[i][j] = min(-A[j] + dp[i-1][j+1], -A[j+i] + dp[i-1][j]);
				}
			}
		}
		sign *= -1;
	}

	cout << dp[N - 1][0] << endl;

	return 0;
}

Measured memory_bytes: 70656
///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define PB pop_back 
#define pb push_back
#define mp make_pair
#define int long long
#define y1 y_golabi
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll; 
typedef map<int , int> mii;
typedef pair<int , int> pii; 
typedef map<string , int> msi;
typedef pair<int , string> pis; 
typedef pair<int , pair<int , int> > piii;
const int MAXN = 1e5 + 10;
int n , l , t , ans , x[MAXN] , w[MAXN];
vector<int> vec;
int32_t main()
{
	cin >> n >> l >> t;
	for(int i = 0 ; i < n ; i ++)
	{
		cin >> x[i] >> w[i];
		if(w[i] == 1)
			vec.pb((t + x[i]) % l) , ans = (l - x[i] <= t ? ans + ((t - (l - x[i])) / l + 1) : ans + 0);
		else
			vec.pb(((x[i] - t) % l + l) % l) , ans = (x[i] < t ? ans - ((t - x[i] - 1) / l + 1) : ans + 0);
	}
	sort(all(vec)) , ans %= n , (ans += n) %= n;
	for(int i = ans ; i < n ; i ++)
		cout << vec[i] << endl;
	for(int i = 0 ; i < ans ; i ++)
		cout << vec[i] << endl;
	return 0;
}




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

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] array = new int[3];
		array[0] = sc.nextInt();
		array[1] = sc.nextInt();
		array[2] = sc.nextInt();
		Arrays.sort(array);

		int cost2 = array[1] - array[0];
		int cost3 = array[2] - array[1];
		int totalCost = cost2 + cost3;

		System.out.println(totalCost);

	}
}


Measured memory_bytes: 21972
N = int(input())
L=list(map(int,input().split()))
L.sort(reverse=True)
sum=0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if L[i]<L[j]+L[k] and L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i]:
                sum+=1
print(sum)

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> ab(M);
  for (int i=0; i<M; i++) cin >> ab.at(i).first >> ab.at(i).second;
  for (int i=0; i<N; i++) {
    int num = 0;
    for (int j=0; j<M; j++) {
      if (ab.at(j).first==i+1||ab.at(j).second==i+1) num++;
    }
    cout << num << endl;
  }
}

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

using namespace std;



void func()
{
	int year, month, day;
	string S, heisei;
	heisei = "2019/04/30";
	cin >> S;
	if (S > heisei)
		cout << "TBD\n";
	else
		cout << "Heisei\n";

	return;
}

int main() {

//	while (1)
		func();
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))

#define DEBUG(x) cout<<#x<<": "<<(x)<<endl

int h,w;
char c[1252][1252];

int main(){
	scanf("%d%d",&h,&w);
	REP(i,h)scanf("%s",c[i]);
	int ans = 0;
	{
		int mn=1e9, mx=-1e9;
		REP(i,h)REP(j,w)if(c[i][j]=='B'){
			CHMIN(mn,i+j);
			CHMAX(mx,i+j);
		}
		CHMAX(ans, mx-mn);
	}
	{
		int mn=1e9, mx=-1e9;
		REP(i,h)REP(j,w)if(c[i][j]=='B'){
			CHMIN(mn,i-j);
			CHMAX(mx,i-j);
		}
		CHMAX(ans, mx-mn);
	}
	printf("%d\n",ans);
	return 0;
}


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

char c;

int main() {
    cin >> c;
    if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
      cout << "vowel" << endl;
    } else {
      cout << "consonant" << endl;
    }
}

Measured memory_bytes: 3592
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 100010;
const int MAXP = 10000000;
const u64 MOD = 1000000007;
const f80 MI = f80(1)/MOD;
const ll INF = 10000000000000000LL;
const ll inf = 5000000000000LL;


int main()
{
	
	int n;
	string a, b, c;
	cin >> n >> a >> b >> c;
	int ans = 0;
	for (int i = 0; i < n; ++ i)
	{
		set<char> s;
		s.insert(a[i]);
		s.insert(b[i]);
		s.insert(c[i]);
		ans += s.size()-1;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
	char a;
	string s;
	cin>>s;
	a=s[0];
	int cnt=0;
	for(int i=1;i<s.length();i++){
		if(a!=s[i]) cnt++;
		a=s[i];
	}
	cout<<cnt<<endl;
	return 0;
}

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

using namespace std;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  int odd = 0;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    odd += a[i] & 1;
  }
  if (odd > 2) {
    cout << "Impossible\n";
    return 0;
  }
  for (int i = 0; i < m && odd > 0; i++) {
    if (a[i] & 1) {
      swap(a[i], a[0]);
      odd--;
      break;
    }
  }
  for (int i = m - 1; i >= 0 && odd > 0; i--) {
    if (a[i] & 1) {
      swap(a[i], a[m - 1]);
      odd--;
      break;
    }
  }
  for (int i = 0; i < m; i++) {
    cout << a[i] << ' ';
  }
  cout << '\n';
  vector<int> b;
  for (int i = 0; i < m; i++) {
    b.push_back(a[i] + (i == 0 ? -1 : (i == m - 1 ? 1 : 0)));
  }
  if (m == 1) {
    b.push_back(1);
  }
  cout << (int) b.size() - (b[0] == 0) << '\n';
  for (int i = (b[0] == 0); i < (int) b.size(); i++) {
    cout << b[i] << ' ';
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 256
import queue
q = queue.Queue()
n, m = map(int, input().split())
mat = [[] for i in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  mat[a-1].append((a-1,b-1))
  mat[b-1].append((b-1,a-1))

d_list = [(-1,-1)]*n

d_list[0] = (0,0)
while len(mat[0]) > 0:
  q.put(mat[0].pop())

while not q.empty():
  u,v = q.get()

  if d_list[v][1] != -1 and d_list[v][1] <= d_list[u][1]+1:
    pass
  else:
    d_list[v] = (u, d_list[u][1]+1)
    while len(mat[v]) > 0:
      q.put(mat[v].pop())
print("Yes")
for i in range(1,n):
  print(d_list[i][0]+1)


Measured memory_bytes: 112860
#include"bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.141592653589793238

int main() {
	int N, T;
	cin >> N >> T;
	int ans = -1;
	rep(i, N) {
		int c, t;
		cin >> c >> t;
		if (t <= T) {
			if (ans == -1) {
				ans = c;
			}
			else if (c < ans) {
				ans = c;
			}
		}
	}
	if (ans == -1) {
		puts("TLE");
	}
	else {
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N, X = map(int, input().split())
An = [1]
Pn = [1]

for i in range(N):
  An.append(2*An[i]+3)
  Pn.append(2*Pn[i]+1)

ans = 0
#print(An, Pn)

def f(x, i):
  global ans

  if x == An[i]:
    ans += Pn[i]
    print(ans)

  elif An[i]//2 + 1 < x < An[i]:
    ans += Pn[i-1] + 1
    f(x-(An[i]//2 + 1), i-1)

  elif An[i]//2 + 1 == x:
    ans += Pn[i-1] + 1
    print(ans)

  elif 1 < x <= An[i]//2:
    f(x-1, i-1)

  else:
    print(ans)

f(X, N)

Measured memory_bytes: 9236
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

bool check(int x,int y,vector<string> a,vector<string> b ){
    for(auto i = 0; i<b.size();i++){
        for(auto j =0; j<b.size();j++){
            if(a[x+i][y+j]!= b[i][j]) return false;
        }
    }
    return true;
}

int dist(pii a, pii b){
    return abs(a.first-b.first) + abs(a.second-b.second);
}

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







Measured memory_bytes: 256
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := getNextInt(scanner)
	b := getNextInt(scanner)
	c := getNextInt(scanner)
	if a == most(a, b, c) {
		fmt.Fprintln(writer, "A")
		return
	}
	if b == most(a, b, c) {
		fmt.Fprintln(writer, "B")
		return
	}
	fmt.Fprintln(writer, "C")
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func most(a, b, c int) int {
	return max(a, max(b, c))
}



Measured memory_bytes: 1204
#include<iostream>
#include<algorithm>
using namespace std;
int A[100010],B[100010];
int main(){
	string s,t;
	cin>>s>>t;A[0]=0,B[0]=0;
	for(int i=0;i<s.size();i++)A[i+1]=A[i]+(s[i]=='A');
	for(int i=0;i<t.size();i++)B[i+1]=B[i]+(t[i]=='A');
	int q,a,b,c,d;
	cin>>q;
	while(q--){
		cin>>a>>b>>c>>d;a--,c--;
		int x=2*A[b]-b;x-=2*A[a]-a;x%=3;if(x<0)x+=3;
		int y=2*B[d]-d;y-=2*B[c]-c;y%=3;if(y<0)y+=3;
		if(x%3==y%3)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 1664
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ').map(Number);
  const k = 10000;
  let cnt_arr = [];
  for (let i = 0; i <= k; i++) cnt_arr[i] = 0;
  for (let i = 0; i < n; i++) cnt_arr[arr[i]]++;
  for (let i = 1; i <= k; i++) cnt_arr[i] += cnt_arr[i - 1];

  let out_arr = [];
  for (let i = n - 1; i >= 0; i--) {
    out_arr[--cnt_arr[arr[i]]] = arr[i];
  }
  console.log(out_arr.join(' '));
})();



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

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

	string s;cin >> s;
	int ans;
	for(int i = 0; i < pow(2,s.size()-1); i++){
		int sum = stoi(s.substr(0,1));
		for(int j = 0; j < s.size()-1; j++){
			if((i>>j&1) == 1){
				sum -= stoi(s.substr(j+1,1));
			}else{
				sum += stoi(s.substr(j+1,1));
			}
		}
		if(sum == 7){
			ans = i;
		}
	}

	string out = "";
	for(int i = 0; i < 3; i++){
		out += s.substr(i,1);
		if((ans>>i&1) == 1){
			out += "-";
		}else{
			out += "+";
		}
	}
	out += s.substr(3,1)+"=7";
	cout << out << endl;
	
}


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

int main() {
  int n;
  bool check = false;
  cin >> n;
  int x = 1;
  for (int i = 1; i <= 5; i++) {
    x *= 10;
    if (n == x) {
      check = true;
    }
  }
  if (check) {
    cout << 10 << '\n';
  }
    else {
      int sum = 0;
      sum = n/10000 + (n%10000)/1000 + (n%1000)/100 + (n%100)/10 + n%10;
      cout << sum << '\n';
    }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main()
{
    int a ,b, i;
    for(i=1; i<=3000; i++)
    {
        cin >> a >> b;
        if(a==0 && b==0)
            break;
            
        if(a > b)
        {
            a = a+b;
            b = a-b;
            a = a-b;
        }
        cout << a << " " << b << endl;
    }
}




Measured memory_bytes: 3004
from itertools import combinations

S = str(input())
n = len(S)

ans = 0
for i in range(1 << (n-1)):
    cur_ans = int(S[0])
    for j in range(n-1):
        add_plus = (i >> (n-2-j)) & 1
        if add_plus:
            ans += cur_ans
            cur_ans = 0
        else:
            cur_ans *= 10
        cur_ans += int(S[j+1])
    ans += cur_ans
print(ans)            

    



Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int n,d;
    cin>>n>>d;
    int ans = 0;
    rep(i,1,30){
        if(n-((d*2+1)*i)<=0){
            ans = i;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,x;
ll sum,b[N];
struct node
{
    ll b,l,r,x;
    bool operator<(const node&o)const
    {
        return x>o.x;
    }
}a[N];
bool judge(ll m)
{
    ll p=m%x;
    if(p==0) return b[m/x]+sum>=0;
    for(int i=1;i<=n;i++)
    {
        if(i<=m/x)
        {
            if(b[m/x+1]-a[i].x+a[i].b*a[i].l+(p-a[i].b)*(p<=a[i].b?a[i].l:a[i].r)+sum>=0) return true;
        }
        else
        {
            if(b[m/x]+a[i].b*a[i].l+(p-a[i].b)*(p<=a[i].b?a[i].l:a[i].r)+sum>=0) return true;
        }
    }
    return false;
}
int main()
{
    scanf("%d%d",&n,&x);
    for(int i=1;i<=n;i++)
        scanf("%lld%lld%lld",&a[i].b,&a[i].l,&a[i].r),sum-=a[i].b*a[i].l,a[i].x=a[i].b*a[i].l+(x-a[i].b)*a[i].r;
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++)
        b[i]=a[i].x+b[i-1];
    ll l=0,r=(ll)x*n,ans;
    while(l<=r)
    {
        ll m=l+r>>1;
        if(judge(m)) ans=m,r=m-1;
        else l=m+1;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 4096