akhauriyash/Code-Regression huggingface dataset:
import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long X) {
    auto w = new long[](N + 1);
    auto p = new long[](N + 1);
    w[0] = p[0] = 1;

    foreach (i; 1 .. N + 1) {
        w[i] = 2 * w[i - 1] + 3;
        p[i] = 2 * p[i - 1] + 1;
    }

    long patties(long level, long x) {
        if (level <= 0)
            return 1;
        if (x <= 1)
            return 0;
        if (x <= 1 + w[level - 1])
            return patties(level - 1, x - 1);
        if (x == 1 + w[level - 1] + 1)
            return p[level - 1] + 1;
        if (x <= w[level] - 1)
            return p[level - 1] + 1 + patties(level - 1, x - (1 + w[level - 1] + 1));
        return p[level - 1] + 1 + p[level - 1];
    } 

    return patties(N, X);
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long X;
    X = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(N, X);
    else
        solve(N, X).writeln;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cstdio>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define fr first
#define sc second
#define mp make_pair

typedef long long int64;
typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

const int INF = 2 << 28;
const double EPS = 1e-10;

#define MAX 1000000

vector< int > p;
vector< bool > isP(MAX, true);

void makePrime() {
    isP[0] = isP[1] = false;
    for(int i = 2; i * i < MAX; i++)
        for(int j = i + i; j < MAX; j += i)
            isP[j] = false;

    for(int i = 2; i < MAX; i++) {
        if(isP[i]) p.push_back(i);
    }
}

int main() {

    makePrime();

    int N, P;
    while(cin >> N >> P, ~N) {
        int off = upper_bound(p.begin(), p.end(), N) - p.begin();

        vector< int > M;
        for(int i = 0; i < P; i++) {
            for(int j = i; j < P; j++) {
                M.push_back(p[off + i] + p[off + j]);
            }
        }
        sort(M.begin(), M.end());
        cout << M[P - 1] << endl;
    }
}

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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}


typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

ll pow(ll x, ll y) {
	if(y == 0)
	return 1;
	ll temp = pow(x, y/2);
	temp = (temp*temp);
	if(y%2 == 1)
		temp *= x;
	return temp;
}

int main() {
	ll n, k;
	cin >> n >> k;
	ll res = n;
	for(int i = 0; i < (int)(1E6); i++) {
		if(n >= k)
			n = n%k;
		else
			n = k - n;
		res = min(res, n);
	}
	cout << res;
}

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

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

    int l, r, d;
    cin >> l >> r >> d;

    int res = 0;
    for(int i = l; i <= r; ++i){
        if(i%d == 0)++res;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
int main(void){
	char S[101];
	long long K;
	scanf("%s",S);
	scanf("%lld",&K);
	for(int i=0;i<= (strlen(S)<(K-1) ? strlen(S):K-1);i++){
		if(S[i] != '1'){
			printf("%c",S[i]);return 0;
		}
	}
	printf("1");	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=9999999999999999;
int func(int k,int x){
  int count=0;
  while(x>0){
    x/=k;count++;
  }
  return count;
}
int main() {
  int N,K;
  cin>>N>>K;
  cout<<func(K,N)<<endl;
return 0;}

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

char X[1010], Y[1010];
int dp[1010][1010];

int LCS(){
    int maxl=0;
    int m, n, i, j;

    scanf("%s", &X);
    scanf("%s", &Y);
    m = strlen(X);
    n = strlen(Y);

    for(i=0; i<=m; i++){
        for(j=0; j<=n; j++){
            dp[i][j] = 0;
        }
    }
    for(i=0; i<m; i++){
        for(j=0; j<n; j++){
            if(X[i]==Y[j]){
                dp[i+1][j+1] = dp[i][j] +1;
            }else if(dp[i][j+1] < dp[i+1][j]){
                dp[i+1][j+1] = dp[i+1][j];
            }else{
                dp[i+1][j+1] = dp[i][j+1];
            }

            if(maxl < dp[i+1][j+1]){
                maxl = dp[i+1][j+1];
            }
        }
    }

    return maxl;
}

int main(){
    int q, i, j, k;
    int m, n;
    int ans;
    scanf("%d", &q);
    for(i=0; i<q; i++){
        ans = LCS();
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 5652
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();

    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();

    let mut xs: Vec<u64> = s.trim().split(' ').map(|x| x.parse().unwrap()).collect();

    xs.sort();

    let mut b = 0;
    let mut d = 0;
    let mut m = 0;

    for x in xs {
        if x != b {
            b = x;
            m += 1;
        }
        else {
            d += 1;
        }
    }

    println!("{}",
        if d % 2 == 1 {
            m - 1
        }
        else {
            m
        }
    );
}


Measured memory_bytes: 3964
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int main() {
    ll n,l;
    std::cin >> n>>l;
    ll sum = 0;
    ll mi = 1e9;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        sum += l+i-1;
        if(mi > abs(l+i-1)){
            mi = abs(l+i-1);
            ans = i;
        }
    }
    std::cout << sum-(l+ans-1) << std::endl;
    
}   


Measured memory_bytes: 256
def calc_distance(left, right, p):
    return sum(list(map(lambda x, y: abs(x - y) ** p, left, right))) ** (1 / p)


n = int(input())
v1 = list(map(lambda x: float(x), input().split()))
v2 = list(map(lambda x: float(x), input().split()))
for i in range(1, 4):
    print("{:f}".format(calc_distance(v1, v2, i)))
print("{:f}".format(max(list(map(lambda x, y: abs(x - y), v1, v2)))))



Measured memory_bytes: 5668
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll sum=0,m=a[0];
    rep(i,n) {
        if(m>a[i]) {
            sum+=m-a[i];
        }
        else m=a[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 4348
import sys
input = sys.stdin.readline
K, Q = map(int, input().split())
d = list(map(int, input().split()))

for _ in range(Q):
  n, x, m = map(int, input().split())
  x %= m
  dq = [y % m for y in d]
  
  for i in range(K): dq[i] += (dq[i] == 0) * m
  res = (sum(dq) * ((n - 1) // K) + sum(dq[: (n - 1) % K]) + x) // m
  print(n - 1 - res)


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

int main(){
  vector <int> v(3);
  for(int i=0;i<3;i++){
    cin >> v.at(i);
  }
  sort(v.begin(),v.end());
  int n=0;
  bool flag=true;
  while(flag){
    if(v.at(2)-v.at(1)>=1){
      v.at(0)++;
      v.at(1)++;
      n++;
    }else if(v.at(2)-v.at(0)>=2){
      v.at(0)+=2;
      n++;
    }else if((v.at(0)==v.at(1))&&(v.at(1)==v.at(2))){
      flag=false;
      break;
    }else{
      v.at(2)++;
      v.at(1)++;
      n++;
    }
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;

int main() {
  ll n, z, d;
  cin >> n;
  if (n % 2)
    cout << 0 << "\n";
  else {
  	z = 0;
  	d = 10;
  	while (d <= n) {
  		z += (n / d);
  		d *= 5;
  	}
  	cout << z << "\n";
  }
  return 0;
}

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

int main(){
  string S;
  bool a=false;
  bool b=false;
  bool c=false;
  cin >> S;
  for (int i = 0; i < 3; i++) {
    if(S[i]=='a') {
      a=true;      
    } else if(S[i]=='b'){
      b=true;
    } else if(S[i]=='c'){
      c=true;
    }
  }
  if(a&&b&&c){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

using namespace std;
const int maxn=200000+5;
char aa[maxn];

int main()
{
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    getchar();
    cin>>aa[1];
    char ss=aa[1];
    int te=0;
    int la=max(c,d);
    for(int i=2;i<=n;i++)
    {
        cin>>aa[i];
        if(aa[i]=='#'&&ss=='#'&&i>a&&i<la)
        {
             te=1;
             break;
        }
        ss=aa[i];
    }
    la=min(c,d);
    if(c==d) te=1;
    if(c>d)
    {
        te=1;
        for(int i=b-1;i<=la-1;i++)
        {
            if(aa[i]=='.'&&aa[i+1]=='.'&&aa[i+2]=='.')
            {
                te=0;
                break;
            }
        }
    }
    if(te) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#define N 104
using namespace std;
typedef long long ago;

int n, a, b, len, d[N], now[N], ans;
vector<int> G[N];

void dfs(int u, int p, int dep, int &dis, int &dot) {
    if (dep > dis) dot = u, dis = dep;
    for (auto v : G[u])
        if (v != p) dfs(v, u, dep + 1, dis, dot);
}

int stk[N], top;
void dfs2(int u, int p, int t) {
    stk[++top] = u;
    if (u == t) memcpy(d, stk, sizeof stk);
    for (int v : G[u])
        if (v != p) dfs2(v, u, t);
    stk[top--] = 0;
}

void dfs3(int u, int p, int dep) {
    int son = 0;
    for (int v : G[u]) 
        if (v != p) dfs3(v, u, dep + 1), ++son;
    now[dep] = max(now[dep], son);
}

ago calc(int u, int v = 0) {
    dfs3(u, v, 1);
    if (v) dfs3(v, u, 1);
    ago res = 1;
    for (int i = 1; i < ans; ++i)
        res = res * now[i], now[i] = 0;
    return res;
}

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n;
    for (int i = 1, u, v; i < n; ++i)
        scanf("%d%d", &u, &v),
        G[u].push_back(v), G[v].push_back(u);

    len = 0, dfs(1, 0, 1, len, a);
    len = 0, dfs(a, 0, 1, len, b);

    ans = (len + 1) / 2;
    cout << ans << ' ';
    dfs2(a, 0, b);

    if (len & 1) {
        ago res = calc(d[ans]);
        for (int v : G[d[ans]])
            res = min(res, 2ll * calc(d[ans], v));
        cout << res << endl;
    } else cout << 2ll * calc(d[ans], d[ans + 1]) << endl;

    return 0;
}


Measured memory_bytes: 256
K = list(map(int, input()))
D = int(input())

mod = 10 ** 9 + 7

next_dp = [0] * D
border = 0

for current_digit in K:
    dp, next_dp = next_dp, [0] * D
    for current_mod, cnt in enumerate(dp):
        for next_mod in range(current_mod, current_mod + 10):
            next_dp[next_mod % D] += cnt

    for next_mod in range(border, current_digit + border):
        next_dp[next_mod % D] += 1

    border = (border + current_digit) % D

    for i in range(D):
        next_dp[i] %= mod
print((next_dp[0] + (border == 0) - 1) % mod)


Measured memory_bytes: 43884
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    StringBuilder ans =  new StringBuilder();
    while(N > 0){
      N--;
      ans.append((char) (N % 26 + 'a'));
      N /= 26;
    }
    System.out.println(ans.reverse());
  }
}

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

int main(){
    ll N; cin >> N;
    vector<ll> A(N+1), S(N+1);
    rep(i, 1, N+1){
        cin >> A[i];
        A[i] *= 2;
    }
    S[0] = 0;
    rep(i, 1, N + 1) S[i] = S[i-1] + A[i];
    for(auto t: S) cerr << t << " ";
    cerr << endl;
    ll left = 2, right = 3;
    ll ans = 1e18;

    rep(mid, 3, N){
        ll pq = S[mid-1], rs = S[N] - S[mid-1];
        while(llabs(pq/2 - S[left-1]) > llabs(pq/2 - S[left]) && left < mid-1) left++;
        if(right <= mid) right = mid + 1;
        while( right < N && llabs(rs/2 - (S[right-1] - S[mid-1])) > llabs(rs/2 - (S[right] - S[mid-1]) )) right++;
        ll t[4];
        t[0] = S[left-1];
        t[1] = pq - t[0];
        t[2] = S[right-1] - (t[1] + t[0]);
        t[3] = S[N] - (t[2] + t[1] + t[0]);
        cerr << "left, mid, right " << left << " " <<  mid << " " << right << endl;
        for(auto e: t) cerr << e << " ";
        cerr << endl;
        sort(t, t + 4);
        //cerr << t[3] << t[0] << endl;
        ans = min(ans, t[3] - t[0]);
        cerr << ans << endl;
    }
    cout << ans / 2 << endl;
}

Measured memory_bytes: 3456
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
const int maxn = 100010;
using namespace std;
int n, a[maxn], f[maxn], w[maxn], m, x, tmp[maxn]; ll k;
int main() {
	scanf("%d", &n);
	rep(i, 1, n) scanf("%d", &a[i]);
	rep(i, 2, n) f[i] = i;
	scanf("%d%lld", &m, &k);
	rep(i, 1, m) scanf("%d", &x), swap(f[x], f[x + 1]);
	rep(i, 2, n) w[i] = f[i], f[i] = i;
	for (; k; k /= 2) {
		if (k & 1LL) rep(i, 2, n) f[i] = w[f[i]];
		rep(i, 2, n) tmp[i] = w[i];
		rep(i, 2, n) w[i] = tmp[w[i]];
	} 
	printf("%d.0\n", a[1]); ll las = a[1];
	for (int i = 2; i <= n; ++ i) 
		las += a[f[i]] - a[f[i] - 1], printf("%lld.0\n", las);
	return 0;
}

Measured memory_bytes: 3072
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7


def main():
    n = int(input())
    d = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        for j in range(i + 1, n):
            if i == j:
                continue
            ans += (d[i]*d[j])
    print(ans)


    
            
    

    

    

if __name__ == '__main__':
    main()


Measured memory_bytes: 71916
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
string str;
vector<int> xid[27];
int dp[200001];
int type[200001],nexts[200001];

int solve(int v){
	if(dp[v]!=-1)return dp[v];
	int res=n+2,nex=n+2;
	for(int i=0;i<26;i++){
		int nv=lower_bound(xid[i].begin(),xid[i].end(),v)-xid[i].begin();
		if(xid[i][nv]==n){
			if(res>1){
				res=1;
				type[v]=i;
				nexts[v]=n;
			}
		}else{
			int vv=solve(xid[i][nv]+1);
			if(res>vv+1){
				res=vv+1;
				type[v]=i;
				nexts[v]=xid[i][nv]+1;
			}
		}
	}
	dp[v]=res;
	return dp[v];
}

int main(void){
	memset(dp,-1,sizeof(dp));
	cin >> str;
	n=str.size();
	dp[n]=1;
	for(int i=0;i<n;i++){
		xid[str[i]-'a'].push_back(i);
	}
	for(int i=0;i<26;i++){
		xid[i].push_back(n);
	}
	solve(0);
	int now=0;
	string res="";
	while(now<n){
		res+=('a'+type[now]);
		now=nexts[now];
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4228
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    tmp0 = input[0].split(" ");
    A = Number(tmp0[0]);
    P = Number(tmp0[1]);

    console.log(Math.floor((P + A*3)/2))
  }
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//   Main("32 21\n");

Measured memory_bytes: 21064
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int n,k,cards[100000];

int main(void)
{
	while(true)
	{
		memset(cards,0,sizeof(cards));
		cin >> n >> k;
		if(n == 0 && k == 0)
			exit(0);
		for(int i = 0;i < k;i++)
			cin >> cards[i];
		sort(cards,cards+k);
		int result = 0;
		if(cards[0] != 0)
		{
			int maxcount = 0;
			for(int i = 0;i < k;i++)
			{
				int ptr_up = i;
				int ptr_dn = i+2;
				int prev_up = cards[i+1];
				int prev_dn = cards[i+1];
				int count = 1;
				while(ptr_up >= 0 && prev_up - 1 == cards[ptr_up])
				{
					prev_up--;
					ptr_up--;
					count++;
				}
				while(ptr_dn < k && prev_dn + 1 == cards[ptr_dn])
				{
					prev_dn++;
					ptr_dn++;
					count++;
				}
				maxcount = max(maxcount,count);
			}
			result = maxcount;
		}
		else
		{
			int maxcount = 0;
			for(int i = 1;i < k;i++)
			{
				int ptr_up = i;
				int ptr_dn = i+1;
				int prev_up = cards[i]+1;
				int prev_dn = cards[i]+1;
				int count = 1;
				while(ptr_up >= 0 && prev_up - 1 == cards[ptr_up])
				{
					prev_up--;
					ptr_up--;
					count++;
				}
				while(ptr_dn < k && prev_dn + 1 == cards[ptr_dn])
				{
					prev_dn++;
					ptr_dn++;
					count++;
				}
				maxcount = max(maxcount,count);
			}
			result = maxcount;
		}
		cout << result << endl;
	}
}

Measured memory_bytes: 3364
/* You are being watched. */


//~ while (clock() <= 69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")

using namespace std;

//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
//~ using namespace __gnu_pbds;
//~ template <typename T>
//~ using ordered_set =
  //~ tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define show(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

void solve() {
  int n; cin >> n;
  string s[] = {"AC", "WA", "TLE", "RE"};
  map <string, int> cnt;
  for(int i = 0; i < n; i++) {
    string x; cin >> x;
    cnt[x]++;
  }
  for(auto x : s) cout << x << " x " << cnt[x] << '\n';
}

int main() {
  int t; t = 1;
  while(t--) solve();
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int x;
    cin >> x;
    
    cout << (x ? 0 : 1) << endl;

    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>

bool path[8][8] = {};

using namespace std;


int search(bitset<8> state, int position, int N) {
  state.set(position);

  bitset<8> s = state | bitset<8>(((1 << 8) - 1) ^ ((1 << N) - 1));
  if(s.all()) return 1;

  int num = 0;
  for(int i = 0; i < N; i++) {
    if(i == position) continue;
    if(path[position][i] != true) continue;
    if(state[i] == true) continue;
    num += search(state, i, N);
  }

  return num;

}

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

  for(int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--,b--;
    path[a][b] = true;
    path[b][a] = true;
  }

  cout << search(bitset<8>(), 0, N) << endl;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
n = int(input())
li = list(map(int, input().split()))
line = 1
L =[]
for i, a in enumerate(li, 1):
    while a > 0:
        L.append(i)
        a -= 1
        if len(L) == w:
            if line % 2:
                print(*L)
            else:
                print(*reversed(L))
            L = []
            line += 1


Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
int N, M;
int A[100005];
long long ans;
vector <int> G[100005];
bool Use[100005];
vector <int> V[100005];
int cnt;
int Ind[100005];
set <pair <int, int> > S;
void Read()
{
    cin >> N >> M;
    for(int i = 1; i <= N; i++)
        cin >> A[i];
    for(int i = 1; i <= M; i++)
    {
        int x, y;
        cin >> x >> y;
        ++x;++y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
}

void DFS(int node, int father)
{
    Use[node] = 1;
    V[cnt].push_back(A[node]);
    for(int i = 0; i < G[node].size(); i++)
    {
        int neighb = G[node][i];
        if(neighb == father)
            continue;
        DFS(neighb, node);
    }
}

void precalcV()
{
    for(int i = 1; i <= N; i++)
    {
        if(Use[i] == 0)
        {
            ++cnt;
            //Ord[cnt] = cnt;
            DFS(i, 0);
            sort(V[cnt].begin(), V[cnt].end());
        }
    }
    //sort(Ord + 1, Ord + cnt + 1, cmp);
}

void Solve()
{
    int sum = 0;
    for(int i = 1; i <= cnt; i++)
    {
        sum += V[i].size();
    }
    if(sum < 2 * (cnt - 1))
    {
        cout << "Impossible\n";
        return;
    }
    int nb = cnt;
    for(int i = 1; i <= cnt; i++)
    {
        ++Ind[i];
        if(Ind[i] < V[i].size())
            S.insert(make_pair(V[i][Ind[i]], i));
        ans += V[i][0];
    }
    while(nb < 2 * (cnt - 1))
    {
        ++nb;
        auto it = S.begin();
        int val = it -> first, comp = it -> second;
        S.erase(it);
        ans += val;
        Ind[comp]++;
        if(Ind[comp] < V[comp].size())
            S.insert(make_pair(V[comp][Ind[comp]], comp));
    }
    cout << ans << "\n";
}
int main()
{
    Read();
    precalcV();
    if(cnt == 1)
    {
        cout << "0\n";
        return 0;
    }
    Solve();
    return 0;
}


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

int main(){
	int x; cin>>x;
	if(x>=400&&x<=599)
		cout<<8;
	else if(x>=600&&x<=799)
		cout<<7;
	else if(x>=800&&x<=999)
		cout<<6;
	else if(x>=1000&&x<=1199)
		cout<<5;
	else if(x>=1200&&x<=1399)
		cout<<4;
	else if(x>=1400&&x<=1599)
		cout<<3;
	else if(x>=1600&&x<=1799)
		cout<<2;
	else
		cout<<1;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n;
cin>>n;
long long d[n][2];
for(long long i=0;i<n;i++){
  cin>>d[i][0];
  cin>>d[i][1];
}
long long ans=0;
for(long long i=0;i<n-2;i++){
if(d[i][0]==d[i][1]&&d[i+1][0]==d[i+1][1]&&d[i+2][0]==d[i+2][1]){
  ans=1;
}
}
if(ans==1){
  cout<<"Yes"<<endl;
}
else{
  cout<<"No"<<endl;
}
return 0;

}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 1111
#define pb push_back
#define fi first
#define sc second
typedef pair<long double,int> P;
int N;
long double Xs,Ys,Xt,Yt;
long double X[MAX_N],Y[MAX_N],R[MAX_N];
long double cost[MAX_N][MAX_N];
long double s[MAX_N];
long double dis(int i,int j);
int main()
{
	cout.precision(22);cin.precision(22);
	//printf("long double : %d\n", sizeof(long double));
	cin >> Xs >> Ys >> Xt >> Yt;
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> X[i] >> Y[i] >> R[i];
	}
	X[N]=Xs;Y[N]=Ys;R[N]=0;
	X[N+1]=Xt;Y[N+1]=Yt;R[N+1]=0;N+=2;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			cost[i][j]=dis(i,j);
			//cout << i << " " << j << " " << cost[i][j] << "\n";
			cost[j][i]=cost[i][j];
		}
	}
	for(int i=0;i<N;i++){
		s[i]=3000000000;
	}
	priority_queue<P,vector<P>,greater<P> >que;
	que.push(P(0,N-2));
	while(!que.empty()){
		P p=que.top();que.pop();
		if(s[p.sc]<=p.fi)continue;
		s[p.sc]=p.fi;
		for(int i=0;i<N;i++){
			if(p.fi+cost[p.sc][i]<s[i]){
				que.push(P(p.fi+cost[p.sc][i],i));
			}
		}
	}
	
	cout << s[N-1] << "\n";
	return 0;
}
long double dis(int i,int j){
	long double l=sqrt((Y[j]-Y[i])*(Y[j]-Y[i])+(X[j]-X[i])*(X[j]-X[i]));
	l-=(R[i]+R[j]);
	if(l<0)return 0;
	return l;
}


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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    N = len(S)
    is_whole_statement_palindrome = S == S[::-1]
    former = S[:((N-1)//2)]
    is_former_palindrome = former == former[::-1]
    latter = S[(((N+3)//2)-1):]
    is_latter_reversed = latter == latter[::-1]
    return (
        is_whole_statement_palindrome
        and is_former_palindrome
        and is_latter_reversed
    )


def main():
    S = input()  # type: str
    print(YES if solve(S) else NO)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll common(ll x){
    ll res=1;
    for(ll i=2; i*i<=x; i++){
        if(x%i) continue;
        while(x%i==0){
            x/=i;
        }
        res++;
    }
    if(x!=1) res++;
    return res;
}
int main(){
    ll A,B;cin >> A >> B;
    ll ab=gcd(A,B);
    ll ans=common(ab);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	n, k := readInt(), readInt()

	if k == 0 {
		fmt.Println(n * n)
		return
	}

	ans := 0
	for b := 1; b <= n; b++ {
		if b-1 < k {
			continue
		}
		ans += n / b * (b - 1 - k + 1)
		// fmt.Println("b:", b, ", cnt:", n/b*(b-1-k+1))
		if n%b >= k {
			ans += n%b - k + 1
			// fmt.Println(n%b - k + 1)
		}
	}
	fmt.Println(ans)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int nmax=200005;
ll fac[nmax],finv[nmax],inv[nmax];
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<nmax;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll com(int n,int k){
  if(n<k||n<0||k<0){
    return 0;
  }
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w,a,b;cin >> h >> w >> a >> b;
    COMinit();
    ll ans=0;
    for(int i=0;i<h-a;i++){
        (ans+=com(i+b-1,i)*com(h-1-i+w-1-b,w-1-b)%mod)%=mod;
    }
    cout << ans << endl;
}

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

#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define lb(v, z) lower_bound(all(v), z)
#define ub(v, z) upper_bound(all(v), z)
#define fill(a, z) memset(a, z, sizeof(a))
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define rdp(i, a, b) for (int i = (a); i >= (b); i--)
#define rlt(i, a, b) for (int i = (a); i < (b); i++)
#define cns(z) cout << z << ' '
#define cnl(z) cout << z << '\n'
#define printclock cerr << "Time : " << 1000 * (double)clock() / (double)CLOCKS_PER_SEC << "ms\n";
#define M 1000000007
#define M2 998244353
#define INF 10000000000000000
#define MAXN 300005
#define endl "\n"
#define iip(t) \
	int t;     \
	cin >> t;
#define iip2(a, b) \
	int a, b;      \
	cin >> a >> b;
#define dip(a) \
	double a;  \
	cin >> a;
#define dip2(a, b) \
	double a, b;   \
	cin >> a >> b;
#define garr(ip)       \
	for (auto &x : ip) \
		cin >> x;
#define parr(ip)          \
	for (auto &x : ip)    \
		cout << x << " "; \
	cout << endl;
#define test   \
	int _t;    \
	cin >> _t; \
	while (_t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vp;

int n;
map<pii, int> dp;
vi arr(MAXN);

int f(int start, int left)
{
	if (left == 0)
		return 0;
	else if (n - start + 1 < left + left - 1 or start > n)
		return -INF;
	else if (dp.find({start, left}) != dp.end())
		return dp[{start, left}];
	else
		return dp[{start, left}] = max(arr[start] + f(start + 2, left - 1), f(start + 1, left));
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	rep(i, 1, n) cin >> arr[i];
	cnl(f(1, n / 2));
}

Measured memory_bytes: 33756
import sys

a, b, c = map(int, input().split())

sum_1 = a + b
sum_2 = b + c
sum_3 = c + a

if sum_1 >= sum_2:
    min_1 = sum_2
else: 
    min_1 = sum_1

if min_1 >= sum_3:
    ans = sum_3
else:
    ans = min_1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
int a[100000];
int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  int mi,ma;
  mi = a[n/2-1];
  ma = a[n/2];
  cout << ma - mi << endl; 
  return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (ll i = x; i < y; i++)
#define DEC(i, x, y) for (ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
using namespace std;
 
// Some typedef's
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<ii> vii;
 
template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
 
ll lcm(ll a, ll b) { return (a * (b / __gcd(a, b))); }
 
// Some contants
const ll inf = 1e12 + 7;
const double eps = 1e-9;
const double pi = 1.00 * acos(-1.00);
 
ll n;
vlli Ai, Bi;

void solve(){
 
    rep(n){
       ll a, b;
       scanf("%lld %lld", &a, &b); 
      Ai.pb(a); Bi.pb(b);
    }
    sort(all(Ai));
    sort(all(Bi));
    if (n&1){
        printf("%lld\n", Bi[n/2] - Ai[n/2] + 1);
        return;
    }
    
    printf("%lld\n", Bi[n/2] + Bi[n/2 - 1] - Ai[n/2] - Ai[n/2 -1] + 1);

} 
 
int main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
 
    scanf("%lld", &n);
    solve();
 
 
    return 0;
 
 
}


Measured memory_bytes: 6736
N, W = list(map(int, input().split()))
items = []
for _ in range(N):
    items.append(tuple(map(int, input().split())))

dp = [[-1] * (W + 1) for _ in range(N + 1)]

for i in range(N + 1):
    dp[i][0] = 0
for w in range(W + 1):
    dp[0][w] = 0

from itertools import product
for i, w in product(range(N), range(W + 1)):
    dp[i + 1][w] = dp[i][w]
    value, weight = items[i]
    if w - weight >= 0:
        dp[i + 1][w] = max(dp[i][w], dp[i][w - weight] + value)

print(dp[-1][-1])


Measured memory_bytes: 25864
#include<iostream>
#include<stdio.h>
#include<string>
#include <algorithm>
#include<cstring>
#include <math.h>
#include <iomanip>
using namespace std;

int main()
{
  int n;
  cin>>n;
  int x;
  int max=0,min=2000;
  for(int i=0;i<n;i++){
    cin>>x;
    if(x<min)min=x;
    if(x>max)max=x;
  }
  x=(min+max)/2;
  int ans=max-x;
  cout<<ans<<endl;
  return 0;
  
}



Measured memory_bytes: 3084
import java.util.Scanner;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int m = sc.nextInt();
            int l = sc.nextInt();
            
            int[][] A = new int[n][m];
            int[][] B = new int[m][l];
            
            for(int i = 0 ; i < n ; i++){
                for(int j = 0 ; j < m ; j++){
                    A[i][j] = sc.nextInt();
                }
            }
            for(int i = 0 ; i < m ; i++){
                for(int j = 0 ; j < l ; j++){
                    B[i][j] = sc.nextInt();
                }
            }
            
            for(int i = 0 ; i < n ; i++){
                for(int j = 0 ; j < l ; j++){
                    long c = 0;
                    for(int k = 0 ; k < m ; k++){
                        c += A[i][k] * B[k][j];
                    }
                    if(j == l-1){
                         System.out.print(c);
                    } else {
                         System.out.print(c + " ");
                    }
                }
                System.out.println();
            }
        
    }
}


Measured memory_bytes: 53236
#include <stdio.h>

int main(){
	int n;
	int a = 1, b = 1, c;

	scanf("%d",&n);
	while(n > 0){
		c=a+b;
		a=b;
		b=c;
		n--;
	}
	
	printf("%d\n",a);
	return 0;
}



Measured memory_bytes: 2148
import java.util.*;
class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  long n=sc.nextLong();
  long a=sc.nextLong();
  long b=sc.nextLong();
  System.out.println((n/(a+b))*a+(((n%(a+b))>a)?a:n%(a+b)));
}
}


Measured memory_bytes: 21972
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <list>
#include <math.h>
#include <vector>
#include <algorithm>
#include<iomanip>
#include <unordered_map> 
#include <queue>
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pp;
 
#define MOD 1000000007
 
 
int main() {
  
  ll N;
  ll A[3*100000+10];
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i]; 
  }
  
  int tmp[64] = {0};
  for (int i = 0; i < 64; i++) {
    tmp[i] = 0;
  }
  for (int i = 0; i < N; i++) {
	for (int j = 0; j < 64; j++) { 
      if(((A[i] >> j) & 0x1) == 0x1) {
         tmp[j]++;
      }
    }
  }
  
  ll sum = 0;
  ll base = N * (N-1) / 2;
  for (int i = 0; i < 64; i++) {
    if(tmp[i] != 0){
      ll a = (ll)(tmp[i]) * (ll)(tmp[i] - 1) / 2;
      ll b = (ll)(N - tmp[i]) * (ll)(N - tmp[i] - 1) / 2;
      if (a <= 0) a = 0;
      if (b <= 0) b = 0;
      ll t = base - a - b;
      //cout << i << ":" << base << ":" << a << ":" << b << ":" << t << endl;
      if (t > 0) {
	    sum += (((ll)((1l << i)%MOD) * (t % MOD))%MOD);
      }
      sum %= MOD;
    }
  }
  
  cout << (sum % MOD);
  
  //for float, double precision
  //cout << std::fixed << setprecision(15);
  return 0;
 
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }
    
    sort(all(data));
    cout << data[n/2] - data[n/2-1] << endl;

    return 0;
}


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

int main(void){
  
  int N,A;
  map<int,int> mp{};
  cin >> N;
  
  for(int i=0;i<N;i++){
      cin >> A;
      mp[A] = 1;
  }
  
  if(mp.size() == N){
      cout << "YES" << endl;
  }
  else{
      cout << "NO" << endl;
  }
}

Measured memory_bytes: 12956
#include <stdio.h>

int main(void){
  int d;
  while(scanf("%d", &d) != EOF){
    int area = 0;
    int i;
    for(i=d; i<600; i+=d){
      area += i*i*d;
    }

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

  return 0;
}

Measured memory_bytes: 0
//Beg 132 B.cpp
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
#define int long long
bool seclar(int a,int b,int c)
{
    int ma = max(a,b);
    ma = max(ma, c);
    int mi= min(a,b);
    mi = min(mi,c);
    if(ma!=b&&mi!=b)
    {
        return true;
    }
    else
    {
        return false;
    }
}
int cousec(vector<int> &v,int n)
{
    int ans=0;
    for(int i=1;i<n-1;i++)
    {
        if(seclar(v[i-1],v[i],v[i+1]))ans++;
    }
    return ans;
}

int32_t main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    cout<<cousec(v,n);
    return 0;
}


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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
	cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	cout << head;
	if (sizeof...(tail) != 0) cout << " ";
	print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
	for (auto& a : vec) {
		cout << a;
		if (&a != &vec.back()) cout << " ";
	}
	cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
	for (auto& vec : df) {
		print(vec);
	}
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	auto N = IN();
	auto A = IN();
	print(N % 500 <= A ? "Yes" : "No");
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val t = readLine()!!.toInt()
    if (t in 400..599) {
    	println(8)
    } else if (t in 600..799) {
      	println(7)
    } else if (t in 800..999) {
      	println(6)
    } else if (t in 1000..1199) {
      	println(5)
    } else if (t in 1200..1399) {
      	println(4)
    } else if (t in 1400..1599) {
      	println(3)
    } else if (t in 1600..1799) {
      	println(2)
    } else {
    	println(1)
    }
}

Measured memory_bytes: 34412
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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; }
int main()
{
  int a,g; cin >> a >> g;
  cout << 2*g - a << "\n";
  return 0;
}


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

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int n, m, x, y, ans = 0;
    cin >> n >> m;
    UnionFind uf(n);
    int a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    for(int i = 0; i < m; ++i) {
        cin >> x >> y;
        x--, y--;
        uf.unite(x, y);
    }
    vector<vector<int>> v(n);
    for(int i = 0; i < n; ++i) v[uf.root(i)].push_back(a[i]);
    for(int i = 0; i < n; ++i) sort(v[i].begin(), v[i].end());
    for(int i = 0; i < n; ++i) {
        if(binary_search(v[uf.root(i)].begin(), v[uf.root(i)].end(), i+1)) ans++;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 6528
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb push_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
#define N 31000000
// #define M 19
 
// #define mod  11092019
#define mod1 1000000007
#define mod2 1000000009
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 2000000000000000

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

inline ll mul(ll a, ll b, ll mod) { return (long long) a*b%mod;}
inline ll add(ll a, ll b, ll mod) { return a+b < mod? a+b: a+b-mod;}
inline void Mul(ll &a, ll b, ll mod) { a = (long long) a*b%mod;}
inline ll bp(ll a, ll p, ll mod){
	ll ret;
	for(ret = 1; p; p>>=1, Mul(a, a, mod)) (p & 1) && (Mul(ret, a, mod), 1);
	return ret;
}

static inline void read(ll &x) { cin>>x;}

int main(){
	ll a, b, c; read(a), read(b), read(c);
	ll z = min({a+b, b+c, c+a});
	cout<<z<<"\n";
	return 0;
}

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

const int MAX_N = 2e5+10;
int N;
string S;
int W[MAX_N];

void solve()
{
	int rc = count(S.begin(),S.end(),'R');
	int wc = N-rc;
	int ans = min(rc,wc);
	W[1]=(S[0]=='W')?1:0;
	for(int i=2;i<=N;++i) W[i]=W[i-1]+(S[i-1]=='W');
	for(int r=0;r<=N;++r){
		//1...r r+1..N
		int wrong = max(W[r], N-r-(W[N]-W[r]));
		ans=min(ans, wrong);
	}
	cout << ans;
}

int main()
{
	cin >> N >> S;
	solve();
	return 0;
}


Measured memory_bytes: 4552
#include<bits/stdc++.h>
#define fr(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,a,b) for(int i=(a);i>=(b);--i)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
template<typename T>
inline void read(T &x){
	char c=getchar();T fh=0;bool f=false;
	while(!isdigit(c))f|=(c=='-'),c=getchar();
	while(isdigit(c))fh=(fh<<1)+(fh<<3)+(c^48),c=getchar();
	x=f?-fh:fh;
	return;
}
char s[100005];
const int mod=1e9+7;
ll p3[100005];
int main(){
    scanf("%s",s+1);
    int n=strlen(s+1);
    p3[0]=1;
    fr(i,1,n)p3[i]=(p3[i-1]*3)%mod;
    ll ans=p3[n],tmp=1;
    fr(i,1,n)
    	if(s[i]=='0')
    		ans=((ans-tmp*2*p3[n-i])%mod+mod)%mod;
		else
		    tmp=(tmp*2)%mod;
	printf("%lld\n",ans%mod);
	return 0;
}

Measured memory_bytes: 4640