akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i]
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion




int32_t main() {
    make(int, n, m);
    n = 2 * m + 1;
    int q = n / 2;
    q += q & 1;
    for(int i = 1; 2 * i <= q; ++i){
        cout << i << ' ' << (q + 1) - i << '\n';
    }
    q++;
    for(int i = q; i + i < n + q;++i){
        cout << i << ' ' << (n + q) - i << '\n';
    }

    return 0;
}

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

int main() {
  int n,t;
  cin>>n>>t;
  int bad=0;
  vector<int>vec(n);
  vector<int>vek(n);
  for(int i=0;i<n;i++) {
    int a,b;
    cin>>a>>b;
    vec.at(i)=a;
    vek.at(i)=b;
    if(vek.at(i)>t) {
      vec.at(i)=2000;
      bad++;
    }
  }
  if(bad<n) {
    sort(vec.begin(), vec.end());
    cout<<vec.at(0)<<endl;
  }
  else if(bad==n) {
    cout<<"TLE"<<endl;
  }
}

Measured memory_bytes: 256
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    int a,b,n,ans=99999,sum=0;
    //bool flag=false;

    cin >> n;

    for(int i=1;i<n;i++){
        a=i;
        b=n-i;
        sum=0;
        while(a>0){
            sum+=a%10;
            a/=10;
        }
        while(b>0){
            sum+=b%10;
            b/=10;
        }
        ans=min(sum,ans);
    }

    //cout << (flag ? "Yes" : "No") << endl;
    cout << ans << endl;
    //printf("%.10f",ans_d);cout<<endl;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    char c;
    cin>>c;
    //cout<<'a'-'A'<<endl;
    if(c<='Z'){
        cout<<'A'<<endl;;
    }
    else{
        cout<<'a'<<endl;
    }
    return 0;

}
/*


*/


Measured memory_bytes: 3620
N,M,X=list(map(int,input().split()))
cost = []
tech = []
for _ in range(N):
    book=list(map(int,input().split()))
    cost.append(book[0])
    tech.append(book[1:])

ans = 10**10
for i in range(1,2**N):
    tmp = [0]*M
    c = 0
    for ind,j in enumerate("{:0>{haba}b}".format(i, haba=N)):
        if j == "0":
            continue
        c+=cost[ind]
        for k,upp in enumerate(tech[ind]):
            tmp[k]+=upp
    isOk = True
    for t in tmp:
        if t<X:
            isOk = False
            break
    if isOk:
        ans = min(ans,c)
if ans == 10**10:
    print(-1)
else:
    print(ans)
        
            

Measured memory_bytes: 69544
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	solve(){}
	int operator()(set<pii>&mf, vi&x, vi&y) {
		for(auto mx:x)
		{
			for(auto my:y)
			{
				if(mf.find(make_pair(mx, my))==mf.end()) return 1;
			}
		}
		return 0;
	}
};


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

	for(;;)
	{
		int h, w, m;
		cin >> h >> w >> m;
		if(cin.fail()) break;

		vi x(m), y(m);
		set<pii> mf;
		for(int i=0;i<m;i++)
		{
			cin >> y[i] >> x[i];
			mf.insert(make_pair(x[i], y[i]));
		}

		vi mx(w+1), my(h+1);
		int mx_max=0, my_max=0;
		for(int i=0;i<m;i++)
		{
			mx[x[i]]++;
			my[y[i]]++;
			max_u(mx_max, mx[x[i]]);
			max_u(my_max, my[y[i]]);
		}

		vi tx, ty;
		for(int i=1;i<=w;i++)
		{
			if(mx[i]==mx_max) tx.push_back(i);
		}
		for(int i=1;i<=h;i++)
		{
			if(my[i]==my_max) ty.push_back(i);
		}

		int ans=mx_max+my_max-1;
		cout << ans+solve()(mf, tx, ty) << "\n";
	}
	return 0;
}


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

int a[1001],n;

bool check()
{
    for(int i=1;i<=n;++i)if(a[i]%2)return false;
    return true;
}

int main()
{
    cin >> n;
    for(int i=1;i<=n;++i)
    cin >> a[i];
    int ans=0;
    while(check())
    {
        ++ans;
        for(int i=1;i<=n;++i)a[i]/=2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    System.out.println(Math.abs(x-a) > Math.abs(x-b) ? "B" : "A");
  }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	map<int,int> m;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		if(m.count(x)){
			cout << "NO";
			return 0;
		}
		m[x]++;
	}
	cout << "YES";

	return 0;
}



Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int p[N];
	rep(i, 0, N) {
		cin >> p[i];
		p[i]--;
	}

	ll rsl = 0;
	if(p[0] == 0) {
		swap(p[0], p[1]);
		rsl++;
	}

	rep(i, 1, N - 1) {
		if(p[i] == i) {
			if(p[i + 1] == i + 1) {
				rsl++;
				swap(p[i], p[i + 1]);
			} else {
				rsl++;
				swap(p[i - 1], p[i]);
			}
		}
	}
	if(p[N - 1] == N - 1) rsl++;

	cout << rsl << endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pow_mod(ll fi,ll se,ll mod){
  if(se==0){
    return 1;
  }
  if(se%2){
    return pow_mod(fi,se-1,mod)*fi%mod;
  }
  ll t=pow_mod(fi,se/2,mod);
  return t*t%mod;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

vector<pair<int,int>> Dir={{-1,0},{1,0},{0,1},{0,-1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/



int main(){
  double n,k;
  cin>>n>>k;
  double ans=0;
  double tmp;
  for(double i=1;i<n+1;i++){

    tmp=(double)1.0000000000/(double)n;
    for(ll j=i;j<k;j*=2){
      tmp*=0.5000000000000;
    }
    ans+=tmp;
  }
  cout<<fixed;
  cout<<setprecision(12);
  op(ans);
  return 0;
}

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

int main(){
  int n,i,j,sa,sum=0;
  cin>>n;
  int v[n],c[n];
  for(i=0;i<n;i++){
    cin>>v[i];
  }
  for(i=0;i<n;i++){
    cin>>c[i];
  }
  for(i=0;i<n;i++){
    sa=v[i]-c[i];
    if(sa>0)sum+=sa;
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
      	int count = 0;
      
      	for(int i = 0;i < s.length()/2;i++){
        	if(s.charAt(i) != s.charAt(s.length()-1-i)) count++;
        }
      
      	System.out.println(count);
	}
}

Measured memory_bytes: 35772
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
using namespace std;
#define MAX_N  100
int main(void) {
    string s;
    cin >> s;
    string t= "keyence";
    bool ans = false;
    if (s.length() == t.length() && s == t) ans = true;

    int dif;
    dif = s.length() - t.length()+1;
    string new_t;
    for(int i=0; i<t.length(); i++ ) {
        new_t = s.substr(0, i+1) + s.substr(i+dif, t.length());
//        cout << new_t <<endl;
        if (new_t == t) ans = true;
    }
    if(ans) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll N;
    cin>>N;
    ll ans{};
    for(ll i=2;i*i<=N;i++){
        if(N%i==0){
            int cnt=0;
            while(N%i==0){
                cnt++;
                N/=i;
            }
            Fr(j,100){
                cnt-=j;
                if(cnt<0) break;
                ++ans;
            }
        }
    }
    if(N>1) ++ans;
    cout<<ans<<endl;
}

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

using namespace std;

int main() {
    int n; cin >> n;
    vector<long long> R(n); for(int i = 0; i < n; ++i) cin >> R[i];

    long long m = R[0];
    long long ans = -(1LL<<32);
    for (int i = 1; i < n; ++i) {
        ans = max(ans, R[i] - m);
        m = min(m, R[i]);
    }
    cout << ans << endl;
}



Measured memory_bytes: 4380
#include <stdio.h>
#define MAX 500000

int parent(int );
int left(int );
int right(int );
void buildMaxHeap(int []);
void maxHeapify(int [],int);

int n;

int main(void){
  
  int i;
  int Tree[MAX];
  
  scanf("%d",&n);
  
  for(i = 1; i <= n;i++)
    scanf("%d",&Tree[i]);
  
  
  buildMaxHeap(Tree);
  
  for(i = 1;i <= n;i++)
    printf(" %d",Tree[i]);
  
  printf("\n");
  
  return 0;
}

int parent(int i){
  return i / 2;
}

int left(int i){
  return 2 * i;
}

int right(int i){
  return 2 * i + 1;
} 

void buildMaxHeap(int Tree[]){
  int i;

  for(i = n/2;i >= 1;i--)
    maxHeapify(Tree, i);
}

void maxHeapify(int Tree[], int i){
  int l = left(i);
  int r = right(i);
  int largest;
  int tmp;

  if(l <= n && Tree[l] > Tree[i])
    largest = l;

  else
    largest = i;

  if(r <= n && Tree[r] > Tree[largest])
    largest = r;

  if(largest != i){
    tmp = Tree[largest];
    Tree[largest] = Tree[i];
    Tree[i] = tmp;
    maxHeapify(Tree, largest);
  }
}

Measured memory_bytes: 2552
L = 100
@memo = Array.new(9) {Array.new(101) {[]}}

def solve(num, start, sum)
  return 0 if sum < 0 or start > L
  return (start <= sum and sum <= L) ? 1 : 0 if num == 1
  a = @memo[num - 1][start][sum]
  return a if a
  co = 0
  lim = [L, (2 * sum - num ** 2 + num) / (2 * num)].min
  (start..lim).each do |i|
    co += solve(num - 1, i + 1, sum - i)
  end
  @memo[num - 1][start][sum] = co
end
  
until (a = $<.gets.split.map(&:to_i)) == [0, 0]
  puts solve(a.first, 0, a.last)
end


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

int main(void){
    int x,y;
    cin>>x>>y;
    int group1[7] = {1,3,5,7,8,10,12};
    int group2[4] = {4,6,9,11};
    int x_group=3,y_group=3;
    for(int i=0;i<7;i++){
        if(group1[i] == x) x_group=1;
        if(group1[i] == y) y_group=1;
    }
    for(int i=0;i<4;i++){
        if(group2[i] == x) x_group=2;
        if(group2[i] == y) y_group=2;
    }

    cout<<(x_group==y_group?"Yes":"No")<<endl;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[],int n,int g){
	for (int i = g; i < n; ++i) {
		int v=A[i];
		int j=i-g;
		while(j>=0&&A[j]>v){
			A[j+g]=A[j];
			j-=g;
			cnt++;
		}
		A[j+g]=v;
		}
}


void shellSort(int A[],int n){
	for (int h=1; ; ) {
		if(h>n)break;
		G.push_back(h);
		h=3*h+1;
	}
	for (int i = G.size()-1; i >= 0; i--) {
		insertionSort(A,n,G[i]);
	}
}

int main() {
cin>>n;
for (int i = 0; i < n; ++i) {scanf("%d",&A[i]);}
cnt=0;
shellSort(A,n);
cout<<G.size()<<endl;
for (int i = G.size()-1; i >=0; i--) {
	printf("%d",G[i]);
	if(i)printf(" ");
}
printf("\n");
printf("%d\n",cnt);
for (int i = 0; i < n; ++i) {printf("%d\n",A[i]);}

return 0;
}

Measured memory_bytes: 7144
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
    int x,y;
    cin>>x>>y;
    bool ans=true;
    rep(i,x+1){
        if(2*i+4*(x-i)==y){
            cout<<"Yes";
            ans=false;
            break;
        }
    }
    if(ans) cout<<"No";
    }

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	int m1, d1, m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;
	if (m1 != m2) cout << "1" << endl;
	else cout << "0" << endl;
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    long double X;
    ll count = 0;
    cin >> X;
    while(100.0 < X) {
        X = ceil(X / 1.01);
        count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define all(x) x.begin(),x.end()
#define YES {cout << "YES\n"; return;}
#define NO {cout << "NO\n"; return;}

const int INF=INT_MAX;
const ld PI=acos(-1);//3.1415926535897932384626433
const ld E=2.71828183;
const int MOD=1e9+7;

vi bfs(vector<vi>adj,int src){
    //adjacency list, not-weighted, possibly directed ,src is 1-indexed, adj[0].size()=0!!!
    //for n vertices, adj.size()=n+1. (constructed via push_back() ).

    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return dst;
}
vi bfsParents(vector<vi>adj,int src){
    vi parents=vi(adj.size(),INF);
    parents[src]=-1;
    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                parents[nbr]=c;
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return parents;
}
vi shortestPath(vector<vi>adj,int src,int dst){
    vi bfsParetns=bfsParents(adj,src);
    vi ans;
    while(src!=dst){
        if(bfsParetns[src]==INF)
            return {};
        ans.push_back(src);
        src=bfsParetns[src];
    }
    return ans;
}
int powMod(int base,int exp,int mod){
    //(base^exp) %mod
    int ans=1;
    for(int i=0; i<exp; i++)
        ans=((ans%mod)*(base%mod))%mod;
    return ans;
}
vi divisorsOf(int n){
    //vector of divisors of n (inc. 1 , excl.n)
    vi ans;
    for(int i=1; i*i<=n; i++){
        if(n%i==0)
            ans.push_back(i);
        if(i*i!=n && i!=1)
            ans.push_back(n/i);
    }
    return ans;
}

ll gcd(ll a,ll b){if(a%b==0) return b; else return gcd(b,a%b);}
ld log (ld a,ld b){return log(b)/log(a);}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll power(ll base, ll exp){ll res=1;while(exp){exp--;res*=base;}return res;}

void solve();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
        solve();
    return 0;
}
void solve (){
    int n;
    cin >> n;
    int nxt=1;
    int toBreak=0;
    bool has1=false;
    while(n--){
        int x;
        cin >> x;
        has1|=(x==1);
        if(x==nxt){
            nxt++;
        }
        else
            toBreak++;
    }
    if(has1)
        cout << toBreak << "\n";
    else
        cout << "-1\n";
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
//#define LOCAL
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define ft first
#define sd second
#define sz size()
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
//cout << fixed << setprecision(12) <<x<<endl;

int main(){
fastIO;
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
#endif
 ll x=0,k=0,d=0,aux=0,aux1=0;
 cin>>x>>k>>d;
 //x=abs(x);
      aux = abs(x)/d;
      aux1 = abs(x)-d*min(k,aux) ;
     if(aux<k){
        k-=aux;
        if(k%2==1){
            cout<<abs(aux1-d)<<endl;
        }else{
            cout<<aux1<<endl;
        }
     }else{
         cout<<aux1<<endl;
     }

 


}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define ALL(x) begin(x), end(x)
using ll = long long;
using namespace std;

struct union_find_tree {
    vector<int> data;
    union_find_tree() = default;
    explicit union_find_tree(size_t n) : data(n, -1) {}
    bool is_root(int i) { return data[i] < 0; }
    int find_root(int i) { return is_root(i) ? i : (data[i] = find_root(data[i])); }
    int tree_size(int i) { return - data[find_root(i)]; }
    int unite_trees(int i, int j) {
        i = find_root(i); j = find_root(j);
        if (i != j) {
            if (tree_size(i) < tree_size(j)) swap(i,j);
            data[i] += data[j];
            data[j] = i;
        }
        return i;
    }
    bool is_same(int i, int j) { return find_root(i) == find_root(j); }
};

int solve(int n, int m, vector<ll> const & vw, vector<tuple<int, int, ll> > const & edges) {
    vector<int> order(m);
    iota(ALL(order), 0);
    sort(ALL(order), [&](int i, int j) {
        return get<2>(edges[i]) < get<2>(edges[j]);
    });

    union_find_tree uft(n);
    vector<ll> sum_vw = vw;
    vector<int> unused(n);

    for (int i : order) {
        int a, b; ll ew; tie(a, b, ew) = edges[i];
        a = uft.find_root(a);
        b = uft.find_root(b);
        if (a == b) {
            if (ew <= sum_vw[a]) {
                // nop
            } else {
                ++ unused[a];
            }
        } else {
            int c = uft.unite_trees(a, b);
            if (c != a) swap(a, b);
            assert (c == a);
            sum_vw[a] += exchange(sum_vw[b], 0ll);
            unused[a] += exchange(unused[b], 0);
            if (ew <= sum_vw[a]) {
                unused[a] = 0;
            } else {
                ++ unused[a];
            }
        }
    }

    return accumulate(ALL(unused), 0);
}

int main() {
    int n, m; cin >> n >> m;
    vector<ll> vw(n);
    REP (i, n) cin >> vw[i];
    vector<tuple<int, int, ll> > edges;
    REP (i, m) {
        int a, b; ll ew; cin >> a >> b >> ew;
        -- a; -- b;
        edges.emplace_back(a, b, ew);
    }
    cout << solve(n, m, vw, edges) << endl;
    return 0;
}


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

#define pb(a) push_back(a)

typedef long long ll;
const ll inf = 1e9+7;
const int MAX_N = 1e5+5;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
vector<ll> prime;

ll inv[MAX_N],fac[MAX_N];

template <class T = ll> T in(){T x;cin >> x;return x;}

inline ll GCD(ll a,ll b){ll c;while(b!=0){c=a%b;a=b;b=c;}return a;}
inline ll LCM(ll a,ll b){return a*b/GCD(a,b);}
inline ll POW(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%inf;}a=a*a%inf;b>>=1;}return c;}
inline void _nCr(){fac[0]=1;for(int i=1;i<MAX_N;i++){fac[i]=fac[i-1]*i%inf;}for(int i=0;i<MAX_N;i++){inv[i]=POW(fac[i],inf-2);}}
inline ll nCr(ll n,ll r){return (fac[n]*inv[r]%inf)*inv[n-r]%inf;}
inline void PRI(ll n){bool a[n+1];for(int i=0;i<n+1;i++){a[i]=1;}for(int i=2;i<n+1;i++){if(a[i]){prime.pb(i);ll b=i;while(b<=n){a[b]=0;b+=i;}}}}

class UnionFind {
private:
    int par[MAX_N];
    int rank[MAX_N];
public:
    void init(int n);
    int find(int x);
    void unite(int x,int y);
    bool same(int x,int y);
};

void UnionFind::init(int n) {
    for (int i = 0;i < n;i++) {
        par[i] = i;
        rank[i] = 0;
    }
}

int UnionFind::find(int x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
}

void UnionFind::unite(int x,int y) {
    x = find(x);
    y = find(y);
    if (rank[x] < rank[y]) par[x] = y;
    else {
        par[y] = x;
        if (rank[x] == rank[y]) rank[x]++;
    }
}

bool UnionFind::same(int x,int y) {
    x = find(x);
    y = find(y);
    return x == y;
}

int main() {
    int a,b,q;cin >> a >> b >> q;
    vector<ll> S;
    vector<ll> T;
    ll aa;
    for (int i = 0;i < a;i++) {
        cin >> aa;
        S.push_back(aa);
    }
    for (int i = 0;i < b;i++) {
        cin >> aa;
        T.push_back(aa);
    }
    sort(S.begin(),S.end());
    sort(T.begin(),T.end());
    ll smin=S[0],smax=S[a-1],tmin=T[0],tmax=T[b-1];
    for (int i = 0;i < q;i++) {
        ll x = in();
        ll s,ss,t,tt;
        auto itr=upper_bound(S.begin(),S.end(),x);
        ss=*itr;itr--;s=*itr;
        if (x<smin) s = -914514191981036436;
        if (smax<=x) ss = 914514191981036436;
        itr=upper_bound(T.begin(),T.end(),x);
        tt=*itr;itr--;t=*itr;
        if (x<tmin) t = -914514191981036436;
        if (tmax<=x) tt = 914514191981036436;
        ll ans=914514191981036436;
        ans = min({max(x-s,x-t),max(ss-x,tt-x),min(ss-t+ss-x,ss-t+x-t),min(tt-s+tt-x,tt-s+x-s)});
        // cout <<s << " " << ss <<" " << t << " " <<tt <<endl;
        cout << ans << endl;
    }
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll n;
    cin >> n;

    double v[n+10];
    NREP() cin >> v[i];

    sort(v, v+n);

    double value = 0;
    NREP(){
        if (i == n-2) break;
        double tmp = (v[i] + v[i+1]) / 2;
        v[i+1] = tmp;
    }

    cout << (v[n-2] + v[n-1]) / 2 << endl;

}


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
typedef pair<ll,ll> P;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<P> v;
    vector<ll> vl;
    vector<ll> vr;
    REP(i, N) {
        P tmp; cin >> tmp.first >> tmp.second;
        vl.push_back(tmp.first);
        v.push_back(tmp);
        vr.push_back(tmp.second);
    }
    sort(vl.begin(), vl.end());
    sort(vr.begin(), vr.end());
    ll ans;
    if (N%2 == 0) {
        ll l = vl[N/2-1] + vl[N/2];
        ll r = vr[N/2-1] + vr[N/2];
        ans = r - l + 1;
    }
    else {
        ll l = vl[N/2];
        ll r = vr[N/2];
        ans = r - l + 1;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

void solve(){
	string s;
	map<char,int> m;
	bool ok = true;
	int quant = 0;
	cin >> s;
	for(int i=0;i<4;++i){
		m[s[i]]++;
	}
	for(auto &x:m){ 
		++quant;
		if(x.second != 2) ok = false;
	}
	cout << (ok && quant == 2 ? "Yes" : "No") << '\n';
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--){ 
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int ab, bc, ca;
    cin >> ab >> bc >> ca;
    cout << ab * bc / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]


    token = lines[0].split()
    n = int(token[0])
    k = int(token[1])

    return (n, k)


def solve(n, k):


    return n - k + 1


def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3188
def gcd(x, y)
  y == 0 ? x : gcd(y, x % y)
end

def lcm(x, y)
  x / gcd(x, y) * y
end

a, b, c, d = gets.chomp.split.map(&:to_i)

# 範囲に含まれる c の倍数の数
nc = b / c - (a-1) / c

# 範囲に含まれる d の倍数の数
nd = b / d - (a-1) / d

# 範囲に含まれる lcm の数
lc = lcm(c, d)
nlcm = b / lc - (a-1) / lc

ans = b - (a - 1) - nc - nd + nlcm

puts ans


Measured memory_bytes: 14312
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = 1e9+7;

int main()
{
	ll N,K;
	cin >> N >> K;
	ll ans = 0;
	for (ll i = K; i <= N+1; ++i)
	{
		ans = (ans + i*(2*N-i+1)/2 - i*(i-1)/2 + 1) % MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
N = int(input())
march = [0]*5
for i in range(N):
    tmp = input()
    if tmp[0]=='M':
        march[0] +=1
    elif tmp[0]=='A':
        march[1] +=1
    elif tmp[0]=='R':
        march[2] +=1
    elif tmp[0]=='C':
        march[3] +=1
    elif tmp[0]=='H':
        march[4] +=1
sum = 0
sum += march[0]*march[1]*march[2]
sum += march[0]*march[1]*march[3]
sum += march[0]*march[1]*march[4]
sum += march[0]*march[2]*march[3]
sum += march[0]*march[2]*march[4]
sum += march[0]*march[3]*march[4]
sum += march[1]*march[2]*march[3]
sum += march[1]*march[2]*march[4]
sum += march[1]*march[3]*march[4]
sum += march[2]*march[3]*march[4]
print(sum)

Measured memory_bytes: 3188
import java.util.*;

public class Main {
	
	public static void main(String args[]){
		
		
		Scanner sc= new Scanner(System.in);
		String ln= sc.next();
		
		int ans = 753;
		
		for(int i=0;i<ln.length()-2;i++){
			int x1=ln.charAt(i)-'0';
			int x2=ln.charAt(i+1)-'0';
			int x3=ln.charAt(i+2)-'0';
			
			int num = x1*100+x2*10+x3;
			//System.out.println(num);
			if(ans>Math.abs(num-753))ans=Math.abs(num-753);
		}
		
		
		System.out.println(ans);
	}

}



Measured memory_bytes: 21972
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main{
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        while(true){
            int n=scan.nextInt();
            if(n==0){
                break;
            }
            int[] maxMin=new int[4];
            List<NodeM1165> list=new LinkedList<NodeM1165>();
            NodeM1165 node=new NodeM1165();
            for(int i=0;i<4;i++){
                maxMin[i]=0;
            }
            node.setX(0);
            node.setY(0);
            list.add(node);
            for(int i=1;i<n;i++){
                int index=scan.nextInt();
                int move=scan.nextInt();
                list.add(getXY(list,index,move));
            }
            for(int i=1;i<list.size();i++){
                node=list.get(i);
                int x=node.getX();
                int y=node.getY();
                if(x>0){
                    if(maxMin[0]<x){
                        maxMin[0]=x;
                    }
                }
                else {
                    if(maxMin[1]>x){
                        maxMin[1]=x;
                    }
                }
                if(y>0){
                    if(maxMin[2]<y){
                        maxMin[2]=y;
                    }
                }
                else {
                    if(maxMin[3]>y){
                        maxMin[3]=y;
                    }
                }
            }
            int hoge=maxMin[0]-maxMin[1]+1;
            int huga=maxMin[2]-maxMin[3]+1;
            System.out.println(hoge+" "+huga);
        }
    }
    private static NodeM1165 getXY(List<NodeM1165> list,int index,int move){
        NodeM1165 node=list.get(index);
        int x=node.getX();
        int y=node.getY();
        if(move==0){
            x--;
        }
        else if(move==1){
            y--;
        }
        else  if(move==2){
            x++;
        }
        else {
            y++;
        }
        node=new NodeM1165();
        node.setY(y);
        node.setX(x);
        return  node;
    }
}
class NodeM1165{
    private int x,y;

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public void setX(int x) {
        this.x = x;
    }

    public void setY(int y) {
        this.y = y;
    }
}


Measured memory_bytes: 41204
# https://atcoder.jp/contests/abc117/tasks/abc117_b

N = int(input())
L = sorted(list(map(int, input().split())))

l_sum = sum(L[:len(L)-1])
longest = L[len(L)-1]

if l_sum > longest:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc=new FastScanner();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		if(a<0 && c<0 || b>=0 && d>=0) {
			System.out.println(Math.max(a*c, b*d));
		}else {
			long ans = Math.max(a*d, c*b);
			System.out.println(ans);
		}
		
	}
	static final Random random = new Random();
	
	static void sort(int[] a) {
		int n = a.length;
		for(int i =0; i<n; i++) {
			int val = random.nextInt(n);
			int cur = a[i];
			a[i] = a[val];
			a[val] = cur;
		}
		Arrays.sort(a);
	}
	
	static void sortl(long[] a) {
		int n = a.length;
		for(int i =0; i<n; i++) {
			int val = random.nextInt(n);
			long cur = a[i];
			a[i] = a[val];
			a[val] = cur;
		}
		Arrays.sort(a);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (st == null  || !st.hasMoreTokens()) {
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		String nextLine() { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
		} 
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
	}

}


Measured memory_bytes: 32752
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;

int solve(int n,int m){
	int flag[21][21]={};
	int field[21][21]={};
	queue<pair<int,int> >q;
	for(int i=0;i<m;i++){
		string s;
		cin >> s;
		for(int j=0;j<n;j++){
			if(s[j]=='.')field[i][j]=0;
			if(s[j]=='#')field[i][j]=-1;
			if(s[j]=='@'){
				field[i][j]=1;
				flag[i][j]=1;
				q.push(make_pair(i,j));
			}
		}
	}
	while(!q.empty()){
		pair<int,int> p = q.front();
		q.pop();
		int a = p.first;
		int b = p.second;
		if(a>0){
			if(flag[a-1][b]==0&&field[a-1][b]==0){
				q.push(make_pair(a-1,b));
				flag[a-1][b]=1;
			}
		}
		if(a<m-1){
			if(flag[a+1][b]==0&&field[a+1][b]==0){
				q.push(make_pair(a+1,b));
				flag[a+1][b]=1;
			}
		}
		if(b>0){
			if(flag[a][b-1]==0&&field[a][b-1]==0){
				q.push(make_pair(a,b-1));
				flag[a][b-1]=1;
			}
		}
		if(b<n-1){
			if(flag[a][b+1]==0&&field[a][b+1]==0){
				q.push(make_pair(a,b+1));
				flag[a][b+1]=1;
			}
		}
	}
	int ans=0;
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			if(flag[i][j]==1)ans+=1;
		}
	}
	return ans;
}


int main(){
	int n,m;
	while(1){
		cin >> n >> m;
		if(n==0&&m==0)break;
		cout << solve(n,m) <<endl;
	}
	return 0;
}

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

int main() {
    ll N,K;
    cin >> N >> K;
    ll pos;
    for(int i=0;i<N;i++){
        ll A;
        cin >> A;
        if(A==1){
            pos = i;
        }
    }
    cout << (N-1+K-2)/(K-1) << endl;


    return 0;
}

Measured memory_bytes: 256
<?php 
fscanf(STDIN, "%s", $s);
$array = str_split($s);
if($array[0] === $array[1]){
    echo 'Bad';
}elseif($array[1] === $array[2]){
    echo 'Bad';
}elseif($array[2] === $array[3]){
    echo 'Bad';
}elseif($array[0] === $array[1] && $array[2] === $array[3]){
    echo 'Bad';
}elseif($array[0] === $array[1] && $array[2] === $array[3]){
    echo 'Bad';
}else{
    echo 'Good';
}
?>


Measured memory_bytes: 4728
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		sc.close();
		long a = 0;
		long b = 0;
		long ans = Long.MAX_VALUE;
		for(int i = 1; i <= Math.sqrt(n); i++) {
			if(n%i == 0) {
				a = i;
				b = n/i;
				ans = Math.min(ans, b+a-2);
				}
			}
		System.out.println(ans);
		}
	}

Measured memory_bytes: 23764
import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	int c = a-1;
    	if(b >= a) c += 1;
    	
    	System.out.println(c);
	}

}


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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
#define N 100010
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll result(ll a, ll b, ll p){
    ll ans=1;
    if(b==(-1))
        b=p-2;
    while(b){
        if(b&1){
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

ll T = 1,n,m,k;

int main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    cin >> n;
    ll a[n];
    ll x = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        x = x^a[i];
    }
    for(int i=0;i<n;i++){
        ll p = x^a[i];
        cout << p << " ";
    }


    return 0;
}


Measured memory_bytes: 5156
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    int ans=A-B;
    if(K%2==1) ans=-ans;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
N = int( input() )
W_list = list( map( int, input().split() ) )
mid = int( sum(W_list) / 2 )
sumW = 0
for i in range(N):
    if sumW > mid:
        break
    sumW += W_list[i]
a = sum( W_list[i-1:] ) - sum( W_list[:i-1] ) 
b = sum( W_list[:i] ) - sum( W_list[i:] )
print( min(a,b) )

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

typedef pair<int,int> P;
#define INF 1145141919

int N, M, K;
int S[3010];
vector<int> edges[3010];
int cost[3010][3010];
int D[3010];

int main() {
  cin >> N >> M >> K;
  for (int i=0; i<M; i++) {
    int a, b, l;
    cin >> a >> b >> l;
    edges[a-1].push_back(b-1);
    edges[b-1].push_back(a-1);
    cost[a-1][b-1] = l;
    cost[b-1][a-1] = l;
  }
  for (int i=0; i<K; i++) {
    int s;
    cin >> s;
    S[i] = s-1;
  }

  for (int i=0; i<N; i++) D[i] = INF;
  priority_queue< P, vector<P>, greater<P> > q;
  for (int i=0; i<K; i++) {
    D[S[i]] = 0;
    q.push(P(0, S[i]));
  }

  while (!q.empty()) {
    P p = q.top(); q.pop();
    int s = p.second;

    for (auto t : edges[s]) {
      if (D[t] > D[s] + cost[s][t]) {
        D[t] = D[s] + cost[s][t];
        q.push(P(D[t], t));
      }
    }
  }

  int ans = 0;
  for (int i=0; i<N; i++) {
    for (int x : edges[i]) {
      ans = max(ans, (int)round((double)(D[i] + D[x] + cost[i][x]) / 2));
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 39872
A,B =map(int,input().split())
count = 0
if A%3==0:
    print("Possible")
    count += 1
if B%3==0:
    if count == 0:
        print("Possible")
        count += 1
if (A+B)%3==0 :
    if count == 0:
        print("Possible")
        count += 1
if count == 0:
    print("Impossible")


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

bool isKaibun(int n){
    string s = to_string(n);
    for(int i = 0; i < s.size()/2; i++){
        if(s.at(i) != s.at((s.size()-1)-i))return false;
    }
    return true;
}

int main(){
    int A,B;
    cin >> A >> B;

    int count = 0;
    for(int i = A; i <= B; i++){
        if(isKaibun(i))count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3680
n,m,x,y=map(int,input().split())
xl=list(map(int,input().split()))
yl=list(map(int,input().split()))

flag=False

if max(xl)>=min(yl):
    pass
else:
    l=range(max(xl)+1,min(yl)+1)
    for i in range(len(l)):
        if x<l[i]<=y:
            flag=True
        else:
            pass

if flag:
    print("No War")
else:
    print("War")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;

int32_t main() {
    // freopen("in.txt", "r", stdin);
    IOS;
    int x; cin >> x;
    cout << (x^1);
}

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

int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;

  int ret = 0;
  for (int nr = 0; nr <= n / r; ++nr) {
    int m = n - nr * r;
    for (int ng = 0; ng <= m / g; ++ng) {
      int rem = m - ng * g;
      if (rem % b)
        continue;
      ++ret;
    }
  }
  cout << ret << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <bitset>
#include <map>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>
#include <math.h>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecchar vector<char>
#define vecstr vector<string>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define pairll pair<ll,ll>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

#define Pi 3.1415926535897932384626

//探索するマスが設定したマップの中に存在するか判断する関数
bool isInFirld(int col, int row, const pair<int, int> &point)
{
	const int c = point.second;
	const int r = point.first;
	return (0 <= c && c < col) && (0 <= r && r < row);
}

int main()
{
	int r, c;
	cin >> r >> c;

	ll count = 0;

	//使用する迷路を表す行列
	vecstr map(r);
	//スタートとゴールの位置を表す。今回はpair型で宣言した(配列でも一応可)
	//要素1(first)がx座標、要素2(second)がy座標
	pair<int, int> start, goal;
	//スタートからゴールまで到達できたか判断するフラグ
	bool checkFlag = false;



	forll(i, 0, r)
	{
		cin >> map[i];
	}

	start = { 0,0 };
	goal = { r - 1,c - 1 };

	// 2. 各マスの訪問履歴(memo)を作成する
	//    memoにはスタートからそのマスまでの歩数を格納する(初期値は0)
	//注 ) mapと同じサイズの行列を宣言すること
	vector<vector<int>> memo;
	for (int i = 0; i < map.size(); ++i) {
		vector<int> v(map[i].size(), 0);
		memo.push_back(v);
	}

	// 移動方向の定義(上下左右、pair型)
	const pair<int, int> points[4] = {
		{ -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 },
	};

	// 3. スタートのマスをキュー(待ち行列)に格納する
	queue<pair<int, int>> data;
	data.push(start);

	// 11. 4から10をキューが空になるまで繰り返す
	while (!data.empty()) {

		// 4. キューの先頭から一マス取得する。その後先頭の要素は削除
		pair<int, int> cur = data.front();
		data.pop();

		// 5. 取り出したマスがゴールなら(ゴールの座標と同じ座標を示していたら)終了するよう分岐を作成
		if (cur == goal) {

			//ゴールが見つかったのでtrueに
			checkFlag = true;
			break;
		}

		//autoは自動で型を合わせる機能(今回だと変数pointの型はpair<int,int>に自動で設定している)
		//pointの中身はpair<int,int>の配列pointsの各要素
		for (const auto &point : points) {

			// 6. 手順4で取り出したマス(cur)から上下左右の何れかに移動する
			pair<int, int> next = { (cur.first + point.first), (cur.second + point.second) };

			// 7. 移動先のマス(next)が迷路外でないことを確認する(迷路外の場合は手順6に戻る)
			if (isInFirld(map[0].size(), map.size(), next)) {

				//移動先のマス情報を取得
				const char s = map[next.first][next.second];

				// 8. 移動先のマス(next)が道またはゴールであることを確認する(道でもゴールでもない場合は手順6に戻る)
				if (s == '.') {

					// 9. 移動先のマス(next)が未訪問であることを確認する(訪問済みの場合は手順6に戻る)
					if (memo[next.first][next.second] == 0) {

						// 10. 移動先のマス(next)をキューに格納し、訪問履歴を更新する
						data.push(next);

						//nextでは歩数を1加算する(curから1マス進んでいるため)
						memo[next.first][next.second] = memo[cur.first][cur.second] + 1;
					}
				}
			}
		}
	}

	if (checkFlag)
	{
		forll(i, 0, r)
		{
			forll(j, 0, c)
			{
				if (map[i][j] == '.')
				{
					count++;
				}
			}
		}
		cout << (count-1) - memo[r-1][c-1] << endl;
	}
	else
	{
		cout << "-1" << endl;
	}

	return 0;
}

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

using namespace std;

#define MAX_N 105
#define MAX_K 100005
#define MOD 1000000007

int n, k, y[MAX_N];
long long dp[MAX_N][MAX_K];

int main()
{
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", y + i);
	}
	long long s = 0;
	for (int i = 0; i <= k; i++)
	{
		if (i <= y[n - 1])
			s++;
		dp[n - 1][i] = s;
	}
	for (int i = n - 2; i >= 0; i--)
	{
		s = 0;
		for (int c = 0; c <= k; c++)
		{
			dp[i][c] = dp[i + 1][c] - (c > y[i] ? dp[i + 1][c - y[i] - 1] : 0);
			s = (s + dp[i][c] + MOD)%MOD;
			dp[i][c] = s;
		}
	}
	if (k != 0)
		printf("%lld\n", (dp[0][k] - dp[0][k - 1] + MOD)%MOD);
	else
		printf("%lld\n", dp[0][k]);
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define ri register
#define int long long
using namespace std;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int Q=read();
    for(ri int i=1;i<=Q;i++)
    {
        int x,y;
        x=read(), y=read();
        if(x>y) swap(x,y);
        int qwq=sqrt(x*y);
        if(x*y==qwq*qwq) qwq--;
        if(y-x<=1) printf("%lld\n",(x-1)*2);
        else if(x*y<=(qwq+1)*(qwq)) printf("%lld\n",(qwq-1)*2);
        else printf("%lld\n",(qwq-1)*2+1);
    }
    return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<string>
int main()
{
	int a,b,z,one,two,three,four,five,count=0;
	std::cin >> a >> b;
	z = b - a + 1;
	for (int i = 0; i < z; i++)
	{
		one = a / 10000;
		two = (a - one * 10000) / 1000;
		three = (a - one * 10000 - two * 1000) / 100;
		four = (a - one * 10000 - two * 1000 - three * 100) / 10;
		five = (a - one * 10000 - two * 1000 - three * 100 - four * 10) / 1;
		if (one == five&&two == four) {
			count++;
		}
		a++;
	}
	std::cout << count;
	}


Measured memory_bytes: 256
/*package whatever //do not write package name here */
/*package whatever //do not write package name here */

// Working program with FastReader 
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 

public class Main 
{ 
	static class FastReader 
	{ 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

		int nextInt() 
		{ 
			return Integer.parseInt(next()); 
		} 

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

		double nextDouble() 
		{ 
			return Double.parseDouble(next()); 
		} 

		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	} 

	public static void main(String[] args) 
	{ 
		FastReader ob=new FastReader(); 
		String s1 = ob.next(), s2=ob.next();
		int k1=ob.nextInt(),k2=ob.nextInt();
		String u = ob.next();
		if(u.compareTo(s1)==0){
		    System.out.println((k1-1) +" "+k2);
		}
		else{
		    System.out.println(k1+" "+(k2-1));
		}
	
	
	} 
} 


Measured memory_bytes: 21460