akhauriyash/Code-Regression huggingface dataset:
import numpy as np
from statistics import median

N = int(input())
A = list(map(int, input().split()))
list_n = list(range(1, (N+1), 1))
A_tmp = np.array(A)
list_n_tmp = np.array(list_n)
list_diff = A_tmp - list_n_tmp
b = median(list_diff)
Xtmp = 0

for n in range(0, N, 1):
    Xtmp += abs(A[n] - (b + n + 1))

print(int(Xtmp))


Measured memory_bytes: 41988
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a < b){
            if(b < c){
                System.out.printf("%d %d %d\n",a,b,c);
            }else{//c <= b
                if(a < c) {
                    System.out.printf("%d %d %d\n",a,c,b);
                }else{
                    System.out.printf("%d %d %d\n",c,a,b);
                }
            }
        }else{//b <= a
            if(a < c){
                System.out.printf("%d %d %d\n",b,a,c);
            }else{//c <= a
                if(b < c){
                    System.out.printf("%d %d %d\n",b,c,a);
                }else{
                    System.out.printf("%d %d %d\n",c,b,a);
                }
            }
        }
    }
}


Measured memory_bytes: 26356
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int adtax(int p, int x){
	return (p*(100+x))/100;
}

int rmtax(int p, int x){
	int l,r,i;
	l = (100*p)/(100+x);
	r = (100*p+100)/(100+x);
	for(i=l; i<=r; ++i){
		if(adtax(i,x)==p){
			return i;
		}
	}
	return -3444;
}

int main(void){
	int x,y,s,i,ans;
	while(true){
		cin >> x >> y >> s;
		if(!(x&&y&&s)){
			break;
		}
		ans = 0;
		for(i=1; i<s; ++i){
			ans = max(ans,adtax(rmtax(i,x),y)+adtax(rmtax(s-i,x),y));
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());


int main(){
	int n,m;
	while(cin>>n>>m,n||m){
		vint v(n);
		rep(i,n) cin>>v[i];
		sort(ALL(v));
		reverse(ALL(v));
		int c=0;
		int ans=0;
		rep(i,n){
			if(c==m-1){
				c=0;

			}
			else{
				ans+=v[i];
				c++;
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>

using namespace std;

void c()
{
    int n;
    cin >> n;
    vector<int> a, b, c;
    for(int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    for(int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        b.push_back(temp);
    }
    for(int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        c.push_back(temp);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    reverse(c.begin(), c.end());
    vector<long long int>dp1(n);
    vector<long long int>dp2(n);
    int index = 0;
    for(int i = 0; i < n; i++)
    {
        long long int count = 0;
        while(index < n)
        {
            if(b[i] < c[index])
            {
                count++;
                index++;
            } else{
                break;
            }
        }
        if(i == 0){
            dp1[i] = count;
        } else{
            dp1[i] = dp1[i - 1] + count;
        }
    }
    index = 0;
    for(int i = 0; i < n; i++)
    {
        long long int pattern = 0;
        while (index < n)
        {
            if(a[i] < b[index])
            {
                pattern += dp1[index];
                index++;
            } else{
                break;
            }
        }
        if(i == 0)
        {
            dp2[i] = pattern;
        } else{
            dp2[i] = dp2[i - 1] + pattern;
        }
    }
    long long int sum = 0;
    for(auto e : dp2)
    {
        sum += e;
    }
    cout << sum << endl;
}

void d()
{
    long long int k;
    cin >> k;
    long long int target = k;
    long long int count = k;
    for(long long int i = 1; i <= k * k; i++)
    {
        target =  k * i;
        string str = to_string(target);
        long long int temp = 0;
        for(int j = 0; j < str.size(); j++)
        {
            temp += str[j] - '0';
        }
        if(count > temp)
        {
            count = temp;
        }
    }
    cout << count << endl;
}

int main() {
    c();
    return 0;
}


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
static const int inf = 1 << 30;

int main(void) {
  char c[10];
  REP(i, 9) { cin >> c[i]; }
  cout << c[0] << c[4] << c[8] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
vector <ull>numbers;
vector<ull>accumsum;
ull dp[105][100005];
ull mod = 1e9 + 7;

int main() {

	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ull n, k;
	cin >> n >> k;
	accumsum.push_back(0);
	for (int i = 0; i < n; ++i) {
		ll e;
		cin >> e;
		numbers.push_back(e);
		accumsum.push_back(e + accumsum.back());
	}


	for (int i = numbers.size(); i >= 0; --i) {
		ll right = k, left = k, m = 0;
		for (int j = k; j >= 0; --j) {

			if (i == numbers.size() && j == 0) {
				dp[i][j] = 1;
				continue;
			}

			else if (i == numbers.size()) {
				dp[i][j] = 0;
				continue;
			}

			ll taken = k - j;
			if (taken > accumsum[i])
				break;

			if (left == right) {

				for (int h = 0; h <= min((ull)j, numbers[i]); ++h) {
					m = (m + dp[i + 1][j - h]);
					left = j - h;
				}

			}

			else {
				m -= dp[i + 1][j + 1];
				if (left > 0)
					--left, m += dp[i + 1][left];
			}

		    dp[i][j] = m % mod;
		}
		
	}
	
	cout << dp[0][k] << "\n";

	return 0;
}



Measured memory_bytes: 79360
class MyNode
  attr_accessor :v, :parent, :left_child, :right_child

  def initialize v, parent, left_child, right_child
    @v = v
    @parent = parent
    @left_child = left_child
    @right_child = right_child
  end
end

def insert(root_node, v)
  p = nil
  x = root_node
  while x
    p = x
    if v < x.v
      x = x.left_child
    else
      x = x.right_child
    end
  end
  node = MyNode.new(v, p, nil, nil)
  if p
    if node.v < p.v
      p.left_child = node
    else
      p.right_child = node
    end
  else
    root_node = node
  end

  return root_node
end

def find(root_node, v)
  return true if root_node.v == v
  if v < root_node.v && root_node.left_child
    return find(root_node.left_child, v)
  end
  if v > root_node.v && root_node.right_child
    return find(root_node.right_child, v)
  end
  return false
end

def get_minimum(root_node)
  root_node = get_minimum(root_node.left_child) if root_node.left_child
  root_node
end

def delete(root_node, v)
  if root_node.v == v
    if root_node.left_child.nil? && root_node.right_child.nil?
      if root_node.v < root_node.parent.v
        root_node.parent.left_child = nil
      else
        root_node.parent.right_child = nil
      end
    elsif root_node.left_child && root_node.right_child
      successor = get_minimum(root_node.right_child)
      root_node.v = successor.v
      root_node.v = successor.v
      delete(successor, successor.v)
    elsif root_node.left_child
      root_node.left_child.parent = root_node.parent
      if root_node.v < root_node.parent.v
        root_node.parent.left_child = root_node.left_child
      else
        root_node.parent.right_child = root_node.left_child
      end
    elsif root_node.right_child
      root_node.right_child.parent = root_node.parent
      if root_node.v < root_node.parent.v
        root_node.parent.left_child = root_node.right_child
      else
        root_node.parent.right_child = root_node.right_child
      end
    end
    return
  end
  if v < root_node.v && root_node.left_child
    delete(root_node.left_child, v)
  end
  if v > root_node.v && root_node.right_child
    delete(root_node.right_child, v)
  end
end

def make_pre node, vs
  vs << node.v
  make_pre node.left_child, vs if node.left_child
  make_pre node.right_child, vs if node.right_child
  vs
end

def make_in node, vs
  make_in node.left_child, vs if node.left_child
  vs << node.v
  make_in node.right_child, vs if node.right_child
  vs
end

_ = gets
root = nil
while l = gets
  command, val = l.chomp.split(' ')
  if command == 'insert'
    root = insert(root, val.to_i)
  elsif command == 'print'
    puts ' ' + make_in(root, []).join(' ')
    puts ' ' + make_pre(root, []).join(' ')
  elsif command == 'find'
    puts find(root, val.to_i) ? 'yes' : 'no'
  elsif command == 'delete'
#     puts ' ' + make_in(root, []).join(' ')
    delete(root, val.to_i)
  end
end


Measured memory_bytes: 60764
#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ll long long
#define all(a) a.begin(), a.end() 
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  for(int i = 1; i <= 100100; ++i) {
    if((b*i + c)%a == 0) {
      cout << "YES" << endl;
      return 0;
    }
  }
  
  cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    cout << abs(a[1]-a[0])+abs(a[2]-a[1]) << endl;
    return 0;
}      


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int value = a + b + c;
        if (value >= 22) {
            System.out.println("bust");
        } else {
            System.out.println("win");
        }
    }
}


Measured memory_bytes: 21588
#include<stdio.h>
#include<algorithm>
#define maxn 200005
#define inf 0x3f3f3f3f
using namespace std;
typedef long int ll;
int main()
{
    int n, t, x;
    long long ans = 0;
    scanf("%d %d", &n, &t);
    if (t) return 0 & puts("-1");
    while(--n){
        scanf("%d", &x);
        if (x <= t) ans += x;
        else if (x == t + 1) ++ans;
        else return 0 & puts("-1");
        t = x;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main (void){

 int W,H,x,y,r,a,b,c,d;

 scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
 
 a = W- x;
 b= H - y;
 c= x -r;
 d= y-r;
 if(a>0 && b>0 && c>=0 && d>=0) {
 puts("Yes");
 }else{
 puts("No"); 
}

 return 0;
}


Measured memory_bytes: 2104
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	ll n;cin>>n;
	ll ans=(n*(n+1))/2;
	cout<<(ll)(ans-n)<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main()
{
	int k, s;
	cin >> k >> s;
	int counter = 0;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= k; j++) {
			int z = s - j - i;
			if (0 <= z && z <= k) counter++;
		}
	}
	cout << counter << endl;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

double h,w,x,y,ans;
int memo;

signed main() {
    cin >> w >> h >> x >> y;
    if (w/2 == x && h/2 == y) memo = 1;
    cout << w*h/2 << " " << memo << endl;
}





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

int main(){
  string s;
  cin >> s;
  int n =s.size();
  int ans;
  for(int i=0;i<n/2;i++){
    if(s.at(i) != s.at(n-i-1)){
      s[n-i-1] = s[i];
      ans ++;
    }
  }
    cout << ans;
}

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


signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int H, W;
  cin >> H >> W;
  int A[H][W] = {}, B[H][W] = {};
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> A[i][j];
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> B[i][j];
    }
  }
  int C[H][W] = {};
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      C[i][j] = abs(A[i][j] - B[i][j]);
    }
  }
  bool dp[H][W][13000] = {};
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      for(int k=0;k<=12800;k++){
        if(i == 0 && j == 0){
          int Z = C[i][j];
          dp[0][0][Z] = true;
          break;
        }
        else{
          if(i == 0){
            if(dp[0][j-1][k]){
              dp[0][j][k+C[i][j]] = true;
              dp[0][j][abs(k-C[i][j])] = true;
            }
          }
          else if(j == 0){
            if(dp[i-1][0][k]){
              dp[i][0][k+C[i][j]] = true;
              dp[i][0][abs(k-C[i][j])] = true;
            }
          }
          else{
            if(dp[i][j-1][k]){
              dp[i][j][k+C[i][j]] = true;
              dp[i][j][abs(k-C[i][j])] = true;
            }
            if(dp[i-1][j][k]){
              dp[i][j][k+C[i][j]] = true;
              dp[i][j][abs(k-C[i][j])] = true;
            }
          }
        }
      }
    }
  }
  for(int i=0;i<=80;i++){
    if(dp[H-1][W-1][i]){
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 81664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n, t;
  cin >> n >> t;
  vector<int> a(n);
  ll ans = 0;
  rep(i, n) cin >> a[i];
  for(int i = 1; i < n; ++i){
    ans += min(t, a[i] - a[i - 1]);
  }
  ans += t;

  cout << ans << endl;
}

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

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

    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    
    vector<int> colors;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < a[i]; ++j) colors.push_back(i+1);
    }
    
    vector<vector<int>> res(h, vector<int>(w));
    int ptr = 0;
    for(int i = 0; i < h; ++i){
        if(i%2 == 0){
            for(int j = 0; j < w; ++j){
                res[i][j] = colors[ptr];
                ++ptr;
            }
        }
        else{
            for(int j = w-1; j >= 0; --j){
                res[i][j] = colors[ptr];
                ++ptr;
            }
        }
    }

    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w-1; ++j) cout << res[i][j] << " ";
        cout << res[i].back() << endl;
    }

    return 0;
}

Measured memory_bytes: 3756
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

string S, T;

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

  int ans = 0;
  for (int i = 0; i < 3; i++) {
    if (S[i] == T[i]) {
      ans++;
    }
  }

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

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 10000000000
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
typedef pair<double, double> doup;

vector<ll> a;

ll ascend(ll i) {
    while(a[i]<a[i+1])
        i++;
    
    return i;
}

ll descend(ll i) {
    while(a[i]>a[i+1])
        i++;
    
    return i;
}

int main(void) {
    ll n, i, ans=0, tmp;
    cin >> n;
    
    for(i=0; i<n; i++) {
        cin >> tmp;
        if(i==0 || a[a.size()-1]!=tmp) {
            a.push_back(tmp);
        }
    }
    
    for(i=0; i<a.size(); i++) {
        if(a[i]<a[i+1]) {
            i=ascend(i);
            ans++;
        }else if(a[i]>a[i+1]) {
            i=descend(i);
            ans++;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1400
package main

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

var (
	n, k  int
	h, dp []int
)

func main() {
	io := newIo()
	n = io.nextInt()
	k = io.nextInt()

	h = make([]int, n)
	for i := range h {
		h[i] = io.nextInt()
	}

	dp = make([]int, n)
	for i := range dp {
		dp[i] = -1
	}

	fmt.Println(recDp(n - 1))
}

func recDp(i int) int {
	if i == 0 {
		return 0
	}
	if dp[i] != -1 {
		return dp[i]
	}
	res := math.MaxInt64
	for j := range make([]struct{}, k) {
		if i-j-1 >= 0 {
			res = min(res, recDp(i-j-1)+abs(h[i]-h[i-j-1]))
		}
	}
	dp[i] = res
	return res
}

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

type _io struct {
	reader    *bufio.Reader
	tokens    []string
	nextToken int
}

func newIo() *_io {
	return &_io{
		reader: bufio.NewReader(os.Stdin),
	}
}

func (_io *_io) nextLine() string {
	var buffer []byte
	for {
		line, isPrefix, _ := _io.reader.ReadLine()
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (_io *_io) next() string {
	for _io.nextToken >= len(_io.tokens) {
		line := _io.nextLine()
		_io.tokens = strings.Fields(line)
		_io.nextToken = 0
	}
	r := _io.tokens[_io.nextToken]
	_io.nextToken++
	return r
}

func (_io *_io) nextInt() int {
	i, _ := strconv.Atoi(_io.next())
	return i
}


Measured memory_bytes: 34176
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <vector>
using namespace std;

int main(){
	int A, B, Q;
	cin >> A >> B >> Q;
	vector<long int> s(A), t(B), x(Q);
	for(int i = 0;i<A;i++){
		cin >> s[i];
	}
	for(int i = 0;i<B;i++){
		cin >> t[i];
	}
	for(int i = 0;i<Q;i++){
		cin >> x[i];
	}
	for(int i = 0;i<Q;i++){
		long int MIN = 20000000000;
		vector<long int>::iterator itrrs = lower_bound(s.begin(), s.end()-1, x[i]);
		vector<long int>::iterator itrrt = lower_bound(t.begin(), t.end()-1, x[i]);
		long int rs, ls, rt, lt;
		if(itrrs == s.begin()){
			rs = *itrrs;
			ls = *itrrs;
		}else{
			rs = *itrrs;
			ls = *(itrrs - 1);
		}
		if(itrrt == t.begin()){
			rt = *itrrt;
			lt = *itrrt;
		}else{
			rt = *itrrt;
			lt = *(itrrt - 1);
		}
		long int shrine[2] = {ls, rs};
		long int temple[2] = {lt, rt};
		for(int j = 0;j<2;j++){
			for (int l = 0;l<2;l++){
				long int sfirst = abs(shrine[j] - x[i]) + abs(shrine[j] - temple[l]);
				long int tfirst = abs(temple[l] - x[i]) + abs(temple[l] - shrine[j]);
				MIN = min({MIN, sfirst, tfirst});
			}
		}
		cout << MIN << endl;
	}	
}


Measured memory_bytes: 3712
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        if(n%m==0){
            System.out.println("0");
        }
        else{
            System.out.println("1");
        }
    }      
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string in;
    cin>>in;

    int C_counter=0;
    int uppercase_counter=0;
    int length= in.length();
    if(in[0]=='A')
    {
        if (in[1]>='a'&&in[1]<='z'){
        for(int i=2; i<length; i++)
        {
            if (in[i] =='C' && i != length-1)
                C_counter++;
            else if (in[i]>='A'&&in[i]<='Z')
                uppercase_counter++;
        }
        }
        else{
            cout<<"WA";
            return 0;
        }
    }
    else{
        cout<<"WA";
        return 0;
    }

    if (C_counter==1 && uppercase_counter==0)
            cout<<"AC";
    else
        cout<<"WA";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

template <typename T> struct BIT {
    int n;
    vector<T> bit;
    BIT(int n_) : n(n_ + 1), bit(n, 0) {}

    T sum(int i) {
        T s(0);
        for (int x = i; x > 0; x -= (x & -x)) {
            s += bit[x];
        }
        return s;
    }

    void add(int i, T a) { // add a to i
        // The range of i is from 1 to n
        if (i == 0) {
            return;
        } else {
            for (int x = i; x <= n; x += (x & -x)) {
                bit[x] += a;
            }
        }
    }

    // min x  s.t.  bit[1]+bit[2]+...+bit[x] >= w
    int lower_bound(int w) {
        if (w <= 0) {
            return 0;
        } else {
            int x = 0, r = 1;
            while (r < n) {
                r = r << 1;
            }
            for (int k = r; k > 0; k = k >> 1) {
                if (x + k <= n && bit[x + k] < w) {
                    w -= bit[x + k];
                    x += k;
                }
            }
            return x + 1;
        }
    }

    // [l,r)
    T query(int l, int r) { return sum(r - 1) - sum(l - 1); }

    void print() {
        for (int i = 1; i <= n; i++) {
            cout << query(i, i + 1) << ",";
        }
        cout << endl;
    }
};

int main() {
    // https://atcoder.jp/contests/arc033/tasks/arc033_3
    ll N;
    cin >> N;

    vector<ll> a(N);
    REP(i, N) { cin >> a.at(i); }

    ll low = -1, high = 1 << 30;
    ll geta = N + 1;
    if (N == 1) {
        cout << a[0] << endl;
        return 0;
    }

    while (high - low > 1) {
        BIT<int> bit(3e5);
        ll mid = (high + low) / 2;
        ll ans = 0;
        ll sum = 0;
        bit.add(sum + geta, 1);
        REP(j, N) {
            ll val;
            if (a[j] >= mid) {
                val = 1;
            } else {
                val = -1;
            }
            sum += val;
            ans += bit.sum(sum + geta);
            bit.add(sum + geta, 1);
            // cout << sum << " ";
        }
        // cout << low << " " << high << " " << ans << endl;
        if (ans >= ((((N + 1LL) * N) / 2LL) + 1LL) / 2LL) {
            low = mid;
        } else {
            high = mid;
        }
    }
    cout << low << endl;
    return 0;
}


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

int main() {
  
  int N;
  int P = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    
    int A, B;
    cin >> A >> B;
    P += B - A + 1;
  }
  
  cout << P << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

int main()
{
    int a, b;
    std::cin >> a >> b;

    int h = 0;
    for (int i = 1; i < b-a+1; i++) {
        h += i;
    }

    int ans;
    ans = h-b;
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll A, B, C;
    cin >> A >> B >> C;
    if ((A * B * C) % 2 == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << min(min(A * B, B * C), C * A) << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

class ScreenKeyboard {
private:
  char m_key[50][50];
  int m_count;
  int m_width, m_height;
  struct Position {
    int x;
    int y;
  };
  Position m_position;

  void findKey(char key, Position &pos)
  {
    for (int i = 0; i < m_width; i++) {
      for (int j = 0; j < m_height; j++) {
        if (m_key[i][j] == key) {
          pos.x = i;
          pos.y = j;
        }
      }
    }
  }

public:
  ScreenKeyboard(int width, int height) : m_count(0), m_position(),
                                          m_width(width), m_height(height)
  {
    for (int i = 0; i < width; i++) {
      for (int j = 0; j < height; j++) {
        m_key[i][j] = '_';
      }
    }
  }

  ~ScreenKeyboard()
  {
  }

  void setKey(char key, int x, int y)
  {
    m_key[x][y] = key;
  }

  void moveKey(char key)
  {
    Position pos;
    findKey(key, pos);
    m_count += abs(m_position.x - pos.x) + abs(m_position.y - pos.y) + 1;
    m_position.x = pos.x;
    m_position.y = pos.y;
  }

  int getCount()
  {
    return m_count;
  }
};

int main()
{
  int h, w;
  
  while (1) {
    cin >> h >> w;
    if (h == 0 && w == 0) return 0;
    cin.ignore();
    ScreenKeyboard* screenKeyboard = new ScreenKeyboard(h, w);
    string keyString[50];
    string inString;
    for (int i = 0; i < h; i++) {
      getline(cin, keyString[i]);
      for (int j = 0; j < keyString[i].size(); j++) {
        screenKeyboard->setKey(keyString[i][j], i, j);
      }
    }
    getline(cin, inString);
    for (int i = 0; i < inString.size(); i++) {
      screenKeyboard->moveKey(inString[i]);
    }
    cout << screenKeyboard->getCount() << endl;
    delete screenKeyboard;
  }
}



Measured memory_bytes: 3220
//**************************
//*** author  :  Alex Hu **
//************************

//  _______        __________         ________        __   
//  \      \   ____\______   \ ____  /  _____/  _____/  |_ 
//  /   |   \ /  _ \|       _// __ \/   \  ____/ __ \   __\
// /    |    (  <_> )    |   \  ___/\    \_\  \  ___/|  |  
// \____|__  /\____/|____|_  /\___  >\______  /\___  >__|  
//         \/              \/     \/        \/     \/      

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define fi first
#define se second
#define sqr(a) ((a)*(a))

typedef long long ll; 
typedef pair<int, int> pii;
typedef vector<int> vi;
int main(){
	int k,n;
	cin>>n>>k;
	if (k*2-1>n) cout<<"NO";
	else cout<<"YES";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a1, a2, a3, temp;
  scanf("%d %d %d", &a1, &a2, &a3);

  if(a1 > a2){
    temp = a1;
    a1 = a2;
    a2 = temp;
  }

  if(a2 > a3){
    temp = a2;
    a2 = a3;
    a3 = temp;
  }

 if(a1 > a2){
    temp = a1;
    a1 = a2;
    a2 = temp;
  }
 
  printf("%d %d %d\n", a1, a2, a3);

  return 0;
}



Measured memory_bytes: 2036
from collections import deque

N, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N - 1)]
Y = [list(map(int, input().split())) for _ in range(Q)]

graph = [[] for _ in range(N + 1)]
for a, b in X:
    graph[a].append(b)
    graph[b].append(a)

ctr = [0] * (N + 1)
for p, x in Y:
    ctr[p] += x

# BFS
visited = [False] * (N + 1)
visited[1] = True
q = deque([1])
while q:
    u = q.popleft()
    for v in graph[u]:
        if visited[v]:
            continue
            
        ctr[v] += ctr[u]
        visited[v] = True
        q.append(v)
        
print(*ctr[1:])


Measured memory_bytes: 122476
n = int(input())
min1 = 10000000000
max1 = -10000000000
min2 = 10000000000
max2 = -10000000000

for _ in range(n):
    x, y = map(int,input().split())
    if x+y> max1:
        r1 = [x,y]
        max1 = x+y
    if x+y<min1:
        l1 = [x,y]
        min1 = x+y
    if x-y>max2:
        r2 = [x,y]
        max2 = x-y
    if x-y<min2:
        l2 = [x,y]
        min2 = x-y


#print(abs(l[0]-r[0]) + abs(r[1]-l[1]))
print(max(max1-min1,max2-min2))

Measured memory_bytes: 9204
#include <iostream>
#include <vector>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;

#define ll long long

int main(){
    ll N,tmp;
    ll ans1=0, ans2=0;
    map<ll,ll> cnt;
    cin >> N;
    vector<int> A(N);
    vector<int> v;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i++){
        cnt[A[i]]++;
        if(cnt[A[i]] == 2) cnt[A[i]] = 0, v.push_back(A[i]); 
    }
    sort(v.begin(),v.end(), greater<ll>());
    if(v.size()>1){
        cout << 1LL * v[0] * v[1] << endl;
    }else{
        cout << 0 << endl;
    }

    // for(int i = 0; i < N; i++){
    //     cin >> tmp;
    //     if(st.count(tmp) == 0){
    //         st.insert(tmp);
    //     }else if(st.count(tmp) > 2){
    //         st.insert(tmp);
    //         ans2 = max(ans2, tmp);
    //         if(ans1 < ans2){
    //             long long t = ans1;
    //             ans1 = ans2;
    //             ans2 = t;
    //         }   
    //     }else{
    //         if(tmp != ans1 && tmp != ans2){
    //             st.insert(tmp);
    //             ans2 = max(ans2, tmp);
    //             if(ans1 < ans2){
    //                 long long t = ans1;
    //                 ans1 = ans2;
    //                 ans2 = t;
    //             }
    //         }
    //     }
    // }
    // long long ans =  ans1 * ans2;
    // cout << ans << endl;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e10
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<lli>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> bool chmax(T &a, T &b){ if(a<b) { a=b; return 1; }}
template<typename T> bool chmin(T &a, T &b){ if(b<a) { a=b; return 1; }}
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n, m, a, b;
    multimap<int, int> mp;
    cin >> n >> m;
    rep(i, m){
        cin >> a >> b;
        mp.insert(make_pair(b, a));
    }

    vector<pair<int, int>> span;
    int res = 1;
    for(auto const& e : mp){
        if(span.size() == 0){
            span.push_back(make_pair(e.first, e.second));
        }

        bool flg = false;
        for(auto const& sp : span){
            if(!(sp.first <= e.second) && !(sp.second >= e.first)){
                flg = true;
                break;
            }
        }
        // if(!flg){
        //     cout << e.second << " " << e.first << endl;
        // }
        if(!flg){
            res++;
            span.push_back(make_pair(e.first, e.second));
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 4992
const chunks = [];
process.stdin.on("data", chunk => {
  chunks.push(chunk);
});
process.stdin.on("end", () => {
  const body = Buffer.concat(chunks).toString("utf8");
  main(body.trim());
});

function main(data) {
  switch (data) {
    case "Sunny":
      console.log("Cloudy");
      break;
    case "Cloudy":
      console.log("Rainy");
      break;
    case "Rainy":
      console.log("Sunny");
      break;
  }
}


Measured memory_bytes: 7500
#include <iostream>

using namespace std;
typedef unsigned long long int ull;

int main()
{
    const int PN=104729+1;
    bool checked[PN] = {};
    const int N=10000+1;
    ull s[N] = {};

    for( int i=2, l=1; i<PN; ++i )
    {
        if ( !checked[i] ) {
            for( int j=i; j<PN; j+=i ) {
                checked[j] = true;
            }
            s[l] = s[l-1] + i;
            ++l;
        }
    }

    int n;
    while( cin >> n, n ) {
        cout << s[n] << endl;
    }
}

Measured memory_bytes: 1336
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int N;
  cin >> N;

  int ans = 1;
  while (ans * 2 <= N) {
    ans *= 2;
  }
  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


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

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

char str[10];

int get(int x)
{
	printf("%d\n",x);
	fflush(stdout);
	scanf("%s",&str);
	int ret=0;
	if(str[0]=='F') ret=1;
	else if(str[0]=='M') ret=-1;
	return ret;
}
int main()
{
	int n;
	scanf("%d",&n);
	int l=0,r=n;
	int s=get(0),t=s;
	if(s==0) return 0;
	while(1)
	{
		int m=(l+r)/2;
		int g=get(m);
		if(g==0) return 0;
		if(m%2==l%2)
		{
			if(s==g) l=m,s=g;
			else r=m,t=g;
		}
		else
		{
			if(s!=g) l=m,s=g;
			else r=m,t=g;
		}
	}
	return 0;
}


Measured memory_bytes: 760
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    s = input()
    N = s.count('N')
    W = s.count('W')
    S = s.count('S')
    E = s.count('E')
    if N:
        if S:
            pass
        else:
            print('No')
            exit()
    if S:
        if N:
            pass
        else:
            print('No')
            exit()
    if W:
        if E:
            pass
        else:
            print('No')
            exit()
    if E:
        if W:
            pass
        else:
            print('No')
            exit()
    print('Yes')
if __name__ == '__main__':
  main()


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

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

    int test[num];
    for(int i=0;i<num;i++){
        cin>>test[i];
    }
    for(int s=0;s<num-1;s++){
        for(int t=s+1;t<num;t++){
            if(test[t]>test[s]){
               int tmp=test[s];
               test[s]=test[t];
               test[t]=tmp;
            }
        }
    }
    int sum=0;
    int ans=0;

    for(int i=0;i<num;i++){
       
      sum+=test[i];
    }ans=sum-test[0]/2;
       
       cout<<ans;
    
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define S set<int>
#define itn int
bool dbg = false;
itn N, A[202020];
itn a[202020];
void solve() {
    FOR(i, 0, N) {
        a[i + 1] = a[i] + A[i];
    }
    int T = a[N];
    int ans = INF;
    FORR(i, 0, N) {
        ans = min(ans, abs(T - a[i] * 2));
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(i, 0, N) {
        cin >> A[i];
    }
    solve();
    return 0;
}


Measured memory_bytes: 3456
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
#print(a)

if a[-1] < 0:
    ans = a[-1]
    for i in range(0,n-1):
        ans = ans - a[i]
    print(ans)

    ko = a[-1]
    for i in range(0,n-1):
        print(ko,a[i])
        ko = ko-a[i]

elif a[0] < 0:
    ans = 0
    negn = 0
    for i in range(n):
        ans += abs(a[i])
        if a[i]<0:
            negn += 1
    print(ans)
    s = a[0]
    for i in range(negn , n-1):
        print(s,a[i])
        s = s-a[i]
    k = a[-1]
    for i in range(1,negn):
        print(k,a[i])
        k = k-a[i]
    print(k,s)

else:
    ans = 0
    for i in range(n):
        ans += abs(a[i])
    print(ans-2*a[0])
    m = a[0]
    for i in range(1,n-1):
        print(m,a[i])
        m = m-a[i]
    print(a[-1],m)


Measured memory_bytes: 61580
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int X; cin >> X;
    int res = 1;
    rep(b, 1, 1000){
        rep(p, 2, 1000){
            int cur = (int)(pow(b, p));
            if(cur > X) break;
            chmax(res, cur);
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define INF 100000000

const int MOD = 1e9+7;
typedef long long ll;
using namespace std;
const ll M = 998244353;

ll gcd(ll a, ll b) {
    ll tmp, r;
    if(a<b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    r = a%b;
    while(r!=0) {
        a = b;
        b = r;
        r = a%b;
    }

    return b;
}

int main(void) {
	ll k, sum=0;
	cin >> k;
	for(ll a=1;a<k+1;a++) {
	  for(ll b=1;b<k+1;b++) {
		for(ll c=1;c<k+1;c++) {
          sum += gcd(gcd(a,b), c);
		}
	  }	
	}

	cout << sum << endl;
}

Measured memory_bytes: 3636
package main
import "fmt"
func main(){
    // Your code here!
    var a,b,c int
    fmt.Scan(&a)
    fmt.Scan(&b)
    fmt.Scan(&c)
    ans := c - (a-b)

    if ans < 0 {
        ans = 0
    }
    fmt.Println(ans)
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

typedef struct inode{
  int v;
  int index;
} node;

int cmp(const void *a,const void *b){
  node *p=(node *)a;
  node *q=(node *)b;
  return p->v-q->v;
}

void run(void){
  int n;
  scanf("%d",&n);
  node *a=(node *)malloc(sizeof(node)*n);
  int i;
  for(i=0;i<n;i++){
    int m;
    scanf("%d",&m);
    a[i].v=m;
    a[i].index=i;
  }
  qsort(a,n,sizeof(node),cmp);
  int ans=0;
  for(i=0;i<n;i++) if(i%2!=a[i].index%2) ans++;
  printf("%d\n",ans/2);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1788
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var inputs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int a = inputs[0];
        int b = inputs[1];

        for (int i = 0; i < 1001; i++)
        {
            if ((int)(i * 0.08d) == a && (int)(i * 0.1d) == b)
            {
                Console.WriteLine(i);
                return;
            }
        }

        Console.WriteLine(-1);
    }
}

Measured memory_bytes: 13268
a = int(input())

if 400 <= a <= 599:
    print(8)
if 600 <= a <= 799:
    print(7)
if 800 <= a <= 999:
    print(6)
if 1000 <= a <= 1199:
    print(5)
if 1200 <= a <= 1399:
    print(4)
if 1400 <= a <= 1599:
    print(3)
if 1600 <= a <= 1799:
    print(2)
if 1800 <= a <= 1999:
    print(1)
    


Measured memory_bytes: 9184
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner kbd = new Scanner(System.in);
        int n = kbd.nextInt();
        int[] hotel = new int[n];
        for (int i = 0; i < n; i++) {
            hotel[i] = kbd.nextInt();
        }
        int cou = 0;
        for (int j = 0; j < n; j++) {
            if (j == 0) {
                cou++;
            } else {
                boolean flag = true;
                for (int k = j - 1; k >= 0; k--) {
                    if (hotel[j] < hotel[k]) {
                        flag = false;
                    }
                }
                if (flag) {
                    cou++;
                }
            }
        }
        System.out.println(cou);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}cout<<endl;}

int main() {
    ll n,m;
    cin>>n>>m;
    unordered_map<ll, ll> mm;
    rep(i, n) {
        ll k;
        cin >>k;
        vector<ll> v;
        rep(j, k) {
            ll t;
            cin >> t;
            mm[t]++;
        }
    }
    ll sum=0;
    for (auto it : mm) {
        if (it.second == n) {
            sum++;
        }
    }
    pr(sum);
    
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
const ll MOD=1e9+7;
const int INF = 0x3f3f3f3f;

int main(){
    ll n;
    cin>>n;
    ll ans=2;
    if(n==1){
    	cout<<1<<endl;
    	return 0;
	}
    else if(n==2){
    	cout<<3<<endl;
    	return 0;
	}else {
		ll cnt=0;
		while(n){
			cnt++;
			n/=2;
		}
		cnt-=1;
		while(cnt--){
			ans*=2;
		}
	}
	cout<<ans-1<<endl;
	return 0;
}
//2  3 
//3 1 1   
//4 2 2  1 1 1 1  7
//5 2 2 1 1 1 1
//6 3 3 1 1 1 1
//7 3 3 1  1 1 1
//8 4 4 2 22  2  1 1 1 1  15
//9 4 4 2 2  1 1  1 1
// 10 5 5 2 2 1 1 1 1 
// 11 
// 12 6 6 3 3 1 1  1 1
// 13 14 15 16 8 8 4 4 4 4 2 2 2 2 2 2 2 2  31
// 32 16 16 43


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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  
  long long p = 0;
  p += A[0] / 2;
  A[0] %= 2;
  for(int i = 1; i < N; i++){
    if(A[i - 1] > 0 && A[i] > 0){
      A[i]--;
      p++;
    }
    p += A[i] / 2;
    A[i] %= 2;
  }
  
  cout << p << endl;
  
  return 0;
}


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

int main() {
  int a,b,c,k,cnt = 0;
  cin >> a >> b >> c >> k;
  while(a >= b){
    b *= 2;
    cnt++;
  }
  while(b >= c){
    c *= 2;
    cnt++;
  }
  if(cnt <= k) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
    int x,a = 0;
    cin >> x;
    if(x >= 500) {
        a = x / 500;
        x %= 500;
    }
    int b = x / 5;
    cout << a * 1000 + b * 5 << endl;
}


Measured memory_bytes: 256