akhauriyash/Code-Regression huggingface dataset:
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int cnt[SIZE],d[SIZE];
int main(){
    MOD=998244353;
    int N; R(N);
    FOR(i,1,N)R(d[i]);
    LL an=1;
    if(d[1])an=0;
    FOR(i,1,N){
        cnt[d[i]]++;
    }
    if(cnt[0]>1)an=0;
    FOR(i,2,N-1){
        REP(j,cnt[i]){
            an=an*cnt[i-1]%MOD;
        }
    }
    W(an);
    return 0;
}


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

int main() {
	int n, m;
	while(cin >> n >> m, n){
		vector<ll> a(n);
		for(int i = 0; i < n; ++i) cin >> a[i];
		
		ll ans = -1;
		for(int i = 0; i < n; ++i){
			for(int j = i + 1; j < n; ++j){
				ll sum = a[i] + a[j];
				if(sum <= m) ans = max(ans, sum);
			}
		}
		
		if(ans != -1) cout << ans << endl;
		else cout << "NONE" << endl;
	}
	return 0;
}


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int A = scan.nextInt();
			int B = scan.nextInt();
			int C = scan.nextInt();
			int D = scan.nextInt();
			
			
			while(true) {
				C-=B;
				if(C<=0) {
					System.out.println("Yes");
					break;
				}
				A-=D;
				if(A<=0) {
					System.out.println("No");
					break;
				}
				
			}
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 35764
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int n, t[26][1000006];

void inc(int c, int x, int v) {
    for (x += n; x; x >>= 1) t[c][x] += v;
}

int que(int c, int l, int r) {
    int z = 0;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
        if (l & 1) z += t[c][l++];
        if (r & 1) z += t[c][--r];
    }
    return z;
}

int main() {
    ios::sync_with_stdio(false);
    int q, u, v, w;
    string s;
    char d;
    cin >> n >> s >> q;
    for (int i = 0; i < n; i++) inc(s[i] - 'a', i, 1);
    while (q--) {
        cin >> u;
        if (u == 1) {
            cin >> v >> d;
            inc(s[v - 1] - 'a', v - 1, -1);
            s[v - 1] = d;
            inc(s[v - 1] - 'a', v - 1, 1);
        } else {
            cin >> v >> w;
            int z = 0;
            for (int i = 0; i < 26; i++) if (que(i, v - 1, w) != 0) z++;
            cout << z << '\n';
        }
    }
}


Measured memory_bytes: 105448
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <deque>
#include <algorithm>
using namespace std;

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

    int N, K;
    string S;

    cin >> N >> K >> S;
    deque<int> zero_list;

    bool is_zero_continuous = false;
    int num_one_and_zero = 0; // sum of zeros and ones just before zeros
    int tmp_ans = 0;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (S[i] == '0') {
            if (!is_zero_continuous && zero_list.size() == K) {
                if (tmp_ans > ans) ans = tmp_ans;
                tmp_ans -= zero_list.front();
                zero_list.pop_front();
            }
            is_zero_continuous = true;
            ++num_one_and_zero;
            ++tmp_ans;
        } else {
            if (is_zero_continuous) {
                is_zero_continuous = false;
                zero_list.push_back(num_one_and_zero);
                num_one_and_zero = 0;
            }
            ++num_one_and_zero;
            ++tmp_ans;
        }
    }

    if (tmp_ans > ans) ans = tmp_ans;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Binary Search
n ????????´??°???????????°??? S ??¨???q ????????°????????´??°???????????°??? T ??????????????????
T ?????????????????´??°????????§ S ?????????????????????????????° C ???????????????????????°????????????????????????????????????
"""
def bsrch(l, s, e, a):
    """ ????????????????????? """
    c = int((e - s) / 2) + s if e - s > 1 else s
    x = l[c]
#    print(l[s:e])
#    print("s:{} e:{} c:{} a:{}".format(s,e,c,a))
    if x == a:
        return True
    else:
        if c > s:
            if x < a:
                return bsrch(l, c, e, a)
            elif x > a:
                return bsrch(l, s, c, a)
    return False

def main():
    """ ????????? """
    n = int(input())
    S = list(map(int,input().split()))
    q = int(input())
    T = list(map(int,input().split()))

    cnt = {}
    for j in range(q):
       x = bsrch(S, 0, n, T[j])
       if x == True:
           cnt[T[j]] = 1
    print(len(cnt))

if __name__ == '__main__':
    main()

Measured memory_bytes: 18720
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    string s;
    int ans = 0,cnt = 0;
    cin >> s;
    rep(i, s.size()){
        if (s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G') {
            ++cnt;
        }else{
            if(ans < cnt)ans = cnt;
            cnt = 0;
        }
    }
  if(ans < cnt)ans = cnt;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = 1e-9;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline ll gcd(ll a, ll b) {
	while (b) {
		ll c = a;
		a = b; b = c % b;
	}
	return a;
}
inline ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
bool isprime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
ll mypow(ll a, ll b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	int memo = mypow(a, b >> 1);
	return memo * memo;
}
int n, a, b;
int bit[1 << 17];
void func(int m, int e, int c, int d, int l, int r) {
	bit[l] = c;
	bit[r - 1] = d;
	if (m == 1)return;
	int dbit;
	rep(i, n) {
		if ((e & (1 << i)) && (c & (1 << i)) != (d & (1 << i))) {
			dbit = i;
			break;
		}
	}
	int md = c;
	rep(i, n) {
		if ((e & (1 << i)) && i != dbit) {
			md ^= (1 << i);
			break;
		}
	}
	func(m - 1, e - (1 << dbit), c, md, l, (l + r) / 2);
	func(m - 1, e - (1 << dbit), md, d, (l + r) / 2, r);
	for (int i = l; i < (l + r) / 2; i++) {
		if (bit[i] & (1 << dbit))bit[i] -= 1 << dbit;
		bit[i] += c & (1 << dbit);
	}
	for (int i = (l + r) / 2; i < r; i++) {
		if (bit[i] & (1 << dbit))bit[i] -= 1 << dbit;
		bit[i] += d & (1 << dbit);
	}
}
signed main() {
	cin >> n >> a >> b;
	int cnt = 0;
	if ((bitset<17>(a).count() & 1) == (bitset<17>(b).count() & 1)) {
		puts("NO");
		return 0;
	}
	puts("YES");
	func(n, (1 << n) - 1, a, b, 0, (1 << n));
	rep(i, (1 << n) - 1)cout << bit[i] << " ";
	cout << bit[(1 << n) - 1] << endl;
	return 0;
}

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

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

  vector<int64_t> C(N),F(N);
  vector<int64_t> S(N);

  for(int i=0;i<N-1;++i){
    cin>>C.at(i)>>S.at(i)>>F.at(i);
  }

  for(int i=0;i<N;++i){
    int64_t sum=0;
    int j=i;
    while(j<N-1){
      if(sum<=S.at(j)){
        sum=S.at(j)+C.at(j);
        ++j;
      }
      else{
        if(sum%F.at(j)==0){
          sum+=C.at(j);
          ++j;
        }
        else{
          sum+=(F.at(j)-(sum%F.at(j)))+C.at(j);
          ++j;
        }
      }
    }
    cout<<sum<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int a,b;
	cin>>a>>b;
	cout<<(a-1)*(b-1)<<endl;
}









Measured memory_bytes: 256
S    = gets.chomp + "x"
X, Y = gets.split.map(&:to_i)

@dst = []
fwd  = 0
S.each_char do |c|
    if c=="F"
      fwd+=1
    else #"T" or "x"
      @dst.push(fwd)
      fwd=0
    end
end

def check(idx, expt)
    loc = {0=>true}
    while @dst[idx]
      tmp = {}
      loc.each do |k, v|
        tmp[k+@dst[idx]] = true
        tmp[k-@dst[idx]] = true if idx > 0
      end
      loc = tmp 
      idx+=2
    end
    loc.has_key?(expt) 
end

puts check(0, X) && check(1, Y) ? "Yes" : "No"


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

ll N, C;
ll dp[575][100010];
ll w[100010];
ll v[100010];

ll solve(ll i, ll c){
    //条件
    if(dp[i][c] != -1) return dp[i][c];
    if(i == 0) return dp[i][c] = 0;

    // c-w_i >= 0 で選ぶ場合
    if((c-w[i]) >= 0) return dp[i][c] =  max(solve(i-1,c-w[i])+v[i], solve(i-1,c));   
    else return dp[i][c] = solve(i-1,c);
}

int main(void){
    cin >> N >> C;
    for(int j=1; j<=N; j++) cin >> w[j] >> v[j];
	memset(dp , -1 , sizeof(dp));
    solve(N, C);
    cout << dp[N][C] << endl;
}

Measured memory_bytes: 449536
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define MN (1<<18)
int n,a[MN+5],b[MN+5][2],c[MN+5][2],ans=0;
int cnt=0;
void xxx(int to,int frm,int p){
	if(c[to][0]==c[frm][p]||c[to][1]==c[frm][p]) return;
	if(b[to][0]<b[frm][p]){
		b[to][1]=b[to][0];  c[to][1]=c[to][0];
		b[to][0]=b[frm][p]; c[to][0]=c[frm][p];
	}else if(b[to][1]<b[frm][p]){
		b[to][1]=b[frm][p]; c[to][1]=c[frm][p];
	}
}
void work(int x){
	for(int j=1;j<(1<<18);j<<=1)
		if(x&j){
			xxx(x,x^j,0);
			xxx(x,x^j,1);
		}
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<(1<<n);i++)
		scanf("%d",&a[i]);
	memset(c,0xff,sizeof(c));
	b[0][0]=a[0]; c[0][0]=0;
	b[0][1]=-1;   c[0][1]=-1;
	for(int i=1;i<(1<<n);i++){
		b[i][0]=a[i]; c[i][0]=i;
		work(i);
		ans=std::max(ans,b[i][0]+b[i][1]);
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 8192
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
using ll = long long;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//動的計画法で役に立つ関数
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; }

//最大公約数と最小公倍数
ll gcd(ll a, ll 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;
}

vector<vector<long long> > comb(int n) {
  vector<vector<long long> > v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main() 
{
    
    ll X,Y;cin>>X>>Y;
    cout<<(ll)floor((long double)(log2((long double)(Y/X))))+1LL<<endl;
  
    return 0;
}



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

int main() {
  int A[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << A[K - 1] << endl;
  
  return 0;
}


Measured memory_bytes: 256
/*AOJ-ITP-4-2*/

/* ?????? r ???????????¢?????¨?????¨?????????????±???????????????°????????????????????????????????? */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
 
public class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
 
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String st[] = br.readLine().split(" ");
        double r = Double.parseDouble(st[0]);
        if(!(0 < r && 10000 > r)){System.exit(1);}
        
        double circumference = Math.PI  * 2 * r;
        double circleArea = r * r * Math.PI;
        
        BigDecimal x = new BigDecimal(circumference);
        BigDecimal y = new BigDecimal(circleArea);
        //?°???°???5????????§?????????
        x = x.setScale(5, BigDecimal.ROUND_HALF_UP);
        y = y.setScale(5, BigDecimal.ROUND_HALF_UP);
        System.out.printf("%.5f %.5f",y,x);
        System.out.println();
    }
}

Measured memory_bytes: 24872
#import<iostream>
#import<algorithm>
long long i,j,n,x,m=1000000007,s[200],d[1<<17];
main(){std::cin>>n>>x;for(i=0;i<n;++i)std::cin>>s[i];std::sort(s,s+n);for(i=-1;i++<x;)d[i]=i;for(i=0;i<n;++i)for(j=x;j;--j)d[j]=(d[j]*i+d[j%s[i]])%m;std::cout<<d[x];}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int compare(const void*a,const void *b) {
	return *(int*)a - *(int*)b;
}

int main() {
	int n, t, x, ans = 10000, r[200010] = {0};
	char s[1000],T[1000];
	scanf("%d", &x);
	//scanf("%s", T);
	//for (int i = 0; i + strlen(T) <= strlen(s); i++) {
		//int re = 0;
		///for (int j = 0; j < strlen(T); j++) if (s[i + j] != T[j])re++;
		//if (re < ans)ans = re;
	//}
	if (x == 1)printf("0");
	else printf("1");
	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    string S; cin >> S;
    int N = S.size();
    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }

    int L = 0, R = N-1;
    int cnt = 0;
    while (L < R) {
        if (S[L] == S[R]) {
            L++, R--;
            continue;
        }
        cnt++;
        if (S[L] == 'x') {
            L++;
            continue;
        }
        if (S[R] == 'x') {
            R--;
            continue;
        }
        cout << -1 << endl;
        return 0;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3752
n = int(input())
p = list(map(int,input().split()))
l =[]
for i in range(1,n-1):
  if p[i] != max(p[i-1],p[i],p[i+1]) and p[i] != min(p[i-1],p[i],p[i+1]):
    l.append(p[i])
print(len(l))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a,b=0;
  cin>>a;
  for(int i=1;i<1000000&&a>b;i++){
    if(prime(i)){
      if(i%5==1){
      b++;
      cout<<i;
      if(a==b)
        cout<<endl;
      else
        cout<<' ';
    }
  }
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b,m;
    while(1){
        cin >> a >> b;
        if((a == 0)&&(b == 0)){
            break;
        }
        else{
            if(a > b){
                m = a;
                a = b;
                b = m;
            }
            cout << a << " " << b <<endl;
        }
    }
}


Measured memory_bytes: 3008
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <stack>
#include <queue>
#include <math.h>
#include <bitset>

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

#define rep(i,s,n)for(int i = s;i<n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=s;i--)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define repe_r(i,s,n)for(int i = n;i>=s;i--)

ll s[11][11];
ll p[11];
int main() {
	ll n, m; cin >> n >> m;
	repe(i, 1, m) {
		ll k; cin >> k;
		repe(j, 1, k) {
			cin >> s[i][j];
		}
	}

	repe(i, 1, m) {
		cin >> p[i];
	}

	ll ans = 0;
	for (int i = 0; i < 1 << n; i++) {
		bool on = true;
		repe(j, 1, m) {
			int cnt = 0;
			rep(b, 1, 11) {
				if (s[j][b]) {
					ll sw = s[j][b];
					if (i & (1 << (sw-1))) {
						cnt++;
					}
				}
			}
			on &= (p[j] == (cnt % 2));
		}
		if (on) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define TTF template<typename T, typename F>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline void Out(T&x){cout<<x;}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline int ubnd(T&v,ET(T)&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T)&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF inline void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF inline void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
#undef TT
#undef TTF
#undef ET

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}

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

struct Edge {
  int f, t, c;
  Edge(int f, int t, int c) : f(f), t(t), c(c) {}
  bool operator<(const Edge& e) const { return c != e.c ? c > e.c : (f != e.f ? f < e.f : t < e.t); }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int dijkstra(const Graph& g, int s, int t){
  int vis[128];
  fill(begin(vis), end(vis), 0);
  priority_queue<Edge> pq;
  for (pq.push(Edge(-2, s, 0)); !pq.empty(); pq.pop()){
    Edge e = pq.top();
    if (vis[e.t]++) continue;
    if (e.t == t) return e.c;
    for (const auto& ee : g[e.t]){
      pq.push(Edge(e.f, ee.t, e.c + ee.c));
    }
  }
  return -1;
}

int main()
{
  int n, k;
  while (cin >> n >> k, n || k){
  Graph g(n + 1);
  for (int i = 0; i < k; i++){
    int t = in();
    if (t){
      int a, b, c;
      cin >> a >> b >> c;
      g[a].push_back(Edge(a, b, c));
      g[b].push_back(Edge(b, a, c));
    }
    else {
      int a, b;
      cin >> a >> b;
      cout << dijkstra(g, a, b) << endl;
    }
  }
  }
  return (0);
}

// priority_queue queue deque front stringstream max_element min_element insert count make_tuple

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

int main() {
    int k,x;
    cin>>k>>x;
    int l=max(-1000000,x-k+1);
    int r=min(1000000,x+k-1);
    for (int i=l;i<=r;i++) {
        cout<<i<<' ';
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){ 
    int N, D, X;
    cin >> N >> D >> X;
    int a[N];
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j*a[i]+1 <= D; j++){
            X++;
        }
    }
    cout << X << endl;
}

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

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

int main()
{   
    long long n;
    cin >> n;

    vector<long long> trans(5);
    REP(i, 5)   cin >> trans[i];

    long long lim = *min_element(trans.begin(), trans.end());
    
    if (n%lim == 0)     cout << n/lim + 4 << endl;
    else                cout << n/lim + 5 << endl;
}

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a <= 2 * b)
    {
        cout << 0 << endl;
        return 0;
    }
    cout << a - 2 * b << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int H,W,i,k;
  while(true)
  {
    cin>>H>>W;
      if(H==0 && W==0){break;}
    for(i=0;i<H;i++)
    {
      for(k=0;k<W;k++)
      {
        if(i%2==1)
        {
        if(k%2==1 )
        {
        cout<<"#";
      }else{
        cout<<".";
      }
    }else{
      if(k%2==0 )
      {
      cout<<"#";
    }else{
      cout<<".";
    }
    }
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3100
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;

    char s[n];
    for(int i=0;i<n;i++)cin >> s[i];

    for(int i=0;i<n;i++){
        if(s[i]=='Y'){
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
}


Measured memory_bytes: 256
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let _ = s.next();
	let mut min = std::i32::MAX;
	let mut maxp = 0;
	let mut ans = 0;
	for a in s.take(n).map(|a| a.parse::<i32>().unwrap()) {
		if a < min {
			min = a;
		} else {
			let p = a - min;
			if p > maxp {
				maxp = p;
				ans = 1;
			} else if p == maxp {
				ans += 1;
			}
		}
	}
	println!("{}", ans);
}


Measured memory_bytes: 2920
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) {rep(i,x.size()) cout << x[i] << " "; cout << endl;}
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+7;
const ll inf_l = 1e18;
const int MAX = 1e7+10;

int main() {
    int n; cin >> n;
    set<int> od;
    vint a(n);
    rep(i,n) {
        int x; cin >> x;
        if (i&1) od.insert(x);
        a[i] = x;
    }
    sort(all(a));
    int ans = 0;
    rep(i,n) {
        if (i&1 && !od.count(a[i])) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5972
#include <cstdio>
#include <iostream>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main(void)
{
    int n;
    string s;

    cin >>n;
    cin >>s;

    set<string> patt;
    set<string> npatt;
    npatt.insert("");
    for(int i = 0; i < n ; i++){
        patt = npatt;
        for(set<string>::iterator it = patt.begin(); it != patt.end(); it++){
            if((*it).size() >= 3){
                continue;
            }
            npatt.insert(*it + s[i]);
        }
    }
    int ans = 0;
    for(set<string>::iterator it = npatt.begin(); it != npatt.end(); it++){
        if((*it).size() == 3){
            ans++;
        }
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 384
#B
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
S = sum(A)

flag = True
for i in range(M):
    if A[i] < S/(4*M):
        flag = False
        break

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



Measured memory_bytes: 3060
#include <stdio.h>

int main(void){

  int A, B;
  scanf("%d %d",&A,&B);
  int i, count=A, count1=1;
  if(B==1){
    printf("0");}
  else{
   for(i=0;count<B;i++){
    count+=A-1;
    count1+=1;
  }
  printf("%d",count1);
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#define rep(i,n) for(int i = 0 ; i < n ; i++ )
#define cc(a,n) 0<=(a) && (a) < n
#define INF 1000000
using namespace std;
int n;
int ma[16][16] = {{0}};
int dfs(int px,int py,int cnt){
  ma[px][py] = cnt;
  if(cnt == n*n)return 0; 
  int nx = px+1,ny = py+1;

  while(1){
    if(n <= nx){
      nx = 0;
    }else if(0 > nx){
      nx = n-1;
    }else if(n <= ny){
      ny = 0;
    }else if(ma[nx][ny] != 0){
      nx--;
      ny++;
    }
    if(ma[nx][ny] == 0&&cc(nx,n)&&cc(ny,n))break;
  }
  dfs(nx,ny,cnt+1);
}
int main(){

  while(cin >> n,n){
    rep(i,n+1)rep(j,n+1)ma[i][j] = INF;
    rep(i,n)rep(j,n)ma[i][j] = 0;

    int px = n/2,py = (n/2)+1;
    int t = dfs(px,py,1);
    rep(i,n){
      rep(j,n){
	printf("%4d",ma[j][i]);
      }
      cout << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1192
n = int(input())
mod = 10**9+7
num = [ int(v) for v in input().split() ]
bits = [ 0 for i in range(100) ]

for i in num:
    j = 0
    while i > 0:
        if i % 2 == 1:
            bits[j] += 1
        i //= 2
        j += 1


binmax = 0
for i in range(100):
    if bits[i] > 0:
        binmax = i
binmax += 2


pow_2_list = []
q = 1
for i in range(100):
    pow_2_list.append(q)
    q *= 2
    q %= mod


ans = 0
for i, v in enumerate(bits[:binmax]):
    ans += v * (n-v)  * pow_2_list[i] 
print(ans % mod)


Measured memory_bytes: 125624
#include <stdio.h>
#include <string.h>
#define ONE_WEEK 7

int main(void)
{
	char day[7][4] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	char s[4];
	int i;

	scanf("%s", s);

	for (i = 0; i < ONE_WEEK; i++)
	{
		if (strcmp(s, day[i]) == 0)
		{
			printf("%d\n", ONE_WEEK - i);
		}
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>

using namespace std;

int main() {
  int n,k,x[200];
  cin >> n >> k;
  for(int i = 0; i < n; i++)
    cin >> x[i];

  int sum = 0;
  for(int i = 0; i < n; i++) {
    if(x[i] <= (k-x[i]))
        sum += x[i] * 2;
    else sum+= (k-x[i]) * 2;
  }

  cout << sum << endl;
}

Measured memory_bytes: 3576
/* ***********************************************
Author        :BPM136
Created Time  :7/21/2019 7:58:00 PM
File Name     :A.cpp
************************************************ */

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<bitset>
#include<queue>
#include<ctime>
#include<set>
#include<map>
#include<list>
#include<vector>
#include<cassert>
#include<string>
#include<cinttypes>
#include<cstdint>
#include<array>
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define USE_CIN_COUT ios::sync_with_stdio(0)

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

int main() {
	ll S;
	cin >> S;
	ll sq = sqrt(S);
	if (sq * sq < S)
		++sq;
	ll l = sq, r = sq;
	for (; ; --l) {
		while (l * r < S)
			++r;
		if (l * r - S <= 1e9) {
			cout << "0 0 " << l << ' ' << 1 << ' ' << l * r - S << ' ' << r << '\n';
			return 0;
		}
	}
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, x0) = readLine()!!.split(" ").map(String::toInt)
    var x = readLine()!!.split(" ").map(String::toInt).toMutableList()
    x.add(x0)
    x.sort()

    val delta = (0 until x.size-1).mapIndexed{i, n ->
        x[i+1] - x[i]
    }
    print(delta.reduce{a, b -> gcd(a,b)})
}

tailrec fun gcd(a: Int, b: Int): Int{
    if(b == 0) return a
    return gcd(b, a%b)
}

Measured memory_bytes: 57908
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
x = list(map(int, input().split()))
l = int(input())
q = int(input())
ps = [None]*n
# ps2 = [None]*n
j = 0
for i in range(n):
    if j<i:
        j = i
    while j+1<n and x[j+1]-x[i]<=l:
        j += 1
    ps[i] = j
# ダブリング
def double(ps):
    # global: n=psのサイズ
    k = 0
    n = len(ps)
    while pow(2,k)<n:
        k += 1
    prev = [[None]*n for _ in range(k)] # ノードjから2^i個上の上司
    for j in range(n):
        prev[0][j] = ps[j]
    for i in range(1,k):
        for j in range(n):
            p = prev[i-1][j]
            if p>=0:
                prev[i][j] = prev[i-1][p]
            else:
                prev[i][j] = p
    return prev
dl = double(ps)
ans = [None]*q
def sub(a,b,x):
    for k in range(len(dl)-1, -1, -1):
        if x>=pow(2,k):
            x-=pow(2,k)
            a = dl[k][a]
    return a>=b
        
        
for i in range(q):
    a,b = map(lambda x: int(x)-1, input().split())
    a,b = min(a,b), max(a,b)
#     print(a,b)
    res = 0
    tmp = float("inf")
    l = 0
    r = n
    while l+1<r:
        m = (l+r)//2
        if sub(a,b,m):
            r = m
        else:
            l = m
    ans[i] = r
write("\n".join(map(str, ans)))

Measured memory_bytes: 111648
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

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

    int N;
    cin >> N;
    int current = 1;

    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;

        if (a == current)
            current++;
    }

    if (current == 1)
        cout << -1 << '\n';
    else
        cout << N - (current - 1) << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<list>
#include<cmath>
#include<vector>
#include<cstdio>
using namespace std;
int main(void){
	int i,tri[3];
	cin>>tri[0]>>tri[1]>>tri[2];
	sort(tri,tri+3);
	cout<<tri[0]*tri[1]/2<<endl;
	return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
cells = [['.'] * (W + 2)] + [['.'] + [s for s in input()] + ['.'] for _ in range(H)] + [['.'] * (W + 2)]

def check(i, j):
  return '#' in [cells[i - 1][j], cells[i][j - 1], cells[i][j + 1], cells[i + 1][j]]

for i in range(1, H + 1):
  for j in range(1, W + 1):
    if cells[i][j] == '#' and not check(i, j):
      print('No')
      break
  else:
    continue
  break
else:
  print('Yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b,c;
	cin>>a>>b>>c;
	int d=0,e=0,f=0;
	char g='a';
	for(int i=0;i<a.size()+b.size()+c.size();i++){
		if(g=='a'){
			g=a[d];
			if(d==a.size()){
				cout<<'A'<<endl;
				return 0;
			}
			d++;
		}
		if(g=='b'){
			g=b[e];
			if(e==b.size()){
				cout<<'B'<<endl;
				return 0;
			}
			e++;
		}
		if(g=='c'){
			g=c[f];
			if(f==c.size()){
				cout<<'C'<<endl;
				return 0;
			}
			f++;
		}
	}
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
using ll = long long;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	map<int, int> P;
	map<int, int> Q;
	bool flag = false;
	for (int i = 0; i < N; i++)
	{
		P[A[i]]++;
		Q[A[N - i - 1]]++;
		if (P == Q)
		{
			if (flag)cout << " ";
			cout << (i + 1);
			flag = true;
		}
	}
	cout << endl;
}

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


Measured memory_bytes: 7892
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
def f(x):
    return x[0]-x[1]
def g(x):
    return x[0]+x[1]
ans = max(f(max(xy, key=f))-f(min(xy, key=f)),
          g(max(xy, key=g))-g(min(xy, key=g)),)
print(ans)

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

const int INF = 1 << 25;
using S = tuple<int, int, int, ll>;
map<ll, int> dist[50][50];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int n, m;
	while(cin >> n >> m, n){
		int G[50][50] = { 0 };
		int h[50] = { 0 };
		int v[50] = { 0 };
		fill((int*)begin(G), (int*)end(G), INF);
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				dist[i][j].clear();
			}
		}

		h[n - 1] = 1000;
		for(int i = 1; i < n - 1; i++){
			cin >> v[i] >> h[i];
		}

		for(int i = 0; i < m; i++){
			int a, b, c;
			cin >> a >> b >> c;
			a--, b--;
			G[a][b] = min(G[a][b], c);
		}

		dist[0][0][0] = 0;
		priority_queue<S, vector<S>, greater<S>> q;
		q.emplace(0, 0, 0, 0);
		int ans = INF;
		while(q.size()){
			int a, b, d;
			ll bit;
			tie(d, a, b, bit) = q.top();
			q.pop();
			if(a == n - 1 && b == n - 1){
				ans = d;
				break;
			}
			for(int i = 0; i < n; i++){
				if(h[a] > h[i]) continue;
				if(G[a][i] == INF) continue;
				int nd = d + G[a][i];
				if((bit >> i & 1) == 0) nd += v[i];
				ll nbit = bit;
				if(h[i] > h[b]) nbit = 1LL << i;
				if(h[i] == h[b]) nbit = bit | (1LL << i);

				if(dist[i][b].count(nbit) == 0 || dist[i][b][nbit] > nd){
					dist[i][b][nbit] = nd;
					q.emplace(nd, i, b, nbit);
				}
			}
			for(int i = 0; i < n; i++){
				if(h[b] > h[i]) continue;
				if(G[i][b] == INF) continue;
				int nd = d + G[i][b];
				if((bit >> i & 1) == 0) nd += v[i];
				ll nbit = bit;
				if(h[i] > h[a]) nbit = 1LL << i;
				if(h[i] == h[a]) nbit = bit | (1LL << i);
				if(dist[a][i].count(nbit) == 0 || dist[a][i][nbit] > nd){
					dist[a][i][nbit] = nd;
					q.emplace(nd, a, i, nbit);
				}
			}
		}

		if(ans == INF) ans = -1;
		cout << ans << endl;
	}
}

Measured memory_bytes: 10688
#include<stdio.h>
#include<string.h>
int main(){
    char ara[10000];
    gets(ara);
    int f=0;
    int n=strlen(ara);
    for(int i=0;i<n;i++){
        if(ara[i]==' '){
            if(ara[i-1]!=ara[i+1]){
                f=1;
                break;
            }
           
        }
    }
    if(f==0) printf("YES\n");
    else printf("NO\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>

typedef long long ll;
using namespace std;
const int mod = 1000000007;

int main() {

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

    int cur = 1;
    int can = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] == cur) {
            cur++;
            can = 1;
        }
    }
    if (can) {
        cout << N - cur + 1 << '\n';
    }
    else {
        cout << -1 << '\n';
    }

}


Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		String str;
		int s;
		double w, h;
		
		while(scan.hasNext()){
			str = scan.next();
			String[] num = str.split(",", 0);
			
			s = Integer.parseInt(num[0]);
			w = Double.parseDouble(num[1]);
			h = Double.parseDouble(num[2]);
			
			if((w / (h*h)) >= 25)System.out.println(s);
		}
	}
}

Measured memory_bytes: 25936
import java.io.*;

public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true) {
			String[] line = br.readLine().split(" ");
			int a = Integer.parseInt(line[0]);
			int b = Integer.parseInt(line[2]);
			
			if(line[1].equals("+")) System.out.println(a + b);
			else if(line[1].equals("-")) System.out.println(a - b);
			else if(line[1].equals("*")) System.out.println(a * b);
			else if(line[1].equals("/")) System.out.println(a / b);
			else break;
		}
		
	}
}

Measured memory_bytes: 24332
from collections import Counter

N = int(input())

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

odd = arr[0::2]
even = arr[1::2]

odd_counter = Counter(odd)
even_counter = Counter(even)

odd_mode = odd_counter.most_common()[0][0]
even_mode = even_counter.most_common()[0][0]

odd_diff = (N / 2) - odd_counter.most_common()[0][1]
even_diff = (N / 2) - even_counter.most_common()[0][1]

if odd_mode != even_mode:
	print(int(odd_diff + even_diff))
elif odd_diff == 0:
	print(int(N / 2))
else:
	odd_diff2 = (N / 2) - odd_counter.most_common()[1][1]
	even_diff2 = (N / 2) - even_counter.most_common()[1][1]
	if odd_diff2 > even_diff2:
		print(int(odd_diff + even_diff2))
	else:
		print(int(odd_diff2 + even_diff))


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);

    int x;
    cin >> x;
    int res = 0;
    res += x / 500 * 1000;
    int remain = x % 500;
    res += remain / 5 * 5;

    cout << res << '\n';

    return 0;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  int x;
  cin >> x;
  vector<int> v(m);
  for(int i=0; i<m; i++){
    cin >> v[i];
  }
  int sma,big;
  sma = 0;
  big = 0;
  for(int i=0; i<m; i++){
    if(v[i] > x){
      big++;
    }
    else{
      sma++;
    }
  }
  
  cout << min(big,sma) << endl;
  
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n,m,i,j,x;
	int a[100][100]={0,};
	int b[100][1]={0,};
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&x);
			a[i][j]=x;
		}
	}
	for(i=0;i<m;i++){
		scanf("%d",&x);
		b[i][1]=x;
	}
	for(i=0;i<n;i++){
		x=0;
		for(j=0;j<m;j++){
			x+=a[i][j]*b[j][1];
		}
		printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 648
N, Q = map(int, input().split())
S = input()
W = [0 for i in range(N + 1)]
AC = [False for b in range(N + 1)]
for i in range(1, N):
    if S[i] == 'C' and S[i - 1] == 'A':
        W[i + 1] = W[i] + 1
        AC[i] = True
    else:
        W[i + 1] = W[i]

for i in range(Q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    ans = W[r + 1] - W[l]
    if AC[l]:
        ans -= 1
    print(ans)



Measured memory_bytes: 6976
from collections import defaultdict
s = defaultdict(list)
t = defaultdict(list)
S = list(input())
T = list(input())
for i in range(len(S)):
    if T[i] not in s[S[i]]:
        s[S[i]].append(T[i])
        if len(s[S[i]]) >= 2:
            print("No")
            break
    if S[i] not in t[T[i]]:
        t[T[i]].append(S[i])
        if len(t[T[i]]) >= 2:
            print("No")
            break
    if i == len(S) - 1:
        print("Yes")

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    double R;
    cin >> R;
    cout << 2 * R * M_PI << endl;

    return 0;
}

Measured memory_bytes: 3780
//Dekha hobe.....POROKALE

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

int main()
{
    int x, a, b;
    scanf("%d%d%d", &x, &a, &b);
    int A = abs(x-a);
    int B = abs(x-b);
    if(A < B) printf("A");
    else printf("B");

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int k;//number of buy
  int n;//number of fruit
  scanf("%d %d",&n,&k);
  int p[n];
  for(int i = 0;i < n;i++){
    scanf("%d",&p[i]);
  }
  int tmp;
  for(int i = 0;i < n;i++){
    for(int j = 0;j < n - 1;j++){
      if(p[j] > p[j + 1]){
        tmp = p[j];
        p[j] = p[j + 1];
        p[j + 1] = tmp;
      }
    }
  }
  int sum = 0;
  for(int i = 0;i < k;i++){
    sum = sum + p[i];
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 1708
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int mod=1e9+7;
int out=0;
string s;
int n;
int dp[3005][3005];
int sum[3005][3005];
void add( int & a ,int b)
{
	a+=b;
	if(a>=mod)
		a-=mod;
}
int ss( int t , int l , int r )
{
	if(l>r)
		return 0;
	l=max(l,0);
	if(l==0)
		return sum[t][r];
	else
		return sum[t][r]-sum[t][l-1]+mod;
}
int main(){
cin>>n>>s;
dp[0][0]=1;
sum[0][0]=1;
for(int i=1;n>i;i++)
{
	char z=s[i-1];
	for(int j=0;i>=j;j++)
	{
		if(z=='<')
			{add(dp[i][j],ss(i-1,0,j-1));}
		else
			add(dp[i][j],ss(i-1,j,i-1));
	}
	for(int j=0;i>=j;j++)
	{
		add(sum[i][j],dp[i][j]);
		if(j)
			add(sum[i][j],sum[i][j-1]);
	}
}
for(int i=0;n>i;i++)
	add(out,dp[n-1][i]);
cout<<out;

	return 0;
}


Measured memory_bytes: 69504
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 100005;

int n;
LL k;
LL lef[N],rig[N];
LL fl[N*2],fr[N*2];
struct node{
	int v,l,r;
}tree[N*4];
int tot;
int h[N*2],m;

int getw(int v){
	int l=1,r=m,ans=0;
	while(l<=r){
		int mid=(l+r)/2;
		if (v<h[mid])r=mid-1;
		else ans=mid,l=mid+1;
	}
	return ans;
}

void build(int &now,int l,int r){
	now=++tot;
	tree[now].v=1e+9;
	if (l==r)return;
	int mid=(l+r)/2;
	build(tree[now].l,l,mid);
	build(tree[now].r,mid+1,r);
}

void change(int now,int l,int r,int x,int y,int id){
	if (x<=l&&r<=y){
		tree[now].v=id;
		return;
	}
	int mid=(l+r)/2;
	if (x<=mid)change(tree[now].l,l,mid,x,y,id);
	if (y>mid)change(tree[now].r,mid+1,r,x,y,id);
}

int getv(int now,int l,int r,int x){
	if (l==r)return tree[now].v;
	int mid=(l+r)/2;
	if (x<=mid)return min(tree[now].v,getv(tree[now].l,l,mid,x));
	return min(tree[now].v,getv(tree[now].r,mid+1,r,x));
}

LL minll(LL x,LL y){return x<y?x:y;}

int main(){
	n=get();k=get();
	LL sum=0,ans=0;
	fo(i,1,n){
		int a=get(),b=get();
		if (a*2>k&&b==1)return printf("-1\n"),0;
		ans+=a*2;
		sum=(sum+a)%k;
		if (b==2)lef[i]=0,rig[i]=k-1;
		else rig[i]=(k-sum)%k*2%k,lef[i]=(k-sum+a+k)%k*2%k;
	}
	fo(i,1,n)h[++m]=lef[i],h[++m]=rig[i];
	sort(h+1,h+1+m);
	int m_=1;
	fo(i,2,m)if (h[i]>h[i-1])h[++m_]=h[i];
	m=m_;
	int rt=0;tot=0;
	build(rt,1,m);
	fd(i,n,1){
		int l=getw(lef[i]),r=getw(rig[i]);
		int p=getv(1,1,m,l);
		if (p<=n)fl[i]=fl[p]+(lef[p]+k-lef[i])%k;
		p=getv(1,1,m,r);
		if (p<=n)fr[i]=fl[p]+(lef[p]+k-rig[i])%k;
		if (l<=r){
			if (l>1)change(1,1,m,1,l-1,i);
			if (r<m)change(1,1,m,r+1,m,i);
		}
		else if(r+1<l)change(1,1,m,r+1,l-1,i);
	}
	tot=0,rt=0;
	build(rt,1,m);
	LL fans=1e+14;
	fo(i,1,n){
		int l=getw(lef[i]),r=getw(rig[i]);
		int p=getv(1,1,m,l);
		if (p>n)fans=minll(fans,fl[i]);
		p=getv(1,1,m,r);
		if (p>n)fans=minll(fans,fr[i]);
		if (l<=r){
			if (l>1)change(1,1,m,1,l-1,i);
			if (r<m)change(1,1,m,r+1,m,i);
		}
		else if(r+1<l)change(1,1,m,r+1,l-1,i);
	}
	fans=fans+ans;
	printf("%lld\n",fans);
	return 0;
}

Measured memory_bytes: 10112
A,B = map(int,input().split())
# 1,A,2A-1,3A-2

if B == 1:
    print(0)
else:
    ans = 0
    misiyo = 1
    while True:
        ans += 1
        misiyo += A-1
        if B <= misiyo:
            print(ans)
            break

Measured memory_bytes: 2940