akhauriyash/Code-Regression huggingface dataset:
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f

using namespace std;

int memo[100005];
vector<int> A;

bool solve(int left) {
    if(memo[left] != -1) return memo[left];
    bool ans = false;
    for(int pick : A) {
        if(left >= pick && !solve(left - pick)) ans = true;
    }
    memo[left] = ans;
    return ans;
}


int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    memset(memo, -1, sizeof memo);
    int N, K;
    cin >> N >> K;
    A.resize(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    sort(A.begin(), A.end());
    cout << (solve(K) ? "First" : "Second") << endl;
    return 0;

}



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

#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define per(i,n) for (int i=(int)(n)-1;i>=0;i--)
#define For(i,n) for (int i=1;i<=(int)(n);i++)
#define Rep(i,n) for (int i=0;i<=(int)(n);i++)
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()
#define Max(a,b,c) max(a,max(b,c))
#define Min(a,b,c) min(a,min(b,c))
#define cmax(x,y) x=max(x,y)
#define cmin(x,y) x=min(x,y)
#define pii pair<int,int>
#define vi vector <int>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define pb push_back
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const int MAXN=3000+3;

ll f[MAXN][MAXN],a[MAXN],n;
bool v[MAXN][MAXN];

ll dfs(const int &l,const int &r){
	if (v[l][r]) re f[l][r];
	if (l==r-1) re a[l];
	v[l][r]=1;
	f[l][r]=max(a[l]-dfs(l+1,r),a[r-1]-dfs(l,r-1));
	re f[l][r];
}

int main(){
	cin>>n;
	rep(i,n){
		cin>>a[i];
	}
	cout<<dfs(0,n)<<endl;
	re 0;
}

Measured memory_bytes: 78592
# python3


def main():
    N = input()
    h = [Node(int(ele)) for ele in input().split()]
    cal_dp(h)
    print(h[-1].dp_val)


def cal_dp(h):
    for idx, n in enumerate(h):
        if idx == 0:
            n.dp_val = 0

        elif idx == 1:
            n.dp_val = abs(h[0].val - n.val)
        else:
            n.dp_val = min(h[idx-1].dp_val + abs(n.val - h[idx-1].val),
                           h[idx-2].dp_val + abs(n.val - h[idx-2].val))


class Node():

    def __init__(self, val):
        self.val = val
        self.dp_val = 'unk'


if __name__ == '__main__':
    main()


Measured memory_bytes: 29780
N = int(input())
X = list(map(int,input().split(' ')))

minAns=100*100*100+1

for p in range(100+1):
    tmpAns=0
    for i in range(N):
        tmpAns+=(X[i]-p)**2
    minAns=min(minAns,tmpAns)

print(minAns)

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

vector < vector <int> > graph;
vector <int> dp;
int ans = -1;
void dfs(int src) {
    dp[src] = 0;
    int m = graph[src].size();
    for(int i=0;i<m;i++) {
        int j = graph[src][i];
        if(dp[j] == -1)
            dfs(j);
        dp[src] = max(dp[src],1+dp[j]);
        ans = max(ans,dp[src]);
    }
}
int main(){
    int n,m;
    cin>>n>>m;
    graph.resize(n);
    while(m--) {
        int a,b;
        cin>>a>>b;
        graph[a-1].push_back(b-1);
    }
    dp.resize(n,-1);
    for(int i=0;i<n;i++) {
        if(dp[i] == -1) {
            dfs(i);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 8192
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
c=list(map(int,input().split()))
l=[]
for i in range(q):
  L,R=map(int,input().split())
  l.append([L*10**6+i,R])
l.sort(key=lambda x:x[1])

L=[-1]*(5*10**5+1)

class Bit:
  def __init__(self,n):
    self.size=n
    self.tree=[0]*(n + 1)
    self.depth=n.bit_length()

  def sum(self,i):
    s=0
    while i>0:
      s+=self.tree[i]
      i-=i&-i
    return s

  def add(self,i,x):
    while i<=self.size:
      self.tree[i]+=x
      i+=i&-i

BIT=Bit(n+1)

ans=[0]*q
ct=0
for i in range(q):
  while ct<=l[i][1]:
    if L[c[ct-1]-1]!=-1:
      BIT.add(L[c[ct-1]-1],-1)
    L[c[ct-1]-1]=ct+1
    BIT.add(ct+1,1)
    ct+=1
  ans[l[i][0]%10**6]=BIT.sum(l[i][1]+1)-BIT.sum(l[i][0]//10**6)

for i in range(q):
  print(ans[i])

Measured memory_bytes: 221972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
int main(){
    string l;
    cin>>l;
    ll dp[100005][2];
    rep(i,100005) rep(j,2) dp[i][j] = 0;
    dp[0][0] = 1;
    rep(i,100003){
        { // a + b == 0
            if(l[i]=='0'){
                dp[i+1][0] += dp[i][0]%mod;
                dp[i+1][1] += dp[i][1]%mod;
                dp[i+1][0] %=mod;
                dp[i+1][1] %=mod;
            } else {
                dp[i+1][1] += (dp[i][1] + dp[i][0])%mod;                
                dp[i+1][1] %=mod;
            }
        }
        { // a + b == 1
            if(l[i]=='0'){
                // dp[i+1][0] += dp[i][0];
                dp[i+1][1] += 2*dp[i][1]%mod;
                dp[i+1][1] %=mod;
            } else {
                dp[i+1][0] += (2*dp[i][0])%mod;
                dp[i+1][1] += (2*dp[i][1])%mod;
                dp[i+1][0] %=mod;
                dp[i+1][1] %=mod;                
            }
        }
    }
    cout<<(dp[l.size()][0] + dp[l.size()][1])%mod<<endl;
    return 0;
}

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


int main() {
  int N, D;
  cin >> N >> D;
  vector<pair<long double, long double>> pq(N);
  
  for(int i=0; i<N; i++){
    cin >> pq.at(i).first >> pq.at(i).second;
  }
  int count = 0;
  for(int i=0; i<N; i++){
    long double x;
    x = sqrtl(pow(pq.at(i).first, 2.0) + pow(pq.at(i).second, 2.0));
 	 if(x <= D )
 	   count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 9576
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> Pi;
typedef queue<Pi> QPi;
typedef pair<ll, ll> Pll;
typedef queue<Pll> QPll;
typedef vector<vi> Graph;
const int mod = 1000000007;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  double r;
  cin >> r;
  double ans=2*M_PI*r;
  cout << fixed << setprecision(4) << ans << endl;
  return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(n,v) for(int64_t i=0;i<(n);i++){cin >> (v).at(i);}

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

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

int ctoi(char c){
  return c - '0';
}

int main(){
  I a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e - a > k){
    cout << ":(" << endl;
  }else{
    cout << "Yay!" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#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() {
    ll x, k ,d;
    cin >> x >> k >> d;
    ll ans =0;
    x = abs(x);
    // x - kd > 0
    if (x/d > k) {
        ans =  x - k*d;
    } else {
        ll t = x/d;
        ans = x - t*d;
        k -= t;
        if(k%2==1) ans = abs(ans-d);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
B=[int(input()) for j in range(N)]
for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            A[i][j]=0
for i in range(3):
    if len(set(A[i]))==1:
        print("Yes")
        exit()
    if A[0][i]==A[1][i]==A[2][i]==0:
        print("Yes")
        exit()
if A[0][0]==A[1][1]==A[2][2]==0 or A[0][2]==A[1][1]==A[2][0]==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <stdio.h>

int main(){

  int i;
  int n = 0;
  int count = 0;
  int a;

  while(1){
    scanf("%d", &n);
    if(n == 0){
      break;
    }

    for(i = n / 4; i >= 1; i--){
      scanf("%d", &a);
      count = count + a;
    }

    printf("%d\n", count);
    count = 0;
  }


  return 0;
}

Measured memory_bytes: 600
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt"); return;
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }


    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var n     = int.Parse(spl[0]);
        var k     = int.Parse(spl[1]);
        var s     = long.Parse(spl[2]);
        
        long z = s-1;
        if (z == 0) z = 100;

        var buil = new StringBuilder();

        for(int i=0; i<n; i++) {
            if (k > 0) {
                buil.Append(s);
                k--;
            } else {
                buil.Append(z);
            }
            buil.Append(' ');
        }

        return buil.ToString();
    }
}


Measured memory_bytes: 22620
<?php
fscanf(STDIN, "%d %d", $n, $m);
$wd = array_sum(explode(" ", fgets(STDIN)));
if($n == $wd) {
    echo 0;
} elseif($n > $wd) {
    echo $n - $wd;
} else {
    echo -1;
}
echo PHP_EOL;

Measured memory_bytes: 16604
import sys
import numpy as np

# inputを高速化する。
input = sys.stdin.readline

# 入力
vacation = int(input())
lst_happiness = [list(map(int, input().split())) for i in range(vacation)]

# lst_happinessをndarrayにする。
arr_happiness_a = np.array([lst_happiness[i][0] for i in range(vacation)])
arr_happiness_b = np.array([lst_happiness[i][1] for i in range(vacation)])
arr_happiness_c = np.array([lst_happiness[i][2] for i in range(vacation)])

# DPのndarrayを作る。
dp_a = np.zeros(vacation, dtype=int)
dp_b = np.zeros(vacation, dtype=int)
dp_c = np.zeros(vacation, dtype=int)

# dpに初期値を入れる。
dp_a[0] = arr_happiness_a[0]
dp_b[0] = arr_happiness_b[0]
dp_c[0] = arr_happiness_c[0]

for i in range(1, vacation):
    dp_a[i] += max(dp_b[i-1], dp_c[i-1]) + arr_happiness_a[i]
    dp_b[i] += max(dp_a[i-1], dp_c[i-1]) + arr_happiness_b[i]
    dp_c[i] += max(dp_a[i-1], dp_b[i-1]) + arr_happiness_c[i]

ans = max(dp_a[vacation-1], dp_b[vacation-1], dp_c[vacation-1])
print(ans)

Measured memory_bytes: 44800
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
vector<int>p[100000];
queue<int>q;
int v1[100000];
int v2[100000];
int n;
void dfs1(){
int j,x,y;
q.push(1);
q.push(0);
while(!q.empty()){
x=q.front();
q.pop();
y=q.front();
q.pop();
for(int i=0;i<p[x].size();i++){
j=p[x][i];
if(v1[j]==0){
v1[j]=y+1;
q.push(j);
q.push(y+1);
}}}}
void dfs2(){
int j,x,y;
while(!q.empty())
q.pop();
q.push(n);
q.push(0);
while(!q.empty()){
x=q.front();
q.pop();
y=q.front();
q.pop();
for(int i=0;i<p[x].size();i++)
{j=p[x][i];
if(v2[j]==0)
{
v2[j]=y+1;
q.push(j);
q.push(y+1);
}}}}
int main(){
int j,k,x,y;
cin>>n;
for(int i=1;i<n;i++){
cin>>x>>y;
p[x].push_back(y);
p[y].push_back(x);
}
for(int i=0;i<100000;i++)
if(v1[i]!=0)
v1[i]=0;
v1[1]=-1;
dfs1();
for(int i=0;i<100000;i++)
if(v2[i]!=0)
v2[i]=0;
v2[n]=-1;
dfs2();
v2[n]=-1;
y=0;
for(int i=1;i<=n;i++)
if(v2[i]<v1[i])
y++;
x=n-y;
if(x>y)
cout<<"Fennec";
else
cout<<"Snuke";
system("pause");
return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int,int> P;
const int INF = 1e9;


int main(){
    int N, M; cin >> N >> M;
    vector<vector<int>> to(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
    }

    int S, T; cin >> S >> T;
    S--; T--;
    queue<P> q;
    q.push(P(S, 0));

    int d[N][3];
    rep(i, N) rep(j, 3) d[i][j]=INF;
    d[S][0]=0;

    // BFS
    while (!q.empty()) {
        int v = q.front().first;
        int lo = q.front().second;
        q.pop();
        for (auto u:to[v]) {
            int a = (lo + 1) % 3;
            if (d[u][a] != INF) continue;
            d[u][a] = d[v][lo] + 1;
            q.push(P(u, a));
        }
    }
    int ans = d[T][0];
    if (ans == INF) cout << -1 << endl;
    else cout << ans / 3 << endl;

    return 0;
}

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

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

using ll = long long;
#define INF 1e9

int main(){
  ll H, W;
  cin >> H >> W;
  ll maxs, mins, ans = INF*INF;

  if(W % 3 == 0 || H % 3 == 0){
    ans = 0;
  }
  else{
    ans = min(W, H);
  }

  vector<ll> s(3);
  FOR(h, 1, H){
    ll s1 = h * W;
    ll s2 = (H-h) * (W/2);
    ll s3 = s2;
    if(W % 2) s3+=(H-h);
    maxs = max(s1, max(s2, s3));
    mins = min(s1, min(s2, s3));
    //cout << h << " " << maxs - mins << endl;
    ans = min(ans, maxs - mins);
  }
  FOR(w, 1, W){
    ll s1 = H*w;
    ll s2 = (H/2)*(W-w);
    ll s3 = s2;
    if(H%2) s3 += (W-w);
    maxs = max(s1, max(s2, s3));
    mins = min(s1, min(s2, s3));
    //cout << w << " " << maxs - mins << endl;
    ans = min(ans, maxs - mins);
  } 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define s second
#define f first
long long const mod = 1000000007;
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

ll power(ll x,ll y,ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;
    return (y%2 == 0)? p : (x * p) % m;
}

ll modInv(ll x)
{
    return power(x,mod-2,mod)%mod;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    
    string s;
    cin>>s;
    ll n=s.length();
    bool flag=true;
    for(int i=0;i<n;i=i+2)
    {
        if(s[i]=='h')
        {
            if(i+1<n && s[i+1]=='i')
            {
                continue;
            }
            else
            {
                flag=false;
                break;
            }
        }
        else
        {
            flag=false;
            break;
        }
    }
    if(flag)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    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 all(obj) (obj).begin(),(obj).end()
typedef long long ll;
ll mod=ll(1e9)+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  vector<int> a(n);
  double tot=0;
  rep(i,n){
    cin>>a[i];
    tot+=a[i];
  }
  int tmp=0;
  rep(i,n){
    if(a[i]>=tot/(4*m))tmp++;
  }
  if(tmp>=m)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define p_ll pair<ll, ll>
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int a, b; cin >> a >> b;
  string result;
  if (a+b==15) result = "+";
  else if (a*b==15) result = "*";
  else result = "x";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

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

  vector<ll> dn, dn_1;

  for (ll i = 1; i*i <= n; i++) {
    if (n % i == 0) {
      dn.push_back(i);
      if (n/i != i) {
        dn.push_back(n/i);
      }
    }
    if ((n-1) % i == 0) {
      dn_1.push_back(i);
      if ((n-1)/i != i) {
        dn_1.push_back((n-1)/i);
      }
    }
  }
  int ans = dn_1.size()-1;

  for (int i = 0; i < dn.size(); i++) {
    if (dn[i] == 1) continue;
    ll a = n;
    while(a%dn[i] == 0) {
      a /= dn[i];
    }
    if (a % dn[i] == 1){
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int dfs(int d, int n, int k) {
  if (n == 1) return min(d*2, d+k);
  return min(dfs(d*2, n-1, k), dfs(d+k, n-1, k));
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, k;
  cin >> n >> k;
  cout << dfs(1, n, k) << endl;
  return 0;
}


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

int main(void) {
	int N, a0, a1, ans;
	int sig;

	ans = 1;
	cin >> N;
	cin >> a0;
	if (N == 1) {
		cout << ans << '\n';
		return 0;
	}
	sig = 0;
	for (int i = 2; i <= N; ++i) {
		cin >> a1;
		if (sig > 0) {
			if (a1 < a0) {
				sig = 0;
				++ans;
			}
		}
		else if (sig < 0) {
			if (a1 > a0) {
				sig = 0;
				++ans;
			}
		}
		else {
			if (a1 != a0)
				sig = (a1 > a0) ? 1 : -1;
		}
		a0 = a1;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int ar[100005];
int inc[100005];
int dec1[100005];
int32_t main(){
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
	}
	inc[n]=1;
	for(int i=n-1;i>=1;i--){
		if(ar[i]<=ar[i+1]){
			inc[i]=inc[i+1]+1;
		}
		else {
			inc[i]=1;
		}
	}
	dec1[n]=1;
	for(int i=n-1;i>=1;i--){
		if(ar[i]>=ar[i+1]){
			dec1[i]=dec1[i+1]+1;
		}
		else {
			dec1[i]=1;
		}
	}
	int ans = 0;
	int i=1;
	while(i<=n){
		ans++;
		//cout<<i<<" ";
		i+=max(inc[i],dec1[i]);
	}
	/*cout<<"\n";
	for(int i=1;i<=n;i++){
		cout<<inc[i]<<" ";
	}
	cout<<"\n";
	for(int i=1;i<=n;i++){
		cout<<dec1[i]<<" ";
	}
	cout<<"\n";*/
	cout<<ans;
}


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

using namespace std;

int n;
double p;
vector<double> v;
double dp[3000][1501];
double more_heads(int i, int left)
{
    if(left==0)
        return 1;
    if(i==n && left)
        return 0;

    if(dp[i][left]!=-1)
        return dp[i][left];
    else
        return dp[i][left]=more_heads(i+1,left-1)*v[i] + more_heads(i+1,left)*(1-v[i]);
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
  	cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>p;
        v.push_back(p);
    }

    for(int i=0; i<=n; i++)
        for(int j=0; j<=(n+1)/2; j++)
            dp[i][j]=-1;

    cout<<setprecision(10)<<more_heads(0,(n+1)/2)<<endl;
}


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

using namespace std;

#define boost                         \
    ios_base::sync_with_stdio(false); \
    fin.tie(NULL);                    \
    fout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll, ll>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923

int main()
{
    // boost;
    // ifstream fin;
    // fin.open("./fb_d1.txt");
    // ofstream fout;
    // fout.open("./d1_out.txt");

    time_t tic, toc;
    ll tt = 1, n, m, k = 0, i, j, p, q;
    ll a, b, c, h, w, u, v, x, y, t;
    ll l = 0, r = 0;
    ll ans = 0;

    bool poss = true;

    string s;

    // cin >> tt;
    tic = clock();
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> n;
        cin >> s;

        i = 0, j = n - 1;
        ans = 0;
        while(i < j){
            while(i < n and s[i] == 'R') i++;
            while(j >= 0 and s[j] == 'W') j--;

            if(j < i) break;
            swap(s[i], s[j]);
            ans++;
        }
        cout << ans << nl;
    }
    // fin.close();
    // fout.close();
    // cerr << (clock() - tic*1.0) / CLOCKS_PER_SEC << nl;
    return 0;
}


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

int main()
{
    int N;
    cin >> N;
    int tmp;
    cin >> tmp;
    int ans = 0;
    for (int i = 0; i < N-1; i++)
    {
        int tmp2;
        cin >> tmp2;
        if (tmp == tmp2)
        {
            ans++;
            i++;
            cin >> tmp;
        }
        else
        {
            tmp = tmp2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1005;
const int M=20005;
ll dp[2][M];
int c,p=1;
int v[N],w[N],s[N],id[N];
bool comp(int i, int j){ return w[i]+s[i]<w[j]+s[j];}
int main()
{
	int n,i,j,k;
	scanf("%i",&n);
	for(i=1;i<=n;i++) scanf("%i %i %i",&w[i],&s[i],&v[i]),id[i]=i;
	sort(id+1,id+1+n,comp);
	for(j=1;j<=n;j++)
	{
		i=id[j];
		for(k=M-1;~k;k--)
		{
			dp[c][k]=dp[p][k];
			if(k<=s[i]) dp[c][k+w[i]]=max(dp[c][k+w[i]],dp[p][k]+v[i]);
		}
		c^=1;p^=1;
	}
	ll ans=0;
	for(i=0;i<M;i++) ans=max(ans,dp[p][i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int h, w;

int main(void) {
    int row, col;
    
    while (1) {
        scanf("%d%d", &h, &w);
        if (h == 0 && w == 0) break;
        
        for (row = 1; row <= h; ++row) {
            for (col = 1; col <= w; ++col) {
                if (row == 1 || row == h || col == 1 || col == w) {
                    printf("#");
                } else {
                    printf(".");
                }
            }
            
            printf("\n");
        }
        
        printf("\n");
    }
    
    return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,s,dp[2*100001][2];

ll solve(ll arr[],int idx,int prev)
{
  if(idx>=n) return 0;
  if(dp[idx][prev]!=-(1e9 +7)) return dp[idx][prev];
  if(prev==0)
  {
    return dp[idx][prev]=max(arr[idx]+solve(arr,idx+2,0),arr[idx+1]+solve(arr,idx+2,1));
  }
  else
  {
    return dp[idx][prev]=arr[idx+1]+solve(arr,idx+2,1);
  }
}

int main()
{

    ll m; cin>>m;
    cin>>n;
    ll arr[n],sum=0;
    for(int i=0;i<n;i++)
    {
      cin>>arr[i]; sum+=arr[i];
    }
    if(sum>m) cout<<-1;
    else cout<<m-sum;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    string s;
    cin >> s;
    bool flag = true;
    rep(i,s.size())
    {
        if( (i+1)%2 == 0 )
        {
            if( s[i] == 'L' || s[i] == 'U' || s[i] == 'D' ) continue;
            else flag = false;
        }
        else
        {
            if( s[i] == 'R' || s[i] == 'U' || s[i] == 'D' ) continue;
            else flag = false;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=1000+10;
char ch[N];
bool b;
int main(){
	scanf("%s",ch+1);
	int n=strlen(ch+1);
	for(int i=1;i<=n;i++){
		if(ch[i]=='C')b=1;
		if(b&&ch[i]=='F'){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if(A+B > C+D) puts("Left");
    else if(A+B == C+D) puts("Balanced");
    else puts("Right");
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int absolute(int n){
    if(n < 0) n = (-1)*n;
    return n;
}
int main()
{
    int a, b, c, i, j, min, temp, ara[4];
    for(i=1; i<=3; i++)
    {
        scanf("%d", &ara[i]);
    }
    for(i=1; i<=2; i++){
        for(j=i+1; j<=3; j++){
            if(ara[i] > ara[j]){
                temp = ara[i];
                ara[i] = ara[j];
                ara[j] = temp;
            }
        }
    }
    printf("%d\n", ara[3] - ara[1]);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

ll cum[3][4020];

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

    ll N;
    string S;
    cin >> N >> S;

    map<char, int> col;
    col['R'] = 0;
    col['G'] = 1;
    col['B'] = 2;

    REP(i, N){
        cum[col[S[i]]][i+1] = 1;
    }
    REP(i, 3){
        REP(j, 4019) cum[i][j+1] += cum[i][j];
    }

    ll res = 0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(S[i]==S[j]) continue;
            ll tar = (3 - col[S[i]] - col[S[j]])%3;
            ll tmp = cum[tar][N+1] - cum[tar][j+1];
            if(j+(j-i)<N and col[S[j+(j-i)]]==tar)  tmp--;
            res += tmp;
        }
    }
    cout << res << endl;

    return 0;
}

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

signed main()
{
    double x1,y1,x2,y2,x3,y3; cin>>x1>>y1>>x2>>y2>>x3>>y3;

    double a=hypot(abs(x1-x2),abs(y1-y2));
    double b=hypot(abs(x2-x3),abs(y2-y3));
    double c=hypot(abs(x3-x1),abs(y3-y1));

    double s=(a+b+c)/2;
    double S=sqrt(s*(s-a)*(s-b)*(s-c));
    double r=S/s;

    double ok=0.0,ng=max({a,b,c});
    for(int i=0;i<1000;i++){
        double mid=(ok+ng)/2;
        if(max({a,b,c})*(r-mid)/r>=2*mid){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    cout<<fixed<<setprecision(10)<<ok<<endl;
}


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

using namespace std;
vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m)
{ return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//

vector<ll> p(101010, 0);
vector<ll> r(101010, 0);
vector<ll> sz(101010, 1);

ll get(ll x)
{
	if (p[x] != x)
		p[x] = get(p[x]);
	return p[x];
}

void un(ll x, ll y){
	x = get(x);
	y = get(y);
	if(x == y)
		return;
	if(r[x] == r[y]){
		r[x]++;
	}
	if(r[x] < r[y])
	{
		p[x] = y;
		sz[y] += sz[x];
	}else{
		p[y] = x;
		sz[x] += sz[y];
	}
}

int main()
{
	IOS
	for (int i = 0; i < p.size(); ++i)
	{
		p[i] = i;
	}
	ll n;
	cin >> n;
	ll res = (n * (n - 1)) / 2;
	ll m;
	cin >> m;
	vector<pll> edges(m);
	for(int i = 0;i < m; ++i)
		cin >> edges[i].first >> edges[i].second;
	reverse(all(edges));
	vector<ll> ans;
	ans.push_back(res);
	for(int i = 0; i < m-1; ++i){
		if(get(edges[i].first) != get(edges[i].second))
		{
			ll s1 = sz[get(edges[i].first)], s2 = sz[get(edges[i].second)];
			res -= (n - s1) * s1;
			res -= (n - s2) * s2;
			res += s1 * s2;
			res += (n - s1 - s2) * (s1 + s2);
			un(edges[i].second, edges[i].first);
		}
		ans.push_back(res);
	}
	reverse(all(ans));
	for(auto i : ans)
		cout << i << '\n';

	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 10000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

vll s(100009),t(100009);
vll truth(100009);


int main(){
    int a,b,q;
    cin>>a>>b>>q;
    vll s,t;
    rep(i,a){
        ll x;
        cin>>x;
        s.pb(x);
    }
    rep(i,b){
        ll x;
        cin>>x;
        t.pb(x);
    }
    s.pb(-inf);s.pb(inf);
    t.pb(-inf);t.pb(inf);

    sort(all(s));
    sort(all(t));

    rep(i,q){
        ll x;
        cin>>x;
        int sright=lower_bound(all(s),x)-s.begin();
        int sleft=sright-1;
        int tright=lower_bound(all(t),x)-t.begin();
        int tleft=tright-1;

        ll ss[2]={s[sleft],s[sright]};
        ll ts[2]={t[tleft],t[tright]};
        ll ans=inf;
        rep(j,2){
            rep(k,2){
                ans=min(ans,abs(ss[j]-ts[k])+min(abs(ss[j]-x),abs(ts[k]-x)));
            }
        }
        cout<<ans<<endl;
        
    }
}

Measured memory_bytes: 5492
#include <stdio.h>
#define NIL -1

typedef struct{
  int parent;
  int left;
  int right;
} Node;

Node T[25];

void preParse(int u);
void inParse(int u);
void postParse(int u);

int main(){
  int n,m,i,j,t;

  scanf("%d",&n);

  for(i=0; i < n; i++){
    T[i].parent = NIL;
  }

  for(i=0; i < n; i++){
    scanf("%d",&m);
    scanf("%d%d",&T[m].left,&T[m].right);
    if(T[m].left != NIL){
      T[T[m].left].parent = m;
    }
    if(T[m].right != NIL){
      T[T[m].right].parent = m;
    }
  }

  for(i=0; i < n; i++){
    if(T[i].parent == NIL){
      t = i;
      break;
    }
  }


  printf("Preorder\n");
  preParse(t);
  printf("\n");

  printf("Inorder\n");
  inParse(t);
  printf("\n");

  printf("Postorder\n");
  postParse(t);
  printf("\n");
  
  return 0;
}
void preParse(int u){
  if(u == NIL) return;
  printf(" %d",u);
  preParse(T[u].left);
  preParse(T[u].right);
}

void inParse(int u){
  if(u == NIL) return;
  inParse(T[u].left);
  printf(" %d",u);
  inParse(T[u].right);
}

void postParse(int u){
  if(u == NIL) return;
  postParse(T[u].left);
  postParse(T[u].right);
  printf(" %d",u);
}



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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    int N, R;
    cin >> N >> R;

    int ans;
    if (N < 10) {
        R += 100 * (10 - N);
    }

    cout << R << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int a,b,c;
    cin>>a>>b>>c;
    long long int tmpA,tmpB,tmpC;
    long long int count=0;
    while (a%2==0&&b%2==0&&c%2==0) {
        count++;
        tmpA=(b+c)/2;
        tmpB=(a+c)/2;
        tmpC=(a+b)/2;
        a=tmpA;
        b=tmpB;
        c=tmpC;
        if (count>10000000) {
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <utility>

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1001001001;

vector<bool> visited;
vvi G;

void dfs(int v)
{
    visited[v] = true;
    for(int u : G[v]){
        if(!visited[u]){
            dfs(u);
        }
    }
}

signed main()
{
    int n, m;
    cin >> n >> m;
    G.resize(m);
    
    vi appear;
    
    rep(i, n){
        int k;
        cin >> k;
        vi lang(k);
        rep(j, k){
            cin >> lang[j];
            lang[j]--;
            appear.push_back(lang[j]);
        }
        rep(j, k-1){
            int a = lang[j];
            int b = lang[j+1];
            G[a].push_back(b);
            G[b].push_back(a);
        }
    }
    
    visited.assign(m, false);
    dfs(appear[0]);
    
    for(int l : appear){
        if(!visited[l]){
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;
}


Measured memory_bytes: 6008
N, K = map(int, input().split())
p = list(map(int, input().split()))
a = list(map(lambda p_i: (p_i+1)/2, p))
ans = sum(a[:K])
m = sum(a[:K])

for i in range(N-K):
    ans = ans - a[i] + a[i+K]
    m = max(m, ans)

print(m)

Measured memory_bytes: 77448
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>


#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;

using namespace std;

ll modd = 1000 * 1000 * 1000 + 7;

class UnionFind {
    public:
      vector<int> parent;
      vector<int> size;
//      size[i] = number of nodes in tree rooted at i
// Note: not necessarily correct if i is not a root node
      set<int> roots;

    UnionFind(int n) : parent(n), size(n) {
        forr(i,0,n) { roots.insert(i); }
        forr(i,0,n) {
            parent[i] = i; size[i] = 1;
        }
    } 

    int Find(int p) {
        int root = p;
        while (root != parent[root]) {  root = parent[root]; }
        while (p != root) {
            int newp = parent[p];
            parent[p] = root;
            p = newp;
        }
        return root;
    }

    void Union(int p, int q) {
        int rootP = Find(p);
        int rootQ = Find(q);
        if (rootP == rootQ) return;

        if (size[rootP] < size[rootQ]) {
            parent[rootP] = rootQ;
            size[rootQ] += size[rootP];
            roots.erase(rootP);
        }
        else {
            parent[rootQ] = rootP;
            size[rootP] += size[rootQ];
            roots.erase(rootQ);
        }
    }

};


int main()   {

      ios_base::sync_with_stdio(false);

      cout.precision(17);
      mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
      uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n);
        map<int,int> c;
        vector<int> dict;
        forr(i,0,n) {
            readint(a); readint(b);
            c[a] = b;
            dict.push_back(a);
        }
        UnionFind uf(n+1);
        map<int,int> lowest_y;
        for(auto x : c) {
            bool connected = false;
            for(auto it = lowest_y.begin(); it != lowest_y.end(); ++it) {
                if (it->first < x.second) {
                    connected = true;
                    int which = it->second;
                    uf.Union(which, x.first);
                } else {
                    break;
                }
            }
            if (!connected) {
                lowest_y[x.second] = x.first;
            }
        }

        forr(i,0,n) {
            cout << uf.size[ uf.Find(dict[i])  ] << endl;
        }

    }
    return 0;
}


Measured memory_bytes: 24328
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
bool dislike[256]={};
bool solve(string s){
  for(char c:s) if(dislike[c]) return true;
  return false;
}
int main(void)
{
  int n,k;
  cin >> n >> k;
  REP(i,k){
    string tmp;
    cin >> tmp;
    dislike[tmp[0]]=true;
  }
  while(solve(to_string(n))) ++n;
  cout << n << endl;
  return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
    int N;
    cin >> N;
    vector<int> arr(N);
    for (int i = 0; i < N; i++) {
        cin >> arr[i];
    }

    int sum = 0;
    for (int j = 0; j < N; j++) {
        for (int k = 0; k < N; k++) {
            if (j == k) continue;
            sum += (arr[j] * arr[k]);
        }
    }
    cout << (sum / 2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

signed main() {
    INIT;
    cin >> N;
    cout << 800 * N - 200 * (N / 15) << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B;
    string S,ans = "Yes";
    cin >> A >> B >> S;
    bool judge = true;
    for(int i = 0;i < A+B+1;i ++){
        if(i==A && S[A]!='-') ans = "No";
        else if(i!=A && !isdigit(S[i])) ans = "No"; 
    }
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	s := getNextString(scanner)

	c := 0
	l := 0
	for i := 0; i < n; i++ {
		if s[i] == '(' {
			c++
			continue
		}
		if c == 0 {
			l++
			continue
		}
		c--
	}
	for i := 0; i < l; i++ {
		fmt.Fprint(writer, "(")
	}
	fmt.Fprint(writer, s)
	for i := 0; i < c; i++ {
		fmt.Fprint(writer, ")")

	}
	fmt.Fprintln(writer, "")
	writer.Flush()
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n,a[100005];
ll dp[100005];
ll k;
//<<-----Implement Functions Here---->>//
ll solve(ll pos)
{
	if(pos>n)return 1e+18;
	if(pos==n)return 0;
	if(dp[pos]!=-1)return dp[pos];
	ll ans = 1e+18;
	for(ll i=1;i<=k;i++)
	{	
		ans = min(ans,abs(a[i+pos]-a[pos])+solve(pos+i));
	}
	return dp[pos] = ans;
}

//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>n>>k;
		for(ll i=0;i<=n;i++)dp[i] = -1;
		for(ll i=1;i<=n;i++)cin>>a[i];
		cout<<solve(1);
		

}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

  
}

Measured memory_bytes: 8576
N,K=map(int,input().split())
A=list(map(int, input().split())) 
ans0=sum(A[0:K])
ans=ans0
for i in range(0,N-K):
  ans=ans-A[i]+A[K+i]
  if ans>ans0:
    ans0=ans
    
ans=(ans0+K)*0.5
print(ans)

Measured memory_bytes: 24812
#include <stdio.h>
#include <stdlib.h>

void liner_search(int *S, int *T, int n, int q);
void binery_search(int *S, int *T, int n, int q);

int main(void)
{
    int n,q;
    int *S,*T;
    int i;

    scanf("%d", &n);
    S = calloc(n, sizeof(int));
    
    for (i = 0; i < n; i++){
        scanf("%d", &S[i]);
    }

    scanf("%d", &q);
    T = calloc(q, sizeof(int));

    for (i = 0; i < q; i++){
        scanf("%d", &T[i]);
    }

    //liner_search(S, T, n, q);
    binery_search(S, T, n, q);

    return (0);
}

void liner_search(int *S, int *T,int n, int q)
{
    int i,j;
    int count;

    count = 0;
    for (i = 0; i < q; i++){
        j = 0;
        while (j < n){
            if (S[j] == T[i]){
                count++;
                break;
            }
            j++;
        }
    }
    printf("%d\n", count);


}
void binery_search(int *S, int *T, int n, int q)
{
    int i;
    int count;
    int left,right,center;

    count = 0;
    for (i = 0; i < q; i++){
        left = 0;
        right = n;
        while (left < right){
            center = (left + right) / 2;
            if (S[center] == T[i]){
                count++;
                break;
            }else if (T[i] < S[center]){
                right = center;
            }else{
                left = center + 1;
            }
        }
    }
    printf("%d\n", count);
}


Measured memory_bytes: 2280
n=int(input())
l=list(map(int,input().split()))
l1=sorted(l)
import copy
if l1[0]==0:
  print(0)
else:
  d={}
  for i in range(1,13):
    d[i]=0
  for i in range(n):
    d[l1[i]]+=1
#12時を高橋くんの時刻とする
  d1=[]
  d2=[]
  d1.append(12)
  for i in range(1,13):
    if d[i]>=3:
      print(0)
      exit()
    elif d[i]==2:
      d1.append(12+i)
      d1.append(12-i)
      d[i]=0
    elif d[i]==1:
      d2.append(i)
  #ここまでで登場回数1のみが残る
  num=len(d2)
  num1=2**num-1
  bitlist=[]
  b=[]
  while num1!=0:
    b.append(num1%2)
    num1//=2
  bitlist.append(b)
  for i in range(2,2**num+1):
    num1=2**num-i
    b=[]
    while num1!=0 or len(b)<len(bitlist[0]):
      b.append(num1%2)
      num1//=2
    bitlist.append(b)
  #1なら12+i1 0なら12-i
  m=0
  for i in range(2**num):
    d3=copy.deepcopy(d1)
    b1=bitlist[i]
    m1=24
    for j in range(num):
      if b1[j]==1:
        d3.append(12+d2[j])
      else:
        d3.append(12-d2[j])
    d3=sorted(d3)
    for i in range(1,len(d3)):
      if m1>d3[i]-d3[i-1]:
        m1=d3[i]-d3[i-1]
    if m1>(24-d3[-1])+d3[0]:
      m1=(24-d3[-1])+d3[0]
    if m<m1:
      m=m1
  print(m)

Measured memory_bytes: 3572
#include <stdio.h>

typedef struct {
	int left,right;
} oyaki_t;

int isok(const oyaki_t *oyaki,int N,int W) {
	static int imos[100010];
	int i;
	for(i=0;i<W;i++)imos[i]=0;
	for(i=0;i<N;i++) {
		imos[oyaki[i].left>=0?oyaki[i].left:0]++;
		imos[oyaki[i].right<=W?oyaki[i].right:W]--;
	}
	if(imos[0]==0)return 0;
	for(i=1;i<W;i++) {
		imos[i]+=imos[i-1];
		if(imos[i]<=0)return 0;
	}
	return 1;
}

int main(void) {
	int N,W,H;
	int i;
	static oyaki_t ox[100000];
	static oyaki_t oy[100000];
	if(scanf("%d%d%d",&N,&W,&H)!=3)return 1;
	for(i=0;i<N;i++) {
		int x,y,w;
		if(scanf("%d%d%d",&x,&y,&w)!=3)return 1;
		ox[i].left=x-w;
		ox[i].right=x+w;
		oy[i].left=y-w;
		oy[i].right=y+w;
	}
	puts((isok(ox,N,W) || isok(oy,N,H))?"Yes":"No");
	return 0;
}

Measured memory_bytes: 2536