akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n),d(n*2+2,0),e(n*2+2,0);
    ll sum = 0;
    REP(i,n){
        cin >> a[i];
        sum+=a[i];
    }
    if(sum%(n*(n+1)/2)!=0){
        put("NO");
        return 0;
    }
    vector<int> b(2*n+1,0);
    int cnt=0;
    REP(i,n){
        int next = (i+1)%n;
        if(a[i]>a[next]-cnt){
            b[i] += (a[i]-(a[next]-cnt)+n-2)/(n-1);
            b[i+n] -= (a[i]-(a[next]-cnt)+n-2)/(n-1)*n;
            b[i+n+1] += (a[i]-(a[next]-cnt)+n-2)/(n-1)*n;
        }
    }
    REP(i,n*2+1){
        d[i+1] = d[i]+b[i];
    }
    REP(i,n*2+1){
        e[i+1] = e[i]+d[i];
    }
    REP(i,n){
        a[i]-=e[i+n+1];
    }
    bool flag = true;
    ll cc = -1;
    REP(i,n){
        if(a[i]%(n*(n+1)/2)!=0){
            flag=false;
        }else if(cc<0){
            cc = a[i]/(n*(n+1)/2);
        }else if(cc!=a[i]/(n*(n+1)/2)){
            flag=false;
        }
    }
    if(flag){
        put("YES");
    }else{
        put("NO");
    }
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF LLONG_MAX / 2;
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;

const ll INF = LLONG_MAX / 2;

#define ARRAY_MAX 100005


typedef struct edge{

    int to;
    int cost;

}EDGE;

vector<ll> dijkstra(int n,vector<vector<EDGE> >& G,int x){

    /*最終的にdは経由点からの最短距離が格納される、その過程では暫定的な最短距離が格納され、最短距離が見つかれば、その都度更新される*/

    vector<ll> d(n,INF);/*最終的な最短距離を保持、初期化はINF*/
    d[x] = 0;
    priority_queue<LL_IP,vector<LL_IP>,greater<LL_IP> > que;/*vectorのpriority_queueで暫定的な最短距離が小さい順に取り出す*/
    que.push(LL_IP(0,x));/*経由点からダイクストラを適用するので経由点の暫定的な最短距離のコストは0*/

    while(!que.empty()){/*queが空になれば最短距離が全て探索できたことになる*/

        LL_IP p = que.top();/*最短距離の１番小さいものの取り出し*/
        que.pop();/*取り出したので調べたとみなし、queから出す*/
        int v = p.second;/*取り出した頂点の番号*/
        if(d[v] < p.first){
            /*取り出した頂点からの最短距離よりも短い経路があるので更新の必要はない*/
            continue;
        }

        for(int i = 0;i < G[v].size(); i++){
            /*取り出した頂点から辺でつながっている頂点への最短距離を調べて現在の値より短ければ更新する*/
            EDGE e = G[v][i];/*取り出した頂点からつながっている頂点を1つ取り出す*/
            if(d[e.to] > d[v] + e.cost){
                /*現在の最短距離よりも、現在の頂点を経由する経路のほうが最短距離が短い場合は最短距離を更新し、次の頂点を調べる*/
                d[e.to] = d[v] + e.cost;/*最短経路の更新*/
                que.push(P(d[e.to],e.to));/*先の頂点を調べるためqueに格納*/
            }
                    
        }
    }
    return d;
}



int main(){

    int n,a,b,c,q,k,x,y;
    cin >> n;
    vector<vector<EDGE> > G(n);/*n個の各頂点からそれ以外の頂点へのコスト*/
    REP(i,n-1){
        cin >> a >> b >> c;
        a--;
        b--;/*配列の添え字へ合わせる*/
        EDGE e1 = {b,c};
        EDGE e2 = {a,c};
        /*無効グラフなので双方向にコストを保持*/
        G[a].pb(e1);/*頂点aから頂点bへのコストがc*/
        G[b].pb(e2);/*頂点bから頂点aへのコストがc*/
    }
    /*辺の張り終わり*/

    cin >> q >> k;
    //cout << q << endl;
    k--;/*配列の添え字に合わせる*/

    vector<ll> d = dijkstra(n,G,k);/*経由点から各頂点への最短距離を格納した配列*/

    REP(i,q){

        cin >> x >> y;
        x--;
        y--;/*配列の添え字に合わせる*/
        cout << d[x] + d[y] << endl;/*経由点から始点、終点までの最短経路を調べる足すことで、経由点を経由した最短経路が求まる*/
    }

    return 0;
}

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

const int N = 1e5 + 5;

int a, n;

int main(){



    cin >> a >> n;
    for (int i = 1; i <= n; ++i){
        int x;
        cin >> x;
        a -= x;
    }
    if (a > 0) cout << "No\n";
    else cout << "Yes\n";   


}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double bunbo = 0;
    for(int i=0;i<n;i++){
      bunbo += 1.0/sc.nextInt();
    }
    System.out.println( (1.0/bunbo) );
  }
}

Measured memory_bytes: 21844
n = gets.to_i
N, K= gets.chomp.split.map(&:to_i)
d = gets.chomp.split.map(&:to_i)
box1 = []
box2 = []
box3 = []

d.each do |i|
	if i <= N
		box1 << i
	elsif N < i && i <= K
		box2 << i
	else
		box3 << i
	end
end

puts [box1.length, box2.length, box3.length].min

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

typedef struct {
    Int y, x;
} p_t;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    vector<pair<char, Int>> a;
    char x = s[0];
    a.emplace_back(x, 1);
    for (Int i = 1; i < s.size(); i++) {
        if (s[i] == a.back().fi) {
            a[a.size() - 1].se++;
        }
        else {
            a.emplace_back(s[i], 1);
        }
    }
    deque<Int> q;
    for (Int i = 0; i < a.size(); i++) {
        q.push_back(a[i].se);
    }
    Int n = s.size();
    Int mi = n;
    while (q.size() > 1) {
        if (q.front() <= q.back()) {
            mi = min(mi, n - q.front());
            Int add = q.front();
            q.pop_front();
            add += q.front();
            q.pop_front();
            q.push_front(add);
        }
        else {
            mi = min(mi, n - q.back());
            Int add = q.back();
            q.pop_back();
            add += q.back();
            q.pop_back();
            q.push_back(add);
        }
    }
    dump(mi);
    return 0;
}

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

int main()
{
    int N, X, Y, Z;
    cin >> N;
    X = 98;
    Y = 36;
    Z = N;
    while (N > 0)
    {
        Z = N % 10;
        if (Z == Y)
        {
            X = Z;
            N /= 10;
            Z = N % 10;
            if (X == Y && Y == Z)
            {
                cout << "Yes" << endl;

                break;
            }
            else
            {
                cout << "No" << endl;
                break;
            }
        }
        else if (N < 10)
        {
            cout << "No" << endl;
        }
        Y = Z;
        N /= 10;
    }
}

Measured memory_bytes: 3620
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main() 
{
  ll N; cin>>N;
  vector<ll> A(N); 
  rep(i,N) cin>>A.at(i);
  
  ll ans=1000,kabu=0;
  
  rep(i,N){
    //cout<<ans<<" "<<kabu<<endl;
    if(i==0) {
      if(A.at(1)>A.at(0)) {kabu+=ans/A.at(0); ans%=A.at(0);} continue;
    }
    if(i==N-1){
      ans+=kabu*A.at(N-1); break;
    }  
    if(A.at(i-1)<=A.at(i)&&A.at(i)>A.at(i+1)) {ans+=kabu*A.at(i); kabu=0;}
    if(A.at(i-1)>=A.at(i)&&A.at(i)<A.at(i+1)) {kabu+=ans/A.at(i); ans%=A.at(i);}
  }  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N;
	cin >> N;
	vector<ll> ue(N);
	vector<ll> si(N);
	ll wa = 0;
	rep(i, N) {
		cin >> ue.at(i);

	}
	wa = 0;
	rep(i, N) {
		cin >> si.at(i);
	}

	ll an = 0;
	rep(i, N) {
		ll get = 0;
		for (ll j = 0; j <= i; j++) {
			get += ue.at(j);
		}
		for (ll j = i; j < N; j++) {
			get += si.at(j);
		}
		an = max(an, get);
	}
	cout << an << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define NumberOfOnes __builtin_popcount
#define LSOne(S) (S & (-S))
#define ll long long
#define two pair<int,int>
#define twoll pair<ll,ll>
#define four pair<two,two>
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define y1 y1922
#define INF 1000000000000000000
#define P 1000000007
#define lmax 1000000000
#define nn 1000003
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define vi vector<int>
#define vll vector<ll>
#define vtwo vector<two>
#define ALL(container) (container).begin(), (container).end()
#define sz(container) (int)(container.size())
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define mid(a,b) (a+b>>1)
#define minN 0
#define maxN 10000000
#define na(x) ((x)<P?(x):(x)-P)
#define ab(a) (-(a)<(a)?(a):-(a))
#define FAST std::ios::sync_with_stdio(false)
#define xRand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define rnd rng
#define IT iterator
typedef
tree<
  int,// aq pair<int,int> shegidzlia
  null_type,
  less/*_equal*/<int>,// aqac
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;
// '_equal' mashin ginda roca multiset gchirdeba
template<class key, class value,class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
ordered_map<int, int> my_map;
inline int rin(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
inline int bin(){
	int x=0;char ch=getchar();
	while (ch<'0'||ch>'9') ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x;
}
int n;
ll ans,a,k,dp[200005];
map<ll,ll>mp;
int main(){FAST;xRand;
cin>>n>>k;
mp[0]++;
for(int i=1;i<=n;i++){
	cin>>a; a--;
	if(i>=k) mp[dp[i-k]]--;
	dp[i]=dp[i-1]+a;
	dp[i]%=k;
	ans+=mp[dp[i]];	
	mp[dp[i]]++;
}
cout<<ans<<endl;

}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
                 *   *   * *   *
                  *   *   *   *
                   *   * *   *
                     *  *   *
					   *  *


*/



Measured memory_bytes: 14336
#include<iostream>
//#include<vector>
//#include<algorithm>
//#include<numeric>
//#include<queue>
#include<cstdio>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n],b[n],c[n-1];
  for(int i=0;i<n;++i) cin >> a[i];
  for(int i=0;i<n;++i) cin >> b[i];
  for(int i=0;i<n-1;++i) cin >> c[i];
  
  int sat=0;
  for(int i=0;i<n-1;++i){
    sat+=b[i];
    if(a[i]+1==a[i+1]) sat+=c[a[i]-1];
  }
  sat+=b[n-1];

  printf("%d\n", sat);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 8000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};

typedef long long ll;

using namespace std;


int ans,ans2;
int n,m;
int l[211111],r[211111],d[211111];
vector<vector<int>> v(211111);
map<P,int> pos;
int flag[211111],res[211111];
void dfs(int n){
	flag[n]=1;
	for(auto x:v[n]){
		if(!flag[x]){
			//ans++;
			res[x]=res[n]+pos[P(n,x)];
			dfs(x);
		}
	}
}


signed main(){

	cin>>n>>m;
	
	rep(i,m){
		cin>>l[i]>>r[i]>>d[i];
		pos[P(l[i],r[i])]=d[i];
		pos[P(r[i],l[i])]=-d[i];
		v[l[i]].push_back(r[i]);
		v[r[i]].push_back(l[i]);
	}
	res[l[0]]=0;
	for(int i=0;i<n;i++){
		if(!flag[i+1])dfs(i+1);
	}
	int f=1;
	rep(i,m){
		if(res[r[i]]-res[l[i]]!=d[i])f=0;
	}
	if(f)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	//DEB(ans)END
}


Measured memory_bytes: 50304
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
//#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
 
 
int main()
{
    fastio;
    map<string ,int> m;
    ll n;cin>>n;
    string s;
    while(n--)
    {
        cin>>s;
        m[s]++;
    }
    ll count=0;
    map<string,int> :: iterator  it;
    it=m.begin();
    while(it!=m.end())
    {
        count++;
        ++it;
    }
    cout<<count<<endl;
      
       
       
        
}

Measured memory_bytes: 19216
#include <iostream>
     
    int main(void) {
      int k, s;
      std::cin >> k;
      std::cin >> s;
      
      int count = 0;
      for (int x = 0; x <= k; ++x) {
        for (int y = 0; y <= k; ++y) {
          int z = s - x - y;
          if ((z >= 0) && (z <= k)) {
            count++;
          }
        }
      }
      
      std::cout << count << std::endl;
      
      return 0;
    }

Measured memory_bytes: 256
n = int(input())
lis = list(map(int,input().split()))
tigai = []
a = 1

for i in lis:
    if i == a:
        pass
    else:
        tigai.append([a,i])
    a = a+1
if len(tigai) == 0:
    print('YES')
elif len(tigai) != 2:
    print('NO')
else:
    if tigai[0][0] == tigai[1][1]:
        print('YES')
    else:
        print('NO')

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

#define inf 0x3f3f3f3f
#define pi acos(-1)
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(),a.end()
template<class T> bool mmin(T &a,T b){return (a>b ?(a=b,true):false);};
template<class T> bool mmax(T &a,T b){return (a<b ?(a=b,true):false);};

int32_t main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	string str;
	cin >> str;
	int num1=0,num2=0;
	num1=num1*10+(int)(str[0]-'0');
	num1=num1*10+(int)(str[1]-'0');
	num2=num2*10+(int)(str[2]-'0');
	num2=num2*10+(int)(str[3]-'0');
	int yymm=(num2>=1 and num2<=12),mmyy=(num1>=1 and num1<=12);
	
	if(yymm and mmyy)
		cout << "AMBIGUOUS\n";
	else if(yymm)
		cout << "YYMM\n";
	else if(mmyy)
		cout << "MMYY\n";
	else
		cout << "NA\n";
#ifdef LOCAL_DEFINE
	cerr << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}




















Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 

fn main() {

    input!{
    	n: i32
    }
    let mut ok = false;
    for i in 1..10 {
    	for j in 1..10 {
    		let m = i*j;
    		if m == n {
    			ok = true;
    		}
    	}
    }
    
    match ok {
    	true  => println!("{}","Yes"),
    	false => println!("{}","No")
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>

#define white 2
#define gray 1 
#define black 0

#define N 100

int n ,M[N][N], ID[N], judge[N], f[N], t;

void dps_visit(int a);
void dps(void);

int main(){
  int i, j, k, id, num;

  scanf("%d", &n);

  for(i = 0; i < n; i++)
    for(j = 0; j < n; j++)
      M[i][j] = 0;

  for(i = 0; i < n; i++){
    scanf("%d%d", &id, &k);

    id--;

    for(j = 0; j < k; j++){
      scanf("%d", &num);
      num--;

      M[id][num] = 1;
    }
  }

  dps();

  return 0;
}

void dps_visit(int a){
  int i;

  judge[a] = gray;

  ID[a] = ++t;

  for(i = 0; i < n; i++){
    if(M[a][i] == 0)
      continue;

    if(judge[i] == white)
      dps_visit(i);
  }

  judge[a] = black;
  f[a] = ++t;
}

void dps(){
  int i;

  for(i = 0; i < n; i++)
    judge[i] = white;
  
  t = 0;

  for(i = 0; i < n; i++)
    if(judge[i] == white)
      dps_visit(i);

  for(i = 0; i < n; i++)
    printf("%d %d %d\n", i + 1, ID[i], f[i]);
}





Measured memory_bytes: 2112
N,M = map(int,input().split())

step = [0]*N

for i in range(M):
    a = int(input())
    step[a-1] = 1

mod = int(1e9+7)

dp = [0]*N

if N == 1:
    if step[0]:
        print(0)
    else:
        print(1)
    exit()

if not step[0] and not step[1]:
    dp[0] = 1
    dp[1] = 2
elif step[0] and not step[1]:
    dp[0] = 0
    dp[1] = 1
elif not step[0] and step[1]:
    dp[0] = 1
    dp[1] = 0
else:
    print(0)
    exit()

for i in range(2,N):
    if step[i]:
        continue
    else:
        dp[i] = (dp[i-1] + dp[i-2])%mod
    
print(dp[-1])


Measured memory_bytes: 7668
#define _USE_MATH_DEFINES
#include<cmath>
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;

int main(){
	int n, m, M, a;
	long sum = 0;
	cin >> n;

	for (int i = 0; i < n; i++){
		cin >> a;
		sum += a;
		if (i){
			if (a>M)M = a;
			else if (a<m)m = a;
		}
		else{
			m = a;
			M = a;

		}


	}
	//cout << fixed << setprecision(5);
	cout << m << " " << M << " " << sum << endl;

	return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
    string s;
    cin >> s;
    int c   = 0;
    int big = 0;
    if (s.front() == 'A') {
        for (int i = 2; i < s.size() - 1; i++) {
            if (s[i] == 'C')
                c++;
        }
        REP(i, s.size()) {
            if (isupper(s[i])) {
                big++;
            }
        }

        if (big == 2 && c == 1) {
            cout << "AC" << endl;
            return 0;
        }
    } else {
        cout << "WA" << endl;
        return 0;
    }

    cout << "WA" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int main(){
	int a, b, i;
	char c[50];
	scanf("%d", &a);
	scanf("%d", &b);
  b-=1;
	for(i = 0;i<a;i++){
		scanf("%s", &c[i]);
	}
	if(c[b]=='A'){
		c[b]='a';
	}else if(c[b]=='B'){
		c[b]='b';
	}else{
		c[b]='c';
	}
	for(i = 0;i<a;i++){
		printf("%c", c[i]);
	}	
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define pb push_back
#define pf push_fron
#define INF 1e9
#define PI acos(-1)
typedef long long ll;

int cnt[100010] = {0};
int check[100010];

int main() {

	int n,ans=0, pos=0;
	cin >> n;
	
	for (int i = 1; i <= n; i++) {
		int t;
		cin >> t;
		
		if (t > 100000) {
			ans++;
		}
		else {
			cnt[t]++;
		}
	}
	for (int i = 1; i <= 100000; i++) {
		if (cnt[i] == 0)continue;
		if (cnt[i] != i) {
			if(cnt[i]>i)ans+=cnt[i]-i;
			else if (cnt[i] < i)ans += cnt[i];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long int lli;
int main()
{
  ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
 lli n,a[100005]={0},i,sum=0;
 cin>>n;
 lli z[n];
 for(i=0;i<n;i++)
 {
     cin>>z[i];
     sum=sum+z[i];
     a[z[i]]++;
 }
 lli q;
 cin>>q;
 while(q--)
 {
     lli b,c;
     cin>>b>>c;
     sum=sum-(a[b]*b);
     sum=sum+(a[b]*c);
     a[c]=a[c]+a[b];
     a[b]=0;
     cout<<sum<<"\n";
 }
}

Measured memory_bytes: 5220
/*
g++ -std=c++11 -o2 -Wall ABC103A.cpp -o ./out/ABC103A.out
./out/ABC103A.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int ans = 100000000;
  int a, b, c;
  cin >> a >> b >> c;
  ans = min(ans, abs(a - b) + abs(b - c));
  ans = min(ans, abs(b - c) + abs(c - a));
  ans = min(ans, abs(c - a) + abs(a - b));
  cout << ans << "\n";
}


Measured memory_bytes: 384
n = int(input())
a = list( map(int, input().split()) )
b = list( map(int, input().split()) )

cnt = 0
for i in range(n):
    monster = min(a[i], b[i])
    a[i] -= monster
    b[i] -= monster
    cnt += monster

    monster = min(a[i+1], b[i])
    a[i+1] -= monster
    b[i] -= monster
    cnt += monster

print(cnt)

Measured memory_bytes: 18476
/* Author: shriamrut
 * Language: C++17
 * Made on:16.02.2020
 * */
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ll long long
#define ss second
#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(v) (v).begin(),(v).end()
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
using namespace std;
void ra(auto a[],int n) { for(int i=0;i<n;i++) cin>>a[i];}
void pa(auto a[],int n) { for(int i=0;i<n;i++) cout<<a[i]<<" ";}
void rv(vector<auto>&v,int n) {v.resize(n);for(int i=0;i<n;i++)	cin>>v[i]; }
void pv(vector<auto>&v) {for(size_t i=0;i<v.size();i++) cout<<v[i]<<" ";}
ll maxl(ll a,ll b) { if(a>b) return a; return b; }
ll minl(ll a,ll b) { if(a<b) return a; return b; }
int main() {
	//IOS;
	int n;
	cin>>n;
	string s;
	map<string,int>m;
	for(int i=0;i<n;i++) {
		cin>>s;
		m[s]++;
	}
	vector<pair<string,int>>v;
	int maxf=INT_MIN;
	for(auto x:m) {
		v.pb({x.ff,x.ss});
		maxf=max(x.ss,maxf);
	}
	vector<string>ans;
	for(auto x:v) {
		if(x.ss==maxf) {
			ans.pb(x.ff);
		}
	}
	sort(ans.begin(),ans.end());
	for(auto x:ans) {
		cout<<x<<"\n";
	}
	return 0;
}



Measured memory_bytes: 32496
# ABC104C
# 解説をみた．
# 一部をとる場合は，まだ残っていてかつ最大の点数のもので良い
import math
inf = 10000000000000000
D, G = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(D)]
ans_cnt = inf
# bit全探索
# ex)i = 0b0000011111 -> 1 ~ 5問目まで全て解く
for i in range(2 ** D):
    flag = True
    tmp_score = 0           # iにおけるscore
    tmp_cnt = 0             # iにおけるcount
    for j in range(D):      # iの各桁が1かどうかを調べる
        if (i >> j) & 1:    # 1の時は足していく
            tmp_score += pc[j][0] * (100 * (j+1)) + pc[j][1]    # p[j]とボーナスを全部足す
            tmp_cnt += pc[j][0]                                 # p[j]:をcountに足す
    if tmp_score < G:       # 足りない時
        for j in range(D-1, -1, -1):    # 使っていなくてかつ最も大きいところからとってくる
            if not (i >> j) & 1:
                tmp_tmp_cnt = math.ceil((G - tmp_score) / ((j+1) * 100))        # Gを超えるのに必要な点数
                if tmp_tmp_cnt > pc[j][0]:          # もってる枚数より多い場合はダメ
                    flag = False
                    break
                else:                               # 足りるならcntに加える
                    tmp_cnt += tmp_tmp_cnt
                    break
    if flag:
        ans_cnt = min(tmp_cnt, ans_cnt)
print(ans_cnt)

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;
public class Main {


    public static void main(String[] args) {


        Scanner scan = new Scanner(System.in);
int A=scan.nextInt();
        int B =scan.nextInt();
        int C=scan.nextInt();
        int D=scan.nextInt();
        int E=scan.nextInt();
if (A==0){System.out.println("1");}
        if (B==0){System.out.println("2");}
        if (C==0){System.out.println("3");}
        if (D==0){System.out.println("4");}
        if (E==0){System.out.println("5");}
        
        }
    }



Measured memory_bytes: 35720
#include <iostream>
#include <string>
#include <list>
using namespace  std;

struct StDtl
{
  int m_iHeight;
  int m_iArea;

  StDtl(int a_iHeight) :
    m_iHeight(a_iHeight), m_iArea(0)
  { }

  ~StDtl() { }
};

struct StSum
{
  bool m_bSumOK;
  int m_iHeight;
  int m_iArea;

  StSum(bool a_bSumOK, int a_iHeight, int a_iArea) :
    m_bSumOK(a_bSumOK), m_iHeight(a_iHeight), m_iArea(a_iArea)
  { }

  ~StSum() { }

};

void fnCrossSectAreaSet(list<StDtl> &a_rltoDtl, list<StSum> &a_rltoSum)
{
  string sCrossSect;
  int iHeight = 0;
 
  cin >> sCrossSect;

  for (int i = 0; i < sCrossSect.size(); i++)
  {
   
    for (auto itltoDtl = a_rltoDtl.begin(); itltoDtl != a_rltoDtl.end(); ++itltoDtl)
    {
      itltoDtl->m_iArea++;
    }

    if (sCrossSect.at(i) == '\\')
    {
      StDtl oDtl(iHeight);
      a_rltoDtl.push_back(oDtl);
      iHeight--;
    }
    else if (sCrossSect.at(i) == '/')
    {
      iHeight++;
      bool bSumOK;
      int iSum = 0;

      if (a_rltoDtl.size() > 0)
      {
        iSum = a_rltoDtl.back().m_iArea;
        a_rltoDtl.pop_back();

        if (a_rltoDtl.size() == 0)
          bSumOK = false;
        else
          bSumOK = true;

        for (auto itltoSum = a_rltoSum.begin(); itltoSum != a_rltoSum.end(); )
        {
          if (itltoSum->m_bSumOK  == true   &&
              itltoSum->m_iHeight < iHeight)
          {
            iSum += itltoSum->m_iArea;
            itltoSum = a_rltoSum.erase(itltoSum);
            continue;
          }
          itltoSum++;
        }

        StSum oSum(bSumOK, iHeight, iSum);
        a_rltoSum.push_back(oSum); 
      }
      else
        for (auto itltoSum = a_rltoSum.begin(); itltoSum != a_rltoSum.end(); ++itltoSum)
          itltoSum->m_bSumOK = false;
    }
  }
}

void  fnCrossSectAreaGet(const list<StSum> &a_cnrltoSum)
{
  int iArea = 0;
  for (auto itltoSum = a_cnrltoSum.begin(); itltoSum != a_cnrltoSum.end(); ++itltoSum)
    iArea += itltoSum->m_iArea;

  cout << iArea << endl;
  cout << a_cnrltoSum.size() ;
  if (a_cnrltoSum.size() > 0)
  {
    cout << " ";
    for (auto itltoSum = a_cnrltoSum.begin(); itltoSum != a_cnrltoSum.end(); ++itltoSum)
    {
      if (itltoSum != a_cnrltoSum.begin()) cout << " ";
      cout << itltoSum->m_iArea;
    }
  }
  cout << endl;
}

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

  list<StDtl> ltoDtl;
  list<StSum> ltoSum;

  fnCrossSectAreaSet(ltoDtl, ltoSum);
  fnCrossSectAreaGet(ltoSum);

  return 0;
}

Measured memory_bytes: 1840
#include<iostream>
#define rep(i,f,t) for(int i=f;i<t;i++)
#define inf 200010
using namespace std;
int main(){
	int n;
  cin>>n;
  int a[n];
  rep(i,0,n)cin>>a[i];
  int mini=inf,cnt=0;
  rep(i,0,n){
  	if(a[i]<mini){
    	cnt++;
      	mini=a[i];
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
long long a,b,c,d;
scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
if (abs(c-a)<=d || abs (b-a)<=d && abs (c-b)<=d)
printf("Yes");
else
printf("No");
}


Measured memory_bytes: 1732
// D - Friend Suggestions
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

#define MAX 100000+1
int N,M,K;
vvi F(MAX),B(MAX);//friend,block
vi gid(MAX);

int bfs(int root){
	queue<int> q;
	q.push(root);
	while(!q.empty()){
		int p = q.front(); q.pop();
		if(gid[p]) continue;
		gid[p] = root;
		for(auto c:F[p]) q.push(c);
	}
	return root;
}

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

	rp(i,0,M){
		int s,t; cin>>s>>t;
		F[s].push_back(t);
		F[t].push_back(s);
	}

	vi cnt(N+1);
	rp(i,1,N+1) cnt[gid[bfs(i)]]++;

	rp(i,0,K){
		int s,t; cin>>s>>t;
		if(gid[s] != gid[t]) continue;
		B[s].push_back(t);
		B[t].push_back(s);
	}

	int self = 1;
	rp(i,1,N+1) cout<< cnt[gid[i]]-F[i].size()-B[i].size()-self <<" ";

}

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

using namespace std;

struct node{

	long long int a,b;

};

bool cmp(node e,node f)

{

	if(e.a!=f.a)

	return e.a<f.a;

	else

	return e.b>f.b;

}

int main(){

long long int n,m,y=0;

cin>>n>>m;

node d[n+1];

for(int i=1;i<=n;i++)

cin>>d[i].a>>d[i].b;

sort(d+1,d+n+1,cmp);

for(int i=1;i<=n;i++){

	if(d[i].b<m)

	{

		y+=d[i].a*d[i].b;

		m-=d[i].b;

	}

	else

	{

		y+=d[i].a*m;

		break;

	}

}

cout<<y;

}


Measured memory_bytes: 1792
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll inf = 1e9 + 7;
const ll Mod = 998244353;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

int GCD(int A, int B){
  if (A < B) swap(A, B);
  while (A % B != 0){
    A = A % B;
    swap(A, B);
  }
  return B;
}

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

  int ans = 0;
  for (int i = 1; i <= K; i++){
    for (int j = 1; j <= K; j++){
      for (int k = 1; k <= K; k++){
        ans += GCD(i, GCD(j, k));
      }
    }
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3632
use proconio::input;

fn main() {
    input! {
        n: usize,
        xs: [usize; n-1],
    };

    let mut array = [0; 200000];
    for x in xs {
        array[x-1] += 1;
    }

    for v in array.iter().take(n) {
        println!("{}", v);
    }
}


Measured memory_bytes: 5532
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 20){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/

/*
const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}
*/

double dp[3010][3010];
void solve(){
  ll N;
  cin >> N;
  vector<double> p(N);
  rep(i, N) cin >> p[i];
  dp[0][0] = 1;
  rep(i, N){
    rep(j, N+1){
      dp[i+1][j+1] += dp[i][j] * p[i];
      dp[i+1][j] += dp[i][j] * (1.0 - p[i]);
    }
  }
  double ans = 0;
  rep(o, N+1){
    ll x = N - o;
    if(o > x){
      ans += dp[N][o];
    }
  }
  pres(ans);
}

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


Measured memory_bytes: 70784
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <algorithm>
#include <cstdlib>
#include <cmath> 
using namespace std;

int main(){
    string S, T;
    cin >> S >> T;
    if(S == T){
        cout << "Yes" << endl;
        return 0;
    }
    //文字列の長さを取得
    int len;
    len = S.length();
    for(int i=0;i<len;i++){
        //Sを回転させる
        char temp;
        temp = S[len -1];
        for(int j=len-1;j>0;j--){
            S[j] = S[j-1];
        }
        S[0] = temp;
        if(S == T){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int c,r,cal,value,i,j,k;
    while(scanf("%d%d",&c,&r)!=EOF)
    {
        if(c==0 && r==0)
        {
            break;
        }
        else
        {
            for(i=0; i<c; i++)
            {
                for(j=0; j<r; j++)
                {
                  if(i==0)
                  {
                      cout<<"#";
                  }
                  else if(i==c-1)
                  {
                      cout<<"#";
                  }
                  else{
                    if(j==0 || j==r-1)
                    {
                        cout<<"#";
                    }
                    else
                    {
                        cout<<".";
                    }
                  }
                }
                cout<<endl;
            }
            cout<<endl;
        }

    }
}



Measured memory_bytes: 3112
// きりみんちゃんの配信からきました
// 左右をとる+-1のしゃくとり、左がマイナスかつ右がプラスの場合には「左に行った後折り返す」vs「右に行ったあと折り返す」が発生する
// ゼロ含む場合マジでなんなんだよ
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := make([]int, n)
	includeZero := false
	zeroIdx := -1
	for i := 0; i < n; i++ {
		var j int
		fmt.Scan(&j)
		a[i] = j
		if j == 0 {
			includeZero = true
			zeroIdx = i
		}
	}
	if includeZero {
		// ゼロを含む場合、よくわかんなかったので値を更新することにした
		if zeroIdx != 0 && zeroIdx != n-1 {
			if abs(a[zeroIdx-1]) < abs(a[zeroIdx+1]) {
				a[zeroIdx] = a[zeroIdx-1]
			} else {
				a[zeroIdx] = a[zeroIdx+1]
			}
		}
	}
	ans := 10000000000000000
	r := 0
	tmp := 0
	for l := 0; l <= n-k; l++ {
		for r < n && r-l < k {
			tmp += a[r]
			r += 1
		}
		if a[r-1] <= 0 {
			tmp = a[l] * -1
		} else if a[l] >= 0 {
			tmp = a[r-1]
		} else if a[l] < 0 {
			// これが無限にバグった原因 0を挟んでいる状態だと右にいくか左にいくかで変わるんだよ（あたりまえ）
			tmp = min(a[l]*-2+a[r-1], a[r-1]*2+a[l]*-1)
		}
		ans = min(ans, tmp)
		tmp -= a[l]
	}
	fmt.Println(ans)
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 5504
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define PQS priority_queue <int, vector<int>, greater<int> > 
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve() {
  int x, k, d;
  cin >> x >> k >> d;
  if(x < 0) x*=-1;
  int mn = x%d;
  int needed = (x-mn)/d;
  if(needed > k) {
    mn = x - k*d;
    cout << mn << '\n'; return;
  }
  k -= needed;
  if(k%2) {
    mn = abs(mn-d);
  } 
  cout << mn << '\n';
}

/*
  * overflow, array bounds
  * do smth instead of nothing and stay organized
*/
signed main() {   
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
  #endif
   int t = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
   //  cout << "Case #" << i << ": ";
     solve();
  }
}    

/*

*/

Measured memory_bytes: 3656
#include<iostream>
using namespace std;
int main(){
  int A,B,C,X;
  int count=0;
  cin>>A>>B>>C>>X;
  for(int a=0;a<=A;a++){
    for(int b=0;b<=B;b++){
      for(int c=0;c<=C;c++){
        if(500*a+100*b+50*c==X){
          count++;
        }
      }
    }
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
from itertools import combinations, permutations, product, combinations_with_replacement, accumulate
from heapq import heapify, heappop, heappush, heappushpop
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from math import sqrt, log, floor, ceil, factorial, cos, sin, pi#, gcd
from fractions import gcd
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
INF = float('inf')
LINF = 2**63-1
NIL = -LINF
MOD = 10**9+7
MGN = 4
def II(): return int(input())
def IF(): return float(input())
def IS(): return input().replace('\n', '')
def ILCI(n: int): return [II() for _ in range(n)]
def ILCF(n: int): return [IF() for _ in range(n)]
def ILI(): return list(map(int, input().split()))
def ILLI(n: int): return [[int(j) for j in input().split()] for i in range(n)]
def ILF(): return list(map(float, input().split()))
def ILLF(n: int): return [[float(j) for j in input().split()] for i in range(n)]
def LTOS(lst: list, sep: str = ' '): return sep.join(map(str, lst))
def DEC(lst: list): return list(map(lambda x: x-1, lst))
def INC(lst: list): return list(map(lambda x: x+1, lst))


def stoli(s, sep = ''):
    """ 文字列と区切り文字(列)を受け取り、
    整数のリストにして返す """
    if sep == None or sep == '':
        return list(map(int, list(s)))

    ls = []
    for e in s.split(sep):
        if e == None or e == '':
            continue
        else:
            ls.append(e)

    return list(map(int, ls))


def main():
    N, P = ILI()
    S = IS()

    d = stoli(S)
    
    d.reverse()

    if 10%P == 0:
        ans = 0
        for l in range(N):
            if d[l] % P == 0:
                ans += N-l
        print(ans)
        return 0

    md = [0] * N
    ten = 1
    for i in range(N):
        md[i] = (d[i] * ten) % P
        ten *= 10
        ten %= P
    
    sum = [0] * N
    sum[0] = md[0]
    for i in range(1,N):
        sum[i] = (sum[i-1] + md[i]) % P

    ans = 0
    cnt = [0] * P
    for i in range(N):
        ans += cnt[sum[i]]
        cnt[sum[i]] += 1
    ans += cnt[0]

    print(ans)
    return 0


if __name__ == '__main__':
    main()


Measured memory_bytes: 22012
#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)
using namespace std;
typedef long long ll;
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))

const ll INF = 1LL << 60;
ll w[110], v[110];
ll dp[110][100010];

int main() {
  int n, W;
  cin >> n >> W;
  rep(i,n) cin >> w[i] >> v[i];
  rep(i,n) {
    for(int sum_w = 0; sum_w <= W; ++sum_w){
      if(sum_w - w[i] >= 0){
        maxs(dp[i+1][sum_w], dp[i][sum_w-w[i]]+v[i]);
      }
      maxs(dp[i+1][sum_w], dp[i][sum_w]);
    }
  }
  cout << dp[n][W] << endl;
  return 0;
}


Measured memory_bytes: 79360
N, M = map(int, input().split())
graph = [[] for i in range(N)]
for i in range(M):
    x, y, z = map(int, input().split())
    x, y = x-1, y-1
    graph[x].append(y)
    graph[y].append(x)
visited = [False for i in range(N)]
def dfs(v):
    Q = []
    visited[v] = True
    Q.append(v)
    while len(Q) > 0:
        v = Q.pop()
        for u in graph[v]:
            if not visited[u]:
                visited[u] = True
                Q.append(u)

count = 0
for i in range(N):
    if not visited[i]:
        dfs(i)
        count += 1
print(count)



Measured memory_bytes: 23564
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll dp[100][2][2][2];
ll x, y;

ll rec(int k, int f1, int f2, int f3){
    if(k==-1)return 1;
    if(dp[k][f1][f2][f3]!=-1)return dp[k][f1][f2][f3];
    ll ans = 0;
    int Y = (y>>k)&1, X = (x>>k)&1;
    if(f1 && f2){
        ans += 3*rec(k-1,1,1,f3);
    }
    if(f1 && !f2){
        if(Y)ans += 2*rec(k-1,1,0,f3) + rec(k-1,1,1,f3);
        else ans += rec(k-1,1,0,f3);
    }
    if(!f1 && f2){
        if(f3){
            if(!X)ans += 2*rec(k-1,0,1,f3)+rec(k-1,1,1,f3);
            else ans += rec(k-1,0,1,f3);
        }
        else {
            if(!X)ans += rec(k-1,0,1,0)+rec(k-1,1,1,1);
            else ans += rec(k-1,0,1,1);
        }
    }
    if(!f1 && !f2){
        if(X==Y){
            if(f3)ans += rec(k-1,0,0,1);
            else {
                if(X==1)ans += rec(k-1,0,0,1);
                else ans += rec(k-1,0,0,0);
            }
        }
        else if(X>Y)return dp[k][f1][f2][f3] = 0;
        else {
            if(!f3){
                ans += rec(k-1,1,0,1);
                ans += rec(k-1,0,1,0);
            }
            else {
                ans += rec(k-1,0,0,f3);
                ans += rec(k-1,1,0,f3);
                ans += rec(k-1,0,1,f3);
            }
        }
    }
    ans %= mod;
    return dp[k][f1][f2][f3]=ans;
}

int main(){
    cin>>x>>y;
    rep(i,100)rep(j,2)rep(k,2)rep(l,2)dp[i][j][k][l]=-1;
    cout<<rec(61,0,0,0)<<endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
from collections import deque

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W, K = lr()
SX, SY, GX, GY = lr()
SX -= 1; SY -= 1; GX -= 1; GY -= 1
pond = [sr() for _ in range(H)]
INF = 10 ** 10
dist = [[INF] * W for _ in range(H)]
dist[SX][SY] = 0
que = deque([(0, SX, SY)])
UDLR = [(0, 1), (1, 0), (0, -1), (-1, 0)]
while que:
    d, px, py = que.popleft()
    if px == GX and py == GY:
        print(d); exit()
    if dist[px][py] < d:
        continue
    nd = d + 1
    for dx, dy in UDLR:
        nx = px + dx; ny = py + dy
        for _ in range(K):
            if not (0 <= nx < H) or not (0 <= ny < W) \
                    or dist[nx][ny] < nd or pond[nx][ny] == '@':
                break
            if dist[nx][ny] > nd:
                que.append((nd, nx, ny))
                dist[nx][ny] = nd
            nx += dx; ny += dy

print(-1)
            

Measured memory_bytes: 130012
import java.util.Map.Entry;
import java.util.*;

import org.w3c.dom.css.Counter;

public class Main {
//public class App {

    public static void main(String[] args){
     //スキャン
     Scanner s = new Scanner(System.in);
     // 入力
        int n = s.nextInt();
        if(n /100 == 7 || n % 100 /10 ==7 || n%10 ==7){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
        
    
    }
  
}


Measured memory_bytes: 35844
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> vec(h);
    
    for(int i = 0; i < h; i++){
        cin >> vec.at(i);
    }

    for (int j = 0; j < h+2; j++)
    {
        cout << "#";
        if(j == 0 || j == h + 1){
            for(int k = 0; k < w; k++){
                cout << "#";
            }
        }
        else cout << vec.at(j - 1);

        cout << "#" << endl;
    }
    
    return 0;

}

Measured memory_bytes: 512
n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
#m = y[n//2-1:n//2+1]
m_index = n//2-1
m = y[m_index]

for i in range(n):
  if x[i] <= m:
    print(y[m_index+1])
  else:
    print(y[m_index])

Measured memory_bytes: 30836