akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    //n even
    //m odd
    //nC2
    //mC2
    int ans = n*(n-1)/2;
    ans+=m*(m-1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pf push_front
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main(){
  int n;
  cin>>n;
  int a[200005];
  rep(i,n)cin>>a[i];
  deque<int> dq;
  int x=(n%2==0?0:1);
  loop(i,1,n+1){
    if((i%2==1&&x==1)||(i%2==0&&x==0)){
      dq.pf(a[i-1]);      
    }else{
      dq.pb(a[i-1]);
    }
  }

  rep(i,n){
    cout<<dq[i];
    if(i<n-1)cout<<' ';
  }
  cout<<endl;
  return 0;
}


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

using namespace std;

int main()
{
    int r,c,k;
    scanf("%d%d%d",&r,&c,&k);
    char s[r][c+1];
    for(int o=0;o<r;o++) scanf("%s",s[o]);
    int a[r][c];
    for(int o=0;o<r;o++) for(int i=0;i<c;i++) a[o][i]=0;
    int num=0;
    int idx=1;
    for(int o=0;o<r;o++)
    {
        int cnt=0;
        for(int i=0;i<c;i++) cnt+=(s[o][i]=='#');
        if(cnt==0)
        {
            num++;
            continue;
        }
        int fruit=0;
        for(int i=0;i<c;i++)
        {
            for(int j=o-num;j<=o;j++) a[j][i]=idx-(fruit==cnt);
            if(s[o][i]=='#')
            {
                fruit++;
                idx++;
            }
        }
        num=0;
    }
    for(int o=r-num;o<r;o++) for(int i=0;i<c;i++) a[o][i]=a[o-1][i];
    for(int o=0;o<r;o++) for(int i=0;i<c;i++) printf("%d%c",a[o][i]," \n"[i==c-1]);
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
using namespace std;
struct node
{
    char str[11];
    int t;
};
node a[100001];
int main()
{
    int n,q;
    while(scanf("%d%d",&n,&q)!=EOF)
    {
        queue<node> Q;
        for(int i=0;i<n;i++)
        {
            scanf("%s",a[i].str);
            scanf("%d",&a[i].t);
            Q.push(a[i]);
        }
        int sum=0;
        while(!Q.empty())
        {
            if(Q.front().t<=q)
            {
                sum+=Q.front().t;
                printf("%s %d\n",Q.front().str,sum);
                Q.pop();
            }
            else
            {
                Q.front().t-=q;
                sum+=q;
                Q.push(Q.front());
                Q.pop();
            }
        }
    }
    return 0;
}



Measured memory_bytes: 4548
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
answer = 0
for x in range(1, N+1):
    y = 0
    while True:
        if x * 2 ** y >= K:
            break
        y += 1
    answer += (.5) ** y

answer /= N
print(answer)


Measured memory_bytes: 3060
n, m, c = map(int, input().split())
B = list(map(int, input().split()))
ans = 0

for i in range(n):
	A = list(map(int, input().split()))
	temp = 0
	for j in range(m):
		temp += A[j]*B[j]
		
	if(temp + c > 0):
		ans += 1

print(ans)


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int N, K;
int a[1111];
vec<int> cand;
int dp[1111111];
int use[44];

int cntt(int a) {
   int ret = 0;
   for (int x : cand) {
      if ((x & a) == a) {
         ret++;
      }
   }
   return ret;
}

signed main() {
   cin >> N >> K;
   rep (i, N) { cin >> a[i+1]; }
   repp (i, 1, N+1) { a[i] += a[i-1]; }

   for (int i = 1; i <= N; i++) {
      for (int j = 0; j < i; j++) {
         cand.push_back(a[i] - a[j]);
      }
   }

   int mask = 0;

   for (int i = 40; i >= 0; i--) {
      if (cntt(mask | (1LL << i)) >= K) {
         mask |= (1LL << i);
      }
   }

   cout << mask << endl;

   return 0;
}

Measured memory_bytes: 6384
def chmin(DP,b,i):
    if (DP[i]> b):
        DP[i] = b
        return True
    return False
N = int(input())
H = [i for i in map(int,input().split())]
dp = [10**10 for i in range(N)]
dp[0] = 0
for i in range(1,N):
    chmin(dp,dp[i-1]+abs(H[i]-H[i-1]),i)
    if i > 1:
        chmin(dp,dp[i-2]+abs(H[i]-H[i-2]),i)
print(dp[-1])


Measured memory_bytes: 14052
#include <iostream>
#include <vector>
using namespace std;
int N, M, Q;
vector<long long> a(55), b(55), c(55), d(55);

long long score(const vector<int> &A) {
    long long res = 0;
    for (int i = 0; i < Q; i++) {
        if (A[b[i]] - A[a[i]] == c[i]) res += d[i];
    }
    return res;
}

long long dfs(vector<int> &A) {
    if (A.size() == N) {
        return score(A);
    }
    long long res = 0;
    int prev = (A.empty() ? 0 : A.back());
    for (int i = prev; i < M; i++) {
        A.push_back(i);
        res = max(res, dfs(A));
        A.pop_back();
    }
    return res;
}

int main() {
    cin >> N >> M >> Q;
    int cnt = 0;
    for (int i = 0; i < Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }
    vector<int> A;
    cout << dfs(A) << endl; 
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int count=0;
  cin>>N;
  vector<int>R(N);
  for(int i=0;i<N;i++){
    cin>>R.at(i);
    if(R.at(i)!=i+1){
      count++;
    }
  }
  if(count==0||count==2){
    cout <<"YES"<<endl;
  }
  else{
    cout <<"NO"<<endl;
  }
}

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

int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans = 1;
    for (int i=0;i<n-1;i++) {
        if (s[i] != s[i+1]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){
  int k,x; cin >> k >> x;
  for(int i=x-k+1;i<x+k;i++){
    cout << i << " " ;
  }
  cout << endl;
}


Measured memory_bytes: 3640
N = int(input())
A = [int(input()) for _ in range(N)]
ans = A[0] // 2
A[0] = A[0] % 2
for i in range(1, N):
    if A[i-1] > 0 and A[i-1] + A[i] >= 2:
        ans += 1; A[i] -= 1
    q, r = divmod(A[i], 2); A[i] = r
    ans += q
print(ans)

Measured memory_bytes: 7072
#include <iostream>

using namespace std;
int main(){
   int a[4];
   for(int i=0;i<5;i++){
       cin>>a[i];
   }
   int k;
   cin>>k;
   
  if(a[4]-a[0]<=k){
      cout<<"Yay!"<<endl;
  }else{
      cout<<":("<<endl;
  }
  
    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        N: usize,
        S: String,
    }

    if N % 2 == 1 {
        println!("No");
        return;
    }

    let s1: &str = &S[..N / 2];
    let s2: &str = &S[N / 2..];

    let ans = if s1 == s2 { "Yes" } else { "No" };
    println!("{}", ans);
}


Measured memory_bytes: 2188
import sys
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
readline = sys.stdin.readline
A = [int(i) for i in readline().split()]

A.sort()

CB = []
for _ in range(m):
    b, c = [int(i) for i in readline().split()]
    CB.append([c, b])
    
CB.sort(reverse=True)

idx = 0
c = 0
for i in range(n):
    if A[i] < CB[idx][0]:
        A[i] = CB[idx][0]
        c += 1
    if CB[idx][1] <= c:
        idx += 1
        c = 0
    if idx >= m:
        break

print(sum(A))

Measured memory_bytes: 28368
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

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


signed main() {
	ll n;
	cin >> n;
	VL v(n);
	cin >> v;

	double p = 1;
	REPC(x, v) {
		p *= x;
	}

	double esum = 0;
	REPC(x, v) {
		esum += p / x;
	}

	cout << std::fixed << std::setprecision(10) << (p / esum) << endl;
}

Measured memory_bytes: 256
function Main(input) {
	tmp = input.split(" ");
	var n = tmp[0];
	var m = tmp[1];
	var a = n-1;
	var b = m-1;
	var c = a*b;
	console.log(c);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef pair<int,int> P;
typedef long long int lnt;
lnt n,a[2000],b[2000],x;
lnt ans,p;
int main()
{
	cin>>n>>x;
	for(lnt i=0;i<n;i++){
		cin>>a[i];
		b[i]=a[i];
		ans+=a[i];
	}
	for(lnt i=1;i<n;i++){
		lnt sum=0;
		for(lnt j=n;j<2*n;j++){
			b[j%n]=min(b[j%n],a[(j-i)%n]);
			sum+=b[j%n];
		}
		ans=min(ans,sum+x*i);
	}
	cout<<ans<<endl;
}

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(){
  int n;
  cin>>n;
  vector<int> a(n-1);
  vector<int> cnt(n,0);
  rep(i,n-1){
    cin>>a[i];
    cnt[a[i]-1]++;
  }
  rep(i,n)cout<<cnt[i]<<endl;
  return 0;
}

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

int main(){
  string s[3];
  cin >> s[0] >> s[1] >> s[2];
  bool f=true;
  int a[3]={-1,-1,-1};
  int i=0;
  while(f){
    a[i]++;
    if(s[i].size()==a[i]){
      f=false;
      break;
    }
    i=s[i][a[i]]-'a';
  }
  cout << char(i+'A') << endl;
  return 0;
}

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

int main(void){
    int N;
    scanf("%d",&N);

    int range[8]={400,800,1200,1600,2000,2400,2800,3200};
    int color[9]={0,0,0,0,0,0,0,0,0};

    for(int i=0;i<N;i++){
        int a;
        scanf("%d",&a);
        for(int j=0;j<8;j++){
            if(a<range[j]){
                color[j]++;
                break;
            }
        }
        if(a>=3200) color[8]++;
    }

    int min=0;
    for(int i=0;i<8;i++){
        if(color[i]>0) min++;
    }
    int max=min+color[8];
    if(min==0) min=1;
    printf("%d %d\n",min, max);

    return 0;
}

Measured memory_bytes: 128
n,m=map(int,input().split())
ans=10000000000000
for i in range(1,n):
    a=i*m
    nk=n-i
    if nk%2==0:
        b=m*(nk//2)
        ans=min(ans,abs(a-b))
    elif nk>1:
        b=m*((nk+1)//2)
        c=m*((nk-1)//2)
        ans=min(ans,max(a,b,c)-min(a,b,c))
    if m%2==0:
        b=nk*m//2
        ans=min(ans,abs(a-b))
    elif m>1:
        b=nk*(m+1)//2
        c=nk*(m-1)//2
        ans=min(ans,max(a,b,c)-min(a,b,c))

for i in range(1,m):
    a=i*n
    nk=m-i
    if nk%2==0:
        b=n*(nk//2)
        ans=min(ans,abs(a-b))
    elif nk>1:
        b=n*((nk+1)//2)
        c=n*((nk-1)//2)
        ans=min(ans,max(a,b,c)-min(a,b,c))
    if n%2==0:
        b=nk*n//2
        ans=min(ans,abs(a-b))
    elif n>1:
        b=nk*(n+1)//2
        c=nk*(n-1)//2
        ans=min(ans,max(a,b,c)-min(a,b,c))
print(ans)

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

using ll = long long;
#define rep(i,n) for(int i = 0;i < n;i++)

template<class T> bool chmin(T& a,T b){ if(a > b){ a = b; return true; } return false; }
template<class T> bool chmax(T& a,T b){ if(a < b){ a = b; return true; } return false; }
/*
 * Modint struct
 * library author : @snuke
 * */
const int mod = 1e9 + 7;
struct mint {
  long long x; // typedef long long ll;
  mint(long long x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) { if((x+=a.x)>=mod)x-=mod;return *this;}
  mint& operator-=(const mint a) { if((x+=mod-a.x)>=mod)x-=mod; return *this;}
  mint& operator*=(const mint a) { (x *=a.x)%=mod; return *this;}
  mint operator+(const mint a) const { mint res(*this);return res+=a;}
  mint operator-(const mint a) const { mint res(*this);return res-=a;}
  mint operator*(const mint a) const { mint res(*this);return res*=a;}
  mint pow(ll t) const {
    if (!t) return 1;mint a = pow(t>>1);a*=a;
    if (t&1) a *= *this;return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return (*this) *= a.inv();}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct Combination{
    const int MAX = 2000050;
    vector<mint> fact;
    vector<mint> finv;
    Combination():fact(MAX),finv(MAX){
        for(int i = 0;i < MAX;i++){
            if(i == 0)fact[i] = (mint)1;
            else fact[i] = fact[i-1]*(mint)i;
        }
        finv[MAX - 1] = fact[MAX - 1].inv();
        for(int i = MAX - 2;i >= 0;i--){
            finv[i] = finv[i + 1] * (mint)(i + 1);
        }
    }
    mint comb(int n,int r){
        if(r==0)return 1;
        if(n<0||r<0||n<r)return 0;
        else return fact[n]*finv[r]*finv[n-r];
    }
};

Combination  C;

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

    int64_t k;cin >> k;
    string s;cin >> s;

    vector<int> used(26,0);
    for(char x : s) used[x - 'a'] = 1;
    int64_t kind = 0;
    rep(i,26) kind += used[i];

    int64_t m = k + s.size();

    mint ans = 0;
    for(int last = 0;last <= k;last++){
       ans += C.comb(m - last - 1,s.size() - 1) * mint(25).pow(k - last) * mint(26).pow(last);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 35504
import itertools

def solve(n, S):
    initials = ('M', 'A', 'R', 'C', 'H')
    d = {}
    for s in S:
        if s[0] in initials:
            d[s[0]] = d.get(s[0], 0) + 1
    return sum(d[x] * d[y] * d[z] for x, y, z in itertools.combinations(d.keys(), 3))

_n = int(input())
_S = [input() for _ in range(_n)]
print(solve(_n, _S))

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

int main (void) {
    int a, b, ans;

    char op;

    cin >> a >> op >> b;

    if (op == '+') {
        ans = a + b;
    }else if(op == '-'){
        ans = a - b;
    }

    cout << ans << endl;
  
    return 0;
    
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int main(void) {
    int k;

    if(scanf("%d", &k) == 1);

    if (k % 2 == 0) {
        printf("%d", (k / 2) * (k / 2));
    } else {
        printf("%d", (k / 2) * (k / 2 + 1));
    }
    

    return 0;
}

Measured memory_bytes: 128
use std::io;

fn main(){
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let o = buf.trim().chars().collect::<Vec<char>>();
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let e = buf.trim().chars().collect::<Vec<char>>();
	let mut ret:Vec<char> = Vec::new();
	for i in 0..(o.len()+e.len()) {
		if i%2 == 0 {
			ret.push(o[i/2]);
		}else{
			ret.push(e[i/2]);
		}
	}
	for i in ret {
		print!("{}", i);
	}
	println!("");
}

Measured memory_bytes: 4352
N = int(input())

A = list(map(int, input().split()))

dp = [0] * N
dp[0] = 1000

for i in range(1, N):
    dp[i] = dp[i - 1]
    for j in range(i):
        kabu = dp[j] // A[j]
        money = dp[j] + (A[i] - A[j]) * kabu
        dp[i] = max(dp[i], money)

print(dp[-1])

Measured memory_bytes: 9200
while True:
  H, W = map(int, raw_input().split())
  if H == 0 and W == 0:
    break
  print "#"*W
  for i in range(H-2):
    if W > 2:
      print "#" + "."*(W-2) + "#"
    else:
      print "#"*W 
  print "#"*W
  print ""
 

Measured memory_bytes: 6428
#include<bits/stdc++.h>
#define endl "\n" 
#define pi acos(-1)
#define ll long long 
using namespace std;
void att(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
}
void sirra(){
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
}
void solve();
int main(){
	att();sirra();
	int q=1;//cin>>q;
	while(q--){
		solve();
	}
	return 0;
}
void solve(){
	int n,p=0;cin>>n;
    int a[n+1];
    a[0]=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]%2!=0&&i%2!=0)
            p++;
    }
    cout<<p;
}

Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] tmpArray = br.readLine().split(" ");

		//0 origin
		int n = Integer.parseInt(tmpArray[0]);
		int m = Integer.parseInt(tmpArray[1]);
		int x = Integer.parseInt(tmpArray[2]);

		Edge edges[] = new Edge[m];

		for(int i = 0; i < m; i++){
			tmpArray = br.readLine().split(" ");
			int from = Integer.parseInt(tmpArray[0]);
			int to = Integer.parseInt(tmpArray[1]);
			int cost = Integer.parseInt(tmpArray[2]);

			edges[i] = new Edge(from, to, cost);
		}

		solve(edges, n, x);
	}

//	static final int INF = 10_000_001;

	static void solve(Edge[] edges,  int n, int x){
		//xからそれぞれのfarmへの帰り道の最短距離
		int[] dist = shortestPath(edges, n, x);

		if(dist == null){
			System.out.println("NEGATIVE CYCLE");
			return;
		}

		for(int i = 0; i < n; i++){
			if(dist[i] == INF){
				System.out.println("INF");
			}
			else {
				System.out.println(dist[i]);
			}
		}

	}

	static final int INF = Integer.MAX_VALUE;


	static int[] shortestPath(Edge[] edges, int n, int s){
		int dist[] = new int[n];

		Arrays.fill(dist, INF);
		dist[s] = 0;

		int e = edges.length;

		int k = 0;
		while(true){
			boolean update = false;

			for(int i = 0; i < e; i++){
				Edge edge = edges[i];
				if(dist[edge.from] != INF && dist[edge.to] > dist[edge.from] + edge.cost){
					dist[edge.to] = dist[edge.from] + edge.cost;
					update = true;

//					System.out.println("dist:"+edge.to+" is "+dist[edge.to]);

					if(k == n - 1){
						return null;
					}
				}
			}

			if(!update){
				break;
			}

			k++;
		}

		return dist;
	}
}
//
//class Distance implements Comparable<Distance>{
//	int dist;
//	int id;
//
//	Distance(int dist, int id){
//		this.dist = dist;
//		this.id = id;
//	}
//
//	@Override
//	public int compareTo(Distance d) {
//		return this.dist - d.dist;
//	}
//}

class Edge {
	int from;
	int to;
	int cost;

	Edge(int from, int to, int cost){
		this.from = from;
		this.to = to;
		this.cost = cost;
	}
}


Measured memory_bytes: 27852
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

n,m,r=map(int,input().split())
r=list(map(int,input().split()))
abc=[list(map(int,input().split())) for i in range(m)]

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


d = [[float("inf") for i in range(n)] for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(m):
    x,y,z = abc[i]
    x-=1
    y-=1
    d[x][y] = z
    d[y][x] = z
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
warshall_floyd(d)

lst=list(permutations(r))
# print(lst)

ans=float('inf')
for i in range(len(lst)):
    tmp=0
    for j in range(len(lst[i])-1):
        tmp+=d[lst[i][j+1]-1][lst[i][j]-1]
    ans=min(ans,tmp)
print(ans)

Measured memory_bytes: 88152
import math
def check(n):
    if isinstance(n,int):
        return True
    if isinstance(n,float):
        return n.is_integer()
    return False

n,d=map(int,input().split())
info=[]
for i in range(n):
    info.append(list(map(int,input().split())))
#print(info)
count=0
dis=0
for i in range(n-1):#0～n-2
    for j in range(i+1,n): #i+1～n-1
        for k in range(d): #点iと点jの距離を調べる
            #print(str(i)+" "+str(j))
            dis+=abs(info[i][k]-info[j][k])**2
            #print(dis)
        #print(dis)
        dis2=math.sqrt(dis)
        #print(dis2)
        if check(dis2)==True:
            count+=1
        dis=0 #jが変わると初期化
    dis=0 #iが変わると初期化
    
print(count)

Measured memory_bytes: 3064
program prob5
    implicit none
    integer, parameter :: N = 200005
    character(N) :: s, t
    integer :: a(26), b(26), c(26)
    integer :: i, L, j
    read(*,*) s, t
    
    L = len_trim(S)
    do i = 1, 26
        a(i) = 26
    end do

    do i = 1, L
        if(a(ichar(s(i:i)) - ichar('a') + 1) == 26) then
            a(ichar(s(i:i)) - ichar('a') + 1) = ichar(t(i:i)) - ichar('a')
        else
            if(a(ichar(s(i:i)) - ichar('a') + 1) == ichar(t(i:i)) - ichar('a')) then
                cycle
            else
                write(*,*) 'No'
                stop
            end if
        end if
    end do

    do i = 1, 26
        do j = 1, 26
            if(i == j) then
                cycle
            end if
            if(a(i) == 26) then
                cycle
            end if
            if(a(i) == a(j)) then
                write(*,*) 'No'
                stop
            end if
        end do
    end do
    ! b = 0
    ! c = 0
    ! do i = 1, L
    !     b(ichar(s(i:i)) - ichar('a') + 1) = 1
    !     c(ichar(t(i:i)) - ichar('a') + 1) = 1
    ! end do
    ! do i = 1, 26
    !     if(b(i) /= c(i)) then
    !         write(*,*) 'No'
    !         stop
    !     end if
    ! end do

    write(*,*) 'Yes'

    stop
contains
end program prob5

Measured memory_bytes: 3436
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n, k, q;
    cin>>n>>k>>q;
    vector<ll> a(q);
    vector<ll> b(n, 0);
    for(ll i=0;i<q;++i){
        cin>>a[i];
        b[a[i]-1]++;
    }
    for(ll i=0;i<n;++i){
        string ans = "No";
        ll sum = k;
        sum += b[i];
        sum -= q;
        if(sum > 0){
            ans = "Yes";
        }
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	string s, t;
    int ans = INF;
    
    cin>>s>>t;
	
    for(int i = 0; i < s.size(); i++){
        if(i + t.size() >= 1+ s.size()) break;
        
        int con = 0;
        
        for(int j = 0; j < t.size(); j++){
            if(s[i + j] != t[j]) con++;
        }
        
        ans = min(ans, con);
    }
    
    cout<<ans<<endl;
	
	return 0;
}

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

int main() {
    int n,temp,cnt=0;;
    cin>>n;
    map<int,int> mp;
    rep(i,n) {
        cin>>temp;
        if (temp<=399) mp[0]++;
        else if(temp<=799) mp[1]++;
        else if(temp<=1199) mp[2]++;
        else if(temp<=1599) mp[3]++;
        else if(temp<=1999) mp[4]++;
        else if(temp<=2399) mp[5]++;
        else if(temp<=2799) mp[6]++;
        else if(temp<=3199) mp[7]++;
        else cnt++; 
    }
    if (mp.size()==0&&cnt!=0) cout<<1<<" "<<cnt<<endl;
    else cout<<mp.size()<<" "<<mp.size()+cnt<<endl;
}


Measured memory_bytes: 256
N, X, Y = map(int, input().split())

k = [0] * (N + 1)

for i in range(1, N):
    for j in range(i + 1, N + 1):
        if j <= Y:
            k[min(j - i, Y - j + 1 + abs(X - i))] += 1
        else:
            k[min(Y - i, abs(X - i) + 1) + (j - Y)] += 1

for i in range(1, N):
    print(k[i])


Measured memory_bytes: 3444
/*************************************************************************
  > File Name: b.cpp
  > Author: Samuel
  > Mail: enminghuang21119@gmail.com
  > Created Time: Tue Mar 17 19:06:31 2020
*************************************************************************/

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

int h, n, sum;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> h >> n;
    while (n--) {
        int a;
        cin >> a;
        sum += a;
    }
    cout << (sum >= h ? "Yes" : "No") << '\n';
    return 0;
}


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

ll dp[N][N];
string s,t;
int main()
{
    cin>>s>>t;
    ll n=s.size();
    ll m=t.size();
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=m;j++)
    	{
    		if(s[i-1]==t[j-1])
    		dp[i][j]=1+dp[i-1][j-1];
    		else
    		dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    	}
    }
    string str="";
    int i=n;
    int j=m;
    while(i>0&&j>0)
    {
    	  
    	  	if(s[i-1]==t[j-1])
    	  	{
    	  		str=s[i-1]+str;
    	  		i--;
    	  		j--;
    	  	}
    	  else if(dp[i-1][j]>dp[i][j-1])
    	  i--;
    	  else
    	  j--;
    }
    cout<<str<<endl;
	
	return 0;
}

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

#define sz(x) (int)x.size()
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define __ ios_base::sync_with_stdio(cin.tie(0) && 0);

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

const ld pi = 3.141592653589793;
const ll inf = 1e18 + 5;
const int MOD = 1e9 + 7;
const int maxn = 1e5 + 5;

int main() {
  __;

  int n;
  cin >> n;

  cout << (1000 - n % 1000) % 1000 << '\n';

  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
 
 
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集

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

  int a; cin >> a;
  cout << a + a*a + a*a*a << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> used(N);
    rep(i, N) cin >> A[i];
    int next = 0;
    int cnt = 0;
    while(1) {
        if(used[next]) {
            cout << -1 << endl;
            return 0;
        }
        used[next] = 1;
        next = A[next] - 1;
        cnt++;
        if(next == 1)
            break;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	//declairring
	int n,q,c=0,tmp;
	//inputting
	cin >> n;
	int S[n];
	for(int i=0;i<n;i++){
		cin >> S[i];
	}
	cin >> q;
	for(int i=0;i<q;i++){//inputting&searching&counting
		cin >> tmp;
		if(binary_search(S,S+n,tmp))
			c++;
	}
	//outputting
	cout<< c << endl;
	return 0;
}

Measured memory_bytes: 1548
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

n,m = map(int, input().split())
l = [list(map(int,input().split())) for i in range(m)]

# n,mが10^5なのでO(n^2)は間に合わない
"""
ans = 0
for i in range(1,n+1):
    flg = True
    for j in range(m):
        if i < l[j][0] or i > l[j][1]:
            flg = False
    if (flg):
        ans+=1
print(ans)
"""

#lをO(m)で走査して上限、下限をあらかじめ確定しておく
up = 10**5+1
lo = 0

for i in range(m):
    if lo < l[i][0]:
        lo = l[i][0]
    if  up > l[i][1]:
        up = l[i][1]

ans = 0
for i in range(1,n+1):
    if i >= lo and i <= up:
        ans+=1
print(ans)




Measured memory_bytes: 27116
H, W = [int(i) for i in input().split()]
S = [[i for i in input().split()] for j in range(H)]

for h in range(H):
    for w in range(W):
        if S[h][w] == 'snuke':
            print(chr(ord('A') + w) + str(h + 1))
            exit()

Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
long long dp[1<<13][1005];
vector < int >vec;
int  c[1005];
int  n,m;
bool ones(int mask){
    if(mask+1==1<<(n))return true;
    return false;
}
int updatemask(int mask , int a){
    int p=mask;
    mask=mask|vec[a];
  if(mask==p)return -1;
  return mask;
}
long long solve(int a , int mask){
   if(a==m){
    if(ones(mask))return 0;
    return 10000000000;
   }
   if(dp[mask][a]!=0)return dp[mask][a];
   long long x=solve(a+1,mask);
   int maskupdate=updatemask(mask,a);
   if(maskupdate==-1)return x;
   return dp[mask][a]=min( c[a]+solve(a+1,maskupdate), x);

}
int main()
{
   // cin>>n>>m;
           int k;
           int o;
   scanf("%d %d",&n,&m);
    vec.resize(m);
    for(int i=0;i<m;i++){
        //cin>>c[i];
        scanf("%d",&c[i]);
        //cin>>k;
        scanf("%d",&k);
        int y=0;
        for(int j=0;j<k;j++){
           // cin>>o;
           scanf("%d",&o);
           y=y|(1<<(o-1));
        }
        vec[i]=y;
    }
    long long ans=solve(0,0);
    if(ans>=10000000000)cout<<-1;
    else cout<<ans;
    return 0;
}


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

void main()
{
    auto nq = readln.split.to!(int[]);
    auto N = nq[0];
    auto Q = nq[1];
    auto S = readln.chomp;
    auto cs = new int[](N);
    foreach (i; 1..N) {
        cs[i] += cs[i-1];
        if (S[i-1] == 'A' && S[i] == 'C') cs[i] += 1;
    }
    foreach (_; 0..Q) {
        auto lr = readln.split.to!(int[]);
        writeln(cs[lr[1]-1] - cs[lr[0]-1]);
    }
}

Measured memory_bytes: 4220
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N, K;
	vector<int> sun;
	
	cin>>N>>K;
	
	sun.resize(N);
	
	for(int i = 0; i < K; i++){
		int d;
		
		cin>>d;
		
		for(int j = 0; j < d; j++){
			int A;
			cin>>A;
			
			A--;
			
			sun[A]++;
		}
	}
	
	int ans = 0;
	
	for(int i = 0; i < N; i++) if(sun[i] == 0) ans++;
	
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>	
int main(void)
{
		int n,a,b,c,d;
		scanf("%d %d",&n,&a);
		b=n/500;
		c=n-(500*b);
		d=a-c;
		if(d>=0) printf("Yes\n",d);	
		else printf("No\n",d);
		return 0;		
}					

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<tuple>

using namespace std;
const int INF = (int)1e9;

int main(){
	int n, m, ans = 0;
	cin >> n >> m;
	vector<vector<int>> d(n + 1, vector<int>(n + 1, INF));
	vector<tuple<int, int, int>> e(m);
	for(int i = 0; i <= n; i++){
		d[i][i] = 0;
	}
	for(int i = 0; i < m; i++){
		int a, b, c;
		cin >> a >> b >> c;
		e[i] = tie(a, b, c);
		d[a][b] = c;
		d[b][a] = c;
	}
	for(int k = 1; k <= n; k++){
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	for(int i = 0; i < m; i++){
		int a, b, c;
		tie(a, b, c) = e[i];
		if(d[a][b] != c) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
s=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n=int(input())
print(s[n-1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll N;

int main() {
    cin >> N;
    ll ans = 0;
    if(N%2==0) {
        ll d = 5;
        while(d * 2 <= N) {
            ans += N / (d * 2);
            d *= 5;
        }
    }
    cout << ans << endl;
	return 0;
}

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

const int INF = 1e9;

template <typename T>
struct Dijkstra {
  struct Edge {
    int to;
    T cost;
  };
  vector<vector<Edge>> g;
  Dijkstra(int n) : g(n) {}

  void addEdge(int u, int v, T w) {
    g[u].push_back({v, w});
    g[v].push_back({u, w});
  }
  T build(int s, int t) {
    vector<T> dist(g.size(), -1);
    using Node = pair<T, int>;
    priority_queue<Node, vector<Node>, greater<Node>> pq;
    pq.push({dist[s] = 0, s});
    while (!pq.empty()) {
      T d;
      int u;
      tie(d, u) = pq.top();
      pq.pop();
      if (dist[u] < d) continue;
      for (auto&& v : g[u]) {
        if (dist[v.to] < 0 || dist[v.to] > dist[u] + v.cost) {
          dist[v.to] = dist[u] + v.cost;
          pq.push({dist[v.to], v.to});
        }
      }
    }
    return dist[t];
  }
};

int main() {
  int N, M, L, K, A, H;
  while (cin >> N >> M >> L >> K >> A >> H, N) {
    map<int, int> mp;
    mp[A] = 0;
    mp[H] = 1;
    int c = 2;
    REP(i, L) {
      int F;
      cin >> F;
      mp[F] = c++;
    }

    vector<vector<ll>> dist(N, vector<ll>(N, INF));
    REP(i, K) {
      int X, Y, T;
      cin >> X >> Y >> T;
      dist[X][Y] = dist[Y][X] = T;
    }
    REP(k, N) REP(i, N) REP(j, N) {
      dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }
    
    Dijkstra<ll> g(c);
    REP(i, N) REP(j, N) {
      if (i >= j) continue;
      if (mp.find(i) == mp.end()) continue;
      if (mp.find(j) == mp.end()) continue;
      g.addEdge(mp[i], mp[j], (dist[i][j] <= M) ? dist[i][j] : INF);
    }
    ll dt = g.build(mp[A], mp[H]);
    ll ans = (dt <= M) ? dt : dt * 2 - M;
    if (ans >= INF) {
      cout << "Help!" << endl;
    } else {
      cout << ans << endl;
    }
  }
}



Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
typedef pair<ll,ll> P;
const ll MO = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<vector<int>> dp(3,vector<int>(n+5));
    rep(i,n){
        if(i<1){
            rep(j,3)cin >>dp[j][i];
        }
        else{
            int a,b,c;
            cin >> a >> b >> c;
            dp[0][i] = max(dp[1][i-1]+a,dp[2][i-1]+a);
            dp[1][i] = max(dp[2][i-1]+b,dp[0][i-1]+b);
            dp[2][i] = max(dp[0][i-1]+c,dp[1][i-1]+c);
        }
    }    
    // rep(i,3){
    //     rep(j,n)cout << dp[i][j] << " ";
    //     cout << endl;
    // }
    cout << max(max(dp[0][n-1],dp[1][n-1]),dp[2][n-1]) << endl;
    return 0;
}

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

int main(int argc, const char * argv[]) {
    
    while(true){
        int H,W;
        cin >> H >> W;
        if(H == 0 && W == 0){
            break;
        }
        
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if((i+j) % 2 == 0){
                    cout << "#";
                }
                else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    if(x == w/2 && y == h/2){
        double a = w*h;
        double ans = a/2;
        cout << ans << " " << 1 << endl;
    }else{
        double a = w*h;
        double ans = a/2;
        cout << ans << " " << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 3772
#関数を持ってくる
from collections import deque

#入力
n,m = map(int,input().split())
ab_list = [list(map(int,input().split())) 
           for nesya in range(m)]

#roomのリストを作る
room = [0]*n

#ある部屋に繋がっている部屋のリストを作り、入れる
route = [[] for motsu in range(n)]
for ab in ab_list:
  a = ab[0]
  b = ab[1]
  route[a-1].append(b)
  route[b-1].append(a)

d = deque()
d.append(1)
while len(d) > 0:
  s = d.popleft()
  s_list = route[s-1]
  for h in s_list:
    if room[h-1] != 0:
      continue
    room[h-1] = s
    d.append(h)
ans = room[1:]
if 0 in ans:
  print('No')
else:
  print('Yes')
  for w in ans:
    print(w)

Measured memory_bytes: 58736
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Dhanin Gupta
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CReplacingInteger solver = new CReplacingInteger();
        solver.solve(1, in, out);
        out.close();
    }

    static class CReplacingInteger {
        public void solve(int testNumber, InputReader in, PrintWriter w) {

            long n = in.nextLong();
            long k = in.nextLong();

            long x1 = n % k;
            long x2 = Math.abs(k - x1);
            w.println(Long.min(x1, x2));
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22100
def extEuclid(x, y, debug=False):
    """
    Param:
        x, y - coeffcients
        debug - print an equation
    Return:
        a tuple of integer (a, b) satisfying xa + yb = 1
    """
    changed = False
    if x < y:
        tmp = x
        x = y
        y = tmp
        changed = True
    if x % y == 0:
        raise ValueError("extEuclid: x, y not coprime or x = 1 or y = 1")
    
    alist = [x]
    blist = [y]
    a,b = x,y
    q = a // b
    r = a % b
    qlist = [q]
    rlist = [r]
    while r != 0:
        a = b
        b = r
        q = a//b
        r = a%b
        alist.append(a)
        blist.append(b)
        qlist.append(q)
        rlist.append(r)
    N = len(qlist)

    if rlist[N-2] != 1:
        raise ValueError("extEuclid: x, y not coprime")
    
    s = [1]
    t = [-qlist[N-2]]
    for i in range(N-2):
        s.append(t[i])
        t.append(s[i]+t[i]*(-qlist[N-3-i]))
    
    if(debug):
        print("("+str(x)+")*("+str(s[len(s)-1])+")+("+str(y)+")*("+str(t[len(t)-1])+") = 1")
    
    if not changed:
        return (s[len(s)-1], t[len(t)-1])
    else:
        return (t[len(t)-1], s[len(s)-1])

N, K = map(int,input().split())
mod = 10**9+7
f = [None for i in range(N+1)] # fs[i] = i!
for i in range(N+1):
    if i == 0:
        f[i] = 1
    else:
        f[i] = (f[i-1] * i) % mod

def inv(x):
    res = 1
    k = mod - 2
    y = x
    while k:
        if (k & 1):
            res = (res * y) % mod
        y = (y * y) % mod
        k //= 2
    
    return res

def conb(n, k):
    fn = f[n]
    fm = f[n-k]
    fk = f[k]

    fmk = (fm * fk) % mod

    return (fn * inv(fmk)) % mod
for i in range(1, K+1):
    if N - K + 1 < i:
        print(0)
    else:
        print(conb(N-K+1, i)*conb(K-1, i-1) % mod)


Measured memory_bytes: 3572