akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  ll n;
  cin >> n;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) { cin >> v[i]; }
  sort(v.rbegin(), v.rend());

  // 考えやすくする
  if (n == 2) {
    cout << v[0] - v[1] << endl;
    cout << v[0] << " " << v[1] << endl;
    return 0;
  }

  // マイナス要素とプラス要素を作って、集めまくって、最後に差を取る
  deque<ll> plus;
  deque<ll> minus;

  // プラスとマイナスで分ける
  for (int i = 0; i < n; i++) {
    if (v[i] >= 0)
      plus.push_front(v[i]);
    else
      minus.push_back(v[i]);
  }

  ll ma, mi;
  if (plus.empty()) {
    ma = minus.front();
    minus.pop_front();
    ma -= minus.front();
    minus.pop_front();
  } else {
    ma = plus.front();
    plus.pop_front();
  }

  if (minus.empty()) {
    mi = plus.front();
    plus.pop_front();
    mi -= plus.front();
    plus.pop_front();
  } else {
    mi = minus.front();
    minus.pop_front();
  }

  while (!minus.empty()) {
    ma -= minus[0];
    minus.pop_front();
  }

  while (!plus.empty()) {
    mi -= plus[0];
    plus.pop_front();
  }

  cout << ma - mi << endl;

  // もっかい同じことをする ＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝

  // プラスとマイナスで分ける
  for (int i = 0; i < n; i++) {
    if (v[i] >= 0)
      plus.push_front(v[i]);
    else
      minus.push_back(v[i]);
  }

  if (plus.empty()) {
    ma = minus.front();
    minus.pop_front();
    cout << ma << " " << minus.front() << endl;
    ma -= minus.front();
    minus.pop_front();
  } else {
    ma = plus.front();
    plus.pop_front();
  }

  if (minus.empty()) {
    mi = plus.front();
    plus.pop_front();
    cout << mi << " " << plus.front() << endl;
    mi -= plus.front();
    plus.pop_front();
  } else {
    mi = minus.front();
    minus.pop_front();
  }

  while (!minus.empty()) {
    cout << ma << " " << minus[0] << endl;
    ma -= minus[0];
    minus.pop_front();
  }

  while (!plus.empty()) {
    cout << mi << " " << plus[0] << endl;
    mi -= plus[0];
    plus.pop_front();
  }

  cout << ma << " " << mi << endl;
}


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

int main(){
	int n;
	int num[100];
	long long min_cost = 4000000,res;
	cin >> n;
	int min=100,max=-100;
	for(int i=0;i<n;i++){
		cin >> num[i];
		if(min > num[i])
			min = num[i];
		if(max < num[i])
			max = num[i];
	}
	for(int i=min;i<=max;i++){
		res = 0;
		for(int j=0;j<n;j++){
			res += (num[j]-i)*(num[j]-i);
		}
		if(res < min_cost)
			min_cost = res;
	}
	cout << min_cost << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N + 1, 0);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    long long ans = 0;
    for (int i = 0; i < N; i++) {
        ans += a[i] / 2;
        if (a[i] % 2 == 1 && a[i + 1] > 0) {
            ans++;
            a[i + 1]--;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>

struct vec
{
    int64_t x,y;

    int quatr() const
    {
        if (x>0 && y>=0) return 0;
        else if (x<=0 && y>0) return 1;
        else if (x<0 && y<=0) return 2;
        else if (x>=0 && y<0) return 3;
        else return 666;
    }

    bool operator<(const vec& v) const
    {
        int l = quatr();
        int r = v.quatr();
        if (l == r) return x*v.y-y*v.x > 0;
        else return l < r;
    }
    vec operator+(const vec& v) const
    {
        return {x+v.x, y+v.y};
    }
    vec& operator+=(const vec& v)
    {
        x += v.x;
        y += v.y;
        return *this;
    }
    int64_t len() const
    {
        return x*x + y*y;
    }
} V[100];

int main()
{
    std::ios_base::sync_with_stdio(0);
    int n;
    std::cin >> n;
    int64_t result = 0;
    for (int i=0;i<n;++i) std::cin >> V[i].x >> V[i].y;
    std::sort(V, V+n);

    for (int s=0;s<n;++s)
    {
        vec v = {0, 0};
        for (int l=0;l<n;++l)
        {
            v += V[(s+l)%n];
            result = std::max(result, v.len());
        }
    }

    std::cout << std::setprecision(20) << std::fixed << sqrtl(result);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ll n,k,i,sum,p=0;
  double f=1.000000000000,res=0.000000000000;
  cin>>n>>k;
  for(i=1;i<=n;i++)
  {
    p=0;
    sum=i;
    while(sum<k)
    {
      sum=2*sum;
      p++;
    }
    f=1;
    while(p--)
    {
      f=f*(1/(double)2);
    }
    res=res+f/(double)n;
  }
    cout<<fixed<<setprecision(12)<<res<<endl;
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int64_t c;
    cin >> c;
    vector<pair<int64_t, int64_t>> xv(n, pair<int, int>());
    for (int i = 0; i < n; i++)
    {
        cin >> xv.at(i).first >> xv.at(i).second;
    }
    sort(xv.begin(), xv.end());

    vector<int64_t> max_r(n + 1, 0);
    vector<int64_t> cost_r(n + 1, 0);
    int64_t acc = 0;
    for (int i = 0; i < n; i++)
    {
        int64_t xi = xv.at(i).first, vi = xv.at(i).second;
        acc += vi;
        if (max_r.at(i) < acc - xi)
        {
            max_r.at(i + 1) = acc - xi;
            cost_r.at(i + 1) = xi;
        }
        else
        {
            max_r.at(i + 1) = max_r.at(i);
            cost_r.at(i + 1) = cost_r.at(i);
        }
    }

    vector<int64_t> max_l(n + 1, 0);
    vector<int64_t> cost_l(n + 1, 0);
    acc = 0;
    for (int i = 0; i < n; i++)
    {
        int64_t xi = xv.at(n - i - 1).first, vi = xv.at(n - i - 1).second;
        acc += vi;
        if (max_l.at(i) < acc - (c - xi))
        {
            max_l.at(i + 1) = acc - (c - xi);
            cost_l.at(i + 1) = c - xi;
        }
        else
        {
            max_l.at(i + 1) = max_l.at(i);
            cost_l.at(i + 1) = cost_l.at(i);
        }
    }

    int64_t res = 0;
    for (int i = 0; i < n + 1; i++)
    {
        res = max(res, max(max_r.at(i), max_l.at(n - i)));
        res = max(res, max_r.at(i) + max_l.at(n - i) - min(cost_r.at(i), cost_l.at(n - i)));
    }
    cout << res << endl;
}

Measured memory_bytes: 4992
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
n, q = map(int, input().split())

trees = [ [] for i in range(n) ]
for i in range(n-1):
    a, b = map(int, input().split())
    trees[a-1].append(b-1)
    trees[b-1].append(a-1)

values = [ 0 for i in range(n) ]
for i in range(q):
    p, x = map(int, input().split())
    values[p-1] += x
#print(values)

def dfs2(i, parent):
    for j in trees[i]:
        if j == parent: continue
        values[j] += values[i]
        dfs2(j, i)

dfs2(0, -1)
print(*values)

Measured memory_bytes: 230920
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>

#define roop(i, n) for(int i=0;i<n;i++)

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ull mod = 1e9+7;
constexpr int N = 13;
ull dp[100010][N];

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	int n;
	cin >> n;
	int ans[3];
	ans[0] = 9;
	ans[1] = 900;
	ans[2] = 90000;
	int count = 0;
	if (n < 10) {
		cout << n << endl;
	} else if (n < 100) {
		cout << ans[0] << endl;
	} else if (n < 1000) {
		cout << (ans[0] + (n + 1) - 100) << endl;
	} else if (n < 10000) {
		cout << (ans[0] + ans[1]) << endl;
	} else if (n < 100000) {
		cout << (ans[0] + ans[1] + (n + 1) - 10000) << endl;
	} else if (n < 1000000) {
		cout << (ans[0] + ans[1] + ans[2]) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
	f = 0; _T fu = 1; char c = getchar();
	while (c < '0' || c > '9') { if (c == '-') { fu = -1; } c = getchar(); }
	while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
	f *= fu;
}

template <typename T>
void print(T x) {
	if (x < 0) putchar('-'), x = -x;
	if (x < 10) putchar(x + 48);
	else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
	print(x); putchar(t);
}

const int N = 5e5 + 5, md = 998244353;

inline int add(int x, int y) {
	x += y;
	if (x >= md) x -= md;
	return x;
}

inline int sub(int x, int y) {
	x -= y;
	if (x < 0) x += md;
	return x;
}

inline int mul(int x, int y) { return 1ll * x * y % md; }

inline int fpow(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		y >>= 1; x = mul(x, x);
	}
	return ans;
}

int fac[N], inv[N];
int n, m, ans;

inline int C(int n, int m) {
	if (n < 0 || m < 0 || n < m) return 0;
	return mul(fac[n], mul(inv[m], inv[n - m]));
}

int main() {
	read(n); read(m);
	if (n < m) swap(n, m);
	fac[0] = 1;
	for (int i = 1; i <= n; i++) fac[i] = mul(fac[i - 1], i);
	inv[n] = fpow(fac[n], md - 2);
	for (int i = n; i >= 1; i--) inv[i - 1] = mul(inv[i], i);
	int pw1 = fpow(m + 1, n), pw2 = fpow(n + 1, m), inv1 = fpow(m + 1, md - 2), inv2 = fpow(n + 1, md - 2);
	for (int i = 0; i <= m; i++, pw1 = mul(pw1, inv1), pw2 = mul(pw2, inv2)) {
		int v = mul(mul(C(n, i), C(m, i)), mul(mul(pw1, pw2), fac[i]));
		if (i & 1) ans = sub(ans, v);
		else ans = add(ans, v);
	}
	print(ans, '\n');
	return 0;
}

Measured memory_bytes: 7416
#include<stdio.h>
#include<string.h>
int main(void){
	int i,j,k,n;
	int taro=0,hana=0;
	int lent,lenh,lena;
	char t[101],h[101];

	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%s %s",&t,&h);

		lent=strlen(t);
		lenh=strlen(h);
		lena=(lent>lenh)?lent:lenh;

		j=0;
		for(k=1;k<=lena;k++){
			j=strncmp(t,h,i);
			if(j!=0) break;
		}
		if (j==0){
			taro++;
			hana++;
		}
		else if(j>0){
			taro+=3;
		}
		else{
			hana+=3;
		}
	}
	printf("%d %d\n",taro,hana);
	return 0;
}

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

using namespace std;

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

    vector<int> as(N);

    for (int i = 0; i < N; ++i)
        cin >> as[i];

    sort(as.begin(), as.end(), greater<int>());

    int xs[] { 0, 0 };

    for (int i = 0, k = 0; i < N; ++i, k = 1 - k)
        xs[k] += as[i];

    cout << xs[0] - xs[1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    char a,b,ans='A';
    while(scanf(" %c,%c",&a,&b)!=EOF)
    {
        if(a==ans) ans=b;
        else if(b==ans) ans=a;
    }
    printf("%c\n",ans);
  return 0;
}

Measured memory_bytes: 1136
import java.io._
import java.util.StringTokenizer

import scala.reflect.ClassTag

object Main {
  def main(args: Array[String]): Unit = {
    try {
      val (in, out) =
        if (isOnlineJudge) {
          (
            new FastScanner(new InputStreamReader(System.in)),
            new PrintWriter(System.out)
          )
        } else {
          (
            new FastScanner(new FileReader(new File("src/resource/problem.in"))),
            new PrintWriter(new File("src/resource/problem.out"))
          )
        }
      new Abc151(in, out).solve()
      out.flush()
      out.close()
    } catch {
      case e: IOException => e.printStackTrace()
    }
  }

  private[this] val isOnlineJudge = true

  class FastScanner(val streamReader: InputStreamReader) {
    private[this] val reader = new BufferedReader(streamReader, 32768)
    private[this] var tokenizer: StringTokenizer = _

    @inline private[this] final def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = Integer.parseInt(next())

    def nextLong(): Long = java.lang.Long.parseLong(next())

    def nextChar(): Char = next().charAt(0)

    def ni(): Int = nextInt()

    def nl(): Long = nextLong()

    def nc(): Char = nextChar()

    def ns(): String = next()

    def ns(n: Int): Array[Char] = ns().toCharArray

    def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)

    def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
      val A1, A2 = Array.ofDim[Int](n)
      REP(n) { i =>
        A1(i) = ni() + offset
        A2(i) = ni() + offset
      }
      (A1, A2)
    }

    def nm(n: Int, m: Int): Array[Array[Int]] = {
      val A = Array.ofDim[Int](n, m)
      REP(n) { i =>
        REP(m) { j =>
          A(i)(j) = ni()
        }
      }
      A
    }

    def nal(n: Int): Array[Long] = map(n)(_ => nl())

    def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n)(_ => ns(m))
  }

  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while (i < N) {
      f(i);
      i += 1
    }
  }

  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while (i >= offset) {
      f(i);
      i -= 1
    }
  }

  def TO(from: Int, to: Int)(f: Int => Unit): Unit = {
    REP(to - from + 1, from)(f)
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]): Array[Long] = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

class Abc151(fScanner: Main.FastScanner, out: java.io.PrintWriter) {

  import Main._
  import fScanner._

  def solve(): Unit = {
    val c = nc()
    out.println((c + 1).toChar)
  }
}


Measured memory_bytes: 27204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define INF 1e9

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

    int N;
    vector<string> W;

    cin >> N;
    string x;
    for (int i = 0; i < N; i++) {
        cin >> x;
        W.push_back(x);
    }

    for (int i = 0; i < N - 1; i++) {
        if (W[i][W[i].length()-1] != W[i+1][0]) {
            cout << "No" << endl;
            exit(0);
        }
    }

    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            if (W[i] == W[j]) {
                cout << "No" << endl;
                exit(0);
            }
        }
    }
    cout << "Yes" << endl;
}

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

int field[101][101];
int pattern[50][50];
int next[50][50];

int main() {
    while (true) {
        int n, m;
        cin >> n >> m;
        if ((n | m) == 0) {
            break;
        }
        for (int y = 1; y <= n; y++) {
            for (int x = 1; x <= n; x++) {
                cin >> field[y][x];
            }
        }
        for (int y = 0; y < m; y++) {
            for (int x = 0; x < m; x++) {
                cin >> pattern[y][x];
            }
        }
        pair<int, int> ans = make_pair(n + 1, n + 1);
        for (int i = 0; i < 4; i++) {
            for (int y = 1; y + m - 1 <= n; y++) {
                for (int x = 1; x + m - 1<= n; x++) {
                    pair<int, int> add = make_pair(-1, -1);
                    for (int dy = 0; dy < m; dy++) {
                        for (int dx = 0; dx < m; dx++) {
                            if (add.first == -1 && pattern[dy][dx] >= 0) {
                                add = make_pair(y + dy, x + dx);
                            }
                            if (pattern[dy][dx] >= 0 && pattern[dy][dx] != field[y + dy][x + dx]) {
                                goto endMatch;
                            }
                        }
                    }
                    if ((add.first < ans.first)
                        || (add.first == ans.first && add.second < ans.second)) {
                        ans = add;
                    }
                endMatch:;
                }
            }
            if (i == 3) {
                break;
            }
            for (int y = 0; y < m; y++) {
                for (int x = 0; x < m; x++) {
                    next[y][x] = pattern[m - 1 - x][y];
                }
            }
            for (int y = 0; y < m; y++) {
                for (int x = 0; x < m; x++) {
                    pattern[y][x] = next[y][x];
                }
            }
        }
        if (ans.first > n) {
            cout << "NA" << endl;
        } else {
            cout << ans.second << " " << ans.first << endl;
        }
    }
}

Measured memory_bytes: 936
import java.util.Scanner;

/**
 * @author author
 *
 */
public class Main {

  /**
   * @param args
   */
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());

    int[] numbers = new int[n];
    for (int i = 0; i < n; i++) {
      numbers[i] = Integer.parseInt(sc.next());
    }
    
    int min = 12000;
    for (int k = 0; k < numbers.length; k++) {
      int sumRight = 0;
      int sumLeft = 0;
      for (int k2 = k + 1; k2 < numbers.length; k2++) {
        sumRight += numbers[k2];
      }
      for (int k3 = 0; k3 < k + 1; k3++) {
        sumLeft += numbers[k3];
      }
      min = Math.min(Math.abs(sumRight - sumLeft), min);
    }
    System.out.println(min);
  }
}



Measured memory_bytes: 23636
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl



signed main() {

	string s;
	cin >> s;
	int n = s.length();
	int cnt = 0;
	rep(i, n) {
		if (s[i] == 'o') cnt++;
	}
	if (cnt+(15-n) >= 8) YES;
	else NO;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static long bignum = 1000000000+7;

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int ans = 0;

		for(int i =0;i<n;i++) {
			int a = sc.nextInt();
			if(i%2==0&&(a%2!=0))ans++;
		}
		System.out.println(ans);
	}

	static long yuclid(long a, long b) {
		long ans;
		if(a<b) {
			long aa = a;
			a=b;
			b=aa;
		}
		while(true) {
			if(b%a==0) {
				ans = a;
				break;
			}else {
				long aa =a;
				a= b%a;
				b=aa;
			}
		}
		return ans;
	}


	static long divn(int target, int times) {//10_9+7のあまり累乗版
		int sqtimes = (int)Math.sqrt(times);
		long ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans * target)%(bignum);
		}
		long holder = ans;
		ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans*holder)%(bignum);
		}
		for(int i=0;i<times - sqtimes*sqtimes;i++) {
			ans = (ans * target)%(bignum);
		}
		return ans;
	}

	static long div(long a) {//10_9+7のあまり
		if(a<0)a+=bignum;
		return a%(bignum);
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 35904
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, C = 0;

  std::string S;

  std::cin >> N >> S;

  for (int i = 0; i < N - 2; i ++) {
    std::string s(S.substr(i, 3));

    if (s == "ABC")
      C ++;
  }

  std::cout << C << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <cstring>

#define LL long long
#define INF 2147483647

using namespace std;
struct node{
	int a,b;
};

int cmp(node a,node b){
	return a.a<b.a;
}
int main(){
	int n;
	cin>>n;
	node nd[100005];
	for (int i=0;i<n;i++){
		scanf("%d%d",&nd[i].a,&nd[i].b);
	}
	sort(nd,nd+n,cmp);
	int ans=nd[n-1].a+nd[n-1].b;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>

int main(){
  int N,L;
  int sigma=0;
  scanf("%d %d",&N,&L);
  for(int i=1;i<=N;i++)
    sigma += L + i - 1;
  if(!L||L<0&&L+N-1>0)
    printf("%d\n",sigma);
  else if(L>0)
    printf("%d\n",sigma-L);
  else
    printf("%d\n",sigma-(N+L-1));

  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n){
	for(int i=2;i<n;i++){
		if(n%i==0){
			return false;
		}
	}
	return true;
}
int main(){
	int n;
	cin>>n;
	for(int i=n;;i++){
		if(isPrime(i)){
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
} 

Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	if N >= 1000 {
		fmt.Fprintln(wtr, "ABD")
	} else {
		fmt.Fprintln(wtr, "ABC")
	}

	wtr.Flush()
}


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

namespace AtCoder179
{
    class Program
    {
        static int[] RI()
        {
            return Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        }

        static long[] RL()
        {
            return Console.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        }

        static string RS()
        {
            return Console.ReadLine();
        }

        static void W(object msg)
        {
            Console.WriteLine(msg);
        }

        static void Main(string[] args)
        {
            QA();
        }

        private static void QA()
        {
            string line = RS();
            W(line + (line.EndsWith("s") ? "es" : "s"));
        }

        private static void QB()
        { 

        }

        private static void QC()
        {
 
        }

        private static void QD()
        {

        }

        private static void QE()
        {

        }
    }
}


Measured memory_bytes: 18192
n = int(input())
a = list(map(int, input().split()))

alice = []
bob = []
sorted_cards = sorted(a, reverse=True)

for i, v in enumerate(sorted_cards):
    if i % 2 == 0:
        alice.append(v)
    else:
        bob.append(v)

print(sum(alice)-sum(bob))

Measured memory_bytes: 38256
n,a=map(int,input().split())
x=list(map(int,input().split()))
b=sum(x)
ans=0
dp=[[0]*(b+1)for i in range(n+1)]
dp[0][0]=1
for i in range(n):
    for k in range(i+1,0,-1):
        for v in range(b,x[i]-1,-1):
            dp[k][v]+=dp[k-1][v-x[i]]
for k in range(1,n+1):
    if k*a>b:
        break
    ans+=dp[k][k*a]
print(ans)


Measured memory_bytes: 4084
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())
ab = [a1, a2, a3, b1, b2, b3]

if ab.count(1) >= 3 or ab.count(2) >= 3 or ab.count(3) >= 3 or ab.count(4) >= 3:
    print('NO')
else:
    print('YES')


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

void dfs(int now, int from, const vector<vector<int>>& G, vector<int>& dist) {
  for (auto it : G[now]) {
    if (it == from) continue;
    dist[it] = dist[now] + 1;
    dfs(it, now, G, dist);
  }
}

int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--, v--;
  vector<int> a(n-1), b(n-1);
  vector<vector<int>> G(n+1);
  rep(i, n-1) {
    int s, t;
    cin >> s >> t;
    a[i] = --s, b[i] = --t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  vector<int> distT(n), distA(n);
  dfs(u, -1, G, distT);
  dfs(v, -1, G, distA);

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    // debug(distT[i]);
    // debug(distA[i]);
    if (distT[i] < distA[i]) {
      chmax(ans, distA[i]-1);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 13696
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define MAXN 1<<20
int t[MAXN], lazy[MAXN];
#define INF 100000000000000000

void init(){
	fill_n(t,MAXN,INF);
	fill_n(lazy,MAXN,INF);
}
 
void push(int v) {
    t[v*2] = min(lazy[v],t[2*v]);
    lazy[v*2] = min(lazy[v],lazy[2*v]);
    t[v*2+1] = min( t[2*v+1], lazy[v]);
    lazy[v*2+1] = min(lazy[v], lazy[2*v+1] ) ;
    //lazy[v] = INF;
}
 
void update(int v, int tl, int tr, int l, int r, int addend) {
    if (l > r) 
        return;
    if (l == tl && tr == r) {
        t[v] = min(addend,t[v]);
        lazy[v] = min(addend,lazy[v]);
    } else {
        push(v);
        int tm = (tl + tr) / 2;
        update(v*2, tl, tm, l, min(r, tm), addend);
        update(v*2+1, tm+1, tr, max(l, tm+1), r, addend);
        t[v] = min(t[v*2], t[v*2+1]);
    }
}
 
int query(int v, int tl, int tr, int l, int r) {
    if (l > r)
        return INF;
    if (l <= tl && tr <= r)
        return t[v];
    push(v);
    int tm = (tl + tr) / 2;
    return min(query(v*2, tl, tm, l, min(r, tm)), 
               query(v*2+1, tm+1, tr, max(l, tm+1), r));
}
 
int n,m,dp[101010];
string s;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
        
	cin >> n >> m;
	cin >> s;
	init();
	dp[0] = 0;
	update(1,0,n,0,0,0);
	for(int i=0;i<n;i++){
		if(s[i]=='1'){
			dp[i] = INF;
			continue;
		}
		int l = i+1;
		int r = min(n, i+m);
		if(i!=0){
			dp[i] = query(1,0,n,i,i);
		}
		update(1,0,n,l,r,dp[i]+1);
	}
	dp[n] = query(1,0,n,n,n);
	//cout << dp[n] << endl;
	if(dp[n]>=INF){
		cout << -1 << endl;
		return 0;
	}
	vi ans;
	int cur = n;
	while(cur>0){
		for(int j=max(0LL,cur-m);j<cur;j++){
			if(dp[cur]==dp[j]+1){
				ans.pb(cur-j);
				cur = j;
				break;
			}
		}
	}
	reverse(all(ans));
	for(auto t:ans){
		cout << t << " ";
	}
	cout << endl;


return 0;
}
///....


Measured memory_bytes: 18632
(async () => {
    let input = '';
    for await (const chunk of process.stdin) input += chunk;
    const lines = input.split(/\n/);
    const [n, k] = lines.shift().split(/\s/).map(v => +v);
    let a = lines[0].split(/\s/).slice(0, n).map(v => +v);

    let min = 0;
    let max = 1e9;
    while(Math.abs(max - min) > 1){
        const mid = Math.ceil((max + min) / 2);
        if(a.reduce((count, a) => count + Math.ceil(a / mid) - 1, 0) <= k){
            max = mid;
        }else{
            min = mid;
        }
    }
    console.log(Math.ceil(max));
})()


Measured memory_bytes: 53472
#include <bits/stdc++.h>
#define WHOLE(v) v.begin(), v.end()
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    int ans = 0;
    for(int i = 0; i < N; i++) cin >> p[i];
    for(int i = 0; i < N - 2; i++) {
        if( (p[i] <= p[i + 1] && p[i + 1] <= p[i + 2]) || (p[i] >= p[i + 1] && p[i + 1] >= p[i + 2])) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int f = 0, t = 0, o = 0;
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            long a = in.nextLong();
            if (a % 4 == 0) {
                f++;
            } else if (a % 2 == 0) {
                t++;
            } else {
                o++;
            }
        }
        if(f > 0) {
            if(o < f || f == o || (o == f + 1 && t == 0)) {
                System.out.println("Yes");
            }else {
                System.out.println("No");
            }
        }else {
            if(o == 0 && t > 1) {
                System.out.println("Yes");
            }else {
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 48624
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,s=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                s+=__gcd(__gcd(i,j),__gcd(j,k));
            }
        }
    }
    cout<<s;
}


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

#define DEBUG 0

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DLOG(...)
#endif

void debug(auto f) {
#if DEBUG
  f();
#endif
}

ll big = 101;

int main() {
  ll bN;
  cin >> bN;
  vector<string> bS(bN);
  ll sum = 0;
  ll nonMult = big;
  for (ll i = 0; i < bN; i++)  {
    ll x;
    cin >> x;
    sum += x;
    if (x % 10 != 0 && x < nonMult)  nonMult = x;
  }
  ll ans = sum % 10 != 0 ? sum : nonMult == big ? 0 : sum - nonMult;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
N = int(input())
U, V, W = [], [], []
T = [[] for _ in range(N)]
# tree
class Tree(object):
    def __init__(self, us, vs, ws):
        self.con_table = [[] for _ in range(len(us) + 1)]
        self.weights = dict()
        for (u, v, w) in zip(us, vs, ws):
            self.con_table[u-1].append(v-1)
            self.con_table[v-1].append(u-1)
            self.weights[(u-1, v-1)] = w
        self.init_search()

    def init_search(self):
        self.visited = [False for _ in range(len(self.con_table))]

dists = [None for _ in range(N)]

from collections import deque

def dfs(tree, s):
    tree.init_search()
    dists[s] = 0
    while not all(tree.visited):
        search = deque()
        tree.visited[s] = True
        search.append(s)
        while len(search) > 0:
            v = search.pop()
            for u in tree.con_table[v]:
                if not tree.visited[u]:
                    dists[u] = dists[v] + tree.weights[(min(u, v), max(u, v))]
                    tree.visited[u] = True
                    search.append(u)

for _ in range(N-1):
    u, v, w = map(int, input().split())
    U.append(u)
    V.append(v)
    W.append(w)

tree = Tree(U, V, W)

dfs(tree, 0)

print('\n'.join(('0' if d % 2 == 0 else '1') for d in dists))


Measured memory_bytes: 66736
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

int main(void){
	ll n,x;
	scanf("%lld%lld",&n,&x);
	printf("%lld\n",(ll)3LL*((ll)n-gcd(n,x)));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> d(n);
	for (int i = 0; i < n; i++) cin >> d[i];
	sort(d.begin(), d.end());
	int ans = 0;
	int last = 0;
	for (int i = 0; i < n; i++) {
		if (last == d[i]) {
			continue;
		}
		ans++;
		last = d[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]

ab.sort()
cnt = 0
ans = 0
for i in range(n):
	ans += ab[i][0] * min(ab[i][1], m - cnt)
	cnt += min(ab[i][1], m - cnt)
	if cnt == m:
		print(ans)
		exit()

Measured memory_bytes: 61016
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

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

ll lcm(ll a, ll b){
   return a * b / gcd(a, b);
}


int main(){
    FIN;

    ll a,b;
    cin >> a >> b;
    ll ans = lcm(a,b);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>

int main()
{
	int a, b;
	int te, tt;
	int result = -1;

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

	for (int i = 1; i <= a* 800; i++) {
		te = i * 0.08;
		tt = i * 0.1;

		if (te == a && tt == b) {
			result = i;
			break;
		}
	}

	printf("%d\n", result);

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        
        Scanner scan = new Scanner(System.in);
       
        int n = scan.nextInt();
        int s = scan.nextInt();

        int x = -1, y = -1, z = -1;
        boolean flg = false;
        for(int i=0; i<=n; i++){
            for(int j=0; j<=n-i; j++){
                int k = n - (i + j);
                if((i+j+k) != n || (10000*i + 5000*j + 1000*k) != s) continue;
                else{
                    x = i;
                    y = j;
                    z = k;
                    flg = true;
                    break;
                }
            }
            if(flg) break;
        }

        System.out.println(x + " " + y + " " + z);

        scan.close();
        
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <sstream>
#include <map>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
bool desc(pair<int, string> p1, pair<int, string> p2) {
	if(p1.first==p2.first) return p1.second < p2.second;
	return p1.first > p2.first;
}
int main() {
	int	n;
	string str, s, k;
	bool f = 0;
	while(1) {
		scanf("%d", &n);
		if(n==0) break;
		cin.ignore();
		map<string, int> m;
		vector<pair<int, string> > v;
		rep(i,n) {
			getline(cin, str);
			stringstream ss(str);
			while(!ss.eof()) {
				ss >> s;
				m[s]++;
			}
		}
		cin >> k;
		bool f = 0;
		auto it = m.lower_bound(k);
		if(it == m.end()) f = 1;
		else {
			string u = it->first;
			while(1) {
				if(u[0] != k[0]) break;
				v.push_back(make_pair(it->second, it->first));
				it++;
				if(it == m.end()) break;
				u = it->first;
			}
		}
		if(f || v.empty()) cout << "NA" << endl;
		else {
			sort(v.begin(), v.end(), desc);
			cout << v[0].second;
			rep2(i,1,v.size()) {
				if(i==5) break;
				cout << " " << v[i].second;
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 1260
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int tower[1005];
int main()
{
	for(int i=1;i<=999;i++)
		tower[i]=tower[i-1]+i;
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=2;i<=999;i++)
		if(tower[i-1]-a==tower[i]-b)
		{
			printf("%d\n",tower[i-1]-a);
			return 0;
		}
	return 0;
}//

Measured memory_bytes: 128
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=0
for i in range(N):
    ans+=B[A[i]-1]
    if i>0 and A[i-1]+1==A[i]:
        ans+=C[A[i-1]-1]
print(ans)

Measured memory_bytes: 3064
N = int(input())
cnt1 = 0
cnt2 = 0
cnt3 = 0
cnt4 = 0
for i in range(N):
  s = input()
  if s == 'AC':
    cnt1 += 1
  elif s == 'WA':
    cnt2 += 1
  elif s == 'TLE':
    cnt3 += 1
  elif s == 'RE':
    cnt4 += 1
print("AC x",cnt1)
print("WA x",cnt2)
print("TLE x",cnt3)
print("RE x",cnt4)

Measured memory_bytes: 9208
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int n=in();
	vector<int> a(n);
	for(int &i:a)i=in();
	vector<int> p(n+1);
	map<int,int> f;
	int ans=0;
	for(int i=1;i<=n;i++)p[i]+=(p[i-1]+a[i-1]);
	for(int i=0;i<=n;i++)
	{
		if(f[p[i]])ans+=f[p[i]];
		f[p[i]]++;
	}
	cout<<ans;
	
}


Measured memory_bytes: 18736
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



ll H;
ll dfs(ll h){
    
  if(h ==1) return 1;
  return (dfs(h/2)*2)+1;
}
int main(){
   
    
    cin >> H;  
    fin(dfs(H));
    
}
  

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

int main(){
	vector<int> a(3);
  	cin>>a.at(0)>>a.at(1)>>a.at(2);
  
    sort(a.begin(),a.end());
  
    if(a.at(0)==a.at(1) && a.at(1)==a.at(2)){
    	cout<<1<<endl;
      	return 0;
    }
  	
  	if(a.at(0)==a.at(1) || a.at(1)==a.at(2)){
    	cout<<2<<endl;
      	return 0;
    }
  
  	cout<<3<<endl;
   	
}    

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func isYear(i int) bool {
	return 0 <= i && i <= 99
}

func isManth(i int) bool {
	return 1 <= i && i <= 12
}

func main()  {
	var str string

	fmt.Scan(&str)

	a, _ := strconv.Atoi(str[0:2])
	b, _ := strconv.Atoi(str[2:4])

	yymm := isYear(a) && isManth(b)
	mmyy := isManth(a) && isYear(b)

	if yymm && mmyy {
		fmt.Println("AMBIGUOUS")
	} else if yymm {
		fmt.Println("YYMM")
	} else if mmyy {
		fmt.Println("MMYY")
	} else {
		fmt.Println("NA")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int ans = 0;
    
    int N = 3;
    int a[3];

    for(int i=0; i < N; i++){
        cin >> a[i];
    }
    sort(a, a+N);
    
    // for(int i=0; i < N; i++){
    //     cout << a[i] << " ";
    // }
    for(int i=1; i < N; i++){
        ans += a[i] - a[i-1];
    }

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
int a[2],cnt1=0,cnt2=0,cnt3=0;
cin>>a[0]>>a[1];
for(int i=0;i<2;++i)
{
if(a[i]==1||a[i]==3||a[i]==5||a[i]==7||a[i]==8||a[i]==10||a[i]==12)
cnt1++;
else
if(a[i]==2)
cnt2++;
else
if(a[i]==4||a[i]==6||a[i]==9||a[i]==11)
cnt3++;
}

if(cnt1==2||cnt2==2||cnt3==2)
cout<<"Yes";
else
cout<<"No";

}

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

int main() {
    int n;
    cin >> n;
    for (int i = 0;; i++) {
        if (n < pow(2, i)) {
            cout << pow(2, i - 1) << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <utility>

using namespace std;

#define pb push_back
#define ft first
#define sd second
#define mpr make_pair
#define all(x) begin((x)), end((x))
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int (i) = 0; (i) < (n); ++(i))
#define max3(a, b, c) max((a), max((b), (c)))
#define max4(a, b, c, d) max(max((a), (b)), max((c), (d)))
#define min3(a, b, c) min((a), min((b), (c)))
#define min4(a, b, c, d) min(min((a), (b)), min((c), (d)))
#define isz(x) (int)(x).size()

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef pair<int, int> pii;
typedef vector<int> vi;

/* <------------------------------------------------------------------------------------> */

const ll M = 1e9 + 7, MAX = 1e5 + 7;
ll a[MAX], cn[MAX], cx[MAX];

ll bin_pow(ll a, ll n)
{
    if (!n) return 1;
    if (n & 1) return a * bin_pow(a, n - 1) % M;
    ll b = bin_pow(a, n >> 1);
    return b * b % M;
}

ll inv(ll a)
{
    return bin_pow(a, M - 2);
}

void init_cnk(ll * cnk, ll n)
{
    cnk[0] = 1;
    for (ll k = 1; k <= n; ++k)
        cnk[k] = (cnk[k - 1] * (n - k + 1) % M) * inv(k) % M;
}

void solve()
{
    int n;
    scanf("%d", &n);
    ll r = 0;
    forn (i, n + 1)
    {
        scanf("%lld", a + i);
        r += a[i];
    }
    r -= 1LL * (n + 1) * n / 2;
    int x = -1, y = -1;
    forn (i, n + 1) if (a[i] == r)
    {
        if (x == -1) x = i;
        else y = i;
    }
    y = n - y;
    x += y;
    init_cnk(cn, n + 1);
    init_cnk(cx, x);
    for (int k = 1; k <= n + 1; ++k)
    {
        printf("%lld\n", ((cn[k] - cx[k - 1]) % M + M) % M);
    }
    puts("");
}

/* <------------------------------------------------------------------------------------> */

// #define LOCAL
// #define FILE_NAME

int main()
{
    #if defined LOCAL
        freopen("input.txt", "r", stdin);
    #elif defined FILE_NAME
        freopen(FILE_NAME".in", "r", stdin);
        freopen(FILE_NAME".out", "w", stdout);
    #endif

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

    solve();

    return 0;
}


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

using namespace std;


int p, q, a, n;
double EPS = 1e-9;

int solve(double sum, int mul, int prev, int num) {
	if (num > n) return 0;
	if (mul > a) return 0;
	
	if (fabs(sum - (double)p/(double)q) < EPS) return 1;
	if (sum > (double)p/(double)q) return 0;
	
	int ret = 0;
	for (int i=prev; mul*i<=a; i++) {
		ret += solve(sum + 1.0/(double)i, mul * i, i, num + 1);
	}
	return ret;
}

int main() {
	while (1) {
		cin >> p >> q >> a >> n; if (p==0 && q==0 && a==0 && n==0) break;
		
		cout << solve(0.0, 1, 1, 0) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160