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

int main()
{
  ll i=1,cnt=1;
  string str,s1,s2;
  cin>>str;
  s1=to_string(str[0]);
  while(i<str.size())
  {
    s2=to_string(str[i]);
    if(s1==s2)
    {
      i++;
      if(i==str.size())
      	break;
      s2.push_back(str[i]);
    }  
    cnt++;
    s1=s2;
    i++;
  }  
  cout<<cnt;
  return 0;
}

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

int digits(long long n)
{
  if(n == 0)
    return 0;
  else
    return 1 + digits(n / 10);
}
int main()
{
  long long n;
  int k;
  scanf("%lld%d", &n, &k);
  int ans = 0;
  while(n > 0)
  {
    n /= k;
    ans++;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
x1, x2, x3, x4, x5 = map(int, input().split())

if x1 == 0:
    print(1)
elif x2 == 0:
    print(2)
elif x3 == 0:
    print(3)
elif x4 == 0:
    print(4)
else:
    print(5)


Measured memory_bytes: 9164
#include <algorithm>
#include <iostream>
#include <stack>
#include <set>
#include <cstdio>
#include <cstring>

using namespace std;

int ans[100005];
int res[100005];
int kun[100005];

int a[200005][2]={0};

int main(){
    int n,m;
    scanf("%d%d",&n,&m);


    int ca=0,cb=0;
    for(int i=0;i<m;i++){
        int aa,bb;
        scanf("%d%d",&aa,&bb);
        if(aa==1){
            a[bb][0]=1;
        }
        if(bb==n){
            a[aa][1]=1;
        }
    }
    int f=1;
    for(int i=0;i<n;i++){
        if(a[i][0]==1&&a[i][1]==1){
            cout<<"POSSIBLE";
            f=0;
            break;
        }

    }
    if(f){
        cout<<"IMPOSSIBLE";
    }
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

# define fr(a,b) for(int i = a; i < b; i++)
# define rep(i,a,b) for(int i = a; i < b; i++)

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

void solve(){

    ull A,B,x;
    cin >> A >> B >> x;
    ull a = A/x;
    ull b = B/x;
    if(A%x==0) {
        cout <<b-a+1;
        return;

    }
    cout << b-a;
    return;

}

int main(){
	fast
	int tc=1;
	//cin >> t;
	while(tc--){
             solve();
    }

	R 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int n, k;
	cin >> n >> k;
	
	vector<ll> v(n);
	for(int i = 0; i < n; i++)
		cin >> v[i];
	
	sort(v.rbegin(), v.rend());
	
	ll ans = 0;
	
	for(int i = 0; i < n; i++){
		if(i >= k)
			ans += v[i];
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>

using namespace std;
int N;

int main() {
  cin >> N;
  long sum = 0;
  vector<long> A(N);

  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }

  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    A.at(i) -= (i+1);
  }

  sort(A.begin(), A.end());

  long ave1 = A.at(N/2);
  long ave2 = A.at(N/2-1);

  long sum1 = 0;
  long sum2 = 0;
  for (int i=0; i<N; i++) {
    sum1 += abs(A.at(i) - ave1);
    sum2 += abs(A.at(i) - ave2);
  }
  cout << min(sum1, sum2) << endl;
}

Measured memory_bytes: 1792
using System;

public class Hello
{
    public static void Main()
    {
        var g = Console.ReadLine();
        var s = g.Split(' ');
        var a = int.Parse(s[0]);
        var b = int.Parse(s[1]);
        var c = int.Parse(s[2]);

        int p = 0;
        if (a >= b)
        {
            if (a >= c)
            {
                p = c + b;
            }
            else
                p = a + b;
        }
        else if (b >= c)
        {
            p = c + a;
        }
        else
            p = a + b;

        Console.WriteLine(p);
    }
}

Measured memory_bytes: 13140
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {
    int X, P;
    cin >> X >> P;
    double p = P / 100.0;

    auto f = [&](int x) {
        return x / (2 * p);
    };

    if (X % 2 == 0) {
        cout << f(X) << endl;
    } else {
        cout << 1 + f(X - 1)*p + f(X + 1)*(1 - p) << endl;
    }
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int a,b,k,c;
  cin>>a>>b>>k;
  rep(i,k){
    c=i+a;
    if(c>b) break;
    cout<<c<<endl;
  }
  rep(i,k){
    int d=b-k+i+1;
    if(d<=c) continue;
    cout<<d<<endl;
  }
  return 0;
}



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


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

    ll x = min(b-1, n);
    cout << ((a*x)/b - a*(x/b)) << endl;

    return 0;
}

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

const int N = 300011;
typedef long long intl;

int s[N], d[N];
int e[N];
pair <int, int> p[N];

int ans[N];

int main()
{
        ios :: sync_with_stdio(false);
        int n, m;
        intl t;
        cin >> n >> m >> t;
        for(int i = 0; i < n; i ++)
        {
                char c;
                cin >> s[i] >> c;
                d[i] = (c == '2');
                p[i] = {s[i], i};
        }
        intl shift = 0;
        for(int i = 0; i < n; i ++)
        {
                if(d[i] == 1)
                {
                        e[i] = ((s[i] - t) % m + m) % m;
                        shift += (s[i] - t - e[i]) / m;
                }
                else
                {
                        e[i] = (s[i] + t) % m;
                        shift += (s[i] + t - e[i]) / m;
                }
                shift = (shift % n + n) % n;
        }

        sort(p, p + n);
        sort(e, e + n);
        for(int i = 0; i < n; i ++)
                ans[p[i].second] = e[(i + shift) % n];
        for(int i = 0; i < n; i ++)
                cout << ans[i] << '\n';

        return 0;
}


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

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            string st = Console.ReadLine();
            bool n = false;
            bool w = false;
            bool s = false;
            bool e = false;
            for (int i = 0; i < st.Length; i++)
            {
                switch (st[i])
                {
                    case 'N':
                        n = true;
                        break;
                    case 'W':
                        w = true;
                        break;
                    case 'S':
                        s = true;
                        break;
                    case 'E':
                        e = true;
                        break;
                    default:
                        break;
                }
            }
            if (n == s && e == w) Console.WriteLine("Yes");
            else Console.WriteLine("No");

        }
    }
}


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

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

	int			n;
	/* int			max; */
	/* int			second_max; */
	cin >> n;
	vector<int>	A(n);
	vector<int>	B;

	/* rep(i, n) */
	/* 	cin >> A.at(i); */
	for (int &a : A)
		cin >> a;
	B = A;
	sort(B.rbegin(), B.rend());
	/* max = B.at(0); */
	/* second_max = B.at(1); */
	for (int a : A)
	/* { */
		cout << (a != B.at(0) ? B.at(0) : B.at(1)) << "\n";
		/* if (a != B.at(0)) */
		/* 	cout << B.at(0) << endl; */
		/* else */
		/* 	cout << B.at(1) << endl; */
	/* } */
}


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>

using namespace std;

#define ll long long
#define rep(i, n) for (i = 0; i < n; i++)

int main()
{
  ll N, K;
  cin >> N >> K;
  ll ans = 0;
  for (ll i = K; i <= N + 1; i++)
  {
    ans += (N - i + 1) * i + 1;
    ans %= 1000000007;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
# coding=utf-8

N = int(input())
dp = 1
asum = 0
for a in input().split(" "):
    x = int(a)
    asum += x
    dp = dp|(dp<<x)

for i in range((asum+1)//2, asum+1):
    if (dp>>i)&1:
        print(i)
        break


Measured memory_bytes: 5360
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

using namespace std;
typedef long long int ll;
typedef pair<int,int> P;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;


int main(){
	int N, L[205], ans=0;

	cin >> N;
	rep(i,2*N) cin >> L[i];
	sort(L, L+2*N);

	rep(i,N){
		ans += L[2*i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int getSum(int n){
    int num = n;
    int sum = 0;
    while(num > 0){
        sum += num % 10;
        num /= 10;
        
    }
    return sum;
}

int main(){
   int N;
   cin >> N;
    int A,B;
    int s = 0;
    int min = 10000;
   for(int i=1; i < N; i++){
       A = i;
       B = N - i;
       s = getSum(A) + getSum(B);
       if(s < min) min = s;

   }

   cout << min;

  return 0;
    

}

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

using namespace std;



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

    int n,h,temp=0,jmp=0,ans=0;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>h;
        //cout<<temp<<" ";
        if(h<=temp)
        {
            jmp++;
        }
        else
        {
            ans=max(ans,jmp);
            jmp=0;
        }
        temp=h;
        ans=max(ans,jmp);
        //cout<<jmp<<" "<<ans<<" "<<temp<<endl;


    }
    cout<<ans;

}


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

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

static const int INF = 1E8;
int n, k;
vector<pair<int, int> > g[111];
int s, t, e;
int q;
int d[111];
pair<int, int> tmp;

int main()
{
  while(cin >> n >> k, n){
    rep(i, n) g[i].clear();
    rep(i, k){
      cin >> q >> s >> t;
      s -= 1;
      t -= 1;
      if(q == 0){
        rep(i, n) d[i] = INF;
        d[s] = 0;
        priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;
        que.push(make_pair(0, s));
        while(!que.empty()){
          pair<int, int> top = que.top();  que.pop();
          int cost = top.first;
          int v = top.second;
          if(d[v] < cost) continue;
          if(v == t) break;
          rep(i, g[v].size()){
            if(d[g[v][i].first] > d[v] + g[v][i].second){
              d[g[v][i].first] = d[v] + g[v][i].second;
              que.push(make_pair(d[g[v][i].first], g[v][i].first));
            }
          }
        }
        if(d[t] < INF) cout << d[t] << endl;
        else cout << -1 << endl;
      }
      else{
        cin >> e;
        g[s].push_back(make_pair(t, e));
        g[t].push_back(make_pair(s, e));
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1232
using System;
using System.Collections.Generic;
class Program
    {
    	static void Main(string[] args)
    	{
            int n = int.Parse(Console.ReadLine());
            int[] x = new int[n], y = new int[n];
            for (int i=0; i<n; i++)
            {
                string[] s1 = Console.ReadLine().Split(' ');
                x[i] = int.Parse(s1[0]);
                y[i] = int.Parse(s1[1]);
            }

            int countMax = 0;
            
            for (int i=0; i<n-1; i++)
            {
                for (int j=i+1; j<n; j++)
                {
                    int p = x[j] - x[i], q = y[j] - y[i];
                    int count = 0;
                    for (int k=0; k<n; k++)
                    {
                        for (int l=0; l<n; l++)
                        {
                            if (k == l) continue;
                            if (x[l] - x[k] == p && y[l] - y[k] == q)
                            {
                                count++;
                            }
                        }
                    }
                    countMax = Math.Max(countMax, count);
                }
            }
            int ans = n - countMax;
            Console.WriteLine(ans);
            
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
ull x,ans;
 
int main(){
	cin>>x;
	
	ull n=100;
	
	while(n<x){
		n*=1.01;
		ans++;
	}
	
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

std::vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){   
        IsPrime.resize(max+1,true);
    }
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i)
        if(IsPrime[i])
            for(size_t j=2; i*j<=max; ++j)
                IsPrime[i*j] = false;
}

signed main() {
    sieve(55555);
    vector<int> v;
    rep(i,55556){
        if(i<10) continue;
        if(IsPrime[i]) {
            if(i%5==1) v.push_back(i);
        }
    }
    int N; cin >> N;
    rep(i,N){
        cout << v[i] << (i==N-1?"":" ");
    }
    cout << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
a = [tuple(map(int, input().split())) for _ in range(N)]
#print(a)
table = [0] * N
for k in range(N): table[k] = min(abs(a[k][0]), abs(a[k][1])) * a[k][2]
tableudi = [10 ** 12 for _ in range((1 << N) * N)]
tablelri = [10 ** 12 for _ in range((1 << N) * N)]
for i in range(1 << N):
  for j in range(N):
    if i & (1 << j):
      for k in range(N):
        ud = min(abs(a[k][0] - a[j][0]) * a[k][2], table[k])
        lr = min(abs(a[k][1] - a[j][1]) * a[k][2], table[k])
        tableudi[i * N + k] = min(tableudi[i * N + k], ud)
        tablelri[i * N + k] = min(tablelri[i * N + k], lr)
    else:
      for k in range(N):
        tableudi[i * N + k] = min(tableudi[i * N + k], min(abs(a[k][0]), abs(a[k][1])) * a[k][2])
        tablelri[i * N + k] = min(tablelri[i * N + k], min(abs(a[k][0]), abs(a[k][1])) * a[k][2])
res = [10 ** 12] * (N + 1)
for t in range(1 << N):
  i = t + 0
  c = bin(t).count("1")
  while True:
    x = i + 0
    y = t ^ x
    rres = 0
    for j in range(N):
      rres += min(tableudi[x * N + j], tablelri[y * N + j])
    res[c] = min(res[c], rres)
    #print(t, res, rres)
    if i == 0: break
    i = (i - 1) & t
for r in res: print(r)

Measured memory_bytes: 145956
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, x;
    cin >> N >> x;
    int a[100010];
    rep(i, N) cin >> a[i];
    ll ans = 0;
    rep(i, N) {
        ans += max(0, a[i] - x);
        a[i] -= max(0, a[i] - x);
    }
    rep(i, N - 1) {
        if (a[i] + a[i + 1] > x) {
            ans += max(0, a[i] + a[i + 1] - x);
            a[i + 1] -= max(0, a[i] + a[i + 1]  - x);
        }
    }
    // rep(i, N) cout << a[i] << " ";
    // cout << endl;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int N, arr[110], ans;
int main() {
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        cin >> arr[i];
    }
    sort(arr + 1, arr + 1 + N);
    for (int i = 1; i <= N; ++i) {
        for (int j = i + 1; j <= N; ++j) {
            if (arr[i] == arr[j])
                continue;
            for (int k = j + 1; k <= N; ++k) {
                if (arr[k] == arr[i] || arr[k] == arr[j])
                    continue;
                if (arr[i] + arr[j] > arr[k]) {
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;
    // system("pause");
    return 0;
}

Measured memory_bytes: 3636
// atcoder/abc175/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  lli x, k, d;
  while (cin >> x >> k >> d) {
    x = abs(x);
    const lli y = min(k, x / d);
    x -= y * d;
    k -= y;

    while (k && abs(x) > abs(x - d)) {
      --k;
      x = abs(x - d);
    }
    if (k) {
      k %= 2;
    }
    if (k) {
      x = min(abs(x - d), abs(x + d));
    }

    cout << x << endl;
  }

  return 0;
}


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

using lint = long long int;
using pii = std::pair<int, int>;

using std::vector;

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

vector<lint> ve;

int main(void) {
	lint N, K;
	scanf("%lld %lld", &N, &K);
	for (int i = 1; i <= N; i++) {
		lint temp;
		scanf("%lld", &temp);
		ve.push_back(temp);
	}
	sort(ve.begin(), ve.end());
	ve.resize(std::unique(ve.begin(), ve.end()) - ve.begin());

	if (ve.size() == 1) {
		if (K == ve[0]) {
			printf("POSSIBLE");
		}
		else {
			printf("IMPOSSIBLE");
		}
	}
	else {
		lint temp = gcd(ve[1] - ve[0], ve[1] % (ve[1] - ve[0]));
		for (int i = 2; i < ve.size(); i++) {
			temp = gcd(temp, ve[i] % temp);
		}

		if (K % temp == 0 && K <= ve.back()) {
			printf("POSSIBLE");
		}
		else {
			printf("IMPOSSIBLE");
		}
	}

	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int main() {
  int n;
  cin >> n;
  int check;
  check = n % 10;
  if (check == 2 or check == 4 or check == 5 or check == 7 or check == 9) {
    cout << "hon"  << endl;
  }
  if (check == 0 or check == 1 or check == 6 or check == 8) {
    cout << "pon"  << endl;
  }
  if (check == 3) cout << "bon" << endl;

  return 0;
}


Measured memory_bytes: 3620
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let ha = readInts()
    let h = ha[0]
    let a = ha[1]
    
    if h % a == 0 {
        print(h / a)
    } else {
        print(h / a + 1)
    }
}

main()


Measured memory_bytes: 8244
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void rd(string &x){
  char *buf = (char *)wmem;
  rd(buf);
  x = buf;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
string S;
string T;
string U;
int A;
int B;
int main(){
  wmem = memarr;
  rd(S);
  rd(T);
  rd(A);
  rd(B);
  rd(U);
  if(S==U){
    A--;
  }
  else{
    B--;
  }
  wt_L(A);
  wt_L(' ');
  wt_L(B);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200214-1

// --- original code ---
// string S,T,U;
// int A,B;
// {
//   rd(S,T,A,B,U);
//   if[S==U, A, B]--;
//   wt(A,B);
// }


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

int main(){
  int n;
  int cost = 0;
  cin >> n;
  std::vector<int> a(n);
  std::vector<int> b(n);
  std::vector<int> c(n-1);
  rep(i, n) cin >> a.at(i);
  rep(i, n){
    cin >> b.at(i);
    cost += b.at(i);
  }
  rep(i, n-1) cin >> c.at(i);
  
  rep(i, n-1){
    if(a.at(i+1) - a.at(i) == 1){
      cost += c.at(a.at(i) - 1);
    }
  }

  std::cout << cost << '\n';
  
  return 0;
}

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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);
int N;
int C[220000];
int dp[220000];
int mod = 1e9 + 7;

signed main() {
    cin >> N;
    for (int i = 1; i <= N; i++)cin >> C[i];
    int ans = 1;
    for (int i = 1; i <= N; i++) {
        if (C[i] == C[i - 1])continue;
        ans = dp[C[i]] = (ans + dp[C[i]]) % mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <algorithm>
using namespace std;
int a[100005];
int main()
{
	int n,m,i,j,k,s,t;
	while(~scanf("%d",&n))
	{
		for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	    sort(a+1,a+1+n);
	    m=n/2;
	    printf("%d\n",a[m+1]-a[m]);
	}
	return 0;
} 

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


int main () {
  int x, a, b;
  cin >> x >> a >> b;
  if (abs(x - a) < abs(x - b)) cout << 'A' << endl;
  else cout << 'B' << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rfor(i, a, b) for (int i=a; i<(b); i++)
#define zfor(i, a) for (int i=0; i<(a); i++)
#define brfor(i,a,b) for (int i = (b)-1; i >= a; i--)
#define bzfor(i,a) for (int i = (a)-1; i >= 0; i--)

int main(){
    int n;
    cin>>n;
    int arr[n] , X = 0;
    zfor(i,n){
        cin>>arr[i];
        X^=arr[i];
    }
    zfor(i,n){
        cout<<(X^arr[i])<<" ";
    }
}

Measured memory_bytes: 4284
import java.util.*;

public class Main {

	static long Examine(long countM,long countA,long countR,long countC,long countH) {
		long count = 0;
		count += countM * countA * countR;
		count += countM * countA * countC;
		count += countM * countA * countH;
		
		count += countM * countR * countC;
		count += countM * countR * countH;
		
		count += countM * countC * countH;
		
		count += countA * countR * countC;
		count += countA * countR * countH;
		
		count += countA * countC * countH;
		
		count += countR * countC * countH;

		return count;
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] names = new String[N];
		long countM = 0;
		long countA = 0;
		long countR = 0;
		long countC = 0;
		long countH = 0;
		String[] I = new String[N];
		for(int i = 0;i < N;i++) {
			names[i] = sc.next();
			I[i] = names[i].substring(0,1);
		}
		for(int k = 0;k < N;k++) {
			if(I[k].equals("M")) countM++;
			else if(I[k].equals("A")) countA++;
			else if(I[k].equals("R")) countR++;
			else if(I[k].equals("C")) countC++;
			else if(I[k].equals("H")) countH++;
		}
		System.out.println(Examine(countM,countA,countR,countC,countH));
		sc.close();
	}

}

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

using namespace std;

int cnt[40];

int main(){
    int n, m, i, j, k, x;
    while(scanf("%d%d", &n, &m) != EOF){
        memset(cnt, 0, sizeof(cnt));
        for(i = 1; i <= n; i++){
            scanf("%d", &k);
            for(j = 1; j <= k; j++){
                scanf("%d", &x);
                cnt[x]++;
            }
        }
        int ans = 0;
        for(i = 1; i <= m; i++) ans += (cnt[i]==n);
        printf("%d\n", ans);
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef tuple<int,int,int> tii;
#define rep(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

int main(){
  ll N;
  cin >> N;
  ll ans = 0;
  for(ll i=1;i<N;i++){
    for(ll j=1;i*j<N;j++){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3672
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		int[] masu=new int[M];
		for(int i=0; i<M; i++) {
			masu[i]=sc.nextInt();
		}
		Arrays.sort(masu);
		if(M==1) {
			pl(0);
			System.exit(0);
		}
		if(N==1) {
			pl(masu[M-1]-masu[0]);
			System.exit(0);
		}
		else {
			if(N>=M) {	//コマが過剰のとき
				pl(0);
				System.exit(0);
			}
			else {
				int[] sa=new int[M-1];
				for(int i=0; i<M-1; i++) {
					sa[i]=masu[i+1]-masu[i];
				}
				Arrays.sort(sa);
				int max=masu[M-1]-masu[0];
				for(int i=0; i<N-1; i++) {
					max-=sa[M-2-i];
				}
				pl(max);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}

Measured memory_bytes: 35028
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    int N;
    cin >> N;
    
    long long int sum = 0;
    for (int i = 1; i < N; i++)
    {
        sum += i;
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

MOD = 10**9+7
def frac(limit):
    frac = [1]*limit
    for i in range(2,limit):
        frac[i] = i * frac[i-1]%MOD
    fraci = [None]*limit
    fraci[-1] = pow(frac[-1], MOD -2, MOD)
    for i in range(-2, -limit-1, -1):
        fraci[i] = fraci[i+1] * (limit + i + 1) % MOD
    return frac, fraci
frac, fraci = frac(1341398)


MOD = 10**9+7
N = int(readline())
X = list(map(int, readline().split()))

D = [x1 - x0 for x0, x1 in zip(X, X[1:])]

g = [0]*(N+3)
g[1] = 1
for i in range(2, N+3):
    g[i] = (g[i-1] + pow(i, MOD-2, MOD)) % MOD

ans = 0
for i in range(N-1):
    ans = (ans + D[i]*g[i+1])%MOD

print(ans*frac[N-1]%MOD)


Measured memory_bytes: 109532
h,w=map(int,input().split())
l=[]
for i in range(10):
  l.append(list(map(int,input().split())))
way=[]
for i in range(h):
  way.append(list(map(int,input().split())))
from collections import deque
q=deque([[0,0]])
for k in range(10):
  for j in range(10):
    for i in range(10):
      l[i][j]=min(l[i][j],l[i][k]+l[k][j])
cost=0
d=[[-1 for i in range(w)] for j in range(h)]
if way[0][0]!=-1:
  cost+=l[way[0][0]][1]
d[0][0]=1
move=[[0,1],[0,-1],[-1,0],[1,0]]
while q:
  m=q.popleft()
  for i in move:
    x=m[0]+i[0]
    y=m[1]+i[1]
    if x<0 or y<0 or x>=h or y>=w:
      pass
    elif d[x][y]==1:
      pass
    else:
      d[x][y]=1
      if way[x][y]!=-1:
        cost+=l[way[x][y]][1]
      way[x][y]=1
      q.append([x,y])
print(cost)

Measured memory_bytes: 4028
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

struct Node {
  array<Node*, 2> ch;
};

Node root;
int N;
LL L;
char buf[114514];

void Register(string S) {
  int m = S.size();
  auto node = &root;
  rep(i, m) {
    int b = S[i] - '0';
    if (node->ch[b] == NULL) {
      node->ch[b] = new Node();
    }
    node = node->ch[b];
  }
}

LL ans = 0;
void Dfs(Node *node, LL d) {
  int cnt = 0;
  rep(i, 2) {
    if (!node->ch[i]) continue;
    Dfs(node->ch[i], d+1);
    cnt++;
  }

  if (cnt == 1) {
    LL g = L-d;
    ans ^= (g&-g);
  }
}

int main() {
  scanf("%d%lld", &N, &L);
  rep(i, N) {
    scanf(" %s", buf);
    Register(buf);
  }

  Dfs(&root, 0);
  if (ans == 0) {
    puts("Bob");
  } else {
    puts("Alice");
  }
}


Measured memory_bytes: 6656
# import sys
#
#
# RS = lambda: sys.stdin.readline()[:-1]
# RI = lambda x=int: x(RS())
# RA = lambda x=int: map(x, RS().split())
# RSS = lambda: RS().split()

# import decimal
# decimal.getcontext().prec = 50


def solve(a , b):
    b = b.replace(".", "")
    b = int(b)
    ans = a*b // 100
    print(ans)
    return


inp = input().split()
a = int(inp[0])
b = inp[1]
solve(a, b)


Measured memory_bytes: 61764
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 28 17:53:21 2020

@author: Kanaru Sato
"""

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

asort = sorted(a,reverse=True)

Max = asort[0]
MaxIndex = a.index(Max)
Pmax = asort[1]
PmaxIndex = a.index(Pmax)

if Pmax != Max:
    for i in range(n):
        if i == MaxIndex:
            print(Pmax)
        else:
            print(Max)
else:
    for i in range(n):
        print(Max)

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    int a,b;cin>>a>>b;

    int result = max(a+b,a-b);
    result = max(result,a*b);

    cout<<result<<endl;

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
using namespace std;
 
int main() {
  int n, t;
  cin >> n >> t;
  int c[100], s[100];
  int min = 10000;
  for (int i = 0; i < n; i++) {
    cin >> c[i] >> s[i];
    if (s[i] <= t && c[i] < min) min = c[i];
  }
  if (min == 10000) {
    cout << "TLE" << endl;
  }
  else {
    cout << min << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

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

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    ll a[n];
    F0R(i,n) cin >> a[i];
    ll d = a[0];
    F0R(i,n){
      d = __gcd(d,a[i]);
    }
    cout << d<< endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 1024
#include <iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
 //Compiler version g++ 6.3.0

int makecards(char c, int n)
{
    if(c=='H')n+=13;
   else if(c=='C')n+=26;
    else if(c=='D')n+=39;
    return n;
}
char checkcards(int n)
{
    int d = n/13;
    if(n%13!=0)
    {
    if(d==0)return 'S';
    else if(d==1)return 'H';
    else if(d==2)return 'C';
    else return 'D';
    }
    else
    {
    if(d==1)return 'S';
    else if(d==2)return 'H';
    else if(d==3) return 'C';
    else return 'D';
    }
}

int reigai(int n)
{
    if(n==0)return 13;
    else return n;
}

 int main()
 {
     int n;
     cin>>n;
     vector<bool> cards(53);
     cards[0]=true;
     for(int i = 0; i<n; ++i)
     {
         char c;
         int a;
         cin>>c>>a;
         cards[makecards(c,a)]=true;
     }
     for(int i = 0; i<53; ++i)
     {
         if(cards[i]==false)
         {
             //cout<<i<<endl;
             cout<<checkcards(i)<<" "<<reigai(i%13)<<endl;
         }
     }
 }


Measured memory_bytes: 3020
#include <iostream>
#include <vector>
using namespace std;
 
int main(void){
    int N, s;
    long long sum;
    cin >> N;
    vector<int> vec(100, 0);
    sum = 0;
    for(int i = 0; i < N; i ++)
    {
        cin >> s;
        vec[s-1] += 1;
        sum += s;
    }
    for(int i = 0; i < 100; i++)
    {
        if(sum%10 != 0)
        {
            cout << sum << endl;
            return 0;
        }
        if( (i + 1)%10 != 0 && vec[i] >= 1)
        {
            sum -= (i + 1);
            vec[i]--;
            cout << sum << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
$N = (int) trim(fgets(STDIN));
$a = array_map(function($v){return (int)$v;} ,split(' ', trim(fgets(STDIN)) ) );
$a_map = [];
$max_a = 0;
for ($i=0;$i<$N;$i++) {
  if ($a[$i] > $max_a) $max_a = $a[$i];
  if (array_key_exists($a[$i], $a_map) ) {
    $a_map[$a[$i]]+=1;
  } else {
    $a_map[$a[$i]]=1;
  }
}

$min_a = (int) ($max_a / 2);
if($max_a%2) $min_a+=1;
// 最長パスが作れるか
for ($i=$min_a;$i<=$max_a;$i++) {
  if (array_key_exists($i, $a_map) ) {
    if ($i==$min_a && $max_a%2==0 && $a_map[$i]>=1) {
      $a_map[$i]-=1;
    } elseif ($a_map[$i] >= 2) {
      $a_map[$i]-=2;
    } else {
      print("Impossible\n");
      exit();
    }
  } else {
    print("Impossible\n");
    exit();
  }
}

// 最短パスより短いパスが無いか
for ($i=1;$i<=$min_a;$i++) {
  if (array_key_exists($i, $a_map) ) {
    if($a_map[$i]>=1) {
      print("Impossible\n");
      exit();
    }
  }
}

print("Possible\n");


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
#define p(x) cout<<(x)<<endl

int main() {
  int n; cin >> n;
  rep(i, 8) {
    int d = pow(2, i);

    if (d > n) {
      p(pow(2, i-1));
      return 0;
    }
  }
  return 1;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a <= 5)
  cout << 0 << endl;
  else  if (a >= 13)
  cout << b <<endl;
  else cout  << b / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    long double a, b, c;
    cin >> a >> b >> c;

    if(c - a - b < 0){
        cout << "No" << endl;
    }else if((c - a - b) * (c - a - b) > 4 * a * b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }



    /*
    long double tmp_a = sqrtl((long double)a);
    long double tmp_b = sqrtl((long double)b);
    long double tmp_c = sqrtl((long double)c);
    */

    /*
    if(sqrtl((long double)c) - sqrtl((long double)a) - sqrtl((long double)b) > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    */

    /*
    if(a + b + (2 * sqrt(a*b)) < c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    */

    
    /*
    double tmp_a = sqrt(a);
    double tmp_b = sqrt(b);
    double tmp_c = sqrt(c);
    
    cout << tmp_a << endl;
    cout << tmp_b << endl;
    cout << tmp_c << endl;
    
    if(tmp_a + tmp_b < tmp_c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    double x = 1000000000 * 1000000000;
    cout << x << endl;
    */
    

}

Measured memory_bytes: 256
n = int(input())
A = [int(x) for x in input().split()]
S = sum(A)

X_1 = S
i = 0
while 2*i+1 < n:
    X_1 -= 2 * A[2*i+1]
    i += 1

X = [0] * n
X[0] = X_1

for i in range(n-1):
    X_i_1 = 2 * A[i] - X[i]
    X[i+1] = X_i_1
    
print(" ".join(map(str, X)))

Measured memory_bytes: 19144
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Queue;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		int t = Integer.parseInt(br.readLine());
		for (int x = 0; x < t; x++) {
			int n = Integer.parseInt(br.readLine());
			Obj[] arr = new Obj[n];
			for (int i = 0; i < n; i++) {
				String[] sa = br.readLine().split(" ");
				Obj o = new Obj();
				o.k = Integer.parseInt(sa[0]);
				o.l = Integer.parseInt(sa[1]);
				o.r = Integer.parseInt(sa[2]);
				o.d = Math.abs(o.l - o.r);
				arr[i] = o;
			}
			Arrays.sort(arr, (o1, o2) -> o1.k - o2.k);

			long ans = 0;
			Queue<Obj> fix = new ArrayDeque<>();
			PriorityQueue<Obj> ok = new PriorityQueue<>((o1, o2) -> o1.d - o2.d);
			Queue<Obj> ng = new ArrayDeque<>();
			int used = 0;
			for (int i = 0; i < n; i++) {
				Obj o = arr[i];
				if (o.l == o.r) {
					fix.add(o);
				} else if (o.l > o.r) {
					if (o.k > used) {
						ok.add(o);
						used++;
					} else {
						Obj f = ok.peek();
						if (o.d > f.d) {
							ng.add(ok.poll());
							ok.add(o);
						} else {
							ng.add(o);
						}
					}
				}
			}

			PriorityQueue<Obj> ok2 = new PriorityQueue<>((o1, o2) -> o1.d - o2.d);
			Queue<Obj> ng2 = new ArrayDeque<>();
			used = n;
			for (int i = n - 1; i >= 0; i--) {
				Obj o = arr[i];
				if (o.l < o.r) {
					if (o.k < used) {
						ok2.add(o);
						used--;
					} else {
						if (!ok2.isEmpty() && o.d > ok2.peek().d) {
							ng2.add(ok2.poll());
							ok2.add(o);
						} else {
							ng2.add(o);
						}
					}
				}
			}
			for (Obj o : fix) {
				ans += Math.max(o.l, o.r);
			}
			for (Obj o : ok) {
				ans += Math.max(o.l, o.r);
			}
			for (Obj o : ok2) {
				ans += Math.max(o.l, o.r);
			}
			for (Obj o : ng) {
				ans += Math.min(o.l, o.r);
			}
			for (Obj o : ng2) {
				ans += Math.min(o.l, o.r);
			}
			pw.println(ans);
		}
		br.close();
		pw.flush();
	}

	static class Obj {
		int k, l, r, d;
	}
}


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

using namespace std;

// #define INF LONG_MAX
#define INF 100000000000
#define ll long long int

int main(){
  int A,B,Q;
  cin >> A >> B >> Q;

  vector<ll> s;
  vector<ll> t;
  s.push_back(-1*INF);  //二分探索用（スタート位置がs,t範囲に入るように）
  t.push_back(-1*INF);
  for(int i=0;i < A;i++){
    ll ss;
    cin >> ss;
    s.push_back(ss);
  }
  for(int i=0;i < B;i++){
    ll tt;
    cin >> tt;
    t.push_back(tt);
  }
  s.push_back(INF);
  t.push_back(INF);
  
  ll ans = INF;

  for(int i=0;i < Q;i++){
    ll x;
    cin >> x;
    auto b = lower_bound(s.begin(),s.end(),x);
    auto d = lower_bound(t.begin(),t.end(),x);
    ll sl = *(b - 1), sr = *b;
    ll tl = *(d - 1), tr = *d;
    // printf("%ld %ld %ld %ld\n",sl,sr,tl,tr);

    ll res0 = abs(x-tr)+abs(tr-sl);
    ll res1 = sl < tl ? abs(x-sl) : abs(x-tl);
    ll res2 = abs(x-sr)+abs(sr-tl);
    ll res3 = sr < tr ? abs(x-tr) : abs(x-sr);
    ll res4 = abs(x-tl)+abs(tl-sr);
    ll res5 = abs(x-sl)+abs(sl-tr);
    ans = min({res0,res1,res2,res3,res4,res5});
    cout << ans << endl;
  }
  
  return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] tmp = br.readLine().split(" ");
			int n = Integer.parseInt(tmp[0]);
			int x = Integer.parseInt(tmp[1]);
			if(n == 0 && x == 0){
				break;
			}
			int count = 0;
			for(int i = 3;i <= n;i++){
				for(int j = 2;j < i;j++){
					for(int k = 1;k < j;k++){
						if((i + j + k) == x){
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}

}

Measured memory_bytes: 18868