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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0);cout<<fixed<<setprecision(10); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}

#define pii pair<int,int>
#define ff first
#define ss second
#define endll '\n'
#define rep(i,n) for(int i=0;i++<n;)
#define scl(i) scanf("%lld",&i);
#define int long long int

signed main()
{
    int a,b,c,k;cin>>a>>b>>c>>k;

    int ans = 0;

    int xx = min(a,k);
    if(xx>=0)
    {
        ans+=xx;
        k -= xx;
    }
    xx = min(b,k);
    if(xx>=0)
    {
        ans+=0;
        k -= xx;
    }
    xx = min(c,k);
    if(xx>=0)
    {
        ans+=-1*(xx);
        k -= xx;
    }

    cout<<ans<<endll;


}


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

#define F first
#define S second
#define ll long long
#define int long long
#define pb push_back
#define ld long double

using namespace std ; 

const int N = 1001 * 1001  , MOD = 1e9 + 7 ; 

int32_t main()
{
	ios::sync_with_stdio(0) ;cin.tie(0) ; 
	int x , y ; 
	cin >> x >> y ; 
	if(x%y==0) return cout << -1 << endl , 0 ; 
	cout << x << endl ; 
}	

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

using ll = long long;

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

ll gcd(ll x, ll y) {
    if (x < y)
        std::swap(x, y);
    while (y > 0) {
        ll r = x % y;
        x = y;
        y = r;
    }
    return x;
}

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

ll A, B, D;

inline void Main() {
  // code
  cin >> A >> B;
  cout << prime_factor(gcd(A, B)).size() + 1 << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 105000000000

const int maxn = 1e5 + 10;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a,b; cin >> a>>b;

	if (a + b >= 10) Print("error");
	else Print(a + b);

	return 0;
	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int flag = 0;

void in_mal(int a_b[]);
void sum_i(int a[], int b[], int sum[]);

int main(void)
{
	int i, j, k;
	int n, show;
	int a[100], b[100], sum[100];
	
	scanf("%d", &n);
	while (n > 0){
		n--;
		show = 0;
		flag = 0;
		for (i = 0; i < 16; i++){
			a[i] = 0;
			b[i] = 0;
			sum[i] = 0;
		}
		
		in_mal(a);
		in_mal(b);
		sum_i(a, b, sum);
		
		if(flag == 1){
			printf("overflow\n");
			continue;
		}
		for (i = 0; i < 16; i++){
			if (sum[i] != 0 && !show){
				printf("%d", sum[i]);
				show = 1;
			}
			else if (show == 1){
				printf("%05d", sum[i]);
			}
		}
		if (sum[15] == 0 && !show)printf("0");
		printf("\n");
	}
	return (0);
}

void in_mal(int a_b[])
{
	char x[100];
	int i;
	int j;
	int len;
	
	scanf("%99s", x);
	len = strlen(x);
	if (len > 80){
		flag = 1;
		return;
	}
	for (i = 0; i < len; i++){
		j = 15;
		a_b[j] = a_b[j] * 10 + x[i] - '0';
		for (j = 0; j < 16; j++){
			if (j != 15)a_b[j] *= 10;
			if (a_b[j] >= 100000){
				a_b[j - 1] += a_b[j] / 100000;
				a_b[j] %= 100000;
				
			}
		}
	}
}

void sum_i(int a[], int b[], int sum[])
{
	int i, j;
	
	for (i = 15; i >= 0; i--){
		
		sum[i] += a[i] + b[i];
		if (sum[0] >= 100000){
			flag = 1;
			return;
		}
		for (j = 0; j < 16; j++){
			if (sum[j] >= 100000){
				sum[j - 1] += sum[j] / 100000;
				sum[j] %= 100000;
			}
		}
	}

}

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

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
constexpr char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

template <class T> T positive_mod(T p, T q){
  T tmp = p % q;
  if(tmp >= 0) return tmp;
  return q + tmp;
}

int main(void){
  int n; scanf("%d", &n);
  Vlli A(n), B(n);
  REP(i, n) scanf("\n%lld %lld", &A.at(i), &B.at(i));
  lli res = 0;
  rREP(i, n){
    A.at(i) += res;
    res += positive_mod( (B.at(i) - A.at(i)), B.at(i));
  }
  printf("%lld\n", res);
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
 
int main(void){
    // Your code here!
    
    int n;
    int ac=0;
    int wa=0;
    int tle=0;
    int re=0;

   char s[10];


scanf("%d",&n);
    

for(int i=0;i<n;i++){
     scanf("%s",s);
     
    switch (s[0]) {
	case 'A':
		ac++;
		break;
	case 'W':
		wa++;
		break;
	case 'T':
		tle++;
		break;
	case 'R':
	re++;
	break;
	default:
		printf("bug");
		break;
    }
}
printf("AC x %d\n",ac);
printf("WA x %d\n",wa);
printf("TLE x %d\n",tle);
printf("RE x %d",re);
 
  return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>

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

  if(n>=500){
      q=n/500;
      aux= n%500;
      printf("%d\n", q*1000+ 5*(aux/5) );
      return 0;
  }
  else{
    q=n/5;
    printf("%d\n", q*5);
  }
  return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication62
{
    class Program
    {
        static void Main()
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (a[0] + a[1] * 5 + a[2] * 10 + a[3] * 50 + a[4] * 100 + a[5] * 500 >= 1000)
            {
                Console.WriteLine(1);
            }
            else
            {
                Console.WriteLine(0);
            }
        }
    }
}

Measured memory_bytes: 9612
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(){
    long long x;
    cin >> x;

    int deg = 0;
    vector <int> revX;
    while (x > 0){
        int d = x % 10;
        revX.push_back(d);
        x = x / 10;
        deg++;
    }

    vector <int> X(deg);
    for (int i = 0; i < deg; i++){
        X[i] = revX[deg - i - 1];
    }
    
    long long ans = 0;
    if (deg == 1){
        ans = X[0];
    }else{
        int c = pow(2, deg - 1);
        int plus[c][deg - 1];

        for (int i = 0; i < c; i++){
            int num = i;
            for (int j = 0; j < deg - 1; j++){
                plus[i][j] = num % 2;
                num = num / 2;
            }
        }
        
        for (int i = 0; i < c; i++){
            long long sum = 0;

            long long reg = X[0];
            for (int j = 0; j < deg - 1; j++){
                if (plus[i][j] == 0){
                    reg = reg * 10 + X[j + 1];
                }else{
                    sum += reg;
                    reg = X[j + 1];
                }
            }
            if (reg != 0){
                sum += reg;
            }
            
            ans += sum;
        }
        
    }

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

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>

using namespace std;

const double EPS = 1e-4;
const double pi = 3.141592653589793;

int k;
int arr[100005];

bool valid(long long mid, bool flag)
{
    for (int i = 0; i < k; i++)
    {
        mid = mid / arr[i] * arr[i];
    }
    if (flag)
        return mid >= 2;
    else
        return mid <= 2;
}

bool check(long long c)
{
    for (int i = 0; i < k; i++)
        c = c / arr[i] * arr[i];
    return c == 2;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin >> k;
    for (int i = 0; i < k; i++)
        cin >> arr[i];

    long long l = 0, r = 1e18;
    while (l < r)
    {
        long long mid = l + (r - l) / 2;
        if (valid(mid, true))
            r = mid;
        else
            l = mid + 1;
    }

    if(!check(l))
    {
        cout << -1 << endl;
        return 0;
    }
    cout << l << ' ';
    l = 0, r = 1e18;
    while (l < r)
    {
        long long mid = l + (r - l + 1) / 2;
        if (valid(mid, false))
            l = mid;
        else
            r = mid - 1;
    }
    cout << l << endl;
}


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

int main() {
  double goalMoney, year;
  double startMoney = 100;
  cin >> goalMoney;
  while(true){
      year ++;
      startMoney = floor(startMoney) * 1.01;

      if (startMoney >= goalMoney){
          cout << int(year);
          break;
      }
  }
  return 0;
}

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

using namespace std;

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

deque<int> del_val(deque<int> &deq, int val){
  deque<int> new_deq;
  bool flag = true;

  while(!deq.empty()){
    if((deq.front() == val)&&(flag)){
      deq.pop_front();
      flag = false;
      continue;
    }
    new_deq.push_back(deq.front());
    deq.pop_front();
  }

  return new_deq;
}

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

  deque<int> deq;
  string command;

  int tmp;

  rep(i,N){
    cin >> command;

    if(command == "insert"){
      cin >> tmp;
      deq.push_front(tmp);
    }
    else if(command == "delete"){
      cin >> tmp;
      deq = del_val(deq, tmp);
    }
    else if(command == "deleteFirst"){
      deq.pop_front();
    }
    else if(command == "deleteLast"){
      deq.pop_back();
    }
  }

  while(!deq.empty()){
    cout << deq.front();
    deq.pop_front();
    if(!deq.empty()){
      cout << " ";
    }
    else{
      cout << endl;
    }
  }
}



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

using namespace std;
using ll = long long;
using ld = long double;

vector<ll> LvCountAll;
vector<ll> LvCountPutty;
ll result = 0;

void resolve(ll N, ll X){
    if(X <= 0){
        return;
    }
    if(X == LvCountAll[N]){
        result += LvCountPutty[N];
        return;
    }

    if(N == 1){
        if(X <= 1){
            return;
        }
        if(2 <= X && X <= 4){
            result += X -1;
            return;
        }
        result += 3;
        return;
    }
    if(LvCountAll[N-1] +1 >= X){
        resolve(N - 1, X-1);
        return;
    }
    if(LvCountAll[N-1] +2 == X){
        result += LvCountPutty[N-1] + 1;
        return;
    }
    else{
        ll Xnokori = X - (LvCountAll[N -1] + 2);
        result += LvCountPutty[N-1] + 1;
        resolve(N-1, Xnokori);
        return;
    }
}

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


    ll cAll = 1;
    ll cPutty = 1;
    for (int i = 0; i <= N; ++i) {
        if(i > 0){
            cAll = LvCountAll[i-1] * 2 + 3;
            cPutty = LvCountPutty[i-1] * 2 + 1;
        }
        LvCountAll.push_back(cAll);
        //cout << "cALL[" << i << "] = " << cAll << endl;
        LvCountPutty.push_back(cPutty);
        //cout << "cPutty[" << i << "] = " << cPutty << endl;
    }

    resolve(N, X);
    cout << result << endl;

    return 0;
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b;
	cin >> a >> b;
	
	if (b % a == 0) cout << a + b << endl;
	else cout << b - a << endl;
	
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)n; i++)
int main() {
  int n,cur_btn=0; cin>>n;
  int a[n];
  rep(i,n){
    cin>>a[i];
    a[i]--;
  }
  rep(i,n){
    if(cur_btn==1){
      cout<<i;
      return 0;
    }
    cur_btn=a[cur_btn];
  }
  cout<<-1;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<algorithm>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

int main() {

  int a, b, ret = 0;
  char op;
  scanf("%d %c %d", &a, &op, &b);

  if(op == '+') {
    ret = a + b;
  }
  else if(op == '-') {
    ret = a - b;
  }

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

  return 0;
}


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

#define pb push_back

#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 998244353ll;
const ll MAXN = (ll) 1e5 + 100;
const ll INF = (ll) 9223372036854775;
const ld EPS = (ld) 1e-8;

vector<ll> G[MAXN];
ll mk[MAXN];

ll node = -1;
void DFS(ll u){
	mk[u] = 1;
	for(auto adj : G[u]) if(mk[adj] == 0 and adj != node) DFS(adj);
	
}
map<ll,ll> mp;
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n, m;
	cin >> n >> m;
	ll u, v;
	for(int i = 0; i<m ;i++){
		cin >> u >> v;
		G[u].pb(v);
		G[v].pb(u);
	}
 	ll cm = 0;
 	for(int i = 1; i <= n;i++){
	 	if(G[i].size() == 0) continue;
		 if(mk[i] == 0){
		 	cm ++;
		 	DFS(i);
		 }
	 }
	 if(cm > 3) return cout << "No", 0;
	 ll mxd = 0;
	 
	 for(int i = 1; i<= n;i++){
	 	ll d = G[i].size();
	 	if(d % 2 == 1) return cout << "No", 0;
	 	mp[d] ++;
	 	mxd = max(mxd, d);
	 	if(d == 4) node = i;
	 }
	 if(mxd >= 6) return cout << "Yes", 0;
	 if(mp[4] > 2) return cout << "Yes", 0;
	 if(cm == 2){
	 	if(mxd == 2) return cout << "No", 0;
	 	return cout << "Yes", 0;
	 } 
	 if(mp[4] < 2) return cout << "No", 0;
	 memset(mk, 0, sizeof mk);
	
	cm = 0;
 	for(int i = 1; i <= n;i++){
	 	if(G[i].size() == 0) continue;
		 if(i == node) continue;
		 if(mk[i] == 0){
		 	cm ++;
		 	DFS(i);
		 }
	 } 
	 if(cm == 2) cout << "Yes";
	 else cout << "No";
	return 0;
}


/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/




Measured memory_bytes: 8576
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main(){
    
    string s;
    cin >> s;
    int n=(int)s.size();
    rep(i,n){
        if(i+1<n&&s[i]==s[i+1]){
            cout << i+1<<space<<i+2<<endl;
            break;
        }
        if(i+2<n&&s[i]==s[i+2]){
            cout << i+1<<space<<i+3<<endl;
            break;
        }
        if(i==n-1){
            cout << -1<<space<<-1<<endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 512
S = list(input())
S = [int(s) for s in S]
A = 753
res = []
index_a, index_b, index_c = 0, 1, 2


while index_c < len(S):
    X = (S[index_a] * 100) + (S[index_b] * 10) + S[index_c]
    temp = X - A
    res.append(abs(temp))
    index_a += 1
    index_b += 1
    index_c += 1

print(min(res))


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int length_chair=scan.nextInt();
        int length_sit=scan.nextInt();
        int pitch=scan.nextInt();
        System.out.println((length_chair-pitch)/(length_sit+pitch));

    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;

int main(){
	ll n, m, k; cin >> n >> m >> k;
	if (!k){
		cout << "Yes" << endl;
		return 0;
	}
	nrep(i, 1, n + 1) nrep(j, 1, m + 1){
		if (k == (i*j)+(n - i)*(m - j)){
			cout << "Yes" << endl;
			return 0;
		}
	}cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
const int M=100010;
int INF=1000000007;
using ll=long long;

int main(){
	int n,a[200010];
	ll l=0,r=0,ans=1e15;
	cin>>n;
	rep(i,0,n){
		cin>>a[i];
		r+=a[i];
	}
	rep(i,0,n-1){
		l+=a[i],r-=a[i];
		ans=min(ans,abs(l-r));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n,m;
	cin >> n >> m;
	vector<pair<int,int> >e(n-1+m);
	vector<int> in_degree(n,0);
	vector<vector<int> > adj(n);
	vector<int> parent(n,-1);

	for (int i = 0; i < n-1+m; i++)
	{
		cin >> e[i].first >> e[i].second;
	}

	for(int i = 0; i < n-1+m; i++){
		adj[e[i].first-1].push_back(e[i].second-1);
		in_degree[e[i].second-1]++;
	}

	int root =-1;
	for(int i = 0; i < n; i++){
		if(in_degree[i] == 0){
			root = i;
			break;
		}
	}

	parent[root] = 0;
	queue<int> que;
	que.push(root);
	while(!que.empty()){
		int now = que.front();
		que.pop();
		for(int i = 0; i < adj[now].size(); i++){
			if(parent[adj[now][i]]<0){
				if(in_degree[adj[now][i]] == 1){
					que.push(adj[now][i]);
					parent[adj[now][i]] = now+1;
				}else{
					in_degree[adj[now][i]]--;
				}
			}
		}
	}

	for(int i = 0; i < n; i++){
		cout << parent[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 7808
import itertools
H, W = [int(_) for _ in input().split()]
S = [input().split() for _ in range(H)]
for i, j in itertools.product(range(H), range(W)):
    if S[i][j] == 'snuke':
        print('ABCDEFGHIJKLMNOPQRSTUVWXYZ'[j]+str(i+1))
        exit()


Measured memory_bytes: 3060
# 0028
array = []
while True:
    try:
        a = input()
        if a == '': break
        array.append(int(a))
    except EOFError:
        break
s = set(array)
mx = max(list(map(lambda a: array.count(a), set(array))))
for a in sorted(s):
    if array.count(a) == mx:
        print(a)

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1000000000 //
#define LINF (ll)4000000000000000000 //
#define MOD (ll)1000000007
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

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

    if (n == 1 && m == 1) {
        cout << 1 << endl;
    } else if (n == 1) {
        cout << (m - 2) << endl;
    } else if (m == 1) {
        cout << (n - 2) << endl;
    } else {
        cout << (n - 2)*(m - 2) << endl;
    }
    return 0;
}



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

#define iFOR(idx, from, upto) for (int  idx = from; idx < upto; ++idx)
#define lFOR(idx, from, upto) for (long idx = from; idx < upto; ++idx)

#define ll long long

using namespace std;

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

    long q;
    cin >> q;

    int t, f;
    char c;
    bool rev = false;
    string head = "";
    string foot = "";

    lFOR(i, 0, q) {
        cin >> t;
        if (t == 2) {
            cin >> f >> c;
            if (--f == rev) {
                head = c + head;
            } else {
                foot += c;
            }
        } else {
            rev = !rev;
        }
    }

    s = head + s + foot;

    if (rev) reverse(s.begin(), s.end());

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 1360
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int N, A, B, C; 
vector<int> l;

int dfs(int n, int a, int b, int c, int cost, bool fa, bool fb, bool fc){
  if(n == N){
    if(fa && fb && fc) return abs(A-a)+abs(B-b)+abs(C-c)+cost-30;
    return INF;
  }

  int ret = INF;
  chmin(ret, dfs(n+1, a+l[n], b, c, cost+10, true, fb, fc));
  chmin(ret, dfs(n+1, a, b+l[n], c, cost+10, fa, true, fc));
  chmin(ret, dfs(n+1, a, b, c+l[n], cost+10, fa, fb, true));
  chmin(ret, dfs(n+1, a, b, c, cost, fa, fb, fc));

  return ret;
}

signed main() {
  cin >> N >> A >> B >> C;

  l.resize(N);
  REP(i, N) cin >> l[i];

  cout << dfs(0, 0, 0, 0, 0, false, false, false) << "\n";

  return 0;
}

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

int main() {
    int N;
    cin >> N;
    int ans=0;

    for(int i=1; i<=N; i++){
         int cnt=0;
          int w=i;
        while(w){
            w /= 10;
            cnt++;
        }
        if(cnt%2){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            long[] A = in.Long(N);

            for (int i = 0; i < N; i++) {
                if (A[i] == 0) {
                    out.println(0);
                    return;
                }
            }

            BigInteger max = BigInteger.valueOf((long) 1e18);

            BigInteger a = BigInteger.ONE;
            for (int i = 0; i < N; i++) {
                a = a.multiply(BigInteger.valueOf(A[i]));
                if (a.compareTo(max) > 0) {
                    out.println(-1);
                    return;
                }
            }
            out.println(a.toString());
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

        public long Long() {
            return Long.parseLong(next());
        }

        public long[] Long(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = Long();
            }
            return a;
        }

    }
}



Measured memory_bytes: 49224
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  ll N;
  cin>>N;
  char a[N];
  string s;
  for(ll i = 0;i<N;i++){
    cin>>a[i];
  }
  cin >> s;
  string p;
  ll k = 0;
  while(k<N){
    if(a[k] == a[k+1]){
      p += 'a';
      k += 2;
    }
    else{
      p += 'b';
      k++;
    }
  }
  ll ans;
  if(p.at(0) == 'a'){
    ans = 6;
  }
  else{
    ans = 3;
  }
  for(ll i = 1;i<p.size();i++){
    if(p.at(i-1) == 'a' && p.at(i) == 'b'){
      ans = ans;
    }
    else if(p.at(i-1) == 'a' && p.at(i) == 'a'){
      ans*= 3;
    }
    else{
      ans *= 2;
    }
    ans = ans%MOD;
  }
  cout << ans%MOD << endl;
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());

  string t;
  cin >> t;
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

  if(s < t){
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
/*@shutoshsuman99*/
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define pi 3.141592653589
#define pb push_back
#define ld long double
#define rem 1000000007
#define rem1 998244353
#define inf 1e18+1e17
#define F first
#define S second
#define pii pair<long long,long long>
#define p_q priority_queue <ll, vector<ll>, greater<ll> >
#define m_sp multiset <pair <ll,ll> > 
#define el "\n"
#define sp " "
typedef long long ll;
ll Pow(ll x,ll y,ll m) 
{ if (y == 0) return 1; ll p = Pow(x, y/2, m) % m; 
p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m; } 
main()
{ 
	// fast io
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);ll i; 
	ll a,p;
	cin>>a>>p;
	ll cnt=3*a+p;
	cout<<cnt/2<<el;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int    N, i, AA;
  double M, A[1001], c;
  
  c=0; AA=0;
  scanf("%d%lf",&N,&M);
  for(i=0; i<N; i++){
    scanf("%lf",&A[i]);
    AA=AA+A[i];
  }
  for(i=0; i<N; i++)
    if(A[i]>=AA/(4*M))
      c++;
  if(c>=M)
    printf("Yes\n");
  else
    printf("No\n");
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"I=lambda:map(int,input().split());n,m,c=I();*b,=I();print(eval('+(-c<sum(x*y for x,y in zip(I(),b)))'*n))\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=1;i<=n;i++)
#define ld long double
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
int n;
ll a[100],k=0;
ll lim;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	lim=n;
	for (int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	while (a[n]>=n){
		ll t=a[n]/n;
		k+=t;
		a[n]%=n;
		rep(i,n-1) a[i]+=t;
		sort(a+1,a+n+1);
	}
	cout<<k;
}

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


struct Edge {
    int to, cost;

};
typedef vector<vector<Edge> > AdjList;  // 隣接リストの型
AdjList graph;

const int INF = 1000000;

vector<int> dist;


bool bellman_ford(int n, int s){
    dist = vector<int>(n,INF);
    dist[s] = 0;
    for(int i=0;i<n;i++){
        for(int v=0;v<n;v++){
            for(int k=0;k<graph[v].size();k++){
                Edge e = graph[v][k];
                if(dist[v] != INF && dist[e.to] > dist[v] + e.cost){
                    dist[e.to] = dist[v] + e.cost;
                    if(i == n-1) return true;
                }
            }
        }
    }
    return false;
}

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

    graph = AdjList(n);

    for(int i=0;i<m;i++){
        int from, to, cost;
        cin >> from >> to >> cost;
        graph[from].push_back((Edge){to,cost});
    }
    bool negative;
    negative = bellman_ford(n,r);
    if(negative){
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
    for (int i = 0; i < n; i++){
       if(dist[i] == INF) cout << "INF" << endl;
       else cout << dist[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3184
#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() {
    string S;
    cin >> S;
    int N = S.size();
    for (int i = 1; i * 2 < N; ++i) {
        S.erase(S.size() - 2);
        string front = S.substr(0, S.size()/2);
        string rear = S.substr(S.size()/2);
        if (front == rear) {
            cout << S.size() << endl;
            return 0;
        }
    }
}



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

int main() {
	int r, D, X;
	cin >> r >> D >> X;

	int x = X;
	for (int i = 0; i < 10; i++) {
		x = r * x - D;
		cout << x << endl;
	}



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int A[10010] = {}; 
	for(int i = 1; i < 10000; i++){
		A[i] = i * (i + 1) / 2; 
	}
	int N; 
	cin >> N; 
	int K = lower_bound(A, A + 10000, N) - A; 
	int missing = A[K] - N; 
	for(int i = 1; i <= K; i++){
		if(i == missing) continue; 
		cout << i << endl; 
	}
}

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

int main()
{
   for (int i = 1; ; i++) {
   int x,y;
   cin >> x >> y;
   if (x == 0 && y == 0)
    break;
   if (x > y) {
   int t = x;
   x = y;
   y = t;
  }
  cout << x << ' ' << y << endl;
  }
}

Measured memory_bytes: 3020
h, w = 1, 1

dataset = []
while not(h == w == 0):
    h, w = map(int, input().split())
    dataset.append([h, w])

for n, data in enumerate(dataset):
    h, w = data[0], data[1]
    for i in range(h):
        for j in range(w):
            print("#", end="")
        print("")
    if n!=len(dataset)-1:
        print("")


Measured memory_bytes: 7016
#include <bits/stdc++.h>
#define rint register int
#define fo(i, n) for(rint i = 1; i <= (n); i ++)
#define out(x) cerr << #x << " = " << x << "\n"
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); ++ it)
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
  x = 0;char c = getchar(); bool f = 0;
  for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}
const int N = 3e5 + 233;
const int M = N;
struct Edge {
  int nxt, to;
}e[M << 1];
int head[N], e_cnt = 1;
int n, m;
int s[N], t[N], cnt[N], vis[N], opt[N];
vector<int> edges[N], querys[N];

inline void add(int u, int v) {
  e[++ e_cnt] = (Edge) {head[u], v}; head[u] = e_cnt;
}

inline int dfs(int u, int fat, int t, vector<int> &vec) {
  if(u == t) return 1;
  for(int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if(v != fat && dfs(v, u, t, vec)) {
      ++ cnt[i >> 1];
      vec.push_back(i);
      return 1;
    }
  }
  return 0;
}

inline void doit(void) {
  while(true) {
    int e = 0;
    for(int i = 1; i <= n - 1; i ++) {
      if(cnt[i] == 1 && (opt[i << 1] ^ opt[i << 1 | 1])) {
        if(opt[i << 1]) e = i << 1 | 1;
        else e = i << 1;
        break;
      }
    }
    if(!e) {
      for(int i = 1; i <= n - 1; i ++) {
        if(cnt[i] >= 2) {
          e = i << 1; break;
        }
      }
    }
    if(!e) return ;
    while(vis[querys[e / 2].back()])
      querys[e / 2].pop_back();
    int q = querys[e / 2].back();
    vis[q] = true;
    for(int i: edges[q]) {
      if((i ^ e) == 1) {
        swap(s[q], t[q]);
        for(int &t: edges[q])
          t ^= 1;
        break;
      }
    }
    for(int i: edges[q])
      opt[i] = true, -- cnt[i >> 1];
  }
}

main(void) {
  read(n); read(m);
  for(int i = 1; i <= n - 1; i ++) {
    int x, y; read(x); read(y);
    add(x, y); add(y, x);
  }
  for(int i = 1; i <= m; i ++) {
    read(s[i]); read(t[i]);
    dfs(s[i], 0, t[i], edges[i]);
    for(auto v: edges[i]) {
      querys[v / 2].push_back(i);
    }
  }
  int ans = 0;
  for(int i = 1; i <= n - 1; i ++)
    ans += min(cnt[i], 2);
  cout << ans << "\n";
  doit();
  for(int i = 1; i <= m; i ++) {
    cout << s[i] << " " << t[i] << "\n";
  }
}


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

int main()
{
    int n;
    double x,ans=0;
    cin>>n;
    double a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    ans=a[0];
    for(int i=1;i<n;i++)
    {
        ans=(ans/2)+(a[i]/2);
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp make_pair
#define pb push_back
#define fp first
#define sp second
typedef long long int ll;
typedef pair<ll,ll> pp;
#define check(x, i) ((x>>i)&1LL)
#define set(x,i) (x|(1LL<<i))
#define unset(x,i) (x&~(1LL<<i))
#define INF LONG_MAX
#define MAX_N 20
#define MAX 4000005
#define mod 1000000007
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define len(i,s) for(i=0;s[i];i++)
#define T() ll t;cin>>t;while(t--)
ll gcd (ll a, ll b){return (a?gcd(b%a,a):b);}
ll pow1(ll a,ll b,ll MOD){ll ans=1;while(b!=0){if(b&1)ans=(ans*a)%MOD;a=(a*a)%MOD;b=b/2;}return ans;}
ll modInverse(ll a,ll p){return pow1(a,p-2,p);}
 
int main()
{
  boost
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);    
    freopen("output.txt", "w", stdout);
#endif

  ll a;
  long double b;
  cin>>a>>b;
  cout<<(ll)(a*b)<<"\n";
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 			1000000007
#define tc(t) 			int t;cin >> t;while(t--)
#define for0(i , n)		for(int i=0;i<n;i++)
#define loop(i , a, b)	for(int i=a;i<=b;i++)
#define endl 			'\n'
#define inf 			1e18
#define fi 				first
#define se 				second

int XX[8]={+1, +1, +1, 0, 0, -1, -1, -1};
int YY[8]={+1, 0, -1, +1, -1, +1, 0, -1};
int dx[4]={-1,1,0,0};
int dy[4]={0,0,1,-1};


signed main() {

	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif

	int x,k,d;
	cin>>x>>k>>d;

	x=abs(x);

	if(x/d >= k){
		cout<< x-d*k;
	}else{
		if((k-(x/d))%2==0){
			cout<<x%d<<endl;
		}else{
			cout<<d-(x%d)<<endl;
		}
	}


	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 10;

int p[N],c[N],s[N];

int main() {
	int d,g;cin>>d>>g;
	rep(i,d){cin>>p[i]>>c[i];s[i]=p[i]*(i+1)*100+c[i];}
	int ans=INF;
	rep(i,1<<d){
		bool f[N];
		int j=i;
		rep(k,d){
			if(j%2==1) f[k]=true;
			else f[k]=false;
			j/=2;
		}
		int ss=0,sn=0;;
		rep(k,d) if(f[k]) {ss+=s[k];sn+=p[k];}
		if(ss>=g) {ans=min(ans,sn);continue;}
		j=-1;
		for(int k=d-1;k>=0;k--) if(!f[k]) {j=k;break;}
		if(j!=-1){
			int dn=(g-ss-1)/(100*(j+1))+1;
			if(ss+(j+1)*dn*100>=g&&dn<=p[j]-1) ans=min(ans,sn+dn);
		}
	}
	cout<<ans<<endl;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define pb push_back

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

void solve() {

}

int main() {
  int n;
  cin >> n;
  int sum = 0;
  map<string,int> mp;
  string pre = "";
  rep(i,n) {
    string s;
    int v;
    cin >> s >> v;
    sum += v;

    if( !pre.empty() ) {
      v += mp[pre];
    }
    mp[s] = v;
    pre = s;
  }
  string x;
  cin >> x;
  cout << ( sum - mp[x] ) << endl;
  return 0;
}


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

int main() {
    int n,m,l;
    cin >> n >> m >> l;
    if(max(n,max(m,l)) == l) cout << (l-max(n,m)+abs(m-n));
    else if(max(n,max(m,l)) == m) cout << (m-max(n,l)+abs(l-n));
    else if(max(n,max(m,l)) == n) cout << (n-max(l,m)+abs(m-l));
    return 0;
}

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

int n;
bool check[35];
int res;
int grundy;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int x; cin >> x;
		grundy ^= x;
		int last = (x & -x);
		last = (int)log2(last);
		check[last] = 1;
	}

	for (int i = 30; i >= 0; --i) {
		int b = (grundy >> i) & 1;
		if (b) {
			if (!check[i]) return printf("-1\n"), 0;
			else {
				++res; grundy ^= ((1 << i) - 1);
			}
		}
	}

	cout << res << endl;
}

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

int main() {
  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;
  
  int nab = 0, nb = 0;
  vector<bool> ok(n,false);
  
  rep(i,n) {
    if (s[i] == 'a' && nab < a+b) {
      ok[i] = true;
      nab++;
    }
    if (s[i] == 'b' && nab < a+b && nb < b) {
      ok[i] = true;
      nab++;
      nb++;
    }
  }
  
  rep(i,n) {
    if (ok[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 896
import java.util.*;
class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    void run(){
	int s = sc.nextInt();
	String ans="";
	int a=0;
	while(s>=3600){
	    s -= 3600;
	    a++;
	}
	ans += Integer.toString(a)+":";
	a = 0;
	while(s>=60){
	    s -= 60;
	    a++;
	}
	ans += Integer.toString(a)+":";
	ans += Integer.toString(s);
	System.out.println(ans);
    }
}

Measured memory_bytes: 17308
package main

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

func main() {
	X, Y := ReadInt(), ReadInt()
	a := (2*Y - X) / 3
	b := (2*X - Y) / 3
	if a < 0 || b < 0 || (2*Y-X)%3 != 0 || (2*X-Y)%3 != 0 {
		fmt.Println(0)
		return
	}
	fmt.Println(ModCombination(a+b, a))
}

const Mod = int(1e9) + 7

func ModCombination(n, k int) int { return fac[n] * (finv[k] * finv[n-k] % Mod) % Mod }

var fac, finv, inv []int

func init() {
	const MAX = 1e6
	fac, finv, inv = make([]int, MAX+1), make([]int, MAX+1), make([]int, MAX+1)
	fac[0], fac[1], finv[0], finv[1], inv[1] = 1, 1, 1, 1, 1
	for i := 2; i <= MAX; i++ {
		fac[i] = fac[i-1] * i % Mod
		inv[i] = Mod - inv[Mod%i]*(Mod/i)%Mod
		finv[i] = finv[i-1] * inv[i] % Mod
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 26188
package main

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

func main() {
	var x int
	var y int

	fmt.Scan(&x)
	fmt.Scan(&y)

	rr := make([]string, x, x)

	scanner := bufio.NewScanner(os.Stdin)

	i := 0
	for scanner.Scan() {
		rr[i] = scanner.Text()
		i++
		if x == i {
			break
		}
	}

	for _, r := range rr {
		fmt.Println(r)
		fmt.Println(r)
	}
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>

int calc(std::vector<std::vector<char> >&v, int sx, int sy){

	v[sx][sy] = '#';

	int res = 1;
	if (sx - 1 >= 0 && v[sx - 1][sy] == '.')res += calc(v, sx - 1, sy);
	if (sx + 1 < v.size() && v[sx + 1][sy] == '.')res += calc(v, sx + 1, sy);
	if (sy - 1 >= 0 && v[sx][sy - 1] == '.')res += calc(v, sx, sy - 1);
	if (sy + 1 < v[sx].size() && v[sx][sy + 1] == '.')res += calc(v, sx, sy + 1);

	return res;

}

int main(){

	int w, h;
	while (std::cin >> w >> h){
		if (w == 0 && h == 0)break;

		std::vector<std::vector<char> >v(h, std::vector<char>(w));

		int sx, sy;
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				std::cin >> v[i][j];
				if (v[i][j] == '@')sx = i, sy = j;
			}
		}

		std::cout << calc(v, sx, sy) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1240
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

x = inp[0]
ans = 0
ans += x/500*1000
x %= 500
p ans + x/5*5


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

int main() {
  string s;
  cin>>s;
  bool ok=true;
  for(int i=0;i<s.size();i+=2){
    if(s[i]!='R'&& s[i]!='U'&& s[i]!='D')ok=false;
  }
  
  for(int i=1;i<s.size();i+=2){
    if(s[i]!='L'&& s[i]!='U'&& s[i]!='D')ok=false;
  }
  
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
    
}


Measured memory_bytes: 256