akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
	int n;
	cin >> n;
	int a[n+1], c = 0;
	for(int i = 1; i < n+1; i++)
	{
		cin >> a[i];
		if(a[i] != i) c++;
	}
	if(c > 2) cout << "NO";
	else cout << "YES";
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
N = int(input())
s = []
for i in range(N):
    s.append(''.join(sorted(input())))
s.sort()
count = 0
ans = 0
for i in range(1,N):
    if(s[i]==s[i-1]):
        count  = count+1
        ans = ans+count
    else:
        count = 0

print(ans)

Measured memory_bytes: 59224
x = int(input())

if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
else:
    print(1)


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> k(M),p(M);
  vector<vector<int>> s(M,vector<int>(10));
  for (int i=0;i<M;i++){
    cin >> k[i];
    for (int j=0;j<k[i];j++){
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  for (int i=0;i<M;i++){
    cin >> p[i];
  }
  int ans=0;
  for (int bit=0;bit<(1<<N);bit++){
    bool check=true;
    for (int i=0;i<M;i++){
      int count=0;
      for (int j=0;j<k[i];j++){
        if (bit&(1<<s[i][j])){
          count++;
        }
      }
      if (count%2!=p[i]){
        check=false;
        break;
      }
    }
    if (check){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

int n,m;
ll r=0;
int x[100010];
vector<int> qq;

int main(){
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d",&x[i]);
        
    }
    sort(x,x+m);
    for(int i=0;i<m-1;i++){
        qq.push_back(x[i+1]-x[i]);
    }
    
    //for(auto itr:qq)cout<<itr<<endl;;
    sort(qq.begin(),qq.end());
    for(int i=0;i<m-n;i++)r+=qq[i];
    printf("%lld\n",r);
    
    
    
}


Measured memory_bytes: 1276
//
//  main.cpp

#include <iostream>
using namespace std;


int main(){	
	int pastamin = 1000000;
	int juicemin = 1000000;
	int input;
	for(int i=0;i<3;i++){
		cin >> input;
		pastamin = min(input,pastamin);
	}
	for(int i=0;i<2;i++){
		cin >> input;
		juicemin = min(input,juicemin);
	}
	
	cout << pastamin + juicemin - 50 << endl;
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <sstream>
#define rep2(i,x,y) for (int i = x; i < (y); ++i)
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;

int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }
  int ans = 0;
  sort(a.begin(), a.end());
  for(int i = 0; i < n; i++){
    for(int j = 0; j < i; j++){
      for(int k = 0; k < j; k++){
        if(a[j] != a[k] and a[j] != a[i] and a[j] + a[k] > a[i]) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3576
n = input()

a = map(int, raw_input().split())

ct = 0

for i in range(len(a) - 1):
    if i + 1 == a[i]:
        a[i], a[i + 1] = a[i + 1], a[i]
        ct += 1

key = len(a)
if a[key - 1] == key:
    a[key - 1], a[key - 2] = a[key - 1], a[key - 2]
    ct += 1

print ct

Measured memory_bytes: 11328
#include<iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
const long long int mod1=1000000007;
const long long int mod2 = -1;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back                                       
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define ordered1 tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define inf mod1
ll gcd(ll a, ll b){
    ll c;
     while(b){
        c = b;
        b = a % b;
        a = c;
     }
     return a;
}
ll power1(ll a, ll b){
     if(b == 0) return 1;
     else if(b % 2) return a * power1(a, b - 1);
     else {
        ll temp = power1(a, b / 2);
        return temp * temp;
     }
}
ll power2(ll a, ll b, ll m){
     a %= m;
     if(b == 0) return 1;
     else if(b % 2) return (a * power2(a, b - 1, m)) % m;
     else{
        ll temp = power2(a, b / 2, m);
        return (temp * temp) % m;
     }
}
ll mod(ll x, ll p){
return (x % p + p) % p;
}
ll lcm(ll x, ll y){
return (x * y)/gcd(x, y);
}
ll modi(ll x){
    return power2(x, mod1 - 2, mod1);
}
ll fac[100005];
ll comb(ll n, ll r){
    if(n < r){
        return 0;
    }
    else if(n == r){
        return 1;
    }
    return (fac[n] * modi(fac[r] * fac[n - r] % mod1)) % mod1;
}
int main(){
	fast;
	ll h1 = 1;
	//cin >> h;
    fac[0] = 1;
    for(int i = 1; i < 100005; i++){
        fac[i] = fac[i - 1] * i % mod1;
     }
    while(h1--){
        ll n, k;
        cin >> n >> k;
        ll a[n];
        for(int i = 0; i < n; i++){
            cin >> a[i];
        }
        ll out = 0;
        sort(a, a + n);
        for(int i = 0; i < n; i++){
            out += (a[i] * comb(i, k - 1) % mod1);
            out %= mod1;
            out -= (a[i] * comb(n - i - 1, k - 1)) % mod1;
            out %= mod1;
        }
        while(out < 0){
            out += mod1;
        }
        cout << out << endl;
   }
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while (scan.hasNext()) {

            long a = scan.nextLong();
            long b = scan.nextLong();
            long X = a;
            long Y = b;
            long Z;

            while (X % Y != 0) {
                Z = X;
                X = Y;
                Y = Z % Y;
            }
            System.out.println(Y + " " + a / Y * b);
        }
    }
}



Measured memory_bytes: 26220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h,w;
  int x,y;
  int nx,ny;
  int count=0;
  cin>>h>>w;
  int f[h][w];
  vector<int>xx={1,0,-1,0};
  vector<int>yy={0,1,0,-1};
  int inf=10000000;
  queue<pair<int,int>>q;
  char c;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>c;
      if(c=='.'){
        f[i][j]=inf;
      }
      else {
        f[i][j]=0;
        count++;
      }
    }
  }
  q.push(pair(0,0));
  f[0][0]=0;
  while(q.size()>0){
    tie(x,y)=q.front();
    q.pop();
    for(int i=0;i<4;i++){
      nx=x+xx[i];
      ny=y+yy[i];
      if(nx<0||ny<0||nx>=w||ny>=h)continue;
      if(f[ny][nx]==0)continue;
      if(f[ny][nx]>f[y][x]+1){
        f[ny][nx]=f[y][x]+1;
        q.push(pair(nx,ny));
      }      
    }
  }
  if(f[h-1][w-1]==inf){
    cout<<-1;
  }else{
    cout<<h*w-f[h-1][w-1]-count-1;
  }
  
}

Measured memory_bytes: 3636
import sys

# sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n, a, b = read_int_list()
    x = read_int_list()
    res = 0
    for i in range(1, n):
        d = x[i] - x[i - 1]
        effort = min(a * d, b)
        res += effort
    print(res)


main()


Measured memory_bytes: 14480
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    x=inp()
    n=x//100
    for i in range(n+1):
        y=x-100*i
        if y<=i*5:
            print(1)
            return
    print(0)

if __name__ == "__main__":
    main()

Measured memory_bytes: 39148
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
// fold was added in D 2.071.0.
template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
        static if (S.length < 2) {
            return reduce!fun(seed, r);
        } else {
            return reduce!fun(tuple(seed), r);
        }
    }
}

void main() {
    readln.chomp.to!(dchar[]).sort().group.all!"a[1]%2==0".pipe!(a => a?"Yes":"No").writeln;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
STAGE = [input() for _ in range(H)]

ccheck = 0
for i, l in enumerate(STAGE):
	ccheck |= int(l.replace("#", "1").replace(".", "0"), 2)

for l in STAGE:
	if "#" not in l:
		continue
	for f, c in zip(format(ccheck, "b").zfill(W), l):
		if "1" == f:
			print(c, end="")
	print("")


Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2000+10,mod=1e9+7,inf=1e9+10;
int dp[M][M],rev[M*M],fact[M*M];
int pw(int x,int y)
{
	if(y==0)return 1;
	int tmp=pw(x,y/2);
	if(y%2==0)return (tmp*tmp)%mod;
	return ((tmp*tmp)%mod*x)%mod;
}
int C(int n,int r)
{
	int tmp=fact[r]*fact[n-r];
	tmp%=mod;
	tmp=pw(tmp,mod-2);
	tmp*=fact[n];
	tmp%=mod;
	return tmp;
}
int32_t main()
{	
	int n,k;
	cin>>n>>k;
	fact[0]=1;
	for(int i=1;i<=4e6;i++)fact[i]=fact[i-1]*i,fact[i]%=mod,rev[i]=pw(fact[i],mod-2);
	if(k==1)return cout<<1,0;
	for(int i=n+1;i>=1;i--)
	{
		for(int j=i;j>=1;j--)
		{
			if(i==n+1 && j==n+1)
			{
				dp[i][j]=1;
				continue;
			}
			dp[i][j]+=dp[i+1][j];
			dp[i][j]%=mod;
			if(n*k-(i-1)-((j-1)*(k-1))-1>=0)
				dp[i][j]+=C(n*k-(i-1)-((j-1)*(k-1))-1,k-2)*dp[i][j+1];
			dp[i][j]%=mod;
			//cout<<c[n*k-(i-1)-((j-1)*(k-1))][k-1]<<" "<<i<<" "<<j<<" "<<dp[i][j]<<endl;
		}
	}
	cout<<(dp[1][1]*fact[n])%mod;
}	

Measured memory_bytes: 94848
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>
#include <random>
#include <cmath>
using namespace std;
using namespace __gnu_pbds;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define uid uniform_int_distribution<lli>
#define lli long long int
#define ff first
#define ss second
#define pb push_back
#define popf pop_front()
#define popb pop_back()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define forr(x,arr) for(auto& x:arr)
#define sz(x) (x.size())
#define mod 1000000007
#define INF 1000000000000000010
#define vi vector<int>
#define vlli vector<lli>
#define endl "\n"
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

template <class my>
inline my aabs (const my &a)   { return (a > 0)  ? a : -a;         }
inline lli gcd(lli a, lli b)   { return (b == 0) ? a : gcd(b,a%b); }
inline lli LSOne(lli k)        { return (k&(-k));                  }

inline int inv(lli o, int m = mod) {
  int b = m, u = 0, v = 1, t, a=o%m;
  while (a) {
    t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  if (u < 0) u += m;
  return u;
}
inline int add(const int &a, const int &b, int m=mod) { return a + b >= m ? a + b - m : a + b; }
inline int sub(const int &a, const int &b, int m=mod) { return a - b < 0 ? a - b + m : a - b; }
inline int mul(const int &a, const int &b, int m=mod) { return int(a * 1ll * b % m); }
inline int pow(int a, int b, int m=mod) {
    int ans = 1;
    a=((a%m)+m)%m;
    while (b) {
        if (b & 1) ans = mul(ans, a, m);
        a = mul(a, a, m);
        b >>= 1;
    }
    return ans;
}

int fact[100010], invfact[100010];
int ans=1, k;

void dfs(int v, int p, vector<vi> &adj)
{
    ans=mul(ans,fact[k-2]);
    ans=mul(ans,invfact[k-adj[v].size()-1]);
    forr(x,adj[v]) if(x!=p) dfs(x,v,adj);
}

void solve()
{
    lli n, m, t, q, temp=0, u=0, v=0, ans1=0, ans2=0, val=0, sum=mod;
    cin>>n>>k;
    vector<vector<int>> adj(n+5);
    fol(i,1,n)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    fol(i,0,n+1) if(adj[i].size()>=k) {cout<<0<<endl; return;}
    ans=fact[k];
    ans=mul(ans,invfact[k-adj[1].size()-1]);
    forr(x,adj[1]) dfs(x,1,adj);
    cout<<ans<<endl;


}

int main()
{
    fastio cout<<endl;
    cout << fixed << setprecision(7);
    fact[0]=1;
    fol(i,1,100010) fact[i]=mul(fact[i-1],i);
    fol(i,0,100010) invfact[i]=inv(fact[i]);
    int t=1;
    //cin>>t;
    while(t--)
        solve();
}

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

using ll = long long;

int main() {
    ll n, k, cycle_size = 0, cycle_start = 0;
    cin >> n >> k;
    vector<ll> arr(n + 1);
    vector<bool> vis(n + 1, false);

    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }

    ll curr = 1;
    while (!vis[curr]) {
        vis[curr] = true;
        curr = arr[curr];
    }
    cycle_start = curr;
    vis.assign(n + 1, false);

    curr = cycle_start;

    while (!vis[curr]) {
        vis[curr] = true;
        curr = arr[curr];
        cycle_size++;
    }

    curr = 1;
    while (k > 0 && curr != cycle_start) {
        curr = arr[curr];
        k--;
    }
    k %= cycle_size;

    while (k != 0) {
        curr = arr[curr];
        k--;
    }

    if (curr == 0) curr = 1;
    cout << curr << endl;

}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int K,A,B;
    cin>>K>>A>>B;

    if(A>=K){
        cout<<1<<endl;
        return 0;
    }

    if(A<=B){
        cout<<-1<<endl;
        return 0;
    }

    cout<<(K-A+A-B-1)/(A-B)*2+1<<endl;
    return 0;
}


Measured memory_bytes: 256
#define TEST_MODE true

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;             \
                                   c > 0 ? i < b : i > b; \
                                   i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long

#ifdef LOCAL_ENV

#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x)
#define dumpl(x) dump(x) << endl
#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#endif

#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#endif

int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep))
	{
		v.push_back(buffer);
	}
	return v;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
	return accumulate(begin, end, 0ll);
}

template<typename T>
T gcd(T a, T b)
{
	T c;
	while (a != 0) {
		c = a; a = b%a;  b = c;
	}
	return b;
}

class Solver {
public:
	int pow_vec[3] = { 1, 100, 10000 };
	int D, N;
	
	void solve() {
		cin >> D >> N;
		int a = (int)round(pow(100, D));
		int b = (N == 100 ? 101 : N);
		cout << a * b << endl;
	}
};

signed main()
{
	srand((unsigned int)time(NULL));
	cout << fixed << setprecision(20);
	auto ptr = new Solver();
	ptr->solve();
	delete ptr;
	//while (true) {
	//	if (cin.eof() == true) break;
	//	auto ptr = new Solver();
	//	ptr->solve();
	//	delete ptr;
	//}
	return 0;
}

// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;

// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;

// #define cin mycin
// #define cout mycout
// #define endl '\n'

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin>>vec.at(i);
    }
    sort(vec.begin(),vec.end());
    double a=vec.at(0);
    for(int i=0;i<n-1;i++){
        a=(a+vec.at(i+1))/2;
    }
    cout<<a<<endl;
}


Measured memory_bytes: 256
S = list(input())

S_rev = S[::-1]

key_front = [False] * 7

key_back = [False] * 7

s_key = ["k", "e", "y", "e", "n", "c", "e"]
s_key_rev = s_key[::-1]

i = 0
while S[i] == s_key[i] and i < 6:
    key_front[i] = True
    i += 1

i = 0
while S_rev[i] == s_key_rev[i] and i < 6:
    key_back[i] = True
    i += 1
ans = 0
for b in key_front:
    if b:
        ans += 1
for b in key_back:
    if b:
        ans += 1

if ans >= 7:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
(function(input) {
  var p = input.replace(/\n$/, '').split('\n');
  var n = p.length;
  for (var i = 0; i < n; i++) {
    var a = p.shift().split(',').map(Number);
    var v2 = a.pop();
    var v1 = a.pop();
    console.log(cross(a, v1, v2));
  }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function cross(a, v1, v2) {
  var l = [];
  for (var i = 0; i < a.length; i++) {
    l[i] = a[i];
    if (i > 0) {
      l[i] += l[i - 1];
    }
  }
  var x = l[l.length - 1] * v1 / (v1 + v2);
  //console.log(l, x);
  var c = 1;
  for (i = 0; i < l.length; i++) {
    if (x > l[i]) {
      c = i + 2;
      continue;
    }
    return c;
  }
}

Measured memory_bytes: 7644
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
int main(void) {
int n;
scanf("%d",&n);
int count=0;
int array[n];
for (int i=0;i<n;i++){
    scanf("%d",&array[i]);
}
for (int i=1;i<n-1;i++){
    if ((array[i]>=array[i-1] && array[i]<=array[i+1])
     || (array[i]<=array[i-1] && array[i]>=array[i+1]))
        count++;

}
printf("%d",count);
 return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,num=0;
  string X;
  cin>>N>>X;
  REP(i,N){
    if(X[i]=='1') num++;
  }
  
  ll P[N+1],Q[N+1],PP=0,QQ=0;
  P[0]=1;
  Q[0]=1;
  for(int i=1; i<=N; ++i){
    if(num>1) P[i]=P[i-1]*2%(num-1);
    Q[i]=Q[i-1]*2%(num+1);
    if(X[N-i]=='1'){
      if(num>1) PP+=P[i-1];
      QQ+=Q[i-1];
    }
    if(num>1) PP%=num-1;
    QQ%=num+1;
  }
  
  for(int i=0; i<N; ++i){
    ll cnt=num;
    if(X[i]=='1') cnt--;
    if(X[i]=='0') cnt++;
    if(cnt==0){
      co(0);
      continue;
    }
    
    ll L=0;
    if(cnt==num-1){
      if(X[i]=='1') L=PP-P[N-1-i];
      else L=PP+P[N-1-i];
      L%=num-1;
      if(L<0) L+=num-1;
    }
    else{
      if(X[i]=='1') L=QQ-Q[N-1-i];
      else L=QQ+Q[N-1-i];
      L%=num+1;
      if(L<0) L+=num+1;
    }
    if(L==0) co(1);
    else{
      ll ans=1;
      while(L>0){
        cnt=0;
        for(int j=0; j<30; ++j){
          if(L&(1<<j)) cnt++;
        }
        L%=cnt;
        ans++;
      }
      co(ans);
    }
  }
  
  return 0;
}

Measured memory_bytes: 6776
//ITNOA
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <cassert>

using namespace std;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;


#define rep(i, s, e) for(int i = s; i < e; i ++)
#define X first
#define Y second

typedef long long ll;
typedef long double ld;

const int maxN = 200*1000 + 5;
const int mod = 1000*1000*1000 + 7;
const int base = 701;
const int SQ = 500;
const int maxL = 20;

int deg[maxN];
vector<int> a[maxN], ar[maxN];
int ans[maxN];

int get_mex(int v) {
	vector<int> d;
	for(int i = 0; i < a[v].size(); i ++)
		if(ans[a[v][i]] > -1)
			d.push_back(ans[a[v][i]]);
	sort(d.begin(), d.end());
	d.resize(unique(d.begin(), d.end()) - d.begin());

	int mex = 0;
	while(mex < d.size() && d[mex] == mex) mex ++;
	return mex;
}

bool check(int v) {
	for(int i = 0; i < a[v].size(); i ++)
		if(ans[a[v][i]] == -1)
			assert(false);
	if(ans[v] != get_mex(v))
		return false;
	return true;
}


int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	for(int i = 0; i < n; i ++) {
		int x; cin >> x;
	   	x --;
		if(x == i) {
			cout << "IMPOSSIBLE" << endl;
			return 0;
		}
		deg[x] ++;
		a[x].push_back(i);
		ar[i].push_back(x);
	}

	queue<int> q;
	for(int i = 0; i < n; i ++) 
		if(deg[i] == 0)
			q.push(i);

	memset(ans,-1,sizeof ans);
	while(q.size()) {
		int v = q.front(); q.pop();
		ans[v] = get_mex(v);	
	
		for(int i = 0; i < ar[v].size(); i ++) {
			deg[ar[v][i]] --;
			if(deg[ar[v][i]] == 0)
				q.push(ar[v][i]);
		}
	}

	for(int i = 0; i < n; i ++) {
		if(deg[i] == 0) continue;

		vector<int> pat;
		int v = i;
		while(deg[v]) {
			pat.push_back(v);
			deg[v] --;
			for(int i = 0; i < a[v].size(); i ++) 
			   if(ans[a[v][i]] == -1) {
			   		v = a[v][i];
					break;
			   }
		}
	 		
		int mex = get_mex(pat[0]);
		ans[pat[0]] = mex;
		for(int i = pat.size()-1; i > 0; i --)
			ans[pat[i]] = get_mex(pat[i]);
					
		bool bad = false;
		for(int i = 0; i < pat.size(); i ++)
			if(!check(pat[i])) {
				bad = true;
				break;
			}

		if(!bad) continue;
	    bad = false;

		ans[pat[1]] = mex;
		ans[pat[0]] = get_mex(pat[0]);
		for(int i = pat.size()-1; i > 1; i --)
			ans[pat[i]] = get_mex(pat[i]);
		
		for(int i = 0; i < pat.size(); i ++)
			if(!check(pat[i])) {
				bad = true;
				break;
			}
		if(bad) { 
			cout << "IMPOSSIBLE" << endl;
			return 0;
		}
	}

	cout << "POSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 23800
#include<bits/stdc++.h>
#define now edge[i].v
#define go(x) for(int i=head[x];i;i=edge[i].nxt)
#define rep(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
const int sz=1e5+7;
int n;
int u,v,cnt;
bool flag;
bool vis[sz];
int head[sz];
struct Edge{
	int v,nxt;
}edge[sz<<1];
void add(int u,int v){
	edge[++cnt]=(Edge){v,head[u]};head[u]=cnt;
	edge[++cnt]=(Edge){u,head[v]};head[v]=cnt;
}
void dfs(int x,int fa){
	go(x) if(now!=fa){
		dfs(now,x);
		if(!vis[x]&&!vis[now]) vis[x]=vis[now]=1;
	}
}
int main(){
	scanf("%d",&n);
	rep(i,1,n-1){
		scanf("%d%d",&u,&v);
		add(u,v);
	}
	dfs(1,0);
	rep(i,1,n) flag|=!vis[i];
	if(flag) printf("First\n");
	else printf("Second\n");
} 

Measured memory_bytes: 2304
// #[warn(dead_code)]
// const TOP: u64 = 1000000007;

pub struct Poper<'a> {
	iter: std::str::SplitWhitespace<'a>,
}

impl<'a> Poper<'a> {
	pub fn new(iter: std::str::SplitWhitespace<'a>) -> Poper {
		Poper { iter: iter }
	}
	pub fn read<T: std::str::FromStr>(&mut self) -> T
	where
		<T as std::str::FromStr>::Err: std::fmt::Debug,
	{
		self.iter.next().unwrap().parse().unwrap()
	}
}

fn main() {
	let input = {
		use std::io::Read;
		let mut s = String::new();
		std::io::stdin().read_to_string(&mut s).unwrap();
		s
	};
	let mut iter = Poper::new(input.split_whitespace());

	let n: u64 = iter.read();
	let m: u64 = iter.read();

	let mut l: u64 = 1;
	let mut r: u64 = n;
	for _ in 0..m {
		let li: u64 = iter.read();
		let ri: u64 = iter.read();
		if l < li {
			l = li;
		}
		if r > ri {
			r = ri;
		}
	}
	let a = if l > r { 0 } else { r - l + 1 };
	println!("{}", a);
}


Measured memory_bytes: 6396
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include<utility>
using namespace std;
using ll = long long;

int main()
{
	ll h, w,ans=INT32_MAX;
	cin >> h >> w;
	for (int i = 1; i < h; i++) {
		ll memo[3];
		memo[0] = i * w;
		if (w % 2 == 0 || (h - i) % 2 == 0) {
			memo[1] = w * (h - i) / 2;
			memo[2] = memo[1];
		}
		else {
			memo[1] = min(w, h - i)*(max(w, h - i) / 2);
			memo[2] = min(w, h - i)*(max(w, h - i) / 2+1);
		}
		ll asd = max(memo[0], max(memo[1], memo[2])) - min(memo[0], min(memo[1], memo[2]));
		ans = min(ans, asd);
}
	for (int i = 1; i < w; i++) {
		ll memo[3];
		memo[0] = i * h;
		if (h % 2 == 0 || (w - i) % 2 == 0) {
			memo[1] = h * (w - i) / 2;
			memo[2] = memo[1];
		}
		else {
			memo[1] = min(h, w - i)*(max(h, w - i) / 2);
			memo[2] = min(h, w - i)*(max(h, w - i) / 2 + 1);
		}
		ll asd = max(memo[0], max(memo[1], memo[2])) - min(memo[0], min(memo[1], memo[2]));
		ans = min(ans, asd);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

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



Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define N_PRIME 1000000007
#define ll int64_t


int main(void){
    int N,K;
    
    cin >> N >> K;
    
    ll ret = 1;
    
    ret = K;
    for(int i = 1 ; i < N ; i++ )
        ret *= (K-1);
    
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void read(int &x){
	char ch=getchar();x=0;
	for (;ch==' '||ch=='\n';ch=getchar());
	for (;ch!=' '&&ch!='\n';x=x*10+ch-'0',ch=getchar()); 
}
void write(int x){
	if (x>9) write(x/10);
	putchar(x%10+'0'); 
}
void output(int x,int y){
	write(x),putchar(' '),write(y),puts("");
}
int n,a[200004],b[200004],s[600004],z[600004];
void Z(){
    int l=0,r=0;
    for (int i=1;i<3*n;i++){
        if (i>r){
            l=i,r=i;
            while (r<3*n && s[r-l]==s[r]) r++;
            z[i]=r-l,r--;
		}else{
            int k=i-l;
            if (z[k]<r-i+1) z[i]=z[k];
            else{
                l=i;
                while (r<3*n && s[r-l]==s[r]) r++;
                z[i]=r-l,r--;
        	}
        }
    } 
}
int main(){
	read(n);
	for (int i=0;i<n;i++) read(a[i]);
	for (int i=0;i<n;i++) read(b[i]);
	swap(a,b);
	if (n==1){
		output(0,a[0]^b[0]);return 0;
	}
	for (int i=0;i<n;i++)
		s[i]=a[i]^a[(i+1)%n];
	for (int i=0;i<n;i++)s[i+n]=b[i]^b[(i+1)%n],s[i+2*n]=b[i]^b[(i+1)%n];
	Z();
	for (int i=0;i<n;i++)
		if (z[i+n]>=n)
			output(i,b[i]^a[0]);
}

Measured memory_bytes: 9728
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto as = readln.split.to!(int[]);
    auto cs = new long[](N);
    foreach (long i; 0..N) {
        auto a = as[i];
        if (i - (a-1) < 0) continue;
        ++cs[i-(a-1)];
    }
    long r;
    foreach (ii, a; as) {
        auto i = ii.to!long;
        if (i + a + 1 >= N) continue;
        r += cs[i+a+1];
    }
    writeln(r);
}

Measured memory_bytes: 12512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
ll MOD = 1e9+7;
int main()
{
    int a, b;
    cin >> a >> b;
    if(a >= 10 || b >= 10)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << a * b << endl;
    }
}


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

#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define TC int tc; cin >> tc; while(tc--)

using namespace std;

const int INF = 1e9 + 7;


int main(void)
{
	FAST
	ll k; cin >> k;
	if(k%2==0 || k%5 == 0) {
		cout << -1 << '\n';
		return 0;
	}
	ll a = 7, cnt = 1;	

	while(a % k != 0){
		cnt++;
		a = (a*10 + 7)%k;
	}

	cout << cnt << '\n';

	return 0;
}


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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CN cout<<"No\n"
#define CY cout<<"Yes\n"

using namespace std;
using ll = long long;
ll ct=0;
void dfsu(ll s,vector<ll>v[],vector<ll>&vis)
{
    vis[s]=1;
    ct++;
    for(auto e:v[s])
    {
        if(vis[e]==0)
        {
            dfsu(e,v,vis);
        }
    }
}
ll dfs(vector<ll>v[],ll n,vector<ll>&vis)
{
    ll res=0;
    for(int i=0;i<n;i++)
    {
        if(vis[i]==0)
        {
            ct=0;
            dfsu(i,v,vis);
            res=max(res,ct);
        }
    }
    return res;
}
void solve()
{
    ll n; cin>>n;
    ll m; cin>>m;
    vector<ll>v[n];
    set<pair<ll,ll>>s;
    rep(i,m)
    {
        ll x,y; cin>>x>>y;
        if(s.count({x-1,y-1})==1||s.count({y-1,x-1})==1)
            continue;
        s.insert({x-1,y-1});
        v[x-1].pb(y-1);
        v[y-1].pb(x-1);
    }
    vector<ll>vis(n,0);
    ll ans=dfs(v,n,vis);
    cout<<ans<<"\n";
}
int main()
{
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    int t;t=1;
 //  cin>>t;
    while(t--)
        {solve();}
    return 0;
}

Measured memory_bytes: 37392
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=5e4,mod=1e9+7,M=2e5+10;
ll fac[N],inv[N],dp[4010][4010],a[M],b[M],n,ans;
ll power_mod(ll x,ll y){
	ll res=1;
	while(y){
		if(y&1)res=res*x%mod;
		x=x*x%mod;
		y>>=1;	
	}
	return res;
}
ll C(int x,int y){
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main(){
	fac[1]=1;
	for(int i=2;i<=40000;i++)fac[i]=fac[i-1]*i%mod;
	inv[40000]=power_mod(fac[40000],mod-2);
	for(int i=39999;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d %d",&a[i],&b[i]);
		dp[2001-a[i]][2001-b[i]]++;
	}
	for(int i=1;i<=4001;i++){
		for(int j=1;j<=4001;j++){
			dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
			dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
		}
	}
	for(int i=1;i<=n;i++)ans=(ans+dp[2001+a[i]][2001+b[i]])%mod;
	for(int i=1;i<=n;i++)ans=(ans-C(2*(a[i]+b[i]),2*a[i])+mod)%mod;
	printf("%lld\n",ans*power_mod(2,mod-2)%mod);
	return 0;
}

Measured memory_bytes: 129664
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main(){
  char a[11];
  scanf("%s", a);
  
  int length = strlen(a);
  int bits[length] = {};
  for (int i=0; i<length; i++){
    bits[i] = 1;
    if (a[i] == 'A') continue;
    if (a[i] == 'T') continue;
    if (a[i] == 'C') continue;
    if (a[i] == 'G') continue;
    bits[i] = 0;
  }
  
  int max_sum = 0;
  int now_sum = 0;
  for (int i=0; i<length; i++){
    if (bits[i] == 0) {
      max_sum = max(max_sum, now_sum);
      now_sum = 0;
      continue;
    }
    now_sum++;
  }
  
  max_sum = max(max_sum, now_sum);
  
  printf("%d", max_sum);
  return 0;
}

Measured memory_bytes: 128
N,M = map(int,input().split())
ln = []
for i in range(N):
  ln.append(list(map(int,input().split())))
lm = []
for i in range(M):
  lm.append(list(map(int,input().split())))

l_ans = [] 
for i in range(N):
  a,b = ln[i][0],ln[i][1]
  dis = float("inf")
  ch = 0
  for j in range(M):
    c,d = lm[j][0],lm[j][1]
    if dis > abs(a-c)+abs(b-d):
      dis = abs(a-c)+abs(b-d)
      ch = j+1
  l_ans.append(ch)

for i in l_ans:
  print(i)

Measured memory_bytes: 3064
program sample
    implicit none
  
    integer(8) :: i,j,m,n,x,b,c
    integer(8),allocatable :: a(:),y(:)
  
    read(*,*) n,x
    allocate(a(n))
    read(*,*)a
    m=0
    if(a(1)>x)then
        m=a(1)-x
        a(1)=x
    end if
    do i=1,n-1
        
        b=a(i)+a(i+1)
        if(b>x)then
            c=b-x
            m=m+c
            a(i+1)=a(i+1)-c
        end if
        
    end do



    write(*,*) m
  
    stop
end program sample
  



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

int gcd(int a, int b){
    if(b==0) return a;
    else return gcd(b, a%b);
}

int gcds(vector<int> x){
    int ans = x[0];
    for(int i = 1; i < (int)x.size(); i++)
    {
        ans = gcd(ans, x[i]);
    }
    return ans;
}

int main(){
    string s[3];
    for(int i = 0; i < 3; i++)
    {
        cin >> s[i];
    }
    cout << 'A';
    cout << s[1][0];
    cout << 'C' << endl;

    
    return 0;
}

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

int main(){
    map<string,int> M;
    M["SUN"] = 7;
    M["MON"] = 6;
    M["TUE"] = 5;
    M["WED"] = 4;
    M["THU"] = 3;
    M["FRI"] = 2;
    M["SAT"] = 1;
    string S;
    cin>>S;
    cout<<M[S]<<endl;
    return 0;
}

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


using namespace std;

typedef long long ll;

int main() {
	int a, b;
	cin >> a >> b;

	if (a > b) {
		swap(a, b);
	}

	for (int i = 0; i < b; i++) {
		cout << a;
	}
}

Measured memory_bytes: 256
/*bismillah ->                                                                                                         << Suirkhanov Meyirlan >>
  GL HF


                                                                                                                      42

    bless my code =)
                                                                                                            NEVER FOLLOW YOUR RULES :D HAHAHAHA
*/


///scanf ("%d%d", &x, &y);
///printf("%d", &a)

#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));
#define pii pair < int , int >
#define pll pair < ll, ll >
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll N = 1e6 + 7;
const ld pi = 3.14159265359;
const int INF = 1e9 + 7;
const double eps = 1e-9;

const int xi[4] = {-1, 0, +1, 0};
const int yj[4] = {0, +1, 0, -1};
const int xxi[4] = {+1, 0, -1, 0};
const int yyj[4] = {0, -1, 0, +1};

ll n, ans;

bool check(int x){
  int cnt = 0;
  for(int i = 1; i <= x; i++){
    if(x % i == 0){
      cnt++;
    }
  }
  if(cnt == 8){
    return 1;
  }
  return 0;
}

int main(){

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

  fast
  randoperation;

  ///           ||
  ///start here \/

  cin >> n;

  for(int i = 1; i <= n; i++){
    if(i % 2 == 1){
      if(check(i)){
        ans++;
      }
    }
  }

  cout << ans;
}


Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



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

    long long K;cin >> K;
    if(K % 2 == 0 || K % 5 == 0){
        cout << -1 << endl;
        return 0;
    }
    long long ans = 0;
    long long amari = 0;
    while(true){
        ans++;
        amari = amari*10+7;
        amari %= K;
        if(amari % K == 0) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define re cin>>
#define pr cout<<
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)


const int N=2e6+5;
const int mod=1e9+7;

bool vis[1000006];
int main(){
      int rem=0;
      int k,at=0;
      cin>>k;
      while(1){
            at++;
            rem=(rem*10+7)%k;
            if(vis[rem]) {
                  cout<<-1;
                  return 0;
            }
            vis[rem]=1;
            if(!rem) {
                  cout<<at;
                  return 0;
            }
      }
      return 0;
}

Measured memory_bytes: 4608
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

int main(){
	ll d ; cin >> d ;
	vll c(26) ;
	for(auto &i:c) cin >> i ;
	vvll di(d,vll(26)) ;
	for(int i=0;i<d;i++) for(int j=0;j<26;j++) cin >> di.at(i).at(j) ;
	vll last(26,-1) ;
	ll sum = 0 ;
	for(int i=0;i<d;i++){
		ll mx = -INF ;
		ll contest = -1 ;
		ll dec = 0 ;
		for(int j=0;j<26;j++){
			dec += c.at(j)*(i-last.at(j)) ;
		}
		for(int j=0;j<26;j++){
			if(ll tmp=di.at(i).at(j)-dec+c.at(j)*(i-last.at(j));tmp>=mx){
				if(contest=-1||c.at(j)>c.at(contest)){
					contest = j ;
					mx = tmp ;
				}
			}
		}
		cout << contest+1 << endl ;
		sum += mx ;
		// ll t ; cin >> t ;
		// t-- ;
		// last.at(t) = i ;
		// sum += di.at(i).at(t) ;
		// for(int j=0;j<26;j++){
			// sum -= c.at(j)*(i-last.at(j)) ;
		// }
		//cout << sum << endl ;
	}
}

Measured memory_bytes: 3716
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

string s;
llong ans;

int main() {
    cin >> s;

    llong cnt = 0;
    for (int i = s.length() - 1; i >= 0; i--) {
        if (i > 0 && s[i] == 'C' && s[i - 1] == 'B') {
            cnt++;
            i--;
        }
        else if (s[i] == 'A') {
            ans += cnt;
        }
        else {
            cnt = 0;
        }
    }

    cout << ans << endl;

    return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T1> bool chmax(T1 &a, const T1 &b) { if (a < b) { a = b; return true; } return false; }
template<class T1> bool chmin(T1 &a, const T1 &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int T1,T2;
	int A1,A2;
	int B1,B2;
	cin>>T1>>T2>>A1>>A2>>B1>>B2;
	int P=(A1-B1)*T1,Q=(A2-B2)*T2;
	if(P>0)P=-P,Q=-Q;

	if(P+Q==0)
	{
		cout<<"infinity"<<endl;
		return 0;
	}
	if(P+Q<0)cout<<"0"<<endl;
	else
	{
		int T=(-P)/(P+Q);
		T*=2;
		if((-P)%(P+Q)!=0)T++;
		cout<<T<<endl;
	}
	

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define rep2(i,start,end) for(ll i = start; i < end; i++)
#define dwn(i,n) for(int i = n; i >= 0; i--)
#define dwn2(i,start,end) for(ll i = start; i >= end; i--)
#define pll pair<ll,ll>
#define mk(x,y) make_pair(x,y)
#define pdl pair<double, ll>
const ll N = 4e5 + 200;
const ll INF = 0x3f3f3f;
const ll Mode = 1e9 + 7;


int main(){
	int n,m;
	cin>>n;
	vector<double> v(n);
	double sum = 0;
	rep(i,n){
		double x;
		cin>>x;
		v[i] = 1.0/x;
	}
	rep(i,n){
		sum += v[i];
	}
	printf("%.6lf\n",1.0/sum);
	


	return 0;
}








Measured memory_bytes: 256
import itertools
import math

n = int(input())
p = []
for i in range(n):
    x, y = map(int, input().split())
    p.append([x, y])

ans = 0
sum = 0
for v in itertools.permutations(range(n), n):
    past = [0, 0]
    for i, t in enumerate(v):
        if i == 0:
            past = p[t]
            continue
        x, y = p[t]
        x_p, y_p = past
        distance = math.sqrt((x - x_p)**2 + (y - y_p)**2)
        sum += distance
        past = [x, y]

pattrun = math.factorial(n)
print(sum/pattrun)


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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> A(N, 0);
  
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    A.at(a-1) += 1;
    A.at(b-1) += 1;
  }
  
  for (int i = 0; i < N; i++) {
    cout << A.at(i) << endl;
  }
}

Measured memory_bytes: 3568
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

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

	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; ++i)
		cin >> a[i];
	a.push_back(-1);
	n += 1;
	
	int ans = 0;
	int i1 = 0;
	for(int i=0; i<n; ++i)
	{
		if(a[i] != a[i1])
		{
			ans += (i-i1)/2;
			i1 = i;
		}
	}
	
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#define llint long long

using namespace std;

llint n;
llint a[2005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a+1, a+n+1);
	
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(i >= j) continue;
			ans += lower_bound(a+1, a+n+1, a[i]+a[j]) - (a+j) - 1;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#coding:utf-8

X,N = map(int,input().split())

P = [int(y) for y in input().split()]

flag = True
x = 0
count = 0

while flag:
    x = X - count
    if(x not in P):
        print("{}".format(x))
        break

    x = X + count
    if(x not in P):
        print("{}".format(x))
        break

    count += 1

Measured memory_bytes: 9136