akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

import static java.lang.System.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = ni();

        List<Integer> b = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            b.add(sc.nextInt());
        }

        List<Integer> seq = new ArrayList<>();
        boolean canPick = true;
        while (canPick) {
            canPick = false;
            for (int i = b.size() - 1; i >= 0; i--) {
                if (b.get(i) == i + 1) {
                    b.remove(i);
                    seq.add(i + 1);
                    canPick = true;
                    break;
                }
            }
        }

        if (b.isEmpty()) {
            Collections.reverse(seq);
            for (int s : seq) {
                out.println(s);
            }
        } else {
            out.println(-1);
        }
    }

    static int ni() {
        return sc.nextInt();
    }

    static long nl() {
        return sc.nextLong();
    }

    static String ns() {
        return sc.next();
    }

    static int[] niarr(int N) {
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }
        return a;
    }

    static long[] nlarr(int N) {
        long[] a = new long[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextLong();
        }
        return a;
    }
}

Measured memory_bytes: 25172
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define mt(a,b,c) make_tuple(a,b,c)
#define rank qwertyuio
#define next dfghjk
#define plus fsghsf
#define minus ytryr
#define pb push_back
using namespace std;
 
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
 
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;
#define ent '\n'


  

int main(){
    int n;
    cin>>n;
    int i,a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    ll r=-1,g=-1,b=-1;
    ll sum=1;
    int j;
    for(i=0;i<n;i++){
        if(r+1==a[i]&&g+1==a[i]&&b+1==a[i]){
            r++;
            sum=(sum*3)%MOD;
            
        }
        else if((r+1==a[i]&&g+1==a[i])){
            r++;
            sum=(sum*2)%MOD;
        }
        else if((r+1==a[i]&&b+1==a[i])){
            b++;
            
            sum=(sum*2)%MOD;
        }
        else if((b+1==a[i]&&g+1==a[i])){
            b++;
         
            sum=(sum*2)%MOD;
        }
        else if(r+1==a[i]){
            r++;
        }
        else if(g+1==a[i]){
            g++;
        }
        else if(b+1==a[i]){
            b++;
        }
        else{
            sum*=0;
        }
        
    }
    cout<<sum<<ent;

    return 0;
}


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

// Levenshtein Distance とは、挿入・削除・置換でS->Tに変換する最小回数

// dp[i][j]: S[0:i] -> T[0:j] に変換する最小回数

// 挿入
//  dp[i+1][j+1] = dp[i+1][j] + 1

// 削除
//  dp[i+1][j+1] = dp[i][j+1] + 1

// 置換
//   S[i] == T[j] ならば dp[i+1][j+1] = dp[i][j]
//   S[i] != T[j] ならば dp[i+1][j+1] = dp[i][j] + 1

int levenshtein_distance(string &S, string &T) {
    int s = S.size(), t = T.size();
    vector <vector<int>> dp(s + 1, vector<int>(t + 1, 1 << 30));
    for (int i = 0; i <= s; i++) dp[i][0] = i;
    for (int j = 0; j <= t; j++) dp[0][j] = j;
    for (int i = 0; i < s; i++) {
        for (int j = 0; j < t; j++) {
            if (S[i] == T[j]) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j]);
            else dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + 1);
            dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j + 1] + 1);
            dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i + 1][j] + 1);
        }
    }
    return dp[s][t];
};


// verified
//  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_E&lang=jp
void AOJ_DPL_1_E(){
    string s1, s2;
    cin >> s1 >> s2;
    cout << levenshtein_distance(s1, s2) << '\n';
}

int main() {
    AOJ_DPL_1_E();
    return 0;
}


Measured memory_bytes: 6808
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;
//abc172
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3608
while inp=gets
	inp=inp.chomp.split(" ")
	flag=false
while !flag
	inp.map!{|str|
		res=String.new;
		str.each_char{|c|
			if c=="z" then
				res<<"a"
			elsif !(c==".")
				res<<(c.succ)
			else
				res<<"."
			end
		}
		res
	}
	inp.each{|str|
		if (str=="this" || str=="that" || str=="the")
			flag=true;
		end
	}
end

puts inp.join(" ")

end

Measured memory_bytes: 6100
#include "bits/stdc++.h"

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int x, n;
    cin >> x >> n;

    set< int> st;
    for (int i = 0; i < n; i++) {
        int v;
        cin >> v;
        st.insert(v);
    }

    int diff = 50000;
    int res = 0;

    for (int i = 0; i <= 101; i++) {
        if (st.count(i)) continue;
        if (abs(i - x) < diff) {
            res = i;
            diff = abs(i - x);
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define INF 100000000000000000LL
using namespace std;

int main()
{
	int n, m, e=0, i0;
	int a[2000], b[2000];
	long long int c[2000], d[1000];
	long long int d1[1000];
	scanf("%d %d", &n, &m);
	for(int i=0; i<m; i++){
		scanf("%d %d %lld", &a[i], &b[i], &c[i]);
		a[i]--;
		b[i]--;
		if(b[i]==n-1){
			i0=i;
		}
	}
	for(int i=0; i<n; i++){
		if(i==0){
			d[0]=0;
		}else{
			d[i]=-INF;
		}
	}
	for(int i=0; i<=n; i++){
		for(int j=0; j<m; j++){
			if(d[b[j]]<d[a[j]]+c[j]){
				d[b[j]]=d[a[j]]+c[j];
			}
		}
	}
	for(int i=0; i<=n; i++){
	for(int j=0; j<m; j++){
		if(j==i0 && d[b[j]]<d[a[j]]+c[j]){
			e=1;
		}
		if(d[b[j]]<d[a[j]]+c[j]){
			d[b[j]]=d[a[j]]+c[j];
		}
	}
	}
	
	if(e==1){
		printf("%s\n", "inf");
	}else{
		printf("%lld\n", d[n-1]);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i, n) for( int i = 0; i < n; i++ )
typedef vector<int> vec;

int main(){
    int n;
    while( cin >> n, n ){
        vec s(n);
        double m = 0;
        rep(i, n){
            cin >> s[i];
            m += s[i];
        }
        m /= n;
        double a = 0;
        rep(i, n){
            a += (s[i]-m)*(s[i]-m)/n;
        }
        printf("%.5f\n",sqrt(a));
    }
}

Measured memory_bytes: 1224
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <queue>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;
typedef long long ll;
const ll INF = 1e12;


int main(){
        ll N, M, R;
        cin >> N >> M >> R;
        vector<ll> r(R);
        for(ll i=0; i<R; i++){
                cin >> r[i];
                r[i]--;
        }
        vector<vector<ll>> A(N, vector<ll>(N, INF));
        ll a, b, c;
        for(ll i=0; i<M; i++){
                cin >> a >> b >> c;
                A[a-1][b-1] = c;
                A[b-1][a-1] = c;
        }
        for(ll i=0; i<N; i++){
                A[i][i] = 0;
        }
        for(ll i=0; i<N; i++){
                for(ll k=0; k<N; k++){
                        for(ll j=0; j<N; j++){
                                A[k][j] = min(A[k][j], A[k][i] + A[i][j]);
                        }
                }
        }
        ll Count = INF;
        ll nowCount = 0;
        sort(r.begin(), r.end());
        do{
                for(int i=1; i<R; i++){
                        nowCount += A[r[i-1]][r[i]];
                }
                if(Count > nowCount) Count = nowCount;
                nowCount = 0;
        }while(next_permutation(r.begin(), r.end()));
        cout << Count;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define MAXN 100010
using namespace std;
typedef pair<int,int>pii;
int a,b,c;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>a>>b>>c;
    if(a==b && c!=a)cout<<"Yes\n";
    else if(b==c && a!=b)cout<<"Yes\n";
    else if(a==c && b!=a)cout<<"Yes\n";
    else cout<<"No\n";

}

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

def round_robin_scheduling(N, Q, A):
    t = 0
    while A:
        process = A.popleft()
        if process[1] <= Q:
            t += process[1]
            print(process[0],t) 
        else:
            t += Q
            A.append([process[0],process[1]-Q])

if __name__ == '__main__':
    N,Q = map(int,input().split())
    A = deque()
    for i in range(N):
        a = input()
        A.append([a.split()[0],int(a.split()[1])])

    round_robin_scheduling(N,Q,A) 

Measured memory_bytes: 16208
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int next_combination(int S){
    int x = S & -S, y = S + x;
    return (((S & ~y) / x) >> 1) | y;
}

int main(){
    int n;
    scanf("%d", &n);
    if(n == 1){
        printf("%d\n", 0);
        return 0;
    }
    int a[n], b[n];
    rep(i, n) scanf("%d", &a[i]);
    rep(i, n) scanf("%d", &b[i]);

    int ans=MAX;
    for(int k=n/2, S=(1<<k)-1; S<1<<n; S=next_combination(S)){
        deque<pii> even, odd;
        rep(i, n){
            int t=(i%2==(S>>i&1) ? a[i] : b[i]);
            if(S>>i&1) odd.emplace_back(t, i);
            else even.emplace_back(t, i);
        }
        sort(even.begin(), even.end());
        sort(odd.begin(), odd.end());
        vector<pii> p;
        rep(i, n){
            if(i%2==0){
                p.push_back(even.front());
                even.pop_front();
            }
            else{
                p.push_back(odd.front());
                odd.pop_front();
            }
        }
        bool flag=true;
        rep(i, n-1)if(p[i+1].fi<p[i].fi){
            flag=false;
            break;
        }
        if(flag){
            int cnt=0;
            rep(i, n)rep(j, i)if(p[j].se>p[i].se) ++cnt;
            chmin(ans, cnt);
        }
    }
    printf("%d\n", ans==MAX ? -1 : ans);
}

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

int main()
{
   int a,b;
   cin>>a>>b;
   int cur=0;
   if(b==1){ 
       cout<<0;
       return 0;
   } 
   for(int i=1; ; i++){ 
       cur+=a;
       if(cur>=b){ 
           cout<<i;
           return 0;
       } 
       else cur--;
   } 
   
   
   
   
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e9;
const long long LINF = 1LL << 50;
#define int long long



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string n; cin >> n;
	int c = n.at(0) - '0';
	int ans = c + 9 * (n.size() - 1);
	bool ok = true;
	rep(i, n.size()) {
		if (i == 0)continue;
		if (n.at(i) != '9') {
			ok = false; break;
		}
	}
	if (!ok)cout << ans - 1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#define int long long
using namespace std;

signed main() {
	int A,B,C,X,Y;
	cin >> A >> B >> C >> X >> Y;
	C = C * 2;
	int answer = 0;
	if(A + B >= C) {
		int cnt = min(X,Y);
		answer += cnt * C;
		X -= cnt;
		Y -= cnt;
		if(X == 0) {
			answer += min(Y * B,Y * C);
		}
		else {
			answer += min(X * A,X * C);
		}
	}
	else {
		answer = X * A + Y * B;
	}
	cout << answer << endl;
}

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

long long d[1<<20];
int main(){
	int n, w;
	cin >> n >> w;
	fill(d + 1, d + w + 1, - ( 1LL << 40 ) );
	
	for( int i = 0; i < n; i++ ){
		int ww , vv;
		cin >> ww >> vv;
		for(int j = w; j >= ww; j--){
			d[j] = max( d[j], d[j-ww] + vv );
		}
	}cout << *max_element( d + 1, d + w +1) << "\n";
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  std::string s; std::cin >> s;
  int l = (s.front()==s.back())? 3: 2;
  int t = (s.size()-l)%2;
  if(t==1) fin("First");
  fin("Second");
  return 0;
}

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

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<char> c(n);
    for (int i = 0; i < n; i++) cin >> c[i];

    int ans = 0;
    int r = n;
    for (int l = 0; l < r; l++) {
        if (c[l] == 'W') {
            while (l != r) {
                r--;
                if (c[r] == 'R') {
                    ans++;
                    c[l] = 'R';
                    c[r] = 'W';
                    break;
                }
            }
            if (c[l] == 'W' && l != r) {
                ans++;
                c[l] = 'R';
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define ll long long 
int main() {
int n,i,c=0,d=0;
cin>>n;
int a[n];
for(i=0;i<n;i++)
    cin>>a[i];
for(i=0;i<n;i++)
{
    if(a[i]%2==0)
    {
        d++;
        if((a[i]%3==0)||(a[i]%5==0))
        {
            c++;
        }
        else
        {
            cout<<"DENIED";
            break;
        }    
    }
}
if(c==d)
    cout<<"APPROVED";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
string str;
string f() {
	string ret;
	char c = str[0];
	int k = 1;
	for (int i = 1; i < str.size(); i++) {
		if (str[i] == c) k++;
		else {
			ret += to_string(k);
			ret += c;
			c = str[i];
			k = 1;
		}
	}
	ret += to_string(k);
	ret += c;
	return ret;
}
int main() {
	int n;
	while (cin >> n) {
		if (!n)return 0;
		cin >> str;
		for (int i = 0; i < n; i++)str = f();
		cout << str << endl;
	}
}

Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define MP make_pair
#define llu unsigned long long
#define U unsigned int
#define ff first
#define ss second
#define SIZE 100005
#define pie 3.14159265358979323
#define minuss 1e-6
#define pair pair<ll,ll>
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define BIG 1000000000
#define INF 1000000000000005
#define N 10000
vector<ll>vec;
map<string,ll> mps;
map<ll,string> mpss;
set<ll>s1;
set<string>s2;
map<string,ll>::iterator str;
set<ll>::iterator itr;
/*
std::cout << std::fixed;
std::cout << std::setprecision(1);
std::cout << VALUE NAME<<endl;
*/
ll tra[100006],tra1[100006];


int main()
{

    map<ll,ll>mp;
    map<ll,ll>::iterator it;
    string s;
    ll n,m;
    cin>>n>>m;


    if(m%2!=0)
        cout<<"No"<<endl;
    else
    {
        ll ans=m/4;
        ll ss=m/2;
        if((ans==n && m%4==0) || ss==n)
        {
            cout<<"Yes"<<endl;
        }
        else if(ss>n)
        {
            ll save=0,save1=0;
            ll lock=0;
           while(m>=4)
           {
               m-=4;
               save++;
               save1=m/2;
               if(save1+save==n)
               {
                   lock=1;
                   break;
               }
           }
           if(lock==1)
            cout<<"Yes"<<endl;
           else
             cout<<"No"<<endl;
        }
        else
            cout<<"No"<<endl;

    }
}



Measured memory_bytes: 3628
<?php
  list($n, $m) = explode(" ", trim(fgets(STDIN)));
  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));

  sort($a);
  $sa = [];
  for($i=1;$i<$m;$i++){
     $sa[] = $a[$i]-$a[$i-1];
  }

  rsort($sa);
  $ans = array_sum($sa);
  for($i=0;$i<$n-1 && $i<count($sa);$i++){
    $ans -= $sa[$i];
  }
  echo $ans;

Measured memory_bytes: 27832
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.Char
import Data.List


-- space delimited integers
getVals::IO [Int]
getVals = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

-- space delimited strings
getStrings::IO [String]
getStrings = (map BS.unpack . BS.words) <$> BS.getLine

distsolve::Int -> (Int,Int) ->Bool
distsolve lim (x,y) = (x^2 + y^2) <=  lim^2

main::IO()
main =do
    n:d:_<- getVals
    dat <-forM [1..n] (\_ -> do
        x:y:_<- getVals
        return (x,y))
    print $ length $ filter (distsolve d) dat


Measured memory_bytes: 28064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <queue>
#include <functional>
const int INF =1e5;
const int MOD = 1e9 + 7;
using namespace std;
typedef pair<int,int> P;
typedef long long lint;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fill(x,y) memset(x,y,sizeof(x))
#define all(x) (x).begin(),(x).end()
#define pb push_back

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int sum=0;
    int check[3]={0};
    for(int i=0;i<n;i++){
        if((a[i]%4)==0){
            a[i]=2;
            check[2]++;
        }else if((a[i]%2)==0){
            a[i]=1;
            check[1]++;
        }else{
            a[i]=0;
            check[0]++;
        }
        sum+=a[i];
    }
    sum*=2;
    int count=0;
    for(int i=0;i<2;i++){
        while(check[i]>0){
            check[i]--;
            sum=sum-i;
            count++;
            if(count>=2){
                break;
            } 
        }
    }
   if(sum>=(n-1)*2){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;

}


Measured memory_bytes: 640
#include <cstdio>

using namespace std;

#define rep(i,x) for(int i=0;i<(int)(x);++i)

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

char mp[20][22];
int H, W;

void dfs(int y, int x)
{
	if (y < 0 || y >= H || x < 0 || x >= W || mp[y][x] == '#' || mp[y][x] == ' ') return;

	mp[y][x] = ' ';

	rep(i, 4) dfs(y + dy[i], x + dx[i]);
}

int main()
{
	while (scanf("%d %d", &W, &H), H || W) {
		int sy, sx;

		rep(i, H) rep(j, W) {
			scanf("\n%c", &mp[i][j]);
			if (mp[i][j] == '@') sy = i, sx = j, mp[i][j] = '.';
		}

		dfs(sy, sx);

		int cnt = 0;

		rep(i, H) rep(j, W) if (mp[i][j] == ' ') cnt++;

		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 1032
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
// 10:40-
const int MAX_N=2e5+1;
int N;
LL A[MAX_N];
void solve() {
  LL res=0;
  int r=0,cur=0;
  REP(l,N) {
    r=max(r,l);
    while(r<N&&(cur&A[r])==0) {
      cur|=A[r];
      ++r;
    }
    res+=r-l;
//    dump3(l,r,res);
    cur^=A[l];
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N;
  REP(i,N) cin>>A[i];
  solve();
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int max = 0;
		boolean can = false;
		for (int i = 0; i < n; i++) {
			int d = sc.nextInt();
			int e = sc.nextInt();
			if (d == e) {
				max++;
			} else {
				max = 0;
			}
			if (max == 3) can = true;
		}

		if (can) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();

	}
}


Measured memory_bytes: 35944
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main()
{
    int N, K, S, T;
    cin>>N>>K>>S>>T;
    vector<int> A(N);
    for (int &a: A)
        cin>>a;

    if ((S&T)!=S)
    {
        cout<<0<<endl;
        return 0;
    }

    int B = 0;
    for (int b=0; b<18; b++)
        if ((S>>b&1)==0 && (T>>b&1)==1)
            B++;
    
    vector<int> A_;
    A_.swap(A);
    for (int a: A_)
        if ((a&S)==S && (a|T)==T)
        {
            int t = 0;
            for (int b=0; b<18; b++)
                if ((S>>b&1)==0 && (T>>b&1)==1)
                    t = t<<1|a>>b&1;
            A.push_back(t);
        }
    N = (int)A.size();

    vector<vector<long long>> C;
    for (int i=0; i<=N; i++)
    {
        C.push_back(vector<long long>(i+1));
        C[i][0] = C[i][i] = 1;
        for (int j=1; j<i; j++)
            C[i][j] = C[i-1][j-1]+C[i-1][j];
    }

    long long ans = 0;
    map<int, int> M;
    for (int b=0; b<1<<B; b++)
    {
        M.clear();
        for (int a: A)
            M[a&b]++;
        long long a = 0;
        for (auto m: M)
            for (int k=1; k<=K; k++)
                if (m.second>=k)
                    a += C[m.second][k];
        int c = 0;
        for (int i=0; i<B; i++)
            c += b>>i&1;
        ans += c%2==0 ? a : -a;
    }
    cout<<ans<<endl;
}


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

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

  // vector<P> f;
  // for(ll i=2;i*i<=x;++i){
  //   int cnt = 0;
  //   while(x%i == 0){
  //     x /= i;
  //     ++cnt;
  //   }
  //   if(cnt==0) continue;
  //   f.push_back({i, cnt});
  // }
  // if(x != 1) f.push_back({x, 1});

  for(ll i=-1000;i<=1000;++i){
    ll a = 1;
    rep(j, 5) a *= i;
    ll res = a - x;
    for(ll j=-1000;j<=1000;++j){
      ll b = 1;
      rep(k, 5) b *= j;
      if(b == res) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3596
N, Q=map(int, input().split())
S = input()
t = [0]*(N + 1)
for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1]-t[l-1])


Measured memory_bytes: 9540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define isSquare(x) (sqrt(x)*sqrt(x) == x)
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(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template <typename T> void Exit(T first){cout << first << endl;exit(0); };

int main(){
    iosetup;
    ll N, A, B; cin >> N >> A >> B;
    ll ans = 0;
    ans += A * (N / (A + B));
    N %= A + B;
    if(N >= A)ans += A;
    else ans += N;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,k;
    std::cin >> n >>k;
    int ans=0;
    for (int i = 0; i < n; i++) {
        int tmp;
        std::cin >> tmp;
        ans+=min(tmp-0,k-tmp)*2;
    }
    std::cout << ans << std::endl;
}


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

#define INF 1 << 30
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

ll hp[100000];
ll n,a,b;


bool check(ll m){
  ll cnt = 0;
  REP(i,n){
    ll rest = hp[i] - b*m;
    if(rest<=0) continue;
    cnt += (rest-1)/(a-b)+1;
  }
  return cnt <= m;
}

int main(){
  cin >> n >> a>> b;
  REP(i,n){
    cin >> hp[i];
  }
  ll ng = 0;
  ll ok = 1e10;
  ll m;
  while(abs(ng-ok)>1){
    m = (ng+ok)/2;
    if(check(m)){
      ok = m;
    }else{
      ng = m;
    }
  }
  cout << ok <<endl;
}


/*
void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int nibutan(ll l,ll r,bool(*fn)(ll)){
  ll m = (r+l)/2;
  while(r-l>1){
    if(fn(m)){
      r = m;
    }else{
      l = m;
    }
    m =(r+l)/2;
  }
  return r;
}

vector<int> hp;
int n,a,b;

bool enough(ll t){
  ll cnt = 0;
  REP(i,hp.size()){
    cnt += (hp[i]-b*t-1)/(a-b)+1;
  }
  return cnt<=t;
}


int main(){
  scanf("%d %d %d",&n,&a,&b);
  REP(i,n){
    int a;
    scanf("%d",&a);
    hp.push_back(a);
  }
  printf("%lld\n",nibutan(0,LLONG_MAX/1000,enough));
}

int n,a,b;
vector<int> hp;
int cnt = 0;

int main(){
  scanf("%d %d %d",&n,&a,&b);
  REP(i,n){
    int s;
    scanf("%d",&s);
    hp.push_back(s);
  }
  sort(hp.begin(),hp.end(),greater<int>());
  int mi = hp[n-1];
  REP(i,n){
    hp[i]-=mi;
  }
  int c = a-b;
  while(hp[0]>0){
    int d = hp[0] - hp[1];
    int n_cnt = (d-1)/c+1;
    int tmp = hp[0] - n_cnt*d;
    int tmp_mi = mi - n_cnt*b;
    if(tmp+tmp_mi<=0){
      cnt+=(hp[0]+mi-1)/a+1;
      break;
    }
    cnt += (d-1)/c+1;
    hp.erase(hp.begin());
    hp.insert(upper_bound(hp.begin(),hp.end(),tmp),tmp);
  }
  mi -= b*cnt;
  if(mi<=0){
    printf("%d\n",cnt);
    return 0;
  }
  cnt += (mi-1)/b + 1;
  printf("%d\n",cnt);
}
*/


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <stdlib.h>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	// your code goes here
	
	std::string buf, S_str, T_str;
	std::vector<int> S,T;
	std::cin >> buf;
	int n = atoi(buf.c_str());
	for (int i=0; i<n; i++){
		std::cin >> buf;
		S.push_back(atoi(buf.c_str()));
	}
	std::cin >> buf;
	int m = atoi(buf.c_str());
	for (int i=0; i<m; i++){
		std::cin >> buf;
		T.push_back(atoi(buf.c_str()));
	}
	
	int count = 0;
	int preNum = -1;
	for (std::vector<int>::iterator it = S.begin(); it != S.end(); it++){
		//std::cout << *it << std::endl;
		if (preNum == *it) continue;
		preNum = *it;
		std::vector<int>::iterator e = find(T.begin(), T.end(), *it);
		if (e!=T.end()){
			count ++;
			continue;
		}
	}
	
	std::cout << count << std::endl;
	
	return 0;
}

Measured memory_bytes: 1816
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main(){
	ll N,K;
	cin >> N >> K;
	cout << min(N%K,K-N%K) << endl;
	
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int X,Y,Z,temp;
    scanf("%d %d %d",&X,&Y,&Z);
    if((X>=1)&&(X<=100)&&(Y>=1)&&(Y<=100)&&(Z>=1)&&(Z<=100))
    {
        temp=X;
        X=Y;
        Y=temp;
        temp=X;
        X=Z;
        Z=temp;
        printf("%d %d %d",X,Y,Z);
    }

}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 10000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n;
	cin>>n;
	vector<int> gd;
	for(int i=0;i<=5555;i++){
		int cur = 10 * i + 3;
		bool fl = true;
		for(int j=2; j*j <= cur ; j++){
			if( cur % j == 0){
				fl = false;
			}
		}
		if( fl == true ) gd.pb(cur);
	}
	for(int i=1;i<=n;i++){
		cout<<gd[i]<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#define INF 114514810
#define FOR(i, r, n) for(int i=(r); i<(n); i++) 
#define REP(i, n) FOR(i, (0), n)
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

using namespace std;

int n=0, a, b;

int main(){
	while (cin >> a >> b){
		a += b;
		while (a > 0)
		{
			n++;
			a /= 10;
		}
		cout << n << endl;
		n = 0;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    //入力
    ll N;
    cin >> N;
    ll h[1000000];
    for (ll i = 0;i<N;i++) cin >> h[i];

    //初期化
    ll dp[1000000];
    for (ll i = 0;i<1000000;i++) dp[i] = INF;

    //初期設定
    dp[0] = 0;
    
    //遷移
    for (ll i = 0;i<N;i++) {
        chmin(dp[i+1],dp[i] + abs(h[i] - h[i+1]));
        chmin(dp[i+2],dp[i] + abs(h[i] - h[i+2]));
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 11776
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;

const ll mod197 = 1000000007LL;

const double PI11 = 3.14159265358979;
const double EPS = 1e-10;

const ll INF = 1000000000000000;

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

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

ll powMod(ll x, ll k, ll m) {
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k / 2, m);
	else            return x*powMod(x, k - 1, m) % m;
}

ll combi(ll n, ll k) {

	if (n < k) {
		swap(n, k);
	}

	ll a = 1, b = 1;

	for (ll i = n; i > n - k; i--) {
		a *= i;
		a %= mod197;
	}
	for (ll i = k; i > 0; i--) {
		b *= i;
		b %= mod197;
	}


	//cout << endl << a << " " << b << endl;

	//(n/a)%p = (n*a^(p-2))%p
	return (a*powMod(b, mod197 - 2, mod197)) % mod197;
}

int n, m, p;

int in_length(int, int);

//外回りの距離
int out_length(int a, int b) {

	if (a > b) {
		return n - in_length(a, b);
	}
	else {
		return b - a;
	}

}

//内回りの距離
int in_length(int a, int b) {

	if (b > a) {
		return n - out_length(a, b);
	}
	else {
		return a - b;
	}

}

int imos_big[4010][4010] = {};
int imos[2010][2010] = {};

int main(void) {

	int n, k;
	cin >> n >> k;

	for (int i = 0; i < n; i++) {
		int x, y;
		char c;
		cin >> x >> y >> c;

		if (c == 'B') {
			y += k;
		}

		x %= 2 * k;
		y %= 2 * k;

		imos_big[x][y] ++;
		imos_big[x][y + k] --;
		imos_big[x + k][y] --;
		imos_big[x + k][y + k] ++;

		imos_big[x + k][y + k] ++;
		imos_big[x + k][y + 2 * k] --;
		imos_big[x + 2 * k][y + k] --;
		imos_big[x + 2 * k][y + 2 * k] ++;
/*

		for (int i = 0; i < 4 * k; i++) {
			for (int j = 0; j < 4 * k; j++) {
				cerr << setw(3) << imos_big[i][j] << " ";
			}
			cerr << endl;
		}
		cerr << endl;*/

	}
/*
	for (int i = 0; i < 4 * k; i++) {
		for (int j = 0; j < 4 * k; j++) {
			cerr << setw(3) << imos_big[i][j] << " ";
		}
		cerr << endl;
	}
	cerr << endl;*/

	for (int i = 0; i <= 4 * k; i++) {
		for (int j = 0; j <= 4 * k; j++) {
			imos_big[i][j + 1] += imos_big[i][j];
		}
	}
	for (int i = 0; i <= 4 * k; i++) {
		for (int j = 0; j <= 4 * k; j++) {
			imos_big[i + 1][j] += imos_big[i][j];
		}
	}
/*
	for (int i = 0; i < 4 * k; i++) {
		for (int j = 0; j < 4 * k; j++) {
			cerr << imos_big[i][j] << " ";
		}
		cerr << endl;
	}
	cerr << endl;*/

	for (int i = 0; i < 4010; i++) {
		for (int j = 0; j < 4010; j++) {
			imos[i % (2 * k)][j % (2 * k)] += imos_big[i][j];
		}
	}
/*
	for (int i = 0; i < 2 * k; i++) {
		for (int j = 0; j < 2 * k; j++) {
			cerr << imos[i][j] << " ";
		}
		cerr << endl;
	}
	cerr << endl;
*/
	int answer = 0;
	for (int i = 0; i < 2 * k; i++) {
		for (int j = 0; j < 2 * k; j++) {
			answer = max(answer, imos[i][j]);
		}
	}

	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 78720
use strict;
use warnings;
package ModInt;
use constant MOD=>10**9+7;
use overload
	"+"=>\&modadd,
	"-"=>\&modsub,
	"*"=>\&modmul,
	"/"=>\&moddiv,
	"**"=>\&modpow,
	"=="=>\&modeq,
	"!="=>\&modne,
	"0+"=>sub{return${$_[0]}},
;
sub new{
	my$class=shift;
	return bless\($_[0]%MOD),$class;
}
sub modadd{
	my($x,$y)=@_;
	return bless\(($$x+(ref$y?$$y:$y))%MOD),ref$x;
}
sub modsub{
	my($x,$y)=@_;
	my$v=$$x;
	$v-=ref$y?$$y:$y;
	$v=-$v if$_[2];
	$v%=MOD;
	return bless\$v,ref$x;
}
sub modmul{
	my($x,$y)=@_;
	return bless\((ref$y?$$y:$y%MOD)*$$x%MOD),ref$x;
}
sub moddiv{
	my($x,$y)=@_;
	my$v=$$x;
	my$w=ref$y?$$y:$y%MOD;
	$v=$_[2]?$w*modinv($v)%MOD:$v*modinv($w)%MOD;
	return bless\$v,ref$x;
}
sub modpow{
	my($x,$y)=@_;
	my$r=1;
	my$v=$$x;
	my$w=$y;
	($v,$w)=($w,$v)if$_[2];
	$v%=MOD;
	while($w>0){
		$r=$r*$v%MOD if$w&1;
		$v=$v*$v%MOD;
		$w>>=1;
	}
	return bless\$r,ref$x;
}
sub modeq{
	my($x,$y)=@_;
	my$v=$$x;
	my$w=ref$y?$$y:$y%MOD;
	return$v==$w;
}
sub modne{
	my($x,$y)=@_;
	my$v=$$x;
	my$w=ref$y?$$y:$y%MOD;
	return$v!=$w;
}
sub modinv{
	my$r=1;
	my$a=shift;
	my$n=MOD-2;
	while($n>0){
		$r=$r*$a%MOD if$n&1;
		$a=$a*$a%MOD;
		$n>>=1;
	}
	return$r;
}
package main;
<>;
my$ans=ModInt->new(0);
my$cumsum=ModInt->new(0);
for(split$",<>){
	$ans+=$cumsum*$_;
	$cumsum+=$_;
}
print$ans,$/;


Measured memory_bytes: 24724
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>


typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) 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);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	int r, d, x;
	cin >> r >> d >> x;
	rep(i, 10) {
		int a;
		a = x;
		x = r * a - d;
		cout << x << endl;
	}
	return 0;
}










Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, k;

signed main() {
	cin >> n >> k;
	cout << (n%k>0);
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod.m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}


int main(){
    int a;
    cin >> a;
    if(a) cout << 0 << endl;
    else cout << 1 << endl;
}



Measured memory_bytes: 3632