akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S; S += '~';
  int pos = 0, ret = 0;
  while(pos < S.length() - 1){
    int J = 0, O = 0, I = 0; 
    while(S[pos] == 'J') ++J, ++pos;
    while(S[pos] == 'O') ++O, ++pos;
    while(S[pos] == 'I') ++I, ++pos;
    if(J >= O && O <= I) ret = max( ret, O);
  }                          
  cout << ret << endl;
}

Measured memory_bytes: 2052
character(4) :: s
logical :: flag = .false.
read*,s

if( s(1:1)==s(2:2).and.s(3:3)==s(4:4).and.s(1:1)/=s(3:3) ) flag = .true.
if( s(1:1)==s(3:3).and.s(2:2)==s(4:4).and.s(1:1)/=s(2:2) ) flag = .true.
if( s(1:1)==s(4:4).and.s(2:2)==s(3:3).and.s(1:1)/=s(2:2) ) flag = .true.

if( flag )then
  print*,'Yes'
else
  print*,'No'
end if
end program


Measured memory_bytes: 512
#include<iostream>
using namespace std;
void input();
long long func();
long long getnum(long long *,long long);
long long n,m,*nline,*mline;
int main(){
    input();
    long long ans=func();
    cout<<ans<<endl;
    return 0;
}

void input(){
    cin>>n>>m;
    nline=new long long[n];
    for(int i=0;i<n;++i){
        cin>>nline[i];
    }
    mline=new long long[m];
    for(int i=0;i<m;++i){
        cin>>mline[i];
    }
}

long long func(){
    long long res=(long
    long)getnum(nline,n)*getnum(mline,m)
    %1000000007;
    return res;
}

long long getnum(long long *line,long long num){
    long long res=0;
    for(int i=0;i<num-1;++i){
        res=(long long)(res+(line[i+1]
        -line[i])*(((i+1)*(num-i-1))
        %1000000007))%1000000007;
    }
    return res;
}

Measured memory_bytes: 1792
#include<stdio.h>  

int main()

{ 

  int length = 0;  

int height = 0;  

int area = 0;  

int cir = 0;    

scanf("%d %d", &length, &height); 

  area = length * height;  

cir = length*2 + height*2;  

  printf("%d %d\n", area, cir); 

    return 0;

} 

Measured memory_bytes: 596
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

double memo[301][301][301];
bool used[301][301][301];
int n;

double dfs(int x, int y, int z){
  if(x < 0 || y < 0 || z < 0) return 0;
  if(used[x][y][z]) return memo[x][y][z];
  used[x][y][z] = true;
  double m = D(n)/(x+y+z);
  return memo[x][y][z] = (1+dfs(x-1,y,z)*x/n+dfs(x+1,y-1,z)*y/n+dfs(x,y+1,z-1)*z/n)*m;
}

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

  cin >> n;

  vector<int> a(4,0);
  REP(i,n){
    int x;
    cin >> x;
    a[x]++;
  }

  used[0][0][0] = true;

  cout << fixed << setprecision(12) << dfs(a[1],a[2],a[3]) << endl;

  return 0;
}

Measured memory_bytes: 239872
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <vector>
#include <stack>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

typedef struct P {
    double x;
    double y;
} P;

double isCross(P a, P b, P c, P d)
{
    return ((a.x - b.x)*(c.y - a.y) + (a.y - b.y)*(a.x - c.x)) * ((a.x - b.x)*(d.y - a.y) + (a.y - b.y)*(a.x - d.x));
}

int main(void)
{
    double xa,xb,xc,xd,ya,yb,yc,yd;
    
    while (~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc, &xd, &yd)) {
        P a = {xa, ya};
        P b = {xb, yb};
        P c = {xc, yc};
        P d = {xd, yd};
        if (isCross(a, b, c, d) > 0.0 && isCross(c, d, a, b) > 0.0) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1224
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop,heapify
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

from itertools import accumulate
from functools import lru_cache

M = mod = 10 ** 9 + 7
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)
 
def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]
 



sys.setrecursionlimit(10 ** 6)

g = 0
@lru_cache(None)
def dp(i, par = -1, black = 0):
    global g
    ans = 1
    nokids = 1
    if black:
        for j in g[i]:
            if j != par:
                nokids = 0
                ans = ans * dp(j, i, 0) % mod
    else:
        for j in g[i]:
            if j != par:
                nokids = 0
                ans = ( ans * (dp(j, i, 0) + dp(j, i, 1)) ) % mod

    if nokids:ans = 1
    return ans



n = val()
g = [[] for i in range(n + 1)]

l = []
for _ in range(n - 1):
    a, b = li()
    g[a].append(b)
    g[b].append(a)


root = 1    
ans = dp(root, -1, 0) + dp(root, -1, 1)

print(ans % mod)


Measured memory_bytes: 170776
#include<iostream>
using namespace std;
int main(){
	double n,a;
  	cin >> n;
   	string s;
  	double sum;
  	for(int i=0;i<n;++i){
    	cin >> a >> s;
      (s=="JPY"?sum += a:sum += a*380000);
    }
  	cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
main(){int n,m[4],p[4]={10,50,100,500},x[4],y[4],k,i=0,q,j;while(true){std::cin>>n;if(!n){break;}if(i){printf("\n");}i++;k=0;std::cin>>m[0]>>m[1]>>m[2]>>m[3];for(j=3;j>=0;j--){k+=m[j]*p[j];}q=k-n;for(j=3;j>=0;j--){x[j]=q/p[j];q-=x[j]*p[j];y[j]=std::max(0,m[j]-x[j]);}for(j=0;j<4;j++){if(y[j]){printf("%d %d\n",p[j],y[j]);}}}}

Measured memory_bytes: 1148
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nmc = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nmc[0];
        var m = nmc[1];
        var c = nmc[2];
        var bs = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var a = new int[n][];
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        }

        var k = 0;
        for (int i = 0; i < a.Length; i++)
        {
            var d = c;
            for (int j = 0; j < bs.Length; j++)
            {
                d += a[i][j] * bs[j];
            }
            if (d > 0)
            {
                k++;
            }
        }
        Console.WriteLine(k);
    }
}


Measured memory_bytes: 13396
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))
const int mxN = 105;

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int cnt[mxN];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i], cnt[a[i]]++;
	sort(all(a));
	if(a[n - 2] != a[n - 1]){
		cout << "Impossible" << endl;
		return 0;
	}
	if(a[n - 1] == 1){
		if(n == 2) cout << "Possible" << endl;
		else cout << "Impossible" << endl;
		return 0;
	}
	int us = cnt[a[n - 1]];
	a[n - 1]--;
	int cur = a[n - 1];
	rep(i, a[n - 1] / 2){
		us += cnt[cur];
		if(cnt[cur] < 2 || ((i == ((a[n - 1] / 2) - 1)) && cnt[cur] > 2 && (a[n - 1] % 2 == 0))){
			cout << "Impossible" << endl;
			return 0;
		}
		cur--;
	}
	if(a[n - 1] & 1){
		us += cnt[cur];
		if(cnt[cur] != 1){
			cout << "Impossible" << endl;
			return 0;
		}
	}
	if(us != n) cout << "Impossible" << endl;
	else cout << "Possible" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

// Start of template
//
    #define FOR(i, a, b) for (int i = (a); i < (b); i++)
    #define ROF(i, a, b) for (int i = (b); i > (a); i--)
    #define REP(a) for (int i = 0; i < (a); i++)
    #define pb push_back

    typedef long long ll;
    typedef vector<int> vi;

    const int MOD = 1e9 + 7;

    // to_string methods
    string ts(int n) { return to_string(n); }
    string ts(double n) { return to_string(n); }
    string ts(long double n) { return to_string(n); }
    string ts(long long n) { return to_string(n); }
    string ts(char c) { return to_string(c); }
    string ts(bool b) { return b ? "true" : "false"; }
    string ts(string s) { return s; }

    template <typename T, typename V>
    string ts(pair<T,V> p) {
        return "{" + ts(p.first) + ", " + ts(p.second) + "}";
    }

    template <typename T>
    string ts(T arr[], int len) {
        ostringstream oss;
        oss << "[";
        string delim = "";
        for (int i = 0; i < len; i++) {
            oss << delim << ts(arr[i]);
            delim = ", ";
        }
        oss << "]";
        return oss.str();
    }

    template<typename Container>
    string ts(const Container &v) {
        ostringstream oss;
        oss << "[";
        string delim = "";
        for (const auto &x : v) {
            oss << delim << ts(x);
            delim = ", ";
        }
        oss << "]";
        return oss.str(); 
    }

    template <typename T, typename V>
    string ts(map<T,V> m) {
        ostringstream oss;
        oss << "[";
        string delim = "";
        for (auto&& [first, second] : m) {
            oss << delim;
            oss << "{" << first << ": " << second << "}";
            delim = ", ";
        }
        oss << "]";
        return oss.str(); 
    }

    // IO stuff
    void setI(string s) {
        freopen(s.c_str(), "r", stdin);
    }

    void setO(string s) {
        freopen(s.c_str(), "w", stdout);
    }

    void setIO(string s1, string s2) {
        setI(s1); setO(s2);
    }

    void setUsacoIO(string s) {
        setIO(s + ".in", s + ".out");
    }


// End of template

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

    string s, t;
    cin >> s >> t;

    int ret = 0;
    for (int i = 0; i < s.length(); i++) {
        ret += s[i] != t[i];
    }
    cout << ret << endl;

    return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    if(n==5 || n==7 || n==3)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

typedef long long ll;
/* const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll EPS = 1e-9; */

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ((ll)(x).size())

int main() {
  string s;
  cin >> s;
  if (s[SIZE(s)-1] == 's') {
    cout << s << "es" << endl;
  } else {
    cout << s << 's' << endl;
  }
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, k;
    cin >> n >> k;

    vector<pair<int, int>> pr;
    rep(i, 1, n) {
        pr.push_back(make_pair(0, i));
    }

    int cnt = (n - 1) * (n - 2) / 2;
    if (k > cnt) {
        cout << -1 << endl;
        return 0;
    }
    rep(i, 1, n) {
        if (cnt == k) break;
        rep(j, i + 1, n) {
            if (cnt == k) break;
            pr.push_back(make_pair(i, j));
            cnt--;
        }
    }

    cout << pr.size() << endl;
    for (auto i : pr) {
        cout << i.first + 1 << " " << i.second + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; // 998'244'353LL
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
ll A[200000], B[200000];

pair<ll, ll> calc(int idx){
    vector<ll> v;
    rep(i, N) v.pb(A[i]);
    sort(all(v));
    ll m = v[idx];
    v.clear();
    rep(i, N) v.pb(B[i]);
    sort(all(v));
    ll M = v[idx];
    return { m,M };
}

signed main(){
    cin >> N;
    rep(i, N) cin >> A[i] >> B[i];

    if(N%2 == 1){
        auto p = calc(N/2);
        cout << p.second - p.first + 1 << endl;
    }
    else{
        auto p1 = calc(N/2-1);
        auto p2 = calc(N/2);
        cout << p1.second+p2.second - p1.first-p2.first + 1 << endl;
    }
}

Measured memory_bytes: 9996
#include<bits/stdc++.h>
using namespace std;
int n,m,d,s,_min=2147483647;
int main()
{
	scanf("%d%d",&n,&m);
	for(register int i=1;i<=n;i++)
	{
		scanf("%d",&d);
		_min=min(_min,d);
		s+=d;
	}
	m-=s;
	printf("%d",n+m/_min);
	return 0;
}

Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
#define int long long
#define rep(i,n,k) for(int i=n;i<k;i++)
#define P make_pair
#define F first
#define S second
#define M LLONG_MAX
signed main(void){
    int n,m,ans,w,p,q;
    ans=0;
    string s,s1,s2;
    vector<int> v;
   cin>>n>>m;
  if(n==1||m==1)
    cout<<"1"<<endl;
  else
   cout<<(n*m+1)/2<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int res = 1;
    for(int i=2; i<x; i++){
      res = Math.max(res, getMax(x,i));
    }
    System.out.println(res);
  }

  public static int getMax(int x, int w){
    int r = w*w;
    if(r>x) return -1;
    while(r*w<=x){
      r *= w;
    }
    return r;
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,max,min;
    while(cin>>a>>b>>c){
    max=a;min=a;
    if(a>b)
    {
        min=b;
    }
    if(min>c){
        min=c;
    }
    if(max<b)
    max=b;
    if(max<c)
    max=c;
    cout<<min<<" "<<max<<endl;
}
    
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >>  k;
  ll ans = 0;
  for(ll i=k+1;i<=n;i++) {
    if(n%i == 0) {
      ans += (i-1-(k-1)) * (n/i);
    } else {
      ans += (i-1-(k-1)) * (n/i);
      if( k != 0)
        ans += max<ll>(0, n%i - k+1);
      else
        ans += max<ll>(0, n%i - k);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n,m,c=gets.chomp.split(" ").map{|a| a.to_i}
b=gets.chomp.split(" ").map{|a| a.to_i}
a=[]
count=0
0.upto(n-1) do |i|
  total=0
  a=gets.chomp.split(" ").map{|a| a.to_i}
  0.upto(m-1) do |j|
    total+=b[j]*a[j]
  end
  count+=1 if total+c>0
end
puts count

Measured memory_bytes: 1788
def main():
    s = input()
    acgt = set("ACGT")
    max_len = 0
    for i in range(len(s)+1):
        for j in range(i+1, len(s)+1):
            p = s[i:j]
            if set(p) <= acgt:
                max_len = max(len(p), max_len)
    print(max_len)


if __name__ == "__main__":
    main()




Measured memory_bytes: 38500
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>

typedef long long ll;

using namespace std;

ll GetMaximumSumFlippingSigns(vector<ll>& num) {
    ll sum = 0;
    ll minAbs = -1;
    ll cntNegative = 0;
    for(int i = 0; i < num.size(); ++i) {
        sum += abs(num[i]);
        if(num[i] < 0) {
            cntNegative += 1;
        }
        if(minAbs == -1) {
            minAbs = abs(num[i]);
        } else {
            minAbs = min(minAbs, abs(num[i]));
        }
    }
    if(cntNegative % 2 == 1){
        sum -= 2 * minAbs;
    }
    return sum;
}

int main() {
    int n = 11;
    cin >> n;
    vector<ll> num(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> num[i];
    }

    ll maxSum = GetMaximumSumFlippingSigns(num);
    cout << maxSum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <climits>
#include <algorithm>

using namespace std;

struct Edge
{
	int v, c;
	Edge() {}
	Edge(int _v, int _c) : v(_v), c(_c) {}
};

using G = vector<vector<Edge>>;
using P = pair<double, pair<int, int>>;

double dijkstra(G& g, vector<int>& t, int a, int b) {
	priority_queue<P> que;
	// vector<double> d(g.size(), INT32_MAX);
	vector<vector<double>> d(g.size(), vector<double>(1 << 8, INT32_MAX));

	d[a][0] = 0.0;
	que.push(make_pair(0.0, make_pair(a, 0)));

	while (!que.empty()) {
		auto P = que.top(); que.pop();
		int v = P.second.first;
		int ti = P.second.second;
		double dist = -P.first;
		
		if (dist > d[v][ti]) { continue; }

		for (auto e : g[v]) {
			for(int i = 0; i < t.size(); ++i) {
				if(ti & 1 << i) { continue; }

				if(d[e.v][ti | 1 << i] > d[v][ti] + (double)e.c / t[i]) {
					d[e.v][ti | 1 << i] = d[v][ti] + (double)e.c / t[i];
					que.push(make_pair(-d[e.v][ti | 1 << i], make_pair(e.v, ti | 1 << i)));
				}
			}
			
			// if (ti >= t.size() - 1) { continue; }

			// if (d[e.v][ti + 1] > d[v][ti] + (double)e.c / t[ti + 1]) {
			// 	d[e.v][ti + 1] = d[v][ti] + (double)e.c / t[ti + 1];
			// 	que.push(make_pair(-d[e.v][ti + 1], make_pair(e.v, ti + 1)));
			// }
		}
	}

	return *min_element(d[b].begin(), d[b].end());
}

int main()
{
	while(1) {
		int n, m, p, a, b;
		cin >> n >> m >> p >> a >> b;

		if(n == 0 && m == 0 && p == 0 && a == 0 && b == 0) { break; }

		--a; --b;

		vector<int> t(n);
		for (auto&& ti : t) {
			cin >> ti;
		}

		G g(m);

		for (int i = 0; i < p; ++i) {
			int x, y, z;
			cin >> x >> y >> z;

			--x; --y;

			g[x].emplace_back(y, z);
			g[y].emplace_back(x, z);
		}

		double ans = dijkstra(g, t, a, b);
		if(ans == INT32_MAX) {
			printf("Impossible\n");
		} else {
			printf("%.3f\n", ans);
		}
	}

	return 0;
}

Measured memory_bytes: 4616
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    ll MOD = 1000000007;
    int n;
    cin >> n;

    vi v_[n+1];
    rep(i,n-1){
        int x,y; cin >> x >> y;
        v_[x].push_back(y);
        v_[y].push_back(x);
    }
    
    // 根付き木作成(親は1)
    int par[n+1] = {};
    int child[n+1] = {};
    queue<int> q_;
    q_.push(1);
    par[1] = -1;

    while(q_.size()>0){
        int x = q_.front();
        q_.pop();
        rep(i,v_[x].size()){
            if(par[v_[x][i]]==0){
                child[x]++;
                par[v_[x][i]] = x;
                q_.push(v_[x][i]);
            }
        }
    }

    // ボトムアップで計算(dp[i][0]は黒,dp[i][1]は白)
    ll dp[n+1][2];
    rep(i,n+1){
        dp[i][0] = 1;dp[i][1] = 1;
    }
    int keep[n+1] = {};
    queue<int> q;
    srep(i,1,n+1){
        if(child[i]==0){
            q.push(i);
        }
    }

    while(true){
        // 終了条件 
        if(keep[1]==child[1])break;

        int x = q.front(); q.pop();
        dp[par[x]][0] *= dp[x][1];
        dp[par[x]][0] %= MOD;
        dp[par[x]][1] *= (dp[x][0]+dp[x][1]);
        dp[par[x]][1] %= MOD;
        keep[par[x]]++;
        if(keep[par[x]]==child[par[x]]){
            q.push(par[x]);
        }
    }
    
    ll ans = (dp[1][0] + dp[1][1]) % MOD;
    cout << ans << endl;
    return 0;
}
 
 


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

int main(){
  int num,n,s,p,r;
  char c;
  while(true){
    cin >> num;
    if (num == 0)
      break;
    vector<pair<int,int> >cut;
    cut.push_back(make_pair((int) 1e9+1,-1));
    for(int i=0;i<num;i++){
      cin >> c;
      switch(c){
      case 'W':
	cin >> n >> s;
	for(int j=0;s>0;j++){
	  if (cut[j].second == -1){
	    if (cut[j].first >= s){
	      cut[j].first -= s;
	      cut.insert(cut.begin()+j,make_pair(s,n));
	      s=0;
	    }
	    else if(j==cut.size()){
	      s=0;
	    }
	    else{
	      s -= cut[j].first;
	      cut[j].second = n;
	    }
	  }
	}
	break;
	
      case 'D':
	cin >> p;
	for(int a=0;a<cut.size();a++)
	  if(cut[a].second == p)
	    cut[a].second = -1;
	break;
	
      case 'R':
	cin >> r;
	int sum = 0;
	for(int a=0;a<cut.size();a++){
	  sum += cut[a].first;
	  if(sum > r){
	    cout << cut[a].second << endl;
	    break;
	  }
	}
	break;
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1008
#include<cstdio>
#include<algorithm> 
using namespace std;

long long A,B,C,mx,mn;
int main(){
	scanf("%lld%lld%lld",&A,&B,&C); 
	if(A%2==0||B%2==0||C%2==0)	mn=0;
	else{
		mx=max(A,B);mx=max(mx,C);
		if(mx==A) mn=B*C;
		else if(mx==B)  mn=A*C;
		else mn=A*B;
	}
	printf("%lld\n",mn);
	return 0;
} 

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int x;
    cin >> x;
    cout << (x xor 1) << endl;
    return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <stack>
#include <utility>
#include <algorithm>

using namespace std;

const int kNil = -1;

enum class Color {
  kWhite,
  kGrey,
  kBlack,
};

template <class T>
struct Edge {
  using w_type = T;
  Edge(int u, int v, w_type w): u(u), v(v), w(w) { }
  int u, v;
  w_type w;
  bool operator<(const Edge<T> & rhs) const {
    if (w != rhs.w) { return w < rhs.w; }
    if (u != rhs.u) { return u < rhs.u; }
    return v < rhs.v;
  }
};

template <class Edge>
void GetOrder(const typename vector<Edge>::size_type node_now,
       const vector<vector<Edge>> & adjacency_list,
       vector<Color> & color,
       stack<typename vector<Edge>::size_type> & order) {

  color[node_now] = Color::kGrey;
  for (const auto & e: adjacency_list[node_now]) {
    if (color[e.v] == Color::kWhite) {
      GetOrder(e.v, adjacency_list, color, order);
    }
  }
  color[node_now] = Color::kBlack;
  order.push(node_now);
}

template <class Edge>
void DFSVisit(const typename vector<Edge>::size_type node_now,
       const vector<vector<Edge>> & adjacency_list,
       vector<Color> & color,
       vector<typename vector<Edge>::size_type> & component,
       unsigned & component_num) {
  color[node_now] = Color::kGrey;
  for (const auto & e: adjacency_list[node_now]) {
    if (color[e.v] == Color::kWhite) {
      DFSVisit(e.v, adjacency_list, color, component, component_num);
    }
  }
  color[node_now] = Color::kBlack;
  component[node_now] = component_num;
}

template <class Edge>
decltype(auto) StronglyConnectedComponent(const vector<Edge> & edges,
                 typename vector<Edge>::size_type node_num) {
  using size_type = typename vector<Edge>::size_type;

  vector<vector<Edge>> adjacency_list(node_num, vector<Edge>());
  for (const auto & e: edges) {
    adjacency_list[e.u].push_back(e);
  }

  vector<Color> color(node_num, Color::kWhite);
  stack<size_type> order;
  for (unsigned i = 0; i < node_num; ++i) {
    if (color[i] == Color::kWhite) {
      GetOrder(i, adjacency_list, color, order);
    }
  }

  vector<vector<Edge>> adjacency_list_reversed(node_num, vector<Edge>());
  for (const auto & e: edges) {
    adjacency_list_reversed[e.v].emplace_back(e.v, e.u, e.w);
  }
  color = vector<Color>(node_num, Color::kWhite);
  unsigned component_num = 0;
  vector<size_type> component(node_num);
  while (!order.empty()) {
    auto u = order.top();
    order.pop();
    if (color[u] == Color::kWhite) {
      DFSVisit(u, adjacency_list_reversed, color, component, component_num);
      ++component_num;
    }
  }

  return component;
}

int main(int argc, char const *argv[]) {
  using w_type = unsigned;

  vector<Edge<w_type>> edges;
  unsigned V, E;
  cin >> V >> E;
  for (unsigned i = 0; i < E; ++i) {
    unsigned u, v;
    w_type w;
    cin >> u >> v;
    edges.emplace_back(u, v, 1);
  }

  auto component = StronglyConnectedComponent(edges, V);
  unsigned q, u, v;
  cin >> q;
  for (unsigned i = 0; i < q; ++i) {
    cin >> u >> v;
    if (component[u] == component[v]) {
      cout << "1\n";
    } else {
      cout << "0\n";
    }
  }

  return 0;
}

Measured memory_bytes: 5088
/* vo00_07.cpp */
#include <iostream>
using namespace std;

int main()
{
	int debt = 100000, n, tmp;

	cin >> n;
	while (n--) {
		debt *= 1.05;
		if (tmp = debt % 1000) { debt += 1000; }
		debt -= tmp;
	}

	cout << (int)debt << '\n';

	return 0;
}

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

int main() {
  int N,A,B;
  cin >> N >> A >>B;
  
  int sum = 0;
  int i = 1;
  while(i <= N){
    //ある整数iの各桁の和Cを求める
    int Q = i;
    int R = 0;
    int C = 0;
  
  
  while(true){
    if(Q == 0){
      break;
    }
    R = Q % 10;
   
    Q = Q / 10;
    C += R;
  }
    
    if(C >= A && C <= B){
      sum += i;
    }
    i++;
  }
  cout << sum << endl;

 
}

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

using namespace std;

int main()
{

 int a;
 int b;
 string answer;

 cin >> a >> b;

 if( a < b ){
   answer = "a < b";
 } else if ( a > b ) {
   answer = "a > b";
 } else if ( a == b ) {
   answer = "a == b";
 }

 cout << answer << endl;
}

Measured memory_bytes: 1192
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    string S, a, b, c;
    ll i, judge=1;

    cin >> S;

    while(1){
        if(S.size() == 0){
            judge = 1;
            break;
        }
        else if(S.size() < 5){
            judge = 0;
            break;
        }

        if(S.size()>=5) a = S.substr(S.size()-5);
        if(S.size()>=6) b = S.substr(S.size()-6);
        if(S.size()>=7) c = S.substr(S.size()-7);

        if(S.size()>=5 && (a=="dream" || a=="erase")){
            S = S.substr(0, S.size()-5);
        }
        else if(S.size()>=6 && b=="eraser"){
            S = S.substr(0, S.size()-6);
        }
        else if(S.size()>=7 && c=="dreamer"){
            S = S.substr(0, S.size()-7);
        }
        else{
            judge = 0;
            break;
        }
    }

    if(judge==1) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
    int A, B;
    int sum, sub, mul;
    int ans;

    cin >> A >> B;
    sum = A + B;
    sub = A - B;
    mul = A * B;

    if (sum >= sub) {
        if (sum >= mul) {
            ans = sum;
        }
        else 
            ans = mul;
    }
    else {
        if (sub >= mul) {
            ans = sub;
        }
        else 
            ans = mul;
    }

    cout << ans << endl;

    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N;
	cin >> N;
	REP(i, 3500)REP(j, 3500){
		ll h = i+1;
		ll n = j+1;
		ll x = N*h*n;
		ll y = 4*h*n - N*n - N*h;
		if(y<=0||x<y||x<=0) continue;
		if(x%y==0){
			printf("%d %d %d\n", h, n, x/y);
			return 0;
		}
	}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int n;
	cin>>n;
	cout<<(n%2?(n/2)+1:n/2)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    typedef long long int lint;
    const lint M = 1e9 + 7;
    int n, m;
    cin >> n >> m;

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

    vector<vector<int>> td(n, vector<int>(m,0));
    vector<vector<int>> lr(n, vector<int>(m,0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            td[i][j] = mat[i][j] == '#' ? 0 : (i == 0 ? 0 : td[i-1][j]) + 1;
            lr[i][j] = mat[i][j] == '#' ? 0 : (j == 0 ? 0 : lr[i][j-1]) + 1;
        }
    }

    vector<vector<int>> dt(n, vector<int>(m,0));
    vector<vector<int>> rl(n, vector<int>(m,0));
    for (int i = n-1; i >= 0; --i) {
        for (int j = m-1; j >= 0; --j) {
            dt[i][j] = mat[i][j] == '#' ? 0 : ((i == n-1 ? 0 : dt[i+1][j])) + 1;
            rl[i][j] = mat[i][j] == '#' ? 0 : (j == m-1 ? 0 : rl[i][j+1]) + 1;
        }
    }

    /*for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cout << dt[i][j] << " ";
        }
        cout << endl;
    }*/
    int res = 0;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            res = max(res, dt[i][j] + td[i][j] + lr[i][j] + rl[i][j] - 3);
        }
    }

    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 67328
function Main(input) {
  if ((input[0] == input[1] && input[1] == input[2]) || (input[1] == input[2] && input[2] == input[3])) {
    console.log('Yes');
  } else {
    console.log('No');
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    long double b,a,p;
    cin>>a>>b;
    p=a*b;
    cout<<(long long)(p);
    return 0;
}


Measured memory_bytes: 3732
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		long K = scanner.nextLong();
		int Q = scanner.nextInt();
		HashMap<Integer, Long> hashMap = new HashMap<Integer, Long>();

		for (int i = 1; i <= N; i++) {
			hashMap.put(i, (long) 0);
		}

		for (int i = 0; i < Q; i++) {
			int I = scanner.nextInt();
			hashMap.put(I, hashMap.get(I) + 1);
		}

		for (int i = 1; i <= N; i++) {
			if(hashMap.get(i) + K - Q > 0)
				System.out.println("Yes");
			else
				System.out.println("No");
		}
		
	}
}


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

using namespace std;

int main() {
	string n;
	cin >> n;
	for (int i = 0; i < n.length(); ++i)
		if (n[i] == '9') putchar('1');
		else if (n[i] == '1') putchar('9');
			else putchar(n[i]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int p[510][510];

int main(){
    int n, m, q; cin >> n >> m >> q;
    for(int i = 1; i <= m; ++i) {
        int l, r; cin >> l >> r;
        p[l][r]++;
    }
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= n; ++j){
            p[i][j] += p[i][j-1];
        }
    }
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= n; ++j){
            p[i][j] += p[i-1][j];
        }
    }
    rep(i,q){
        int l, r; cin >> l >> r;
        cout << p[r][r] - p[l-1][r] - p[r][l-1] + p[l-1][l-1] << endl; 
    }
}

Measured memory_bytes: 1920
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  string S;
  cin >> N >> S;
  if (N % 2 != 0) {
    cout << "No" << endl;
    return;
  }
  long half = N / 2;
  rep (i, half) {
    if (S[i] != S[half + i]) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vel vector<long long>
#define vech vector<char>
#define veb vector<bool>
#define vvel vector<vel>
#define vvech vector<vech>
#define int long long
#define pin pair<int,int>
#define ppin pair<int,pin>
#define mkp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define maxel(vec, j) *max_element(vec.begin(), vec.begin()+j)

using namespace std;
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
int vsum(vel v){ return accumulate(v.begin(), v.end(), 0); }
int msum(vvel v){
    int ans = 0;
    rep(i, v.size()){
        ans += vsum(v[i]);
    }
    return ans;
}

signed main() {
    int pr = 1000;
    pr *= pr * pr; pr += 7;
    int A, P;
    cin >> A;
    cin >> P;
    int res = (A*3 + P) / 2;
    cout<<res;
    return 0;
}
/*
 */


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
int A[2010];
int sum = 0;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i], sum += A[i];
    bitset<4000010> ok(0);
    ok[0] = 1;
    for(int i = 0; i < N; i++) ok |= ok << A[i];
    int mid = (sum + 1) / 2;
    for(int i = (sum + 1) / 2; i <= 2000 * 2000; i++){
        if(ok[i]){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1920
#include <iostream>

int main(){
    int n,p1=0,p2=0;
    std::cin >> n;
    while( n != 0){
        for(int i=0;i<n;i++){
            int a ,b;
            std::cin >> a >> b;
            if(a > b){
                p1 += a+b;
            }
            if(b > a){
                p2 += a+b;
            }
            if(a==b){
                p1 += a;
                p2 += b;
            }
        }
        std::cout << p1 << ' ' << p2 << std::endl;
        std::cin >> n;
        p1 = 0;p2=0;
    }
}

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

int main(void)
{
    int n;
    cin >> n;

    vector<char> vec(n, 'a');
    for(int i = 0; i < n; i++){
        cin >> vec[i];
    }

    int start = 0;
    int end = vec.size() - 1;
    int count = 0;

    while(start <= end){
        if(vec[start] == 'W' && vec[end] == 'W'){
            end--;
        }else if(vec[start] == 'W' && vec[end] == 'R'){
            vec[end] = 'W';
            vec[start] = 'R';
            start++;
            end--;
            count++;
        }else if(vec[start] == 'R' && vec[end] == 'W'){
            start++;
            end--;
        }else if(vec[start] == 'R' && vec[end] == 'R'){
            start++;
        }
    }
    
    cout << count << endl;
}

Measured memory_bytes: 3596
n = gets.to_i
a = gets.split().map {|v| v.to_i}

neg = a.count {|v| v < 0}

arr_abs = a.map {|v| v.abs}

if neg % 2 == 0
  puts arr_abs.inject(:+)
else
  puts arr_abs.inject(:+) - arr_abs.min * 2
end


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

int main(){
    ll n, k; cin >> n >> k;
    vector<ll> lis(n), b(41);
    for(int i = 0; i < n; i++){
        cin >> lis[i];
        ll c = lis[i];
        int res = 0;
        while(c > 0){
            b[res] += c & 1;
            c /= 2; res++;
        }
    }
    ll ans = 0, x = 0;
    for(int i = 40; i >= 0; i--){
        if((x + (1LL << i)) > k){
            continue;
        }
        if(n - b[i] > b[i]){
            x += 1LL << i;
        }
    }
    for(int i = 0; i < n; i++){
        ans += x ^ lis[i];
    }
    cout << ans << endl;
}

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

long long int a,b,c,d,x,y;

signed main()
{
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>a>>b>>c>>d;
	x=a/d;if (a%d!=0) x++;
	y=c/b;if (c%b!=0) y++;
	if (x>=y) cout<<"Yes";else cout<<"No";
}


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

#ifdef LOCAL
#include "prabh.hpp"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)

using namespace std;

void solve() {
	int x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	int req = x / d;
	if (req > k) {
		int ans = x - (k * d);
		cout << ans << endl;
		return;
	}

	int v1 = x - (req * d);
	int v2 = v1 - d;
	// dbg(v1, v2);

	if ((k - req) & 1) cout << abs(v2) << endl;
	else cout << abs(v1) << endl;
}


// you should probably see down .. believe me it would help
int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
//	cin >> t_c;
	while (t_c--)
		solve();
}

/*
 * COME ON DUDE .... DONT GET UP UNTIL U GET THE SOLUTION
 * GIVING UP NOT GONNA HELP .. JUST GET YOUR ASS TO WORK ALREADY ..
 * AND FOR FUCKING SAKE ... DONT PANIC !!
*/


Measured memory_bytes: 3612
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    string s;
    cin >> s;

    int count = 0;

    FOR(i, 0, 4){
        if(s[i] == '2'){
            count++;
        }
    }

    p(count);
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int i;
    string a,b,c;
    cin >> a >> b >> c;
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
}

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

using static Input;
class Program
{
    static int N;
    static int[] A;
    static void INPUT()
    {
        N = NextInt();
        A = LineInt();
    }
    static void OUTPUT()
    {
        var ans1 = 0f;
        foreach (var i in A.OrderBy(__ => __).ToArray())
        {
            if (ans1 == 0)
            {
                ans1 = i;
                continue;
            }
            ans1 = (ans1 + i) / 2;
        }

        Console.WriteLine(ans1);
    }
    static void Main(string[] args)
    {
#if DEBUG  
        TESTINPUT();
#else
        INPUT();
#endif
        OUTPUT();
    }

    static void TESTINPUT()
    {
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}



Measured memory_bytes: 13524
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> P;
#define X real()
#define Y imag()
ld restant(P p){return abs(p);}
//polar(x,y) mag=l,arg=y
//typedef unordered_set<ll> usll;
//typedef unordered_multiset<ll> umsll;
typedef multiset<ll> msll;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,ll> > vpll;
typedef priority_queue<ll> pqll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
//typedef unordered_multiset<int> umsi;
//typedef unordered_set<int> usi;
typedef pair<int,int> pi;
typedef vector<pair<int,int> > vpi;
typedef vector<pair<double,double> > vpd;
typedef pair<double,double> pd;
typedef priority_queue<int> pqi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ind_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ind_setll;
#define in insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define be begin
#define en end
#define itr iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mo 1000000007
#define inf 1000000000000000001
#define ninf -1000000000000000001
#define ima INT_MAX
#define imi INT_MIN
#define oncnt __builtin_popcount
#define zerobegin __builtin_clz
#define zeroend __builtin_ctz
#define parity __builtin_parity
#define all(x) x.be(),x.en()
#define eps 1e-9
const ld pii=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return((a-b+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}



int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{	

int n;
cin>>n;
cout<<(n+1)/2;
}return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

vint vec;
int N;

void dfs(int num){
	if(num<=N){
		vec.push_back(num);
	}else{
		return;
	}
	dfs(num * 10 + 7);
	dfs(num * 10 + 5);
	dfs(num * 10 + 3);
}

bool judge(int num){
	bool flg7, flg5, flg3;
	flg7 = flg5 = flg3 = false;

	while(num>0){
		if(num%10==3){
			flg3 = true;
		}
		if(num%10==5){
			flg5 = true;
		}
		if(num%10==7){
			flg7 = true;
		}
		num /= 10;
	}

	return flg7 && flg5 && flg3;
}

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

	cin >> N;
	dfs(7);
	dfs(5);
	dfs(3);

	int ans = 0;

	for (int i = 0; i < vec.size(); i++) {
		if(judge(vec[i])){
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
def main():
    import sys
    input = sys.stdin.readline
    K = int(input())
    M = 10**16
    
    p = K//50
    q = K%50
    
    N = 50
    A = [49+K//50]*50
    for i in range(q):
        A[i] += 50-q+1
    for i in range(q,50):
        A[i] -= q
    
    print(N)
    print(*A)
    

main()

Measured memory_bytes: 38256