akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

inline ll input() {
    ll n;
    cin >> n;
    return n;
}

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

set_random;

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD1 = 998244353;
const ll MOD2 = 1e9 + 7;
const ll MOD3 = 1e9 + 9;

vector<ll> ts , adj[MAXN];
ll n , m , inDeg[MAXN] , dp[MAXN];

void topoSort() {
    queue<ll> q;

    for(ll i = 1 ; i <= n ; i++)
    {
        if(!inDeg[i])
        {
            q.push(i);
        }
    }

    while(!q.empty())
    {
        ll v = q.front();
        q.pop();
        ts.push_back(v);

        for(ll u : adj[v])
        {
            inDeg[u]--;
            if(!inDeg[u])   q.push(u);
        }
    }
}

int main() {
    fast_io;

    cin >> n >> m;
    for(ll i = 0 ; i < m ; i++)
    {
        ll v , u;
        cin >> v >> u;
        adj[v].push_back(u);
        inDeg[u]++;
    }

    topoSort();
    for(ll v : ts)
    {
        for(ll u : adj[v])
        {
            dp[u] = max(dp[u] , dp[v] + 1);
        }
    }

    cout << *max_element(dp , dp + MAXN) << endl;

    return 0;
}
/*
todo :
    1- set constants
    2- check TimeLimit and MemoryLimit
    3- check special test cases
    4- don't forget BS can help you that is good idea(use for loop for floats)
    5- don't forget printf and scanf can help you in your code speed
*/


Measured memory_bytes: 33908
n=input()
a=[map(int,raw_input().split()) for _ in xrange(n)]
z=[[0]*3 for _ in xrange(n)]
z[0]=a[0]
for i in xrange(1,n):
    for j in xrange(3):
        for k in xrange(3):
            if j!=k:
                z[i][j]=max(z[i][j],z[i-1][k]+a[i][j])
print max(z[-1])

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HIGHINF = (ll)1e18;
const ll LOWINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;

template<typename T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template<typename... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
    int N, K; cin >> N >> K;
    cout << (K==1?0:N - K) << endl;




    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Math;

namespace abc126A
{
    class Program
    {
        static void Main(string[] args)
        {

            string a = Console.ReadLine();
            string b = "";
            for (int i = 0; i < a.Length-1; i++)
            {
                b = b + a[i]; 
            }
            string aa = a[a.Length-1].ToString();
            if (aa != "s") { Console.WriteLine(a + "s"); }
            else { Console.WriteLine(a + "es"); }
            //long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
            //long[] b = new long[4] { a[0] * a[2], a[0] * a[3], a[1] * a[2], a[1] * a[3] };
            //Array.Sort(b);
            //Console.WriteLine(b[3]);

        }
    }
}


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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	lli ans = 0;
	for(int i=0;i<n;i++){
		if(a[i]%2==0){
			ans+=a[i]/2;
		} else if(a[i]%2 == 1){
			ans+=a[i]/2;
			if(i+1<n && a[i+1] >= 1){
				a[i]--;
				a[i+1]--;
				ans++;
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef long long int ll;
 
#define endl '\n'
#define int ll

ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}
int n;
int a[501];
int dp[501][501];
int ans(int l,int r)
{
    int &res=dp[l][r];
    if(res!=-1)
        return res;
    if(l==r)
    {
        return res=0;
    }
    res=a[r]-a[l-1];
    int temp=1e18;
    for(int i=l;i<r;++i)
    {
        temp=min(temp,ans(i+1,r)+ans(l,i));
    }
    res+=temp;
    //cout<<l<<" "<<r<<" "<<res<<endl;
    return res;
}

int32_t main()
{
    IOS
   
  
    cin>>n;
    a[0]=0;
    for(int i=1;i<=n;++i)
        cin>>a[i],a[i]+=a[i-1];
    memset(dp,-1,sizeof(dp));

    cout<<ans(1,n)<<endl;
    //cout<<dp[2][5]<<endl;
}



Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int> a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(), (a).end()

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

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

ll keta(ll n)
{
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1, 0, -1, 0};
const int dw[4] = {0, 1, 0, -1};

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

class UnionFind
{
public:
  vi Parent;
  UnionFind(int n)
  {
    Parent = vi(n, -1);
  }

  int root(int a)
  {
    if (Parent[a] < 0)
      return a;
    else
      return Parent[a] = root(Parent[a]);
  }

  int size(int a)
  {
    return -Parent[root(a)];
  }

  bool merge(int a, int b)
  {
    a = root(a);
    b = root(b);
    if (a == b)
      return false;

    if (size(a) < size(b))
      swap(a, b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial
{
public:
  vl Fac;
  Factrial(int MAX)
  {
    Fac = vl(MAX + 1);
    rep(i, MAX)
    {
      if (i == 0)
        Fac[i + 1] = 1;
      else
        Fac[i + 1] = ((i + 1) * Fac[i]) % MOD;
    }
  }
};

ll n,m;
vl a;
vl s;
bool check(ll K){
  ll H = 0;
  // a[i] + a[j] >= K なる(i,j)の個数 H を求める
  rep(i,n) {
    // A[j] >= K - a[i] なる j の個数 h を求める
    int j = lower_bound(all(a),K-a[i]) - a.begin();
    int h = n-j;
    H += h;
  }
  //printf("K:%lld H:%lld\n", K, H);
  return H <= m;
}

int main(){
  cin >> n >> m;
  a.resize(n);
  rep(i,n) cin >> a[i];
  sort(all(a));

  s.resize(n+1);
  rep(i,n) s[i+1] = s[i] + a[i];


  ll ok = 2e5 + 1, ng = -1;
  while (abs(ng-ok)>1){
    ll mid = (ok+ng)/2;
    if(check(mid)) ok = mid;
    else ng = mid;
  }
  
  ll K = ok;

  //printf("K:%lld\n", K);
  
  ll ans = 0;
  ll cnt = 0; // 実際に何回握手をしたかを計数
  rep(i,n) {
    int j = lower_bound(all(a),K-a[i]) - a.begin();
    if(j == n) continue;
    //printf("a[%d]:%lld a[%d]:%lld\n", i, a[i], j, a[j]);
    //printf("s[%lld]:%lld s[%d]:%lld\n", n, s[n], j, s[j]);
    //cout << s[n] - s[j] << endl;
    cnt += n-j;
    ans += a[i]*(n-j) + (s[n] - s[j]);
    //cout << ans << endl;
  }

  //cout << cnt << endl;
  //握手の回数が足りなかったら残りは幸福度を K-1 あげる握手をする
  if(m - cnt > 0){
    ans += (m - cnt) * (K-1);
  }

  cout << ans << endl;

}

Measured memory_bytes: 1920
#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 repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int N; cin >> N;
  vi H(N); rep(i,N) cin >> H.at(i);
  
  int ans = 0;
  rep(i,N) {
    bool is_candidate = true;
    rep(j,i) {
      if (H.at(j) > H.at(i)) {
        is_candidate =false;
        break;
      }
    }
    
    if (is_candidate) ans++;
  }
  
  cout << ans << endl;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

ll baisuu_atob(ll a, ll b, ll x){
    if(a % x > 0) a += x - (a % x);
    b -= a;
    if(b < 0) return 0;
    else return b/x + 1;
}

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

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

int main(void){
    ll N, M; cin >> N >> M;
    ll upplim = 1000000000+1;
    ll A[N]; rep(i, N) cin >> A[i];
    rep(i, N) A[i] /= 2;
    ll lcm_A = 1;
    rep(i, N){
        lcm_A = lcm(lcm_A, A[i]);
        if(lcm_A >= upplim){
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i, N){
        if((lcm_A / A[i]) % 2 == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    //lcm_Aの奇数倍が1からMまでにいくつあるか
    ll ans = (M / lcm_A + 1) / 2;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
struct node
{
    int l;
    int r;
};
node a[100500]= {0};
bool cmp(node a,node b)
{
    if(a.l!=b.l)
        return a.l<b.l;
    else
        return a.r<b.r;
}
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        cin>>a[i].l>>a[i].r;
    }
    sort(a,a+m,cmp);
    long long int sum=1;
    int zd=a[0].r;
    for(int i=1;i<m;i++)
    {
        if(a[i].l>=zd)
        {
            sum++;
            zd=a[i].r;
        }
        else
        zd=min(a[i].r,zd);
    }
    cout<<sum<<endl;
    return 0;
}


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

struct Rectangle
{
	int h;
	int w;
};

int main(){
	vector<Rectangle> nums;
	Rectangle rec;
	int i,j,k;
	while(cin>>rec.h>>rec.w){
		if(rec.h==0 && rec.w==0) break;
		nums.push_back(rec);
	}
	for(i=0; i<nums.size(); i++){
		for(j=0; j<nums[i].h; j++){
			for(k=0; k<nums[i].w; k++){
				cout<<"#";
			}
			cout<<"\n";
		}
		cout<<"\n";
	}
	return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n,cnt,ans=0;
  string c;
  cin>>n>>c;
  cnt=count(c.begin(),c.end(),'W');
  for(int i=0;i<n;i++){
    if(c[i]=='W' && i<n-cnt) ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3724
S = input()
T = input()
s_pairs = [-1] * 26
t_pairs = [-1] * 26

def convert_alphabet_to_int(s):
  return ord(s) - ord('a')

# ペアの要素が別の文字位置でも成り立たない箇所が1つでもあれば終了
for i, s in enumerate(S):
  t = T[i]
  int_s = convert_alphabet_to_int(s)
  int_t = convert_alphabet_to_int(t)
  if s_pairs[int_s] >= 0:
    if s_pairs[int_s] != int_t:
      print('No')
      exit()
  else:
    s_pairs[int_s] = int_t
  
  if t_pairs[int_t] >= 0:
    if t_pairs[int_t] != int_s:
      print('No')
      exit()
  else:
    t_pairs[int_t] = int_s
print('Yes')
    
  

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define loop(i, n) for(int i = 0; i < int(n); i++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;

int N = 7;

bool calculate(int* num, int* op) {
  int sum = num[0];
  loop(i, 3) op[i] == 0 ? sum += num[i + 1] : sum -= num[i + 1];
  return sum == N ? true : false;
}

int main() {
  int S, num[4], op[3];
  bool is_OK = false;
  cin >> S;

  loop(i, 4) {
    num[3-i] = S % 10;
    S /= 10;
  }

  loop(i, 2) {
    if (is_OK) break;
    i == 0 ? op[0] = 0 : op[0] = 1;
    loop(j, 2) {
      if (is_OK) break;
      j == 0 ? op[1] = 0 : op[1] = 1;
      loop(k, 2) {
        if (is_OK) break;
        k == 0 ? op[2] = 0 : op[2] = 1;
        is_OK = calculate(num, op);
      }
    }
  }

  loop(i, 4) {
    cout << num[i] << (i == 3 ? '=' : (op[i] == 0 ? '+' : '-'));  
  }
  cout << N << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
int X;
int D;
string S,T;
vector<int> A;
vector<int> B;
//=============================
void input()
{
    cin>>N;
    cin>>D>>X;
    A.resize(N);
    rep(i,0,N-1){
        cin>>A[i];
    }

}
//=============================
void func(){}
//=============================
void solve()
{
    vector<int> eat;

    rep(i,0,N-1){
        int a = A[i];
        for(int j=0; ((a*j+1)<=D); ++j){
            eat.push_back(a*j+1);
        }
    }

    cout<<eat.size()+X<<endl;


}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define sh cin.tie(0); cin.sync_with_stdio(0); cout.tie(0);
#define FILE freopen("test.in", "r", stdin);
#define vprint(v) for (int ii = 0; ii < v.size(); ii++){cout << v[ii] << " ";}
#define debugv(v) if (v.size() != 0) {cout << "[ "; for (int __ = 0; __ < (int)(v.size()) - 1; __++){cout << v[__] << ", ";} cout << v[(int)(v.size()) - 1] << " ]" << endl;} else {cout << "[]" << endl;}
#define debug cout << "-----------------------------------------------" << endl;
#define print1(a) cout << "{ " << a << " }" << endl;
#define print2(a, b) cout << "{ " << a << ", " << b << " }" << endl;
#define print3(a, b, c) cout << "{ " << a << ", " << b << ", " << c << " }" << endl;
#define print4(a, b, c, d) cout << "{ " << a << ", " << b << ", " << c << ", " << d << " }" << endl;
using namespace std;
//#define int long long
const int INF = 1e9 + 228;
const int MAXN = 1e5 + 228;
map<string, int> mapa;
signed main()
{
#ifdef LOCAL
    FILE;
#endif
    sh;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		mapa[s]++;
	}
	int mx = 0;
	for (auto to : mapa) {
		mx = max(to.S, mx);
	}
	vector<string> v;
	for (auto to : mapa) {
		if (to.S == mx) {
			v.pb(to.F);
		}
	}
	sort(all(v));
	for (auto to : v) {
		cout << to << endl;
	}
    return 0;
}


Measured memory_bytes: 25584
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    cin>>a;
    cout << a*a*3<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;

typedef pair <int, int> pii;
typedef long long ll;

const ll inf = 1e15 + 1;
const double eps = 1e-9;
const int MAXN = 1e5 + 1;

int n, k;
int h[MAXN];
ll dp[MAXN];

int main(){

    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> h[i];
    for (int i = 0; i < n; i++) dp[i] = inf;
    dp[0] = 0;
    for (int i = 0; i < n-1; i++){
        for (int j = 1; j <= k; j++){
            if (i+j < n) dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j]));
        }
    }
    cout << dp[n-1];

    return 0;

}


Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int a,b;
    cin >> a >> b;
    if (a == 1) a += 13;
    if (b == 1) b += 13;

    string ans = "Draw";
    if (a > b) ans = "Alice";
    if (a < b) ans = "Bob";

    cout << ans << endl;
}

Measured memory_bytes: 632
def main():
    N, M = list(map(int, input().split()))
    proc_list = [list(map(lambda z: int(z) - 1, input().split())) for _ in range(M)]
    counter = [1] * N
    red_flag = [0] * N
    red_flag[0] = 1
    for from_box, to_box in proc_list:
        if red_flag[from_box] == 1:
            if counter[from_box] == 1:
                red_flag[from_box] = 0
            red_flag[to_box] = 1
        counter[from_box] -= 1
        counter[to_box] += 1
    print(sum(red_flag))


if __name__ == '__main__':
    main()

Measured memory_bytes: 28676
r,c=map(int,input().split())
a=[0]*(c+1)

for i in range(r):
    li=list(map(int,input().split()))
    for j in range(c):
        a[j]+=li[j]
    a[c]+=sum(li)
    li.append(sum(li))
    l=[str(a) for a in li]
    l=" ".join(l)
    print(l)
a=[str(b) for b in a]
a=" ".join(a)
print(a)


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
// =======================
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long int
#define ull unsigned long long int 
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ss second
#define setbits(x) _builtin_popcount(x)
#define parity(x) _builtin_parity(x)
#define leadzero(x) __builtin_clz(x)
#define trailzero(x) __builtin_ctz(x)
#define endl "\n"
#define elif else if
// =======================
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
typedef map<int, int> mii;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0,lim-1);
  return uid(rang);
}
int mpow(int base, int exp); 
void yes(){ cout << "YES\n"; }
void no(){  cout << "NO\n";  }

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
// =======================
vi a,dp;
int n;
void solve() {
  cin >> n;
  a = vi(n+1);
  Fo(i,1,n+1) cin >> a[i];
  dp = vi(n+1,-1);
}

int cost(int i){
  if(i==1)  return 0;
  if(dp[i]!=-1)  return dp[i];
  dp[i] = INT_MAX;
  if(i-1>=1)  dp[i] = min( dp[i], cost(i-1) + abs(a[i]-a[i-1]) );
  if(i-2>=1)  dp[i] = min( dp[i], cost(i-2)+ abs(a[i]-a[i-2]));
  return dp[i];
}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
      cout << cost(n);
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}


Measured memory_bytes: 7104
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool Finish_read;
template<class T>
inline void read(T &x) {
	Finish_read=0;x=0;int f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x*=f;Finish_read=1;
}
template<class T>
inline void print(T x) {
	if(x/10!=0)
		print(x/10);
	putchar(x%10+'0');
}
template<class T>
inline void writeln(T x) {
	if(x<0)
		putchar('-');
	x=abs(x);
	print(x);
	putchar('\n');
}
template<class T>
inline void write(T x) {
	if(x<0)
		putchar('-');
	x=abs(x);
	print(x);
}
/*================Header Template==============*/
string s,n="";
int ans=0;
int main() {
	cin>>s;
	for(int i=0;i<s.length();i++)
		if(s[i]!='x')
			n+=s[i];
	for(int i=0,j=n.length()-1;i<=j;i++,j--)
		if(n[i]!=n[j]) {
			puts("-1");
			return 0;
		}
	for(int i=0,j=s.length()-1;i<=j;) {
		if(s[i]==s[j]) {
			i++;
			j--;
			continue;
		}
		if(s[i]=='x') {
			ans++;
			i++;
		}
		if(s[j]=='x') {
			ans++;
			j--;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = l[0], B = l[1], C = l[2];

            if (A + B >= C)
                Console.WriteLine(B + C);
            else
                Console.WriteLine(A + B + B + 1);
        }
    }
}


Measured memory_bytes: 13396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		System.out.println(n <= m ? "unsafe" : "safe");
	}

	static class FastScanner {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public String nextLine() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					return reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}

			return tokenizer.nextToken("\n");
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
	}
}

Measured memory_bytes: 32732
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define mo 1000000007
LL L,R;int f[61][2][2][2];
int cal(int x,int a,int b,int c){
	/* a±íÊ¾Ç°ÃæÊÇ·ñÓÐÄ³Î»x>L
		b±íÊ¾ÊÇ·ñÓÐÄ³Î»y<R
		c±íÊ¾Ç°ÃæÊÇ·ñÓÐ1 
	*/
	if(x<0)return 1;
	if(f[x][a][b][c])return f[x][a][b][c];
	int l=(L>>x)&1,r=(R>>x)&1,&ans=f[x][a][b][c];
	if(a)l=0;if(b)r=1;
	for(int i=l;i<2;i++)for(int j=i;j<=r;j++){
		if(c)(ans+=cal(x-1,a|(i>l),b|(j<r),c))%=mo;
		else if((i^j)==0)(ans+=cal(x-1,a|(i>l),b|(j<r),(i==1)))%=mo;
	}
	return ans;
}
int main(){
	scanf("%lld%lld",&L,&R);
	printf("%d",cal(60,0,0,0));
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll t,i,j,k,n;
   string s,st;
   cin>>s>>st;
   k=0;
   for(i=0;i<s.length();i++)
   {
       if(s[i]!=st[i])
       {
           k++;
       }
   }
   cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 3920
#include<stdio.h>

int main(void){
  char a[4],b[4];

  scanf("%s %s",a,b);

  if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])
    printf("YES\n");
  else
    printf("NO\n");
  

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
  putchar(getchar());
  putchar(getchar());
  putchar(getchar());
  putchar(getchar());
  putchar(getchar());
  getchar(); putchar(32);
  putchar(getchar());
  putchar(getchar());
  putchar(getchar());
  putchar(getchar());
  putchar(getchar());
  putchar(getchar());
  putchar(getchar());
  getchar(); putchar(32);
  putchar(getchar());
  putchar(getchar());
  putchar(getchar());
  putchar(getchar());
  putchar(getchar());
  putchar(10);
}


Measured memory_bytes: 128
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
//#define mp make_pair
#define pb push_back
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pdi pair<double, int>
#define pdd pair<double, double>
#define mem(a, b) memset(a, b, sizeof(a))
#define debug(x) cerr << #x << " = " << x << "\n";
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//head

const int N = 22;
int a[N], b[N], n;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
	for (int i = 0; i < n; ++i) scanf("%d", &b[i]);
	int ans = INT_MIN;
	for (int i = 0; i < (1<<n); ++i) {
		int x = 0, y = 0;
		for (int j = 0; j < n; ++j) {
			if(i&(1<<j)) {
				x += a[j];
				y += b[j];
			}
		} 
		ans = max(ans, x-y);
	}
	printf("%d\n", ans);
	return 0;
}

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

ll		betw(ll n, ll x)
{
	ll ans;
	
	if (n >= 0)
		ans = n / x + 1;
	else
		ans = 0;
	return (ans);
}

int		main(void)
{
	ll a, b, x;

	cin >> a >> b >> x;
	ll ans = 0;

	ans = betw(b, x) - betw(a - 1, x);
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x=n%10;
  int y=n%100;
  int z=n%1000;
  if(x==7) {
    cout << "Yes" << endl;}
  else if(y>=70 && y<80) {
    cout << "Yes" << endl;}
  else if(z>=700 && z<800) {
    cout << "Yes" << endl;}
  else {
    cout << "No" << endl;}
  return 0;
  }
    
    
  


Measured memory_bytes: 3632
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		//要素数３の配列を宣言
		int[] array = new int[3];

		Scanner sc = new Scanner(System.in);
		//配列に入力した数値を格納
		array[0] = sc.nextInt();
		array[1] = sc.nextInt();
		array[2] = sc.nextInt();

		for(int i = 0 ;i < array.length-1 ;i++){
			//比較する対象分繰り返す
			for(int j = 0;j < array.length-1 ;j++){
				//配列のjとj+1の要素を比較し,j+1>jならば数値を入れ替える
				if(array[j] > array[j+1]){
					int intChange = array[j];
					array[j] = array[j+1];
					array[j+1] = intChange;
				}
			}
		}
		//並び替えたものを出力
		System.out.println(array[0] + " " + array[1] + " " + array[2]);
	}
}



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

#define int long long
#pragma GCC optimize ("O3")
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;
typedef tree<pii,null_type,less <pii>,rb_tree_tag,tree_order_statistics_node_update>ind_set;
*/
///*X.find_by_order("index")
///X.order_of_key("key")


#define deb(x) cerr<<#x<< " : " <<x<<"\n";
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------


void solve()
{
	int n,w[150];
	cin>>n;rep(i,0,n)cin>>w[i];

	int ans=INT_MAX;
	rep(i,0,n-1)
	{
		int s1=0,s2=0;
		rep(j,0,i+1)s1+=w[j];
		rep(j,i+1,n)s2+=w[j];
		ans=min(ans,abs(s1-s2));
	}
	cout<<ans<<"\n";


}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    #ifdef local
    freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    #endif

    clock_t qwertyuiop = clock();
    int t=1;
    ///cin>>t;
    rep(a,0,t)
    {
        ///    cout<<"Case #"<<a+1<<": ";
        solve();
    }
    {qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,m,i,j,x,k,z=10000,W,B,R;
	char a[1000][1000];
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%s",a[i]);
	}	
	W=0;
	for(i=0;i<n-2;i++){
		for(x=0;x<m;x++){
			if(a[i][x]!='W'){
				W++;
			}
		}
		B=0;
		for(j=i+1;j<n-1;j++){
			for(x=0;x<m;x++){
				if(a[j][x]!='B'){
					B++;
				}
			}
		R=0;
			for(k=j+1;k<n;k++){
				for(x=0;x<m;x++){
					if(a[k][x]!='R'){
						R++;
					}
				}
			}
		if(z>W+B+R){
			z=W+B+R;
		}	
		}
	}
	printf("%d\n",z);
}

Measured memory_bytes: 2760
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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 EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n, k; cin >> n >> k;
	string s; cin >> s;

	for (int i = 0; i < s.size(); i++) {
		if (i == k - 1) {
			if (s[i] == 'A') {
				cout << 'a';
			}

			if (s[i] == 'B') {
				cout << 'b';
			}

			if (s[i] == 'C') {
				cout << 'c';
			}
		}
		else {
			cout << s[i];
		}
	}

	cout << endl;

	return 0;
}

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

int main() {
  double W, H, x, y;
  cin >> W >> H >> x >> y;


  double area = (W*H) / 2;
  int g = (x*2 == W && y*2 == H) ? 1: 0;
  cout << area << " " << g << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){
	int n;
	int a[51000];
	int b;
	int i, j, p;
	int c[10000][3];
	p = 0;
	while (scanf("%d", &n) != EOF){
		c[p][0] = n;
		p++;
	}
		b = (int)pow(51000.0, 0.5);
		a[0] = -1;
		for (i = 2; i <= b; i++){
			for (j = 2; j <= 51000/ i; j++){
				a[i*j - 1] = -1;
			}
		}
	
	for (i = 0; i < p; i++){
		for (j = 1; j < 1000; j++){
			if (a[c[i][0] + j-1] != -1){ 
				c[i][1] = c[i][0] + j; 
				j = 1000;
			}
		}
		for (j = 1; j < 1000; j++){
			if (a[c[i][0] - j-1] != -1){
				c[i][2] = c[i][0] - j;
				j = 1000;
			}
		}
		printf("%d %d\n", c[i][2], c[i][1]);
	}

	return 0;
}

Measured memory_bytes: 800
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	llint i,n,wa=0,sa=big;cin>>n;
	vector<llint>A(n);
	for(i=0;i<n;i++){
		llint x;cin>>x;
		wa+=x;A[i]=wa;
	}
	for(i=0;i<n;i++){mineq(sa,abs(wa-A[i]-A[i]));}
	cout<<sa<<endl;
	return 0;
}


Measured memory_bytes: 1792
n,m,c = list(map(int, input().split()))
b = list(map(int, input().split()))
a = []
for i in range(0,n) :
    a.append(list(map(int, input().split())))
count = 0
for j in range(n) :
    s = 0
    for i in range(0,m) :
        s += b[i] * a[j][i]
    s += c
    if s > 0 :
        count += 1
print(count)


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


int main() {

    int n;
    string s, x, y;
    cin >> n >> s;
    int ans = 0;
    for (int i = 1; i < n; ++i) {
        x = s.substr(0, i);
        y = s.substr(i, n-i);
        int res = 0;
        for (int j = 0; j < 26; ++j) {
            char S = 'a' + j;
            if (x.find(S) != std::string::npos && y.find(S) != std::string::npos) {
                ++res;
            }
        }
        ans = max(ans, res);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int total = 0;
        int max = -1;
        for (int i = 0; i < 3; i++) {
            int a = sc.nextInt();
            max = Math.max(a, max);
            total += a;
        }
        int k = sc.nextInt();
        total += (int)Math.pow(2, k) * max;
        total -= max;

        System.out.println(total);
    }
}


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

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());




int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    int res = 0;
    ff(i,1,n){
        int x;
        cin >> x;
        if(i%2 == 1 && x%2 == 1)res++;
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

int main() {
	ll n, m;
	cin >> n >> m;
	n--, m--;
	wrln(n*m);
	return 0;
}

Measured memory_bytes: 256
#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++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    if( a.back() == b[0] and b.back() == c[0] ) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

int main()
{
  int N,W;
  cin >> N;
  vector<int> vec_W(N);
  for (int i = 0;i < N;i++)
  {
    cin >> W;
    if (i == 0)
    {
      vec_W.at(i) = W;
    }
    else
    {
      vec_W.at(i) = vec_W.at(i-1) + W;
    }
  }
  int maxnum = 100000;
  for (int x:vec_W)
  {
    if (maxnum > abs(x*2 - vec_W.at(N-1)))
    {
      maxnum = abs(x*2 - vec_W.at(N-1));
    }
  }
  cout << maxnum << endl;
}


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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,m;

int has[1<<16],nm[1<<16];

int f[1<<16];

void Work(){
	for(int sta=0;sta<1<<n;sta++)nm[sta]=nm[sta>>1]+(sta&1);
	f[0]=1;
	for(int sta=0;sta<1<<n;sta++)if((sta&3)==3||(sta&3)==0){
		for(int s=sta;s;s=(s-1)&sta){
			int ans=1;
			REP(i,1,n)if(((sta^s)>>i-1)&1)ans=1LL*ans*(fexp(2,nm[has[i]&s])-1)%mod;
			int tmp=0;
			REP(i,1,n)if((s>>i-1)&1)tmp+=nm[has[i]&(sta^s)];
//			if(ans&&f[sta^s])cout<<sta<<' '<<s<<' '<<1LL*f[sta^s]*ans%mod*fexp(2,tmp)<<' '<<tmp<<endl;
			f[sta]=(f[sta]+1LL*f[sta^s]*ans%mod*fexp(2,tmp))%mod;
		}
//		cout<<sta<<' '<<f[sta]<<endl;
	}
	iout((fexp(2,m)-f[(1<<n)-1]+mod)%mod);
}

void Init(){
	read(n,m);
	REP(i,1,m){
		int u,v;
		read(u,v);
		has[u]|=1<<v-1;
	}
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define ll long long
#define mp map<int,int>
using namespace std;
int main() {
	int l,r;
	ll small=1e9*2+1;
	cin>>l>>r; 
	if(r-l>=2019) {
	    cout<<0;
	    return 0;
    }
    r%=2019,l%=2019;
	if(r<l) {
		cout<<0;
		return 0;
	}
	rep(i,l,r-1) rep(j,i+1,r)
		if(i*j%2019<small) small=i*j%2019;
	cout<<small;
	return 0;
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
x = int(input())

count = 0
for i in range(a+1):
  for j in range(b+1):
    for t in range(c+1):
      if (500*i+ 100*j+ 50*t) == x:
        count += 1

print(count)

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

using namespace std;
// using namespace __gnu_pbds;

#define ford(i, a, b, c)        for(int i=(a); i<(b); i+=(c))
#define fori(i, a, b)           ford(i,a,b,1)
#define rep(i, n)               fori(i,0,n)
#define ifor(i, a, b)           for(int i=(a); i>=(b); i--)
#define si(x)                   ((int)x.size())
#define SS                      ({int x;scanf("%d",&x);x;})
#define pb                      push_back
#define mp                      make_pair
#define all(a)                  a.begin(),a.end()
#define inf                     (int)1e9
#define linf                    (long long)1e18
#define V                       vector
#define S                       string
#define XX                      first
#define YY                      second
#define PVI(v)                  rep(i, si(v)) cout<<v[i]<<" "; puts("")
#define PPI(p)                  cout<<"("<<p.first<<", "<<p.second<<")\n"
#define PVPI(v)                 rep(i, si(v)) cout<<"("<<v[i].first<<", "<<v[i].second<<")"<<(i==si(v)-1?"":", ");puts("")
#define PA(arr1, arr2)          for(auto it = arr1; it != arr2; it++) cout<<*it<<" "; puts("");

typedef V<int> vi;
typedef V<S> vs;
typedef long long ll;
typedef pair<int,int> pii;
const int MOD7 = 1000000000+7;
const int MOD9 = 1000000000+9;
/* ################### Program Body starts here ################ */


V<pii> g[50];
pii p[20];
ll paths[50][50];

void dfs(int source, int node, ll edges, vi& vis) {
    if (vis[node]) return;
    vis[node] = 1;
    paths[source][node] = edges;
    for (auto pr : g[node]) {
        int newNode = pr.XX, edgeIndex = pr.YY;
        if (!vis[newNode]) {
            edges |= 1LL<<edgeIndex;
            dfs(source, newNode, edges, vis);
            edges -= 1LL<<edgeIndex;
        }
    }
}
int numBits(ll s) {
    int ans = 0;
    while (s) {
        ans += s & 1;
        s >>= 1;
    }
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    int n = SS;
    rep(i, n-1){
        int x = SS, y =  SS;
        x--;y--;
        g[x].pb({y, i});
        g[y].pb({x, i});
    }
    int m = SS;
    rep(i, m) {
        p[i].XX = SS - 1;
        p[i].YY = SS - 1;
    }
    
    rep(i, n) {
        vi vis(n);
        ll edges = 0;
        dfs(i, i, edges, vis);
    }
 //   cout<<si(paths[0][1])<<"\n";
    ll ans = 1LL<<(n-1);
    fori(mask, 1, (1<<m)) {
        int bc = __builtin_popcount(mask);
        ll s = 0;
        rep(i, m) {
            if(mask & (1<<i)) {
                s |= paths[p[i].XX][p[i].YY];
            }
        }
        ll cnt = 1LL<<(n-1-(numBits(s)));
        if (bc % 2) {
            ans -= cnt;
        } else {
            ans += cnt;
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 256