akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

const int N = 52;
int bit[N][N];

ll accum(int x, int y) {
  ll tot = 0;
  while (x > 0) {
    int yc = y;
    while (yc > 0) {
      tot += bit[x][yc];
      yc &= yc - 1;
    }
    x &= x - 1;
  }
  return tot;
}

void update(int x, int y, ll val) {
  if (x <= 0 || y <= 0) {
    return;
  }
  while (x < N) {
    int yc = y;
    while (yc < N) {
      bit[x][yc] += val;
      yc += yc & (-yc);
    }
    x += x & (-x);
  }
}

map<int, int> comp(const VI &x, VI &inv) {
  VI y(x);
  sort(y.begin(), y.end());
  map<int, int> ret;
  REP(i, 0, y.size()) {
    ret[y[i]] = i;
  }
  inv = y;
  return ret;
}

int main(void) {
  int n, k;
  cin >> n >> k;
  VI x(n), y(n);
  REP(i, 0, n) {
    cin >> x[i] >> y[i];
  }
  VI xc_inv, yc_inv;
  map<int, int> xc = comp(x, xc_inv), yc = comp(y, yc_inv);
  REP(i, 0, n) {
    update(xc[x[i]] + 1, yc[y[i]] + 1, 1);
  }
  ll mi = 5e18;
  REP(i, 1, n + 1) {
    REP(j, i, n + 1) {
      REP(a, 1, n + 1) {
	REP(b, a, n + 1) {
	  if (accum(j, b) - accum(j, a - 1) - accum(i - 1, b) + accum(i - 1, a - 1) >= k) {
	    mi = min(mi, ll(xc_inv[j - 1] - xc_inv[i - 1]) *
		     ll(yc_inv[b - 1] - yc_inv[a - 1]));
	  }
	}
      }
    }
  }
  cout << mi << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a) for(ll i=ll(a-1);i>=0;--i)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll MOD3 = 1e6;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<long double,long double> point;
typedef complex<long double> Point;
const ll MAX = 1e9;
constexpr ll nx[4] = {-1,0,1,0};
constexpr ll ny[4] = {0,1,0,-1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    PRINT(1-x);
}

Measured memory_bytes: 3644
from collections import Counter
import numpy as np


def part(pts, s, t, num, ans):
    a = np.linspace(s, t, num, endpoint=False)
    for i, v in Counter(np.argmax(np.dot(pts, [np.sin(a), np.cos(a)]), axis=0)).items():
        ans[i] += v


def solve(n, pts):
    ans = np.zeros(n)
    part(pts, 0, np.pi, 1e5, ans)
    part(pts, np.pi, 2 * np.pi, 1e5, ans)
    return ans / 2e5


n = int(input())
print('\n'.join(map(str, solve(n, [list(map(int, input().split())) for _ in range(n)]))))


Measured memory_bytes: 175124
#include <bits/stdc++.h>
#define N 1000011
using namespace std;
int mp[2000][2000];
int dx[]={1,0,-1,0},dy[]={0,-1,0,1};//>, ^,<,v
bool prime[N];
int n,m;

void mk_mp(){
  mp[1000][1000]=1;  
  int x=1001,y=1000,dir=0,num=2;
  while(num<N+N){
    mp[y][x]=num;
    int ndir=(dir+1)%4,nx=x+dx[ndir],ny=y+dy[ndir];
    if(mp[ny][nx]==0) dir=ndir;
    else x+=dx[dir],y+=dy[dir],num++;
  }
}

typedef pair<int,int> P;
P mem[2000][2000];
int used[2000][2000];
P dfs(int y,int x){
  if(mp[y][x]>m)return P(0,0);
  if(used[y][x]++) return mem[y][x];
  P res=max(dfs(y+1,x-1),max(dfs(y+1,x),dfs(y+1,x+1)));
  if(!prime[mp[y][x]]){
    res.first++;
    if(res.second==0)res.second=mp[y][x];
  }
  return mem[y][x]=res;
}


int main(){
  prime[0]=prime[1]=1;
  for(int i=2;i*i<N;i++)
    if(!prime[i])
      for(int j=2;j<=N/i;j++) prime[i*j]=1;
  mk_mp();
  while(1){
    cin>>m>>n;
    if(!n&&!m)return 0;
    memset(used,0,sizeof(used));
    int x=-1,y=-1;
    for(int i=0;i<2000&&x==-1;i++)
      for(int j=0;j<2000&&x==-1;j++)if(mp[i][j]==n)x=j,y=i ;
    P ans=dfs(y,x);
    cout <<ans.first<<" "<<ans.second<<endl;
  }
  return 0;
}

Measured memory_bytes: 62120
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};

int main() {

	int n;
	cin>>n;

	ll a=1;
	for(int i=2; i<n+1; i++)a*=i;
	cout<<a<<endl;
	return 0;
}



Measured memory_bytes: 3060
#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 push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int n,k,x;
    cin>>n>>k;
    int ans=0;
    rep(i,n){
        cin>>x;
        ans+=min(x,abs(x-k));
    }
    cout<<ans*2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX_N 1000

void insertionSort(int *, int);

int main()
{
  int A[MAX_N];
  int N=0;
  int i;
  
  scanf("%d", &N);

  for(i=0;i<N;i++)
   {
     scanf("%d",&A[i]);
   }

insertionSort(A,N);

  return 0;
}

void insertionSort(int *A, int N)
{
int i,j,v;

for(j=0;j<N;j++)
  {
if(j>0)printf(" ");
    printf("%d",A[j]);
  }
printf("\n");
for(i=1;i<N;i++)
  {
v = A[i];
j = i - 1;

while(j>=0 && A[j] > v)
  {
A[j+1] = A[j];
j--;
}
A[j+1] = v;

for(j=0;j<N;j++)
  {
if(j>0)printf(" ");
printf("%d",A[j]);
}
printf("\n");

}
}



Measured memory_bytes: 2072
import sys
input = sys.stdin.readline

n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
dp = [[0]*3 for i in range(n+1)]

for i in range(n):
    dp[i+1][0] = max(dp[i][1],dp[i][2])+l[i][0]
    dp[i+1][1] = max(dp[i][0],dp[i][2])+l[i][1]
    dp[i+1][2] = max(dp[i][1],dp[i][0])+l[i][2]
    
print(max(dp[n]))
        
    

Measured memory_bytes: 47364
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處
struct Discount {
    int x, y, c;
} discounts[100005];
int a[100005];
int b[100005];
int main() {
    int A, B, M;
    scanf("%d%d%d", &A, &B, &M);
    for (int i = 1; i <= A; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 1; i <= B; i++) {
        scanf("%d", &b[i]);
    }
    for (int i = 0; i < M; i++) {
        scanf("%d%d%d", &discounts[i].x, &discounts[i].y, &discounts[i].c);
    }
    int ans = 99999999;
    for (int i = 0; i < M; i++) {
        ans = min(ans, a[discounts[i].x] + b[discounts[i].y] - discounts[i].c);
    }
    int minA = 99999999;
    for (int i = 1; i <= A; i++) {
        minA = min(minA, a[i]);
    }
    int minB = 99999999;
    for (int i = 1; i <= B; i++) {
        minB = min(minB, b[i]);
    }
    ans = min(ans, minA + minB);
    printf("%d\n", ans);
}


Measured memory_bytes: 2176
#include <cstdio>

using namespace std;

int max(int a, int b)
{
    if (a > b) return a;
    return b;
}

int main()
{
    int n(0);
    scanf("%d",&n);

    int **v = new int*[n + 1];
    for (int i = 1 ; i <= n ; i++)
        v[i] = new int[3];

    int a(0), b(0), c(0);
    scanf("%d %d %d",&a,&b,&c);
    v[1][0] = a;
    v[1][1] = b;
    v[1][2] = c;

    int max01(0), max11(0), max21(0);
    for (int i = 2 ; i <= n ; i++)
    {
        scanf("%d %d %d",&a,&b,&c);
        max01 = max(v[i-1][1],v[i-1][2]);
        max11 = max(v[i-1][0],v[i-1][2]);
        max21 = max(v[i-1][0],v[i-1][1]);
        v[i][0] = a + max01;
        v[i][1] = b + max11;
        v[i][2] = c + max21;

    }

    int maxim = 0;
    for (int i = 0 ; i < 3 ; i++)
        if (maxim < v[n][i])
            maxim = v[n][i];
    printf("%d",maxim);
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const ll MAX=9187201950435737471;
const int N=100005;
const ll INF=-1e12;
const double pi=acos(-1);

int a[3003];
ll dp[3003][3003][2];
bool p[3003][3003][2];
ll s(int i,int j,int t){
    if(i>j){
        return 0;
    }
    ll &ret=dp[i][j][t];
    if(p[i][j][t])return ret;
    p[i][j][t]=1;
    ll ch1,ch2;
    if(t){
     ch1=s(i+1,j,1-t)-a[i];
     ch2=s(i,j-1,1-t)-a[j];
     return ret=min(ch1,ch2);
    }
    else{
         ch1=s(i+1,j,1-t)+a[i];
         ch2=s(i,j-1,1-t)+a[j];
        return ret=max(ch1,ch2);
    }
}

void solve(int T){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    cout<<s(0,n-1,0);
}

int main() {
    fastio

    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
    }
	return 0;
}


Measured memory_bytes: 158336
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
//<< setprecision(5)
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
const int mod=1000000007;
const int big=1e9;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	llint n,ans=1;cin>>n;
	while(ans&n){ans*=2;}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3112
#include <iostream>

#define MAX 86

using namespace std;

int main(void) {

	unsigned long long int iData[(MAX + 1)];
	int iI;

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

	iData[0] = 2;
	iData[1] = 1;

	for (iI = 2; iI <= MAX; iI++)
		iData[iI] = iData[(iI - 1)] + iData[(iI - 2)];

	cin >> iI;

	cout << iData[iI] << endl;

	return 0;


}

Measured memory_bytes: 256
/*input

*/

#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define pb          push_back
#define pp          pop_back
#define nl          cout << "\n"
#define MIN(con)    (*min_element(ALL(con)))
#define MAX(con)    (*max_element(ALL(con)))
#define NX(cont)    next_permutation(ALL(cont))
#define PX(cont)    prev_permutation(ALL(cont))
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define all(c)      c.begin(),c.end()
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define sp          cout << " "
#define ifalse      ios_base::sync_with_stdio(false),cin.tie(NULL)
#define debug(x)    cout << #x << " = " << x << "\n";

using ll = long long;
using ld = long double;
 
template <typename T> T GCD(T a, T b) { ll t; while(a){ t=a; a=b%a; b=t; } return b; }
template <typename T> T LCM(T a, T b) { return (a*b) / GCD(a, b); }
template <typename T> string toString(T a) { return to_string(a); }
template <typename T> void toInt(string s, T &x) { stringstream str(s); str >> x; }

ll add(ll x, ll y, ll MOD) { x += y; if(x >= MOD) x -= MOD; return x; }
ll sub(ll x, ll y, ll MOD) { x -= y; if(x < 0) x += MOD; return x; }
ll mul(ll x, ll y, ll MOD) { return ((x % MOD) * (y % MOD)) % MOD; }

ll powr(ll a, ll b, ll MOD) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a, MOD);
    a = mul(a, a, MOD);
    b >>= 1;
  }
  return x;
}

ll inv(ll a, ll MOD) { return powr(a, MOD-2, MOD); }
const ll INF =  1e18;
const int SINF = 1e9;
const ll MOD = 1e9 + 7;

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/************************************START***************************************/
const int N = 100005;

int main()
{
  ifalse;
  int n;
  cin >> n;
  vector < int > v;
  rep(i, 0, n) {
    int x;
    cin >> x;
    v.pb(x);
  }
  int ans = 1;
  for(int i = 1; i < n; i ++) {
    bool flag = 0;
    for(int j = i - 1; j >= 0; j --) {
      if(v[j] > v[i]) {
        flag = 1;
        break;
      }
    }
    if(!flag) {
      ans ++;
    }
  } 
  cout << ans;
  return 0;
}

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

int main() {
  ll X;
  ll a= 100;
  ll ans = 0;
  cin >> X;
  while(a<= X){
    a+= a /100;
    ans++;
    if(a>= X){
      cout << ans;
      return 0;
    }
  }
}


Measured memory_bytes: 3588
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <set>
#include <stdint.h>
#include <vector>
using namespace std;

int64_t solve()
{
    int x, y, z;
    cin >> x >> y >> z;

    int n = x + y + z;

    vector<int64_t> as(n), bs(n), cs(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i] >> bs[i] >> cs[i];
    }

    vector<int> ord(n);
    for (int i = 0; i < n; i++)
        ord[i] = i;

    sort(ord.begin(), ord.end(), [&](int i, int j) {
        return as[i] - bs[i] > as[j] - bs[j];
    });

    auto f = [](
        int n, const vector<int>& ord, int x,
        const vector<int64_t>& as, const vector<int64_t>& cs) {

        vector<int64_t> v;
        set<pair<int64_t, int>> ss;
        int64_t acc = 0;
        for (int oi = 0; oi < n; oi++) {
            int i = ord[oi];

            // cout << oi << ": " << i << endl;

            acc += as[i];
            ss.insert(make_pair(as[i] - cs[i], i));
            while (ss.size() > x) {
                acc -= ss.begin()->first;
                ss.erase(ss.begin());
            }
            v.push_back(acc);
        }

        return v;
    };

    auto ls = f(n, ord, x, as, cs);
    reverse(ord.begin(), ord.end());
    auto rs = f(n, ord, y, bs, cs);

    // for (auto& t : ls)
    //     cout << t << " ";
    // cout << endl;
    // for (auto& t : rs)
    //     cout << t << " ";
    // cout << endl;

    int64_t ans = 0;

    for (int i = x; i <= n - y; i++) {
        int l = i;
        int r = n - l;

        assert(l > 0 && r > 0);

        int64_t cur = ls[l - 1] + rs[r - 1];

        ans = max(ans, cur);
    }

    return ans;
}

int main()
{
    cin.tie(0);
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 10376
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    int n;
    cin>>n;
 
    vector<int> vec(n);
    int counts = 0;
 
    sort(vec.begin(), vec.end());
    for(int i = 0; i < n; i++)
        cin>>vec[i];
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            for(int k = j + 1; k < n; k++){
                if(vec[j] != vec[i] && vec[i] != vec[k]&& vec[j] != vec[k] && vec[i] + vec[j] > vec[k] && vec[j] + vec[k] > vec[i] && vec[i] + vec[k] > vec[j]){
                    //cout<<i+1 <<' '<<j+1<<' '<<k+1<<'\n';
                    counts++;
                }
            }
        }
    }
    cout<<counts;
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <iomanip>

using namespace std;

int main(){
	int n;
	cin >> n;
	if(n%2 != 0){
		n/=2;
		n+=1;
		cout << n << endl;
	}
	else
		cout << n/2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set> 
#include<cmath>
using namespace std;
//long long p = 998244353;
long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) { pa[x] = y; }
}
int gcd(int x, int y) {
	if (x < y) { return gcd(y, x); }
	if (y == 0) { return x; }
	return gcd(y, x % y);
}
int solve(int x, int y) {
	int ans = rui(2, x) + rui(2, y) + p - 1;
	ans %= p;
	int g1 = gcd(x, y);
	ans += rui(2, g1) + p - 2;
	ans %= p;
	return ans;
}
void mi(vel &v,int k) {
	int n = v.size();
	int j = n - 1;
	while (v[j] == 0) { j--; }
	v[j]--; 
	if (v[j] != 0){
		j++;
		while (j < n) {
			v[j] = k; j++;
		}
	}

}
signed main() {
	int n, k; cin >> k >> n;
	if (k % 2 == 0) {
		int l = k / 2;
		cout << l;
		rep(i, n-1) {
			cout << " " << k;
		}
		cout << endl;
	}
  else if(k==1){
    int m=(n+1)/2;
    rep(i,m){cout << " "<<1;}
    cout <<endl;
  }
	else {
		vel ans(n,(k + 1) / 2);
		int pl = n - 1;
		while (pl > 0) {
			mi(ans,k);
			pl -= 2;
		}
		cout << ans[0];
		int ind = 1;
		while (ind < n) {
			if (ans[ind] == 0) { break; }
			cout << " " << ans[ind];
			ind++;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 5760
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#define log(args...)
#else
#define log(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); logf(_it, args); }
void logf(istream_iterator<string> it) {
}
template<typename T, typename ... Args>
void logf(istream_iterator<string> it, T a, Args ... args) {
	cout << *it << " = " << a << endl;
	logf(++it, args...);
}
#endif

#define forn(i,k,n) for(ll i=(k); i<(n); i++)

const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

template<typename T>
class fenwick {
public:
	vector<T> fenw;
	int n;

	fenwick(int _n) :
			n(_n) {
		fenw.resize(n);
	}

	void modify(int x, T v) {
		while (x < n) {
			fenw[x] += v;
			x |= (x + 1);
		}
	}

	/* get sum of range (0,x), including x */
	T get(int x) {
		T v { };
		while (x >= 0) {
			v += fenw[x];
			x = (x & (x + 1)) - 1;
		}
		return v;
	}
};

void solve() {
	cini(n);
	cini(d);
	cinll(a);
	vector<pii> xh(n);
	for (int i = 0; i < n; i++) {
		cin >> xh[i].first >> xh[i].second;
	}
	sort(xh.begin(), xh.end());

	fenwick<ll> fen(n + 1);	// fen.get(x) == demage at x so far

	/* remove one monster after the other
	 * allways bombing at xh[i].first+d+1 until current moster is dead.
	 */
	ll ans = 0;
	int r = 0;
	for (int i = 0; i < n; i++) {
		ll demage = fen.get(i);
		//cout << "i=" << i << " demage=" << demage << endl;
		if (xh[i].second > demage) {	// monster not dead so far
			int bombs = (xh[i].second - demage + a - 1) / a;
			ans += bombs;
			//cout << "bombs=" << bombs << endl;
			fen.modify(i, bombs * a);
			// find last affected index
			r = max(r, i);
			while (r < n && xh[i].first + 2 * d >= xh[r].first)
				r++;

			//cout << "i=" << i << " r=" << r << endl;

			fen.modify(r, -bombs * a);
		}
	}
	cout << ans << endl;
}

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



Measured memory_bytes: 3456
#include <stdio.h>
#include <algorithm>

int n, card[2][112];

int main(void) {
	while (true) {
		scanf("%d", &n);
		if (n == 0) { break; }
		for (int i = 0; i < n; ++i) { scanf("%d", &card[0][i]); }

		bool have_flag = false;
		int count[2] = { 0 };
		std::sort(card[0], card[0] + n);
		for (int i = 1; i <= n * 2; ++i) {
			for (int j = 0; j < n; ++j) {
				if (card[0][j] == i) {
					have_flag = true;
					break;
				}
			}
			if (have_flag == false) {
				card[1][count[1]] = i;
				++count[1];
			}
			have_flag = false;
		}
		int now_card = -1, turn = 0, ans = 0, num[2] = { 0 };
		bool flag = true;
		count[1] = 0;
		while (true) {
			if (count[0] >= n || count[1] >= n) { break; }
			if (now_card == -1) {
				now_card = card[0][0];
				card[0][0] = -1;
				++count[turn % 2];
				turn = 1;
			}
			for (int i = 0; i < n; ++i) {
				if (now_card < card[turn % 2][i]) {
					flag = true;
					num[turn % 2] = i;
					break;
				}
			}
			if (flag == false) {
				now_card = 0;
				++turn;
			}
			else {
				now_card = card[turn % 2][num[turn % 2]];
				card[turn % 2][num[turn % 2]] = -1;
				++count[turn % 2];
				++turn;
			}
			flag = false;
		}
		printf("%d\n%d\n", n - count[1], n - count[0]);
	}
	return 0;
}

Measured memory_bytes: 2736
A = list(input())
B = list(input())
C = list(input())

turn = "a"
while True:
    if turn == "a":
        if len(A):
            turn = A[0]
            A.pop(0)
        else:
            break
    elif turn == "b":
        if len(B):
            turn = B[0]
            B.pop(0)
        else:
            break
    else:
        if len(C):
            turn = C[0]
            C.pop(0)
        else:
            break

#誰かが上がったとき

if turn == "a":
    print("A")
elif turn == "b":
    print("B")
else:
    print("C")



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int i = 1;
  while(1){
  	if(i * 1000 >= N){
      cout << i * 1000 - N << endl;
      return 0;
    }
    i++;
  }
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL;
  typedef pair<ll,char> PLC;
  typedef pair<char,ll> PCL;

int main(void){
  int N,K;cin >> N >> K;
  cout << N-K+1 << endl;
  return 0;
}


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
#include <complex>
typedef complex<double> Point;
typedef vector<Point> Polygon;
struct Line : public vector<Point> {
  Line() {;}
  Line(Point a, Point b) { push_back(a); push_back(b); }
};

inline double cross(const Point& a, const Point& b){
  return imag(conj(a) * b);
}

inline double dot(const Point& a, const Point& b){
  return real(conj(a) * b);
}

int ccw(Point a, Point b, Point c){
  b -= a; c -= a;
  double len = abs(b) * abs(c);
  if(cross(b, c) > +EPS * len) return +1; // counter-clockwise
  if(cross(b, c) < -EPS * len) return -1; // clockwise
  if(dot(b, c) < 0) return +2; // c--a--b
  if(norm(b) < norm(c)) return -2; // a--b--c
  return 0; // a--c--b 
}

bool intersectSS(const Line &s, const Line &t) {
  return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
    ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}

bool intersectSP(const Line &s, const Point &p) {
  return abs(s[0] - p) + abs(s[1] - p) - abs(s[1] - s[0]) < EPS;
}

Point projection(const Line &l, const Point &p) {
  double t = dot(p - l[0], l[0] - l[1]) / norm(l[0] - l[1]);
  return l[0] + t * (l[0] - l[1]);
}

double distanceSP(const Line &s, const Point &p) {
  const Point r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}

double distanceSS(const Line &s, const Line &t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
             min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}
typedef pair<double, int> P;
int main(){
  int N, M, L;
  while(cin>>N>>M>>L && N){
    M--; L--;
    double x[100], y[100], a[100], r[100];
    REP(i, N){
      cin>>x[i]>>y[i]>>a[i]>>r[i];
    }
    vector<Line> lines(N * 5);
    REP(i, N){
      Point ps[5];
      REP(j, 5) ps[j] = Point(x[i] + r[i] * cos(M_PI*(90.0 + a[i] + 72 * j)/180.0), y[i] + r[i] * sin(M_PI*(90.0 + a[i] + 72 * j)/180));
      REP(j, 5) lines[5 * i + j] = Line(ps[j], ps[(j + 2) % 5]);
    }
    vector<double> dist(N * 5, INF);
    priority_queue<P, vector<P>, greater<P> > que;
    REP(i, 5){
      dist[5 * M + i] = 0;
      que.push(P(0, 5 * M + i));
    }
    while(!que.empty()){
      P p = que.top(); que.pop();
      int u = p.second;
      if(dist[u] != p.first) continue;
      REP(i, N * 5){
        double next = dist[u] + distanceSS(lines[u], lines[i]);
        if(next < dist[i]){
          dist[i] = next;
          que.push(P(next, i));
        }
      }
    }
    printf("%.10f\n", dist[5*L]);
  }
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vll vector<ll>
#define vi vector<int>
#define vvll vector<vll>
#define wh(t) while(t--)
#define fi(n) for(ll i = 0; i < n; i++)
#define fj(n) for(ll j = 0; j < n; j++)
#define fu(i,s,e) for(ll i = s; i <=e; i++)
#define fd(i,s,e) for(ll i = s; i >=e; i--)
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define fr first
#define se second
#define sll stack<ll>
#define qll queue<ll>
using namespace std;
const ll M = 1e9+7;
//const ll M = 998244353;

ll pmp(ll x,ll n){ll a = 1;while(n > 0){if(n & 1) a = (a * x)%M;x = (x * x)%M;n = n>>1;}return a;}

void solve(){
	ll n;
	cin >> n;
	string s;
	cin >> s;
	ll r = 0;
	fi(n) r+=(s[i]=='R');
	ll ans = r;
	fi(r) ans-=(s[i]=='R');
	cout << ans;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif
	ll t;
	t = 1;
	// cin >> t;
	wh(t){
		solve();
	}
	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 3988
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int divceil(int a, int b) {
  return (a+b-1)/b;
}

int main() {
  int k,q;
  cin >> k >> q;
  vector<int> d(k);
  rep(i,k) cin >> d[i];
  rep(qi,q) {
    int n,x,m;
    cin >> n >> x >> m;
    ll last = x, eq = 0;
    rep(i,k) {
      ll num = divceil(n-1-i,k);
      last += (d[i]%m)*num;
      if (d[i]%m == 0) eq += num;
    }
    ll ans = (n-1) - (last/m - x/m) -eq;
    cout << ans << endl;
  }
  return 0;
}


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

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  int cun=0;
  for(int i=1;i<=n;i++){
    int s=i;
    int g=0;
    while(s){
      g+=s%10;
      s/=10;
    }
    if(g>=a&&g<=b){
      cun+=i;
    }
  }
  cout<<cun<<endl;
}
      


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int n,m,q;
vector<int>a,b,c,d;
int ans;
void dfs(vector<int> A) {
    if(A.size()==n+1) {
        int now = 0;
        rep(i,q) {
            if(A[b[i]]-A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans,now);
        return;
    }
    A.push_back(A.back());
    while(A.back()<=m) {
        dfs(A);
        A.back()++;
    }
}

int main() {
    cin >> n>> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    rep(i,q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];   
    }
    dfs(vector<int>(1,1));
    cout << ans << endl;

}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for(long long i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
using namespace std;
typedef long long ll;

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

	string S,T;
	int N = 0;

	cin >> S >>T;

	REP(i, 3)
	{
		if (S[i] == T[i])
		{
			N++;
		}
	}

	cout << N << endl;
	
	return 0;
}

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

int main() {
    // 例 1: 2 つの整数 a, b を入力し、a と b の最大公約数と最小公倍数を出力する
    int a, b, c, k;
    cin >> k;
  
  int sum = 0;
  for (a = 1; a < k+1; a++){
    for (b = 1; b < k+1; b++){
      for (c = 1; c < k+1; c++){
        sum = sum + __gcd(__gcd(a, b), c);
      }
    }
  }
    
    cout << sum << endl;
   
}

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            int n = Integer.parseInt(br.readLine());
            for(int i = 0 ; i < n ; i++ ){
                BigInteger budget1 = new BigInteger(br.readLine());
                BigInteger budget2 = new BigInteger(br.readLine());
                if(budget1.toString().length() > 80 || budget2.toString().length() > 80){
                    System.out.println("overflow");
                    continue;
                }
                String result = budget1.add(budget2).toString();
                if(result.length()>80){
                    System.out.println("overflow");
                    continue;
                }
                System.out.println(budget1.add(budget2));
            }
        }
        catch (Exception e){
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 24284
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;

vector<int> to[2505];
vector<int> rto[2505];
bool reachableFrom1[2505];
bool reachableFromN[2505];
bool ok[2505];

void dfs(int v){
	if(reachableFrom1[v]) return;
	reachableFrom1[v] = true;
	for(int u : to[v]){
		dfs(u);
	}
}

void rdfs(int v){
	if(reachableFromN[v]) return;
	reachableFromN[v] = true;
	for(int u : rto[v]){
		rdfs(u);
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, p;
	cin >> n >> m >> p;
	vector<tuple<int, int, int>> edges;
	rep(i,m){
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		c -= p;
		c = -c;
		edges.emplace_back(a, b, c);
		to[a].push_back(b);
		rto[b].push_back(a);
	}
	dfs(0);
	rdfs(n-1);
	rep(i,n) ok[i] = reachableFrom1[i]&reachableFromN[i];
	vector<int> d(n, INF);
	d[0] = 0;
	bool upd = true;
	int step = 0;
	while(upd){
		upd = false;
		rep(i,m){
			int a, b, c;
			tie(a, b, c) = edges[i];
			if(!ok[a]) continue;
			if(!ok[b]) continue;
			int newD = d[a] + c;
			if(newD < d[b]){
				upd = true;
				d[b] = newD;
			}
		}
		step++;
		if(step > n){
			cout << -1 << endl;
			return 0;
		}
	}
	int ans = -d[n-1];
	chmax(ans, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
/*...Part - 01...*/

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <iterator>
#include <bitset>
#include <assert.h>
#include <new>
#include <sstream>
//#include <bits/stdc++.h>
using namespace std ;

/*...Part - 02...*/

typedef long long               ll ;
typedef long double             ld ;
typedef unsigned long long      ull ;
typedef pair<int,int>           pii ;
typedef pair<ll,ll>             pll ;
typedef vector<int>             vi ;
typedef vector<ll>              vll ;
typedef vector<vector<int>>     vvi ;

int Int(){int x ; scanf("%d",&x) ; return x ;}
ll Long(){ll x ; scanf("%lld",&x) ; return x ;}

/*...Part - 03...*/
/*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

/*...Part - 04...*/
/*...Needed to change according to problem requirements...*/

const int N          = (int)2e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;

/*..........................................................*/
/*...Part - 05...*/

#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e))  ; i += 1 - 2 * ((b) > (e)))
#define     Int         Int()
#define     Long        Long()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)

/*...Part - 06...*/
/*...... ! Code start from here ! ......*/

ll t[N] ;

void upd(int i, ll v, int n){
	while(i <= n){
		t[i] = max(t[i], v) ;
		i += (i & -i) ;
	}
}

ll query(int i){
	ll res = 0 ;
	while(i){
		res = max(res, t[i]) ;
		i -= (i & -i) ;
	}
	return res ;
}



int main(){
    int test = 1 , tc = 0 ;
    while(test--){
        int n = Int ;
        ll res = 0 ;
        vi a(n + 1) ;
        for(int i = 1 ; i <= n ; ++i)a[i] = Int ;
        for(int i = 1 ; i <= n ; ++i){
        	int x = Int ;
        	ll k = query(a[i]) + x ;
        	upd(a[i], k, n) ;
        	if(res < k)res = k ;
        }
        cout << res << '\n' ;
    }
    return 0 ;
}

/*...Always look at the part - 04...*/
/*...............END................*/




Measured memory_bytes: 2560
using System;

namespace rensyuu1
{
    class Program
    {
        public static void Main()
        {
            while (true)
            {
                string[] num = Console.ReadLine().Trim().Split(' ');
                int h = int.Parse(num[0]);
                int w = int.Parse(num[1]);
                if (h == 0 && w == 0) break;
                string str1 = new string('#',w);
                string str2 = new string('.',w-2);
                Console.WriteLine(str1);
                for(int i =0; i < h-2; i++)
                {
                    Console.WriteLine("#{0}#",str2);
                }
                Console.WriteLine(str1);
                Console.WriteLine();

            }

        }
    }
}


Measured memory_bytes: 17932
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#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__) << "] "

const int MOD = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y, int md = MOD){x += y; if(x >= md) x -= md;}
void sub_self(int &x, int y, int md = MOD){x -= y; if(x < 0) x += md;}
void mul_self(int &x, int y, int md = MOD){x = x * 1LL * y % md;}
inline int mul(int x, int y, int md = MOD){return x * 1LL * y % md;}
inline int add(int x, int y, int md = MOD){x += y; if(x >= md) x -= md; return x;}
inline int sub(int x, int y, int md = MOD){x -= y; if(x < 0) x += md; return x;}

const int dx[] = {0, 0, -1, 1};
const int dy[] = {1, -1, 0, 0};
	
void pre(){
}	

void solve(){
	int h, w, srcx, srcy, desx, desy;
	cin >> h >> w >> srcx >> srcy >> desx >> desy;
	--srcx, --srcy, --desx, --desy;
	vector<vector<char>> vec(h, vector<char>(w));
	for(auto &rw : vec) for(auto &c : rw) cin >> c;

	auto ok = [&](int xx, int yy){
		return xx >= 0 && xx < h && yy >= 0 && yy < w && vec[xx][yy] != '#';
	};

	vector<vector<int>> dist(h, vector<int>(w, 1e9));
	dist[srcx][srcy] = 0;
	deque<array<int, 2>> q;
	q.push_front({srcx, srcy});

	while(!q.empty()){
		auto p = q.front();
		q.pop_front();
		for(int i = 0; i < 4; ++i){
			int xx = p[0] + dx[i];
			int yy = p[1] + dy[i];
			if(ok(xx, yy) && dist[xx][yy] > dist[p[0]][p[1]]){
				dist[xx][yy] = dist[p[0]][p[1]];
				q.push_front({xx, yy});
			}
		}
		for(int i = -2; i <= 2; ++i){
			for(int j = -2; j <= 2; ++j){
				int xx = p[0] + i;
				int yy = p[1] + j;
				if(ok(xx, yy) && dist[xx][yy] > dist[p[0]][p[1]] + 1){
					dist[xx][yy] = dist[p[0]][p[1]] + 1;
					q.push_back({xx, yy});
				}
			}
		}
	}

	int res = dist[desx][desy];
	if(res == (int)1e9) res = -1;
	cout << res << "\n";
	
	return;
}

int main(){

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

	// freopen("input.in", "r", stdin);
	// freopen("output.out", "w", stdout);

	int t;
	t = 1;
	// cin >> t;
	// pre();
	for(int i = 1; i <= t; ++i){
		// cout << "Case #" << i << ": ";
		solve();
		// cout << '\n';
		// cout << endl;
	}

	return 0;
}


Measured memory_bytes: 8624
a, b, c, X, Y = map(int, input().split())
if (2 * c - a -b ) <= 0:
    _z = min(X, Y)
    if X >= Y:
        _x = X - Y
        _y = 0
    else:
        _x = 0
        _y = Y - X
    D = a * _x + b * _y + 2 * c *_z
    E = 2*c * max(X, Y)
    print(min(D, E))
else:
    _z = 0
    _x = X
    _y = Y
    D = a * _x + b * _y + 2 * c *_z
    E = 2*c * max(X, Y)
    print(min(D, E))


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-------------------------------------------------


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

    int n, k;
	cin >> n >> k;
	cout << !!(n % k) << endl;

    return 0;
}




Measured memory_bytes: 896
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] aa = new int[n][m];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				aa[i][j] = sc.nextInt();
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				aa[i][j] = Math.abs(aa[i][j] - sc.nextInt());
		int d = (n + m - 1) * 80;
		boolean[][][] dp = new boolean[n][m][d + 1];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++) {
				int a = aa[i][j];
				if (i == 0 && j == 0) {
					dp[i][j][a] = true;
					continue;
				}
				if (i > 0)
					for (int b = 0; b <= d; b++)
						if (dp[i - 1][j][b]) {
							int c = a + b;
							if (c <= d)
								dp[i][j][c] = true;
							c = Math.abs(a - b);
							dp[i][j][c] = true;
						}
				if (j > 0)
					for (int b = 0; b <= d; b++)
						if (dp[i][j - 1][b]) {
							int c = a + b;
							if (c <= d)
								dp[i][j][c] = true;
							c = Math.abs(a - b);
							dp[i][j][c] = true;
						}
			}
		int c = 0;
		while (!dp[n - 1][m - 1][c])
			c++;
		println(c);
	}
}


Measured memory_bytes: 118944
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
#define MOD 1000000007
using namespace std;

ll fib(ll n)
{
    if(n==0) return 0;
    ll a=0,b=1,c,i;
    for(i=2;i<=n;i++)
    {
        c=a+b;
        a=b%MOD;
        b=c%MOD;
    }
    return b%MOD;
}

int main()
{
    ll a,b,i,j,n,t,c,m;
    string s="1";
    cin>>n>>m;
    ll arr[m];
    for(i=0;i<n;i++) s.pb('1');
    for(i=0;i<m;i++) 
    {
        cin>>arr[i];
        s[arr[i]]='0';
    }
    for(i=1;i<m;i++)
    {
        if(arr[i]-arr[i-1]==1)
        {
            cout<<"0";
            return 0;
        }
    }
    ll count=0;
    ll ans=1;
    for(i=0;i<=n;i++)
    {
        if(s[i]=='1') count++;
        else 
        {
            //cout<<fib(count)<<endl;
            ans*=fib(count);
            ans%=MOD;
            count=0;
        }
    }
    ans*=fib(count);
    ans%=MOD;
    cout<<ans;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll A, B;
    cin >> A >> B;

    if(B%A == 0){
        cout << A+B << endl;
    }
    else{
        cout << B-A << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    f = [0]*10
    M = 1000000
    for n in range(10,M+1):
        k = str(n)
        m = 1
        for i in range(1,len(k)):
            nm = int(k[:i])*int(k[i:])
            if m < nm:
                m = nm
        f.append(f[m]+1)
    q = I()
    for i in range(q):
        print(f[I()])
    return

#Solve
if __name__ == "__main__":
    solve()



Measured memory_bytes: 15920
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;

int main(){
  double pi=3.1415926535;
  double n;
  fix(12);
  cin>>n;
  n*=2*pi;
  co(n);
  return 0;
}


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

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

int main(){
    int n;
    cin>>n;
    int X[n], Y[n], H[n];
    rep(i,n) cin >> X[i] >> Y[i] >> H[i];
    rep(i,101) rep(j,101){
        int f = true;
        int h = 0;
        rep(k,n){
            if(H[k]!=0) 
                h = H[k] + abs(X[k] - i) + abs(Y[k] - j);
        }
        rep(k,n){
            if(max(h - abs(X[k]-i) - abs(Y[k] - j), 0) != H[k]) 
                f = false;
        }
        if(f)
            cout << i << " " << j << " " << h << endl;
    }
    return 0;
}

Measured memory_bytes: 256