akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
int p[25];
using namespace std;
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,cnt=0;
    cin >> n;
    for(int i=1;i<=n;i++)
	cin >> p[i];
    for(int i=2;i<n;i++)
	if(p[i]!=max(p[i-1],max(p[i],p[i+1])) && p[i]!=min(p[i-1],min(p[i],p[i+1])))
	    cnt++;
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var W, H, x, y, r int
	fmt.Scanf("%d %d %d %d %d", &W, &H, &x, &y, &r)
	if x-r < 0 || x+r > W || y-r < 0 || y+r > H {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
	return
}




Measured memory_bytes: 1152
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'



void solve(){
  vector<ll> lucas(87);
  lucas[0] = 2;
  lucas[1] = 1;
  rep(i,2,87){
    lucas[i] = lucas[i-1] + lucas[i-2];
  }
  int n;
  cin >> n;
  cout << lucas[n];
}

int main() {
  ios::sync_with_stdio(false); 
  // cin.tie(0); cout.tie(0);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 




*/

Measured memory_bytes: 3664
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long,long>>;

//f(A,B) = f(0,A-1)^f(0,B)

ll f(ll A,ll B) {
    ll ans;
    if(B%2 == 0) {
        if(A%2 == 0) {
            if((B-1-(A-1))/2%2 == 0) ans = 0^B;
            else ans = 1^B;
        } else {
            if(((B-1)-A)/2%2 == 0) ans = A^0^B;
            else ans = A^1^B;
        } 
    } else if(A%2 != 0) {
        if((B-(A-1))/2%2 == 0) ans = A^0;
        else ans = A^1;
    } else {
        if(A%2 == 0) {
            if((B-(A-1))/2%2 == 0) ans =  0;
            else ans = 1;
        }
    }
    return ans;
}

int main() {
    ll A,B; cin >> A >> B;
    if(A == B) {cout << A << endl;return 0;}
    cout << f(A,B) << endl;
}


Measured memory_bytes: 256
<?php
$input = trim(fgets(STDIN));
$num =explode(" ", $input);
$a = $num[0];
$b = $num[1];
if($a < $b){
    echo "a < b\n";
}elseif($a > $b){
    echo "a > b\n";
}else{
    echo "a == b\n";
}

Measured memory_bytes: 15352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
// C - Typical Stairs
ll W = 1000000007;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> stairs(n+1, 0);
    rep(i, m){
        int ai;
        cin>> ai;
        stairs.at(ai) = 1;
    }

    vector<ll> dp(n+1);
    dp.at(0)=1;

    for(int i=0;i<n;i++){
        for(int j=i+1; j<=min(n, i+2);j++){
            if(stairs.at(j)==0){
                dp.at(j)+=dp.at(i);
                dp.at(j)%=W;
            }
        }
    }
    cout << dp.at(n) << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
int H,W;
int x,y,flg;
string str;
int t[200][200];
void compute(){
  int a;
  if(t[y][x]==-1)return;
  if(t[y][x]==-2)flg=1;
  else {
    a=t[y][x];
    t[y][x]=-2;
    y=y+dy[a];
    x=x+dx[a];
    compute();
  }
}
int main(){
  while(cin>>H>>W){
    if(H==0&&W==0)break;
    for(int i=0;i<H;i++){
      cin>>str;
      for(int j=0;j<W;j++){
	if(str[j]=='^')t[i][j]=0;
	else if(str[j]=='>')t[i][j]=1;
	else if(str[j]=='v')t[i][j]=2;
	else if(str[j]=='<')t[i][j]=3;
	else t[i][j]=-1;
      }
    }
    x=y=flg=0;
    compute();
    if(flg)cout<<"LOOP"<<endl;
    else cout<<x<<' '<<y<<endl;
  }
  return 0;
}

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

using namespace std;
const double eps = 1e-9;
const int INF = (int)1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector <int> a(n);
    map<int, int> cnt;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ans = max(ans, ++cnt[a[i]]);
        ans = max(ans, ++cnt[a[i] + 1]);
        ans = max(ans, ++cnt[a[i] - 1]);
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll m; cin >> m;
    ll keta = 0;
    ll wa = 0;
    REP(i, m){
        ll d; cin >> d;
        ll c; cin >> c;
        keta += c;
        wa += c*d;
    }
    cout << keta-1 + (wa-1)/9 << endl;
    return 0;
}

Measured memory_bytes: 256
/*
** Counting Sort
*/

# include <cstdio>
# include <cstring>
# define MAX 10005

const int maxn = 2000000 + 10;
int a[maxn], b[maxn], c[MAX];

void CountingSort(const int A[], int B[], const int k, const int n) {
    for (int i = 1; i <= n; i++)
        c[A[i]]++;
    
    for (int i = 1; i <= k; i++)
        c[i] = c[i] + c[i - 1];

    for (int i = n; i > 0; i--) {
        B[c[A[i]]] = A[i];
        c[A[i]]--;
    }
}

int main() {
    // freopen("infile", "r", stdin);
    // freopen("outfile", "w", stdout);

    int n;
    scanf("%d", &n);
    // 从Infile中获取输入，并存储至数组a
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    // 初始化c数组
    memset(c, 0, sizeof(c));
    CountingSort(a, b, MAX, n);

    // 输出数组b到outfile
    for (int i = 1; i < n; i++)
        printf("%d ", b[i]);
    printf("%d\n", b[n]);

    return 0;
}


Measured memory_bytes: 18308
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll gcd(ll x, ll y) { return (y ? gcd(y, x % y) : x); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main() {
	init();

	int Q; cin >> Q;
	vector<pair<int, int>>query(Q);
	rep(i, 0, Q) {
		int a, b; cin >> a >> b;
		query[i] = make_pair(a, b);
	}
	vector<int>cnt(100001, 1);
	cnt[0] = 0;
	cnt[1] = 0;
	vector<int>prime;
	rep(i, 2, cnt.size()) {
		if (cnt[i] == 1) {
			prime.push_back(i);
			int x = i;
			while (x + i < cnt.size()) {
				x += i;
				cnt[x] = 0;
			}
		}
	}
	vector<int>hoge = cnt;
	rep(i, 0, prime.size()) {
		int x = prime[i];
		if (cnt[(x + 1)/2] == 0)hoge[x] = 0;
	}
	rep(i, 1, hoge.size()) {
		hoge[i] += hoge[i - 1];
	}
	rep(i, 0, Q) {
		int l = query[i].first, r = query[i].second;
		cout << hoge[r] - hoge[l - 1] << "\n";
	}
	


	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
ll dp[1010][1010];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll h, w; cin >> h >> w;
    vector<string> grid(h);
    rep(i, h) cin >> grid[i];

    rep(i, h)rep(j, w) dp[i][j] = 0;
    rep(i, h){
        if(grid[i][0] == '.') dp[i][0] = 1;
        else break;
    }
    rep(j, w){
        if(grid[0][j] == '.') dp[0][j] = 1;
        else break;
    }
    _rep(i, 1, h)_rep(j, 1, w){
        if(grid[i][j] != '#'){
            dp[i][j] = max(dp[i][j], dp[i - 1][j] + dp[i][j - 1]);
            dp[i][j] %= mod;
        }else{
            dp[i][j] = 0;
        }
    }
    cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 12504
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int a,b,c,d;
int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin>>a>>b>>c>>d;
    if(a==c) cout << 0 << endl;
    else cout << 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define all(t) (t).begin(),(t).end()
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	int n;
	cin >> n;
	vector<pair<int,int>> v;
	FOR(i,n){
		int a;
		cin >> a;
		v.push_back(make_pair(a,i));
	}
	sort(all(v));
	FOR(i,n){
		cout << v[i].second+1 << endl;
	}
}



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

template<typename T>
istream& operator >> (istream& istr, vector<T>& vec){
    for(T& x: vec) istr >> x;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& vec){
    if(!vec.empty()){
        ostr << vec.front();
        for(auto itr = ++vec.begin(); itr != vec.end(); itr++)
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    ostr << p.first << " " << p.second;
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
// vll x(n); x[i]=a;
typedef vector<pair<ll,ll>> vpll;
// vpll x(n); x[i]={a,b}; x[i].first/second;
typedef vector<vector<ll>> vvll;
// vvll x(m,vi(n)); x[i][j]=a;

#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

int main(){
    ll n, k, ans = 0, cnt1 = 0, cnt2 = 0;
    string s;
    cin >> n >> k;
    cin >> s;

    if(s[0] == 'L') cnt1 += 1;
    REP(i,n-1) if(s[i] == 'R' && s[i+1] == 'L') cnt2 += 1;
    if(s[n-1] == 'R') cnt1 += 1;
    ans = n-cnt1-cnt2*2;

    while(k > 0 && cnt2 > 0){
        ans += 2;
        k--;
        cnt2--;
    }
    if(cnt2 == 0){
        if(cnt1 == 0) ans--;
        else if(cnt1 == 2 && k > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int cups[3] = {};

int main() {
  string s;
  cups[0] = 1;
  while(cin>>s) {
    if(cups[s[0]-'A']) cups[s[2]-'A'] = 1, cups[s[0]-'A'] = 0;
    else if(cups[s[2]-'A']) cups[s[2]-'A'] = 0, cups[s[0]-'A'] = 1;
  }
  for(int i=0; i<4; ++i)
    if(cups[i]) cout<<(char)(i+'A')<<endl;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
using namespace std;
char in[510000];
char rev[510000];
int fail[510000];
int f2[510000];
int main(){
	scanf("%s",in);
	int n=strlen(in);
	for(int i=0;i<n;i++)rev[i]=in[n-1-i];
	fail[0]=fail[1]=0;
	for(int i=2;i<=n;i++){
		int at=fail[i-1];
		while(1){
			if(in[i-1]==in[at]){
				fail[i]=at+1;break;
			}
			if(at==0){
				fail[i]=0;break;
			}
			at=fail[at];
		}
	}
	
	if(fail[n]==n-1){
		printf("%d\n1\n",n);
		return 0;
	}
	f2[0]=f2[1]=0;
	for(int i=2;i<=n;i++){
		int at=f2[i-1];
		while(1){
			if(rev[i-1]==rev[at]){
				f2[i]=at+1;break;
			}
			if(at==0){
				f2[i]=0;break;
			}
			at=f2[at];
		}
	}
	//for(int i=0;i<=n;i++)printf("%d %d\n",fail[i],f2[i]);
	if(n-fail[n]<n&&n%(n-fail[n])==0){
		printf("2\n");
		int ret=0;
		for(int i=1;i<n;i++){
			if(fail[i]==0||i%(i-fail[i])){
				if(f2[n-i]==0||(n-i)%((n-i)-f2[n-i])){
					ret++;
				}
			}
		}
		printf("%d\n",ret);
	}else printf("1\n1\n");
}

Measured memory_bytes: 5120
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0092
"""
import sys



def find_square(data):
    max_size = 0
    lmap = []
    for row in data:
        temp = []
        for c in row:
            if c == '.':
                temp.append(1)
            else:
                temp.append(0)
        lmap.append(temp)

    prev_row = lmap[0]
    for curr_row in lmap[1:]:
        for x in range(1, len(lmap[0])):
            if curr_row[x] == 1:
                if prev_row[x-1] != 0 and prev_row[x] != 0 and curr_row[x-1] != 0:
                    curr_row[x] = min(prev_row[x-1], min(prev_row[x], curr_row[x-1])) + 1
                    if curr_row[x] > max_size:
                        max_size = curr_row[x]
        prev_row = curr_row
    return max_size


def find_square2(data):
    max_size = 0
    lmap = []
    for row in data:
        temp = []
        for c in row:
            if c == '.':
                temp.append(1)
            else:
                temp.append(0)
        lmap.append(temp)

    prev_row = lmap[0]
    for curr_row in lmap[1:]:
        for x, t in enumerate(curr_row[1:], start=1):
            if t == 1:
                curr_row[x] = min(prev_row[x-1], min(prev_row[x], curr_row[x-1])) + 1
                if curr_row[x] > max_size:
                    max_size = curr_row[x]
        prev_row = curr_row
    return max_size


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break
        data = [input() for _ in range(n)]
        result = find_square2(data)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 35088
/*
THE BEST IS YET TO COME
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define r(i,s,l) for(int i=s;i<l;i++)
#define mod 1000000007
#define INT_BITS 32
#define ld long double
#define pp pair<long long,long long>
#define ss second
#define ff first
#define N 2000005
#define all(a) a.begin(),a.end()
#define pb push_back
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int main()
{
    fast();
    int n;
    cin>>n;
    vector<int> a(n);
    r(i,0,n)
    cin>>a[i];
    int flag=1;
    for(int i=n-1;i>0;i--)
        if(a[i]<a[i-1])
    {
        a[i-1]--;
        if(a[i]<a[i-1])
        {
            flag=0;
            break;
        }
    }
    if(flag)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;

}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin>>s>>t;
  int count=0;
  for(int i=0;i<s.size();i++){
  	if(s.at(i)!=t.at(i)){count++;}
  }
  cout<<count;
}

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

int main() {
  string S;
  cin>>S;
  if(S=="ABC"){
    cout<<"ARC"<<endl;
  }else{
    cout<<"ABC"<<endl;
  }

}


Measured memory_bytes: 3628
from collections import Counter

n = int(input())
v = [int(i) for i in input().split()]

A = []
B = []
for i in range(n):
    if i % 2 == 0:
        A.append(v[i])
    else:
        B.append(v[i])

C = Counter(A)
D = Counter(B)

E = C.most_common()
F = D.most_common()

E += [(-1,0)]
F += [(-1,0)]

if E[0][0] != F[0][0]:
    print(n-E[0][1]-F[0][1])
else:
    print(n-max(E[0][1]+F[1][1],E[1][1]+F[0][1]))

Measured memory_bytes: 66412
#include<stdio.h>
int main(){
	char s[1025];
	int i,w=0,f=0;
	for(i=0;s[i]=getchar(),s[i]+1;i++){
		if(s[i]==' '||s[i]=='.'||s[i]==','){
			if(i-w>=3 && i-w<=6){
				s[i]=0;
				if(f)
					putchar(' ');
				printf("%s",s+w);
				f=1;
			}
			w=i+1;
		}
	}
	puts("");
	return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n,m;
    Scd2(n,m);

    printf ("%d\n", (n-1)*(m-1));

    return 0;
}



Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

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

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int ind = i - 1;

        if ((i & 1) && (a[ind] & 1)) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
<?php

    fscanf(STDIN,"%d %d %d",$a,$b,$c);
    $ct = 0;
    
    for($i = $a; $i <= $b; $i++) {
        if ($c % $i == 0) {
            $ct++;
        }
    }
    
    echo $ct.PHP_EOL;
    

?>


Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll s[2222][2222];
ll f[2222][2222];

int main(void) {
  ll i, j, k;
  
  ll N, K;
  cin >> N >> K;
  ll x[MAX], y[MAX];
  
  
  for(i=0; i<N; i++) {
    ll x, y;
    char c;
    cin >> x >> y >> c;
    x%=K*2; y%=K*2;
    if(c=='W') (y+=K)%=K*2;
    x++; y++;
    f[x][y]++;
  }
  
  
  for(i=1; i<=K*2; i++) for(j=1; j<=K*2; j++)
    s[i][j]+=s[i][j-1]+f[i][j];
  for(j=1; j<=K*2; j++) for(i=1; i<=K*2; i++)
    s[i][j]+=s[i-1][j];
  
  ll ans=0;
  for(i=0; i<=K; i++) {
    for(j=0; j<=K; j++) {
      ll t=0;
      t+=s[i][j];
      t+=s[i][K*2]-s[i][j+K];
      t+=s[i+K][j+K]-s[i][j+K]-s[i+K][j]+s[i][j];
      t+=s[K*2][j]-s[i+K][j];
      t+=s[K*2][K*2]-s[K*2][j+K]-s[i+K][K*2]+s[i+K][j+K];
      chmax(ans, max(t, N-t));
    }
  }
  
  pt(ans);
  
}




Measured memory_bytes: 71936
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
#define degrees(a) a * 180.0 / M_PI;
#define radians(a) a * M_PI / 180.0;
// #define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  ll A, B, C;
  cin >> A >> B >> C;
  ll ans;
  if (!(A % 2) or !(B % 2) or !(C % 2)) {
    ans = 0;
  } else {
    ll max_ = max({A, B, C});
    if (A == max_) {
      ans = B * C;
    } else if (B == max_) {
      ans = A * C;
    } else {
      ans = A * B;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}

int main(){
	long long N,A,B;read(N);read(A);read(B);
	if((B-A)%2==0){write((B-A)/2);}
	else{write(min(A,N-B+1)+(B-A)/2);}
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int H = Integer.parseInt(sa[0]);
		int W = Integer.parseInt(sa[1]);
		int h = Integer.parseInt(sa[2]);
		int w = Integer.parseInt(sa[3]);
		br.close();

		if (H % h == 0 && W % w == 0) {
			System.out.println("No");
			return;
		}
		System.out.println("Yes");

		int p = 100000000;
		if (H % h != 0) {
			int nh = -(p / (h - 1) + 1);
			StringBuilder sb1 = new StringBuilder();
			StringBuilder sb2 = new StringBuilder();
			sb1.append(p);
			sb2.append(nh);
			for (int j = 1; j < W; j++) {
				sb1.append(' ').append(p);
				sb2.append(' ').append(nh);
			}
			String s1 = sb1.toString();
			String s2 = sb2.toString();
			for (int i = 0; i < H; i++) {
				if (i % h == 0) {
					System.out.println(s1);
				} else {
					System.out.println(s2);
				}
			}

		} else {
			int nw = -(p / (w - 1) + 1);
			StringBuilder sb = new StringBuilder();
			sb.append(p);
			for (int j = 1; j < W; j++) {
				if (j % w == 0) {
					sb.append(' ').append(p);
				} else {
					sb.append(' ').append(nw);
				}
			}
			String s = sb.toString();
			for (int i = 0; i < H; i++) {
				System.out.println(s);
			}
		}
	}
}


Measured memory_bytes: 25300
/*
 * Created by: Son Dinh
 */ 
#include<bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define sz(X) (int)(X).size()
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

const int mod=1e9+7;

int n, p;
string s;
map<string, vector<pii>> m;
vector<pair<string, vector<pii>>> res;
int main(){
    scanf("%d", &n);
    cin.ignore();
    for(int i = 1; i <= n; ++i){
        cin >> s >> p;
        m[s].pb(mp(p,i));
    }
    for(auto &i : m){
        sort(all(i.se), greater<pii>());
        res.pb(mp(i.fi, i.se));
    }
    sort(all(res));
    for(auto &i : res){
        for(auto &j : i.se) printf("%d\n", j.se);
    }
    return 0;
}



Measured memory_bytes: 256
import sys


def main():
    while True:
        n = int(input())

        # nが0なら処理終わり
        if n == 0:
            sys.exit()

        arr = list(map(int, input().split()))

        # dpテーブル
        dp = [[0] * n for _ in range(n)]

        # dはdistance。lとrが1〜n-1離れている場合を順に考えていく
        for d in range(1, n):

            # distanceに応じてleftのレンジが変化する
            for l in range(n - d):

                # rは当然left+distance
                r = l + d

                # もしdistanceが奇数なら、1個内側を見ればいい
                if d % 2 == 1:

                    # left, rightの内側が全部叩き出せる場合
                    if dp[l + 1][r - 1] == d - 1 and abs(arr[l] - arr[r]) <= 1:
                        dp[l][r] = dp[l + 1][r - 1] + 2

                    # 叩けないブロックがある場合はワーシャルフロイドっぽく解く
                    else:
                        for k in range(l + 1, r):
                            tmp = dp[l][k] + dp[k + 1][r]
                            if tmp > dp[l][r]:
                                dp[l][r] = tmp

                # もしdistanceが偶数なら、大きい方を採用するだけ
                else:
                    dp[l][r] = max(dp[l + 1][r], dp[l][r - 1])

        print(dp[0][-1])


if __name__ == '__main__':
    main()


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

void Main()
{
    int64_t N, M;
    cin >> N >> M;

    int64_t result = (N * (N - 1) + M * (M - 1)) / 2;
    cout << result << endl;
}

int main()
{
    Main();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main() {

	bool len[300000];
	int ans = INF;
	int n;
	int r = 0, l = 0;
	
	cin >> n;

	rep(i, 0, n) {
		char c;
		cin >> c;
		if (c == 'E') {
			r++;
			len[i] = true;
		}
		else {
			l++;
			len[i] = false;
		}
	}

	int pr = 0, pl = 0, rr = 0, rl = 0;

	rep(i, 0, n) {
		int nr = pr, nl = pl;
		if (len[i]) {
			pr++;
		}
		else {
			pl++;
		}
		rr = r - pr; rl = l - pl;
		ans = min(ans, nl + rr);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
const double PI  =3.141592653589793238463;
using namespace std;
using ll = long long;
const ll INF = +10010010000;
typedef pair<int,int> P;
const int mod = 1e9+7;

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

    // for prime mod
    mint inv() const {
      return pow(mod-2);
    }
    mint& operator/=(const mint a){
      return (*this) *= a.inv();
    }
    mint operator/(const mint a)const{
      mint res(*this);
      return res/=a;
    }
};

struct combination{
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i<n;++i)fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i>=1;--i) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k){
    if(k<0 || k>n)return 0;
    return fact[n] * ifact[k] + ifact[n-k]; 
  }
};

int main(){
    ll a,v,b,w,t;
    cin >> a >> v >> b  >> w >> t;
    if(a>b) swap(a,b);
    v -=w;
    if(v*t+a>=b)cout << "YES"<<endl;
    else cout << "NO"<< endl;
    return 0;

}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-2;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;


int main() {
	ll a, b, x; cin >> a >> b >> x;
	if (x < a) {
		cout << x % mod << endl;
	}
	else {
		ll num = (x - a) / (a - b) + 1;
		num %= mod;
		cout << (x%mod + b % mod*num%mod) % mod << endl;
	}
	//stop
	return 0;
}



Measured memory_bytes: 3076
def p_prime(n): 
    prime = [2]
    for i in range(3,n+1):
        flag = 0
        for j in prime:
            if i%j == 0:
                flag = 1
                break
            if i**0.5 < j:
                break
        if flag == 0:
            prime.append(i)
    return prime

def main():
    import sys
    input = sys.stdin.readline
    
    Q = int(input())
    prime = p_prime(10**5)
    isprime = {}
    for i in prime:
        isprime[i] = 1
    A = [0]*(10**5+1)
    for i in range(1,10**5+1):
        if i in prime and (i+1)//2 in prime:
            A[i] = 1
    for i in range(1,10**5+1):
        A[i] += A[i-1]
    
    for i in range(Q):
        L,R = map(int,input().split())
        print(A[R]-A[L-1])
    
    
    
main()

Measured memory_bytes: 52312
def solve(v_t, v_a, t, a):
    tmpt = 0
    tmpa = 0
    if v_t % t == 0:
        tmpt = v_t // t
    else:
        tmpt = v_t // t + 1
    if v_a % a == 0:
        tmpa = v_a // a
    else:
        tmpa = v_a // a + 1
    return max(tmpt, tmpa)

N = int(input())
vote_t = 0
vote_a = 0
for i in range(N):
    t, a = map(int,input().split())
    if i == 0:
        vote_t = t
        vote_a = a
    else:
        #ganbaru
        n = solve(vote_t, vote_a, t, a)#t*n >= vote_t and a*n >= vote_tとなる最小のnを求める
        vote_t = t*n
        vote_a = a*n
print(str(vote_t + vote_a))

Measured memory_bytes: 38768
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,m = li()

print((1900*m + 100*(n-m))*(2**m))

Measured memory_bytes: 3064
a, b, m = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
bs = gets.split.map(&:to_i)

ans = as.min + bs.min
m.times do
  x, y, c = gets.split.map(&:to_i)
  ans = [ans, as[x-1] + bs[y-1] - c].min
end
puts ans



Measured memory_bytes: 18588
from collections import defaultdict

N, M = map(int, input().split())
A = list(map(int, input().split()))
cumS = [0]
for a in A:
    cumS.append(a + cumS[-1])
cumS_rem = defaultdict(int)
for c in cumS:
    r = c % M
    cumS_rem[r] += 1
ans = 0
for r, n_r in cumS_rem.items():
    if n_r > 1:
        ans += n_r*(n_r-1)//2
print(ans)

Measured memory_bytes: 16808
#include<bits/stdc++.h>
#define maxn 201000
#define inf 1000000007
using namespace std;
int n,a[maxn],b[maxn],mx=-inf,mn=inf,omx,omn,c[maxn];
int comp(int x,int y){
	return a[x]<a[y];
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d%d",&a[i],&b[i]),c[i]=i;
		if(a[i]>b[i])swap(a[i],b[i]);
		if(mx<b[i])mx=b[i],omx=a[i];
		if(mn>a[i])mn=a[i],omn=b[i];
	}
	int _mx=omx,_mn=omn;
	for(int i=1;i<=n;++i)
		_mx=max(_mx,a[i]),_mn=min(_mn,b[i]);
	long long ans=1ll*(mx-_mn)*(_mx-mn);
	sort(c+1,c+n+1,comp);
	int x=inf;
	for(int i=1;i<=n;++i)
		ans=min(ans,1ll*(mx-mn)*(_mx-min(a[c[i]],x))),x=min(b[c[i]],x),_mx=max(_mx,b[c[i]]);
	printf("%lld",ans);
}



Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#define INF 1000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
ll mod = 1000000007;
bool dp[50010][11][11][11];

int main() {
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		int x = s[i] - '0';
		dp[i][x][10][10] = true;
		for (int j = 0; j < 10; j++) {
			if (i >= 1 && dp[i - 1][j][10][10]) {
				dp[i][j][x][10] = true; dp[i][j][10][10] = true;
			}
 			for (int k = 0; k < 10; k++) {
				if (i >= 1 && dp[i - 1][j][k][10]) {
					dp[i][j][k][x] = true; dp[i][j][k][10] = true;
				}
				for (int l = 0; l < 10; l++) {
					if (i >= 1 && dp[i-1][j][k][l]) dp[i][j][k][l] = true;
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			for (int k = 0; k < 10; k++) {
				if (dp[n - 1][i][j][k]) ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 41216
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================



	ll N, K;
	cin >> N >> K;



	cout << min((N % K), abs(K - (N % K)));





}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int H,W,K;cin>>H>>W>>K;
  	int pos=0;
  int count;
  for(int i=0;i<=H;i++)
    for(int j=0;j<=W;j++){
      	count = i*(W-j)+j*(H-i);
      	//cout<<i<<' '<<j<<' '<<count<<'\n';
      if(count==K)pos=1;
    }
  if(pos==0)cout<<"No";
  else cout<<"Yes";
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int L;

int main(){
    cin>>L;
    int n=1;
    int cur=1;
    while(L>=cur*2) cur*=2,++n;
    int edcnt=0;
    vector<string> ans;
    rep(i,n-1){
        string t;
        t+=to_string(i+1)+" "+to_string(i+2)+" 0";
        ans.pb(t);
        t.clear();
        t+=to_string(i+1)+" "+to_string(i+2)+" "+to_string(1<<i);
        ans.pb(t);
    }
    for(int i=n-2;i>=0;--i){
        if(L-(1<<i)>=(1<<(n-1))){
            string t;
            t+=to_string(i+1)+" "+to_string(n)+" "+to_string(L-(1<<i));
            ans.pb(t);
            L-=(1<<i);
        }
    }
    cout<<n<<" "<<ans.size()<<endl;
    for(auto it:ans) cout<<it<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n[6];
    int a=0, b=0, c=0, d=0;
    int i, k=0;
    for(i=0;i<6;i++){
       scanf("%d",&n[i]);
    }
    for(i=0;i<6;i++){
        if(n[i] == 1){
            a++;
        }else if (n[i] == 2){
            b++;
        }else if(n[i] == 3){
            c++;
        }else if(n[i] == 4){
            d++;
        }
    }
    if((a==2&&b==2) || (a==2&&c==2) || (a==2&&d==2) || (b==2&&c==2) || (b==2&&d==2) || (c==2&&d==2)){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int T,t,x,y,b,u,v,w;
int main() {
	scanf("%d",&T);
    while(T--) {
    	scanf("%d%d%d",&u,&v,&w); 
        if(abs(v-x)+abs(w-y)>abs(u-t)||(abs(u-t)-abs(v-x)-abs(w-y))%2) b=1;
        t=u; x=v; y=w;
    }
    puts(b?"No":"Yes");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
ll MOD = 998244353;
const ll N = 1e7+10;
ll f[N], rf[N];
ll inv(ll x) {
    ll res = 1;
    ll k = MOD - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    for(int i = 1; i < N; i++) f[i] = (f[i - 1] * i) % MOD;
    rf[N - 1] = inv(f[N - 1]);
    for(int i = N-2; i >= 0; i--) rf[i] = (rf[i + 1] * (i + 1)) % MOD;
}
ll C(int n, int k) {
    if(n < k) return 0;
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!
    ll bc = (b * c) % MOD;
    return (a * bc) % MOD;
}

ll mod_pow(ll x, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n & 1)
        {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

int main()
{
    init();
    int n;
    cin >> n;
    ll ans = mod_pow(3, n);
    ll tmp = 0;
    vector<ll> mod2(n/2+1);
    mod2[0] = 1;
    for(int i = 1; i < n/2+1; i++)
    {
        mod2[i] = mod2[i-1] * 2 % MOD;
    }
    for(int a = n/2 + 1; a <= n; a++)
    {
        tmp += C(n, a) * mod2[n-a] % MOD;
        tmp %= MOD;
    }
    tmp = tmp * 2 % MOD;
    ans = (ans - tmp + MOD) % MOD;
    cout << ans << endl;
}


Measured memory_bytes: 195584
#!/usr/bin/env python3

#import
#import math
#import numpy as np
#= int(input())
S = input()
K = int(input())
ls = len(S)
t1 = []

t = 1
for i in range(1, ls):
    if S[i - 1] == S[i]:
        t += 1
    else:
        if t > 1:
            t1.append(t)
        t = 1

if t > 1 or t == ls:
    t1.append(t)

ans = 0
for t in t1:
    ans += t // 2

if len(t1) == 1:
    if t1[0] == ls:
        print(ls * K // 2)

else:
    if S[0] != S[-1]:
        print(ans * K)
    
    else:
        ta = t1[0]
        tb = t1[-1]
        print(ans * K - (ta // 2 + tb // 2 - (ta + tb) // 2) * (K - 1))






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

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    char s[5];
    cin >> s;
    int a = (s[0] - '0') * 10 + s[1] - '0';
    int b = (s[2] - '0') * 10 + s[3] - '0';
    if(a == 0) {
        if(1 <= b && b <= 12) {
            cout << "YYMM";
        } else {
            cout << "NA";
        }
    } else if(a <= 12) {
        if(1 <= b && b <= 12) {
            cout << "AMBIGUOUS";
        } else {
            cout << "MMYY";
        }
    } else {
        if(1 <= b && b <= 12) {
            cout << "YYMM";
        } else {
            cout << "NA";
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
    const int MAX =200002;
const int MOD =1000000007;


     signed main(){
         int x,k,d;
         cin>>x>>k>>d;
         if(abs(x)/d>=k){
          cout<<abs(x)-k*d<<endl;
          
             return 0;
         }
   
         if((abs(x)/d)%2==k%2){
             cout<<(abs(x)%d)<<endl;
         }else cout<<(d- abs(x)%d)<<endl;
       


     }


 


 






    





      

        


Measured memory_bytes: 3616
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ll, ii>  iii;
typedef pair<double, double>  iidb;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const double PI = acos(-1);
#define initseg ll new_nodo=(pnodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 2200
#define offset 3000
#define ptr nodo*
const ll MOD=1e9+7;

using namespace std;
int H,W;
string txt[tam];
bool contar(int y,int x)
{
	int c=0;
	c+=txt[y][x]=='.';
	c+=txt[y][x+1]=='.';
	c+=txt[y+1][x]=='.';
	c+=txt[y+1][x+1]=='.';
	return c%2;
}
int val[tam][tam];
set<int> unos[tam];
vector<int> getvect(int x)
{
	vector<int> res;
	forr(y,0,H)
	{
		int nxt=W;
		auto ite=unos[y].lower_bound(x);
		if (ite!=unos[y].end())
			nxt=*ite;
		res.pb(nxt-x);
	}
	
	return res;
}
int MAX=0;
void solve(vector<int> v)
{
	set<ii> s;
	forr(i,0,v.size())
	{
		s.insert({v[i],i});
	}	
	//<<v.size()<<' '<<H<<endl;
	assert(v.size()==H);
	int ant=-1;
	set<int> spos;
	for(auto par:s)
	{
		
		int nxt=H,nxtiz=-1,dim1,dim2;
		auto ite=spos.lower_bound(par.se);
		if (ite!=spos.end()) nxt=*ite;

		if (ite!=spos.begin())	ite--,nxtiz=*ite;
		dim1=par.fi;
		dim2=nxt-nxtiz-1;

		//<<w8.size()<<" ";
		//<<par.fi<<','<<par.se<<' '<<dim1<<' '<<dim2<<endl;
		if ((dim1+1)*(dim2+1)>MAX)
		{
			MAX=(dim1+1)*(dim2+1);
		}
		spos.insert(par.se);
	}
}
int main()
{	
	cin>>H>>W;
	forr(i,0,H)
	{
		cin>>txt[i];
	}
	forr(i,0,H-1)
	{
		forr(j,0,W-1)
		{
			val[i][j]=contar(i,j);
			//cout<<val[i][j];
			if (val[i][j])
			unos[i].insert(j);
		}
		//cout<<endl;
	}
	MAX=max(H,MAX);
	MAX=max(W,MAX);
	H--,W--;
	
	forr(i,0,W)
	{
		solve(getvect(i));
		//<<MAX<<endl;	
	}
	cout<<MAX<<"\n";
}

Measured memory_bytes: 157584