akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}
ll n;
string s;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    ll m = n/2;
    double ans;
    if(n%2==1){
        ans = (n+1)/2;
        ans /= n;
    }else{
        ans = n/2;
        ans /= n;

    }
    cout<<std::setprecision(10)<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define _USE_MATH_DEFINES
#include<math.h>
#include<algorithm>
#include<memory>
#include<string>
#define Rep(i,n) for(int i = 0;i < (n);i++)	
typedef long long ll;

int gcd(int a, int b) { if (b == 0)  return a;  else  return gcd(b, a % b); }
int lcm(int a, int b) { return a * b / gcd(a, b); }
void swap(int& a, int& b) { int temp = a; a = b; b = temp; return; }
int ncr(int n, int r) { int a = 1; Rep(i, r) a = (a * (n - i)) / (i + 1); return a; }
int npr(int n, int r) { int a = 1; Rep(i, r) a *= n - i; return a; }
int mod(int a, int b) { return a % b; }

int main() {
	std::string s;
	int k;
	std::cin >> k >> s;
	int m = s.size();
	if (k >= m) {
		std::cout << s << std::endl;
	}
	else {
		std::cout << s.substr(0, k) << "..." << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    int N,T,A;
    cin >> N >> T >> A;
    double H[N];
    rep(i,N) cin >> H[i];
    rep(i,N) H[i]=T-H[i]*0.006;
    double dis=INF;
    int ans=0;
    rep(i,N){
        double temp=abs(H[i]-A);
        if(temp<dis) ans=i+1,dis=temp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def main() -> None:
    X = int(input())
    ans = 0
    for i in range(1, X + 1):
        for j in range(2, X + 1):
            if i ** j > X:
                break
            elif ans < i ** j:
                ans = i ** j
    print(ans if X != 1 else 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n = int(input())
f = []
for i in range(1, int(n ** 0.5) + 1):
  if ((n % i) == 0):
    a = int(i)
    b = int(n / i)
    alen = len(str(a))
    blen = len(str(b))
    maxlen = max(alen, blen)
    f.append(maxlen)
print(min(f))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    int N,P;
    cin>>N>>P;
    int odd=0;
    int even=0;
    REP(i,N){
        int k;
        cin>>k;
        if(k%2==0)even++;
        else odd++;
    };
    LL ans=0;

    if(P==1){
        if(odd==0)ans=0;
        else{
            for(int i=1;i<=odd;i+=2){
                LL C=1;
                REP(j,i){
                    C*=(odd-j);
                    C/=(j+1);
                }
                ans+=C;
            }

            REP(i,even){
                ans*=2;
            }
        }
    }else{
        for(int i=0;i<=odd;i+=2){
            LL C=1;
            REP(j,i){
                C*=(odd-j);
                C/=(j+1);
            }
            ans+=C;
        }
        REP(i,even){
            ans*=2;
        }
    }

    cout<<ans<<endl;







    return 0;
}

Measured memory_bytes: 256
import sys

def fun(arr):
	sz = 1
	while sz < len(arr): sz *= 2

	for idx, val in enumerate(arr):
		sys.stdout.write('node '+str(idx + 1) + ': key = ' + str(val) + ', ')
		if idx > 0:
		    sys.stdout.write('parent key = ' + str(arr[(idx - 1) // 2]) + ', ')
		if idx * 2 + 1 < len(arr):
		    sys.stdout.write('left key = ' + str(arr[idx * 2 + 1]) + ', ')
		if idx * 2 + 2 < len(arr):
		    sys.stdout.write('right key = ' + str(arr[idx * 2 + 2]) + ', ')
		sys.stdout.write('\n')
			
			
if __name__ == '__main__':
    n = sys.stdin.readline()
    n = int(n)
    arr = sys.stdin.readline()
    arr = map(lambda x:int(x), arr.split())
    fun(arr)

Measured memory_bytes: 4252
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
int dc=100000;
#define MAX 100010

int comp(const void*a,const void *b){
  int x=*((int*)a),y=*((int*)b);
  return x-y;
}


int main(){
  if(df)printf("*** debug mode ***\n");
  int n;
  scanf("%d",&n);
  int a[n],i;
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  qsort(a,n,sizeof(int),comp);
  int s=0,temp=0,prev=a[0];
  for(i=0;i<n;i++){
    if(prev==a[i])temp^=1;
    else{
      s+=temp;
      temp=1;
      prev=a[i];
    }
  }
  s+=temp;
  
  printf("%d",s);
  return 0;
}


/// confirm df==0 ///


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


int main() {
  string s;
  cin >> s;
  int q;
  cin >> q;
  //制約の手順を実行する
  string t;
  rep(qi,q) {
    int ty;
    cin >> ty;
    if (ty == 1) {
      swap(s,t);
    } else {
      int f; char c;
      cin >> f >> c;
      if (f == 1) {
        t += c;
      } else {
        s += c;
      }
    }
  }

  reverse(t.begin(), t.end());
  t += s;
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 1128
def is_kai(s, r):
  return(s == r)

S = input()
N = len(S)

mae = []
flag = is_kai(S, S[::-1])

be_idx = int((N-1)/2)
af_idx = int((N+3)/2-1)

be = S[:be_idx]
af = S[af_idx:]

if is_kai(S,S[::-1]) and is_kai(be, be[::-1]) and is_kai(af, af[::-1]):
  print('Yes')
else:
  print('No')



Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  int N;
  cin >> N;
  vector<int> a(3 * N);
  rep(i, 3 * N) { cin >> a[i]; }

  sort(a.begin(), a.end());
  int64_t result = 0;
  rep(i, N) { result += a[N + i * 2]; }
  cout << result << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> VI;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())

int main() {

	ll n, k;
	cin >> n >> k;
	if (k % 2 == 0){
		ll cnt = 0, cnt1 = 0;
		eFOR1(i, n){
			if (i%k == 0)cnt++;
			else if (i%k == k / 2)cnt1++;
		}
		cout << cnt*cnt*cnt + cnt1*cnt1*cnt1 << endl;
	}
	else{
		ll cnt = 0;
		eFOR1(i, n){
			if (i%k == 0)cnt++;
		}
		cout << cnt*cnt*cnt << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;

const double PI = acos(-1.0);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin>>N;
    int cnt = 0;
    rep1(i,N){
        if(i!=N-i)cnt++;
    }
    cout<<cnt/2<<endl;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    int dp[n+1][3]; //0:a 1:b 2:c 
    int a1,b1,c1; cin>>a1>>b1>>c1;
    dp[1][0]=a1; dp[1][1]=b1; dp[1][2]=c1;
    for (int i=2;i<=n;i++) {
        int a,b,c; cin>>a>>b>>c;
        dp[i][0]= max(dp[i-1][1]+a,dp[i-1][2]+a);
        dp[i][1]= max(dp[i-1][0]+b,dp[i-1][2]+b);
        dp[i][2]= max(dp[i-1][0]+c,dp[i-1][1]+c);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<"\n";
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main(void)
{	
	float a,ans = 0;
	int n;
	int i;
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%f",&a);
		ans = 1/a + ans;
	}
	ans = 1/ans;
	printf("%f",ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int n,k,i,p[200005];
  
  cin >> n >> k;
  for (i=0;i<n;i++) cin >> p[i];
  
  ll s=0,smax;
  for (i=0;i<k;i++) s+=p[i];
  
  smax=s;
  for (i=0;i+k<n;i++){
    s+=p[i+k]-p[i];
    smax=max(smax,s);
  }
  
  printf("%.12lf\n",(double)(smax+k)/2);
  
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<int> b(N), cmp;
    rep(i, N) {
        cin >> b[i];
    }

    int index = -1;
    rep(i, N) {
        index = -1;
        int num = 1;
        rep(j, N) {
            if (b[j] == 0) continue;
            if (b[j] == num) {
                index = j;
            }
            num++;
        }
        if (index == -1) break;
        cmp.push_back(b[index]);
        b[index] = 0;
    }

    if (index == -1) cout << -1 << endl;
    else {
        reverse(all(cmp));
        rep(i, cmp.size()) cout << cmp[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int N,Pre[100005],a[100005];
long long A[100005],l=0,m,r=1e9+1,F[800005],cnt;
void in(int O,int l,int r,int k)
{
	if(l==r)
	{
		F[O]++;
		return ;
	}
	int mid=(l+r)/2;
	if(k<=mid)
	in(O*2,l,mid,k);
	else
	in(O*2+1,mid+1,r,k);
	F[O]=F[O*2]+F[O*2+1];
}
long long qu(int O,int l,int r,int s,int t)
{
	if(l==s&&r==t)
	return F[O];
	int mid=(l+r)/2;
	if(t<=mid)
	return qu(O*2,l,mid,s,t);
	if(s>mid)
	return qu(O*2+1,mid+1,r,s,t);
	return qu(O*2,l,mid,s,mid)+qu(O*2+1,mid+1,r,mid+1,t);
}
bool check()
{
	cnt=0;
	memset(F,0,sizeof(F));
	for(int i=1;i<=N;i++)
	if(A[i]>=m)
	a[i]=1;
	else
	a[i]=-1;
	for(int i=1;i<=N;i++)
	Pre[i]=Pre[i-1]+a[i];
	in(1,0,N*2,N);
	for(int i=1;i<=N;i++)
	{
		cnt+=qu(1,0,N*2,0,Pre[i]+N);
		in(1,0,N*2,Pre[i]+N);
	}
	if(cnt*2>=(long long)N*(N+1)/2)
	return true;
	return false;
}
int main()
{
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
	scanf("%lld",&A[i]);
	while(l+1<r)
	{
		m=(l+r)/2;
		if(check())
		l=m;
		else
		r=m;
	}
	printf("%lld",l);
	return 0;
}

Measured memory_bytes: 7936
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

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

  std::vector<std::tuple<int, int, int>> data;
  int x, y, h;
  for (int i = 0; i < N; i++) {
    std::cin >> x >> y >> h;
    data.push_back(std::make_tuple(h, x, y));
  }

  //std::sort(std::begin(data), std::end(data), std::greater<int>());

  int CX = 0;
  int CY = 0;
  int H = 0;

  bool find = false;
  for (int x = 0; x <= 100; x++) {
    for (int y = 0; y <= 100; y++) {
      for (int h = 0; h <= 200; h++) {
        int tx = x;
        int ty = y;
        int th = std::get<0>(data.back()) + h;

        // すべての観測点で矛盾が生じなければＯＫ
        bool check = true;
        for (int i = 0; i < N; i++) {
          int dist =
            std::abs(tx - std::get<1>(data[i])) +
            std::abs(ty - std::get<2>(data[i]));
          int ch = std::max(th - dist, 0);
          if (ch != std::get<0>(data[i])) {
            check = false;
            break;
          }
        }

        if (check) {
          CX = tx;
          CY = ty;
          H = th;
          find = true;
          break;
        }
      }

      if (find) break;
    }
    if (find) break;
  }

  if (find) {
    std::cout << CX << " " << CY << " " << H << std::endl;
  }


  return 0;
}


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

int main() {
  string s[3];
  for(int i = 0; i < 3; ++i) cin >> s[i];
  int sizes[3];
  int counter[3] = {0,0,0};
  int chekcer = 0;
  unordered_map<char,int> players = {{'a',0}, {'b',1}, {'c',2}};
  for(int i = 0; i < 3; ++i) sizes[i] = s[i].size();
  while(true){
    if(counter[chekcer] == sizes[chekcer])break;
    ++counter[chekcer]; 
    chekcer = players[s[chekcer][counter[chekcer]-1]];
  }
  if(chekcer == 0) cout << "A" << endl;
  else if(chekcer == 1) cout << "B" << endl;
  else cout << "C" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define c2(n,m) cin>>n>>m
#define c3(n,m,k) cin>>n>>m>>k
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  int a,b,c,d,e;
  c2(a,b);
  if(b/100!=0) d=3;
  else if(b/10!=0) d=2;
  else d=1;
  
  c=a*pow(10,d)+b;
  e=pow(c,0.5);
  if(c==e*e) co("Yes");
  else co("No");
  
  return 0;
}


Measured memory_bytes: 384
s = input()

for x in s:
   s = s[:-1]
   if (len(s) % 2 == 0):
      half = int(len(s) / 2)
      for i in range(0, half):
         if (s[i] != s[i+half]):
            break
      if (i == half - 1):
         print(len(s))
         exit()


Measured memory_bytes: 2940
H,W = map(int,input().split())
grid = [0] * H
for i in range(H):
    grid[i] = input()
right = [[0]*W for _ in range(H)]
left = [[0]*W for _ in range(H)]
up = [[0]*W for _ in range(H)]
down = [[0]*W for _ in range(H)]
for i in range(H):
    now = 0
    for x in range(W):
        if grid[i][x] == '.':
            left[i][x] = now
            now += 1
        else:
            now = 0
    now = 0
    for x in range(W-1,-1,-1):
        if grid[i][x] == '.':
            right[i][x] = now
            now += 1
        else:
            now = 0
for x in range(W):
    now = 0
    for y in range(H):
        if grid[y][x] == '.':
            up[y][x] = now
            now += 1
        else:
            now = 0
    now = 0
    for y in range(H-1,-1,-1):
        if grid[y][x] == '.':
            down[y][x] = now
            now += 1
        else:
            now = 0
ans = 0
for y in range(H):
    for x in range(W):
        if grid[y][x] == '.':
            can = 1 + right[y][x] + left[y][x] + up[y][x] + down[y][x]
            ans = max(ans,can)
print(ans)


Measured memory_bytes: 205712
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

h = int(readline())
cnt = 0
if h == 1:
    print(1)
elif h == 2:
    print(3)
else:
    for i in range(h):
        if h < 2 ** i:
            print(cnt)
            exit()
        else:
            cnt += 2 ** i


Measured memory_bytes: 2940
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> bool max_self(T & a, const T & b){ 
  return b > a ? a = b, true : false; 
}
template<class T> bool min_self(T & a, const T & b){ 
  return b < a ? a = b, true : false;    
}
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

int main(){
  FAST_IO
  string a, b;
  cin >> a >> b;
  int N = SZ(a);
  a += a;
  for(int idx = 0; idx < N; ++idx){
//    cout << a.substr(idx, N) << " ";
    if(a.substr(idx, N) == b){
      cout << "Yes\n";
      return 0;
    }
  }

  cout << "No\n";
  return 0;
}


Measured memory_bytes: 3548
#include<iostream>
using namespace std;main(){char c;int N,M,x,y,i,f[21][21];for(;cin>>N,N;puts(N?"No":"Yes")){for(i=441;i-->0;)f[i%21][i/21]=0;for(;++i<N;f[y][x]=1)cin>>x>>y;x=y=10;for(cin>>M;M-->0;)for(cin>>c>>i;i-->0;y+=(c==78)-(c==83),f[y][x]&&N--,f[y][x]=0)x+=(c==69)-(c==87);}}

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

int t=0;

void dfs(vector<vector<int>> &vec, vector<pair<int, int>> &stmp, int now) {
  if (stmp[now].first) return;
  ++t;
  stmp[now].first = t;

  rep (i, vec[now].size()) dfs(vec, stmp, vec[now][i]);
  

  ++t;
  stmp[now].second = t;
  return;
}
     
int main() {
  int n, k;
  cin >> n;
  vector<vector<int>> vec(n, vector<int>(1));
  vector<pair<int, int>> stmp(n, make_pair(0, 0));
  set<int> s;
  rep (i, n) {
    int voii;
    cin >> voii;
    cin >> k;
    vec[i].resize(k);
    rep (j, k) {
      int x;
      cin >> x;
      vec[i][j] = x - 1;
    }
  }

  rep (i, n) {
    dfs(vec, stmp, i);
  }

  rep (i, n) printf("%d %d %d\n", i + 1, stmp[i].first, stmp[i].second);
}


Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int x;
    cin >> x;
    int bal = x%100;
    int times = x/100;
    if (bal <= times) cout << 1 << endl;
    else {
        if (bal%5 == 0 && bal/5 <= times) cout << 1 << endl;
        else if (bal/5+1 <= times) cout << 1 << endl;
        else cout << 0 << endl;
    }
}

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

int main() {
    int N;
    cin >> N;
    vector<int> card (N);
    for(int i = 0;i < N;i++){
    	cin >> card.at(i);
    }
    sort(card.begin(),card.end());
    reverse(card.begin(),card.end());
    int bob, alice = 0;
    for(int i = 0;i < N;i++){
    	if(i % 2 == 1){
    		bob += card.at(i);
    	}
    	else{
    		alice += card.at(i);
    	}
    }
    cout << alice - bob << endl;
    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    a = LI()
    count = 0
    for i in range(1,n+1):
        if i % 2 != 0 and a[i-1] % 2 != 0:
            count += 1
    print(count)
    return


if __name__ == "__main__":
    solve()


Measured memory_bytes: 67396
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC144A
{
    class Program
    {
        public static void Main()
        {
            var n = Console.ReadLine()
                        .Split(' ').Select(x => int.Parse(x))
                        .ToArray();
            Console.WriteLine((n[0] > 9 || n[1] > 9) ? -1 : n[0] * n[1]);
        }
    }
}

Measured memory_bytes: 13268
n = gets.to_i
h = gets.chomp.split(' ').map(&:to_i)
ans = 0
temp = 0
(n-1).times do |i|
  if (h[i+1]<=h[i])
    temp += 1
  else
    if ans < temp
      ans = temp
    end
    temp = 0
  end
end

if (ans<temp)
    ans = temp
end
puts ans

Measured memory_bytes: 21928
#require 'pp'
require 'prime'

MAX = 10 ** 6
n = gets.to_i
a_n = gets.split.map(&:to_i)
memo = Array.new(10 ** 6 + 1, 0)
primes = Array.new(10 ** 6 + 1, 0)
Prime.each(MAX) do |i|
    primes[i] = 1
end

#pp primes.tally

all_gcd = a_n[0]
1.upto(n-1) do |i|
    all_gcd = all_gcd.gcd(a_n[i])
end

# 全GCDが1でない場合どちらでもない
if all_gcd > 1
    puts "not coprime"
    exit 0
end

## ============
## 以下は全GCDは常に1前提
## ============

a_n.sort!
a_n.each do |a|
    # 素数はすでに計算済みなので素因数分解を省略
    if primes[a] == 1
        if memo[a] == 1
            puts "setwise coprime"
            exit 0
        end

        memo[a] = 1
    else
        Prime.prime_division(a).each do |x, cnt|
            if memo[x] == 1
                puts "setwise coprime"
                exit 0
            end
            memo[x] = 1
        end
    end
end

puts "pairwise coprime"

Measured memory_bytes: 99496
#include <bits/stdc++.h>
#define maxn (int)(2e5)
#define i64 long long
#define pii pair<i64,i64>
#define all(x) x.begin(),x.end()
#define LB(x,v) lower_bound(all(x), v) - x.begin()
#define fread() freopen("in.txt", "r", stdin);
using namespace std;
 int p[maxn+2];
int main() {
    /*BEFORE SUBMIT, CHECK
    sample i/o format
    statements for debugging are removed/comment out
    global values / stl containers are initialized/cleared for each test (if needed)
    all array size are sufficient
    loop variable or output value doesn't cross min/max limit of input
    */
    
    int T,n;
    while(scanf("%d",&n)==1){
        for(int i=0;i<n;i++) scanf("%d",&p[i]);

        int cnt = 1, j=0;
        for(int i=1;i<n;i++){
            if(p[i] <= p[j]){
                j = i;
                cnt++;
            }
        } 
        printf("%d\n", cnt);   
    }   
    return 0;
}

Measured memory_bytes: 1024
n,k=map(int,input().split())
d=list(map(int,input().split()))

flag=False
while True:
  yen=str(n)
  for i in range(len(yen)):
    if int(yen[i]) in d:
      n+=1
      flag=True
      break
  if flag:
    flag = False
    continue
  break
print(n)

Measured memory_bytes: 3060
N, M = map(int, input().split())
A_list = sorted(list(map(int, input().split())))
# C の大きさ順に
BC_list = sorted([list(map(int, input().split())) for _ in range(M)], key=lambda x:x[1], reverse=True)
change_list_sorted = []
for m in range(M):
    b, c = BC_list[m]
    for _ in range(b):
        change_list_sorted.append(c)
    if len(change_list_sorted) > N:
        break
change_cnt = 0
for i, (change_val, a) in enumerate(zip(change_list_sorted, A_list)):
    if a <= change_val:
        A_list[i] = change_val
    else:
        break
print(sum(A_list))

Measured memory_bytes: 34180
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          fozubaoyou    no BUGs alive
*/
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define RFOR(i, a, b) for(int i = b; i >= a; i--)
#define REP(i, n) FOR(i, 0, n)
#define SZ(x) ((int)(x).size())
using namespace std;
#define vc vector<card>

struct card {
    char s;
    int n;
};

void BubSort(vc &C) {
    REP(i, SZ(C))
        RFOR(j, i+1, SZ(C)-1)
            if (C[j].n < C[j-1].n) {
                card t = C[j];
                C[j] = C[j-1];
                C[j-1] = t;
            }
}

void SelSort(vc &C) {
    REP(i, SZ(C)) {
        int minj = i;
        FOR(j, i, SZ(C)) {
            if (C[j].n < C[minj].n) minj = j;
        }
        card t = C[i];
        C[i] = C[minj];
        C[minj] = t;
    }
}

int main(){
    int n; cin >> n;
    vc CS(n);
    REP(i, n) {
        string s; cin >> s;
        CS[i].s = s[0];
        CS[i].n = (int)s[1]-'0';
    }
    vc CB = CS;
    BubSort(CB);
    SelSort(CS);
    REP(i, SZ(CB)) {
        cout << CB[i].s << CB[i].n;
        i != SZ(CB)-1 ? cout << " " : cout << endl;
    }
    cout << "Stable" << endl;
    REP(i, SZ(CS)) {
        cout << CS[i].s << CS[i].n;
        i != SZ(CS)-1 ? cout << " " : cout << endl;
    }
    bool f = false;
    REP(i, SZ(CS)) if(CB[i].s != CS[i].s) f = true;
    f ? cout << "Not stable" << endl : cout << "Stable" << endl;
}

Measured memory_bytes: 3152
# シミュレーション問題

def paint_gt_x(area, threhsold):
    for y in range(len(area)):
        for x in range(len(area[y])):
            if x < threhsold:
                area[y][x] = 1

def paint_lt_x(area, threhsold):
    for y in range(len(area)):
        for x in range(len(area[y])):
            if x > threhsold:
                area[y][x] = 1

def paint_gt_y(area, threhsold):
    for y in range(len(area)):
        for x in range(len(area[y])):
            if y < threhsold:
                area[y][x] = 1

def paint_lt_y(area, threhsold):
    for y in range(len(area)):
        for x in range(len(area[y])):
            if y > threhsold:
                area[y][x] = 1


(w, h, n) = map(int, input().split())

area = []
for _ in range(h):
    area.append([0 for _ in range(w)])

for _ in range(n):
    (x, y, a) = map(int, input().split())
    if 1 == a:
        paint_gt_x(area, x)
    elif 2 == a:
        paint_lt_x(area, x - 1)
    elif 3 == a:
        paint_gt_y(area, y)
    else:
        paint_lt_y(area, y - 1)

count = 0
for row in area:
    for cell in row:
        count += 1 if 0 == cell else 0
print(count)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N, M; cin >> N >> M;
    REP(i, 0, M) {
        int a; cin >> a;
        N -= a;
    }
    cout << max(N, -1) << endl;
    return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans = 0;
    string S; cin >> S;
    rep(i, S.length()) {
        int len = (int)S.length() - i - 1;
        int times = pow(10, len) + 0.5;
        int cnt = (1 << i);
        rep(j, len + 1) {
            ans += (S[i] - '0') * times * cnt;
            cnt *= 2;
            if (j == 0) cnt /= 2;
            times /= 10;
            //cout << i << " " << ans << " " << cnt << endl;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
// Binary Indexed Tree (Fenwick Tree)
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i<=n; i+=i&-i) d[i] += x;
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
};

const int N = 500005;
int main() {
  int n,q;
  cin >> n >> q;
  vector<P> v;
  vector<int> p(N,-1);
  rep(i,n){
    int c;
    cin >> c;
    if(p[c]!=-1) v.emplace_back(p[c],i);
    p[c] = i;
  }
  sort(v.rbegin(),v.rend());
  vector<T> t;
  rep(i,q){
    int l,r;
    cin >> l >> r;
    --l,--r;
    t.emplace_back(l,r,i);
  }
  sort(t.rbegin(),t.rend());

  vector<int> ans(q);
  BIT<int> bit(N);
  int vi = 0;
  for(T ti:t){
    int l,r,i;
    tie(l,r,i) = ti;
    while(vi<v.size()&&v[vi].first>=l) bit.add(v[vi++].second,1);
    ans[i] = r-l+1-bit.sum(r);
  }
  rep(i,q) printf("%d\n",ans[i]);
}


Measured memory_bytes: 18864
N=int(input())
josi = list(map(int,input().split()))
count=[0]*N
n=0
while n<N-1:
  count[josi[n]-1] =count[josi[n]-1]+1
  n=n+1
n=0
while n<N:
  print(count[n])
  n=n+1


Measured memory_bytes: 32344
#include <iostream>
using namespace std;
 
int main() {
  int N, Y;
  int numMan;
  int numGoSen;
  int numSen;
  int flag = 0;
  cin >> N >> Y;
  for (int i=0; i <= N; ++i) {
    for (int j=0; j <= N - i; ++j) {
      int sum = 10000* i + 5000* j + 1000* (N - i - j);
      if (sum == Y) {
        numMan = i;
        numGoSen = j;
        numSen = N - i - j;
        flag = 1;
        break;
      }
    }
  }
  if (flag) {
    cout << numMan << " " << numGoSen << " " << numSen << "\n";
  }
  else {
    cout << "-1 -1 -1\n";
  }
}
        
        
  

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

int main() {
  int N, A;
  cin >> N;
  cin >> A;
  
  int c = N%500;
  int d = A - c;
  
  if (d >= 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector <int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii;
#define ll long long int
#define pb push_back
#define PI 3.1415926535897932384626
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MOD 4294967296
#define MAX 100001
#define forn(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mset(x,v) memset(x, v, sizeof(x))
int main()
{   
      boost;
            int a,b;
            cin>>a>>b;
            if(b>a)
            swap(a,b);
            int d=2*a-1;
            if(a>8)
            {
                  cout<<":("<<endl;
                 // return 0;
            }
            else
            {
                  int unused=d-a;
                  unused+=abs(16-d);
                  if(unused>=b)
                  {
                        cout<<"Yay!"<<endl;
                  }
                  else
                  {
                        cout<<":(";
                  }
            }
}

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

int main(){
  int N;
  cin >> N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  vector<int>ans(N);
  for(int i=0;i<N;i++){
    ans[A[i]-1]=i+1;
  }
  for(int i=0;i<N;i++){
    cout<<ans[i]<<" ";
  }
  cout << endl;
}
      
    
      


Measured memory_bytes: 1664
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<utility>
using namespace std;
const int maxn = 1010;
int g[maxn][maxn];int n,m;
int f[maxn*2],vis[maxn],cnt[2],h[maxn*2];
void mmp()
{
	cout<<-1<<endl;
	exit(0);
}
void dfs(int x,int id)
{
//	cout<<"!"<<x<<" "<<id<<endl;
	cnt[id]++;
	vis[x] = id;
	for(int i=1;i<=n;i++)
	if(x!=i&&!g[x][i])
	{
//		cout<<"->"<<i<<endl;
		if(vis[i]==-1)dfs(i,id^1);
		else if(vis[i]==id)mmp();
	}
	return ;
}
int main()
{
	memset(g,0,sizeof(g));
	memset(f,0,sizeof(f));
	memset(vis,-1,sizeof(vis));
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		g[x][y] = g[y][x] = 1;
	}
	f[0] = 1;
	for(int i=1;i<=n;i++)
	if(vis[i]==-1)
	{
		cnt[0] = cnt[1] = 0;
		dfs(i,0);
//		cout<<"->"<<cnt[0]<<" "<<cnt[1]<<endl;
		memset(h,0,sizeof(h));
		for(int j=n;j>=0;j--)
		if(f[j])
		{
			h[j+cnt[0]]=1;
			h[j+cnt[1]]=1;
		}
		for(int j=0;j<=n;j++)f[j]=h[j];
	}
	int ans = 1<<30;
	for(int i=0;i<=n;i++)
	if(f[i])
	{
		int t = n-i;
//		cout<<"!"<<i<<" "<<t<<endl;
		int buf = i*(i-1)/2 + t*(t-1)/2;
		ans = min(ans,buf);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4224
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
#=================================================
n=int(input())
F=[0]*(2*10**5+1)
for x in range(1,145):
    for y in range(1,145):
        for z in range(1,145):
            F[x**2+y**2+z**2+x*y+y*z+x*z]+=1

for i in range(1,n+1):
    print(F[i])


Measured memory_bytes: 70680
import math

N = int(input())
T = [tuple(map(int, input().split())) for i in range(N)]

S = 0
for i in range(N - 1):
    for j in range(i, N):
        S += math.sqrt((T[i][0] - T[j][0]) ** 2 + (T[i][1] - T[j][1]) ** 2)
print(S * 2 / N)


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

int main ()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0;i < n;i++) cin >> a[i];
    for (int i = n-1;i >= 0;i--)
    {
         cout << a[i];
         if (i > 0) cout << " ";
    }
    cout << endl;
    return 0;
}


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

int main() {
  int a, b, x, y;
  cin >> a >>  b;
  x = a % 2;
  y = b % 2;
  if (x + y == 2) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

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

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 13;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

int n, a[M], x[M];

int cnt[M];

int cnk(int n, int k){
    return cnt[n] == cnt[n-k] + cnt[k];
}

bool check1(){
    bool ok = 0;
    for (int i = 1; i <= n; i++){
        ok ^= (x[i] == 1 && cnk(n-1,i-1));
        //cout << cnk(n-1,i-1) << " ";
    }
    return ok;
}

bool check2(){
    for (int i = 1; i <= n; i++){
        if (x[i] == 1) return 0;
    }
    for (int i = 1; i <= n; i++){
        if (x[i] == 2) x[i] = 1;
    }
    return check1();
}

void solve(){
    char c;
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> c;
        a[i] = c-'0';
    }
    for (int i = 1; i < n; i++){
        x[i] = abs(a[i]-a[i+1]);
    }
    n--;
    if (check2()){
        cout << 2;
        return;
    }
    if (check1()){
        cout << 1;
        return;
    }
    cout << 0;
}

int main(){
    for (int i = 1; i < M; i++){
        cnt[i] = cnt[i-1]+__builtin_ctz(i);
    }
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 12032
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll>pll;

int main() {
	int N, a[100], ans, sum = 0;

	cin >> N;
	REP(i, N) {
		cin >> a[i];
		sum += a[i];
	}

	ans = 0;
	FOR(i, 1, N) {
		if (abs(sum - N * a[i]) < abs(sum - N * a[ans])) {
			ans = i;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 768
{-# OPTIONS_GHC -O #-}
{-# LANGUAGE ViewPatterns #-}

import Control.Monad
import Control.Monad.ST
import Data.Maybe
import Data.Array.Unboxed
import Data.Array.ST
import qualified Data.Sequence as SQ
import Data.Sequence ((|>), (<|), ViewL(..), ViewR(..))

main = do
    (h:w:_)<-map read.words<$>getLine::IO [Int]
    m <- concat <$> replicateM h getLine :: IO String
    --
    let wn = length $ filter(=='.') m
    let bd = listArray ((1,1),(h,w)) $ map (\c->if c=='.' then 0 else (-1)) m::UArray (Int,Int) Int
    --
    let bd' = sol' h w bd

    print $ if bd' ! (h,w) == 0 then (-1) else wn - (bd' ! (h,w))
--
sol' :: Int -> Int -> UArray (Int,Int) Int -> UArray (Int,Int) Int
sol' h w bd = runST $ do
    m <- thaw bd :: ST s (STUArray s (Int,Int) Int)
    writeArray m (1,1) 1
    solve h w m $ SQ.singleton ((1,1),1)
    freeze m

solve :: Int -> Int -> STUArray s (Int,Int) Int -> SQ.Seq ((Int,Int),Int) -> ST s ()
solve _ _ _ (SQ.viewl -> SQ.EmptyL) = return ()
solve h w m (SQ.viewl -> ((i,j),s) :< sq)
    | null nx = solve h w m sq
    | otherwise = do
        mv <- forM nx $ \(i,j) -> do
            nxc <- readArray m (i,j)
            if nxc == 0 then writeArray m (i,j) (s+1) >> (return $ Just ((i,j),s+1)) else return Nothing
        solve h w m $ foldl (|>) sq $ catMaybes mv
    where
        nx = filter (\(i,j)->i>=1&&i<=h&&j>=1&&j<=w) [(i-1,j),(i+1,j), (i,j-1), (i,j+1)]

Measured memory_bytes: 1148
def main():
    n = int(input())
    ps = list(map(int, input().split()))
    score = 0
    for i in range(1, n - 1):
        if ps[i - 1] < ps[i] < ps[i + 1]:
            score += 1
        elif ps[i - 1] > ps[i] > ps[i + 1]:
            score += 1

    print(score)


main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  
  if(a%2==0){
  	cout << (a/2)*(a/2) << endl;
  }
  else{
    cout << a/2*(a/2+1) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    vstr num(2, "");
    rep(i, a) num[0] += to_string(b);
    rep(i, b) num[1] += to_string(a);

    sort(all(num));

    cout << num[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long
main(){
  int n,r=0;
  cin>>n;
  vector<int> p(n),q(n);
  for(int i=0;i<n;++i)cin>>p[i],q[i]=i;
  sort(q.begin(),q.end(),[&](int a,int b){return p[a]>p[b];});
  multiset<int,less<>> s;
  multiset<int,greater<>> t;
  s.insert(-1);s.insert(n);
  t.insert(-1);t.insert(n);
  for(auto i:q){
    auto r1=s.lower_bound(i);
    auto r2=(*r1==n?r1:s.upper_bound(*r1));
    auto l1=t.lower_bound(i);
    auto l2=(*l1==-1?l1:t.upper_bound(*l1));
    r+=((*r2-*r1)*(i-*l1) + (*r1-i)*(*l1-*l2))*p[i];
    s.insert(i);
    t.insert(i);
  }
  cout<<r;
}

Measured memory_bytes: 11136
// Isaunoya
#include<bits/stdc++.h>
using namespace std ;
using LL = long long ;
using uint = unsigned int ;
#define int long long
#define fir first
#define sec second
#define pb push_back
#define mp(x , y) make_pair(x , y)
template < typename T > inline void read(T & x) { x = 0 ; int f = 1 ; register char c = getchar() ;
  for( ; ! isdigit(c) ; c = getchar()) if(c == '-') f = -1 ;
  for( ; isdigit(c) ; c = getchar()) x = (x << 1) + (x << 3) + (c & 15) ;
  x *= f ;
}
template < typename T > inline void print(T x) {
  if(! x) { putchar('0') ; return ; }
  static int st[105] ;
  if(x < 0) putchar('-') , x = -x ;
  int tp = 0 ;
  while(x) st[++ tp] = x % 10 , x /= 10 ;
  while(tp) putchar(st[tp --] + '0') ;
}
template < typename T > inline void print(T x , char c) { print(x) ; putchar(c) ; }
template < typename T , typename ...Args > inline void read(T & x , Args & ...args) { read(x) ; read(args...) ; }
template < typename T > inline void sort( vector < T > & v) { sort(v.begin() , v.end()) ; return ; }
template < typename T > inline void unique( vector < T > & v) { sort(v) ; v.erase(unique(v.begin() , v.end()) , v.end()) ; }
template < typename T > inline void cmax(T & x , T y) { if(x < y) x = y ; return ; }
template < typename T > inline void cmin(T & x , T y) { if(x > y) x = y ; return ; }
const int Mod = LLONG_MAX ;
inline int QP(int x , int y) { int ans = 1 ;
  for( ; y ; y >>= 1 , x = (x * x) % Mod)
    if(y & 1) ans = (ans * x) % Mod ;
  return ans ;
}
template < typename T > inline T gcd(T x , T y) { if(y == 0) return x ; return gcd(y , x % y) ; }
template < typename T > inline T lcm(T x , T y) { return x * y / gcd(x , y) ; }
template < typename T > inline void mul(T & x , T y) { x = 1LL * x * y ; if(x >= Mod) x %= Mod ; }
template < typename T > inline void add(T & x , T y) { if((x += y) >= Mod) x -= Mod ; }
template < typename T > inline void sub(T & x , T y) { if((x -= y) < 0) x += Mod ; }

signed main() {
  int a , b ;
  read(a , b) ;
  if(a > 9 || b > 9) return print(-1) , 0 ;
  print(a * b) ;  return 0 ;
}


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

using namespace std;
#define sz(a) int(a.size())
#define ll  long long
#define ull unsigned long long
//#define mod int(1e9+7)
#define endl '\n'
#define Engz ios::sync_with_stdio(0);ios_base::sync_with_stdio(0);cin.tie(0) , cout.tie(0) ;
#define pi double(acos(-1))
#define S second
#define F first

//  freopen("input.txt","r",stdin);

//------------------- BESH ----------------------//
long long mod ;
long long p(long long a ,long long b)
{
    if(b==0)
        return 1;

    long long z=p(a,b/2);


    if(b%2==0)return ((z%mod)*(z%mod))%mod; else return (((z*z)%mod)*a)%mod;
}

long long g(long long a, long long b)
{
    if(a==0)
        return b;
    else return g(b%a , a);
}

//-----------sieve --------------------//

bool prime[1000001];

void sieve()
{
memset(prime , true , sizeof prime);
prime[0]=prime[1]=0;

for(int i=2 ; i*i<=1000000; i++)
{
    if(prime[i]==true)
    for(int j=i*i ; j<=100000 ; j+=i)
    prime[j]=false;
}
}

ll lcm(ll a, ll b)
{
    return (a*b)/__gcd(a,b);
}


int a[1002][1002]={{}};

int main()
{


   int n;
   cin>>n;
   int a[n];

   for(int i=0 ; i<n ; i++) cin>>a[i];
   int ans[n];

   ans[0]=0; ans[1]=(abs(a[1]-a[0]));

   for(int i=2 ; i<n ; i++)
    ans[i]=min(ans[i-1]+abs(a[i]-a[i-1]) , ans[i-2] +abs(a[i]-a[i-2]));

   cout<<ans[n-1];
	return 0;
}


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

int main(){
    int N;
    int count = 0;
    map<string, bool> collection{};
    cin >> N;
    for (int i = 0; i < N; i++){
        string s;
        cin >> s;
        if(!collection[s]){
            count++;
            collection[s] = true;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 19124
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int s = h1 * 60 + m1;
    int t = h2 * 60 + m2;
    cout << t - k - s << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
using namespace std;
int TenPower (int);

int main (){

        int N;
        int ans;
        int TP;

        cin >> N;

        if ( N%10==0 && TenPower(N)==1) {
                ans= 10;
        }else{
                ans= N%100000/10000 + N%10000/1000 + N%1000/100 + (N%100/10) + N%10;
        }

        cout << ans << endl;
}

int TenPower (int p){

        if (p > 9) {
                p = p/10;
                p=TenPower(p);
        }
        return p;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a-1);i>=(b);i--)
#define all(x) (x).begin(), (x).end()
const int INF = 1e18;
const int MOD = 1e9+7;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef string str;
typedef vector<str> vstr;
void print() {cout<<endl;}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<<endl;}template<class T>void print(vector<vector<T>>&df){for(auto&vec:df){print(vec);}}
template<class T=int>T in() {T x;cin>>x;return(x);}
template<class T=int>vector<T> input_to_vector(int n) {vector<T>x;rep(i,n){T a;cin>>a;x.push_back(a);}return(x);}

signed main(){
    int n = in();
    vint P;
    rep(i, n) {
        int a = in();
        P.push_back(a);
    }
    sort(all(P));
    P[n-1] = P[n-1] / 2;
    int ans = 0;
    ans = accumulate(all(P), 0);
    print(ans);
}

Measured memory_bytes: 256