akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        // 主処理
        int red = s.length() - s.replace("0", "").length();
        int blue = s.length() - s.replace("1", "").length();
        int result = Math.min(red, blue) * 2;

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 34668
L,R = map(int,input().split())
m = 2019
sa = R//m - L//m
if sa == 0:
  ans = float("inf")
  for i in range(L,R+1):
    for j in range(i+1,R+1):
      ans = min(ans,i*j%m)
  print(ans)
if sa >= 1:
  print(0)  

Measured memory_bytes: 3060
import sys

n , total = map(int,input().split())
t = 0
k = 0

for t in range(n + 1):
    for k in range(n + 1):
        x = t + k
        if x == n:
            if 2*t + 4*k == total:
                print("Yes")
                sys.exit()
print("No")
            

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first 
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()

const int N = 1e5 + 5;

void solve()
{
	string input;
	cin >> input;
	if(input == "Sunny") cout << "Cloudy";
	else if(input == "Cloudy") cout << "Rainy";
	else cout << "Sunny" << endl; 
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif
	solve();
	return 0;
}          

Measured memory_bytes: 256
N,M=map(int,input().split())
a=[0 for i in range(M)]
b=[0 for i in range(M)]
for i in range(M):
    a[i],b[i]=map(int,input().split())
    a[i]-=1
    b[i]-=1
X=[0 for i in range(N)]
for i in range(M):
    X[a[i]]+=1
    X[b[i]]+=1
for i in range(N):
    if X[i]%2==1:
        print("NO")
        exit()
print("YES")


Measured memory_bytes: 11844
import sys
import numpy as np

N = sys.stdin.readline()
a = np.fromstring(sys.stdin.readline(), dtype='i4', sep=' ')
a.sort()
p = a[a <= 0]
q = a[a > 0]

if len(p) == 0:
    print(np.sum(q[1:]) - q[0])
    t = q[0]
    for c in q[1:-1]:
        print(str(t) + ' ' + str(c))
        t -= c
    print(str(q[-1]) + ' ' + str(t))
elif len(q) == 0:
    print(p[-1] - np.sum(p[:-1]))
    t = p[-1]
    for c in p[:-1]:
        print(str(t) + ' ' + str(c))
        t -= c
else:
    print(sum(q) - sum(p))
    t = p[0]
    for c in q[:-1]:
        print(str(t) + ' ' + str(c))
        t -= c
    print(str(q[-1]) + ' ' + str(t))
    t = q[-1] - t
    for c in p[1:]:
        print(str(t) + ' ' + str(c))
        t -= c

Measured memory_bytes: 15960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (1e9)

int search(int A[], int n, int key) {
  int left = 0, right = n;
  while(left < right) {
    int mid = (left + right) / 2;
    if(A[mid] == key) return 1;
    
    if(A[mid] > key) {
      right = mid;
    } else {
      left = mid + 1;
    }
  } 
  return 0;
}

int main() {
  int n, S[1000000], sum; cin >> n;
  sum = 0;
  for(int i = 0; i < n; i++) cin >> S[i];
  int q, tmp; cin >> q;
  for(int i = 0; i < q; i++) {
    cin >> tmp;
    sum += search(S, n, tmp);
  }

  cout << sum << endl;

  return 0;
}


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

int main(){
    long N, K;
    cin >> N >> K;
    long ans1 = N % K;
    long ans2 = -1 * (ans1 - K);
    if(ans1 > ans2) cout << ans2 << endl;
    else cout << ans1 << endl;
}

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

int main()
{
    int m, f, r;
    while(1)
    {
        cin >> m >> f >> r;
        
        if(m == -1 && f == -1 && r == -1)
            break;
        else if (m == -1 || f == -1)
            cout << 'F' << endl;
        else if(m + f >= 80)
            cout << 'A' << endl;
        else if(m + f >= 65 && m + f < 80)
            cout << 'B' << endl;
        else if(m + f >= 50 && m + f < 65)
            cout << 'C' << endl;
        else if(m + f >= 30 && m + f < 50 && r >= 50)
            cout << 'C' << endl;
        else if(m + f >= 30 && m + f < 50)
            cout << 'D' << endl;
        else
            cout << 'F' << endl;
    }
}


Measured memory_bytes: 3088
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val M = sc.next().toInt()
        val AB = Array(N) { Pair(sc.next().toLong(), sc.next().toLong()) }
        val CD = Array(M) { Pair(sc.next().toLong(), sc.next().toLong()) }

        AB.forEach { ab ->
            val a = ab.first
            val b = ab.second
            var min = Long.MAX_VALUE
            var ans = -1
            for (j in CD.indices) {
                val c = CD[j].first
                val d = CD[j].second
                val distance = Math.abs(a - c) + Math.abs(b - d)
                if (min > distance) {
                    min = distance
                    ans = j
                }
            }
            pw.println(ans + 1)
        }
    }
}


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

using namespace std;
using ll = long long;

#define ist istream_iterator
#define ost ostream_iterator

ll const inf = 100 * 1000;
int const N = (1 << 17) + 16;


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

  int a, b, c;
  cin >> a >> b >> c;

  cout << ((c >= a && c <= b) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);
        int k = int.Parse(input[3]);
        int sum = 0;
        int remain = k;
        if(a >= k) {
            Console.WriteLine(k);
            return;
        }
        else if(a != 0){
            sum += a;
            remain -= a;
        }
        if(b >= remain){
            Console.WriteLine(sum);
            return;
        }
        else if(b != 0){    
            remain -= b;
        }
        
        sum -= remain;
        Console.WriteLine(sum);
	}
}

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

using int64 = int64_t;

int64 GCD(int64 a, int64 b) {
	while(b != 0) {
		int64 r = a % b;
		a = b;
		b = r;
	}
	return a;
}

int64 LCM(int64 a, int64 b) {
	return a * b / GCD(a, b);
}

int main() {
	int N, M;
	std::cin >> N >> M;

	std::string S, T;
	std::cin >> S;
	std::cin >> T;

	const int64 L = LCM(N, M);
	const int64 gcd = GCD(N, M);

	const int64 dt = L / gcd;
	const int64 dn = L / N;
	const int64 dm = L / M;

	std::string answer = std::to_string(L);
	for(int i = 0; i < gcd; i++) {
		if(S[dt * i / dn] != T[dt * i / dm]) {
			answer = "-1";
		}
	}

	std::cout << answer << std::endl;

	return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,k,nb=0;
    int T[100000];
    cin>>n;
    cin>>k;
    for(int i=0;i<n;i++)
    {
    cin>>T[i];
    if (T[i]>=k)
            nb++;

    }
    cout<<nb;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int s=0;
	for(int i=1;i<=n;i++){
		int a,b;
		cin>>a>>b;
		s+=b-a+1;
	}
	cout<<s<<endl;
	return 0;
}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

const ll MOD = 1000000007;
vector<VI> G;
int N, K;
bool b;

ll dfs(int v, int k, int prev) {
    ll ans = k;
    int c = max(K - 2, k - 1);
    for (int i : G[v]) {
        if (i == prev) continue;
        if (c == 0) {
            return 0;
            b = true;
        }
        ll a = dfs(i, c--, v);
        ans = (ans * a) % MOD;
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> N >> K;
    G.assign(N+2, VI());
    REP(i, N-1) {
        int x, y;
        cin >> x >> y;
        G[x].pb(y);
        G[y].pb(x);
    }
    if (b) cout << 0 << endl;
    else cout << dfs(1, K, -1) << endl;
}

Measured memory_bytes: 11648
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  int d;
  cin >> d;
  int y=2*d+1;
  cout << (n-1)/y+1 << endl;
}  


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
main(){
  double x1,y1,x2,y2;
  scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
  printf("%f\n",hypot(x1-x2,y1-y2));
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> Rain(2*n,0);
  for (int i=0; i<n; i++) {
    cin >> Rain[i];
    Rain[i+n] = Rain[i];
  }
  
  int m = 0;
  int sgn = -1;
  for (int i=0; i<n; i++) {
    sgn *= -1;
    m += sgn * Rain[i];
  }
  cout << m << endl;
  for (int i=1; i<n; i++) {
    m = 2 * Rain[i-1] - m;
    cout << m << endl;
  }
}

Measured memory_bytes: 2048
#include <iostream>
using namespace std;
int main(){
  char b;
  cin >> b;
  switch(b)
  {
    case 'A':cout << 'T';break;
    case 'C':cout << 'G';break;
    case 'G':cout << 'C';break;
    case 'T':cout << 'A';break;
  }
}

Measured memory_bytes: 3536
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>
#include <numeric>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);j++)
#define frk(n) for(k=0;k<(n);k++)
#define frl(n) for(l=0;l<(n);l++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vvvd vector<vector<vector<double>>>


#define int long long

using namespace std;


const int MAX = 510000;

ll mod_inverse(int a,int M){
	int x=M-2;
	ll temp=a;
	ll ret=1;
	//a^(MOD-1)==1(mod MOD)を利用
	//a^-1==a^(MOD-2) (mod MOD)を繰り返し二乗法で求める

	while(x!=0){
		if(x%2==1){
			ret=(ret*temp)%M;
		}
		temp=(temp*temp)%M;
		x=x/2;
	}
	return ret;
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int 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;
	}
}

// 二項係数計算
long long COM(int n, int k){
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed compare_int(const void *a, const void *b)
{
	int *A = (int *)a;
	int *B = (int *)b;
	if (*A < *B) return 1;
	if (*A > *B) return -1;
	return 0;
}


int gcd(int a,int b){
	while(1==1){
		if(a==0||b==0){
			return a+b;
		}else if(a>b){
			a %= b;
		}else{
			b %= a;
		}
	}
}

signed main(void)
{
	//変数の宣言
	int n,m,q;
	int h,w;
	static int a[100010];
	static int s[100010];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	vector<int> vec;
	vector<int> vtemp;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	static char stemp[100010];
	vvi graph;

	//データの読み込み


	scanf("%lld",&n);
	//scanf_s("%lld",&n);


	//scanf("%s",&s);
	//scanf_s("%s",&s,200010);


	/*for(i=0;i<n;i++){
	//scanf("%d",&a[i]);
	scanf_s("%d",&a[i]);
	}

	for(i=0;i<q;i++){
	//scanf("%d",&s[i]);
	scanf_s("%d",&s[i]);
	}*/



	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	//	clock_t start=clock();
	//	COMinit();

	for(i=0;i<=n;i++){
		if(i%3!=0 && i%5!=0){
			ans += i;
		}
	}

	printf("%lld",ans);

	//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力

	//printf("%d",(d[i-1][j-1]+1)/2);

	//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define emp emplace

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 3010;
double pd[N][N];
double p[N];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%lf", p+i);
	for (int j = (n+1)/2; j < N; j++)
		pd[n][j] = 1.;
	for(int i = n-1; i >= 0; i--)
	{
		for (int j = 0; j < (n+1)/2; j++)
			pd[i][j] = p[i] * pd[i+1][j+1] + (1. - p[i]) * pd[i+1][j];
		for (int j = (n+1)/2; j < N; j++)
			pd[i][j] = 1.;
	}
	printf("%.15lf\n", pd[0][0]);
	return 0;
}



Measured memory_bytes: 70784
from collections import defaultdict
N,M=map(int, raw_input().split())
p=map(int, raw_input().split())

#print "p:",p

a = []
for i in range(M):
	x,y=map(int,raw_input().split())
	if x<=y: a.append((x-1,y-1))
	else: a.append((y-1,x-1))

a=sorted(a, key=lambda x: x[0])


#Union Find
par=[ i for i in range(N) ]

def root(x):
	if par[x]==x:
		return x
	else:
		r=root(par[x])
		par[x]=r
		return r

def same(x,y):
	return root(x)==root(y)


def unite(x,y):
	x=root(x)
	y=root(y)
	if x==y:
		return
	elif x<=y:
		par[y]=x
	else:
		par[x]=y


for x,y in a:
	if not same(x,y):
		unite(x,y)


ans=0
for idx,i in enumerate(p):
	if same(idx,i-1):
		ans+=1
print ans


 

Measured memory_bytes: 56044
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,l;cin>>n>>l;
  int sum=0;
  for(int i=0;i<n;i++){
    sum+=i+l;
  }
  int k=0;
  for(int i=0;i<n;i++){
    if(abs(k+l)>abs(i+l))k=i;
  }
  cout<<sum-k-l<<endl;
}

Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), N = ip[0], K = ip[1];
	auto h = N.iota.map!(_ => ri).array;
	h.sort();
	int res = int.max;
	foreach(i; 0..N-K+1) {
		res = min(res, h[i+K-1] - h[i]);
	}
	res.writeln;
}

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

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 3452
#include<bits/stdc++.h>
using namespace std;
class Dice{
  private:

  vector<int> num;

  public:

  Dice(vector<int> input):num(input){};

  void operate(int cmd){
    vector<int>ret = num;
    if(cmd == 0){ //E方向
      ret[0] = num[3]; 
      ret[2] = num[0]; 
      ret[5] = num[2]; 
      ret[3] = num[5]; 
    }
    if(cmd == 1){ // N方向
      ret[0] = num[1];
      ret[1] = num[5];
      ret[5] = num[4];
      ret[4] = num[0];
    }
    if(cmd == 2){// S方向
      ret[1] = num[0];
      ret[5] = num[1];
      ret[4] = num[5];
      ret[0] = num[4];
    }
    if(cmd == 3){ // W方向
      ret[3] = num[0]; 
      ret[0] = num[2]; 
      ret[2] = num[5]; 
      ret[5] = num[3]; 
    }
    num = ret;
  }
  static int dir(char c){
    if(c == 'E')return 0;
    if(c == 'N')return 1;
    if(c == 'S')return 2;
    if(c == 'W')return 3;
  }
  int top(){
    return num[0];
  }
  void print(){
    for(int i = 0; i < 6; i++){
      cout << num[i] << " ";
    }
    cout << endl;
  }
  vector<int> nums(){
    return num;
  }
  using F = function<bool(vector<int>)>;
  vector<int> search(const F &check){
    int limit = 1;
    for(int i = 0; i < 4; i++)limit *= 4;
    for(int i = 0; i < limit; i++){
      vector<int>cmd_num(4);
      int n = i;
      for(int j = 0; j < 4; j++){
        cmd_num[j] = n % 4;
        n >>= 2;
      }
      Dice copy = *this;
      for(int j = 0; j < 4; j++){
        for(int k = 0; k < cmd_num[j]; k++){
          copy.operate(j);
        }
      }
      if(check(copy.nums()))return copy.nums();
    }
    return vector<int>();
  }
  bool equals(Dice d){
    return !(this->search(
      [&](vector<int>dnum){return dnum == d.nums();})
      ).empty();
  }
};

int main(){
  vector<int>a(6), b(6);
  for(int i = 0; i < 6; i++)cin >> a[i];
  for(int i = 0; i < 6; i++)cin >> b[i];
  Dice d1(a),d2(b);
  if(d1.equals(d2))cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

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

int main()
{
    ll i,j;
    ll ans = 0;
    ll max_number = 1e7;
    vector<ll> era(max_number+1, 2);
    era.at(0) = 1;  era.at(1) = 1;
    for(i = 2;i <= max_number;++i){
        for(j = 2*i;j <= max_number;j += i){
            ++era.at(j);
        }
    }
    ll n;
    cin >> n;
    for(i = 1;i <= n;++i){
        ans += i*era.at(i);   
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 81216
n, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0] * 2501 for _ in range(n + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1

for i in range(n):
    for j in range(i + 1):
        for k in range(2451):
            dp[i + 1][j][k] += dp[i][j][k]
            dp[i + 1][j + 1][k + x[i]] += dp[i][j][k]

ans = 0
for j in range(1, n + 1):
    ans += dp[n][j][j * a]

print(ans)

Measured memory_bytes: 92224
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, cnt=0;
  cin >> N;
  for(int i=1;i<=N;i++) {
    if(i%2==1) cnt++;
  }
  cout << cnt*1.0/N << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> xl;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        xl.emplace_back(a,b);
    }
    sort(xl.begin(),xl.end());
    int right = xl[0].first+xl[0].second;
    int cnt = 0;
    rep(i,n-1){
        int nleft =xl[i+1].first-xl[i+1].second;
        int nright = xl[i+1].first+xl[i+1].second;
        if(right >= nright){
            cnt++;
            right = nright;
        }else if(nleft < right){
            cnt++;
        }else{
            right = nright;
        }
    }
    cout << n-cnt <<endl;
}


Measured memory_bytes: 1400
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;
import java.util.HashSet;
import java.util.Iterator;
import java.util.PriorityQueue;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Dish> list = new ArrayList<Dish>(N);
        for (int i = 0; i < N; i++) {
            list.add(new Dish(sc.nextInt(), sc.nextInt()));
        }
        list.sort((a, b) -> {
            return b.sum - a.sum;
        });
        long ans = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                ans += list.get(i).a;
            } else {
                ans -= list.get(i).b;
            }
        }
        System.out.println(ans);
    }
}

class Dish {
    int a;
    int b;
    int sum;

    Dish(int a, int b) {
        this.a = a;
        this.b = b;
        sum = a + b;
    }
}

Measured memory_bytes: 88136
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int ans = 0;
		boolean[] sunuke = new boolean[N];
		for(int i = 0;i < K;i++){
			int d = sc.nextInt();
			for(int j = 0;j < d;j++){
				int A = sc.nextInt() - 1;
				sunuke[A] = true;
				
			}
		}
		for(int i = 0;i < N;i++){
			if(sunuke[i] == false){
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 46280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <string>
using namespace std;
int main() {
	int D;
	cin >> D;
	if (D == 22)
		cout << "Christmas Eve Eve Eve" << endl;
	else if (D == 23)
		cout << "Christmas Eve Eve" << endl;
	else if (D == 24)
		cout << "Christmas Eve" << endl;
	else
		cout << "Christmas" << endl;
	return 0;

}

Measured memory_bytes: 256
fun main() {
    ddcc2020c()
}

fun ddcc2020c() {
    val (h, w, k) = readLine()!!.split(" ").map { it.toInt() }
    var num = 1
    var repeatCount = 0
    var prev = IntArray(w)
    repeat(h) {
        val line = readLine()!!
        if (line.count { it == '#' } == 0) {
            repeatCount++
        } else {
            var foundFirst = false
            for (i in 0 until w) {
                if (line[i] == '#') {
                    if (foundFirst) {
                        num++
                    } else {
                        foundFirst = true
                    }
                }
                prev[i] = num
            }
            num++
            println(prev.joinToString(" "))
            if (repeatCount > 0) {
                repeat(repeatCount) {
                    println(prev.joinToString(" "))
                }
                repeatCount = 0
            }
        }
    }
    if (repeatCount > 0) {
        repeat(repeatCount) {
            println(prev.joinToString(" "))
        }
    }
}

Measured memory_bytes: 48016
#include <bits/stdc++.h>
using namespace std;
const long long int mod=1e9+7;
long long int dp[105][5][5][5];
int main(){
      int n;
      cin >> n;
      long long int ans=0;
      int nnn=0;
      for(int i=0;i<4;i++){
          for(int j=0;j<4;j++){
              for(int k=0;k<4;k++){
                if(i==0 && j==2 && k==1)nnn++;
                else if(i==0 && j==1 && k==2)nnn++;
                else if(i==2 && j==0 && k==1)nnn++;
                else dp[3][i][j][k]++;
          }
        }
      }
    for(int m=3;m<n;m++){
      for(int i=0;i<4;i++){
          for(int j=0;j<4;j++){
            for(int k=0;k<4;k++){
                for(int l=0;l<4;l++){
                    if(j==0 && k==2 && l==1)nnn++;
                    else if(j==0 && k==1 && l==2)nnn++;
                    else if(j==2 && k==0 && l==1)nnn++;
                    else if(i==0 && k==2 && l==1)nnn++;
                    else if(i==0 && j==2 && l==1)nnn++;                    
                    else dp[m+1][j][k][l]+=dp[m][i][j][k];
                    dp[m+1][j][k][l]%=mod;
                }
            }
        }
        }
    }
      for(int i=0;i<4;i++){
          for(int j=0;j<4;j++){
              for(int k=0;k<4;k++){
              ans+=dp[n][i][j][k];
              ans%=mod;
          }
        }
      }
      cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {

	private double getS(double deg){
		double s = Math.sin(deg / 180 * Math.PI) / 2;
		return Math.abs(s);
	}

	public void doIt(){
		final double EPS = 1.0e-08;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n != 0){
			//第1
			double sum1 = 0;
			int degMem = 0;
			for(int i=0; i < n-1 ; i++){
				double deg = sc.nextDouble();
				sum1 += getS(deg);
				degMem += deg;
			}
			degMem = 180*(n-2) - degMem;
			sum1 += getS(degMem);

			//第2
			n = sc.nextInt();
			double sum2 = 0;
			degMem = 0;
			for(int i=0; i < n-1 ; i++){
				double deg = sc.nextDouble();
				sum2 += getS(deg);
				degMem += deg;
			}
			degMem = 180*(n-2) - degMem;
			sum2 += getS(degMem);
			//比較
			if((sum1 - sum2) > EPS)
				System.out.println(1);
			else if(Math.abs(sum1 - sum2) < EPS)
				System.out.println(0);
			else
				System.out.println(2);
			n = sc.nextInt();
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	}

}

Measured memory_bytes: 12000
# 1 "n.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "n.cpp"
# 1 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 1
       
# 12 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/bits/stdc++.h" 1
 #include <bits/stdc++.h>
# 13 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/assoc_container.hpp" 1
 #include <ext/pb_ds/assoc_container.hpp>
# 14 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/tree_policy.hpp" 1
 #include <ext/pb_ds/tree_policy.hpp>
# 15 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2







using namespace std;
using namespace __gnu_pbds;

using ii = pair<long long, long long>;
using vi = vector<long long>;
using vd = vector<long double>;
using vb = vector<bool>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvd = vector<vd>;
using vvb = vector<vb>;
using vvii = vector<vii>;
# 50 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
inline long long mod(const long long n, const long long m = ((long long)1e9+7)){
    return (n%m + m)%m;
}

/**
 * Euclidean GCD.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long gcd(const long long a, const long long b){
    if(a < 0 or b < 0)
        return gcd(abs(a), abs(b));
    if(a == 0)
        return b;
    return gcd(b%a, a);
}

/**
 * Euclidean derivated LCM.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long lcm(const long long a, const long long b){
    // same as a*b/gcd(a, b) but avoiding overflow.
    return a/gcd(a, b)*b;
}
# 2 "n.cpp" 2

long long n;
vi arr;
pair<long long, long long> dp[(long long)4e2][(long long)4e2];

pair<long long, long long> solve(long long i, long long j){
    if(i == j)
        return {arr[i], 0};
    pair<long long, long long> &res = dp[i][j];
    if(res.second == -1){
        for(long long k=i; k<j; ++k){
            ii a = solve(i, k), b = solve(k+1, j);
            long long cost = a.second + b.second + a.first + b.first;
            if(res.second == -1 or cost < res.second)
                res = {a.first + b.first, cost};
            else if(cost == res.second)
                res.first = min(res.first, a.first + b.first);
        }
    }
    return res;
}

int32_t main(){
    (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL));
    cin >> n;
    arr.resize(n);
    for(long long &i:arr)
        cin >> i;
    for(long long i=0; i<n; ++i){
        for(long long j=0; j<n; ++j){
            dp[i][j] = {-1, -1};
        }
    }
    cout << solve(0, n-1).second << "\n";
    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}
int main()
{
  //flash;
	string s,t;
	cin>>s>>t;
	ll cur=0;
	for (int i = 0; i < s.size(); ++i)
	{
		if(s[i]!=t[i])cur++;
	}
	cout<<cur;
  return 0;
}
//code the AC sol !
// BS/queue/map

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// 端点を間違えないように気をつけること!
#define FOR(i, m, n) for (ll i = (ll)(m); i <= (ll)(n); i++)
#define RFOR(i, m, n) for (ll i = (ll)(m); i >= (ll)(n); i--)
// 割り算をするときは自作関数syou,amariを使うこと!
// 入力は変数を宣言した直後に入れること!

int main()
{
    string S;
    cin >> S;
    ll count_0 = 0, count_1 = 0;
    FOR(i, 0, S.size() - 1)
    {
        if ((i % 2 && S[i] == '1') || (!(i % 2) && S[i] == '0'))
        {
            count_0++;
        }
        else
        {
            count_1++;
        }
    }
    cout << min(count_0, count_1) << endl;
}

Measured memory_bytes: 512
n, x = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

B = [a for a in A]
ans = sum(A)

for i in range(1, n):
    for j in range(n):
        if A[j-i] < B[j]:
            B[j] = A[j-i]
    ans = min(ans, sum(B) + i * x)

print(ans)

Measured memory_bytes: 3188
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,ans;
  cin >> n;
  ll a[n],sum=0;
  map<ll,ll> mp;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum += a[i];
    mp[sum]++;
  }
  ans=0;
  for(auto i:mp){
    if(i.first==0){
      ans += (i.second*(i.second+1))/2;
    }else{
      ans += (i.second*(i.second-1))/2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 14336
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();
int main(){
  long long int x;
  cin>>x;
  long long int start=100;
  int year=0;
  while(start<x){
    ++year;
    start+=start/100;
  }
  cout<<year<<"\n";  
  return 0;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
//#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int i = 0;
	while (a > 0 && c > 0)
	{
		if (i % 2 == 0)
		{
			c -= b;
		}
		else
		{
			a -= d;
		}
		i++;
	}
	if (a <= 0)
	{
		cout << "No" << endl;
	}
	else
		cout << "Yes" << endl;
}
	
	

	
	
/**/
/*#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.141592653589793

int main(void) {
	return 0;
}
*/

Measured memory_bytes: 3644
package main

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

var (
	rdr   = bufio.NewReaderSize(os.Stdin, 1000000)
	reply string
)

func main() {
	var s, t, u string
	var a, b int
	fmt.Scan(&s, &t, &a, &b, &u)
	if s == u {
		fmt.Println(a-1, b)
	} else {
		fmt.Println(a, b-1)
	}
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

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

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

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

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

func yesOrNo(b bool) {
	if b {
		reply = "Yes"
		fmt.Println(reply)
		return
	}
	reply = "No"
	fmt.Println(reply)
}

func yesorNO(b bool) {
	if b {
		reply = "YES"
		fmt.Println(reply)
		return
	}
	reply = "NO"
	fmt.Println(reply)
}

Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		string s = GetString();
		var set = new HashSet<char>();
		for(int i = 0; i < s.Length; i++)
			set.Add(s[i]);
		if(set.Count == 1)
		{
			Console.Write(0);
			return;
		}
		var list = set.ToList();

		int ans = int.MaxValue;
		foreach(char c in list)
		{
			int tmp = 0;
			char[] current = s.ToCharArray();
			char[] next = new char[s.Length];
			while(true)
			{				
				var tmpSet = new HashSet<char>();
				for(int i = 0; i < s.Length - 1 - tmp; i++)
				{
					next[i] = current[i];
					if((i + 1 < s.Length - tmp) && (current[i + 1] == c))
						next[i] = c;
					tmpSet.Add(next[i]);
				}
				tmp++;
				current = next;

				if(tmpSet.Count == 1)
				{
					ans = Math.Min(ans, tmp);
					break;
				}
			}
		}
		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 13396
//tanzim bin nasir
#include<bits/stdc++.h>
typedef long long ll;
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
int gcd(int a,int b)
{
    if(b==0)
    return a;
    else
    gcd(b,a%b);
}
ll lcd(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
int main()
{
    int n;
    cin>>n;
    if(n)
    cout<<"0\n";
    else
    cout<<"1\n";
    return 0;
}


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

using namespace std;

#ifndef ONLINE_JUDGE
#define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
#define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
__attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
#define pr_debug(...) do { } while(0)
#define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;
#define X first
#define Y second
#define pb push_back

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fout << vec[i] << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
                                                for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
                                                    if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr double INF = 2e18;
constexpr ll MOD = 1e9 + 7;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e5 + 5;

int main()
{
    ll res = 0;
    ll a, b, c; cin >> a >> b >> c;
    if (a + b >= c) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

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

using namespace std;

typedef long long ll;

const ll INF=(1LL<<63)-1;

ll to_ll(const string &s){
	ll a;
	sscanf(s.c_str(),"%lld",&a);
	return a;
}

string to_string(ll a){
	char s[32];
	sprintf(s,"%lld",a);
	return s;
}

ll calc_index(ll a){
	ll res=0,ten=1,len=1;
	while(1){
		if(a<10*ten){
			res+=(a-ten)*len;
			return res;
		}
		res+=9*len*ten;
		ten*=10;
		len++;
	}
}

int main(){
	for(string s;cin>>s,s[0]!='#';){
		int n=s.length();

		if(count(s.begin(),s.end(),'0')==s.length()){ // s="000...0" のときは例外
			cout<<calc_index(to_ll('1'+s))+2<<endl;
			continue;
		}

		ll ans=INF;
		int ofset;
		// 注目する数が s に完全に含まれるケース ( 341235123612 など )
		rep(i,n) for(int j=i+1;j<=n;j++) {
			string t=s.substr(i,j-i);
			if(t[0]=='0' || t.length()>16) continue;

			ll a=to_ll(t);
			int len=0;
			string r=t;
			for(int k=1;k<30;k++){
				if(a-k>0){
					r=to_string(a-k)+r;
					len+=to_string(a-k).length();
				}
				r=r+to_string(a+k);
			}
			if(len-i>=0 && r.substr(len-i,s.length())==s && ans>a) ans=a, ofset=i;
		}

		// そうでないケース 3456712345
		for(int i=1;i<n;i++){
			string t=s.substr(0,i),r=s.substr(i);
			if(r[0]=='0' || t.length()>16 || r.length()>16) continue;

			t=to_string(to_ll(t)+1);
			if(t[0]=='1' && count(t.begin()+1,t.end(),'0')==t.length()-1) t=t.substr(1);

			rep(d,min(t.length(),r.length())+1){
				if(r.substr(r.length()-d,d)==t.substr(0,d) && t.length()+r.length()-d<=16){
					ll a=to_ll(r+t.substr(d));
					if(ans>a) ans=a, ofset=i;
				}
			}
		}

		cout<<calc_index(ans)-ofset+1<<endl;
	}

	return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t x, k, d;
    cin >> x >> k >> d;

    if (x < 0) {
        x = -x;
    }

    auto t = min(x / d, k);

    x -= t * d;
    k -= t;

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

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

namespace Contest20191112
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] h = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int max = h[0];
            int count = 1;

            for (int i = 1; i < h.Length; i++)
            {
                if(max <= h[i])
                {
                    max = h[i];
                    count++;
                }
            }

            Console.WriteLine(count);
           
        }
    }
}


Measured memory_bytes: 13396
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;

void main() {
    auto S = readln.chomp;
    auto T = readln.chomp;
    int N = S.length.to!int;

    auto ss = new int[][](26);
    auto tt = new int[][](26);

    foreach (i; 0..N) ss[S[i] - 'a'] ~= i;
    foreach (i; 0..N) tt[T[i] - 'a'] ~= i;

    ss = ss.filter!(a => !a.empty).array;
    tt = tt.filter!(a => !a.empty).array;

    ss.sort!"a.front < b.front";
    tt.sort!"a.front < b.front";


    foreach (i; 0..ss.length) {
        if (ss[i] != tt[i]) {
            writeln("No");
            return;
        }
    }

    writeln("Yes");
}


Measured memory_bytes: 4664
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      x: usize,
      aa: [usize; n],
    }

    let mut dp = vec![vec![0; n]; n+1];
    for m in 0..n {
        dp[0][m] = x * m;
    }
    const INF: usize = 1 << 60;
    for i in 0..n {
        let mut v = INF;
        for m in 0..n {
            let a = aa[(i + n - m) % n];
            v = min(a, v);
            dp[i+1][m] = dp[i][m] + v;
        }
    }
    let ans=dp[n].iter().min().unwrap();
    puts!("{}\n", ans);
}


Measured memory_bytes: 45308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
template <typename TYPE> inline void chkmax(TYPE &x,TYPE y){x<y?x=y:TYPE();}
template <typename TYPE> inline void chkmin(TYPE &x,TYPE y){y<x?x=y:TYPE();}
template <typename TYPE> void readint(TYPE &x)
{
    x=0;int f=1;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+c-'0';
    x*=f;
}
const int MAXN=100005,MAXK=60;

int n,m;ll k;
ll a[MAXN];
int p[MAXN],anc[MAXN][MAXK];
ll res[MAXN];

int main()
{
	int x;
	readint(n);
	for(int i=1;i<=n;++i)readint(a[i]);
	readint(m),readint(k);
	for(int i=2;i<=n;++i)p[i]=i;
	for(int i=1;i<=m;++i)readint(x),swap(p[x],p[x+1]);
	for(int i=2;i<=n;++i)anc[i][0]=p[i];
	for(int j=1;j<MAXK;++j)
		for(int i=2;i<=n;++i)
			anc[i][j]=anc[anc[i][j-1]][j-1];
	for(int i=2;i<=n;++i)
	{
		x=i;
		for(int j=0;j<MAXK;++j)
			if(k&(1ll<<j))x=anc[x][j];
		res[i]=a[x]-a[x-1];
	}
	res[1]=a[1];
	for(int i=2;i<=n;++i)res[i]+=res[i-1];
	for(int i=1;i<=n;++i)printf("%lld\n",res[i]);
	return 0;
}

Measured memory_bytes: 26624
"use strict";

function main(arg) {
    const N = arg.split("\n")[0].split("").map(n=>parseInt(n));

    if(N[0] == N[1] && N[1] == N[2] || N[1] == N[2] && N[2] == N[3]) {
        console.log("Yes");
    } else {
        console.log("No");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define ll long long
using namespace std;

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

int main(){
  int n;
  ll x, t, res;
  vector<ll> v;
  cin >> n >> x;
  for(int i = 0; i < n; i++){
    cin >> t;
    res = i == 0 ? abs(t - x) : gcd(res, abs(t - x));
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<numeric>
#include<queue>
#include<string>
#include<sstream>

using namespace std;

int main(void) {

  int n;
  cin >> n;

  vector<string> s(n);
  for(int i=0; i<n; i++) cin >> s[i];

  if( n%2 == 1 ){
    cout << "NO" << endl;
    return 0;
  }

  int a = 0;
  for(int i=0; i<n; i++){
    if( s[i][0] == 'A' ){
      a++;
    }else{
      if( a == 0 ){
        cout << "NO" << endl;
        return 0;
      }
      a--;
    }
  }

  cout << ( a == 0 ? "YES" : "NO" ) << endl;


  return 0;
}










//

Measured memory_bytes: 3176
def make_prime_table(n):
    sieve = list(range(n + 1))
    sieve[0] = -1
    sieve[1] = -1
    for i in range(4, n + 1, 2):
        sieve[i] = 2
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i] != i:
            continue
        for j in range(i * i, n + 1, i * 2):
            if sieve[j] == j:
                sieve[j] = i
    return sieve


def prime_factorize(n):
    result = []
    while n != 1:
        p = prime_table[n]
        e = 0
        while n % p == 0:
            n //= p
            e += 1
        result.append((p, e))
    return result


N = int(input())

prime_table = make_prime_table(N)
d = {}
for i in range(2, N + 1):
    for p, e in prime_factorize(i):
        d.setdefault(p, 0)
        d[p] += e

# 75 = 5 * 5 * 3
#    = 15 * 5
#    = 25 * 3
#    = 75
n74 = 0
n24 = 0
n14 = 0
n4 = 0
n2 = 0
for k in d:
    if d[k] >= 74:
        n74 += 1
    if d[k] >= 24:
        n24 += 1
    if d[k] >= 14:
        n14 += 1
    if d[k] >= 4:
        n4 += 1
    if d[k] >= 2:
        n2 += 1

result = 0
# x ^ 4 * y ^ 4 * z ^ 2 の約数の個数は75個
result += n4 * (n4 - 1) // 2 * (n2 - 2)
# x ^ 14 * y ^ 4 の約数の個数は75個
result += n14 * (n4 - 1)
# x ^ 24 * y ^ 2 の約数の個数は75個
result += n24 * (n2 - 1)
# x ^ 74 の約数の個数は75個
result += n74
print(result)


Measured memory_bytes: 9416