akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<memory.h>
using namespace std;
int a[30], b[30];
int dp[31][1 << 16];
int bit_count(int);
int main()
{
	int n, c;
	while (true) {
		cin >> n >> c;
		if (n == 0 && c == 0)break;
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));
		memset(dp, -1, sizeof(dp));
		dp[0][0] = 0;
		for (int i = 0; i < n; i++) {
			for (int i2 = 0; i2 < 16; i2++) {
				int bit;
				cin >> bit;
				a[i] |= (bit << i2);
			}
		}
		for (int i = 0; i < c; i++) {
			for (int i2 = 0; i2 < 16; i2++) {
				int bit;
				cin >> bit;
				b[i] |= (bit << i2);
			}
		}
		for (int i = 0; i < n; i++) {
			for (int i2 = 0; i2 < (1 << 16); i2++) {
				if (dp[i][i2] == -1)continue;
				for (int i3 = 0; i3 < c; i3++) {
					int bit = a[i] | i2;
					int add = bit & b[i3];
					int bitcount = bit_count(add);
					dp[i + 1][bit - add] = max(dp[i + 1][bit - add], dp[i][i2] + bitcount);
				}
			}
		}
		int maxv = 0;
		for (int i = 0; i < (1 << 16); i++) {
			maxv = max(maxv, dp[n][i]);
		}
		cout << maxv << endl;
	}

}
int bit_count(int bit) { 
	if (bit)
		return (bit & 1) + bit_count(bit >> 1);
	else
		return 0;
}

Measured memory_bytes: 9104
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int         long long
#define ll          long long
#define ld	    long double
#define pb          push_back
#define pp	    pop_back()
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),a.rend()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repj(j,a,b) for(ll j=a;j<b;j++)
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end())
#define IOS	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//CONSTANTS----------------------------------
#define PI 	    3.141592653589793238462643
const ll hell=1000000007;
const ll mod=1000000007;
//function-----------------------------------
ll GCD(ll a , ll b)
{
    if(b==0)
        return a;
    else
        return GCD(b,a%b);
}
ll LCM(ll a, ll b)
{
    return a*(b/GCD(a,b));
}
bool isPrime(ll n) {

    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
ll fact(ll n)
{
    ll f=1;
    for(ll i=2;i<=n;i++)
	f=f*i;
    return f;
}
ll power(ll a,ll b)
{
  if(b==0)return 1;
  if(b==1)return a;
  ll t=power(a,b/2);
  t%=hell;
  t*=t;
  t%=hell;
  if(b%2)return (t*a)%hell;
  else
     return t;
}
//CODE------------------------------------------
ll solve()
{
    string s; cin>>s;
    ll n=sz(s);
    if(s[0]==s[1])
    {
        cout<<1<<" "<<2;
        return 0;
    }
    else
    {
        rep(i,2,n)
        {
            if(s[i]==s[i-1])
            {
                cout<<i<<" "<<i+1;
                return 0;
            }
            else if(s[i]==s[i-2])
            {
                cout<<i-1<<" "<<i+1;
                return 0;
            }
        }
    }
    cout<<-1<<" "<<-1;
    return 0;
}
//MAIN------------------------------------------
signed main(){
    IOS
    #ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--) {
        solve();
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main(void){
    long num;
    char **name;
    long count[5]={0};
    long answer=0;
    int P[10]={0,0,0,0,0,0,1,1,1,2};
    int Q[10]={1,1,1,2,2,3,2,2,3,3};
    int R[10]={2,3,4,3,4,4,3,4,4,4};

    scanf("%ld",&num);
    name=(char **)malloc(sizeof(char *)*num);
    long i;
    for(i=0;i<num;i++){
        name[i]=(char *)malloc(sizeof(char)*11);
        scanf("%s",name[i]);
        if(name[i][0]=='M'){
            count[0]++;
        }
        else if(name[i][0]=='A'){
            count[1]++;
        }
        else if(name[i][0]=='R'){
            count[2]++;
        }
        else if(name[i][0]=='C'){
            count[3]++;
        }
        else if(name[i][0]=='H'){
            count[4]++;
        }
    }
    for(i=0;i<10;i++){
        answer+=count[P[i]]*count[Q[i]]*count[R[i]];
    }
    printf("%ld",answer);
    free(name);
    return 0;
}

Measured memory_bytes: 4096
n = int(input())

target_range = int(n**0.5+0.5)

min_value = 10
for x in range(1,target_range+1):
    if n%x == 0:
        result = max([len(str(x)),len(str(n//x))])
        #pdb.set_trace()
        
        if min_value > result:
            min_value = result
            
print(min_value)

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

typedef struct{
	int a, b, c, d, e, f;
}Dice;

typedef struct{
	int a, b, c, d, e, f;
}Dice2;

int main(void)
{
	Dice dice;
	Dice2 dice2;
	
	int n, k;
	
	scanf("%d", &n);
	scanf("%d %d %d %d %d %d", &dice.a, &dice.b, &dice.c, &dice.d, &dice.e, &dice.f);
	
	
	for(k=0;k<n-1;k++){
		AAA:
		scanf("%d %d %d %d %d %d", &dice2.a, &dice2.b, &dice2.c, &dice2.d, &dice2.e, &dice2.f);
		int i, j, temp;
		
		if(dice.a!=dice2.a){
			for(i=0;i<3;i++){
				temp=dice.a; dice.a=dice.b; dice.b=dice.f; dice.f=dice.e; dice.e=temp;//N
					if(dice.a==dice2.a){goto LABEL;}
				temp=dice.a; dice.a=dice.d; dice.d=dice.f; dice.f=dice.c; dice.c=temp;//E
					if(dice.a==dice2.a){goto LABEL;}
			}
			if(i==2){k++; goto AAA;}
			LABEL:
			;
		}
		
		//if(k==n-2){goto BBB;}
		
		for(i=0;i<4;i++){
			temp=dice.b; dice.b=dice.c; dice.c=dice.e; dice.e=dice.d; dice.d=temp;//横回し
			if((dice.b==dice2.b)&&(dice.c==dice2.c)&&(dice.d==dice2.d)&&(dice.e==dice2.e))break;
		}
		if((dice.a==dice2.a)&&(dice.b==dice2.b)&&(dice.c==dice2.c)&&(dice.d==dice2.d)&&(dice.e==dice2.e)&&(dice.f==dice2.f)){puts("No"); return 0;}
		
		if(k==n-2){goto BBB;}
		
		temp=dice.a; dice.a=dice.b; dice.b=dice.f; dice.f=dice.e; dice.e=temp;//N
		if(dice.b==dice2.b){goto label;}
		temp=dice.a; dice.a=dice.e; dice.e=dice.f; dice.f=dice.b; dice.b=temp;//S
		temp=dice.a; dice.a=dice.e; dice.e=dice.f; dice.f=dice.b; dice.b=temp;//S
		if(dice.e==dice2.e){goto label;}
		temp=dice.a; dice.a=dice.b; dice.b=dice.f; dice.f=dice.e; dice.e=temp;//N
		temp=dice.a; dice.a=dice.c; dice.c=dice.f; dice.f=dice.d; dice.d=temp;//W
		if(dice.d==dice2.d){goto label;}
		temp=dice.a; dice.a=dice.d; dice.d=dice.f; dice.f=dice.c; dice.c=temp;//E
		temp=dice.a; dice.a=dice.d; dice.d=dice.f; dice.f=dice.c; dice.c=temp;//E
		
		label:
		if((dice.a==dice2.a)&&(dice.b==dice2.b)&&(dice.c==dice2.c)&&(dice.d==dice2.d)&&(dice.e==dice2.e)&&(dice.f==dice2.f)){puts("No"); return 0;}
	}
	
	BBB:
	if(k==n-2)puts("Yes");
	
	return 0;
}


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

      int r = sc.nextInt();
      int g = sc.nextInt();
      int b = sc.nextInt();

      int ans =r*100+g*10+b;

      if(ans%4==0){
        System.out.println("YES");
      }else{
        System.out.println("NO");
  }
}
}


Measured memory_bytes: 22100
(let* ((xs (sort (loop :for i :from 1 :to 5 :collect (read))
                 (lambda (a b) (> (if (= (mod a 10) 0) 10 (mod a 10))
                                  (if (= (mod b 10) 0) 10 (mod b 10))))))
       (ans 0))
  (loop :for x :in xs
        :for i :from 1 :to 5
        :do (if (= i 5)
                (incf ans x)
                (incf ans (* 10 (ceiling x 10)))))
  (format t "~A~%" ans))


Measured memory_bytes: 24516
#include<bits/stdc++.h>
using namespace std;
typedef signed long long int ll;

int INFp=1000000007;

int main(){
    int m,n;
    cin>>n>>m;
    //int k[40];
    //int a[40][40];
    int suki[40]={0};
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            int a;
            cin>>a;
            suki[a]++;
        }
    }
    int ans=0;
    for(int i=1;i<=m;i++){
        if(suki[i]==n) ans++;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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")
    };
}

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

const MOD: usize = 1_000_000_007;
const MAX: usize = 510_000;
fn com_init(fac: &mut [usize], finv: &mut [usize], inv: &mut [usize]) {
    fac[0] = 1;
    fac[1] = 1;
    finv[0] = 1;
    finv[1] = 1;
    inv[1] = 1;
    for i in 2..MAX {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

fn bin_coef(n: usize, k: usize, fac: &mut [usize], finv: &mut [usize], inv: &mut [usize]) -> usize {
    if k > n/2 {
        bin_coef(n-k, k, fac, finv, inv)
    } else {
        fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
    }
}


use std::cmp;
use std::collections::{HashSet, BinaryHeap, VecDeque};
use std::iter::FromIterator;
fn main() {
    input!{
        N: usize,
        K: usize,
        h: [isize; N],
    }
    let mut dp = vec![std::isize::MAX; N];
    dp[0] = 0;
    for ind in 1..N {
        for k in 1..K+1 {
            dp[ind] = cmp::min(dp[ind], dp[ind.saturating_sub(k)] + (h[ind]-h[ind.saturating_sub(k)]).abs())
        }
    }
    println!("{}", dp[N-1]);
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
int dfs(long long sum,long long t,int bits);
int d[]={3,5,7};
int n;

int main(){
  cin>>n;
  cout<<dfs(0,1,0)<<endl;
  return(0);
}

int dfs(long long sum,long long t,int bits){
  int rec=0;
  if(bits==7)rec++;
  if(sum>n)return 0;
  for(int i=0;i<3;i++){
    rec+=dfs(sum+d[i]*t,t*10,bits|(1<<i));
  }
  return rec;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define assn(n,a,b) assert(n<=b && n>=a)
using namespace std;
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,b) for(i=0;i<b;i++)
#define rep1(i,b) for(i=1;i<=b;i++)
#define pdn(n) printf("%d\n",n)
#define sl(n) scanf("%lld",&n)
#define sd(n) scanf("%d",&n)
#define pn printf("\n")
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
#define MOD 1000000007
LL mpow(LL a, LL n)
{LL ret=1;LL b=a;while(n) {if(n&1)
    ret=(ret*b)%MOD;b=(b*b)%MOD;n>>=1;}
return (LL)ret;}
#define MAXK 100000
#define MAXN 1000000000
int ar[MAXK];
int get(int n, int k){
    int i=0;
    while(i<k and ar[i]<=n)i++;
    return n-i;
}
typedef unsigned long long int ULL;
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
 
bool isSafe(int r, int c, vector<vector<int> > arr) {
	int n = arr.size();
	int m = arr[0].size();
	return (r>=0 && r<n && c>=0 && c<m);
}
 
/////////////////////////////////////////////////////////////
bool func(pair<LL,LL> a, pair<LL,LL> b) {
	if(a.first < b.first) return true;
	else {
		if(a.second>b.second) return true;
		else return false;
	}
}

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

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    LL t,i,j,k,n,a,b,ans,mn;
    cin>>n;
    ans=0;
    rep1(i,n) {
    	rep1(j,n) {
    		rep1(k,n) {
    			ans+= gcd(i,gcd(j,k));
    		}
    	}
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3652
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <string.h>
#include <stdio.h>

const char main_[] = {
	0x48, 0xc7, 0xc0, 0x00, 0x00, 0x00, 0x40,
	0x48, 0xff, 0xcf,
	0x48, 0x8b, 0x0c, 0xbe,
	0x48, 0x31, 0xd2,
	0x48, 0x29, 0xca,
	0x48, 0x21, 0xd1,
	0x48, 0x39, 0xc1,
	0x73, 0x03,
	0x48, 0x89, 0xc8,
	0x48, 0x83, 0xff, 0x00,
	0x75, 0xe2,
	0x48, 0xff, 0xc8,
	0xf3, 0x48, 0x0f, 0xb8, 0xc0,
	0xc3
};

int main(void){
	int fd = open("/dev/zero", O_RDONLY);
	int (*solve)(int, int[]) = mmap(NULL, sizeof main_, PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0);
	memcpy(solve, main_, sizeof main_);

	int n, a[210];
	scanf("%d", &n);
	for(int i = 0; i < n; ++i) scanf("%d", a + i);
	printf("%d\n", solve(n, a));

	close(fd);
	munmap(solve, sizeof main_);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	i64 n;
	cin >> n;
	int x = 0;
	int y = 0;
	ff(i, 1, sqrt(n) + 1) {
		if (n % i == 0) {
			x = n/i;
		}
	}
	int ans = tos(x).size();
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))



using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;


ll N;
vector<pint> AB, list;

int main() {

	cin >> N;

	ll v, u;


	rep(i, N) {
		cin >> v >> u;
		list.push_back({ v, u });
		AB.push_back({v + u, i });

	}

	sort(AB.begin(), AB.end());
	reverse(AB.begin(), AB.end());
	ll sumT = 0, sumA = 0;

	rep(i, N) {

		if (i % 2 == 0) {
			sumT += list[AB[i].second].first;
		}
		else
			sumA += list[AB[i].second].second;

	}
	

	cout << sumT - sumA << endl;

	return 0;
}

Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i = 0; i < (a); i++)
#define reps(i, a, b) for(int i = (a); i < (b); i++)
#define INF 1e9
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
vector<string> rotate(vector<string> s) {
	vector<string> ret = vector<string>(8, "");
	rep(i, 8) rep(j, 8) ret[i] += s[7-j][i];
	return ret;
}
int main() {
	vector<string> s = vector<string>(8, "");
	rep(i, 8) cin >> s[i];
	vi v = {90, 180, 270};
	rep(k, v.size()) {
		cout << v[k] << endl;
		s = rotate(s);
		for(auto it : s) cout << it << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <cmath>

namespace Geometry {
  using Float = long double;
  using Real = long long;
  constexpr Float eps = 1e-9;

  namespace Plane {
    struct Vec {
      Real x, y;
      constexpr Vec() : x(0), y(0) {}
      constexpr Vec(Real k) : x(k), y(k) {}
      constexpr Vec(Real x, Real y) : x(x), y(y) {}
      static constexpr Real dot(Vec v, Vec w) { return v.x*w.x + v.y*w.y; }
      static constexpr Real cross(Vec v, Vec w) { return v.x*w.y - v.y*w.x; }
      constexpr Real norm2() const { return x*x+y*y; }
      Float norm() const { return std::sqrt(x*x+y*y); }
      Float arg() const { return std::atan2(x, y); }
      constexpr Vec& operator+=(Vec const& v) { x += v.x; y += v.y; return *this; }
      constexpr Vec& operator-=(Vec const& v) { x -= v.x; y -= v.y; return *this; }
      constexpr Vec& operator*=(Real const& k) { x *= k; y *= k; return *this; }
      constexpr Vec& operator*=(Vec const& v) { x *= v.x; y *= v.y; return *this; }
      constexpr Vec operator-() const { return Vec(-x, -y); }
      friend constexpr Vec operator+(Vec const& v, Vec const& w) { return Vec(v) += w; }
      friend constexpr Vec operator-(Vec const& v, Vec const& w) { return Vec(v) -= w; }
      friend constexpr Vec operator*(Real const& k, Vec const& v) { return Vec(v) *= k; }
      friend constexpr Vec operator*(Vec const& v, Vec const& w) { return Vec(v) *= w; }
      constexpr int ort() const { // orthant
        if (eps < x && x < eps && eps < y && y < eps) return 0;
        if (y > 0) return x>0 ? 1 : 2;
        else return x<0 ? 3 : 4;
        // if(abs(x) < eps && abs(y) < eps) return 0;
        if(  x>0  && !(y<0)) return 1;
        if(!(x>0) &&   y>0 ) return 2;
        if(  x<0  && !(y>0)) return 3;
        if(!(x<0) &&   y<0 ) return 4;
        return 0;
      }
      friend constexpr bool operator<(Vec const& a, Vec const& b) {
        int ao = a.ort() , bo = b.ort();
        if(ao != bo) return ao < bo;
        if(ao == 0) return true;
        return 0 < cross(a, b);
      }
      friend std::istream& operator>>(std::istream& is, Vec& v) noexcept { is >> v.x >> v.y; return is; }
      friend std::ostream& operator<<(std::ostream& os, Vec const& v) noexcept { os << '(' << v.x << ',' << v.y << ')'; return os; }
    };

  }
}
using Geometry::Plane::Vec;

#include <iomanip>
#include <algorithm>
#include <vector>

signed main() {
  using namespace std;

  // abc139_f
  int n;
  cin >> n;

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

  sort(v.begin(), v.end());
  //for(int i=0; i<n; ++i) cerr << v[i] << ' ';
  //cerr << endl;

  Vec ans{};
  for(int l=0; l<n; ++l) {
    Vec now{};
    for(int r=l, i=0; i<n; ++r, ++i) {
      now += v[r %= n];
      if(ans.norm2() < now.norm2()) ans = now;
    }
  }

  cout << fixed << setprecision(15) << ans.norm() << endl;

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
    int n;
    cin>>n;
    vector<string> s(n);
    rep(i,n){
        cin>>s[i];
        sort(all(s[i]));
    }
    sort(all(s));
    ll sum = 0;
    ll count = 0;
    for(int i = 1; i < n;i++)
    {
        if(s[i-1]==s[i])
        {
            count++;
            sum+=count;
        }
        else
        {
            count = 0;
        }
    }

    cout<<sum<<endl;

    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  
  for(int r = K ; r < N ; r++){
    int l = r-K;
    
    if( A[l] < A[r] )cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 4020
n,k = map(int,input().split())
sunuke = [0]*n
for i in range(k):
    dum = input()
    sunuke_list = list(map(int,input().split()))
    for i in sunuke_list:
        sunuke[i-1] = 1
count = 0
for i in range(n):
    if sunuke[i] != 1:
        count += 1
print(count)

Measured memory_bytes: 67496
from sys import stdin, setrecursionlimit
from collections import defaultdict


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))

    ans = 0

    dic = defaultdict(int)
    for ai in a:
        dic[ai - 1] += 1
        dic[ai] += 1
        dic[ai + 1] += 1
        ans = max(ans, dic[ai - 1], dic[ai], dic[ai + 1])

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 57628
//C
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
	string d="";
	d.resize(52);
	for(int i=0;i<26;i++)d[i]='a'+i;
	for(int i=0;i<26;i++)d[i+26]='A'+i;
	int num;
	//cout<<d<<endl;
	while(true){
	cin>>num;
	if(num==0)break;
	string ans="",next;
	int key[200];
	for(int i=0;i<num;i++)cin>>key[i];
	cin>>next;
	for(int i=0;i<next.size();i++){
		int tmp;
		for(int j=0;j<52;j++)if(d[j]==next[i])tmp=j;
		int index;
		if(i==0)index=0;
		else index=i%num;
		tmp-=key[index];
		if(tmp<0)tmp+=52;
		cout<<d[tmp];
	}
	cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const int M = 1000000007;


int main()
{
	long long int n, k;
	cin >> n >> k;
	long long int cnt = 0;
	for(int i = k; k <= n+1; k++){
		cnt += ((n*(n+1)/2) - ((n-k)*(n-k+1)/2) - (k*(k-1)/2) + 1);
		//cout << i << ":" << (n*(n+1)/2 - (n-k)*(n-k+1)/2 - k*(k-1)/2 + 1) << ", "; 
	}

	cout << cnt % M << endl;
}


Measured memory_bytes: 3676
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 2000005;
const int MAXV = 50000;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
char text[MAXN];
int fastExp(ll x, ll p, int mod) {
    ll ans = 1;
    while (p) {
        if (p & 1) ans = ans * x % mod;
        x = x * x % mod;
        p >>= 1;
    }
    return ans;
}
ll fact[MAXN];
void extgcd(ll a, ll b, ll& d, ll& x, ll& y) {
    if (!b) {
        d = a;
        x = 1;
        y = 0;
    } else {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}

inline ll getInv(ll x, ll mod) {
    ll g, a, b;
    extgcd(x, mod, g, a, b);
    return (a % mod + mod) % mod;
}

ll choose(int n, int k) {
    return fact[n] * getInv(fact[k] * fact[n - k] % MOD, MOD) % MOD;
}

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    fact[0] = 1;
    for (int i = 1; i <= 2000000; i++) {
        fact[i] = fact[i - 1] * i % MOD;
    }
    scanf("%d", &k);
    scanf("%s", text);
    n = strlen(text);
    ll ans = 0;
    for (int i = 0; i <= k; i++) {
        ll x = fastExp(26, i, MOD);
        ll y = fastExp(25, k - i, MOD) * choose(k - i + n - 1, k - i) % MOD;
        ans += x * y % MOD;
        ans %= MOD;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 20416
N,K,Q = map(int,input().split())
# ans_list = [list(map(int,input().split())) for i in range(Q)]

ans_list = []
for i in range(Q):
    a = int(input())
    ans_list.append(a)
point_list = [K -Q]*N  #[i*0  for i in range(N)]

for i in range(Q):
    tem = ans_list[i] - 1
    point_list[tem] += 1

for i in range(N):
    if point_list[i] >0:
        print("Yes")
    else:
        print("No")

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

int R[4], L[4];
int main()
{
    double r, l;
    while (cin >> r >> l)
    {
        if (r >= 1.1)
            R[0]++;
        else if (r >= 0.6)
            R[1]++;
        else if (r >= 0.2)
            R[2]++;
        else
            R[3]++;
        if (l >= 1.1)
            L[0]++;
        else if (l >= 0.6)
            L[1]++;
        else if (l >= 0.2)
            L[2]++;
        else
            L[3]++;
    }
    for( int i = 0; i < 4; i++ )cout << R[i] << ' ' << L[i] << endl;
    
}



Measured memory_bytes: 3224
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int main(){
	int a=read(),b=read(),c=read(),d=read();
	int num1=(c-1)/b+1,num2=(a-1)/d+1;
	if(num2<num1)puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define loop(i,n) for(int i=0;i<n;i++)
void solve()
{
    int n;
    double t=0;
    cin>>n;
    long p;
    loop(i,n-1)
    p=p*(i+1);  
    double a[n][n];
    int x[n],y[n];
    loop(i,n)
    cin>>x[i]>>y[i];
    loop(i,n)
    {
      loop(j,n)
      {
          a[i][j]=sqrt((x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i]));
         t=t+a[i][j];
      }
      
    }
    //for(int i=1;i<=n;i++)
    t=t/n;
    cout.precision(6);
    cout<<fixed<<t;
}
int main() {
	// your code goes here
// 	int t ;
// 	cin>>t;
// 	while(t--)
    solve();
	return 0;
}


Measured memory_bytes: 256
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

K,X = II()

left = max(-1000000,X-K+1)
right = min(1000000,X+K-1)
ans = []
for i in range(left,right+1):
  ans.append(i)
print(*ans)

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

void chmin(int& a, int b){
    a = min(a, b);
}

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int main(){
    int N, Ma, Mb, a[40], b[40], c[40];
    cin >> N >> Ma >> Mb;
    for(int i=0; i<N; i++) cin >> a[i] >> b[i] >> c[i];

    // OFFSETはsが負になることを防ぐために足す値
    const int OFFSET = 2000, INF = 1e9;
    
    // C[g][s] = グループgの選び方（1つ以上）で Mb*sumA - Ma*sumB + OFFSET = s となるときの最小コスト
    int C[2][4001];
    for(int g=0; g<2; g++) for(int s=0; s<=4000; s++) C[g][s] = INF;
    
    // グループgに属するのはインデックス [start[g], term[g]) の範囲のものとする
    int start[2] = {0, N/2}, term[2] = {N/2, N};
    
    for(int g=0; g<2; g++){
        int sz = term[g] - start[g];
        // 全列挙。1つ以上選ぶのでbits=0を見ない
        for(int bits=1; bits<(1<<sz); bits++){
            int s = OFFSET, cost = 0;
            for(int i=0; i<sz; i++) if(nth_bit(bits, i)){
                s += Mb * a[i+start[g]] - Ma * b[i+start[g]];
                cost += c[i+start[g]];
            }
            chmin(C[g][s], cost);
        }
    }

    // C[0][0], C[1][0], C[0][s] + C[0][-s] をそれぞれ調べるが、OFFSETに注意
    int ans = min(C[0][OFFSET], C[1][OFFSET]);
    for(int s=0; s<=4000; s++) chmin(ans, C[0][s] + C[1][2*OFFSET-s]);
    if(ans >= INF) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def d():
    N,W = map(int, input().split())
    nupList = (map(int, input().split()) for _ in range(N))
    dp = [0] * (W + 1)

    for w, v in nupList:
        for j in range(W, w - 1, -1 ):
            DP = dp[j - w] + v
            if dp[j] < DP:
                dp[j] = DP

    return dp[W]

print(d())


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

int main()
{
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            cin >> X[i][j];
        }
    }
    
    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            int sum = 0;
            for (int k = 0; k < D; k++) {
                int s = abs(X[i][k] - X[j][k]);
                sum += s * s;
            }
            float AAA = sqrt(sum) * 0.5f;
            if (AAA + AAA == sqrt(sum)) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    string s;cin >> s;
    string ans = "No";
    if(s[0] == s[1] && s[1] == s[2]) ans = "Yes";
    if(s[1] == s[2] && s[2] == s[3]) ans = "Yes";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n, m;
    cin >> n >> m;
    vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] %= m;
    }
    ll ret = 0;
    for (int i = 1; i < n; ++i) {
        a[i] = (a[i] + a[i - 1]) % m;
    }
    for (int i = 0; i < n; ++i) {
        if (a[i] == 0)
            ret++;
    }
    unordered_map<int, ll> cnt;
    for (int i = 0; i < n; ++i) {
        ret += cnt[a[i]];
        cnt[a[i]]++;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 4492
#include<stdio.h>
#include<math.h>

void koch(int depth, int n, double p1x, double p1y, double p2x, double p2y) {
  if (depth != n) {
    double sx, sy, ux, uy, tx, ty;
    sx = (p1x*2+p2x)/3;
    sy = (p1y*2+p2y)/3;
    tx = (p1x+p2x*2)/3;
    ty = (p1y+p2y*2)/3;
    ux = sx+(tx-sx)*cos(60 * M_PI / 180.0)-(ty-sy)*sin(60 * M_PI / 180.0);
    uy = sy+(tx-sx)*sin(60 * M_PI / 180.0)+(ty-sy)*cos(60 * M_PI / 180.0);
    koch(depth+1, n, p1x, p1y, sx, sy);
    printf("%f %f\n", sx, sy);
    koch(depth+1, n, sx, sy, ux, uy);
    printf("%f %f\n", ux, uy);
    koch(depth+1, n, ux, uy, tx, ty);
    printf("%f %f\n", tx, ty);
    koch(depth+1, n, tx, ty, p2x, p2y);
  }
}

int main() {
	int n;
  scanf("%d", &n);
  printf("0.00000000 0.00000000\n");
  koch(0, n, 0.00000000, 0.00000000, 100.00000000, 0.00000000);
  printf("100.00000000 0.00000000\n");

  return 0;
}



Measured memory_bytes: 2616
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())

print(a[k-1])


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Main {
	
	static long n = 0;

	public static void main(String[] args) throws Exception {
		try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
			n = Long.parseLong(br.readLine());
			System.out.println(get("0"));
		}
	}
	
	public static int get(String a) {
		boolean[] bools = {false, false, false};
		List<String> num = new ArrayList<>(Arrays.stream(a.split(""))
				.filter(n -> !n.equals("0")).collect(Collectors.toList()));
		int count = 0;
		
		if(Long.parseLong(a) > n) return 0;
		
		for (String s : num) {
			int i = Integer.parseInt(s);
			if(i == 3) bools[0] = true;
			else if(i == 5) bools[1] = true;
			else if(i == 7) bools[2] = true;
			else {
				bools[0] = false;
				break;
			}
		}
		if(bools[0] && bools[1] && bools[2]) count++;
		if(Long.parseLong(a) == 0) a = "";
		
		for (String ss : "357".split("")) {
			count += get(a + ss);
		}
		return count;
		
	}

}


Measured memory_bytes: 97984
#include<stdio.h>
#include<string.h>
int main()
{
    char str1[10],str2[]= {"Sunny"},str3[]= {"Rainy"},str4[]= {"Cloudy"};
    scanf("%s",&str1);
    if (strcmp(str1,str2)==0)
    {
        printf("Cloudy");
    }
    if (strcmp(str1,str3)==0)
    {
        printf("Sunny");
    }
    if (strcmp(str1,str4)==0)
    {
        printf("Rainy");
    }
    return 0;
}


Measured memory_bytes: 128
N, T = map(int,input().split())
list_c = []
list_t = []
for i in range(N) :
    c, t = map(int, input().split())
    list_c.append(c)
    list_t.append(t)

list_ans = []
for i in range(N) :
    if list_t[i] <= T :
        list_ans.append(list_c[i])

if list_ans :
    print(min(list_ans))
else :
    print("TLE")


Measured memory_bytes: 3060
#include <iostream>
#include <climits>
#include <vector>
#include <queue>
 
#define MAX_V 1024
using namespace std;
 
void get_map();
void check();
struct edge
{
  int to;
  int weight;
};
 
 
#define INF INT_MAX/4
vector<edge> g[2000];
int graph[MAX_V][MAX_V];
int dist[MAX_V];
int numofedge;
int vertex;
int start;
int flag=0;
 
int main()
{
  get_map();
  check();
  {
    for(int j=0;j<vertex;j++) {
      if(graph[start][j]<INF/2 && graph[j][j]<0) {
          cout << "NEGATIVE CYCLE" <<endl;
          return 0;
      }
    }
  }
  
  for(int i=0;i<vertex;i++) {
    if(graph[start][i]>=INF/2) {
      cout << "INF" << endl;
    } else {
      cout << graph[start][i] << endl;
    }
  }
  return 0;
}
 
inline int fastmin(int a, int b) {
  return (((a-b)>>31)&(a-b))+b;
}

int c = 0;

int mymin_slow(int a, int b) {
  int t;
  if (a < b) {
    t = a;
    c--;
  } else {
    t = b;
    c--;
  }
  return t;
}
 
void check()
{
  for(int k=0;k<vertex;k++) {
    for(int i=0;i<vertex;i++) {
      int gik= graph[i][k];
      for(int j=0;j<vertex;j++) {
        graph[i][j]= mymin_slow(graph[i][j], gik+graph[k][j]);
      }
    }
  }
}
 
void get_map()
{
  int edge, from ,to;
  cin >> vertex >> numofedge >> start;
   
  fill(graph[0], graph[vertex], INF);
   
  for(int i=0;i<vertex;i++)
    {
      for(int j=0;j<vertex;j++)
        {
          if(i==j)
            {
              graph[i][j]=0;
            }
          /*else
            {
            graph[i][j]=INF;
            }*/
        }
    }
 
  /*for(int i=0;i<vertex;i++)
    {
    dist[i]=INF;
    }
  */
  for(int i=0;i<numofedge;i++)
    {
      cin>>from>>to;
      cin >> graph[from][to];
    }
 
  /*  for(int i=0;i<numofedge;i++)
      {
      int from, to, weight; 
      cin >> from >> to >> weight;
      g[from].push_back({to , weight});
      }
  */ 
 
  /*  for(int i=0;i<vertex;i++)
      {
      for(int j=0;j<vertex;j++)
      {
      cout << graph[i][j] << " ";
      }
      cout << endl;
      }*/
  // dist[start]=0;
   
  /*  cout << vertex << endl;
      for(int i=0;i<vertex;i++)
      {
      for(int j=0;j<vertex;j++)
      {
      cout << graph[i][j] << " ";
      }  
      cout << endl;    
      }*/
   
 
}

Measured memory_bytes: 5300
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000

ll K,N,X,A[200010];
ll ans=0;
ll S[3][5000];
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;
}
map< int64_t, int > ret;
int main(){
    cin>>N;
    for(auto x:prime_factor(N)){
        int diff=1;
        DEB(x.first)DEB(x.second)END;
        while(true){
            x.second-=diff;
            if(x.second>=0)ans++;
            else break;
            diff++;

        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3620
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

A = list(map(int, input().split()))
x = A[0]
k = A[1]
d = A[2]
if x<0:
    x*=-1
if x==0:
    if k%2==0:
        print(0)
    else: print(d)
else:
    if x-k*d<0:
        m=x//d+1
        k-=m
        
        if k%2==0:
            print(abs(x-m*d))
        elif k%2==1:
            print (abs(x-(m-1)*d))
        
    else:
        print(x-k*d)




Measured memory_bytes: 31232
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 107
int p[MAXN];
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int x,n; cin >> x >> n;
	for(int i=0; i<n; i++) cin >> p[i];
	sort(p,p+n);
	int ii=lower_bound(p,p+n,x)-p;
	int xx=x, ox=x;
	for(int i=ii; i<n; i++) {
		if(p[i]==x) {
			x++;
		} else {
			break;
		}
	}
	for(int i=ii; i>=0; i--) {
		if(p[i]==xx) {
			xx--;
		} else {
			break;
		}
	}
	if(x-ox<ox-xx) {
		cout << x << '\n';
	} else {
		cout << xx << '\n';
	}
}


Measured memory_bytes: 3644
n=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
d=[abs(a-b) for (a,b) in zip(x,y)]
for p in range(1,4):
    print(sum(map(lambda t: t**p,d))**(1/p))
print(max(d))


Measured memory_bytes: 5652
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 100000000

using namespace std;

int main() {
   int a,b,c;
   cin >> a >> b >> c;
   cout << (b-a==c-b ? "YES" : "NO") << endl;
 }

Measured memory_bytes: 256
"use strict"
function main(arg) {
    var arg = arg.trim().split("\n")[0].split(" ").map(Number)
    var N = arg[0]
    var K = arg[1]
    
    if (K === 1) {
        console.log(0)
        return
    }
    console.log(N - K)
    return
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21956
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(2000005);
 
int main() {
int K,n;
string S;
cin>>K>>S;
n=S.size();
mint ans=0;
rep(i,K+1){
    ans+=comb(n+i-1,n-1)*mint(25).pow(i)*mint(26).pow(K-i);
}
cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 36596
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    double N, D;
    cin >> N >> D;
    double tmp = N / (D * 2.0 + 1.0);
    int result = ceil(tmp);
    cout << result << endl;
}

Measured memory_bytes: 256
//--- pD ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	public Solution () {
		reader = new Reader();
		while (reader.hasNext()) {
			run_case();
		}
	}

	List<Long> list;
	int tar = (int)1e5 + 5;
	private void run_case() {
		int K = reader.ni();

		list = new ArrayList<>();

		for (int i=1; i<=10; i++) {
			char[] arr = new char[i];
			for (int j=1; j<=9; j++) {
				arr[0] = (char)('0' + j);
				dfs(i, 1, arr);
			}
		}

		System.out.println(list.get(K - 1));
		return;
	}

	private void dfs(int len, int idx, char[] arr) {
		if (list.size() > tar) return;
		if (idx == len) {
			list.add(Long.parseLong(String.valueOf(arr)));
			return;
		}

		char pv = arr[idx - 1];
		for (int i=-1; i<=1; i++) {
			if ((pv == '0' && i == -1) || (pv == '9' && i == 1)) continue;
			arr[idx] = (char)(pv + i);
			dfs(len, idx + 1, arr);
		}

		return;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 35668
#include<stdio.h>
int main(void)
{
  int h,w;
  
  do{
       scanf("%d %d",&h,&w);
       if((h==0)&&(w==0)){
         break;
       }
       for(int i=0;i<h;i++){
         for(int j=0;j<w;j++){
           printf("#");
         }
         printf("\n");
       }
       printf("\n");
    }while(1);
    return 0;
}
      
   


Measured memory_bytes: 2132
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int p[20], n,cnt=0;
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> p[i];
	for (int i = 1; i < n - 1; ++i) {
		int maxv = -10000, minv = 1000000;
		for (int j = -1; j <=1; ++j) {
			maxv = max(maxv, p[i + j]);
			minv = min(minv, p[i + j]);
		}
		if (p[i] != maxv && p[i] != minv) ++cnt;
	}
	cout << cnt << endl;
	return 0;
}

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

typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

const int maxn = 10000005;
int prime[maxn],np[maxn],a[maxn],tot=0;
void init()
{
   a[1]=np[1]=1;
   for(int i=2;i<maxn;++i)
   {
       if(!np[i]) prime[++tot] = i, a[i] = 2;
       for(int j=1;j<=tot;++j)
       {
           if(i*prime[j]>=maxn) break;
           a[i*prime[j]] = a[i] * 2;
           np[i*prime[j]] = 1;
           if(i%prime[j]==0) {
               int cnt = 0;
               int x = i;
               while(x % prime[j] == 0) x /= prime[j], ++cnt;
               a[i*prime[j]] = a[i] / (cnt + 1) * (cnt + 2);
               break;
           }
       }
   }
}
int main() {
    init();
    int n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;++i) ans+=1ll*i*a[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 84292