akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        char[] A = Console.ReadLine().ToCharArray();
        char[] B = Console.ReadLine().ToCharArray();
        char[] C = Console.ReadLine().ToCharArray();
        int turn = (A.Length + B.Length + C.Length);
        int a_t = 0;
        int b_t = 0;
        int c_t = 0;
        char next = 'a';
        for (int i = 0; i < turn; i++)
        {
            if (i + 1 == turn)
            {
                if (next == 'a') Console.WriteLine("A");
                else if (next == 'b') Console.WriteLine("B");
                else if (next == 'c') Console.WriteLine("C");
                return;
            }

            if (next == 'a')
            {
                if (a_t == A.Length) {
                    Console.WriteLine("A");
                    return;
                }
                next = A[a_t];
                a_t++;
            }
            else if (next == 'b')
            {
                if (b_t == B.Length)
                {
                    Console.WriteLine("B");
                    return;
                }
                next = B[b_t];
                b_t++;
            }
            else if (next == 'c')
            {
                if (c_t == C.Length)
                {
                    Console.WriteLine("C");
                    return;
                }
                next = C[c_t];
                c_t++;
            }
        }
    }
}



public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int Cin()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll k, n, a;
  in(k);
  if(k % 2 == 0 || k % 5 == 0){
    out(-1);
    memi;
    return 0;
  }
  a = 1;
  n = 7;
  rep(i, k * 10){
    if(n % k == 0){
      out(a);
      memi;
      return 0;
    }
    a++;
    n = n * 10 + 7;
    n = n % k;
  }
  out(-1);
  memi;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#define INF 1000000000;
using namespace std;
vector<pair<long long,long long>>juice;
int gcd(int a,int b){
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
int d[1000009] = { 0 };
int main() {
	int a = 0, counto=0;
	long long kk[100008],ace=0;
	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> kk[i];
		if (kk[i] < 0) {
			counto++;
		}
		kk[i] = abs(kk[i]);
		ace += kk[i];
	}
	sort(kk, kk + a);
	if (counto % 2 == 0) {
		cout << ace << endl;
		return 0;
	}
	else {
		cout << ace - (kk[0]*2) << endl;
		return 0;
	}
		return 0;
}

Measured memory_bytes: 1024
// 2017-08-06 ABC069 C - 4-adjacent
using System;
class Program
{
    static void Main(string[] args)
    {
        bool yes = false;
        int n = int.Parse(Console.ReadLine());
        string[] sa = Console.ReadLine().Split(' ');
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = int.Parse(sa[i]);
        }

        // 各要素ごとに
        // 4の倍数であればスコア2
        // 4の倍数ではないが2の倍数であればスコア1
        // 2の倍数でなければスコア0とする
        // スコアが要素数以上あれば成立？
        int score = 0;
        for (int i = 0; i < n; i++)
        {
            if (0 == (a[i] % 4))
            {
                score += 2;
            }
            else
            if (0 == (a[i] % 2))
            {
                score += 1;
            }
            else
            {
            }
        }

        // N が奇数の場合は スコア＞（N-1）で成立
        if( 0 != (n % 2)){
            score += 1;
        }
        if (score >= n) {
            yes = true;
        }

        if(yes)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 19552
import java.util.stream.LongStream;

public class Main {
	public static void main(String[] args) {
		java.util.Scanner s = new java.util.Scanner(System.in);
		System.out.println(Main.calc(s.nextInt(), s.nextInt(), s.nextInt(),
				s.nextInt(), s.nextInt()));
	}

	public static long calc(int a, int b, int c, int x, int y) {
		return LongStream.iterate(0, n -> n + 2).limit(Math.max(x, y) + 1)
				.reduce(
						Long.MAX_VALUE,
						(res, cn) -> Math.min(Math.max(a * (x - cn / 2), 0)
								+ Math.max(b * (y - cn / 2), 0) + c * cn, res));

	}

}

Measured memory_bytes: 28620
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,t;
  cin>>n>>x>>t;
  int ans=0;int cnt=x;
  for(int i=1;;++i){
    if(cnt>=n){
      ans=i*t;
      break;
    }
    cnt+=x;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3616
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
a_cut=0
c_cut=0
ans=0
for b_cut in B:
    while a_cut<N and A[a_cut]<b_cut:
        a_cut+=1
    while c_cut<N and C[c_cut]<=b_cut:
        c_cut+=1
    ans+=a_cut*(N-c_cut)
print(ans)

Measured memory_bytes: 22720
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x){
    S[++top] = x;
}
int pop(){
    top--;
    return S[top + 1];
}

int main(){
    int a, b;
    top = 0;
    char s[100];
    while(scanf("%s", s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push( a + b);
        }else if(s[0] == '-'){
            b = pop();
            a = pop();
            push( a - b);
        }else if(s[0] == '*'){
            a = pop();
            b = pop();
            push( a * b);
        }else{
            push(atoi(s));
        }
    }
    printf("%d\n", pop());
    return 0;
}




Measured memory_bytes: 2768
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

struct UnionFind {
    vector<int> par, rank;

    UnionFind(int N) : par(N), rank(N) {
        rep(i, N) par[i] = i, rank[i] = 0;
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (rank[rx] < rank[ry]) {
            par[rx] = ry;
        }
        else {
            par[ry] = rx;
            if (rank[rx] == rank[ry]) rank[rx]++;
        }
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    vector<vector<int>> G(N);
    vector<vector<ll>> d(N + 1, vector<ll>(N + 1, INF));
    rep(i, N) d[i][i] = 0;

    rep(i, N) cin >> S[i];

    UnionFind tree(N);
    rep(i, N) {
        rep(j, S[i].size()) {
            if (S[i][j] == '1') {
                G[i].push_back(j);
                d[i][j] = 1;
            }
        }
    }

    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                chmin(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    int nax = -1;
    int index;
    rep(i, N) {
        rep(j, N) {
            if (i == j) continue;
            if (nax < d[i][j]) {
                index = i;
                nax = d[i][j];
            }
        }
    }

    vector<vector<int>> dis(N + 1);
    rep(i, N) {
        if (index == i) continue;
        dis[d[index][i]].push_back(i);
    }

    bool flag = true;
    rep(i, N) {
        rep(j, dis[i].size()) {
            repd(k, j + 1, dis[i].size()) {
                if (S[dis[i][j]][dis[i][k]] == '1') flag = false;
            }
        }
    }

/*
    rep(i, N) {
        repd(j, 1, dis[i].size()) {
            tree.unite(dis[i][j - 1], dis[i][j]);
        }
    }

*/
    cout << (flag ? nax + 1 : -1) << endl;
    return 0;
}

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

int main(){
    int n,a,c=0,m=INT_MAX;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        while(a%2==0){
            a>>=1;
            c++;
        }
        m=min(m,c);
        c=0;
    }
    cout<<m<<endl;
    return 0;
}

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

const int mn=1e5+7;
int a[mn],x[mn];
long long sum;

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",a+i);
	for(int i=1;i<n;++i) sum+=a[i]*2*(i%2==1?1:-1);
	x[1]=(sum+2*a[n])/2;
	printf("%d ",x[1]);
	for(int i=2;i<=n;++i) {
		x[i]=2*a[i-1]-x[i-1];
		printf("%d ",x[i]);
	}
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N, M, X, Y;

int main()
{
    cin >> N >> M >> X >> Y;
    vector<int> x(N), y(M);
    cin >> x >> y;

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    if (max(x.back(), X) < min(y.front(), Y)) cout << "No ";
    cout << "War" << endl;
}


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

score.sort(reverse=True)
Alice = []
Bob = []
for i in range(len(score)):
  if i%2==0:
    Alice.append(score[i])
  else:
    Bob.append(score[i])
    
print(sum(Alice)-sum(Bob))


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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] tmp = Console.ReadLine().Split(' ');
            int n = int.Parse(tmp[0]);
            int k = int.Parse(tmp[1]);

            var array = new int[k];
            int count = n;

            for(int i = 0; i < k; i++)
            {
                array[i] = 0;
            }

            for(int i = 1; i <= n / k + 1; i++)
            {
                for(int j = 0; j < k ; j++)
                {
                    if (count > 0)
                    {
                        array[j]++;
                        count--;
                    }
                }
            }

            Console.WriteLine(array[0] - array[k-1]);

        }
    }
}

Measured memory_bytes: 11092
a, b, c, d = input().split()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
def m():
        if a>=0 and d<=0:
            max=a*d
            print(max)
        elif a>=0 and c>=0:
            max=b*d
            print(max)
        elif b<=0 and c>=0:
            max=b*c
            print(max)
        elif b<=0 and d<=0:
            max=a*c
            print(max)
        elif a<=0 and b>=0 and c<=0 and d>=0:
            if a*c>=b*d:
                max=a*c
                print(max)
            else:
                max=b*d
                print(max)
        elif a>=0 and c<=0 and d>=0:
            max=b*d
            print(max)
        elif b<=0 and c<=0 and d>=0:
            max=a*c
            print(max)
        elif a<=0 and b>=0 and c>=0:
            max=b*d
            print(max)
        elif a<=0 and b>=0 and d<=0:
            max=a*c
            print(max)

m()

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

int main(){
  int a, b, k;cin >> a >> b >> k;
  int n = 0, m;
  for(int i = min(a, b); i >= 1; i--){
    if(a%i == 0 && b%i == 0){
      n++;
      m = i;
      if(n == k) break;
    }
  }
  cout << m << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll y[101010];
ll a[101010];
ll b[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};
ll sr,sc;
int main() {
    cin>>R>>G>>B>>N;
    rep(i,0,N+1)rep(j,0,N+1){
        if(N-R*i-G*j>=0){
            if((N-R*i-G*j)%B==0)ans++;
        }
        
    }
    cout<<ans<<endl;;
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  double d;
  double a;
  
  for(int i=0;i<n;i++){
    cin >> a;
    d += 1 / a;
  }
  
  cout << 1 / d << endl;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  a -= c;
  cout << a/(b+c) << endl;
  return 0;
}


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

int main() {
  string S , T;
  cin >> S >> T;
  int N = S.size();
  
  string ans = "Yes";
  for (int i = 0; i < N; i++) {
    if (T.at(i) != S.at(i)) {
      ans = "No";
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int X,A,B;
  cin >> X >> A >> B;
  if(-A+B<=0) {
    cout << "delicious" << endl;
  } else if(-A+B<=X) {
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
  return 0;
}

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

int minNum(int, int);

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

  cout<<minNum(N, K);

  return 0;
}

int minNum(int N, int K)
{
  int count = 1;
  for(int i=0; i<N; i++) {
    if(count<K)
      count *= 2;
    else
      count += K;
  }
  return count;
}


Measured memory_bytes: 256
//This code is written by Shammi Anand
#include<bits/stdc++.h>
using namespace std;

#define ll              long long
#define Max(a,b,c)      max((a),max((b),(c))
#define Min(a,b,c)      min(a,min(b,c))
#define pb              push_back
#define mp              make_pair
#define f               first
#define s               second
#define mod             1000000007
#define nl              "\n"
#define w(x)            int x; cin>>x; while(x--)


void max_self(ll& a, ll b) {
	a = max(a, b);
}
void min_self(ll& a, ll b) {
	a = min(a, b);
}

const ll INF = 1e18L + 5;

int main() {
	int n, W;
	scanf("%d%d", &n, &W);
	vector<int> weight(n), value(n);
	for (int i = 0; i < n; ++i) {
		scanf("%d%d", &weight[i], &value[i]);
	}
	int sum_value = 0;
	for (int x : value) {
		sum_value += x;
	}
	vector<ll> dp(sum_value + 1, INF); // 0 ... W
	dp[0] = 0;
	// dp[i] - the minimum total weight of items with total value exactly i
	for (int item = 0; item < n; ++item) {
		for (int value_already = sum_value - value[item]; value_already >= 0; --value_already) {
			//~ for(int weight_already = 0; weight_already <= W - weight; ++weight_already) {
			min_self(dp[value_already + value[item]], dp[value_already] + weight[item]);
		}
	}
	ll answer = 0;
	for (int i = 0; i <= sum_value; ++i) {
		if (dp[i] <= W) {
			answer = max(answer, (ll) i);
		}
		//~ min_self(answer, dp[i]);
	}
	printf("%lld\n", answer);
}

Measured memory_bytes: 3988
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e9;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin >> n >> a >> b;
    if (a > b) PRINT(0);
    else if (n == 1){
        if (a == b) PRINT(1);
        else PRINT(0);
    }
    else{
        PRINT(b*(n-1)+a-(a*(n-1)+b)+1);
    }
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (a,b) =  readLine()!!.split(' ').map { it.toInt() }

    var aa = Math.floor(a /0.08)
    while (aa * 0.08 < a) aa++

    if (Math.floor(aa*0.1).toInt() == b) println(aa.toInt())
    else {
        var bb = Math.floor(b /0.1)
        while (bb * 0.1 < b) bb++
        if (Math.floor(bb*0.08).toInt() == a) println(bb.toInt())
        else println(-1)
    }
}


Measured memory_bytes: 38256
#include <bits/stdc++.h>
        using namespace std;
        #define int long long int
        #define pb push_back
        #define mk make_pair
        #define ft first
        #define sc second
        #define ppb pop_back
        #define sz size
        #define forn(i,a,n) for(i=a;i<n;i++)
        #define M 998244353 
        #define inf 2e18

        signed main() {
 
     
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        int a,b,c,k;
        cin>>a>>b>>c>>k;
        int sum=0;
        
        sum = min(a,k);
        k = max(k-a,0ll);
        k = max(k-b,0ll); 
        sum+=(-min(k,c));
        cout<<sum;
        return 0;
    }

Measured memory_bytes: 3648
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

int main() {
  // cout << fixed << setprecision(10);

  int K, X;
  cin >> K >> X;
  FOR(n, X-K+1, X+K-1) {
    cout << (n > X-K+1? " ": "") << n;
  }
  cout << endl;
  return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)  	
typedef long long ll;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f;
const int maxn = 1e6+5;
const double pi = acos(-1.0);
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }
ll read()     //输入外挂
{
    ll res = 0, ch, flag = 0;
    if ((ch = getchar()) == '-')
        flag = 1;
    else if (ch >= '0' && ch <= '9')
        res = ch - '0';
    while ((ch = getchar()) >= '0' && ch <= '9')
        res = res * 10 + ch - '0';
    return flag ? -res : res;
}

int a[maxn];
int d[maxn];

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    if (n == 0)
    {
        printf("0\n");
        return 0;
    }
    d[1] = a[1];  
    int len = 1;
    for (int i = 2; i <= n; i++)
    {
        if (a[i] <= d[len]) d[++len] = a[i];   
        else 
        {
            int j = upper_bound(d + 1, d + len + 1, a[i]) - d;  
            d[j] = a[i];
        }
    }
    cout << len << endl;
    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 2000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define dum3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl

//ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

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

    int mi = INF;
    for (int i = 1; i <= sqrt(N); i++) {
        if (N%i == 0) {
            string A = to_string(i);
            string B = to_string(N / i);
            mi = (mi, B.size());
        }
    }
    cout << mi << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LL long long int
#define vi vector<int>
#define vl vector<LL>
#define pb push_back
#define all(V) V.begin(),V.end()
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%I64d",&x)
#define pii pair<int,int>
#define cmax(a,b) ((a) = (a) > (b) ? (a) : (b))
#define cmin(a,b) ((a) = (a) < (b) ? (a) : (b))
#define debug(x)  cerr << #x << " = " << x << endl
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};

void solve(){
    int n; sci(n);
    vi a(n); for(int &x : a) sci(x);
    sort(all(a));
    int ret = INT_MAX;
    for(int i = -100; i <= 100; i++){
        int tp = 0;
        for(int x : a) tp += (i - x) * (i - x);
        cmin(ret,tp);
    }
    cout << ret << endl;
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("Local.in","r",stdin);
    freopen("ans.out","w",stdout);
    #endif
    solve();
    return 0;
}

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


struct Node {
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
    Node *cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void init() {
    nil = (Node*)malloc(sizeof(Node));
    nil->next=nil;
    nil->prev=nil;
}

void printList() {
    Node *cur = nil->next;
    int isf = 0;
    while(1) {
        if(cur==nil) break;
        if(isf++>0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t) {
    if(t==nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev=x;
    nil->next=x;
    x->prev=nil;
}

int main(){
    int key, n, i;
    int size = 0;
    char com[20];
    scanf("%d", &n);
    init();
    for(int i=0; i<n; ++i) {
        scanf("%s%d", com, &key);
        if(com[0]=='i') {insert(key); size++;}
        else if(com[0]=='d') {
            if(strlen(com)>6) {
                if(com[6]=='F') deleteFirst();
                else if(com[6]=='L') deleteLast();
            } else {
                deleteKey(key);
            }
            size--;
        }
    }
    
    printList();
    
    return 0;
}


Measured memory_bytes: 34380
x,k,d = gets.split.map(&:to_i)
x = x.abs

if x / d < k
  if (k - (x / d)) % 2 == 0
    puts (x - (x / d) * d).abs
  else
    puts ((x - (x / d) * d).abs - d).abs
  end
else
  puts (x - k * d).abs
end


Measured memory_bytes: 14196
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int n, m;
    cin >> n >> m;
    vector<int> vec(n);
    bool flg=true;
    int sum=0;
    rep(i, n){
        int a;
        cin >> vec.at(i);
        sum += vec.at(i);
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    double point = sum * (1.0 / (4.0 * m));
    rep(i, m){
        if(vec.at(i) < point) flg=false;
    }

    if(flg) cout << "Yes";
    else cout << "No";

}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int q = sc.nextInt();
		Deque<Process> deque = new ArrayDeque<>();
		String s;
		int a;
		for (int i=0; i<n; i++) {
			s = sc.next();
			a = sc.nextInt();
			deque.addLast(new Process(s,a));
		}
		int time = 0;
		int temp;
		while (deque.size()!=0) {
			temp = Math.min(q,deque.getFirst().getTime());
			deque.getFirst().time -= temp;
			time += temp;
			if (deque.getFirst().getTime() > 0) {
				deque.addLast(deque.removeFirst());
			}
			else {out.println(deque.removeFirst().getName()+" "+time);}
		}
	}
}

class Process {
	String name;
	int time;
	public Process (String n, int t) {
		this.name = n;
		this.time = t;
	}
	public String getName () {
		return this.name;
	}
	public int getTime () {
		return this.time;
	}
}


Measured memory_bytes: 73472
{-# LANGUAGE BangPatterns #-}

import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import Data.Bits
import Control.Monad
import Control.Monad.ST

swap :: (VUM.Unbox a) => (a -> Bool) -> VUM.MVector s a -> ST s Int
swap f vec = loopl 0 (VUM.length vec - 1)
  where
    loopl x y | x > y = return x
    loopl x y = do
      vx <- VUM.unsafeRead vec x
      if (f vx) then
        loopl (x+1) y
      else
        loopr x y vx
    loopr x y vx | x > y = return x
    loopr x y vx = do
      vy <- VUM.unsafeRead vec y
      if not (f vy) then
        loopr x (y-1) vx
      else do
        VUM.unsafeWrite vec x vy
        VUM.unsafeWrite vec y vx
        loopl (x+1) (y-1)

sums :: Int -> VU.Vector Int -> ST s (VUM.MVector s Int)
sums n as = do
  vec <- VUM.new $ (n * (n + 1)) `div` 2
  let loop !i !x !y !prevSum
        | y >= n = if x >= n then return () else loop i (x+1) (x+1) 0
      loop i x y prevSum =
        VUM.unsafeWrite vec i newSum >> loop (i+1) x (y+1) newSum
        where
          ay = as VU.! y
          newSum = prevSum + ay
  loop 0 0 0 0
  return vec
  

query :: Int -> Int -> VU.Vector Int -> Int
query n k as = runST $ do
  svec <- sums n as
  loop svec 39 0
  where
    loop !svec (-1) !acc = return acc
    loop !svec !lev !acc = do
      t <- swap (`testBit` lev) svec
      if k <= t then
        loop (VUM.take t svec) (lev - 1) (acc `setBit` lev)
      else
        loop svec (lev - 1) acc

main = do
  [n,k] <- map read . words <$> getLine
  as <- VU.unfoldrN n (BS.readInt . BS.dropWhile (==' ')) <$> BS.getLine
  putStrLn $ show $ query n k as


Measured memory_bytes: 4732
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
    int n,k,a,b,c,d=1,ans=0;
    cin>>n>>k;
    a=n;
    for(int i=0;a>0;i++){
    	b=a%k;
    	a=a/k;
    	ans=ans+b*d;
    	c++;
    	d=d*10;
    }
    

    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string S;
    cin >> S;
    if("RRR"== S){
        cout << "3" <<endl;
    }else if("RRS" == S){
        cout << "2" << endl;
    }else if("SRR" == S){
        cout << "2" << endl;
    }else if("SSS" == S){
        cout << "0" << endl;
    }else{
        cout << "1" << endl;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
typedef pair < int, int > pii;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int n, fa[maxn];
map < pii, int > Map;
queue < pii > q;
set < int > s[maxn];

inline int find(reg int x) { return (x == fa[x]) ? x : (fa[x] = find(fa[x])); }

inline void init(reg int x, reg int y) {
    s[x].insert(y), s[y].insert(x);
    Map[pii(x, y)]++, Map[pii(y, x)]++;
    if (Map[pii(x, y)] == 2) q.push(pii(x, y));
}

inline void solve() {
    while (!q.empty()) {
        reg int u = q.front().first, v = q.front().second; q.pop();
        u = find(u), v = find(v), s[u].erase(v), s[v].erase(u);
        if (s[u].size() < s[v].size()) swap(u, v);
        for (auto it : s[v]) {
            Map[pii(it, v)] = Map[pii(v, it)] = 0,
            s[it].erase(v), s[it].insert(u);
            Map[pii(it, u)]++, Map[pii(u, it)]++;
            if (Map[pii(it, u)] == 2) q.push(pii(it, u));
            s[u].insert(it);
        }
        fa[v] = u, s[v].clear();
    }
}

int main() {
    ios::sync_with_stdio(false);
    n = read(); reg int u, v;
    for (reg int i = 1; i <= 2 * n - 2; i++) u = read(), v = read(), init(u, v);
    for (reg int i = 1; i <= n; i++) fa[i] = i;
    solve(); reg int ans = 0;
    for (reg int i = 1; i <= n; i++) ans += fa[i] == i;
    if (ans == 1) puts("YES");
    else puts("NO");
    return 0;
}


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

int gcd(int n, int m) {
	if (n < m)
		swap(n, m);
	if (n % m == 0)
		return m;
	else
		return gcd(m, n % m);
}

int main() {
	int K, res = 0;
	cin >> K;
	for (int a = 1; a <= K; a++)
		for (int b = 1; b <= K; b++)
			for (int c = 1; c <= K; c++)
				res += gcd(a, gcd(b, c));
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3656
w=int(input())
list1=list(map(int,input().split()))
list2=list(map(int,input().split()))
list3=[0]*w
list4=[0]*w
tmp=0
for i in range(w):
  for j in range(0,i+1):
    list3[i]+=list1[j]
  for k in range(i,w):
    list4[i]+=list2[k]
for i in range(w):
  if list3[i]+list4[i]>tmp:
    tmp=list3[i]+list4[i]
print(tmp)

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

using namespace std;


int main(){
	int n;
	cin >> n;
	int ar[n];
	cin >> ar[0];
	long long int ans = 0;
	for(int i = 1; i < n; i++){
		cin >> ar[i];
		if(ar[i] < ar[i - 1]){
			ans += abs(ar[i] - ar[i - 1]);
			ar[i] = ar[i - 1];
		}

	}
	cout << ans << endl;
}


Measured memory_bytes: 4400
A, B, C, D  =map(int,input().split())
 
if B<=D:
  if B<=C:
    print(0)
  elif (A<=C)and(C<B):
    print(B-C)
  else:
    print(B-A)
elif (A<=D)and(D<B):
  if A<=C:
    print(D-C)
  else:
    print(D-A)
else:
  print(0)

Measured memory_bytes: 3064
def BubbleSort(A,B,N):
    for i in range(N):
        for j in range(N-1,i,-1):
            if B[j] < B[j-1]:
                A[j],A[j-1]=A[j-1],A[j]
                B[j],B[j-1]=B[j-1],B[j]

def SelectionSort(A,B,N):
    for i in range(N):
        minj = i
        for j in range(i,N):
            if B[j] < B[minj]:
                minj = j
        A[i],A[minj]=A[minj],A[i]
        B[i],B[minj]=B[minj],B[i]

N = int(input())
A = list(input().split())
A_BubbleSort = A[:]
A_SelectionSort = A[:]
B=[0 for i in range(N)]
for i in range(N):
    B[i] = int(A[i][1])
B_BubbleSort = B[:]
B_SelectionSort = B[:]
BubbleSort(A_BubbleSort,B_BubbleSort,N)
SelectionSort(A_SelectionSort,B_SelectionSort,N)
print(*A_BubbleSort)
print("Stable")
print(*A_SelectionSort)
if A_BubbleSort == A_SelectionSort:
    print("Stable")
else:
    print("Not stable")


Measured memory_bytes: 5616
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define REV(i, a) for (int i = (a); i >= 0; --i)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) cerr << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int H, W;
int ans = INF;

void solve(int th, int tw) {
    REPS(i, th - 1) {
        int a1 = i * tw;
        int h = th - i;
        if (h % 2 == 0) {
            ans = min(ans, abs(a1 - h / 2 * tw));
        } else if (tw % 2 == 0) {
            ans = min(ans, abs(a1 - tw / 2 * h));
        } else {
            int a2 = max(h, tw) / 2 * min(h, tw);
            int a3 = (max(h, tw) / 2 + 1) * min(h, tw);
            ans = min(ans, abs(max(a1, a3) - min(a1, a2)));
        }
        DUMP(h);
        DUMP(ans);
    }
}

signed main() {
    cin >> H >> W;

    solve(H, W);
    solve(W, H);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16
 
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U; 
    // int a,b,c;
    cin>>n;
 if(n%1000) cout<<1000-(n%1000);
  else cout<<"0";
}
 
 
signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3640
//
// Created by agatsuma on 19/06/16.
//
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>

using ll = long long;

using std::cout;
using std::cin;
using std::endl;

int main() {
    int N;
    int L;
    cin >> N >> L;
    std::vector<int> v(N);

    for (int i = 0; i < N; i++) {
        v[i] = L + i;
    }

    std::sort(v.begin(), v.end(),[](int l,int r){return std::abs(l)<abs(r);});

    int ans = 0;

    for (int j = 1; j < N; ++j) {
        ans += v[j];
    }


    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 888
package main

import "fmt"

func main(){
	var a,b,c int
	fmt.Scan(&a,&b,&c)
	if a == b {
		if a == c {
			fmt.Println("No")
		} else {
			fmt.Println("Yes")
		}
	} else {
		if a == c {
			fmt.Println("Yes")
		} else if b == c {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 512
package main

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

func main() {
	sc := NewScanner(os.Stdin)
	N := sc.NextInt()
	M := sc.NextInt()
	v := make([]int, M)
	for i := 0; i < M; i++ {
		v[i] = sc.NextInt()
	}
	sv := sort.IntSlice(v)
	sort.Sort(sv)
	d := make([]int, M-1)
	for i := 0; i < M-1; i++ {
		d[i] = sv[i+1] - sv[i]
	}
	sd := sort.IntSlice(d)
	sort.Sort(sd)
	ans := 0
	for i := 0; i < M-N; i++ {
		ans += sd[i]
	}
	fmt.Println(ans)
}

func lcm(x, y int) int {
	x, y = max(x, y), min(x, y)
	if y == 0 {
		return x
	}
	return lcm(y, x%y)
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


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



int main() {
    while(true){
        int h,w;
        cin>>h>>w;
        if(h==0) break;
        for(int i=0; i<h; i++){
            for(int j=0;j<w; j++){
                cout<<'#';
            }
            cout<<endl;
            
        }
        cout<<endl;
    }
    



  
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=100010;
const ll oo=1e18;
int n;
ll ans=0,f[N][3];
int a[N],tot[N];
bool b[N];
int main(){
//	freopen("in.txt","r",stdin);
	char c;
	scanf("%d",&n);
	b[1]=1;
	for(int i=1;i<=n;i++){
		tot[i]=tot[i-1];
		if(i>=2){
			scanf(" %c",&c);
			if(c=='+') b[i]=1;
			else tot[i]++;
		}
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++){
			if(b[i]){
				f[i][0]=max(f[i-1][0],max(f[i-1][1],f[i-1][2]))+a[i];
				f[i][1]=max(f[i-1][1]-a[i],f[i-1][2]+a[i]);
				f[i][2]=f[i-1][2]+a[i];
			}else{
				f[i][0]=max(f[i-1][0],max(f[i-1][1],f[i-1][2]))-a[i];
				f[i][1]=max(f[i-1][0]-a[i],max(f[i-1][1]+a[i],f[i-1][2]-a[i]));
				f[i][2]=max(f[i-1][1]+a[i],f[i-1][2]-a[i]);
			}
			if(tot[i]<2) f[i][2]=-oo;
			if(tot[i]<1) f[i][1]=-oo;
	}
//	for(int i=1;i<=n;i++){
//		cout<<f[i][0]<<" ";
//	}
//	cout<<endl;
//	for(int i=1;i<=n;i++){
//		cout<<f[i][1]<<" ";
//	}
//	cout<<endl;
//	for(int i=1;i<=n;i++){
//		cout<<f[i][2]<<" ";
//	}
//	cout<<endl;
	ans=max(f[n][0],max(f[n][1],f[n][2]));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3456
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define vi vector<ll>
#define pii pair<ll,ll>
#define bc __builtin_popcountll
#define vvi vector<vi> 
#define vpii vector<pair<ll,ll>>
#define mll unordered_map<ll,ll>
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define fo(i,a,b) for(i=a;i<=b;i++)
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()-->returns an iterator to the k-th largest element (counting from zero)
//X.order_of_key()-->the number of items in a set that are strictly smaller than our item.
struct cmp
{
	bool operator() (ll a,ll b){
		return (a>b);
	}
};
ll mod=1000000007;
const ll N=100005;
int main()
{
fast;
    ll x;
    cin>>x;
    if(x==1)
        cout<<0;
    else
        cout<<1;
    return 0;
}

Measured memory_bytes: 3648